• 打开google search,从taskbar拖拽全屏应用比如Google进入分屏,页面出现Launcher报错


    相关log:
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: FATAL EXCEPTION: main
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: Process: com.android.launcher, PID: 11673
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: java.lang.SecurityException: Attempt to launch activity without category Intent.CATEGORY_LAUNCHER ComponentInfo{com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.MainInfoGatewayInternal}
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at android.os.Parcel.createExceptionOrNull(Parcel.java:2455)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at android.os.Parcel.createException(Parcel.java:2439)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:2422)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:2364)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at android.content.pm.ILauncherApps$Stub$Proxy.getActivityLaunchIntent(ILauncherApps.java:1285)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at android.content.pm.LauncherApps.getMainActivityLaunchIntent(LauncherApps.java:761)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at com.android.systemui.shared.system.LauncherAppsCompat.getMainActivityLaunchIntent(LauncherAppsCompat.java:32)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at com.android.launcher3.taskbar.TaskbarDragController.startSystemDrag(TaskbarDragController.java:302)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at com.android.launcher3.taskbar.TaskbarDragController.callOnDragStart(TaskbarDragController.java:254)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at com.android.launcher3.dragndrop.DragController.handleMoveEvent(DragController.java:895)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at com.android.launcher3.dragndrop.DragController.onDriverDragMove(DragController.java:458)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at com.android.launcher3.dragndrop.DragDriver$InternalDragDriver.onTouchEvent(DragDriver.java:182)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at com.android.launcher3.dragndrop.DragController.onControllerTouchEvent(DragController.java:573)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at com.android.launcher3.views.BaseDragLayer.onTouchEvent(BaseDragLayer.java:283)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at android.view.View.dispatchTouchEvent(View.java:14633)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3167)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2809)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at com.android.launcher3.views.BaseDragLayer.dispatchTouchEvent(BaseDragLayer.java:318)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at com.android.launcher3.taskbar.TaskbarDragLayer.dispatchTouchEvent(TaskbarDragLayer.java:251)
    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    1、通过log来看报错信息应该是在启动 com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.MainInfoGatewayInternal 时候缺少category Intent.CATEGORY_LAUNCHER

    通过对Google Search进行反编译查看AndroidManifest进行查看

    <activity-alias android:excludeFromRecents="true" android:exported="true" android:label="@string/search_activity_name" android:name="com.google.android.googlequicksearchbox.MainInfoGatewayInternal" android:noHistory="true" android:process=":search" android:targetActivity="com.google.android.googlequicksearchbox.SearchActivity" android:taskAffinity="" android:theme="@android:style/Theme.NoDisplay" android:visibleToInstantApps="true">
    <meta-data android:name="alias_name" android:value="MainInfoGatewayInternal"/>
    <meta-data android:name="instantapps.clients.allowed" android:value="true"/>
    <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.INFO"/>
    intent-filter>
    activity-alias>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    在启动com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.MainInfoGatewayInternal 时候缺少category Intent.CATEGORY_LAUNCHER

    2.通过抓取START u0 log发现在界面点击以及hotseat点击google应用时均启动的是SearchActivity。

    adb logcat -b all | grep “START u0”

    界面点击或者hotseat点击:

    08-23 23:36:56.290   919  6748 I ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.google.android.googlequicksearchbox/.SearchActivity bnds=[60,425][373,650]} from uid 10059
    
    • 1

    只有在crash问题发生点:recent最近应用,这里启动的Activity是com.google.android.googlequicksearchbox.MainInfoGatewayInternal。由于这里Google应用没有配置 Intent.CATEGORY_LAUNCHER,导致在启动这个Activity的时候找不到因此报错。

    3.由于时Google应用我们无法直接进行修改。通过查看代码调用栈,启动应用的位置在launcher里面:

    08-17 18:34:33.907 11673 11673 E AndroidRuntime: at com.android.launcher3.taskbar.TaskbarDragController.startSystemDrag(TaskbarDragController.java:302)

    我们在这里直接硬编码进行规避,由于正常都是走的com.google.android.googlequicksearchbox/.SearchActivity,只有这种情况走com.google.android.googlequicksearchbox.MainInfoGatewayInternal。我们先让他走进MainInfoGatewayInternal然后在重新设置启动的应用包名和类名为SearchActivity。即可规避crash

    startSystemDrag()

    if(item!=null && item.getTargetComponent()!=null && item.getTargetComponent().getPackageName()!=null && item.getTargetComponent().getPackageName().equals("com.google.android.googlequicksearchbox")
          && item.getTargetComponent().getClassName().equals("com.google.android.googlequicksearchbox.MainInfoGatewayInternal")){
                ComponentName cn = new ComponentName(item.getTargetComponent().getPackageName(), "com.google.android.googlequicksearchbox.SearchActivity");
                item.getIntent().setComponent(cn);
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
  • 相关阅读:
    【JAVA springframework.http】如何发送HTTP请求
    HDLBits-Edgecapture
    2022年度嵌入式C语言面试题库(含答案)
    计算机视觉——飞桨深度学习实战-深度学习网络模型
    基于神经网络的预测控制,神经网络预测系统应用
    Electron笔记
    Android笔记(四)Activity之间传递可序列化的数据的优化处理
    Linxu 查看磁盘空间命令
    flask与fastapi性能测试
    【ArcGIS Pro微课1000例】0030:ArcGIS Pro中自带晕渲地貌工具的妙用
  • 原文地址:https://blog.csdn.net/ll_j_21/article/details/126515164