Show promise app icon in All Apps while installation process.

This CL only modifies the model and is behind a feature flag
which per default is set to false.
The app icon will appear as a promise icon, it reacts on icon
or label changes and the icon will be remove on finishing the
installation process. With this CL the progress of the installation
process is not visible.

Bug: 23952570

Change-Id: I510825d0b0b1b01eb14f7e50f0a2358b0d8b99b5
This commit is contained in:
Mario Bertschler committed 2017-03-17 09:21:35 -07:00
1 parent 04030d5a44
commit 817afa3447
9 files changed
+242 -48

No files matched your search

@@ -25,7 +25,9 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.PackageInstaller;
import android.net.Uri;
import android.os.Handler;
import android.os.HandlerThread;
@@ -573,6 +575,25 @@ public class LauncherModel extends BroadcastReceiver
screensUri, null, null, null, LauncherSettings.WorkspaceScreens.SCREEN_RANK));
}
public void onInstallSessionCreated(final PackageInstallInfo sessionInfo) {
enqueueModelUpdateTask(new ExtendedModelTask() {
@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
apps.addPromiseApp(app.getContext(), sessionInfo);
if (!apps.added.isEmpty()) {
final ArrayList<AppInfo> arrayList = new ArrayList<>(apps.added);
apps.added.clear();
scheduleCallbackTask(new CallbackTask() {
@Override
public void execute(Callbacks callbacks) {
callbacks.bindAppsAdded(null, null, null, arrayList);
}
});
}
}
});
}
/**
* Runnable for the thread that loads the contents of the launcher:
* - workspace icons
@@ -1691,10 +1712,21 @@ public class LauncherModel extends BroadcastReceiver
});
}
}
if (FeatureFlags.LAUNCHER3_PROMISE_APPS_IN_ALL_APPS) {
// get all active sessions and add them to the all apps list
PackageInstallerCompat installer = PackageInstallerCompat.getInstance(mContext);
for (PackageInstaller.SessionInfo info : installer.getAllVerifiedSessions()) {
mBgAllAppsList.addPromiseApp(mContext,
PackageInstallInfo.fromInstallingState(info));
}
}
// Huh? Shouldn't this be inside the Runnable below?
final ArrayList<AppInfo> added = mBgAllAppsList.added;
mBgAllAppsList.added = new ArrayList<AppInfo>();
// Post callback on main thread
mUiExecutor.execute(new Runnable() {
public void run() {