Merge "Apply sliding transition to biometric settings" into sc-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ae11ac2..fa6e95e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -13428,4 +13428,25 @@
     <string name="game_settings_title">Game settings</string>
     <!-- Summary for Game settings entry. [CHAR_LIMIT=NONE] -->
     <string name="game_settings_summary">Turn on Game Dashboard shortcut, etc</string>
+
+    <!-- Bluetooth sim card permission alert for notification title [CHAR LIMIT=none] -->
+    <string name="bluetooth_sim_card_access_notification_title">SIM card access request</string>
+    <!-- Bluetooth sim card permission alert for notification content [CHAR LIMIT=none] -->
+    <string name="bluetooth_sim_card_access_notification_content">A device wants to access your SIM card. Tap for details.</string>
+    <!-- Bluetooth sim card permission alert for dialog title [CHAR LIMIT=none] -->
+    <string name="bluetooth_sim_card_access_dialog_title">Allow access to SIM card?</string>
+    <!-- Bluetooth sim card permission alert for dialog content [CHAR LIMIT=none] -->
+    <string name="bluetooth_sim_card_access_dialog_content">A Bluetooth device, <xliff:g id="device_name" example="My device">%1$s</xliff:g>, wants to access data on your SIM card. This includes your contacts.\n\nWhile connected, <xliff:g id="device_name" example="My device">%2$s</xliff:g> will receive all calls made to <xliff:g id="phone_number" example="0912345678">%3$s</xliff:g>.</string>
+    <!-- Bluetooth connect permission alert for notification title [CHAR LIMIT=none] -->
+    <string name="bluetooth_connect_access_notification_title">Bluetooth device available</string>
+    <!-- Bluetooth connect permission alert for notification content [CHAR LIMIT=none] -->
+    <string name="bluetooth_connect_access_notification_content">A device wants to connect. Tap for details.</string>
+    <!-- Bluetooth connect permission alert for dialog title [CHAR LIMIT=none] -->
+    <string name="bluetooth_connect_access_dialog_title">Connect to Bluetooth device?</string>
+    <!-- Bluetooth connect permission alert for dialog content [CHAR LIMIT=none] -->
+    <string name="bluetooth_connect_access_dialog_content"><xliff:g id="device_name" example="My device">%1$s</xliff:g> wants to connect to this phone.\n\nYou haven\u2019t connected to <xliff:g id="device_name" example="My device">%2$s</xliff:g> before.</string>
+    <!-- Strings for Dialog don't connect button -->
+    <string name="bluetooth_connect_access_dialog_negative">Don\u2019t connect</string>
+    <!-- Strings for Dialog connect button -->
+    <string name="bluetooth_connect_access_dialog_positive">Connect</string>
 </resources>
diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
index 8794b08..211bcc6 100644
--- a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
@@ -25,6 +25,7 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.os.Bundle;
+import android.telephony.TelephonyManager;
 import android.util.Log;
 import android.view.View;
 import android.widget.Button;
@@ -94,13 +95,13 @@
         if(DEBUG) Log.i(TAG, "onCreate() Request type: " + mRequestType);
 
         if (mRequestType == BluetoothDevice.REQUEST_TYPE_PROFILE_CONNECTION) {
-            showDialog(getString(R.string.bluetooth_connection_permission_request), mRequestType);
+            showDialog(getString(R.string.bluetooth_connect_access_dialog_title), mRequestType);
         } else if (mRequestType == BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS) {
             showDialog(getString(R.string.bluetooth_phonebook_access_dialog_title), mRequestType);
         } else if (mRequestType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
             showDialog(getString(R.string.bluetooth_message_access_dialog_title), mRequestType);
         } else if (mRequestType == BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
-            showDialog(getString(R.string.bluetooth_sap_request), mRequestType);
+            showDialog(getString(R.string.bluetooth_sim_card_access_dialog_title), mRequestType);
         }
         else {
             Log.e(TAG, "Error: bad request type: " + mRequestType);
@@ -133,9 +134,14 @@
             p.mView = createSapDialogView();
             break;
         }
-        p.mPositiveButtonText = getString(R.string.allow);
+        p.mPositiveButtonText = getString(
+                requestType == BluetoothDevice.REQUEST_TYPE_PROFILE_CONNECTION
+                        ? R.string.bluetooth_connect_access_dialog_positive : R.string.allow);
         p.mPositiveButtonListener = this;
-        p.mNegativeButtonText = getString(R.string.request_manage_bluetooth_permission_dont_allow);
+        p.mNegativeButtonText = getString(
+                requestType == BluetoothDevice.REQUEST_TYPE_PROFILE_CONNECTION
+                        ? R.string.bluetooth_connect_access_dialog_negative
+                        : R.string.request_manage_bluetooth_permission_dont_allow);
         p.mNegativeButtonListener = this;
         mOkButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE);
         setupAlert();
@@ -156,8 +162,8 @@
         String mRemoteName = Utils.createRemoteName(this, mDevice);
         mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null);
         messageView = (TextView)mView.findViewById(R.id.message);
-        messageView.setText(getString(R.string.bluetooth_connection_dialog_text,
-                mRemoteName));
+        messageView.setText(getString(R.string.bluetooth_connect_access_dialog_content,
+                mRemoteName, mRemoteName));
         return mView;
     }
 
@@ -181,10 +187,11 @@
 
     private View createSapDialogView() {
         String mRemoteName = Utils.createRemoteName(this, mDevice);
+        TelephonyManager tm = getSystemService(TelephonyManager.class);
         mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null);
         messageView = (TextView)mView.findViewById(R.id.message);
