Show private space unlocked toast when PS is unlocked from Settings

This contains the change to show private space unlocked toast message
when PS is unlocked from private space settings entry point.
Also has change in the pending intent passed to requestQuietModeEnabled
API to allow BAL of PS settings page as suggested in go/debug-bal

Recording is uploaded to the issue b/317313482

Bug: 317313482
Test: Manually verified Toast is shown on PS unlock from settings

Change-Id: I2f03b7decdad2bb9e1018012ff5986e48305a4e7
This commit is contained in:
josephpv
2024-01-11 11:56:07 +00:00
committed by Joseph Vincent
parent 87e9f512d2
commit 4d6e11ce4b
3 changed files with 24 additions and 3 deletions

View File

@@ -1285,6 +1285,8 @@
<string name="private_space_deleted">Private Space successfully deleted</string> <string name="private_space_deleted">Private Space successfully deleted</string>
<!-- Toast to show when the private space could not be deleted. [CHAR LIMIT=NONE] --> <!-- Toast to show when the private space could not be deleted. [CHAR LIMIT=NONE] -->
<string name="private_space_delete_failed">Private Space could not be deleted</string> <string name="private_space_delete_failed">Private Space could not be deleted</string>
<!-- Toast to show when the private space is unlocked from settings entry point. [CHAR LIMIT=40] -->
<string name="private_space_unlocked">Private space unlocked</string>
<!-- Title of the Alert Dialog when no screen lock is set [CHAR LIMIT=30] --> <!-- Title of the Alert Dialog when no screen lock is set [CHAR LIMIT=30] -->
<string name="no_device_lock_title">Set a screen lock</string> <string name="no_device_lock_title">Set a screen lock</string>
<!-- Summary of the alert when no screen lock is set [CHAR LIMIT=90] --> <!-- Summary of the alert when no screen lock is set [CHAR LIMIT=90] -->

View File

@@ -18,6 +18,7 @@ package com.android.settings.privatespace;
import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PASSWORD; import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PASSWORD;
import android.app.ActivityOptions;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.KeyguardManager; import android.app.KeyguardManager;
import android.app.PendingIntent; import android.app.PendingIntent;
@@ -50,6 +51,8 @@ import com.google.android.setupdesign.util.ThemeHelper;
*/ */
public class PrivateSpaceAuthenticationActivity extends FragmentActivity { public class PrivateSpaceAuthenticationActivity extends FragmentActivity {
private static final String TAG = "PrivateSpaceAuthCheck"; private static final String TAG = "PrivateSpaceAuthCheck";
public static final String EXTRA_SHOW_PRIVATE_SPACE_UNLOCKED =
"extra_show_private_space_unlocked";
private PrivateSpaceMaintainer mPrivateSpaceMaintainer; private PrivateSpaceMaintainer mPrivateSpaceMaintainer;
private KeyguardManager mKeyguardManager; private KeyguardManager mKeyguardManager;
@@ -158,12 +161,19 @@ public class PrivateSpaceAuthenticationActivity extends FragmentActivity {
.setTransitionType(SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE) .setTransitionType(SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE)
.setSourceMetricsCategory(SettingsEnums.PRIVATE_SPACE_SETTINGS); .setSourceMetricsCategory(SettingsEnums.PRIVATE_SPACE_SETTINGS);
if (mPrivateSpaceMaintainer.isPrivateSpaceLocked()) { if (mPrivateSpaceMaintainer.isPrivateSpaceLocked()) {
ActivityOptions options =
ActivityOptions.makeBasic()
.setPendingIntentCreatorBackgroundActivityStartMode(
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
mPrivateSpaceMaintainer.unlockPrivateSpace( mPrivateSpaceMaintainer.unlockPrivateSpace(
PendingIntent.getActivity( PendingIntent.getActivity(
context, /* requestCode */ context, /* requestCode */
0, 0,
privateSpaceSettings.toIntent(), privateSpaceSettings
PendingIntent.FLAG_IMMUTABLE) .toIntent()
.putExtra(EXTRA_SHOW_PRIVATE_SPACE_UNLOCKED, true),
PendingIntent.FLAG_IMMUTABLE,
options.toBundle())
.getIntentSender()); .getIntentSender());
} else { } else {
privateSpaceSettings.launch(); privateSpaceSettings.launch();

View File

@@ -16,20 +16,29 @@
package com.android.settings.privatespace; package com.android.settings.privatespace;
import static com.android.settings.privatespace.PrivateSpaceAuthenticationActivity.EXTRA_SHOW_PRIVATE_SPACE_UNLOCKED;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment; import com.android.settings.dashboard.DashboardFragment;
/** Fragment representing the Private Space dashboard in Settings. */ /** Fragment representing the Private Space dashboard in Settings. */
public class PrivateSpaceDashboardFragment extends DashboardFragment { public class PrivateSpaceDashboardFragment extends DashboardFragment {
private static final String TAG = "PrivateSpaceDashboardFragment"; private static final String TAG = "PSDashboardFragment";
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
if (android.os.Flags.allowPrivateProfile()) { if (android.os.Flags.allowPrivateProfile()) {
super.onCreate(icicle); super.onCreate(icicle);
if (getIntent().getBooleanExtra(EXTRA_SHOW_PRIVATE_SPACE_UNLOCKED, false)) {
Log.i(TAG, "Private space unlocked showing toast");
Toast.makeText(getContext(), R.string.private_space_unlocked, Toast.LENGTH_SHORT)
.show();
}
} }
} }