AndroidRom定制删除Settings某些菜单选项

news2025/4/22 13:32:26

AndroidRom定制删除Settings某些菜单选项

在这里插入图片描述

1.前言.

最近在Rom开发中需要隐藏设置中的某些菜单,launcher3中的定制开发,这个属于很基本的定制需求,和隐藏google搜素栏一样简单,这里我就不展开了,直接上代码.

2.隐藏网络和互联网:

源码路径:package/apps/settings/src/com/android/settings/network/TopLevelNetworkEntryPreferenceController

/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.network;

import android.content.Context;
import android.icu.text.ListFormatter;
import android.text.BidiFormatter;
import android.text.TextUtils;

import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.wifi.WifiMasterSwitchPreferenceController;

import java.util.ArrayList;
import java.util.List;

public class TopLevelNetworkEntryPreferenceController extends BasePreferenceController {

    private final WifiMasterSwitchPreferenceController mWifiPreferenceController;
    private final MobileNetworkPreferenceController mMobileNetworkPreferenceController;
    private final TetherPreferenceController mTetherPreferenceController;

    public TopLevelNetworkEntryPreferenceController(Context context, String preferenceKey) {
        super(context, preferenceKey);
        mMobileNetworkPreferenceController = new MobileNetworkPreferenceController(mContext);
        mTetherPreferenceController = new TetherPreferenceController(
                mContext, null /* lifecycle */);
        mWifiPreferenceController = new WifiMasterSwitchPreferenceController(
                mContext, null /* metrics */);
    }

    @Override
    public int getAvailabilityStatus() {
        return Utils.isDemoUser(mContext) ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
    }

    @Override
    public CharSequence getSummary() {
        final String wifiSummary = BidiFormatter.getInstance()
                .unicodeWrap(mContext.getString(R.string.wifi_settings_title));
        final String mobileSummary = mContext.getString(
                R.string.network_dashboard_summary_mobile);
        final String dataUsageSummary = mContext.getString(
                R.string.network_dashboard_summary_data_usage);
        final String hotspotSummary = mContext.getString(
                R.string.network_dashboard_summary_hotspot);

        final List<String> summaries = new ArrayList<>();
        if (mWifiPreferenceController.isAvailable()
                && !TextUtils.isEmpty(wifiSummary)) {
            summaries.add(wifiSummary);
        }
        if (mMobileNetworkPreferenceController.isAvailable() && !TextUtils.isEmpty(mobileSummary)) {
            summaries.add(mobileSummary);
        }
        if (!TextUtils.isEmpty(dataUsageSummary)) {
            summaries.add(dataUsageSummary);
        }
        if (mTetherPreferenceController.isAvailable()
                && !TextUtils.isEmpty(hotspotSummary)) {
            summaries.add(hotspotSummary);
        }
        return ListFormatter.getInstance().format(summaries);
    }
}


关键修改如下:

2种方式:

2.1.修改getAvailabilityStatus()方法

@Override
public int getAvailabilityStatus() {
    return true ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
}

2.2.直接注释掉xml中互联网相关:

源码路径:package/apps/settings/res/xml/top_level_settings…xml

<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2018 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:key="top_level_settings">

    <Preference
        android:key="top_level_network"
        android:title="@string/network_dashboard_title"
        android:summary="@string/summary_placeholder"
        android:icon="@drawable/ic_homepage_network"
        android:order="-120"
        android:fragment="com.android.settings.network.NetworkDashboardFragment"
        settings:controller="com.android.settings.network.TopLevelNetworkEntryPreferenceController"/>

    <Preference
        android:key="top_level_connected_devices"
        android:title="@string/connected_devices_dashboard_title"
        android:summary="@string/summary_placeholder"
        android:icon="@drawable/ic_homepage_connected_device"
        android:order="-110"
        android:fragment="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment"
        settings:controller="com.android.settings.connecteddevice.TopLevelConnectedDevicesPreferenceController"/>

    <Preference
        android:key="top_level_apps_and_notifs"
        android:title="@string/app_and_notification_dashboard_title"
        android:summary="@string/app_and_notification_dashboard_summary"
        android:icon="@drawable/ic_homepage_apps"
        android:order="-100"
        android:fragment="com.android.settings.applications.AppAndNotificationDashboardFragment"/>

    <Preference
        android:key="top_level_display"
        android:title="@string/display_settings"
        android:summary="@string/summary_placeholder"
        android:icon="@drawable/ic_homepage_display"
        android:order="-80"
        android:fragment="com.android.settings.DisplaySettings"
        settings:controller="com.android.settings.display.TopLevelDisplayPreferenceController"/>

    <Preference
        android:key="top_level_sound"
        android:title="@string/sound_settings"
        android:summary="@string/sound_dashboard_summary"
        android:icon="@drawable/ic_homepage_sound"
        android:order="-70"
        android:fragment="com.android.settings.notification.SoundSettings"/>

