OSDN Git Service

[Settings] Pass lock type extra back to SUW
authorLucky Zhang <luckyzh@google.com>
Wed, 10 Jun 2015 18:05:09 +0000 (11:05 -0700)
committerLucky Zhang <luckyzh@google.com>
Wed, 10 Jun 2015 19:42:15 +0000 (12:42 -0700)
When SetupChooseLockGeneric finishes, it will include the lock type
(password quality) as an extra in the returned intent data. This extra
will be used by Setup Wizard to determine the lock type and log it for
the metrics.

Bug: 20349248
Change-Id: I501e07254ab857ad4f137e7050326415853883d1

src/com/android/settings/SetupChooseLockGeneric.java

index 82157c0..8b09a10 100644 (file)
@@ -16,6 +16,7 @@
 
 package com.android.settings;
 
+import com.android.internal.widget.LockPatternUtils;
 import com.android.setupwizardlib.SetupWizardListLayout;
 import com.android.setupwizardlib.view.NavigationBar;
 
@@ -25,6 +26,7 @@ import android.content.Context;
 import android.content.Intent;
 import android.content.res.Resources;
 import android.os.Bundle;
+import android.os.UserHandle;
 import android.preference.PreferenceFragment;
 import android.hardware.fingerprint.FingerprintManager;
 import android.view.LayoutInflater;
@@ -60,6 +62,8 @@ public class SetupChooseLockGeneric extends ChooseLockGeneric {
     public static class SetupChooseLockGenericFragment extends ChooseLockGenericFragment
             implements NavigationBar.NavigationBarListener {
 
+        private static final String EXTRA_PASSWORD_QUALITY = ":settings:password_quality";
+
         @Override
         public View onCreateView(LayoutInflater inflater, ViewGroup container,
                 Bundle savedInstanceState) {
@@ -91,6 +95,15 @@ public class SetupChooseLockGeneric extends ChooseLockGeneric {
         @Override
         public void onActivityResult(int requestCode, int resultCode, Intent data) {
             if (resultCode != RESULT_CANCELED) {
+                if (data == null) {
+                    data = new Intent();
+                }
+                // Add the password quality extra to the intent data that will be sent back for
+                // Setup Wizard.
+                LockPatternUtils lockPatternUtils = new LockPatternUtils(getActivity());
+                data.putExtra(EXTRA_PASSWORD_QUALITY,
+                        lockPatternUtils.getKeyguardStoredPasswordQuality(UserHandle.myUserId()));
+
                 super.onActivityResult(requestCode, resultCode, data);
             }
             // If the started activity was cancelled (e.g. the user presses back), then this