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
2017-03-15 11:56:47 -07:00
parent 04030d5a44
commit 817afa3447
9 changed files with 242 additions and 48 deletions

View File

@@ -18,15 +18,18 @@ package com.android.launcher3.model;
import android.content.ComponentName;
import com.android.launcher3.AllAppsList;
import com.android.launcher3.AppInfo;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherModel.CallbackTask;
import com.android.launcher3.LauncherModel.Callbacks;
import com.android.launcher3.PromiseAppInfo;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.compat.PackageInstallerCompat;
import com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo;
import java.util.ArrayList;
import java.util.HashSet;
/**
@@ -47,6 +50,46 @@ public class PackageInstallStateChangedTask extends ExtendedModelTask {
return;
}
synchronized (apps) {
final ArrayList<AppInfo> updated = new ArrayList<>();
final ArrayList<AppInfo> removed = new ArrayList<>();
for (int i=0; i < apps.size(); i++) {
final AppInfo appInfo = apps.get(i);
final ComponentName tgtComp = appInfo.getTargetComponent();
if (tgtComp != null && tgtComp.getPackageName().equals(mInstallInfo.packageName)) {
if (appInfo instanceof PromiseAppInfo) {
final PromiseAppInfo promiseAppInfo = (PromiseAppInfo) appInfo;
if (mInstallInfo.state == PackageInstallerCompat.STATUS_INSTALLING) {
promiseAppInfo.level = mInstallInfo.progress;
updated.add(appInfo);
} else if (mInstallInfo.state == PackageInstallerCompat.STATUS_FAILED
|| mInstallInfo.state == PackageInstallerCompat.STATUS_INSTALLED) {
apps.removePromiseApp(appInfo);
removed.add(appInfo);
}
}
}
}
if (!updated.isEmpty()) {
scheduleCallbackTask(new CallbackTask() {
@Override
public void execute(Callbacks callbacks) {
// TODO: this currently causes unnecessary relayouts
// we need to introduce a new bindPromiseAppsChanged
callbacks.bindAppsUpdated(updated);
}
});
}
if (!removed.isEmpty()) {
scheduleCallbackTask(new CallbackTask() {
@Override
public void execute(Callbacks callbacks) {
callbacks.bindAppInfosRemoved(removed);
}
});
}
}
synchronized (dataModel) {
final HashSet<ItemInfo> updates = new HashSet<>();
for (ItemInfo info : dataModel.itemsIdMap) {
@@ -56,7 +99,6 @@ public class PackageInstallStateChangedTask extends ExtendedModelTask {
if (si.isPromise() && (cn != null)
&& mInstallInfo.packageName.equals(cn.getPackageName())) {
si.setInstallProgress(mInstallInfo.progress);
if (mInstallInfo.state == PackageInstallerCompat.STATUS_FAILED) {
// Mark this info as broken.
si.status &= ~ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE;