summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/content/pm/ILauncherApps.aidl1
-rw-r--r--core/java/android/content/pm/LauncherApps.java22
-rw-r--r--services/core/java/com/android/server/pm/LauncherAppsService.java24
3 files changed, 47 insertions, 0 deletions
diff --git a/core/java/android/content/pm/ILauncherApps.aidl b/core/java/android/content/pm/ILauncherApps.aidl
index cec49c710d92..533fa512dae8 100644
--- a/core/java/android/content/pm/ILauncherApps.aidl
+++ b/core/java/android/content/pm/ILauncherApps.aidl
@@ -67,6 +67,7 @@ interface ILauncherApps {
List<String> getPreInstalledSystemPackages(in UserHandle user);
IntentSender getAppMarketActivityIntent(String callingPackage, String packageName,
in UserHandle user);
+ IntentSender getPrivateSpaceSettingsIntent();
void showAppDetailsAsUser(in IApplicationThread caller, String callingPackage,
String callingFeatureId, in ComponentName component, in Rect sourceBounds,
in Bundle opts, in UserHandle user);
diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java
index e437925693af..6bb9c33afb6a 100644
--- a/core/java/android/content/pm/LauncherApps.java
+++ b/core/java/android/content/pm/LauncherApps.java
@@ -899,6 +899,28 @@ public class LauncherApps {
}
/**
+ * Returns {@link IntentSender} which can be used to start the Private Space Settings Activity.
+ *
+ * <p> Caller should have {@link android.app.role.RoleManager.ROLE_HOME} and either of the
+ * permissions required.</p>
+ *
+ * @return {@link IntentSender} object which launches the Private Space Settings Activity, if
+ * successful, null otherwise.
+ * @hide
+ */
+ @Nullable
+ @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE)
+ @RequiresPermission(conditional = true,
+ anyOf = {ACCESS_HIDDEN_PROFILES_FULL, ACCESS_HIDDEN_PROFILES})
+ public IntentSender getPrivateSpaceSettingsIntent() {
+ try {
+ return mService.getPrivateSpaceSettingsIntent();
+ } catch (RemoteException re) {
+ throw re.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Returns the activity info for a given intent and user handle, if it resolves. Otherwise it
* returns null.
*
diff --git a/services/core/java/com/android/server/pm/LauncherAppsService.java b/services/core/java/com/android/server/pm/LauncherAppsService.java
index 9b0fec2c757b..6b56b85938c2 100644
--- a/services/core/java/com/android/server/pm/LauncherAppsService.java
+++ b/services/core/java/com/android/server/pm/LauncherAppsService.java
@@ -161,6 +161,9 @@ import java.util.zip.ZipOutputStream;
public class LauncherAppsService extends SystemService {
private static final String WM_TRACE_DIR = "/data/misc/wmtrace/";
private static final String VC_FILE_SUFFIX = ".vc";
+ // TODO(b/310027945): Update the intent name.
+ private static final String PS_SETTINGS_INTENT =
+ "com.android.settings.action.PRIVATE_SPACE_SETUP_FLOW";
private static final Set<PosixFilePermission> WM_TRACE_FILE_PERMISSIONS = Set.of(
PosixFilePermission.OWNER_WRITE,
@@ -1777,6 +1780,27 @@ public class LauncherAppsService extends SystemService {
}
}
+ @Override
+ public @Nullable IntentSender getPrivateSpaceSettingsIntent() {
+ if (!canAccessHiddenProfile(getCallingUid(), getCallingPid())) {
+ Slog.e(TAG, "Caller cannot access hidden profiles");
+ return null;
+ }
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ Intent psSettingsIntent = new Intent(PS_SETTINGS_INTENT);
+ psSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ final PendingIntent pi = PendingIntent.getActivity(mContext,
+ /* requestCode */ 0,
+ psSettingsIntent,
+ PendingIntent.FLAG_IMMUTABLE | FLAG_UPDATE_CURRENT);
+ return pi == null ? null : pi.getIntentSender();
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
@Nullable
private IntentSender buildAppMarketIntentSenderForUser(@NonNull UserHandle user) {
Intent appMarketIntent = new Intent(Intent.ACTION_MAIN);