Android P 隐藏Settings一级菜单某个选项

时间:2025-01-28 09:08:30
  • 比如:去掉Settings一级菜单中的“Storage”选项
    方法1:
    直接在屏蔽掉即可
    vendor\mediatek\proprietary\packages\apps\MtkSettings\
   <!-- <activity
            android:name=".Settings$StorageDashboardActivity"
            android:label="@string/storage_settings"
            android:icon="@drawable/ic_homepage_storage"
            android:taskAffinity=""
            android:parentActivityName="Settings">
            <intent-filter android:priority="1">
                <action android:name=".INTERNAL_STORAGE_SETTINGS" />
                <action android:name=".MEMORY_CARD_SETTINGS" />
                <category android:name="" />
            </intent-filter>
            <intent-filter>
                <action android:name="" />
                <category android:name="" />
                <category android:name=".VOICE_LAUNCH" />
            </intent-filter>
            <intent-filter android:priority="5">
                <action android:name="" />
            </intent-filter>
            <meta-data android:name=""
                android:value="" />
            <meta-data android:name=""
                android:resource="@string/storage_usb_settings" />
            <meta-data android:name=".FRAGMENT_CLASS"
                android:value="" />
            <meta-data android:name=".PRIMARY_PROFILE_CONTROLLED"
                android:value="true" />
        </activity> -->

方法2:
在Java文件中隐藏,无须修改
vendor\mediatek\proprietary\packages\apps\MtkSettings\src\com\android\settings\

private void doUpdateTilesList() {
...
//add code 
somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
                        ()),
                false, isAdmin)
                || somethingChanged;
//end code     

注意:
要与中一致
表示不显示。

如需隐藏其他选项,如果在已定义,则只需把setTileEnabled方法中的第二个参数改为false即可,
否则需要像Storage一样,需要自己添加相应的code。

方法3:
vendor/mediatek/proprietary/packages/apps/SettingsLib/src/com/android/settingslib/drawer/

  HashMap<String, DashboardCategory> categoryMap = new HashMap<>();
        for (Tile tile : tiles) {
            DashboardCategory category = ();
            if (category == null) {
                category = createCategory(context, , categoryDefinedInManifest);
                if (category == null) {
                    (LOG_TAG, "Couldn't find category " + );
                    continue;
                }
                (, category);
            }
            //add code
               if(("应用和通知") || ("存储") || ("无障碍") ||
                   ("安全性和位置信息") || ("帐号")){
                    continue;
                }
                //end code
            
            (tile);
        }