<!--    <Preference
        android:key="top_level_storage"
        android:title="@string/storage_settings"
        android:summary="@string/summary_placeholder"
        android:icon="@drawable/ic_homepage_storage"
        android:order="-60"
        android:fragment="com.android.settings.deviceinfo.StorageSettings"
        settings:controller="com.android.settings.deviceinfo.TopLevelStoragePreferenceController"/>-->

    <Preference
        android:key="top_level_privacy"
        android:title="@string/privacy_dashboard_title"
        android:summary="@string/privacy_dashboard_summary"
        android:icon="@drawable/ic_homepage_privacy"
        android:order="-55"
        android:fragment="com.android.settings.privacy.PrivacyDashboardFragment"/>

    <Preference
        android:key="top_level_location"
        android:title="@string/location_settings_title"
        android:summary="@string/location_settings_loading_app_permission_stats"
        android:icon="@drawable/ic_homepage_location"
        android:order="-50"
        android:fragment="com.android.settings.location.LocationSettings"
        settings:controller="com.android.settings.location.TopLevelLocationPreferenceController"/>

    <Preference
        android:key="top_level_security"
        android:title="@string/security_settings_title"
        android:summary="@string/summary_placeholder"
        android:icon="@drawable/ic_homepage_security"
        android:order="-40"
        android:fragment="com.android.settings.security.SecuritySettings"
        settings:controller="com.android.settings.security.TopLevelSecurityEntryPreferenceController"/>

    <Preference
        android:key="top_level_accounts"
        android:title="@string/account_dashboard_title"
        android:summary="@string/summary_placeholder"
        android:icon="@drawable/ic_homepage_accounts"
        android:order="-30"
        android:fragment="com.android.settings.accounts.AccountDashboardFragment"
        settings:controller="com.android.settings.accounts.TopLevelAccountEntryPreferenceController"/>

    <Preference
        android:key="top_level_accessibility"
        android:title="@string/accessibility_settings"
        android:summary="@string/accessibility_settings_summary"
        android:icon="@drawable/ic_homepage_accessibility"
        android:order="-20"
        android:fragment="com.android.settings.accessibility.AccessibilitySettings"
        settings:controller="com.android.settings.accessibility.TopLevelAccessibilityPreferenceController"/>

    <Preference
        android:key="top_level_system"
        android:title="@string/header_category_system"
        android:summary="@string/system_dashboard_summary"
        android:icon="@drawable/ic_homepage_system_dashboard"
        android:order="10"
        android:fragment="com.android.settings.system.SystemDashboardFragment"/>

    <Preference
        android:key="top_level_about_device"
        android:title="@string/about_settings"
        android:summary="@string/summary_placeholder"
        android:icon="@drawable/ic_homepage_about"
        android:order="20"
        android:fragment="com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment"
        settings:controller="com.android.settings.deviceinfo.aboutphone.TopLevelAboutDevicePreferenceController"/>

    <Preference
        android:key="top_level_support"
        android:summary="@string/support_summary"
        android:title="@string/page_tab_title_support"
        android:icon="@drawable/ic_homepage_support"
        android:order="100"
        settings:controller="com.android.settings.support.SupportPreferenceController"/>

</PreferenceScreen>

在这里插入图片描述

3.隐藏已连接的设备:

