Android 13 移除下拉栏中的设置入口

介绍

因为当前项目的设置已被加密,客户不希望通过下拉窗口的设置图标进入设置,决定去掉该图标。

效果展示

分析

这里首先想到在SystemUI寻找这个图标的资源文件,找到资源文件后寻找对应控件调用的地方,根据id寻找控件代码即可。

修改

首先找到了对应的资源文件

路径:vendor/mediatek/proprietary/packages/apps/SystemUI/res/drawable/ic_settings.xml

通过搜索我们发现是在如下路径调用,这里我按钮是在容器中的,我们直接搜索容器ID的绑定代码。

路径:vendor/mediatek/proprietary/packages/apps/SystemUI/res-keyguard/layout/footer_actions.xml

        

            

        

控件是在onFinishInflate中完成绑定的,接着往下看,在updateVisibilities中更新了控件的显示状态,那只需在最后设置显示状态为GONE即可,代码如下

路径:vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/FooterActionsView.kt

    override fun onFinishInflate() {
        super.onFinishInflate()
        settingsContainer = findViewById(R.id.settings_button_container)
        multiUserSwitch = findViewById(R.id.multi_user_switch)
        multiUserAvatar = multiUserSwitch.findViewById(R.id.multi_user_avatar)

        // RenderThread is doing more harm than good when touching the header (to expand quick
        // settings), so disable it for this view
        if (settingsContainer.background is RippleDrawable) {
            (settingsContainer.background as RippleDrawable).setForceSoftware(true)
        }
        importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_YES
    }


    private fun updateVisibilities(
        multiUserEnabled: Boolean
    ) {
        settingsContainer.visibility = if (qsDisabled) GONE else VISIBLE
        multiUserSwitch.visibility = if (multiUserEnabled) VISIBLE else GONE
        val isDemo = UserManager.isDeviceInDemoMode(context)
        //*/soda water.20240109 Remove the drop-down Settings entry
        settingsContainer.visibility = GONE
        /*
        settingsContainer.visibility = if (isDemo) INVISIBLE else VISIBLE
        */
    }

你可能感兴趣的:(Android,13,android)