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

+32 -24
View File
@@ -18,10 +18,15 @@ package com.android.launcher3;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo;
import android.os.Process;
import android.os.UserHandle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.PackageInstallerCompat;
import com.android.launcher3.util.FlagOp;
import com.android.launcher3.util.ItemInfoMatcher;
@@ -69,7 +74,7 @@ public class AllAppsList {
if (!mAppFilter.shouldShowApp(info.componentName)) {
return;
}
if (findActivity(data, info.componentName, info.user)) {
if (findAppInfo(info.componentName, info.user) != null) {
return;
}
mIconCache.getTitleAndIcon(info, activityInfo, true /* useLowResIcon */);
@@ -78,6 +83,25 @@ public class AllAppsList {
added.add(info);
}
public void addPromiseApp(Context context,
PackageInstallerCompat.PackageInstallInfo installInfo) {
ApplicationInfo applicationInfo = LauncherAppsCompat.getInstance(context)
.getApplicationInfo(installInfo.packageName, 0, Process.myUserHandle());
// only if not yet installed
if (applicationInfo == null) {
PromiseAppInfo info = new PromiseAppInfo(installInfo);
mIconCache.getTitleAndIcon(info, info.usingLowResIcon);
data.add(info);
added.add(info);
}
}
public void removePromiseApp(AppInfo appInfo) {
// the <em>removed</em> list is handled by the caller
// so not adding it here
data.remove(appInfo);
}
public void clear() {
data.clear();
// TODO: do we clear these too?
@@ -169,9 +193,7 @@ public class AllAppsList {
// Find enabled activities and add them to the adapter
// Also updates existing activities with new labels/icons
for (final LauncherActivityInfo info : matches) {
AppInfo applicationInfo = findApplicationInfoLocked(
info.getComponentName().getPackageName(), user,
info.getComponentName().getClassName());
AppInfo applicationInfo = findAppInfo(info.getComponentName(), user);
if (applicationInfo == null) {
add(new AppInfo(context, info, user), info);
} else {
@@ -208,28 +230,14 @@ public class AllAppsList {
}
/**
* Returns whether <em>apps</em> contains <em>component</em>.
* Find an AppInfo object for the given componentName
*
* @return the corresponding AppInfo or null
*/
private static boolean findActivity(ArrayList<AppInfo> apps, ComponentName component,
UserHandle user) {
final int N = apps.size();
for (int i = 0; i < N; i++) {
final AppInfo info = apps.get(i);
if (info.user.equals(user) && info.componentName.equals(component)) {
return true;
}
}
return false;
}
/**
* Find an ApplicationInfo object for the given packageName and className.
*/
private AppInfo findApplicationInfoLocked(String packageName, UserHandle user,
String className) {
private @Nullable AppInfo findAppInfo(@NonNull ComponentName componentName,
@NonNull UserHandle user) {
for (AppInfo info: data) {
if (user.equals(info.user) && packageName.equals(info.componentName.getPackageName())
&& className.equals(info.componentName.getClassName())) {
if (componentName.equals(info.componentName) && user.equals(info.user)) {
return info;
}
}