源码路径:/packages/apps/settings/res/values.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2007 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

    <!-- If false, MIN is displayed. If true, MSID is displayed. -->
    <bool name="config_msid_enable" translatable="false">false</bool>

    <string name="additional_system_update" translatable="false"></string>
    <string name="additional_system_update_menu" translatable="false"></string>

    <!-- TODO: This is purely enforced by the interface, and does not affect what
         strings may be inserted into the actual content provider.
         With the addition of shortcuts, it seems more likely that users will
         find this limiting; it would be good to have the interface work with
         very long strings too. -->
    <integer name="maximum_user_dictionary_word_length" translatable="false">48</integer>

    <!-- Dashboard number of columns -->
    <integer name="dashboard_num_columns">1</integer>

    <!-- Carrier_enabled editable -->
    <bool name="config_allow_edit_carrier_enabled" translatable="false">false</bool>

    <!-- When true enable color temperature setting. -->
    <bool name="config_enableColorTemperature">false</bool>

    <!-- Whether to show Camera laser sensor switch in Developer Options -->
    <bool name="config_show_camera_laser_sensor">false</bool>

    <!-- Fully-qualified class name for the implementation of the FeatureFactory to be instantiated. -->
    <string name="config_featureFactory" translatable="false">com.android.settings.overlay.FeatureFactoryImpl</string>

    <!-- Package name and fully-qualified class name for the wallpaper picker activity. -->
    <string name="config_wallpaper_picker_package" translatable="false">com.android.settings</string>
    <string name="config_wallpaper_picker_class" translatable="false">com.android.settings.Settings$WallpaperSettingsActivity</string>
    <!-- Fully-qualified class name for the styles & wallpaper picker activity. -->
    <string name="config_styles_and_wallpaper_picker_class" translatable="false"></string>

    <!-- Manufacturer backup settings to launch -->
    <string name="config_backup_settings_intent" translatable="false"></string>

    <!-- Manufacturer backup settings label -->
    <string name="config_backup_settings_label" translatable="true"></string>

    <!-- Double twist sensor name and vendor used by gesture setting -->
    <string name="gesture_double_twist_sensor_name" translatable="false"></string>
    <string name="gesture_double_twist_sensor_vendor" translatable="false"></string>

    <!-- When true enable gesture setting. -->
    <bool name="config_gesture_settings_enabled">false</bool>

    <!-- If the Storage Manager settings are enabled. -->
    <bool name="config_storage_manager_settings_enabled">false</bool>

    <!-- If the support features are enabled. -->
    <bool name="config_support_enabled">false</bool>

    <!-- Whether to enable "show operator name in the status bar" setting -->
    <bool name="config_showOperatorNameInStatusBar">false</bool>

    <!-- List containing the component names of pre-installed screen reader services. -->
    <string-array name="config_preinstalled_screen_reader_services" translatable="false">
        <!--
        <item>com.example.package.first/com.example.class.FirstService</item>
        <item>com.example.package.second/com.example.class.SecondService</item>
        -->
    </string-array>

    <!-- List containing the component names of pre-installed audio and captioning services. -->
    <string-array name="config_preinstalled_audio_and_caption_services" translatable="false">
        <!--
        <item>com.example.package.first/com.example.class.FirstService</item>
        <item>com.example.package.second/com.example.class.SecondService</item>
        -->
    </string-array>

    <!-- List containing the component names of pre-installed display services. -->
    <string-array name="config_preinstalled_display_services" translatable="false">
        <!--
        <item>com.example.package.first/com.example.class.FirstService</item>
        <item>com.example.package.second/com.example.class.SecondService</item>
        -->
    </string-array>

    <!-- List containing the component names of pre-installed interaction control services. -->
    <string-array name="config_preinstalled_interaction_control_services" translatable="false">
        <!--
        <item>com.example.package.first/com.example.class.FirstService</item>
        <item>com.example.package.second/com.example.class.SecondService</item>
        -->
    </string-array>

    <!-- List containing the order of services in screen reader category by componentname.
         All componentnames in a category need to be specified to guarantee correct behavior.-->
    <string-array name="config_order_screen_reader_services" translatable="false">
        <!--
        <item>com.example.package.first/com.example.class.FirstService</item>
        <item>com.example.package.second/com.example.class.SecondService</item>
        -->
    </string-array>

    <!-- List containing the order of services in audio and caption category by preference key
         or componentname. All preference keys in a category need to be specified to guarantee
         correct behavior.-->
    <string-array name="config_order_audio_and_caption_services" translatable="false">
        <!--
        <item>com.example.package.first/com.example.class.FirstService</item>
        <item>com.example.package.second/com.example.class.SecondService</item>
        <item>toggle_master_mono</item>
        <item>seekbar_master_balance</item>
        <item>...</item>
        -->
    </string-array>

    <!-- List containing the order of services in display category by preference key
         or componentname. All preference keys in a category need to be specified to guarantee
         correct behavior.-->
    <string-array name="config_order_display_services" translatable="false">
        <!--
        <item>com.example.package.first/com.example.class.FirstService</item>
        <item>com.example.package.second/com.example.class.SecondService</item>
        <item>font_size_preference_screen</item>
        <item>dark_ui_mode_accessibility</item>
        <item>...</item>
        -->
    </string-array>

    <!-- List containing the order of services in interaction control category by preference key
         or componentname. All preference keys in a category need to be specified to guarantee
         correct behavior.-->
    <string-array name="config_order_interaction_control_services" translatable="false">
        <!--
        <item>com.example.package.first/com.example.class.FirstService</item>
        <item>com.example.package.second/com.example.class.SecondService</item>
        <item>autoclick_preference</item>
        <item>toggle_power_button_ends_call_preference</item>
        <item>...</item>
        -->
    </string-array>

    <!-- List of packages that should be whitelisted for slice uri access. Do not translate -->
    <string-array name="slice_whitelist_package_names" translatable="false"/>

    <!-- Whether or not App & Notification screen should display recently used apps -->
    <bool name="config_display_recent_apps">true</bool>

    <!-- Package name for the storage manager to use from Settings search. -->
    <string name="config_deletion_helper_package" translatable="false">com.android.storagemanager</string>
    <!-- Class name for the storage manager's deletion helper class. -->
    <string name="config_deletion_helper_class" translatable="false">com.android.storagemanager.deletionhelper.DeletionHelperActivity</string>

    <!-- Whether to use a UI variant that minimizes the number of UI elements on screen. This is
         typically used when there is not enough space to display everything, because pattern view
         doesn't interact well with scroll view -->
    <bool name="config_lock_pattern_minimal_ui">true</bool>

    <!-- List of a11y components on the device allowed to be enabled by Settings Slices -->
    <string-array name="config_settings_slices_accessibility_components" translatable="false"/>

    <!-- Whether or not to show the night light suggestion. -->
    <bool name="config_night_light_suggestion_enabled">true</bool>

    <!-- Whether or not the device is capable of multiple levels of vibration intensity.
         Note that this is different from whether it can control the vibration amplitude as some
         devices will be able to vary their amplitude but do not possess enough dynamic range to
         have distinct intensity levels -->
    <bool name="config_vibration_supports_multiple_intensities">false</bool>

    <!--
        Whether or not the homepage should be powered by legacy suggestion (versus contextual cards)
        Default to true as not all devices support contextual cards.
    -->
    <bool name="config_use_legacy_suggestion">true</bool>

    <!-- Whether or not homepage should display user's account avatar -->
    <bool name="config_show_avatar_in_homepage">false</bool>

    <!-- Whether or not emergency info tile should display in device info page -->
    <bool name="config_show_emergency_info_in_device_info">true</bool>

    <!-- Whether or not branded account info tile should display in device info page -->
    <bool name="config_show_branded_account_in_device_info">true</bool>

    <!-- Whether or not device header widget tile should display in device info page -->
    <bool name="config_show_device_header_in_device_info">true</bool>

    <!-- Whether or not TopLevelSettings should force rounded icon for injected tiles -->
    <bool name="config_force_rounded_icon_TopLevelSettings">true</bool>

    <!-- Whether dismissal timestamp should be kept before deletion -->
    <bool name="config_keep_contextual_card_dismissal_timestamp">false</bool>

    <!-- Settings intelligence package name -->
    <string name="config_settingsintelligence_package_name" translatable="false">
        com.android.settings.intelligence
    </string>

    <!-- Whether the confirmation for sim deletion is defaulted to be on or off-->
    <bool name="config_sim_deletion_confirmation_default_on">false</bool>

    <!-- Package Installer package name -->
    <string name="config_package_installer_package_name" translatable="false">
        com.android.packageinstaller
    </string>

    <!-- Settings intelligence interaction log intent action -->
    <string name="config_settingsintelligence_log_action" translatable="false"></string>

    <!-- AOSP Emergency app package name -->
    <string name="config_aosp_emergency_package_name" translatable="false">
        com.android.emergency
    </string>

    <!-- AOSP Emergency app intent action -->
    <string name="config_aosp_emergency_intent_action" translatable="false">
        android.settings.EDIT_EMERGENCY_INFO
    </string>

    <!-- Emergency app package name -->
    <string name="config_emergency_package_name" translatable="false">
        com.android.emergency
    </string>

    <!-- Emergency app intent action -->
    <string name="config_emergency_intent_action" translatable="false">
        android.settings.EDIT_EMERGENCY_INFO
    </string>

    <!-- Email address for the homepage contextual cards feedback -->
    <string name="config_contextual_card_feedback_email" translatable="false"></string>

    <!-- ComponentName to launch a vendor-specific enrollment activity if available -->
    <string name="config_face_enroll" translatable="false"></string>

    <!-- App intent -->
    <string name="config_account_intent_uri" translatable="false"></string>

    <!-- Whether or not the dock settings are to be displayed for this device when docked -->
    <bool name="has_dock_settings">false</bool>
    <!-- Whether there is a boot sounds checkbox -->
    <bool name="has_boot_sounds">false</bool>
    <!-- Whether there is a silent mode checkbox  -->
    <bool name="has_silent_mode">true</bool>

    <!-- Display additional System Update menu if true -->
    <bool name="config_additional_system_update_setting_enable">false</bool>

    <!-- Whether the bluetooth activation confirmation dialogs should be auto dismissed.
         Can be overridden for specific product builds. -->
    <bool name="auto_confirm_bluetooth_activation_dialog">false</bool>

    <!-- Whether the device name is shown in About device or not -->
    <bool name="config_show_device_name">true</bool>

    <!-- Whether to show a preference item for the manual in About phone -->
    <bool name="config_show_manual">false</bool>
    <!-- Whether to show a preference item for regulatory information in About phone -->
    <bool name="config_show_regulatory_info">false</bool>

    <!-- Whether to show a preference item for mobile plan -->
    <bool name="config_show_mobile_plan">true</bool>

    <!-- Whether none security option is hide or not  (country specific). -->
    <bool name="config_hide_none_security_option">false</bool>

    <!-- Whether swipe security option is hidden or not -->
    <bool name="config_hide_swipe_security_option">false</bool>

    <!--Whether help links are defined. -->
    <bool name="config_has_help">false</bool>

    <!-- Whether Wi-Fi settings should be shown or not.
    This also controls whether Wi-fi related sub-settings (e.g. Wi-Fi preferences) will
    surface in search results or not.-->
    <bool name="config_show_wifi_settings">true</bool>

    <!-- Whether toggle_airplane is available or not. -->
    <bool name="config_show_toggle_airplane">true</bool>

    <!-- Whether private_dns_settings is available or not. -->
    <bool name="config_show_private_dns_settings">true</bool>

    <!-- Whether memory from app_info_settings is available or not. -->
    <bool name="config_show_app_info_settings_memory">false</bool>

    <!-- Whether battery from app_info_settings is available or not. -->
    <bool name="config_show_app_info_settings_battery">true</bool>

    <!-- Whether location mode is available or not. -->
    <bool name="config_location_mode_available">true</bool>

    <!-- Whether location scanning is available or not. -->
    <bool name="config_show_location_scanning">true</bool>

    <!-- Whether high_power_apps should be shown or not. -->
    <bool name="config_show_high_power_apps">true</bool>

    <!-- Whether media_volume should be shown or not. -->
    <bool name="config_show_media_volume">true</bool>

    <!-- Whether alarm_volume should be shown or not. -->
    <bool name="config_show_alarm_volume">true</bool>

    <!-- Whether call_volume should be shown or not. -->
    <bool name="config_show_call_volume">true</bool>

    <!-- Whether notification_volume should be shown or not. -->
    <bool name="config_show_notification_volume">true</bool>

    <!-- Whether notification_ringtone should be shown or not. -->
    <bool name="config_show_notification_ringtone">true</bool>

    <!-- Whether screen_locking_sounds should be shown or not. -->
    <bool name="config_show_screen_locking_sounds">true</bool>

    <!-- Whether charging_sounds should be shown or not. -->
    <bool name="config_show_charging_sounds">true</bool>

    <!-- Whether touch_sounds should be shown or not. -->
    <bool name="config_show_touch_sounds">true</bool>

    <!-- Whether encryption_and_credentials_encryption_status should be shown or not. -->
    <bool name="config_show_encryption_and_credentials_encryption_status">true</bool>

    <!-- Whether premium_sms should be shown or not. -->
    <bool name="config_show_premium_sms">true</bool>

    <!-- Whether data_saver should be shown or not. -->
    <bool name="config_show_data_saver">true</bool>

    <!-- Whether enabled_vr_listeners should be shown or not. -->
    <bool name="config_show_enabled_vr_listeners">true</bool>

    <!-- Whether phone_language should be shown or not. -->
    <bool name="config_show_phone_language">true</bool>

    <!-- Whether virtual_keyboard_pref should be shown or not. -->
    <bool name="config_show_virtual_keyboard_pref">true</bool>

    <!-- Whether physical_keyboard_pref should be shown or not. -->
    <bool name="config_show_physical_keyboard_pref">true</bool>

    <!-- Whether spellcheckers_settings should be shown or not. -->
    <bool name="config_show_spellcheckers_settings">true</bool>

    <!-- Whether tts_settings_summary should be shown or not. -->
    <bool name="config_show_tts_settings_summary">true</bool>

    <!-- Whether pointer_speed should be shown or not. -->
    <bool name="config_show_pointer_speed">true</bool>

    <!-- Whether vibrate_input_devices should be shown or not. -->
    <bool name="config_show_vibrate_input_devices">true</bool>

    <!-- Whether manage_device_admin should be shown or not. -->
    <bool name="config_show_manage_device_admin">true</bool>

    <!-- Whether unlock_set_or_change should be shown or not. -->
    <bool name="config_show_unlock_set_or_change">true</bool>

    <!-- Whether screen_pinning_settings should be shown or not. -->
    <bool name="config_show_screen_pinning_settings">true</bool>

    <!-- Whether manage_trust_agents should be shown or not. -->
    <bool name="config_show_manage_trust_agents">true</bool>

    <!-- Whether show_password should be shown or not. -->
    <bool name="config_show_show_password">true</bool>

    <!-- Whether trust_agent_click_intent should be shown or not. -->
    <bool name="config_show_trust_agent_click_intent">true</bool>

    <!-- Whether wallpaper attribution should be shown or not. -->
    <bool name="config_show_wallpaper_attribution">true</bool>

    <!-- Whether assist_and_voice_input should be shown or not. -->
    <bool name="config_show_assist_and_voice_input">true</bool>

    <!-- Whether reset_dashboard should be shown or not. -->
    <bool name="config_show_reset_dashboard">true</bool>

    <!-- Whether system_update_settings should be shown or not. -->
    <bool name="config_show_system_update_settings">true</bool>

    <!-- Whether device_model should be shown or not. -->
    <bool name="config_show_device_model">true</bool>

    <!-- Whether top_level_accessibility should be shown or not. -->
    <bool name="config_show_top_level_accessibility">true</bool>

    <!-- Whether top_level_battery should be shown or not. -->
    <bool name="config_show_top_level_battery">true</bool>

    <!-- Whether top_level_connected_devices should be shown or not. -->
    <bool name="config_show_top_level_connected_devices">true</bool>

    <!-- Whether top_level_display should be shown or not. -->
    <bool name="config_show_top_level_display">true</bool>

    <!-- Whether wifi_ip_address should be shown or not. -->
    <bool name="config_show_wifi_ip_address">true</bool>

    <!-- Whether wifi_mac_address should be shown or not. -->
    <bool name="config_show_wifi_mac_address">true</bool>

    <!-- Whether to disable "Uninstall Updates" menu item for System apps or not. -->
    <bool name="config_disable_uninstall_update">false</bool>

    <!-- Whether or not extra preview panels should be used for screen zoom setting. -->
    <bool name="config_enable_extra_screen_zoom_preview">true</bool>

    <!-- Slice Uri to query nearby devices. -->
    <string name="config_nearby_devices_slice_uri" translatable="false">content://com.google.android.gms.nearby.fastpair/device_status_list_item</string>

    <!-- Grayscale settings intent -->
    <string name="config_grayscale_settings_intent" translatable="false"></string>

    <!-- List containing the injected tile keys which are suppressed. -->
    <string-array name="config_suppress_injected_tile_keys" translatable="false"/>

    <!-- Reset application package name -->
    <string-array name="config_skip_reset_apps_package_name" translatable="false">
        <item>android</item>
        <item>com.android.providers.downloads</item>
        <item>com.android.systemui</item>
        <item>com.android.vending</item>
    </string-array>

    <!-- Settings panel keeps observe this uri -->
    <string-array name="config_panel_keep_observe_uri" translatable="false">
        <item>content://com.android.settings.slices/intent/media_output_indicator</item>
    </string-array>

    <!-- Uri to query non-public Slice Uris. -->
    <string name="config_non_public_slice_query_uri" translatable="false"></string>

    <!-- RTT setting intent action -->
    <string name="config_rtt_setting_intent_action" translatable="false"></string>

    <!-- Package name of dialer supports RTT setting-->
    <string name="config_rtt_setting_package_name" translatable="false"></string>

    <!-- Whether nfc detection point preview image is available or not. -->
    <bool name="config_nfc_detection_point">false</bool>

    <!-- Whether to show Smooth Display feature in Settings Options -->
    <bool name="config_show_smooth_display">false</bool>

    <!-- Whether to show the Preference for Adaptive connectivity -->
    <bool name="config_show_adaptive_connectivity">false</bool>
