Android 11.0 修复在Settings首页,按键盘方向键不会全部选中而是选中单个选项

Posted 王睿丶

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android 11.0 修复在Settings首页,按键盘方向键不会全部选中而是选中单个选项相关的知识,希望对你有一定的参考价值。

思路:
当获取到上下键值时,判断当前界面如果是设置主界面,就让它不执行全选代码

路径:frameworks/base/core/java/android/view/ViewRootImpl.java

if (direction!=33 || (direction == 33 && (!"com.android.settings.homepage.SettingsHomepageActivity".equals(cn.getClassName()))))
 private boolean performFocusNavigation(KeyEvent event) 
            if (direction != 0) 
                View focused = mView.findFocus();
                if (focused != null) 
                    View v = focused.focusSearch(direction);
                    if (v != null && v != focused) 
                        // do the math the get the interesting rect
                        // of previous focused into the coord system of
                        // newly focused view
                        focused.getFocusedRect(mTempRect);
                        if (mView instanceof ViewGroup) 
                            ((ViewGroup) mView).offsetDescendantRectToMyCoords(
                                    focused, mTempRect);
                            ((ViewGroup) mView).offsetRectIntoDescendantCoords(
                                    v, mTempRect);
                        
+                        //wangrui On the home page of the settings, cancel the selection and select the first level directory instead
+                         am = (android.app.ActivityManager) mContext.getSystemService(ACTIVITY_SERVICE);
+                         cn = am.getRunningTasks(1).get(0).topActivity;
+                        if (direction!=33 || (direction == 33 && (!"com.android.settings.homepage.SettingsHomepageActivity".equals(cn.getClassName())))) 
+                            if (v.requestFocus(direction, mTempRect)) 
+                                playSoundEffect(SoundEffectConstants
+                                        .getContantForFocusDirection(direction));
+                                return true;
+                            
+                        

                    
        

以上是关于Android 11.0 修复在Settings首页,按键盘方向键不会全部选中而是选中单个选项的主要内容,如果未能解决你的问题,请参考以下文章

Android 11.0 修复在Settings首页,按键盘方向键不会全部选中而是选中单个选项

Android 11.0 修复同时播放音乐和视频时,上一首下一首暂停按键失灵

Android 11.0 修复:Camera 拍照后,图片详情信息的分辨率和画质信息概率性丢失

Android 11.0 删除Settings-访客模式

Android 11.0 在Settings首页按键盘↓键,实现选中一级目录

Android 11.0 隐藏开发者