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

一、背景


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

二、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 

恢复加入即可。

       

            android:name=".LauncherActivity"

            android:targetActivity=".files.LauncherActivity"

            android:enabled="@bool/is_launcher_enabled"

            android:label="@string/launcher_label"

            android:icon="@drawable/launcher_icon" >

           

               

               

           

           

       

四、解决方案

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

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

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

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

private void loadAllApps() {

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

        final List 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 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);

        }

五、搞定。


你可能感兴趣的:(文件管理器闪退,重启不可恢复)