</resources>

关键修改如下:

把config_show_top_level_connected_devices修改为false

<!-- Whether top_level_connected_devices should be shown or not. -->
<bool name="config_show_top_level_connected_devices">false</bool>

在这里插入图片描述

4.隐藏存储菜单:

源码路径:package/apps/settings/res/xml/app_info_settings.xml

<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2017 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:key="installed_app_detail_settings_screen"
    settings:initialExpandedChildrenCount="6">

    <com.android.settingslib.widget.LayoutPreference
        android:key="header_view"
        android:layout="@layout/settings_entity_header"
        android:selectable="false"
        android:order="-10000"
        settings:allowDividerBelow="true"/>

    <com.android.settingslib.widget.LayoutPreference
        android:key="instant_app_buttons"
        android:layout="@layout/instant_app_buttons"
        android:selectable="false"
        android:order="-9999"
        settings:allowDividerAbove="true"
        settings:allowDividerBelow="true"/>

    <com.android.settingslib.widget.ActionButtonsPreference
        android:key="action_buttons"
        android:order="-9998" />

    <Preference
        android:key="notification_settings"
        android:title="@string/notifications_label"
        settings:controller="com.android.settings.applications.appinfo.AppNotificationPreferenceController"
        settings:allowDividerAbove="true"/>

    <com.android.settings.widget.FixedLineSummaryPreference
        android:key="permission_settings"
        android:title="@string/permissions_label"
        android:summary="@string/summary_placeholder"
        settings:summaryLineCount="1"
        settings:controller="com.android.settings.applications.appinfo.AppPermissionPreferenceController" />

    <Preference
        android:key="storage_settings"
        android:title="@string/storage_settings_for_app"
        android:summary="@string/summary_placeholder"
        settings:controller="com.android.settings.applications.appinfo.AppStoragePreferenceController" />

    <com.android.settings.applications.AppDomainsPreference
        android:key="instant_app_launch_supported_domain_urls"
        android:title="@string/app_launch_supported_domain_urls_title"
        android:selectable="true"
        settings:controller="com.android.settings.applications.appinfo.InstantAppDomainsPreferenceController" />

    <Preference
        android:key="data_settings"
        android:title="@string/data_usage_app_summary_title"
        android:summary="@string/summary_placeholder"
        settings:controller="com.android.settings.applications.appinfo.AppDataUsagePreferenceController" />

    <Preference
        android:key="time_spent_in_app"
        android:title="@string/time_spent_in_app_pref_title"
        settings:controller="com.android.settings.applications.appinfo.TimeSpentInAppPreferenceController" />

    <Preference
        android:key="battery"
        android:title="@string/power_usage_summary_title"
        android:summary="@string/summary_placeholder" />

    <Preference
        android:key="preferred_settings"
        android:title="@string/launch_by_default"
        android:summary="@string/summary_placeholder"
        android:selectable="true"
        settings:controller="com.android.settings.applications.appinfo.AppOpenByDefaultPreferenceController" />

    <Preference
        android:key="memory"
        android:title="@string/memory_settings_title"
        android:summary="@string/summary_placeholder"
        android:enabled="false" />

    <!-- Default apps shortcuts -->
    <Preference
        android:key="default_home"
        android:title="@string/home_app"
        android:summary="@string/summary_placeholder" />

    <Preference
        android:key="default_browser"
        android:title="@string/default_browser_title"
        android:summary="@string/summary_placeholder" />

    <Preference
        android:key="default_phone_app"
        android:title="@string/default_phone_title"
        android:summary="@string/default_phone_title" />

    <Preference
        android:key="default_emergency_app"
        android:title="@string/default_emergency_app"
        android:summary="@string/summary_placeholder" />

    <Preference
        android:key="default_sms_app"
        android:title="@string/sms_application_title"
        android:summary="@string/summary_placeholder" />

    <!-- Advanced apps settings -->
    <PreferenceCategory
        android:key="advanced_app_info"
        android:title="@string/advanced_apps"
        settings:controller="com.android.settings.applications.appinfo.AdvancedAppInfoPreferenceCategoryController">

        <Preference
            android:key="system_alert_window"
            android:title="@string/draw_overlay"
            android:summary="@string/summary_placeholder"
            settings:controller="com.android.settings.applications.appinfo.DrawOverlayDetailPreferenceController" />

        <Preference
            android:key="write_settings_apps"
            android:title="@string/write_settings"
            android:summary="@string/summary_placeholder"
            settings:controller="com.android.settings.applications.appinfo.WriteSystemSettingsPreferenceController" />

        <Preference
            android:key="picture_in_picture"
            android:title="@string/picture_in_picture_app_detail_title"
            android:summary="@string/summary_placeholder"
            settings:controller="com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetailPreferenceController" />

        <Preference
            android:key="install_other_apps"
            android:title="@string/install_other_apps"
            android:summary="@string/summary_placeholder"
            settings:controller="com.android.settings.applications.appinfo.ExternalSourceDetailPreferenceController" />

        <Preference
            android:key="interact_across_profiles"
            android:title="@string/interact_across_profiles_title"
            android:summary="@string/summary_placeholder"
            settings:controller="com.android.settings.applications.specialaccess.interactacrossprofiles.InteractAcrossProfilesDetailsPreferenceController" />

    </PreferenceCategory>

    <!-- App installer info -->
    <PreferenceCategory
        android:key="app_installer"
        android:title="@string/app_install_details_group_title"
        settings:controller="com.android.settings.applications.appinfo.AppInstallerPreferenceCategoryController">

        <Preference
            android:key="app_info_store"
            android:title="@string/app_install_details_title"
            settings:controller="com.android.settings.applications.appinfo.AppInstallerInfoPreferenceController" />

    </PreferenceCategory>

    <Preference
        android:key="app_settings_link"
        android:title="@string/app_settings_link"
        settings:controller="com.android.settings.applications.appinfo.AppSettingPreferenceController"
        settings:allowDividerAbove="true" />

    <Preference
        android:key="app_version"
        android:selectable="false"
        android:order="9999"
        settings:controller="com.android.settings.applications.appinfo.AppVersionPreferenceController"
        settings:allowDividerAbove="true"
        settings:enableCopying="true"/>

