Loading core/java/android/content/pm/ILauncherApps.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.ComponentName; import android.content.Intent; import android.content.IntentSender; import android.content.LocusId; import android.content.pm.LauncherUserInfo; import android.content.pm.ApplicationInfo; import android.content.pm.IOnAppsChangedListener; import android.content.pm.LauncherActivityInfoInternal; Loading Loading @@ -62,6 +63,7 @@ interface ILauncherApps { in Bundle opts, in UserHandle user); PendingIntent getActivityLaunchIntent(String callingPackage, in ComponentName component, in UserHandle user); LauncherUserInfo getLauncherUserInfo(in UserHandle user); void showAppDetailsAsUser(in IApplicationThread caller, String callingPackage, String callingFeatureId, in ComponentName component, in Rect sourceBounds, in Bundle opts, in UserHandle user); Loading core/java/android/content/pm/LauncherApps.java +24 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.Manifest.permission; import static android.Manifest.permission.READ_FRAME_BUFFER; import android.annotation.CallbackExecutor; import android.annotation.FlaggedApi; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -55,6 +56,7 @@ import android.graphics.drawable.Icon; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Flags; import android.os.Handler; import android.os.Looper; import android.os.Message; Loading Loading @@ -775,6 +777,28 @@ public class LauncherApps { } } /** * Returns information related to a user which is useful for displaying UI elements * to distinguish it from other users (eg, badges). Only system launchers should * call this API. * * @param userHandle user handle of the user for which LauncherUserInfo is requested * @return the LauncherUserInfo object related to the user specified. * @hide */ @Nullable @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) public final LauncherUserInfo getLauncherUserInfo(@NonNull UserHandle userHandle) { if (DEBUG) { Log.i(TAG, "getLauncherUserInfo " + userHandle); } try { return mService.getLauncherUserInfo(userHandle); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } /** * Returns the activity info for a given intent and user handle, if it resolves. Otherwise it * returns null. Loading core/java/android/content/pm/LauncherUserInfo.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 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 LauncherUserInfo; core/java/android/content/pm/LauncherUserInfo.java 0 → 100644 +126 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 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.annotation.FlaggedApi; import android.annotation.NonNull; import android.os.Flags; import android.os.Parcel; import android.os.Parcelable; import android.os.UserHandle; import android.os.UserManager; /** * The LauncherUserInfo object holds information about an Android user that is required to display * the Launcher related UI elements specific to the user (like badges). * * @hide */ @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) public final class LauncherUserInfo implements Parcelable { private final String mUserType; // Serial number for the user, should be same as in the {@link UserInfo} object. private final int mUserSerialNumber; /** * Returns type of the user as defined in {@link UserManager}. e.g., * {@link UserManager.USER_TYPE_PROFILE_MANAGED} or {@link UserManager.USER_TYPE_PROFILE_ClONE} * TODO(b/303812736): Make the return type public and update javadoc here once the linked bug * is resolved. * * @return the userType for the user whose LauncherUserInfo this is * @hide */ @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) @NonNull public String getUserType() { return mUserType; } /** * Returns serial number of user as returned by * {@link UserManager#getSerialNumberForUser(UserHandle)} * * @return the serial number associated with the user * @hide */ @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) public int getUserSerialNumber() { return mUserSerialNumber; } private LauncherUserInfo(@NonNull Parcel in) { mUserType = in.readString16NoHelper(); mUserSerialNumber = in.readInt(); } @Override @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeString16NoHelper(mUserType); dest.writeInt(mUserSerialNumber); } @Override @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) public int describeContents() { return 0; } @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) public static final @android.annotation.NonNull Creator<LauncherUserInfo> CREATOR = new Creator<LauncherUserInfo>() { @Override public LauncherUserInfo createFromParcel(Parcel in) { return new LauncherUserInfo(in); } @Override public LauncherUserInfo[] newArray(int size) { return new LauncherUserInfo[size]; } }; /** * @hide */ public static final class Builder { private final String mUserType; private final int mUserSerialNumber; public Builder(@NonNull String userType, int userSerialNumber) { this.mUserType = userType; this.mUserSerialNumber = userSerialNumber; } /** * Builds the LauncherUserInfo object */ @NonNull public LauncherUserInfo build() { return new LauncherUserInfo(this.mUserType, this.mUserSerialNumber); } } // End builder private LauncherUserInfo(@NonNull String userType, int userSerialNumber) { this.mUserType = userType; this.mUserSerialNumber = userSerialNumber; } } services/core/java/com/android/server/pm/LauncherAppsService.java +20 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ 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.LauncherUserInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageInstaller.SessionInfo; import android.content.pm.PackageManager; Loading Loading @@ -1376,6 +1377,25 @@ public class LauncherAppsService extends SystemService { } } @Override public @Nullable LauncherUserInfo getLauncherUserInfo(@NonNull UserHandle user) { // Only system launchers, which have access to recents should have access to this API. // TODO(b/303803157): Add the new permission check if we decide to have one. if (!mActivityTaskManagerInternal.isCallerRecents(Binder.getCallingUid())) { throw new SecurityException("Caller is not the recents app"); } if (!canAccessProfile(user.getIdentifier(), "Can't access LauncherUserInfo for another user")) { return null; } long ident = injectClearCallingIdentity(); try { return mUserManagerInternal.getLauncherUserInfo(user.getIdentifier()); } finally { injectRestoreCallingIdentity(ident); } } @Override public void startActivityAsUser(IApplicationThread caller, String callingPackage, String callingFeatureId, ComponentName component, Rect sourceBounds, Loading Loading
core/java/android/content/pm/ILauncherApps.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.ComponentName; import android.content.Intent; import android.content.IntentSender; import android.content.LocusId; import android.content.pm.LauncherUserInfo; import android.content.pm.ApplicationInfo; import android.content.pm.IOnAppsChangedListener; import android.content.pm.LauncherActivityInfoInternal; Loading Loading @@ -62,6 +63,7 @@ interface ILauncherApps { in Bundle opts, in UserHandle user); PendingIntent getActivityLaunchIntent(String callingPackage, in ComponentName component, in UserHandle user); LauncherUserInfo getLauncherUserInfo(in UserHandle user); void showAppDetailsAsUser(in IApplicationThread caller, String callingPackage, String callingFeatureId, in ComponentName component, in Rect sourceBounds, in Bundle opts, in UserHandle user); Loading
core/java/android/content/pm/LauncherApps.java +24 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.Manifest.permission; import static android.Manifest.permission.READ_FRAME_BUFFER; import android.annotation.CallbackExecutor; import android.annotation.FlaggedApi; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -55,6 +56,7 @@ import android.graphics.drawable.Icon; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Flags; import android.os.Handler; import android.os.Looper; import android.os.Message; Loading Loading @@ -775,6 +777,28 @@ public class LauncherApps { } } /** * Returns information related to a user which is useful for displaying UI elements * to distinguish it from other users (eg, badges). Only system launchers should * call this API. * * @param userHandle user handle of the user for which LauncherUserInfo is requested * @return the LauncherUserInfo object related to the user specified. * @hide */ @Nullable @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) public final LauncherUserInfo getLauncherUserInfo(@NonNull UserHandle userHandle) { if (DEBUG) { Log.i(TAG, "getLauncherUserInfo " + userHandle); } try { return mService.getLauncherUserInfo(userHandle); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } /** * Returns the activity info for a given intent and user handle, if it resolves. Otherwise it * returns null. Loading
core/java/android/content/pm/LauncherUserInfo.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 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 LauncherUserInfo;
core/java/android/content/pm/LauncherUserInfo.java 0 → 100644 +126 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 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.annotation.FlaggedApi; import android.annotation.NonNull; import android.os.Flags; import android.os.Parcel; import android.os.Parcelable; import android.os.UserHandle; import android.os.UserManager; /** * The LauncherUserInfo object holds information about an Android user that is required to display * the Launcher related UI elements specific to the user (like badges). * * @hide */ @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) public final class LauncherUserInfo implements Parcelable { private final String mUserType; // Serial number for the user, should be same as in the {@link UserInfo} object. private final int mUserSerialNumber; /** * Returns type of the user as defined in {@link UserManager}. e.g., * {@link UserManager.USER_TYPE_PROFILE_MANAGED} or {@link UserManager.USER_TYPE_PROFILE_ClONE} * TODO(b/303812736): Make the return type public and update javadoc here once the linked bug * is resolved. * * @return the userType for the user whose LauncherUserInfo this is * @hide */ @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) @NonNull public String getUserType() { return mUserType; } /** * Returns serial number of user as returned by * {@link UserManager#getSerialNumberForUser(UserHandle)} * * @return the serial number associated with the user * @hide */ @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) public int getUserSerialNumber() { return mUserSerialNumber; } private LauncherUserInfo(@NonNull Parcel in) { mUserType = in.readString16NoHelper(); mUserSerialNumber = in.readInt(); } @Override @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeString16NoHelper(mUserType); dest.writeInt(mUserSerialNumber); } @Override @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) public int describeContents() { return 0; } @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) public static final @android.annotation.NonNull Creator<LauncherUserInfo> CREATOR = new Creator<LauncherUserInfo>() { @Override public LauncherUserInfo createFromParcel(Parcel in) { return new LauncherUserInfo(in); } @Override public LauncherUserInfo[] newArray(int size) { return new LauncherUserInfo[size]; } }; /** * @hide */ public static final class Builder { private final String mUserType; private final int mUserSerialNumber; public Builder(@NonNull String userType, int userSerialNumber) { this.mUserType = userType; this.mUserSerialNumber = userSerialNumber; } /** * Builds the LauncherUserInfo object */ @NonNull public LauncherUserInfo build() { return new LauncherUserInfo(this.mUserType, this.mUserSerialNumber); } } // End builder private LauncherUserInfo(@NonNull String userType, int userSerialNumber) { this.mUserType = userType; this.mUserSerialNumber = userSerialNumber; } }
services/core/java/com/android/server/pm/LauncherAppsService.java +20 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ 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.LauncherUserInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageInstaller.SessionInfo; import android.content.pm.PackageManager; Loading Loading @@ -1376,6 +1377,25 @@ public class LauncherAppsService extends SystemService { } } @Override public @Nullable LauncherUserInfo getLauncherUserInfo(@NonNull UserHandle user) { // Only system launchers, which have access to recents should have access to this API. // TODO(b/303803157): Add the new permission check if we decide to have one. if (!mActivityTaskManagerInternal.isCallerRecents(Binder.getCallingUid())) { throw new SecurityException("Caller is not the recents app"); } if (!canAccessProfile(user.getIdentifier(), "Can't access LauncherUserInfo for another user")) { return null; } long ident = injectClearCallingIdentity(); try { return mUserManagerInternal.getLauncherUserInfo(user.getIdentifier()); } finally { injectRestoreCallingIdentity(ident); } } @Override public void startActivityAsUser(IApplicationThread caller, String callingPackage, String callingFeatureId, ComponentName component, Rect sourceBounds, Loading