Merge "Support multi-pane deeplink in PrivateSpaceAuthenticationActivity" into main
This commit is contained in:
@@ -5139,8 +5139,6 @@
|
|||||||
<action android:name="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS" />
|
<action android:name="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
|
|
||||||
android:value="@string/menu_key_security"/>
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".privatespace.PrivateProfileContextHelperActivity" android:exported="false"/>
|
<activity android:name=".privatespace.PrivateProfileContextHelperActivity" android:exported="false"/>
|
||||||
|
@@ -19,6 +19,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 static com.android.internal.app.SetScreenLockDialogActivity.LAUNCH_REASON_PRIVATE_SPACE_SETTINGS_ACCESS;
|
import static com.android.internal.app.SetScreenLockDialogActivity.LAUNCH_REASON_PRIVATE_SPACE_SETTINGS_ACCESS;
|
||||||
|
import static com.android.settings.activityembedding.EmbeddedDeepLinkUtils.tryStartMultiPaneDeepLink;
|
||||||
|
|
||||||
import android.app.ActivityOptions;
|
import android.app.ActivityOptions;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
@@ -36,11 +37,12 @@ import androidx.activity.result.ActivityResult;
|
|||||||
import androidx.activity.result.ActivityResultLauncher;
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
import androidx.activity.result.contract.ActivityResultContracts;
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.app.SetScreenLockDialogActivity;
|
import com.android.internal.app.SetScreenLockDialogActivity;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
|
||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
import com.android.settingslib.transition.SettingsTransitionHelper;
|
import com.android.settingslib.transition.SettingsTransitionHelper;
|
||||||
|
|
||||||
@@ -52,7 +54,7 @@ import com.google.android.setupdesign.util.ThemeHelper;
|
|||||||
* user to set a device lock if not set with an alert dialog. This can be launched using the intent
|
* user to set a device lock if not set with an alert dialog. This can be launched using the intent
|
||||||
* com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS.
|
* com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS.
|
||||||
*/
|
*/
|
||||||
public class PrivateSpaceAuthenticationActivity extends SettingsActivity {
|
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 =
|
public static final String EXTRA_SHOW_PRIVATE_SPACE_UNLOCKED =
|
||||||
"extra_show_private_space_unlocked";
|
"extra_show_private_space_unlocked";
|
||||||
@@ -76,31 +78,55 @@ public class PrivateSpaceAuthenticationActivity extends SettingsActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (isFinishing()) {
|
if (!(Flags.allowPrivateProfile()
|
||||||
|
&& android.multiuser.Flags.enablePrivateSpaceFeatures())) {
|
||||||
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Flags.allowPrivateProfile()
|
Intent intent = getIntent();
|
||||||
&& android.multiuser.Flags.enablePrivateSpaceFeatures()) {
|
String highlightMenuKey = getString(R.string.menu_key_security);
|
||||||
ThemeHelper.trySetDynamicColor(this);
|
if (shouldShowMultiPaneDeepLink(intent)
|
||||||
mPrivateSpaceMaintainer =
|
&& tryStartMultiPaneDeepLink(this, intent, highlightMenuKey)) {
|
||||||
new Injector().injectPrivateSpaceMaintainer(getApplicationContext());
|
finish();
|
||||||
if (getKeyguardManager().isDeviceSecure()) {
|
return;
|
||||||
if (savedInstanceState == null) {
|
}
|
||||||
if (mPrivateSpaceMaintainer.doesPrivateSpaceExist()) {
|
|
||||||
unlockAndLaunchPrivateSpaceSettings(this);
|
ThemeHelper.trySetDynamicColor(this);
|
||||||
} else {
|
mPrivateSpaceMaintainer =
|
||||||
authenticatePrivateSpaceEntry();
|
new Injector().injectPrivateSpaceMaintainer(getApplicationContext());
|
||||||
}
|
if (getKeyguardManager().isDeviceSecure()) {
|
||||||
|
if (savedInstanceState == null) {
|
||||||
|
if (mPrivateSpaceMaintainer.doesPrivateSpaceExist()) {
|
||||||
|
unlockAndLaunchPrivateSpaceSettings(this);
|
||||||
|
} else {
|
||||||
|
authenticatePrivateSpaceEntry();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
promptToSetDeviceLock();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
finish();
|
promptToSetDeviceLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean shouldShowMultiPaneDeepLink(Intent intent) {
|
||||||
|
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the activity is task root, starting trampoline is needed in order to show two-pane UI.
|
||||||
|
// If FLAG_ACTIVITY_NEW_TASK is set, the activity will become the start of a new task on
|
||||||
|
// this history stack, so starting trampoline is needed in order to notify the homepage that
|
||||||
|
// the highlight key is changed.
|
||||||
|
if (!isTaskRoot() && (intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only starts trampoline for deep links. Should return false for all the cases that
|
||||||
|
// Settings app starts SettingsActivity or SubSetting by itself.
|
||||||
|
// Other apps should send deep link intent which matches intent filter of the Activity.
|
||||||
|
return intent.getAction() != null;
|
||||||
|
}
|
||||||
|
|
||||||
/** Starts private space setup flow or the PS settings page on device lock authentication */
|
/** Starts private space setup flow or the PS settings page on device lock authentication */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public void onLockAuthentication(Context context) {
|
public void onLockAuthentication(Context context) {
|
||||||
|
Reference in New Issue
Block a user