</PreferenceScreen>

关键修改如下:

注释掉AppStoragePreferenceController

<!--    <Preference
        android:key="storage_settings"
        android:title="@string/storage_settings_for_app"
        android:summary="@string/summary_placeholder"
        settings:controller="com.android.settings.applications.appinfo.AppStoragePreferenceController" />-->

在这里插入图片描述

5.实现的效果如下:

默认没有隐藏时效果:

在这里插入图片描述

隐藏互联网和已连接的设备:

在这里插入图片描述

3个菜单都隐藏效果:

在这里插入图片描述

6.总结:

  • 隐藏系统设置中的一级菜单很简单,有2种方式,可以根据需要进行实现。
  • 隐藏菜单选项找到对应的源码路径,按照上面的2种方式修改即可.
  • 如果发现调试过程中不生效可以打印日志查看报错,仔细阅读源码。
  • 大家如果感兴趣可以下载源码进行编译调试查看最终效果。

7.源码如下:

可以参考AOSP12中Launcher3的源码,源码下载地址如下:

https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2340133.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【数据结构和算法】3. 排序算法

本文根据 数据结构和算法入门 视频记录 文章目录 1. 排序算法2. 插入排序 Insertion Sort2.1 概念2.2 具体步骤2.3 Java 实现2.4 复杂度分析 3. 快排 QuickSort3.1 概念3.2 具体步骤3.3 Java实现3.4 复杂度分析 4. 归并排序 MergeSort4.1 概念4.2 递归具体步骤4.3 Java实现4.4…

