Merge "Convert menu options to tabs Add new tab for apps on sd"
diff --git a/res/drawable-hdpi/ic_settings_display.png b/res/drawable-hdpi/ic_settings_display.png
index 8efbe76..c35e8be 100644
--- a/res/drawable-hdpi/ic_settings_display.png
+++ b/res/drawable-hdpi/ic_settings_display.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_settings_display.png b/res/drawable-mdpi/ic_settings_display.png
index 1e5628c..85af393 100644
--- a/res/drawable-mdpi/ic_settings_display.png
+++ b/res/drawable-mdpi/ic_settings_display.png
Binary files differ
diff --git a/src/com/android/settings/ChooseLockGeneric.java b/src/com/android/settings/ChooseLockGeneric.java
index a3c8d8a..b244a75 100644
--- a/src/com/android/settings/ChooseLockGeneric.java
+++ b/src/com/android/settings/ChooseLockGeneric.java
@@ -37,22 +37,22 @@
         
         final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
         
-        int mode = getIntent().getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, -1);
-        if (mode == -1) {
-            mode = lockPatternUtils.getPasswordMode();
+        int quality = getIntent().getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, -1);
+        if (quality == -1) {
+            quality = lockPatternUtils.getPasswordMode();
         }
-        int minMode = mDPM.getPasswordMode();
-        if (mode < minMode) {
-            mode = minMode;
+        int minQuality = mDPM.getPasswordQuality(null);
+        if (quality < minQuality) {
+            quality = minQuality;
         }
-        if (mode >= DevicePolicyManager.PASSWORD_MODE_NUMERIC) {
-            int minLength = mDPM.getMinimumPasswordLength();
+        if (quality >= DevicePolicyManager.PASSWORD_QUALITY_NUMERIC) {
+            int minLength = mDPM.getPasswordMinimumLength(null);
             if (minLength < 4) {
                 minLength = 4;
             }
-            final int maxLength = 16;
+            final int maxLength = mDPM.getPasswordMaximumLength(quality);
             Intent intent = new Intent().setClass(this, ChooseLockPassword.class);
-            intent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, mode);
+            intent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, quality);
             intent.putExtra(ChooseLockPassword.PASSWORD_MIN_KEY, minLength);
             intent.putExtra(ChooseLockPassword.PASSWORD_MAX_KEY, maxLength);
             startActivity(intent);
diff --git a/src/com/android/settings/DeviceAdminAdd.java b/src/com/android/settings/DeviceAdminAdd.java
index db4263a..03db9ce 100644
--- a/src/com/android/settings/DeviceAdminAdd.java
+++ b/src/com/android/settings/DeviceAdminAdd.java
@@ -66,8 +66,9 @@
     Button mActionButton;
     
     View mSelectLayout;
-    ArrayList<DeviceAdminInfo> mAvailablePolicies
-            = new ArrayList<DeviceAdminInfo>();
+    
+    final ArrayList<View> mAddingPolicies = new ArrayList<View>();
+    final ArrayList<View> mActivePolicies = new ArrayList<View>();
     
     boolean mAdding;
     
@@ -191,6 +192,13 @@
         }
     }
     
+    static void setViewVisibility(ArrayList<View> views, int visibility) {
+        final int N = views.size();
+        for (int i=0; i<N; i++) {
+            views.get(i).setVisibility(visibility);
+        }
+    }
+    
     void updateInterface() {
         mAdminIcon.setImageDrawable(mDeviceAdmin.loadIcon(getPackageManager()));
         mAdminName.setText(mDeviceAdmin.loadLabel(getPackageManager()));
@@ -207,19 +215,37 @@
         } else {
             mAddMsg.setVisibility(View.GONE);
         }
