Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19f81ba5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Adding API to create and access Private Space from Launcher" into main

parents 6f297adc cad0c4ac
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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);
+22 −0
Original line number Diff line number Diff line
@@ -898,6 +898,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.
+24 −0
Original line number Diff line number Diff line
@@ -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);