文件管理器闪退,重启不可恢复

一、背景


    最近测试设置存储,发现拷贝、复制,必现设置闪退报错,而且不可以恢复

二、log 查看

01-10 16:35:21.428 14609 14609 D AndroidRuntime: Shutting down VM

01-10 16:35:21.428 14609 14609 E AndroidRuntime: FATAL EXCEPTION: main

01-10 16:35:21.428 14609 14609 E AndroidRuntime: Process: com.android.documentsui, PID: 14609

01-10 16:35:21.428 14609 14609 E AndroidRuntime: java.lang.IllegalStateException: Launcher activity not found for package com.android.documentsui

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.os.Parcel.createException(Parcel.java:1958)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:1918)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:1868)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.content.pm.IShortcutService$Stub$Proxy.setDynamicShortcuts(IShortcutService.java:423)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.content.pm.ShortcutManager.setDynamicShortcuts(ShortcutManager.java:92)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at com.android.documentsui.ShortcutsUpdater.update(ShortcutsUpdater.java:60)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at com.android.documentsui.files.-$$Lambda$fW6dnoH4q61dZKfQpx8CIejn0Qo.accept(Unknown Source:4)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at com.android.documentsui.sidebar.RootsFragment$5.onLoadFinished(RootsFragment.java:236)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at com.android.documentsui.sidebar.RootsFragment$5.onLoadFinished(RootsFragment.java:212)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.app.LoaderManagerImpl$LoaderInfo.callOnLoadFinished(LoaderManager.java:497)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.app.LoaderManagerImpl$LoaderInfo.onLoadComplete(LoaderManager.java:465)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.content.Loader.deliverResult(Loader.java:157)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at com.android.documentsui.roots.RootsLoader.deliverResult(RootsLoader.java:67)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at com.android.documentsui.roots.RootsLoader.deliverResult(RootsLoader.java:31)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.content.AsyncTaskLoader.dispatchOnLoadComplete(AsyncTaskLoader.java:272)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.content.AsyncTaskLoader$LoadTask.onPostExecute(AsyncTaskLoader.java:96)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.os.AsyncTask.finish(AsyncTask.java:695)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.os.AsyncTask.access$600(AsyncTask.java:180)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:712)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6718)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: Caused by: android.os.RemoteException: Remote stack trace:

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at com.android.internal.util.Preconditions.checkState(Preconditions.java:163)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at com.android.server.pm.ShortcutService.fillInDefaultActivity(ShortcutService.java:1713)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at com.android.server.pm.ShortcutService.setDynamicShortcuts(ShortcutService.java:1755)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.content.pm.IShortcutService$Stub.onTransact(IShortcutService.java:63)

01-10 16:35:21.428 14609 14609 E AndroidRuntime: at android.os.Binder.execTransact(Binder.java:731)

01-10 16:35:21.428 14609 14609 E AndroidRuntime:

01-10 16:35:21.431  497  943 W ActivityManager:  Force finishing activity com.android.documentsui/.files.FilesActivity

三、分析过程

    通过log发现  Launcher activity not found for package com.android.documentsui

查看代码发现 1  AndroidManifest.xml 的launcher 中 的图标被干掉了,导致在拷贝复制的,找不到这个activity 

恢复加入即可。

<!-- Preserve original launcher activity from Nougat. -->

        <activity-alias

            android:name=".LauncherActivity"

            android:targetActivity=".files.LauncherActivity"

            android:enabled="@bool/is_launcher_enabled"

            android:label="@string/launcher_label"

            android:icon="@drawable/launcher_icon" >

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

            <meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" />

        </activity-alias>

四、解决方案

    为了,兼顾文件管理器正常,而且保留这个图标去掉,

继续去掉这个图标,我们可以在launcher3 中去操作,在 

package\apps\Launcher2\src\com\android\launcher3\model\LoaderTask.java 操作

在这个文件的这个函数里面操作即可

private void loadAllApps() {

        final long loadTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;

        final List<UserHandle> profiles = mUserManager.getUserProfiles();

        // Clear the list of apps

        mBgAllAppsList.clear();

        for (UserHandle user : profiles) {

            // Query for the set of apps

            final long qiaTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;

            final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);

            if (DEBUG_LOADERS) {

                Log.d(TAG, "getActivityList took "

                        + (SystemClock.uptimeMillis()-qiaTime) + "ms for user " + user);

                Log.d(TAG, "getActivityList got " + apps.size() + " apps for user " + user);

            }

            // Fail if we don't have any apps

            // TODO: Fix this. Only fail for the current user.

            if (apps == null || apps.isEmpty()) {

                return;

            }

            boolean quietMode = mUserManager.isQuietModeEnabled(user);

            // Create the ApplicationInfos

            for (int i = 0; i < apps.size(); i++) {

                LauncherActivityInfo app = apps.get(i);

                // This builds the icon bitmaps.

                mBgAllAppsList.add(new AppInfo(app, user, quietMode), app);

            }

            ManagedProfileHeuristic.onAllAppsLoaded(mApp.getContext(), apps, user);

        }

五、搞定。


推荐阅读更多精彩内容

  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 1,534评论 0 3
  • 背景一 今天调试apk 发现发送多个文件,资源管理器会闪退 查看 log 01-19 02:11:25.328 ...
    超__越阅读 246评论 0 1
  • 今年前所未有的关注了双十一,因为我隐隐约约给自己抛了个问题,如果是我怎么运营双十一?留心观察了下天猫的双十一,深感...
    xxwade阅读 139评论 0 2
  • 每天或者定期冥想的人非常推崇冥想的益处。人们有不同的理由想要进行冥想,从平静内心的嘈杂,到更好地了解自己,找到平和...
    正念冥想_阅读 1,439评论 0 5
  • 打卡日期:2019年11月3日 90天打卡累计天数 98 ❤️宣言【妈妈从此刻起要多鼓励、多赞美、少批评、少指责,...
    君超sy阅读 36评论 0 0