一撤卢、背景
????最近測試設(shè)置存儲,發(fā)現(xiàn)拷貝梧兼、復(fù)制放吩,必現(xiàn)設(shè)置閃退報錯,而且不可以恢復(fù)
二羽杰、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發(fā)現(xiàn)??Launcher activity not found for package com.android.documentsui
查看代碼發(fā)現(xiàn) 1??AndroidManifest.xml 的launcher 中 的圖標(biāo)被干掉了,導(dǎo)致在拷貝復(fù)制的考赛,找不到這個activity?
恢復(fù)加入即可惕澎。
<!-- 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>
四、解決方案
????為了颜骤,兼顧文件管理器正常唧喉,而且保留這個圖標(biāo)去掉,
繼續(xù)去掉這個圖標(biāo)忍抽,我們可以在launcher3 中去操作八孝,在?
package\apps\Launcher2\src\com\android\launcher3\model\LoaderTask.java 操作
在這個文件的這個函數(shù)里面操作即可
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);
? ? ? ? }
五、搞定鸠项。