am 9202c64f: am fdbfba88: am 8cce9dd8: DO NOT MERGE Rechecking unrestored items when launcher gets created
* commit '9202c64f75cfd422c8a9a143dd71dd30e109301b': DO NOT MERGE Rechecking unrestored items when launcher gets created
This commit is contained in:
@@ -4610,6 +4610,7 @@ public class Launcher extends Activity
|
||||
mIntentsOnWorkspaceFromUpgradePath = mWorkspace.getUniqueComponents(true, null);
|
||||
}
|
||||
PackageInstallerCompat.getInstance(this).onFinishBind();
|
||||
mModel.recheckRestoredItems(this);
|
||||
}
|
||||
|
||||
private void sendLoadingCompleteBroadcastIfNecessary() {
|
||||
@@ -4718,6 +4719,24 @@ public class Launcher extends Activity
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Packages were restored
|
||||
*/
|
||||
public void bindAppsRestored(final ArrayList<AppInfo> apps) {
|
||||
Runnable r = new Runnable() {
|
||||
public void run() {
|
||||
bindAppsRestored(apps);
|
||||
}
|
||||
};
|
||||
if (waitUntilResume(r)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mWorkspace != null) {
|
||||
mWorkspace.updateShortcutsAndWidgets(apps);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the state of a package, typically related to install state.
|
||||
*
|
||||
|
||||
@@ -198,6 +198,7 @@ public class LauncherModel extends BroadcastReceiver
|
||||
ArrayList<ItemInfo> addAnimated,
|
||||
ArrayList<AppInfo> addedApps);
|
||||
public void bindAppsUpdated(ArrayList<AppInfo> apps);
|
||||
public void bindAppsRestored(ArrayList<AppInfo> apps);
|
||||
public void updatePackageState(ArrayList<PackageInstallInfo> installInfo);
|
||||
public void updatePackageBadge(String packageName);
|
||||
public void bindComponentsRemoved(ArrayList<String> packageNames,
|
||||
@@ -2949,6 +2950,64 @@ public class LauncherModel extends BroadcastReceiver
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Workaround to re-check unrestored items, in-case they were installed but the Package-ADD
|
||||
* runnable was missed by the launcher.
|
||||
*/
|
||||
public void recheckRestoredItems(final Context context) {
|
||||
Runnable r = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(context);
|
||||
HashSet<String> installedPackages = new HashSet<String>();
|
||||
UserHandleCompat user = UserHandleCompat.myUserHandle();
|
||||
synchronized(sBgLock) {
|
||||
for (ItemInfo info : sBgItemsIdMap.values()) {
|
||||
if (info instanceof ShortcutInfo) {
|
||||
ShortcutInfo si = (ShortcutInfo) info;
|
||||
if (si.isPromise() && si.getTargetComponent() != null
|
||||
&& launcherApps.isPackageEnabledForProfile(
|
||||
si.getTargetComponent().getPackageName(), user)) {
|
||||
installedPackages.add(si.getTargetComponent().getPackageName());
|
||||
}
|
||||
} else if (info instanceof LauncherAppWidgetInfo) {
|
||||
LauncherAppWidgetInfo widget = (LauncherAppWidgetInfo) info;
|
||||
if (widget.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY)
|
||||
&& launcherApps.isPackageEnabledForProfile(
|
||||
widget.providerName.getPackageName(), user)) {
|
||||
installedPackages.add(widget.providerName.getPackageName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!installedPackages.isEmpty()) {
|
||||
final ArrayList<AppInfo> restoredApps = new ArrayList<AppInfo>();
|
||||
for (String pkg : installedPackages) {
|
||||
for (LauncherActivityInfoCompat info : launcherApps.getActivityList(pkg, user)) {
|
||||
restoredApps.add(new AppInfo(context, info, user, mIconCache, null));
|
||||
}
|
||||
}
|
||||
|
||||
final Callbacks callbacks = mCallbacks != null ? mCallbacks.get() : null;
|
||||
if (!restoredApps.isEmpty()) {
|
||||
mHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
|
||||
if (callbacks == cb && cb != null) {
|
||||
callbacks.bindAppsRestored(restoredApps);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
sWorker.post(r);
|
||||
}
|
||||
|
||||
private class PackageUpdatedTask implements Runnable {
|
||||
int mOp;
|
||||
String[] mPackages;
|
||||
|
||||
@@ -81,7 +81,6 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat {
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
mInstaller.unregisterSessionCallback(mCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,7 +111,7 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat {
|
||||
// Not yet ready
|
||||
return;
|
||||
}
|
||||
if ((mPendingReplays.size() == 0) && (newInfo == null)) {
|
||||
if ((mPendingReplays.size() == 0) && (newInfo == null) && mPendingBadgeUpdates.isEmpty()) {
|
||||
// Nothing to update
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user