FreeRTos学习记录--2.内存管理

后续的章节涉及这些内核对象&#xff1a;task、queue、semaphores和event group等。为了让FreeRTOS更容易使用&#xff0c;这些内核对象一般都是动态分配&#xff1a;用到时分配&#xff0c;不使用时释放。使用内存的动态管理功能&#xff0c;简化了程序设计&#xff1a;不再需…

HAL库(STM32CubeMX)——高级ADC学习、HRTIM(STM32G474RBT6)

系列文章目录 文章目录 系列文章目录前言存在的问题HRTIMcubemx配置前言 对cubemx的ADC的设置进行补充 ADCs_Common_Settings Mode:ADC 模式 Independent mod 独立 ADC 模式,当使用一个 ADC 时是独立模式,使用两个 ADC 时是双模式,在双模式下还有很多细分模式可选 ADC_Se…

单例模式(线程安全)

1.什么是单例模式 单例模式&#xff08;Singleton Pattern&#xff09;是一种创建型设计模式&#xff0c;旨在确保一个类只有一个实例&#xff0c;并提供一个全局访问点来访问该实例。这种模式涉及到一个单一的类&#xff0c;该类负责创建自己的对象&#xff0c;同时确保只有单…

FreeRTos学习记录--1.工程创建与源码概述

