Loading core/java/android/app/admin/DevicePolicyCache.java +13 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,9 @@ import android.annotation.UserIdInt; import com.android.server.LocalServices; import java.util.ArrayList; import java.util.List; /** * Stores a copy of the set of device policies maintained by {@link DevicePolicyManager} that * can be accessed from any place without risking dead locks. Loading Loading @@ -60,6 +63,12 @@ public abstract class DevicePolicyCache { */ public abstract boolean canAdminGrantSensorsPermissions(); /** * Returns a list of package names for which all launcher shortcuts should be modified to be * launched in the managed profile and badged accordingly. */ public abstract List<String> getLauncherShortcutOverrides(); /** * Empty implementation. */ Loading @@ -85,5 +94,9 @@ public abstract class DevicePolicyCache { public boolean canAdminGrantSensorsPermissions() { return false; } @Override public List<String> getLauncherShortcutOverrides() { return new ArrayList<>(); } } } core/java/android/content/pm/ILauncherApps.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.content.pm.PackageInstaller; import android.content.pm.ParceledListSlice; import android.content.pm.ResolveInfo; import android.content.pm.ShortcutInfo; import android.content.pm.LauncherActivityInfoInternal; import android.graphics.Rect; import android.os.Bundle; import android.os.UserHandle; Loading Loading @@ -114,4 +115,5 @@ interface ILauncherApps { String getShortcutIconUri(String callingPackage, String packageName, String shortcutId, int userId); Map<String, LauncherActivityInfoInternal> getActivityOverrides(String callingPackage, int userId); } core/java/android/content/pm/LauncherActivityInfo.java +3 −5 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ import android.util.DisplayMetrics; */ public class LauncherActivityInfo { private final PackageManager mPm; private UserHandle mUser; private final LauncherActivityInfoInternal mInternal; /** Loading @@ -43,9 +42,8 @@ public class LauncherActivityInfo { * @param context The context for fetching resources. */ LauncherActivityInfo(Context context, UserHandle user, LauncherActivityInfoInternal internal) { LauncherActivityInfo(Context context, LauncherActivityInfoInternal internal) { mPm = context.getPackageManager(); mUser = user; mInternal = internal; } Loading @@ -70,7 +68,7 @@ public class LauncherActivityInfo { * @return The UserHandle of the profile. */ public UserHandle getUser() { return mUser; return mInternal.getUser(); } /** Loading Loading @@ -180,6 +178,6 @@ public class LauncherActivityInfo { public Drawable getBadgedIcon(int density) { Drawable originalIcon = getIcon(density); return mPm.getUserBadgedIcon(originalIcon, mUser); return mPm.getUserBadgedIcon(originalIcon, mInternal.getUser()); } } core/java/android/content/pm/LauncherActivityInfoInternal.java +16 −6 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.compat.annotation.UnsupportedAppUsage; import android.content.ComponentName; import android.os.Parcel; import android.os.Parcelable; import android.os.UserHandle; /** * @hide Loading @@ -30,23 +31,27 @@ public class LauncherActivityInfoInternal implements Parcelable { @NonNull private ActivityInfo mActivityInfo; @NonNull private ComponentName mComponentName; @NonNull private IncrementalStatesInfo mIncrementalStatesInfo; @NonNull private UserHandle mUser; /** * @param info ActivityInfo from which to create the LauncherActivityInfo. * @param incrementalStatesInfo The package's states. * @param user The user the activity info belongs to. */ public LauncherActivityInfoInternal(@NonNull ActivityInfo info, @NonNull IncrementalStatesInfo incrementalStatesInfo) { @NonNull IncrementalStatesInfo incrementalStatesInfo, @NonNull UserHandle user) { mActivityInfo = info; mComponentName = new ComponentName(info.packageName, info.name); mIncrementalStatesInfo = incrementalStatesInfo; mUser = user; } public LauncherActivityInfoInternal(Parcel source) { mActivityInfo = source.readParcelable(ActivityInfo.class.getClassLoader(), android.content.pm.ActivityInfo.class); mActivityInfo = source.readTypedObject(ActivityInfo.CREATOR); mComponentName = new ComponentName(mActivityInfo.packageName, mActivityInfo.name); mIncrementalStatesInfo = source.readParcelable( IncrementalStatesInfo.class.getClassLoader(), android.content.pm.IncrementalStatesInfo.class); mIncrementalStatesInfo = source.readTypedObject(IncrementalStatesInfo.CREATOR); mUser = source.readTypedObject(UserHandle.CREATOR); } public ComponentName getComponentName() { Loading @@ -57,6 +62,10 @@ public class LauncherActivityInfoInternal implements Parcelable { return mActivityInfo; } public UserHandle getUser() { return mUser; } public IncrementalStatesInfo getIncrementalStatesInfo() { return mIncrementalStatesInfo; } Loading @@ -68,8 +77,9 @@ public class LauncherActivityInfoInternal implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeParcelable(mActivityInfo, 0); dest.writeParcelable(mIncrementalStatesInfo, 0); dest.writeTypedObject(mActivityInfo, flags); dest.writeTypedObject(mIncrementalStatesInfo, flags); dest.writeTypedObject(mUser, flags); } public static final @android.annotation.NonNull Creator<LauncherActivityInfoInternal> CREATOR = Loading core/java/android/content/pm/LauncherApps.java +35 −2 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.os.UserManager; import android.util.ArrayMap; import android.util.DisplayMetrics; import android.util.Log; import android.util.Pair; Loading Loading @@ -793,12 +794,44 @@ public class LauncherApps { if (ai == null) { return null; } return new LauncherActivityInfo(mContext, user, ai); return new LauncherActivityInfo(mContext, ai); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } /** * Returns overrides for the activities that should be launched for the shortcuts of certain * package names. * * @return {@link Map} whose keys are package names and whose values are the * {@link LauncherActivityInfo}s that should be used for those packages' shortcuts. If there are * no activity overrides, an empty {@link Map} will be returned. * * @hide */ @NonNull public Map<String, LauncherActivityInfo> getActivityOverrides() { Map<String, LauncherActivityInfo> activityOverrides = new ArrayMap<>(); try { Map<String, LauncherActivityInfoInternal> activityOverridesInternal = mService.getActivityOverrides(mContext.getPackageName(), mContext.getUserId()); for (Map.Entry<String, LauncherActivityInfoInternal> packageToOverride : activityOverridesInternal.entrySet()) { activityOverrides.put( packageToOverride.getKey(), new LauncherActivityInfo( mContext, packageToOverride.getValue() ) ); } } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } return activityOverrides; } /** * Starts a Main activity in the specified profile. * Loading Loading @@ -916,7 +949,7 @@ public class LauncherApps { } ArrayList<LauncherActivityInfo> lais = new ArrayList<>(); for (LauncherActivityInfoInternal internal : internals.getList()) { LauncherActivityInfo lai = new LauncherActivityInfo(mContext, user, internal); LauncherActivityInfo lai = new LauncherActivityInfo(mContext, internal); if (DEBUG) { Log.v(TAG, "Returning activity for profile " + user + " : " + lai.getComponentName()); Loading Loading
core/java/android/app/admin/DevicePolicyCache.java +13 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,9 @@ import android.annotation.UserIdInt; import com.android.server.LocalServices; import java.util.ArrayList; import java.util.List; /** * Stores a copy of the set of device policies maintained by {@link DevicePolicyManager} that * can be accessed from any place without risking dead locks. Loading Loading @@ -60,6 +63,12 @@ public abstract class DevicePolicyCache { */ public abstract boolean canAdminGrantSensorsPermissions(); /** * Returns a list of package names for which all launcher shortcuts should be modified to be * launched in the managed profile and badged accordingly. */ public abstract List<String> getLauncherShortcutOverrides(); /** * Empty implementation. */ Loading @@ -85,5 +94,9 @@ public abstract class DevicePolicyCache { public boolean canAdminGrantSensorsPermissions() { return false; } @Override public List<String> getLauncherShortcutOverrides() { return new ArrayList<>(); } } }
core/java/android/content/pm/ILauncherApps.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.content.pm.PackageInstaller; import android.content.pm.ParceledListSlice; import android.content.pm.ResolveInfo; import android.content.pm.ShortcutInfo; import android.content.pm.LauncherActivityInfoInternal; import android.graphics.Rect; import android.os.Bundle; import android.os.UserHandle; Loading Loading @@ -114,4 +115,5 @@ interface ILauncherApps { String getShortcutIconUri(String callingPackage, String packageName, String shortcutId, int userId); Map<String, LauncherActivityInfoInternal> getActivityOverrides(String callingPackage, int userId); }
core/java/android/content/pm/LauncherActivityInfo.java +3 −5 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ import android.util.DisplayMetrics; */ public class LauncherActivityInfo { private final PackageManager mPm; private UserHandle mUser; private final LauncherActivityInfoInternal mInternal; /** Loading @@ -43,9 +42,8 @@ public class LauncherActivityInfo { * @param context The context for fetching resources. */ LauncherActivityInfo(Context context, UserHandle user, LauncherActivityInfoInternal internal) { LauncherActivityInfo(Context context, LauncherActivityInfoInternal internal) { mPm = context.getPackageManager(); mUser = user; mInternal = internal; } Loading @@ -70,7 +68,7 @@ public class LauncherActivityInfo { * @return The UserHandle of the profile. */ public UserHandle getUser() { return mUser; return mInternal.getUser(); } /** Loading Loading @@ -180,6 +178,6 @@ public class LauncherActivityInfo { public Drawable getBadgedIcon(int density) { Drawable originalIcon = getIcon(density); return mPm.getUserBadgedIcon(originalIcon, mUser); return mPm.getUserBadgedIcon(originalIcon, mInternal.getUser()); } }
core/java/android/content/pm/LauncherActivityInfoInternal.java +16 −6 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.compat.annotation.UnsupportedAppUsage; import android.content.ComponentName; import android.os.Parcel; import android.os.Parcelable; import android.os.UserHandle; /** * @hide Loading @@ -30,23 +31,27 @@ public class LauncherActivityInfoInternal implements Parcelable { @NonNull private ActivityInfo mActivityInfo; @NonNull private ComponentName mComponentName; @NonNull private IncrementalStatesInfo mIncrementalStatesInfo; @NonNull private UserHandle mUser; /** * @param info ActivityInfo from which to create the LauncherActivityInfo. * @param incrementalStatesInfo The package's states. * @param user The user the activity info belongs to. */ public LauncherActivityInfoInternal(@NonNull ActivityInfo info, @NonNull IncrementalStatesInfo incrementalStatesInfo) { @NonNull IncrementalStatesInfo incrementalStatesInfo, @NonNull UserHandle user) { mActivityInfo = info; mComponentName = new ComponentName(info.packageName, info.name); mIncrementalStatesInfo = incrementalStatesInfo; mUser = user; } public LauncherActivityInfoInternal(Parcel source) { mActivityInfo = source.readParcelable(ActivityInfo.class.getClassLoader(), android.content.pm.ActivityInfo.class); mActivityInfo = source.readTypedObject(ActivityInfo.CREATOR); mComponentName = new ComponentName(mActivityInfo.packageName, mActivityInfo.name); mIncrementalStatesInfo = source.readParcelable( IncrementalStatesInfo.class.getClassLoader(), android.content.pm.IncrementalStatesInfo.class); mIncrementalStatesInfo = source.readTypedObject(IncrementalStatesInfo.CREATOR); mUser = source.readTypedObject(UserHandle.CREATOR); } public ComponentName getComponentName() { Loading @@ -57,6 +62,10 @@ public class LauncherActivityInfoInternal implements Parcelable { return mActivityInfo; } public UserHandle getUser() { return mUser; } public IncrementalStatesInfo getIncrementalStatesInfo() { return mIncrementalStatesInfo; } Loading @@ -68,8 +77,9 @@ public class LauncherActivityInfoInternal implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeParcelable(mActivityInfo, 0); dest.writeParcelable(mIncrementalStatesInfo, 0); dest.writeTypedObject(mActivityInfo, flags); dest.writeTypedObject(mIncrementalStatesInfo, flags); dest.writeTypedObject(mUser, flags); } public static final @android.annotation.NonNull Creator<LauncherActivityInfoInternal> CREATOR = Loading
core/java/android/content/pm/LauncherApps.java +35 −2 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.os.UserManager; import android.util.ArrayMap; import android.util.DisplayMetrics; import android.util.Log; import android.util.Pair; Loading Loading @@ -793,12 +794,44 @@ public class LauncherApps { if (ai == null) { return null; } return new LauncherActivityInfo(mContext, user, ai); return new LauncherActivityInfo(mContext, ai); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } /** * Returns overrides for the activities that should be launched for the shortcuts of certain * package names. * * @return {@link Map} whose keys are package names and whose values are the * {@link LauncherActivityInfo}s that should be used for those packages' shortcuts. If there are * no activity overrides, an empty {@link Map} will be returned. * * @hide */ @NonNull public Map<String, LauncherActivityInfo> getActivityOverrides() { Map<String, LauncherActivityInfo> activityOverrides = new ArrayMap<>(); try { Map<String, LauncherActivityInfoInternal> activityOverridesInternal = mService.getActivityOverrides(mContext.getPackageName(), mContext.getUserId()); for (Map.Entry<String, LauncherActivityInfoInternal> packageToOverride : activityOverridesInternal.entrySet()) { activityOverrides.put( packageToOverride.getKey(), new LauncherActivityInfo( mContext, packageToOverride.getValue() ) ); } } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } return activityOverrides; } /** * Starts a Main activity in the specified profile. * Loading Loading @@ -916,7 +949,7 @@ public class LauncherApps { } ArrayList<LauncherActivityInfo> lais = new ArrayList<>(); for (LauncherActivityInfoInternal internal : internals.getList()) { LauncherActivityInfo lai = new LauncherActivityInfo(mContext, user, internal); LauncherActivityInfo lai = new LauncherActivityInfo(mContext, internal); if (DEBUG) { Log.v(TAG, "Returning activity for profile " + user + " : " + lai.getComponentName()); Loading