Merge remote-tracking branch 'aosp/android12-release' into 12-dev

This commit is contained in:
Suphon Thanakornpakapong committed 2021-10-05 14:13:08 +07:00
commit cc2bd15873
1227 files changed
+77789 -38760

No files matched your search

@@ -23,11 +23,10 @@ import static com.android.launcher3.model.data.AppInfo.EMPTY_ARRAY;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.Intent;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.LauncherApps;
import android.os.LocaleList;
import android.os.Process;
import android.os.UserHandle;
import android.util.Log;
@@ -39,7 +38,6 @@ import com.android.launcher3.compat.AlphabeticIndexCompat;
import com.android.launcher3.icons.IconCache;
import com.android.launcher3.model.BgDataModel.Callbacks;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.PromiseAppInfo;
import com.android.launcher3.pm.PackageInstallInfo;
import com.android.launcher3.util.FlagOp;
import com.android.launcher3.util.ItemInfoMatcher;
@@ -140,7 +138,7 @@ public class AllAppsList {
if (findAppInfo(info.componentName, info.user) != null) {
return;
}
mIconCache.getTitleAndIcon(info, activityInfo, true /* useLowResIcon */);
mIconCache.getTitleAndIcon(info, activityInfo, false /* useLowResIcon */);
info.sectionName = mIndex.computeSectionName(info.title);
data.add(info);
@@ -148,11 +146,10 @@ public class AllAppsList {
}
public void addPromiseApp(Context context, PackageInstallInfo installInfo) {
ApplicationInfo applicationInfo = new PackageManagerHelper(context)
.getApplicationInfo(installInfo.packageName, installInfo.user, 0);
// only if not yet installed
if (applicationInfo == null) {
PromiseAppInfo info = new PromiseAppInfo(installInfo);
if (!new PackageManagerHelper(context)
.isAppInstalled(installInfo.packageName, installInfo.user)) {
AppInfo info = new AppInfo(installInfo);
mIconCache.getTitleAndIcon(info, info.usingLowResIcon());
info.sectionName = mIndex.computeSectionName(info.title);
@@ -161,24 +158,31 @@ public class AllAppsList {
}
}
public PromiseAppInfo updatePromiseInstallInfo(PackageInstallInfo installInfo) {
UserHandle user = Process.myUserHandle();
for (int i=0; i < data.size(); i++) {
/** Updates the given PackageInstallInfo's associated AppInfo's installation info. */
public List<AppInfo> updatePromiseInstallInfo(PackageInstallInfo installInfo) {
List<AppInfo> updatedAppInfos = new ArrayList<>();
UserHandle user = installInfo.user;
for (int i = data.size() - 1; i >= 0; i--) {
final AppInfo appInfo = data.get(i);
final ComponentName tgtComp = appInfo.getTargetComponent();
if (tgtComp != null && tgtComp.getPackageName().equals(installInfo.packageName)
&& appInfo.user.equals(user)
&& appInfo instanceof PromiseAppInfo) {
final PromiseAppInfo promiseAppInfo = (PromiseAppInfo) appInfo;
if (installInfo.state == PackageInstallInfo.STATUS_INSTALLING) {
promiseAppInfo.level = installInfo.progress;
return promiseAppInfo;
} else if (installInfo.state == PackageInstallInfo.STATUS_FAILED) {
&& appInfo.user.equals(user)) {
if (installInfo.state == PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING
|| installInfo.state == PackageInstallInfo.STATUS_INSTALLING) {
if (appInfo.isAppStartable()
&& installInfo.state == PackageInstallInfo.STATUS_INSTALLING) {
continue;
}
appInfo.setProgressLevel(installInfo);
updatedAppInfos.add(appInfo);
} else if (installInfo.state == PackageInstallInfo.STATUS_FAILED
&& !appInfo.isAppStartable()) {
removeApp(i);
}
}
}
return null;
return updatedAppInfos;
}
private void removeApp(int index) {
@@ -199,11 +203,16 @@ public class AllAppsList {
/**
* Add the icons for the supplied apk called packageName.
*/
public void addPackage(Context context, String packageName, UserHandle user) {
for (LauncherActivityInfo info : context.getSystemService(LauncherApps.class)
.getActivityList(packageName, user)) {
public List<LauncherActivityInfo> addPackage(
Context context, String packageName, UserHandle user) {
List<LauncherActivityInfo> activities = context.getSystemService(LauncherApps.class)
.getActivityList(packageName, user);
for (LauncherActivityInfo info : activities) {
add(new AppInfo(context, info, user), info);
}
return activities;
}
/**
@@ -246,7 +255,8 @@ public class AllAppsList {
/**
* Add and remove icons for this package which has been updated.
*/
public void updatePackage(Context context, String packageName, UserHandle user) {
public List<LauncherActivityInfo> updatePackage(
Context context, String packageName, UserHandle user) {
final List<LauncherActivityInfo> matches = context.getSystemService(LauncherApps.class)
.getActivityList(packageName, user);
if (matches.size() > 0) {
@@ -270,8 +280,14 @@ public class AllAppsList {
if (applicationInfo == null) {
add(new AppInfo(context, info, user), info);
} else {
mIconCache.getTitleAndIcon(applicationInfo, info, true /* useLowResIcon */);
Intent launchIntent = AppInfo.makeLaunchIntent(info);
mIconCache.getTitleAndIcon(applicationInfo, info, false /* useLowResIcon */);
applicationInfo.sectionName = mIndex.computeSectionName(applicationInfo.title);
applicationInfo.setProgressLevel(
PackageManagerHelper.getLoadingProgress(info),
PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING);
applicationInfo.intent = launchIntent;
mDataChanged = true;
}
@@ -287,6 +303,8 @@ public class AllAppsList {
}
}
}
return matches;
}
/**
@@ -307,7 +325,7 @@ public class AllAppsList {
*
* @return the corresponding AppInfo or null
*/
private @Nullable AppInfo findAppInfo(@NonNull ComponentName componentName,
public @Nullable AppInfo findAppInfo(@NonNull ComponentName componentName,
@NonNull UserHandle user) {
for (AppInfo info: data) {
if (componentName.equals(info.componentName) && user.equals(info.user)) {