DSU enhancement (5/N)

* Support default keyguard strings
  This allows the client to use default strings for the keyguard
  dialog instead of the ones relevant to DSU.

Bug: 277691885
Test: set up pin code and run
  adb shell am start-activity \
  -n com.android.dynsystem/com.android.dynsystem.VerificationActivity \
  -a android.os.image.action.START_INSTALL \
  --el KEY_USERDATA_SIZE 2147483648 \
  --ez KEY_ENABLE_WHEN_COMPLETED true \
  --ez KEY_ONE_SHOT false \
  --ez KEY_KEYGUARD_USE_DEFAULT_STRINGS true
Change-Id: Ic6c528c180a7006d9392734b9a0f562418c47c3b
This commit is contained in:
JW Wang
2023-04-11 16:16:31 +08:00
parent e5dff82b53
commit 9a4d24e735
2 changed files with 29 additions and 4 deletions

View File

@@ -238,6 +238,15 @@ public class DynamicSystemClient {
*/
public static final String KEY_ONE_SHOT = "KEY_ONE_SHOT";
/**
* Intent key: Whether to use default strings when showing the dialog that prompts
* user for device credentials.
* False indicates using the custom strings provided by {@code DynamicSystem}.
* @hide
*/
public static final String KEY_KEYGUARD_USE_DEFAULT_STRINGS =
"KEY_KEYGUARD_USE_DEFAULT_STRINGS";
private static class IncomingHandler extends Handler {
private final WeakReference<DynamicSystemClient> mWeakClient;

View File

@@ -16,6 +16,8 @@
package com.android.dynsystem;
import static android.os.image.DynamicSystemClient.KEY_KEYGUARD_USE_DEFAULT_STRINGS;
import android.app.Activity;
import android.app.KeyguardManager;
import android.content.Context;
@@ -47,10 +49,7 @@ public class VerificationActivity extends Activity {
KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
if (km != null) {
String title = getString(R.string.keyguard_title);
String description = getString(R.string.keyguard_description);
Intent intent = km.createConfirmDeviceCredentialIntent(title, description);
Intent intent = createConfirmDeviceCredentialIntent(km);
if (intent == null) {
Log.d(TAG, "This device is not protected by a password/pin");
startInstallationService();
@@ -63,6 +62,23 @@ public class VerificationActivity extends Activity {
}
}
private Intent createConfirmDeviceCredentialIntent(KeyguardManager km) {
final boolean useDefaultStrings =
getIntent().getBooleanExtra(KEY_KEYGUARD_USE_DEFAULT_STRINGS, false);
final String title;
final String description;
if (useDefaultStrings) {
// Use default strings provided by keyguard manager
title = null;
description = null;
} else {
// Use custom strings provided by DSU
title = getString(R.string.keyguard_title);
description = getString(R.string.keyguard_description);
}
return km.createConfirmDeviceCredentialIntent(title, description);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {