Loading quickstep/src/com/android/launcher3/uioverrides/ApiWrapper.java +23 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.app.PendingIntent; import android.app.Person; import android.content.Context; import android.content.Intent; import android.content.IntentSender; import android.content.pm.ActivityInfo; import android.content.pm.LauncherActivityInfo; import android.content.pm.LauncherApps; Loading Loading @@ -157,6 +158,28 @@ public class ApiWrapper { } } /** * Returns an intent which can be used to open Private Space Settings. */ public static Intent getPrivateSpaceSettingsIntent(Context context) { if (android.os.Flags.allowPrivateProfile() && Flags.enablePrivateSpace()) { LauncherApps launcherApps = context.getSystemService(LauncherApps.class); IntentSender intentSender = launcherApps.getPrivateSpaceSettingsIntent(); if (intentSender == null) { return null; } StartActivityParams params = new StartActivityParams((PendingIntent) null, 0); params.intentSender = intentSender; ActivityOptions options = ActivityOptions.makeBasic() .setPendingIntentBackgroundActivityStartMode(ActivityOptions .MODE_BACKGROUND_ACTIVITY_START_ALLOWED); params.options = options.toBundle(); params.requireActivityResult = false; return ProxyActivityStarter.getLaunchIntent(context, params); } return null; } /** * Checks if an activity is flagged as non-resizeable. */ Loading src/com/android/launcher3/allapps/PrivateProfileManager.java +4 −10 Original line number Diff line number Diff line Loading @@ -30,8 +30,6 @@ import static com.android.launcher3.util.SettingsCache.PRIVATE_SPACE_HIDE_WHEN_L import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.UserHandle; import android.os.UserManager; Loading Loading @@ -60,10 +58,6 @@ import java.util.function.Predicate; */ public class PrivateProfileManager extends UserProfileManager { // TODO (b/324573634): Fix the intent string. public static final Intent PRIVATE_SPACE_INTENT = new Intent("com.android.settings.action.PRIVATE_SPACE_SETUP_FLOW"); private final ActivityAllAppsContainerView<?> mAllApps; private final Predicate<UserHandle> mPrivateProfileMatcher; private Set<String> mPreInstalledSystemPackages = new HashSet<>(); Loading Loading @@ -162,7 +156,8 @@ public class PrivateProfileManager extends UserProfileManager { /** Opens the Private Space Settings Page. */ public void openPrivateSpaceSettings() { if (mPrivateSpaceSettingsAvailable) { mAllApps.getContext().startActivity(PRIVATE_SPACE_INTENT); mAllApps.getContext() .startActivity(ApiWrapper.getPrivateSpaceSettingsIntent(mAllApps.getContext())); } } Loading Loading @@ -194,9 +189,8 @@ public class PrivateProfileManager extends UserProfileManager { private void initializePrivateSpaceSettingsState() { Preconditions.assertNonUiThread(); ResolveInfo resolveInfo = mAllApps.getContext().getPackageManager() .resolveActivity(PRIVATE_SPACE_INTENT, PackageManager.MATCH_SYSTEM_ONLY); setPrivateSpaceSettingsAvailable(resolveInfo != null); Intent psSettingsIntent = ApiWrapper.getPrivateSpaceSettingsIntent(mAllApps.getContext()); setPrivateSpaceSettingsAvailable(psSettingsIntent != null); } private void setPreInstalledSystemPackages() { Loading src_ui_overrides/com/android/launcher3/uioverrides/ApiWrapper.java +7 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,13 @@ public class ApiWrapper { .authority(context.getPackageName()).build()); } /** * Returns an intent which can be used to open Private Space Settings. */ public static Intent getPrivateSpaceSettingsIntent(Context context) { return null; } /** * Checks if an activity is flagged as non-resizeable. */ Loading tests/src/com/android/launcher3/allapps/PrivateProfileManagerTest.java +4 −5 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import androidx.test.runner.AndroidJUnit4; import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.pm.UserCache; import com.android.launcher3.uioverrides.ApiWrapper; import com.android.launcher3.util.ActivityContextWrapper; import com.android.launcher3.util.UserIconInfo; import com.android.launcher3.util.rule.TestStabilityRule; Loading Loading @@ -176,17 +177,15 @@ public class PrivateProfileManagerTest { } @Test public void openPrivateSpaceSettings_triggersSecurityAndPrivacyIntent() { Intent expectedIntent = PrivateProfileManager.PRIVATE_SPACE_INTENT; public void openPrivateSpaceSettings_triggersCorrectIntent() { Intent expectedIntent = ApiWrapper.getPrivateSpaceSettingsIntent(mContext); ArgumentCaptor<Intent> acIntent = ArgumentCaptor.forClass(Intent.class); mPrivateProfileManager.setPrivateSpaceSettingsAvailable(true); mPrivateProfileManager.openPrivateSpaceSettings(); Mockito.verify(mContext).startActivity(acIntent.capture()); Intent actualIntent = acIntent.getValue(); assertEquals("Intent Action is different", expectedIntent.getAction(), actualIntent.getAction()); assertEquals("Intent Action is different", expectedIntent, acIntent.getValue()); } private static void awaitTasksCompleted() throws Exception { Loading Loading
quickstep/src/com/android/launcher3/uioverrides/ApiWrapper.java +23 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.app.PendingIntent; import android.app.Person; import android.content.Context; import android.content.Intent; import android.content.IntentSender; import android.content.pm.ActivityInfo; import android.content.pm.LauncherActivityInfo; import android.content.pm.LauncherApps; Loading Loading @@ -157,6 +158,28 @@ public class ApiWrapper { } } /** * Returns an intent which can be used to open Private Space Settings. */ public static Intent getPrivateSpaceSettingsIntent(Context context) { if (android.os.Flags.allowPrivateProfile() && Flags.enablePrivateSpace()) { LauncherApps launcherApps = context.getSystemService(LauncherApps.class); IntentSender intentSender = launcherApps.getPrivateSpaceSettingsIntent(); if (intentSender == null) { return null; } StartActivityParams params = new StartActivityParams((PendingIntent) null, 0); params.intentSender = intentSender; ActivityOptions options = ActivityOptions.makeBasic() .setPendingIntentBackgroundActivityStartMode(ActivityOptions .MODE_BACKGROUND_ACTIVITY_START_ALLOWED); params.options = options.toBundle(); params.requireActivityResult = false; return ProxyActivityStarter.getLaunchIntent(context, params); } return null; } /** * Checks if an activity is flagged as non-resizeable. */ Loading
src/com/android/launcher3/allapps/PrivateProfileManager.java +4 −10 Original line number Diff line number Diff line Loading @@ -30,8 +30,6 @@ import static com.android.launcher3.util.SettingsCache.PRIVATE_SPACE_HIDE_WHEN_L import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.UserHandle; import android.os.UserManager; Loading Loading @@ -60,10 +58,6 @@ import java.util.function.Predicate; */ public class PrivateProfileManager extends UserProfileManager { // TODO (b/324573634): Fix the intent string. public static final Intent PRIVATE_SPACE_INTENT = new Intent("com.android.settings.action.PRIVATE_SPACE_SETUP_FLOW"); private final ActivityAllAppsContainerView<?> mAllApps; private final Predicate<UserHandle> mPrivateProfileMatcher; private Set<String> mPreInstalledSystemPackages = new HashSet<>(); Loading Loading @@ -162,7 +156,8 @@ public class PrivateProfileManager extends UserProfileManager { /** Opens the Private Space Settings Page. */ public void openPrivateSpaceSettings() { if (mPrivateSpaceSettingsAvailable) { mAllApps.getContext().startActivity(PRIVATE_SPACE_INTENT); mAllApps.getContext() .startActivity(ApiWrapper.getPrivateSpaceSettingsIntent(mAllApps.getContext())); } } Loading Loading @@ -194,9 +189,8 @@ public class PrivateProfileManager extends UserProfileManager { private void initializePrivateSpaceSettingsState() { Preconditions.assertNonUiThread(); ResolveInfo resolveInfo = mAllApps.getContext().getPackageManager() .resolveActivity(PRIVATE_SPACE_INTENT, PackageManager.MATCH_SYSTEM_ONLY); setPrivateSpaceSettingsAvailable(resolveInfo != null); Intent psSettingsIntent = ApiWrapper.getPrivateSpaceSettingsIntent(mAllApps.getContext()); setPrivateSpaceSettingsAvailable(psSettingsIntent != null); } private void setPreInstalledSystemPackages() { Loading
src_ui_overrides/com/android/launcher3/uioverrides/ApiWrapper.java +7 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,13 @@ public class ApiWrapper { .authority(context.getPackageName()).build()); } /** * Returns an intent which can be used to open Private Space Settings. */ public static Intent getPrivateSpaceSettingsIntent(Context context) { return null; } /** * Checks if an activity is flagged as non-resizeable. */ Loading
tests/src/com/android/launcher3/allapps/PrivateProfileManagerTest.java +4 −5 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import androidx.test.runner.AndroidJUnit4; import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.pm.UserCache; import com.android.launcher3.uioverrides.ApiWrapper; import com.android.launcher3.util.ActivityContextWrapper; import com.android.launcher3.util.UserIconInfo; import com.android.launcher3.util.rule.TestStabilityRule; Loading Loading @@ -176,17 +177,15 @@ public class PrivateProfileManagerTest { } @Test public void openPrivateSpaceSettings_triggersSecurityAndPrivacyIntent() { Intent expectedIntent = PrivateProfileManager.PRIVATE_SPACE_INTENT; public void openPrivateSpaceSettings_triggersCorrectIntent() { Intent expectedIntent = ApiWrapper.getPrivateSpaceSettingsIntent(mContext); ArgumentCaptor<Intent> acIntent = ArgumentCaptor.forClass(Intent.class); mPrivateProfileManager.setPrivateSpaceSettingsAvailable(true); mPrivateProfileManager.openPrivateSpaceSettings(); Mockito.verify(mContext).startActivity(acIntent.capture()); Intent actualIntent = acIntent.getValue(); assertEquals("Intent Action is different", expectedIntent.getAction(), actualIntent.getAction()); assertEquals("Intent Action is different", expectedIntent, acIntent.getValue()); } private static void awaitTasksCompleted() throws Exception { Loading