-        ArrayList<DeviceAdminInfo.PolicyInfo> policies = mDeviceAdmin.getUsedPolicies();
-        for (int i=0; i<policies.size(); i++) {
-            DeviceAdminInfo.PolicyInfo pi = policies.get(i);
-            mAdminPolicies.addView(AppSecurityPermissions.getPermissionItemView(
-                    this, getText(pi.label), getText(pi.description), true));
-        }
         if (mDPM.isAdminActive(mDeviceAdmin.getComponent())) {
+            if (mActivePolicies.size() == 0) {
+                ArrayList<DeviceAdminInfo.PolicyInfo> policies = mDeviceAdmin.getUsedPolicies();
+                for (int i=0; i<policies.size(); i++) {
+                    DeviceAdminInfo.PolicyInfo pi = policies.get(i);
+                    View view = AppSecurityPermissions.getPermissionItemView(
+                            this, getText(pi.label), "", true);
+                    mActivePolicies.add(view);
+                    mAdminPolicies.addView(view);
+                }
+            }
+            setViewVisibility(mActivePolicies, View.VISIBLE);
+            setViewVisibility(mAddingPolicies, View.GONE);
             mAdminWarning.setText(getString(R.string.device_admin_status,
                     mDeviceAdmin.getActivityInfo().applicationInfo.loadLabel(getPackageManager())));
             mTitle.setText(getText(R.string.active_device_admin_msg));
             mActionButton.setText(getText(R.string.remove_device_admin));
             mAdding = false;
         } else {
+            if (mAddingPolicies.size() == 0) {
+                ArrayList<DeviceAdminInfo.PolicyInfo> policies = mDeviceAdmin.getUsedPolicies();
+                for (int i=0; i<policies.size(); i++) {
+                    DeviceAdminInfo.PolicyInfo pi = policies.get(i);
+                    View view = AppSecurityPermissions.getPermissionItemView(
+                            this, getText(pi.label), getText(pi.description), true);
+                    mAddingPolicies.add(view);
+                    mAdminPolicies.addView(view);
+                }
+            }
+            setViewVisibility(mAddingPolicies, View.VISIBLE);
+            setViewVisibility(mActivePolicies, View.GONE);
             mAdminWarning.setText(getString(R.string.device_admin_warning,
                     mDeviceAdmin.getActivityInfo().applicationInfo.loadLabel(getPackageManager())));
             mTitle.setText(getText(R.string.add_device_admin_msg));
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 5c44f27..b8ea18c 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -224,7 +224,7 @@
 
     protected void handleUpdateUnlockMethod(final String value) {
         if ("none".equals(value)) {
-            if (mDPM.getPasswordMode() == DevicePolicyManager.PASSWORD_MODE_UNSPECIFIED) {
+            if (mDPM.getPasswordQuality(null) == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
                 mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST);
             }
         } else {
@@ -236,7 +236,7 @@
             } else {
                 reqMode = LockPatternUtils.MODE_PATTERN;
             }
-            int minMode = mDPM.getPasswordMode();
+            int minMode = mDPM.getPasswordQuality(null);
             if (reqMode < minMode) {
                 reqMode = minMode;
             }
diff --git a/src/com/android/settings/wifi/AdvancedSettings.java b/src/com/android/settings/wifi/AdvancedSettings.java
index ff485de..7d62f8e 100644
--- a/src/com/android/settings/wifi/AdvancedSettings.java
+++ b/src/com/android/settings/wifi/AdvancedSettings.java
@@ -34,6 +34,7 @@
 import android.view.Menu;
 import android.view.MenuItem;
 import android.widget.Toast;
+import android.os.SystemProperties;
 
 public class AdvancedSettings extends PreferenceActivity
         implements Preference.OnPreferenceChangeListener {
@@ -57,6 +58,9 @@
     private static final int MENU_ITEM_SAVE = Menu.FIRST;
     private static final int MENU_ITEM_CANCEL = Menu.FIRST + 1;
     
+    //Tracks ro.debuggable (1 on userdebug builds)
+    private static int DEBUGGABLE;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -71,19 +75,24 @@
             preference.setOnPreferenceChangeListener(this);
         }
 
-//        /*
-//         * Fix the Run-time IllegalStateException that ListPreference requires an entries
-//         * array and an entryValues array, this exception occurs when user open/close the
-//         * slider in the Regulatory domain dialog.
-//         */
-//        initNumChannelsPreference();
+        DEBUGGABLE = SystemProperties.getInt("ro.debuggable", 0);
+
         /**
          * Remove user control of regulatory domain
-         * channel count settings
+         * channel count settings in non userdebug builds
          */
-        Preference chanPref = findPreference(KEY_NUM_CHANNELS);
-        if (chanPref != null) {
-            getPreferenceScreen().removePreference(chanPref);
+        if (DEBUGGABLE == 1) {
+            /*
+             * Fix the Run-time IllegalStateException that ListPreference requires an entries
+             * array and an entryValues array, this exception occurs when user open/close the
+             * slider in the Regulatory domain dialog.
+             */
+            initNumChannelsPreference();
+        } else {
+            Preference chanPref = findPreference(KEY_NUM_CHANNELS);
+            if (chanPref != null) {
+              getPreferenceScreen().removePreference(chanPref);
+            }
         }
     }
     
@@ -94,9 +103,11 @@
         updateUi();
         /**
          * Remove user control of regulatory domain
-         * channel count settings
+         * channel count settings in non userdebug builds
          */
-        //initNumChannelsPreference();
+        if (DEBUGGABLE == 1) {
+            initNumChannelsPreference();
+        }
         initSleepPolicyPreference();
         refreshMacAddress();
     }