-        messageView.setText(getString(R.string.bluetooth_sap_acceptance_dialog_text,
-                mRemoteName, mRemoteName));
+        messageView.setText(getString(R.string.bluetooth_sim_card_access_dialog_content,
+                mRemoteName, mRemoteName, tm.getLine1Number()));
         return mView;
     }
 
diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
index 66665f0..ff1c147 100644
--- a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
@@ -144,13 +144,17 @@
                                 R.string.bluetooth_message_access_notification_content);
                         break;
                     case BluetoothDevice.REQUEST_TYPE_SIM_ACCESS:
-                        title = context.getString(R.string.bluetooth_sap_request);
-                        message = context.getString(R.string.bluetooth_sap_acceptance_dialog_text,
+                        title = context.getString(
+                                R.string.bluetooth_sim_card_access_notification_title);
+                        message = context.getString(
+                                R.string.bluetooth_sim_card_access_notification_content,
                                 deviceAlias, deviceAlias);
                         break;
                     default:
-                        title = context.getString(R.string.bluetooth_connection_permission_request);
-                        message = context.getString(R.string.bluetooth_connection_dialog_text,
+                        title = context.getString(
+                                R.string.bluetooth_connect_access_notification_title);
+                        message = context.getString(
+                                R.string.bluetooth_connect_access_notification_content,
                                 deviceAlias, deviceAlias);
                         break;
                 }
diff --git a/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceController.java
index 2ab0239..5d5a2a5 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceController.java
@@ -75,7 +75,7 @@
         mStorageAdapter.addAll(storageEntries);
 
         if (mSpinnerPreference != null) {
-            mSpinnerPreference.setClickable(mStorageAdapter.getCount() > 1);
+            mSpinnerPreference.setVisible(mStorageAdapter.getCount() > 1);
         }
     }
 
@@ -97,7 +97,7 @@
         mSpinnerPreference = screen.findPreference(getPreferenceKey());
         mSpinnerPreference.setAdapter(mStorageAdapter);
         mSpinnerPreference.setOnItemSelectedListener(this);
-        mSpinnerPreference.setClickable(mStorageAdapter.getCount() > 1);
+        mSpinnerPreference.setVisible(mStorageAdapter.getCount() > 1);
     }
 
     @Override
diff --git a/tests/unit/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceControllerTest.java b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceControllerTest.java
index 86351cb..f4661ef 100644
--- a/tests/unit/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceControllerTest.java
@@ -18,6 +18,8 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.mock;
+
 import android.content.Context;
 import android.os.Looper;
 import android.os.storage.StorageManager;
@@ -33,6 +35,7 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -47,9 +50,20 @@
 
     @Before
     public void setUp() throws Exception {
+        if (Looper.myLooper() == null) {
+            Looper.prepare();
+        }
         mContext = ApplicationProvider.getApplicationContext();
         mStorageManager = mContext.getSystemService(StorageManager.class);
         mController = new StorageSelectionPreferenceController(mContext, PREFERENCE_KEY);
+
+        final PreferenceManager preferenceManager = new PreferenceManager(mContext);
+        final PreferenceScreen preferenceScreen =
+                preferenceManager.createPreferenceScreen(mContext);
+        final SettingsSpinnerPreference spinnerPreference = new SettingsSpinnerPreference(mContext);
+        spinnerPreference.setKey(PREFERENCE_KEY);
+        preferenceScreen.addPreference(spinnerPreference);
+        mController.displayPreference(preferenceScreen);
     }
 
     @Test
@@ -70,16 +84,6 @@
 
     @Test
     public void setSelectedStorageEntry_primaryStorage_correctSelectedAdapterItem() {
-        if (Looper.myLooper() == null) {
-            Looper.prepare();
-        }
-        final PreferenceManager preferenceManager = new PreferenceManager(mContext);
-        final PreferenceScreen preferenceScreen =
-                preferenceManager.createPreferenceScreen(mContext);
-        final SettingsSpinnerPreference spinnerPreference = new SettingsSpinnerPreference(mContext);
-        spinnerPreference.setKey(PREFERENCE_KEY);
-        preferenceScreen.addPreference(spinnerPreference);
-        mController.displayPreference(preferenceScreen);
         final StorageEntry primaryStorageEntry =
                 StorageEntry.getDefaultInternalStorageEntry(mContext);
         mController.setStorageEntries(mStorageManager.getVolumes().stream()
@@ -91,5 +95,26 @@
         assertThat((StorageEntry) mController.mSpinnerPreference.getSelectedItem())
                 .isEqualTo(primaryStorageEntry);
     }
+
+    @Test
+    public void setStorageEntries_1StorageEntry_preferenceInvisible() {
+        final List<StorageEntry> storageEntries = new ArrayList<>();
+        storageEntries.add(mock(StorageEntry.class));
+
+        mController.setStorageEntries(storageEntries);
+
+        assertThat(mController.mSpinnerPreference.isVisible()).isFalse();
+    }
+
+    @Test
+    public void setStorageEntries_2StorageEntries_preferenceVisible() {
+        final List<StorageEntry> storageEntries = new ArrayList<>();
+        storageEntries.add(mock(StorageEntry.class));
+        storageEntries.add(mock(StorageEntry.class));
+
+        mController.setStorageEntries(storageEntries);
+
+        assertThat(mController.mSpinnerPreference.isVisible()).isTrue();
+    }
 }