长按添加widget,和recentUI界面结合使用,widget添加流程被打断,导致各种异常问题

文章详细描述了两个在Android系统Launcher3中遇到的问题:长按设置添加小部件后桌面图标无法再次长按,以及长按Gmail拖到桌面后出现的残影问题。作者提供了相应的Java代码修复方案,主要涉及工作区锁定逻辑和状态管理的调整。
摘要由CSDN通过智能技术生成

时间:2021/04/19
之前公司不允许csdn,笔记写在其它地方。最近整理过来

Bug描述

1、长按setting添加widget,在widget选择界面点击recentUI键返回launcher,桌面图标无法再次长按

修复方案

packages/apps/Launcher3/src/com/android/launcher3/Launcher.java

     public boolean isWorkspaceLocked() {
-        return mWorkspaceLoading || mPendingRequestArgs != null;
+        return mWorkspaceLoading;// || mPendingRequestArgs != null;
     }

bug描述

2、长按Gmail,选择第一个插件拖到桌面,在选择文件夹界面点击recentUI键,返回launcher桌面Gmail 残影无法消除

修复方案

--- a/alps/packages/apps/Launcher3/src/com/android/launcher3/Launcher.java
+++ b/alps/packages/apps/Launcher3/src/com/android/launcher3/Launcher.java
@@ -676,7 +676,11 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
         Runnable exitSpringLoaded = new Runnable() {
             @Override
             public void run() {
-                mStateManager.goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
+                if(changeState){
+                    mStateManager.goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
+                }else{
+                    changeState = true;
+                }
             }
         };
@@ -720,7 +724,11 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
                 final Runnable onComplete = new Runnable() {
                     @Override
                     public void run() {
-                        getStateManager().goToState(NORMAL);
+                        if(changeState){
+                            getStateManager().goToState(NORMAL);
+                        }else{
+                            changeState = true;
+                        }
                     }
                 };
@@ -901,6 +909,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
         mAppWidgetHost.setListenIfResumed(true);
         RaceConditionTracker.onEvent(ON_START_EVT, EXIT);
     }
+    boolean changeState = true;
     private void handleDeferredResume() {
         if (hasBeenResumed() && !mStateManager.getState().disableInteraction) {
@@ -923,8 +932,22 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
             DiscoveryBounce.showForHomeIfNeeded(this);
-            if (mPendingActivityRequestCode != -1 && isInState(NORMAL)) {
-                UiFactory.resetPendingActivityResults(this, mPendingActivityRequestCode);
+            if (mPendingActivityRequestCode != -1) {
+                if(isInState(NORMAL)) {
+                    //changeState
+                    //clear widget data and flag
+                    //clearAnimatedView and start Launcher to clearTask
+                    changeState = true;
+                    UiFactory.resetPendingActivityResults(this, mPendingActivityRequestCode);
+                }else{
+                    //it's google issue from the recent ui
+                    //widget-->recent-->normal/allapp
+                    //i should clear widget data and flag
+                    //don't changeState
+                    //don't start Launcher to clearTask
+                    changeState = false;
+                    onActivityResult(mPendingActivityRequestCode, RESULT_CANCELED, null);
+                }
             }
             mDeferredResumePending = false;
         } else {
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值