Revert "[incremental/pm] LauncherApps APIs for loading state and progress"

This reverts commit 0173a44f3d.

Bug: 170959052
Test: Locally confirmed two reverts together fix app tray
Change-Id: I2f7b198f77b54be671c7f02bc2b67838bf99d28b
This commit is contained in:
Greg Kaiser
2020-10-16 07:16:02 -07:00
parent cf4c99720b
commit 69475be847
13 changed files with 78 additions and 352 deletions

View File

@@ -11710,10 +11710,7 @@ package android.content.pm {
method public android.graphics.drawable.Drawable getIcon(int);
method public CharSequence getLabel();
method public String getName();
method public float getProgress();
method public android.os.UserHandle getUser();
method public boolean isLoading();
method public boolean isStartable();
}
public class LauncherApps {
@@ -11753,7 +11750,6 @@ package android.content.pm {
ctor public LauncherApps.Callback();
method public abstract void onPackageAdded(String, android.os.UserHandle);
method public abstract void onPackageChanged(String, android.os.UserHandle);
method public void onPackageProgressChanged(@NonNull String, @NonNull android.os.UserHandle, float);
method public abstract void onPackageRemoved(String, android.os.UserHandle);
method public abstract void onPackagesAvailable(String[], android.os.UserHandle, boolean);
method public void onPackagesSuspended(String[], android.os.UserHandle);

View File

@@ -21,9 +21,9 @@ import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentSender;
import android.content.LocusId;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.IOnAppsChangedListener;
import android.content.pm.LauncherActivityInfoInternal;
import android.content.pm.LauncherApps;
import android.content.pm.ShortcutQueryWrapper;
import android.content.pm.IPackageInstallerCallback;
@@ -47,7 +47,7 @@ interface ILauncherApps {
void removeOnAppsChangedListener(in IOnAppsChangedListener listener);
ParceledListSlice getLauncherActivities(
String callingPackage, String packageName, in UserHandle user);
LauncherActivityInfoInternal resolveLauncherActivityInternal(
ActivityInfo resolveActivity(
String callingPackage, in ComponentName component, in UserHandle user);
void startSessionDetailsActivityAsUser(in IApplicationThread caller, String callingPackage,
String callingFeatureId, in PackageInstaller.SessionInfo sessionInfo,

View File

@@ -33,5 +33,4 @@ oneway interface IOnAppsChangedListener {
in Bundle launcherExtras);
void onPackagesUnsuspended(in UserHandle user, in String[] packageNames);
void onShortcutChanged(in UserHandle user, String packageName, in ParceledListSlice shortcuts);
void onPackageProgressChanged(in UserHandle user, String packageName, float progress);
}

View File

@@ -31,6 +31,7 @@ import android.content.pm.IPackageInstaller;
import android.content.pm.IPackageDeleteObserver;
import android.content.pm.IPackageDeleteObserver2;
import android.content.pm.IPackageDataObserver;
import android.content.pm.IPackageLoadingProgressCallback;
import android.content.pm.IPackageMoveObserver;
import android.content.pm.IPackageStatsObserver;
import android.content.pm.IntentFilterVerificationInfo;

View File

@@ -16,6 +16,7 @@
package android.content.pm;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -34,19 +35,28 @@ public class LauncherActivityInfo {
private static final String TAG = "LauncherActivityInfo";
private final PackageManager mPm;
@UnsupportedAppUsage
private ActivityInfo mActivityInfo;
private ComponentName mComponentName;
private UserHandle mUser;
private final LauncherActivityInfoInternal mInternal;
/**
* Create a launchable activity object for a given ResolveInfo and user.
*
* @param context The context for fetching resources.
* @param info ResolveInfo from which to create the LauncherActivityInfo.
* @param user The UserHandle of the profile to which this activity belongs.
*/
LauncherActivityInfo(Context context, UserHandle user, LauncherActivityInfoInternal internal) {
mPm = context.getPackageManager();
LauncherActivityInfo(Context context, ActivityInfo info, UserHandle user) {
this(context);
mActivityInfo = info;
mComponentName = new ComponentName(info.packageName, info.name);
mUser = user;
mInternal = internal;
}
LauncherActivityInfo(Context context) {
mPm = context.getPackageManager();
}
/**
@@ -55,7 +65,7 @@ public class LauncherActivityInfo {
* @return ComponentName of the activity
*/
public ComponentName getComponentName() {
return mInternal.getComponentName();
return mComponentName;
}
/**
@@ -80,28 +90,7 @@ public class LauncherActivityInfo {
*/
public CharSequence getLabel() {
// TODO: Go through LauncherAppsService
return mInternal.getActivityInfo().loadLabel(mPm);
}
/**
* @return whether the package is startable.
*/
public boolean isStartable() {
return mInternal.getIncrementalStatesInfo().isStartable();
}
/**
* @return whether the package is still loading.
*/
public boolean isLoading() {
return mInternal.getIncrementalStatesInfo().isLoading();
}
/**
* @return Package loading progress
*/
public float getProgress() {
return mInternal.getIncrementalStatesInfo().getProgress();
return mActivityInfo.loadLabel(mPm);
}
/**
@@ -114,20 +103,20 @@ public class LauncherActivityInfo {
*/
public Drawable getIcon(int density) {
// TODO: Go through LauncherAppsService
final int iconRes = mInternal.getActivityInfo().getIconResource();
final int iconRes = mActivityInfo.getIconResource();
Drawable icon = null;
// Get the preferred density icon from the app's resources
if (density != 0 && iconRes != 0) {
try {
final Resources resources = mPm.getResourcesForApplication(
mInternal.getActivityInfo().applicationInfo);
final Resources resources
= mPm.getResourcesForApplication(mActivityInfo.applicationInfo);
icon = resources.getDrawableForDensity(iconRes, density);
} catch (NameNotFoundException | Resources.NotFoundException exc) {
}
}
// Get the default density icon
if (icon == null) {
icon = mInternal.getActivityInfo().loadIcon(mPm);
icon = mActivityInfo.loadIcon(mPm);
}
return icon;
}
@@ -139,7 +128,7 @@ public class LauncherActivityInfo {
* @hide remove before shipping
*/
public int getApplicationFlags() {
return mInternal.getActivityInfo().flags;
return mActivityInfo.applicationInfo.flags;
}
/**
@@ -147,7 +136,7 @@ public class LauncherActivityInfo {
* @return
*/
public ApplicationInfo getApplicationInfo() {
return mInternal.getActivityInfo().applicationInfo;
return mActivityInfo.applicationInfo;
}
/**
@@ -158,7 +147,7 @@ public class LauncherActivityInfo {
public long getFirstInstallTime() {
try {
// TODO: Go through LauncherAppsService
return mPm.getPackageInfo(mInternal.getActivityInfo().packageName,
return mPm.getPackageInfo(mActivityInfo.packageName,
PackageManager.MATCH_UNINSTALLED_PACKAGES).firstInstallTime;
} catch (NameNotFoundException nnfe) {
// Sorry, can't find package
@@ -171,7 +160,7 @@ public class LauncherActivityInfo {
* @return the name from android:name for the acitivity.
*/
public String getName() {
return mInternal.getActivityInfo().name;
return mActivityInfo.name;
}
/**

View File

@@ -1,20 +0,0 @@
/*
**
** Copyright 2020, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License")
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
package android.content.pm;
parcelable LauncherActivityInfoInternal;

View File

@@ -1,83 +0,0 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content.pm;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.os.Parcel;
import android.os.Parcelable;
/**
* @hide
*/
public class LauncherActivityInfoInternal implements Parcelable {
@UnsupportedAppUsage
private ActivityInfo mActivityInfo;
private ComponentName mComponentName;
private IncrementalStatesInfo mIncrementalStatesInfo;
/**
* @param info ActivityInfo from which to create the LauncherActivityInfo.
* @param incrementalStatesInfo The package's states.
*/
public LauncherActivityInfoInternal(ActivityInfo info,
IncrementalStatesInfo incrementalStatesInfo) {
mActivityInfo = info;
mComponentName = new ComponentName(info.packageName, info.name);
mIncrementalStatesInfo = incrementalStatesInfo;
}
public LauncherActivityInfoInternal(Parcel source) {
mActivityInfo = source.readParcelable(ActivityInfo.class.getClassLoader());
mComponentName = new ComponentName(mActivityInfo.packageName, mActivityInfo.name);
mIncrementalStatesInfo = source.readParcelable(
IncrementalStatesInfo.class.getClassLoader());
}
public ComponentName getComponentName() {
return mComponentName;
}
public ActivityInfo getActivityInfo() {
return mActivityInfo;
}
public IncrementalStatesInfo getIncrementalStatesInfo() {
return mIncrementalStatesInfo;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(mActivityInfo, 0);
dest.writeParcelable(mIncrementalStatesInfo, 0);
}
public static final @android.annotation.NonNull Creator<LauncherActivityInfoInternal> CREATOR =
new Creator<LauncherActivityInfoInternal>() {
public LauncherActivityInfoInternal createFromParcel(Parcel source) {
return new LauncherActivityInfoInternal(source);
}
public LauncherActivityInfoInternal[] newArray(int size) {
return new LauncherActivityInfoInternal[size];
}
};
}

View File

@@ -218,7 +218,6 @@ public class LauncherApps {
* Indicates that a package was modified in the specified profile.
* This can happen, for example, when the package is updated or when
* one or more components are enabled or disabled.
* It can also happen if package state has changed, i.e., package becomes unstartable.
*
* @param packageName The name of the package that has changed.
* @param user The UserHandle of the profile that generated the change.
@@ -324,16 +323,6 @@ public class LauncherApps {
public void onShortcutsChanged(@NonNull String packageName,
@NonNull List<ShortcutInfo> shortcuts, @NonNull UserHandle user) {
}
/**
* Indicates that the loading progress of an installed package has changed.
*
* @param packageName The name of the package that has changed.
* @param user The UserHandle of the profile that generated the change.
* @param progress The new progress value, between [0, 1].
*/
public void onPackageProgressChanged(@NonNull String packageName,
@NonNull UserHandle user, float progress) {}
}
/**
@@ -726,15 +715,16 @@ public class LauncherApps {
public LauncherActivityInfo resolveActivity(Intent intent, UserHandle user) {
logErrorForInvalidProfileAccess(user);
try {
LauncherActivityInfoInternal ai = mService.resolveLauncherActivityInternal(
mContext.getPackageName(), intent.getComponent(), user);
if (ai == null) {
return null;
ActivityInfo ai = mService.resolveActivity(mContext.getPackageName(),
intent.getComponent(), user);
if (ai != null) {
LauncherActivityInfo info = new LauncherActivityInfo(mContext, ai, user);
return info;
}
return new LauncherActivityInfo(mContext, user, ai);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
return null;
}
/**
@@ -823,13 +813,13 @@ public class LauncherApps {
}
private List<LauncherActivityInfo> convertToActivityList(
@Nullable ParceledListSlice<LauncherActivityInfoInternal> internals, UserHandle user) {
if (internals == null || internals.getList().isEmpty()) {
@Nullable ParceledListSlice<ResolveInfo> activities, UserHandle user) {
if (activities == null) {
return Collections.EMPTY_LIST;
}
ArrayList<LauncherActivityInfo> lais = new ArrayList<>();
for (LauncherActivityInfoInternal internal : internals.getList()) {
LauncherActivityInfo lai = new LauncherActivityInfo(mContext, user, internal);
for (ResolveInfo ri : activities.getList()) {
LauncherActivityInfo lai = new LauncherActivityInfo(mContext, ri.activityInfo, user);
if (DEBUG) {
Log.v(TAG, "Returning activity for profile " + user + " : "
+ lai.getComponentName());
@@ -1677,19 +1667,6 @@ public class LauncherApps {
}
}
}
public void onPackageProgressChanged(UserHandle user, String packageName,
float progress) {
if (DEBUG) {
Log.d(TAG, "onPackageProgressChanged " + user.getIdentifier() + ","
+ packageName + "," + progress);
}
synchronized (LauncherApps.this) {
for (CallbackMessageHandler callback : mCallbacks) {
callback.postOnPackageProgressChanged(user, packageName, progress);
}
}
}
};
private static class CallbackMessageHandler extends Handler {
@@ -1701,7 +1678,6 @@ public class LauncherApps {
private static final int MSG_SUSPENDED = 6;
private static final int MSG_UNSUSPENDED = 7;
private static final int MSG_SHORTCUT_CHANGED = 8;
private static final int MSG_LOADING_PROGRESS_CHANGED = 9;
private LauncherApps.Callback mCallback;
@@ -1712,7 +1688,6 @@ public class LauncherApps {
boolean replacing;
UserHandle user;
List<ShortcutInfo> shortcuts;
float mLoadingProgress;
}
public CallbackMessageHandler(Looper looper, LauncherApps.Callback callback) {
@@ -1752,10 +1727,6 @@ public class LauncherApps {
case MSG_SHORTCUT_CHANGED:
mCallback.onShortcutsChanged(info.packageName, info.shortcuts, info.user);
break;
case MSG_LOADING_PROGRESS_CHANGED:
mCallback.onPackageProgressChanged(info.packageName, info.user,
info.mLoadingProgress);
break;
}
}
@@ -1822,15 +1793,6 @@ public class LauncherApps {
info.shortcuts = shortcuts;
obtainMessage(MSG_SHORTCUT_CHANGED, info).sendToTarget();
}
public void postOnPackageProgressChanged(UserHandle user, String packageName,
float progress) {
CallbackInfo info = new CallbackInfo();
info.packageName = packageName;
info.user = user;
info.mLoadingProgress = progress;
obtainMessage(MSG_LOADING_PROGRESS_CHANGED, info).sendToTarget();
}
}
/**

View File

@@ -37,7 +37,6 @@ import java.util.Objects;
* updating, and disappearing and reappearing on the SD card.
*/
public abstract class PackageMonitor extends android.content.BroadcastReceiver {
static final String TAG = "PackageMonitor";
static final IntentFilter sPackageFilt = new IntentFilter();
static final IntentFilter sNonDataFilt = new IntentFilter();
static final IntentFilter sExternalFilt = new IntentFilter();
@@ -49,9 +48,6 @@ public abstract class PackageMonitor extends android.content.BroadcastReceiver {
sPackageFilt.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART);
sPackageFilt.addAction(Intent.ACTION_PACKAGE_RESTARTED);
sPackageFilt.addAction(Intent.ACTION_PACKAGE_DATA_CLEARED);
sPackageFilt.addAction(Intent.ACTION_PACKAGE_STARTABLE);
sPackageFilt.addAction(Intent.ACTION_PACKAGE_UNSTARTABLE);
sPackageFilt.addAction(Intent.ACTION_PACKAGE_FULLY_LOADED);
sPackageFilt.addDataScheme("package");
sNonDataFilt.addAction(Intent.ACTION_UID_REMOVED);
sNonDataFilt.addAction(Intent.ACTION_USER_STOPPED);
@@ -309,13 +305,6 @@ public abstract class PackageMonitor extends android.content.BroadcastReceiver {
public void onPackageDataCleared(String packageName, int uid) {
}
/**
* Callback to indicate the package's state has changed.
* @param packageName Name of an installed package
* @param uid The UID the package runs under.
*/
public void onPackageStateChanged(String packageName, int uid) {}
public int getChangingUserId() {
return mChangeUserId;
}
@@ -463,21 +452,12 @@ public abstract class PackageMonitor extends android.content.BroadcastReceiver {
String[] pkgList = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
mSomePackagesChanged = true;
onPackagesUnsuspended(pkgList);
} else if (Intent.ACTION_PACKAGE_STARTABLE.equals(action)
|| Intent.ACTION_PACKAGE_UNSTARTABLE.equals(action)
|| Intent.ACTION_PACKAGE_FULLY_LOADED.equals(action)) {
String pkg = intent.getStringExtra(Intent.EXTRA_PACKAGE_NAME);
int uid = intent.getIntExtra(Intent.EXTRA_UID, 0);
mSomePackagesChanged = false;
if (pkg != null) {
onPackageStateChanged(pkg, uid);
}
}
if (mSomePackagesChanged) {
onSomePackagesChanged();
}
onFinishPackageChanges();
mChangeUserId = UserHandle.USER_NULL;
}

View File

@@ -11710,10 +11710,7 @@ package android.content.pm {
method public android.graphics.drawable.Drawable getIcon(int);
method public CharSequence getLabel();
method public String getName();
method public float getProgress();
method public android.os.UserHandle getUser();
method public boolean isLoading();
method public boolean isStartable();
}
public class LauncherApps {
@@ -11753,7 +11750,6 @@ package android.content.pm {
ctor public LauncherApps.Callback();
method public abstract void onPackageAdded(String, android.os.UserHandle);
method public abstract void onPackageChanged(String, android.os.UserHandle);
method public void onPackageProgressChanged(@NonNull String, @NonNull android.os.UserHandle, float);
method public abstract void onPackageRemoved(String, android.os.UserHandle);
method public abstract void onPackagesAvailable(String[], android.os.UserHandle, boolean);
method public void onPackagesSuspended(String[], android.os.UserHandle);

View File

@@ -1106,17 +1106,4 @@ public abstract class PackageManagerInternal {
}
}
/**
* Retrieve all of the information we know about a particular activity class including its
* package states.
*
* @param packageName a specific package
* @param filterCallingUid The results will be filtered in the context of this UID instead
* of the calling UID.
* @param userId The user for whom the package is installed
* @return IncrementalStatesInfo that contains information about package states.
*/
public abstract IncrementalStatesInfo getIncrementalStatesInfo(String packageName,
int filterCallingUid, int userId);
}

View File

@@ -44,8 +44,6 @@ import android.content.pm.IOnAppsChangedListener;
import android.content.pm.IPackageInstallerCallback;
import android.content.pm.IPackageManager;
import android.content.pm.IShortcutChangeCallback;
import android.content.pm.IncrementalStatesInfo;
import android.content.pm.LauncherActivityInfoInternal;
import android.content.pm.LauncherApps;
import android.content.pm.LauncherApps.ShortcutQuery;
import android.content.pm.PackageInfo;
@@ -371,13 +369,18 @@ public class LauncherAppsService extends SystemService {
}
}
private LauncherActivityInfoInternal getHiddenAppActivityInfo(String packageName,
int callingUid, UserHandle user) {
private ResolveInfo getHiddenAppActivityInfo(String packageName, int callingUid,
UserHandle user) {
Intent intent = new Intent();
intent.setComponent(new ComponentName(packageName,
PackageManager.APP_DETAILS_ACTIVITY_CLASS_NAME));
final List<LauncherActivityInfoInternal> apps = queryIntentLauncherActivities(intent,
callingUid, user);
final PackageManagerInternal pmInt =
LocalServices.getService(PackageManagerInternal.class);
List<ResolveInfo> apps = pmInt.queryIntentActivities(intent,
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
PackageManager.MATCH_DIRECT_BOOT_AWARE
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
callingUid, user.getIdentifier());
if (apps.size() > 0) {
return apps.get(0);
}
@@ -396,14 +399,14 @@ public class LauncherAppsService extends SystemService {
}
@Override
public ParceledListSlice<LauncherActivityInfoInternal> getLauncherActivities(
String callingPackage, String packageName, UserHandle user) throws RemoteException {
ParceledListSlice<LauncherActivityInfoInternal> launcherActivities =
queryActivitiesForUser(callingPackage,
new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_LAUNCHER)
.setPackage(packageName),
user);
public ParceledListSlice<ResolveInfo> getLauncherActivities(String callingPackage,
String packageName, UserHandle user) throws RemoteException {
ParceledListSlice<ResolveInfo> launcherActivities = queryActivitiesForUser(
callingPackage,
new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_LAUNCHER)
.setPackage(packageName),
user);
if (Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.SHOW_HIDDEN_LAUNCHER_ICON_APPS_ENABLED, 1) == 0) {
return launcherActivities;
@@ -425,8 +428,7 @@ public class LauncherAppsService extends SystemService {
return launcherActivities;
}
final ArrayList<LauncherActivityInfoInternal> result = new ArrayList<>(
launcherActivities.getList());
final ArrayList<ResolveInfo> result = new ArrayList<>(launcherActivities.getList());
final PackageManagerInternal pmInt =
LocalServices.getService(PackageManagerInternal.class);
if (packageName != null) {
@@ -438,8 +440,7 @@ public class LauncherAppsService extends SystemService {
ApplicationInfo appInfo = pmInt.getApplicationInfo(packageName, /*flags*/ 0,
callingUid, user.getIdentifier());
if (shouldShowSyntheticActivity(user, appInfo)) {
LauncherActivityInfoInternal info = getHiddenAppActivityInfo(packageName,
callingUid, user);
ResolveInfo info = getHiddenAppActivityInfo(packageName, callingUid, user);
if (info != null) {
result.add(info);
}
@@ -447,8 +448,8 @@ public class LauncherAppsService extends SystemService {
return new ParceledListSlice<>(result);
}
final HashSet<String> visiblePackages = new HashSet<>();
for (LauncherActivityInfoInternal info : result) {
visiblePackages.add(info.getActivityInfo().packageName);
for (ResolveInfo info : result) {
visiblePackages.add(info.activityInfo.packageName);
}
List<ApplicationInfo> installedPackages = pmInt.getInstalledApplications(0,
user.getIdentifier(), callingUid);
@@ -457,8 +458,8 @@ public class LauncherAppsService extends SystemService {
if (!shouldShowSyntheticActivity(user, applicationInfo)) {
continue;
}
LauncherActivityInfoInternal info = getHiddenAppActivityInfo(
applicationInfo.packageName, callingUid, user);
ResolveInfo info = getHiddenAppActivityInfo(applicationInfo.packageName,
callingUid, user);
if (info != null) {
result.add(info);
}
@@ -532,7 +533,7 @@ public class LauncherAppsService extends SystemService {
}
@Override
public LauncherActivityInfoInternal resolveLauncherActivityInternal(
public ActivityInfo resolveActivity(
String callingPackage, ComponentName component, UserHandle user)
throws RemoteException {
if (!canAccessProfile(user.getIdentifier(), "Cannot resolve activity")) {
@@ -544,13 +545,10 @@ public class LauncherAppsService extends SystemService {
try {
final PackageManagerInternal pmInt =
LocalServices.getService(PackageManagerInternal.class);
final ActivityInfo activityInfo = pmInt.getActivityInfo(component,
return pmInt.getActivityInfo(component,
PackageManager.MATCH_DIRECT_BOOT_AWARE
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
callingUid, user.getIdentifier());
final IncrementalStatesInfo incrementalStatesInfo = pmInt.getIncrementalStatesInfo(
component.getPackageName(), callingUid, user.getIdentifier());
return new LauncherActivityInfoInternal(activityInfo, incrementalStatesInfo);
} finally {
Binder.restoreCallingIdentity(ident);
}
@@ -564,46 +562,28 @@ public class LauncherAppsService extends SystemService {
new Intent(Intent.ACTION_CREATE_SHORTCUT).setPackage(packageName), user);
}
private ParceledListSlice<LauncherActivityInfoInternal> queryActivitiesForUser(
String callingPackage, Intent intent, UserHandle user) {
private ParceledListSlice<ResolveInfo> queryActivitiesForUser(String callingPackage,
Intent intent, UserHandle user) {
if (!canAccessProfile(user.getIdentifier(), "Cannot retrieve activities")) {
return null;
}
final int callingUid = injectBinderCallingUid();
long ident = injectClearCallingIdentity();
try {
return new ParceledListSlice<>(queryIntentLauncherActivities(intent, callingUid,
user));
final PackageManagerInternal pmInt =
LocalServices.getService(PackageManagerInternal.class);
List<ResolveInfo> apps = pmInt.queryIntentActivities(intent,
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
PackageManager.MATCH_DIRECT_BOOT_AWARE
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
callingUid, user.getIdentifier());
return new ParceledListSlice<>(apps);
} finally {
injectRestoreCallingIdentity(ident);
}
}
private List<LauncherActivityInfoInternal> queryIntentLauncherActivities(
Intent intent, int callingUid, UserHandle user) {
final PackageManagerInternal pmInt =
LocalServices.getService(PackageManagerInternal.class);
List<ResolveInfo> apps = pmInt.queryIntentActivities(intent,
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
PackageManager.MATCH_DIRECT_BOOT_AWARE
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
callingUid, user.getIdentifier());
final int numResolveInfos = apps.size();
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;
}
results.add(new LauncherActivityInfoInternal(ri.activityInfo,
incrementalStatesInfo));
}
return results;
}
@Override
public IntentSender getShortcutConfigActivityIntent(String callingPackage,
ComponentName component, UserHandle user) throws RemoteException {
@@ -1258,10 +1238,7 @@ public class LauncherAppsService extends SystemService {
} finally {
mListeners.finishBroadcast();
}
PackageManagerInternal pmi = LocalServices.getService(PackageManagerInternal.class);
pmi.registerInstalledLoadingProgressCallback(packageName,
new PackageLoadingProgressCallback(packageName, user),
user.getIdentifier());
super.onPackageAdded(packageName, uid);
}
@@ -1289,11 +1266,6 @@ public class LauncherAppsService extends SystemService {
@Override
public void onPackageModified(String packageName) {
onPackageChanged(packageName);
super.onPackageModified(packageName);
}
private void onPackageChanged(String packageName) {
UserHandle user = new UserHandle(getChangingUserId());
final int n = mListeners.beginBroadcast();
try {
@@ -1310,6 +1282,8 @@ public class LauncherAppsService extends SystemService {
} finally {
mListeners.finishBroadcast();
}
super.onPackageModified(packageName);
}
@Override
@@ -1461,7 +1435,6 @@ public class LauncherAppsService extends SystemService {
} catch (RemoteException re) {
Slog.d(TAG, "Callback failed ", re);
}
}
} catch (RuntimeException e) {
// When the user is locked we get IllegalState, so just catch all.
@@ -1470,12 +1443,6 @@ public class LauncherAppsService extends SystemService {
mListeners.finishBroadcast();
}
}
@Override
public void onPackageStateChanged(String packageName, int uid) {
onPackageChanged(packageName);
super.onPackageStateChanged(packageName, uid);
}
}
class PackageCallbackList<T extends IInterface> extends RemoteCallbackList<T> {
@@ -1484,38 +1451,5 @@ public class LauncherAppsService extends SystemService {
checkCallbackCount();
}
}
class PackageLoadingProgressCallback extends
PackageManagerInternal.InstalledLoadingProgressCallback {
private String mPackageName;
private UserHandle mUser;
PackageLoadingProgressCallback(String packageName, UserHandle user) {
super(mCallbackHandler);
mPackageName = packageName;
mUser = user;
}
@Override
public void onLoadingProgressChanged(float progress) {
final int n = mListeners.beginBroadcast();
try {
for (int i = 0; i < n; i++) {
IOnAppsChangedListener listener = mListeners.getBroadcastItem(i);
BroadcastCookie cookie = (BroadcastCookie) mListeners.getBroadcastCookie(i);
if (!isEnabledProfileOf(cookie.user, mUser, "onLoadingProgressChanged")) {
continue;
}
try {
listener.onPackageProgressChanged(mUser, mPackageName, progress);
} catch (RemoteException re) {
Slog.d(TAG, "Callback failed ", re);
}
}
} finally {
mListeners.finishBroadcast();
}
}
}
}
}

View File

@@ -180,7 +180,6 @@ import android.content.pm.IPackageManager;
import android.content.pm.IPackageManagerNative;
import android.content.pm.IPackageMoveObserver;
import android.content.pm.IPackageStatsObserver;
import android.content.pm.IncrementalStatesInfo;
import android.content.pm.InstallSourceInfo;
import android.content.pm.InstantAppInfo;
import android.content.pm.InstantAppRequest;
@@ -25659,22 +25658,8 @@ public class PackageManagerService extends IPackageManager.Stub
return mIncrementalManager.unregisterCallback(ps.getPathString(),
(IPackageLoadingProgressCallback) callback.getBinder());
}
@Override
public IncrementalStatesInfo getIncrementalStatesInfo(
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();
}
}
@GuardedBy("mLock")
private SparseArray<String> getAppsWithSharedUserIdsLocked() {
final SparseArray<String> sharedUserIds = new SparseArray<>();