1.工程创建与源码概述 1.1 工程创建 使用STM32CubeMX&#xff0c;可以手工添加任务、队列、信号量、互斥锁、定时器等等。但是本课程不想严重依赖STM32CubeMX&#xff0c;所以不会使用STM32CubeMX来添加这些对象&#xff0c;而是手写代码来使用这些对象。 使用STM32CubeMX时&…

进程控制(linux+C/C++)

目录 进程创建 写时拷贝 fork 进程终止 退出码 进程退出三种情况对应退出信号 &#xff1a;退出码&#xff1a; 进程退出方法 进程等待 两种方式 阻塞等待和非阻塞等待 小知识 进程创建 1.在未创建子进程时&#xff0c;父进程页表对于数据权限为读写&#xff0c;对于…

TensorBoard如何在同一图表中绘制多个线条

1. 使用不同的日志目录 TensorBoard 会根据日志文件所在的目录来区分不同的运行。可以为每次运行指定一个独立的日志目录&#xff0c;TensorBoard 会自动将这些目录中的数据加载并显示为不同的运行。 示例&#xff08;TensorFlow&#xff09;&#xff1a; import tensorflow…

微软Entra新安全功能引发大规模账户锁定事件

误报触发大规模锁定 多家机构的Windows管理员报告称&#xff0c;微软Entra ID新推出的"MACE"&#xff08;泄露凭证检测应用&#xff09;功能在部署过程中产生大量误报&#xff0c;导致用户账户被大规模锁定。这些警报和锁定始于昨夜&#xff0c;部分管理员认为属于误…

