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;
    //*/
相关推荐
CYRUS_STUDIO19 分钟前
一文搞懂 Frida Stalker:对抗 OLLVM 的算法还原利器
android·逆向·llvm
zcychong1 小时前
ArrayMap、SparseArray和HashMap有什么区别?该如何选择?
android·面试
CYRUS_STUDIO1 小时前
Frida Stalker Trace 实战:指令级跟踪与寄存器变化监控全解析
android·逆向
ace望世界6 小时前
android的Parcelable
android
顾林海6 小时前
Android编译插桩之AspectJ:让代码像特工一样悄悄干活
android·面试·性能优化
叽哥6 小时前
Flutter Riverpod上手指南
android·flutter·ios
循环不息优化不止6 小时前
安卓开发设计模式全解析
android
诺诺Okami6 小时前
Android Framework-WMS-层级结构树
android
alexhilton17 小时前
面向开发者的系统设计:像建筑师一样思考
android·kotlin·android jetpack
CYRUS_STUDIO1 天前
用 Frida 控制 Android 线程:kill 命令、挂起与恢复全解析
android·linux·逆向