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);
|
mIntentsOnWorkspaceFromUpgradePath = mWorkspace.getUniqueComponents(true, null);
|
||||||
}
|
}
|
||||||
PackageInstallerCompat.getInstance(this).onFinishBind();
|
PackageInstallerCompat.getInstance(this).onFinishBind();
|
||||||
|
mModel.recheckRestoredItems(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendLoadingCompleteBroadcastIfNecessary() {
|
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.
|
* Update the state of a package, typically related to install state.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -198,6 +198,7 @@ public class LauncherModel extends BroadcastReceiver
|
|||||||
ArrayList<ItemInfo> addAnimated,
|
ArrayList<ItemInfo> addAnimated,
|
||||||
ArrayList<AppInfo> addedApps);
|
ArrayList<AppInfo> addedApps);
|
||||||
public void bindAppsUpdated(ArrayList<AppInfo> apps);
|
public void bindAppsUpdated(ArrayList<AppInfo> apps);
|
||||||
|
public void bindAppsRestored(ArrayList<AppInfo> apps);
|
||||||
public void updatePackageState(ArrayList<PackageInstallInfo> installInfo);
|
public void updatePackageState(ArrayList<PackageInstallInfo> installInfo);
|
||||||
public void updatePackageBadge(String packageName);
|
public void updatePackageBadge(String packageName);
|
||||||
public void bindComponentsRemoved(ArrayList<String> packageNames,
|
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 {
|
private class PackageUpdatedTask implements Runnable {
|
||||||
int mOp;
|
int mOp;
|
||||||
String[] mPackages;
|
String[] mPackages;
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
mInstaller.unregisterSessionCallback(mCallback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -112,7 +111,7 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat {
|
|||||||
// Not yet ready
|
// Not yet ready
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((mPendingReplays.size() == 0) && (newInfo == null)) {
|
if ((mPendingReplays.size() == 0) && (newInfo == null) && mPendingBadgeUpdates.isEmpty()) {
|
||||||
// Nothing to update
|
// Nothing to update
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user