Android 13 关闭相册的编辑功能

介绍

因为做的是学生机,客户不希望相册的图片可以编辑。

分析

通过字符串我们找到了几个资源文件,以下只展示其中一个

路径:vendor/mediatek/proprietary/packages/apps/Gallery2/res/menu/operation.xml

XML 复制代码
    <item android:id="@+id/action_edit"
            android:title="@string/edit"
            android:showAsAction="never"
            android:visible="false" />

接着我们通过id排查,看是由哪个JAVA文件调用了该ID,到这里我们发现是在updateSupportedMenuEnabled调用了该项,这里有个if条件supportEdit,这里是通过MediaObject.SUPPORT_EDIT的值来判断是否启用。

路径:vendor/mediatek/proprietary/packages/apps/Gallery2/src/com/android/gallery3d/ui/MenuExecutor.java

java 复制代码
    public static void updateSupportedMenuEnabled(Menu menu, int supported, boolean enabled) {
        boolean supportDelete = (supported & MediaObject.SUPPORT_DELETE) != 0;
        boolean supportRotate = (supported & MediaObject.SUPPORT_ROTATE) != 0;
        boolean supportCrop = (supported & MediaObject.SUPPORT_CROP) != 0;
        boolean supportShare = (supported & MediaObject.SUPPORT_SHARE) != 0;
        boolean supportSetAs = (supported & MediaObject.SUPPORT_SETAS) != 0;
        boolean supportShowOnMap = (supported & MediaObject.SUPPORT_SHOW_ON_MAP) != 0;
        boolean supportCache = (supported & MediaObject.SUPPORT_CACHE) != 0;
        boolean supportEdit = (supported & MediaObject.SUPPORT_EDIT) != 0;
        boolean supportInfo = (supported & MediaObject.SUPPORT_INFO) != 0;
        //add for Bluetooth Print feature
        boolean supportPrint = (supported & MediaObject.SUPPORT_PRINT) != 0;

        if (supportDelete) {
            setMenuItemEnable(menu, R.id.action_delete, enabled);
        }
        if (supportRotate) {
            setMenuItemEnable(menu, R.id.action_rotate_ccw, enabled);
            setMenuItemEnable(menu, R.id.action_rotate_cw, enabled);
        }
        if (supportCrop) {
            setMenuItemEnable(menu, R.id.action_crop, enabled);
        }
        if (supportShare) {
            setMenuItemEnable(menu, R.id.action_share, enabled);
        }
        if (supportSetAs) {
            setMenuItemEnable(menu, R.id.action_setas, enabled);
        }
        if (supportShowOnMap) {
            setMenuItemEnable(menu, R.id.action_show_on_map, enabled);
        }
        if (supportEdit) {
            setMenuItemEnable(menu, R.id.action_edit, enabled);
        }
        if (supportInfo) {
            setMenuItemEnable(menu, R.id.action_details, enabled);
        }
    }

修改

我们只需将SUPPORT_EDIT 的值改为0即可,编译后查看编辑功能确实消失了。

路径:vendor/mediatek/proprietary/packages/apps/Gallery2/src/com/android/gallery3d/data/MediaObject.java

java 复制代码
    //*/soda water.Remove Photo editing
    public static final int SUPPORT_EDIT = 0;
    /*/
    public static final int SUPPORT_EDIT = 1 << 9;
    //*/
相关推荐
用户20187928316713 分钟前
MVP架构模式:餐厅点餐的有趣故事
android
用户20187928316739 分钟前
MVVM 架构模式:咖啡馆的智能点餐系统
android
用户20187928316743 分钟前
浅析Android MVC架构
android
AsiaLYF2 小时前
kotlin中MutableStateFlow和MutableSharedFlow的区别是什么?
android·开发语言·kotlin
2501_916008892 小时前
iOS 发布全流程详解,从开发到上架的流程与跨平台使用 开心上架 发布实战
android·macos·ios·小程序·uni-app·cocoa·iphone
4Forsee3 小时前
【Android】浅析 Android 的 IPC 跨进程通信机制
android·java
叶羽西3 小时前
如何区分Android、Android Automotive、Android Auto
android
用户2018792831673 小时前
用 “奶茶店订单系统” 讲懂 MVI 架构
android
LiuYaoheng4 小时前
【Android】布局优化:include、merge、ViewStub的使用及注意事项
android·java
Kapaseker4 小时前
Kotlin Flow 的 emit 和 tryEmit 有什么区别
android·kotlin