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;
    //*/
相关推荐
代码代码快快显灵4 分钟前
Android项目架构深度解析
android
丐中丐99936 分钟前
一个Binder通信中的多线程同步问题
android
诸神黄昏EX41 分钟前
Android Qualcomm USB 专题系列【篇二:UsbGadget模式配置】
android
vocal41 分钟前
【我的AOSP第一课】Android Init 语言与 rc 文件
android
诸神黄昏EX1 小时前
Android Qualcomm USB 专题系列【总篇:USB HAL架构】
android·linux·网络
原神启动11 小时前
Ansible(三)—— 使用Ansible自动化部署LNMP环境
android·自动化·ansible
前端老白2 小时前
webview在微信小程序中,安卓加载失败,IOS正常加载
android·ios·微信小程序·webview
2501_937154932 小时前
适配中兴主流机型 纯净版刷机固件技术优势合集
android·源码·源代码管理·机顶盒
2501_915106322 小时前
用 HBuilder 上架 iOS 应用时如何管理Bundle ID、证书与描述文件
android·ios·小程序·https·uni-app·iphone·webview
TheNextByte12 小时前
如何通过OTG或不使用OTG将文件从Android传到U盘
android