基于FPGA的一维时间序列idct变换verilog实现,包含testbench和matlab辅助验证程序

目录 1.算法运行效果图预览 2.算法运行软件版本 3.部分核心程序 4.算法理论概述 4.1 DCT离散余弦变换 4.2 IDCT逆离散余弦变换 4.3 树结构实现1024点IDCT的原理 5.算法完整程序工程 1.算法运行效果图预览 (完整程序运行后无水印) matlab仿真结果 FPGA仿真结果 由于FP…

Linux进程5-进程通信常见的几种方式、信号概述及分类、kill函数及命令、语法介绍

目录 1.进程间通信概述 1.1进程通信的主要方式 1.2进程通信的核心对比 2.信号 2.1 信号的概述 2.1.1 信号的概念 2.2信号的核心特性 2.3信号的产生来源 2.4信号的处理流程 2.5关键系统调用与函数 2.6常见信号的分类及说明 2.6.1. 标准信号&#xff08;Standard Sig…

[架构之美]一键服务管理大师:Ubuntu智能服务停止与清理脚本深度解析

[架构之美]一键服务管理大师&#xff1a;Ubuntu智能服务停止与清理脚本深度解析 服务展示&#xff1a; 运行脚本&#xff1a; 剩余服务&#xff1a; 一、脚本设计背景与核心价值 在Linux服务器运维中&#xff0c;服务管理是日常操作的重要环节。本文介绍的智能服务管理脚本&a…

C++算法(10):二叉树的高度与深度,(C++代码实战)

引言 在二叉树的相关算法中&#xff0c;高度&#xff08;Height&#xff09;和深度&#xff08;Depth&#xff09;是两个容易混淆的概念。本文通过示例和代码实现&#xff0c;帮助读者清晰区分二者的区别。 定义与区别 属性定义计算方式深度从根节点到该节点的边数根节点深度…

Psychology 101 期末测验(附答案)

欢呼 啦啦啦~啦啦啦~♪(^∇^*) 终于考过啦~ 开心(*^▽^*) 撒花✿✿ヽ(▽)ノ✿ |必须晒下证书: 判卷 记录下判卷,还是错了几道,填空题2道压根填不上。惭愧~ 答案我隐藏了,实在想不出答案的朋友可以留言,不定时回复。 建议还是认认真真的学习~认认真真的考试~,知识就…

安全协议分析概述

一、概念 安全协议&#xff08;security protocol&#xff09;&#xff0c;又称密码协议。是以密码学为基础的消息交换协议&#xff0c;在网络中提供各种安全服务。&#xff08;为解决网络中的现实问题、满足安全需求&#xff09; 1.1 一些名词 那什么是协议呢&#xff1f; …

基础学习:(7)nanoGPT 剩下的细节

文章目录 前言3 继续巴拉结构3.1 encode 和 embedding3.2 全局layernorm3.3 lm_head(language modeling) 和 softmax3.4 softmax 和 linear 之间的 temperature和topk3.5 weight tying 前言 在 基础学习&#xff1a;&#xff08;6&#xff09;中, 在运行和训练代码基础上,向代…

Spark-SQL连接Hive总结及实验

一、核心模式与配置要点 1. 内嵌Hive 无需额外配置&#xff0c;直接使用&#xff0c;但生产环境中几乎不使用。 2. 外部Hive&#xff08;spark-shell连接&#xff09; 配置文件&#xff1a;将hive-site.xml&#xff08;修改数据库连接为node01&#xff09;、core-site.xml、…

Linux Wlan-四次握手(eapol)框架流程

协议基础 基于 IEEE 802.1X 标准实现的协议 抓包基础 使用上一章文章的TPLINK wn722n v1网卡在2.4G 频段抓包&#xff08;v2、v3是不支持混杂模式的&#xff09; eapol的四个交互流程 根据不同的认证模式不同&#xff0c;两者的Auth流程有所不同&#xff0c;但是握手流程基…

web组件和http协议

1.web组件 2.自定义元素 3.影子DOM 4.HTML模板 5.http协议 6.tcp ip协议

软件工程师中级考试-上午知识点总结(下)

6. 知识产权和标准化 软件著作权客体&#xff1a;指的是受软件著作权保护的对象&#xff0c;即计算机程序和相关文档。知识产权具有严格的地域性。不受保护期限制&#xff1a;著名权、修改权、保护作品完整权&#xff1b;注意的是&#xff0c;发表权受保护期限制。专利权在期满…

IO流--字节流详解

IO流 用于读写数据的&#xff08;可以读写文件&#xff0c;或网络中的数据&#xff09; 概述&#xff1a; I指 Input&#xff0c;称为输入流&#xff1a;负责从磁盘或网络上将数据读到内存中去 O指Output&#xff0c;称为输出流&#xff0c;负责写数据出去到网络或磁盘上 因…