Using LauncherApps API for PS Settings and Setup Flow.
Bug: 310027945 Test: Launcher3 tests Flag: ACONFIG com.android.launcher3.enable_private_space TRUNKFOOD Change-Id: I6e04a4b0c33d4526d83b51e512e1e4372ce1cca4
This commit is contained in:
@@ -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;
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<>();
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user