自学内容网 自学内容网

Android 13 Launcher预置Settings页面快捷方式 提示未安装该应用

11-02 05:58:13.192  2022  2022 E AppLauncher: Unable to launch. tag=WorkspaceItemInfo(id=10 type=APP container=# com.android.launcher3.logger.LauncherAtom$ContainerInfo@1ad470f
11-02 05:58:13.192  2022  2022 E AppLauncher: workspace {
11-02 05:58:13.192  2022  2022 E AppLauncher:   grid_x: 5
11-02 05:58:13.192  2022  2022 E AppLauncher:   grid_y: 4
11-02 05:58:13.192  2022  2022 E AppLauncher:   page_index: 0
11-02 05:58:13.192  2022  2022 E AppLauncher: } targetComponent=ComponentInfo{com.android.settings/com.android.settings.Settings$SecureEraseActivity} screen=0 cell(5,4) span(1,1) minSpan(1,1) rank=0 user=UserHandle{0} title=安全擦除) intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.settings/.Settings$SecureEraseActivity bnds=[2080,1048][2320,1256] }
11-02 05:58:13.192  2022  2022 E AppLauncher: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.settings/.Settings$SecureEraseActivity bnds=[2080,1048][2320,1256] } from ProcessRecord{ef2c8b9 2022:com.android.launcher3/u0a82} (pid=2022, uid=10082) requires android.permission.BACKUP
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.os.Parcel.createExceptionOrNull(Parcel.java:3017)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.os.Parcel.createException(Parcel.java:3001)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.os.Parcel.readException(Parcel.java:2984)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.os.Parcel.readException(Parcel.java:2926)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:2043)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.app.Instrumentation.execStartActivity(Instrumentation.java:1801)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.app.Activity.startActivityForResult(Activity.java:5504)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at com.android.launcher3.Launcher.startActivityForResult(Launcher.java:1808)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at com.android.launcher3.BaseQuickstepLauncher.startActivityForResult(BaseQuickstepLauncher.java:287)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.app.Activity.startActivity(Activity.java:5956)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at com.android.launcher3.views.AppLauncher.startActivitySafely(AppLauncher.java:99)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at com.android.launcher3.Launcher.startActivitySafely(Launcher.java:2183)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at com.android.launcher3.uioverrides.QuickstepLauncher.startActivitySafely(QuickstepLauncher.java:178)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at com.android.launcher3.touch.ItemClickHandler.startAppShortcutOrInfoActivity(ItemClickHandler.java:381)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at com.android.launcher3.touch.ItemClickHandler.onClickAppShortcut(ItemClickHandler.java:304)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at com.android.launcher3.touch.ItemClickHandler.onClick(ItemClickHandler.java:97)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at com.android.launcher3.touch.ItemClickHandler.$r8$lambda$c3IcSovkrXGdCZtXy0f_A5Sz5VA(Unknown Source:0)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at com.android.launcher3.touch.ItemClickHandler$$ExternalSyntheticLambda4.onClick(Unknown Source:0)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.view.View.performClick(View.java:7511)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.view.View.performClickInternal(View.java:7484)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.view.View$PerformClick.run(View.java:29472)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.os.Handler.handleCallback(Handler.java:942)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.os.Handler.dispatchMessage(Handler.java:99)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.os.Looper.loopOnce(Looper.java:201)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.os.Looper.loop(Looper.java:288)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at android.app.ActivityThread.main(ActivityThread.java:8061)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at java.lang.reflect.Method.invoke(Native Method)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:703)
11-02 05:58:13.192  2022  2022 E AppLauncher:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)
  • 从日志信息来看,尝试从Android启动器(Launcher)应用(com.android.launcher3)启动一个特定的设置活动(com.android.settings.Settings$SecureEraseActivity),即“安全擦除”功能时,遇到了权限问题。错误信息显示为java.lang.SecurityException:
    Permission Denial,具体指出需要从ProcessRecord{ef2c8b9
    2022:com.android.launcher3/u0a82}(即启动器进程)启动的Intent需要android.permission.BACKUP权限,但当前进程没有该权限。

  • 解决方案: 检查应用权限:
    确保启动器应用(com.android.launcher3)是否应该拥有android.permission.BACKUP权限。通常,这个权限是用来允许应用备份和恢复数据的,而不是用来启动特定活动的。因此,这可能是一个权限误用的情况。
    如果启动器不需要这个权限来执行其正常功能,那么可能是一个错误的权限请求或代码实现。因此删除android.permission.BACKUP权限。

//Launcher桌面微件快捷方式预置实现
packages/apps/Launcher3/res/xml/default_workspace_x.xml

<resolve
    launcher:container="-101"
    launcher:screen="3"
    launcher:x="1"
    launcher:y="1" >
    <favorite
        launcher:packageName="com.android.settings"
        launcher:className="com.android.settigs.Settings$SecureEraseActivity"/>
    <favorite launcher:uri="#Intent;action=com.android.settings.action.SECURE_ERASE;end" />
</resolve>

//Settings页面配置
packages/apps/Settigns/AndroidManifest.xml

<activity android:name="Settings$SecureEraseActivity"
          android:icon="@drawable/ic_settings_secure_erase"
          android:label="@string/secure_erase_title"
          android:exported="true"
          android:theme="@style/SudThemeGlif.Light"
          android:taskAffinity="com.android.settings"
          android:parentActivityName="Settings">
    <intent-filter>
        <action android:name="com.android.settings.action.SECURE_ERASE"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter android:priority="-2">
        <action android:name="com.android.settings.action.SETTINGS" />
    </intent-filter>
    <meta-data android:name="com.android.settings.category"
        android:value="com.android.settings.category.personal" />
    <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
               android:value="com.android.settings.SecureErase"/>
    <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
        android:value="true" />
</activity>

原文地址:https://blog.csdn.net/Sqq_yj/article/details/143446897

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!