Android11 , Launcher3 切换阿拉伯语,最近应用(后台)不能滑动
Launcher3 切换阿拉伯语,最近应用(后台)不能滑动
Launcher3QuickStep.apk
quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
src/com/android/launcher3/PagedView.java
思路:
找到负责滑动的类,在其对应的函数中,加入日志。
切换成中文,点击Recent 键,进入最近应用界面, 滑动一次,抓取日志。
然后切换成阿拉伯语,执行和上面相同的操作,再一次抓取日志,然后对比日志,看看是否存在差异.
中文日志:
10-01 16:07:19.324 31445 31445 D tang25 : getScrollForPage mPageScrolls == nullfalse----true
10-01 16:07:19.324 31445 31445 D tang25 : computeMaxScroll mIsRtl: true
10-01 16:07:19.324 31445 31445 D tang25 : mDisallowScrollToClearAll: false
10-01 16:07:19.324 31445 31445 D tang25 : computeMaxScroll mTaskViewStartIndex: 0
10-01 16:07:19.324 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.324 31445 31445 D tang25 : updateMinAndMaxScrollX->mMaxScroll:0
10-01 16:07:19.324 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.325 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.325 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.328 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.328 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.332 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.332 31445 31445 D tang25 : computeMaxScroll mIsRtl: true
10-01 16:07:19.332 31445 31445 D tang25 : mDisallowScrollToClearAll: true
10-01 16:07:19.332 31445 31445 D tang25 : computeMaxScroll mTaskViewStartIndex: 0
10-01 16:07:19.332 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.332 31445 31445 D tang25 : updateMinAndMaxScrollX->mMaxScroll:0
10-01 16:07:19.350 31445 31445 D tang25 : getScrollForPage mPageScrolls == nullfalse----true
10-01 16:07:19.350 31445 31445 D tang25 : computeMaxScroll mIsRtl: true
10-01 16:07:19.350 31445 31445 D tang25 : mDisallowScrollToClearAll: false
10-01 16:07:19.350 31445 31445 D tang25 : computeMaxScroll mTaskViewStartIndex: 0
10-01 16:07:19.350 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.350 31445 31445 D tang25 : updateMinAndMaxScrollX->mMaxScroll:0
10-01 16:07:19.372 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.372 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.408 31445 31445 D tang25 : getScrollForPage mPageScrolls == nullfalse----true
10-01 16:07:19.408 31445 31445 D tang25 : computeMaxScroll mIsRtl: true
10-01 16:07:19.408 31445 31445 D tang25 : mDisallowScrollToClearAll: false
10-01 16:07:19.408 31445 31445 D tang25 : computeMaxScroll mTaskViewStartIndex: 0
10-01 16:07:19.408 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.408 31445 31445 D tang25 : updateMinAndMaxScrollX->mMaxScroll:5828
10-01 16:07:19.408 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.408 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.446 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.446 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.460 31445 31445 D tang25 : getScrollForPage mPageScrolls == nullfalse----true
10-01 16:07:19.460 31445 31445 D tang25 : computeMaxScroll mIsRtl: true
10-01 16:07:19.460 31445 31445 D tang25 : mDisallowScrollToClearAll: false
10-01 16:07:19.460 31445 31445 D tang25 : computeMaxScroll mTaskViewStartIndex: 0
10-01 16:07:19.460 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:07:19.460 31445 31445 D tang25 : updateMinAndMaxScrollX->mMaxScroll:5828
阿拉伯语日志:
10-01 16:08:24.982 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:08:24.982 31445 31445 D tang25 : computeMaxScroll mIsRtl: false
10-01 16:08:24.982 31445 31445 D tang25 : mDisallowScrollToClearAll: false
10-01 16:08:24.982 31445 31445 D tang25 : computeMaxScroll mTaskViewStartIndex: 0
10-01 16:08:24.982 31445 31445 D tang25 : computeMaxScroll final indexOfChild:x2 :1
10-01 16:08:24.982 31445 31445 D tang25 : getScrollForPage mPageScrolls == nullfalse----true
10-01 16:08:24.982 31445 31445 D tang25 : updateMinAndMaxScrollX->mMaxScroll:0
10-01 16:08:24.983 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:08:24.983 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:08:24.983 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:08:24.984 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:08:24.985 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:08:24.985 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:08:24.985 31445 31445 D tang25 : computeMaxScroll mIsRtl: false
10-01 16:08:24.985 31445 31445 D tang25 : mDisallowScrollToClearAll: true
10-01 16:08:24.985 31445 31445 D tang25 : computeMaxScroll mTaskViewStartIndex: 0
10-01 16:08:24.985 31445 31445 D tang25 : computeMaxScroll before indexOfChild x1:0
10-01 16:08:24.985 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:08:24.985 31445 31445 D tang25 : updateMinAndMaxScrollX->mMaxScroll:0
10-01 16:08:24.988 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:08:24.988 31445 31445 D tang25 : computeMaxScroll mIsRtl: false
10-01 16:08:24.988 31445 31445 D tang25 : mDisallowScrollToClearAll: false
10-01 16:08:24.988 31445 31445 D tang25 : computeMaxScroll mTaskViewStartIndex: 0
10-01 16:08:24.988 31445 31445 D tang25 : computeMaxScroll final indexOfChild:x2 :1
10-01 16:08:24.988 31445 31445 D tang25 : getScrollForPage mPageScrolls == nullfalse----true
10-01 16:08:24.988 31445 31445 D tang25 : updateMinAndMaxScrollX->mMaxScroll:0
10-01 16:08:25.012 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:08:25.012 31445 31445 D tang25 : computeMaxScroll mIsRtl: false
10-01 16:08:25.012 31445 31445 D tang25 : mDisallowScrollToClearAll: false
10-01 16:08:25.012 31445 31445 D tang25 : computeMaxScroll mTaskViewStartIndex: 0
10-01 16:08:25.012 31445 31445 D tang25 : computeMaxScroll final indexOfChild:x2 :1
10-01 16:08:25.012 31445 31445 D tang25 : getScrollForPage mPageScrolls == nullfalse----true
10-01 16:08:25.012 31445 31445 D tang25 : updateMinAndMaxScrollX->mMaxScroll:0
10-01 16:08:25.023 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:08:25.023 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:08:25.033 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:08:25.033 31445 31445 D tang25 : computeMaxScroll mIsRtl: false
10-01 16:08:25.033 31445 31445 D tang25 : mDisallowScrollToClearAll: false
10-01 16:08:25.033 31445 31445 D tang25 : computeMaxScroll mTaskViewStartIndex: 0
10-01 16:08:25.033 31445 31445 D tang25 : computeMaxScroll final indexOfChild:x2 :6
10-01 16:08:25.033 31445 31445 D tang25 : getScrollForPage mPageScrolls == nullfalse----true
10-01 16:08:25.033 31445 31445 D tang25 : updateMinAndMaxScrollX->mMaxScroll:0
10-01 16:08:25.033 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
10-01 16:08:25.033 31445 31445 D tang25 : getScrollForPage mPageScrolls index:0
对比日志,发现差异 updateMinAndMaxScrollX->mMaxScroll:0,中文可以滑动,它这个mMaxScroll 不是一直为0的,
找到相应函数,打印退栈,查看调用流程,Log.d(TAG, Log.getStackTraceString(new Throwable()));
at com.android.launcher3.PagedView.getScrollForPage(PagedView.java:1062)
at com.android.quickstep.views.RecentsView.computeMaxScroll(RecentsView.java:2370)
at com.android.launcher3.PagedView.updateMinAndMaxScrollX(PagedView.java:712)
at com.android.launcher3.PagedView.onLayout(PagedView.java:647)
at com.android.quickstep.views.RecentsView.onLayout(RecentsView.java:1879)
at android.view.View.layout(View.java:22905)
at android.view.ViewGroup.layout(ViewGroup.java:6389)
at com.android.quickstep.views.RecentsView.showCurrentTask(RecentsView.java:1240)
at com.android.quickstep.AppToOverviewAnimationProvider.onActivityReady(AppToOverviewAnimationProvider.java:77)
at com.android.quickstep.OverviewCommandHelper$RecentsActivityCommand.onActivityReady(OverviewCommandHelper.java:234)
at com.android.quickstep.OverviewCommandHelper$RecentsActivityCommand.lambda$QLBi40m2HnRcFakJUh6rtde_WJM(Unknown Source:0)
at com.android.quickstep.-$$Lambda$OverviewCommandHelper$RecentsActivityCommand$QLBi40m2HnRcFakJUh6rtde_WJM.test(Unknown Source:4)
at com.android.quickstep.FallbackActivityInterface.lambda$createActivityInitListener$0(FallbackActivityInterface.java:97)
at com.android.quickstep.-$$Lambda$FallbackActivityInterface$5yFo4vs3bnvBoGmsaVSWVYH888g.test(Unknown Source:6)
at com.android.quickstep.util.ActivityInitListener.handleInit(ActivityInitListener.java:56)
at com.android.quickstep.util.ActivityInitListener.init(ActivityInitListener.java:52)
at com.android.launcher3.util.ActivityTracker.handleIntent(ActivityTracker.java:81)
at com.android.launcher3.util.ActivityTracker.handleCreate(ActivityTracker.java:68)
at com.android.quickstep.RecentsActivity.onCreate(RecentsActivity.java:262)
at android.app.Activity.performCreate(Activity.java:7994)
at android.app.Activity.performCreate(Activity.java:7978)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1310)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3405)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3596)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2067)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7705)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:952)
流程 RecentsView.onLayout() -> PagedView.updateMinAndMaxScrollX() -> RecentsView.computeMaxScroll() -> PagedView.getScrollForPage()
RecentsView 继承了PagedView,复现了其computeMaxScroll()函数,切换语言后导致mMaxScroll 为0!
改动
方案:不让其走子类的computeMaxScroll(), 走父类的,强制为mMaxScroll赋值!!!
PagedView.java
protected void updateMinAndMaxScrollX() {
mMinScroll = computeMinScroll();
//add start
if(mIsRtl){
mMaxScroll = computeMaxScroll();
}else {
int childCount = getChildCount();
if (childCount > 0) {
final int index = false ? 0 : childCount - 1;
mMaxScroll = getScrollForPage(index);
} else {
mMaxScroll = 0;
}
}
Log.d("TAG","updateMinAndMaxScrollX->mMaxScroll:"+mMaxScroll);
//add end
}