Fix LauncherAppsService queryIntentLauncherActivities
ag/12640480 accidentally changed the logic of `queryIntentLauncherActivities`. Fixing it and adding a few polish. Test: atest NexusLauncherOutOfProcTests BUG: 170963871 BUG: 170959052 Change-Id: I9a69ac15aba4d67fc03a581c381ead3cc3eae073
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.content.pm;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.content.ComponentName;
|
||||
import android.os.Parcel;
|
||||
@@ -28,17 +30,23 @@ public class LauncherActivityInfoInternal implements Parcelable {
|
||||
@UnsupportedAppUsage
|
||||
private ActivityInfo mActivityInfo;
|
||||
private ComponentName mComponentName;
|
||||
private IncrementalStatesInfo mIncrementalStatesInfo;
|
||||
@NonNull private IncrementalStatesInfo mIncrementalStatesInfo;
|
||||
|
||||
/**
|
||||
* @param info ActivityInfo from which to create the LauncherActivityInfo.
|
||||
* @param incrementalStatesInfo The package's states.
|
||||
*/
|
||||
public LauncherActivityInfoInternal(ActivityInfo info,
|
||||
IncrementalStatesInfo incrementalStatesInfo) {
|
||||
@Nullable IncrementalStatesInfo incrementalStatesInfo) {
|
||||
mActivityInfo = info;
|
||||
mComponentName = new ComponentName(info.packageName, info.name);
|
||||
mIncrementalStatesInfo = incrementalStatesInfo;
|
||||
if (incrementalStatesInfo == null) {
|
||||
// default value for non-incremental apps
|
||||
mIncrementalStatesInfo = new IncrementalStatesInfo(
|
||||
true /* isStartable */, false /* isLoading */, 1 /* progress */);
|
||||
} else {
|
||||
mIncrementalStatesInfo = incrementalStatesInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public LauncherActivityInfoInternal(Parcel source) {
|
||||
|
||||
@@ -548,8 +548,13 @@ public class LauncherAppsService extends SystemService {
|
||||
PackageManager.MATCH_DIRECT_BOOT_AWARE
|
||||
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
|
||||
callingUid, user.getIdentifier());
|
||||
final IncrementalStatesInfo incrementalStatesInfo = pmInt.getIncrementalStatesInfo(
|
||||
component.getPackageName(), callingUid, user.getIdentifier());
|
||||
final IncrementalStatesInfo incrementalStatesInfo;
|
||||
if (component.getPackageName() == null) {
|
||||
incrementalStatesInfo = null;
|
||||
} else {
|
||||
incrementalStatesInfo = pmInt.getIncrementalStatesInfo(
|
||||
component.getPackageName(), callingUid, user.getIdentifier());
|
||||
}
|
||||
return new LauncherActivityInfoInternal(activityInfo, incrementalStatesInfo);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(ident);
|
||||
@@ -592,11 +597,12 @@ public class LauncherAppsService extends SystemService {
|
||||
List<LauncherActivityInfoInternal> results = new ArrayList<>();
|
||||
for (int i = 0; i < numResolveInfos; i++) {
|
||||
final ResolveInfo ri = apps.get(i);
|
||||
final IncrementalStatesInfo incrementalStatesInfo =
|
||||
pmInt.getIncrementalStatesInfo(ri.resolvePackageName, callingUid,
|
||||
user.getIdentifier());
|
||||
if (incrementalStatesInfo == null) {
|
||||
continue;
|
||||
final IncrementalStatesInfo incrementalStatesInfo;
|
||||
if (ri.resolvePackageName == null) {
|
||||
incrementalStatesInfo = null;
|
||||
} else {
|
||||
incrementalStatesInfo = pmInt.getIncrementalStatesInfo(
|
||||
ri.resolvePackageName, callingUid, user.getIdentifier());
|
||||
}
|
||||
results.add(new LauncherActivityInfoInternal(ri.activityInfo,
|
||||
incrementalStatesInfo));
|
||||
|
||||
@@ -25662,12 +25662,10 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
|
||||
@Override
|
||||
public IncrementalStatesInfo getIncrementalStatesInfo(
|
||||
String packageName, int filterCallingUid, int userId) {
|
||||
@NonNull String packageName, int filterCallingUid, int userId) {
|
||||
final PackageSetting ps = getPackageSettingForUser(packageName, filterCallingUid,
|
||||
userId);
|
||||
if (ps == null) {
|
||||
Slog.w(TAG, "Failed getting incremental state. Package " + packageName
|
||||
+ " is not available");
|
||||
return null;
|
||||
}
|
||||
return ps.getIncrementalStates();
|
||||
|
||||
Reference in New Issue
Block a user