Merge "Update strings for Vibration" into qt-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 9dd4732..ef8e761 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1333,22 +1333,23 @@
</activity-alias>
<activity android:name=".applications.specialaccess.deviceadmin.DeviceAdminAdd"
- android:label="@string/device_admin_add_title"
- android:clearTaskOnLaunch="true">
+ android:label="@string/device_admin_add_title"
+ android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.app.action.ADD_DEVICE_ADMIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
- <activity-alias android:name="SetProfileOwner"
- android:label="@string/profile_owner_add_title"
- android:targetActivity=".applications.specialaccess.deviceadmin.DeviceAdminAdd">
+ <activity android:name=".applications.specialaccess.deviceadmin.ProfileOwnerAdd"
+ android:excludeFromRecents="true"
+ android:theme="@style/Transparent"
+ android:clearTaskOnLaunch="true">
<intent-filter android:priority="1000">
<action android:name="android.app.action.SET_PROFILE_OWNER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
- </activity-alias>
+ </activity>
<activity
android:name="Settings$UsageAccessSettingsActivity"
diff --git a/res/layout/profile_owner_add.xml b/res/layout/profile_owner_add.xml
new file mode 100644
index 0000000..84c51fd
--- /dev/null
+++ b/res/layout/profile_owner_add.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/active_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TextView android:id="@+id/add_msg_simplified"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:scrollbars = "vertical"
+ android:padding="?dialogPreferredPadding"
+ android:gravity="center_vertical"/>
+
+ <TextView android:id="@+id/admin_warning_simplified"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingStart="?dialogPreferredPadding"
+ android:paddingEnd="?dialogPreferredPadding"/>
+</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d69ee56..4cb495d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1052,17 +1052,17 @@
<!-- Content of the dialog shown when the user tries to skip fingerprint setup, asking them to confirm the action [CHAR LIMIT=NONE] -->
<string name="setup_fingerprint_enroll_enrolling_skip_message">You\u2019ve chosen to use your fingerprint as one way to unlock your phone. If you skip now, you\u2019ll need to set this up later. Setup takes only a minute or so.</string>
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set fingerprint. (tablet) [CHAR LIMIT=NONE] -->
- <string name="fingerprint_lock_screen_setup_skip_dialog_text" product="tablet">Protect your tablet with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+ <string name="fingerprint_lock_screen_setup_skip_dialog_text" product="tablet">Protect your tablet with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN, pattern, or password.</string>
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set fingerprint. (device) [CHAR LIMIT=NONE] -->
- <string name="fingerprint_lock_screen_setup_skip_dialog_text" product="device">Protect your device with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+ <string name="fingerprint_lock_screen_setup_skip_dialog_text" product="device">Protect your device with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN, pattern, or password.</string>
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set fingerprint. (default) [CHAR LIMIT=NONE] -->
- <string name="fingerprint_lock_screen_setup_skip_dialog_text" product="default">Protect your phone with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+ <string name="fingerprint_lock_screen_setup_skip_dialog_text" product="default">Protect your phone with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN, pattern, or password.</string>
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face authentication. (tablet) [CHAR LIMIT=NONE] -->
- <string name="face_lock_screen_setup_skip_dialog_text" product="tablet">Protect your tablet with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+ <string name="face_lock_screen_setup_skip_dialog_text" product="tablet">Protect your tablet with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN, pattern, or password.</string>
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face authentication. (device) [CHAR LIMIT=NONE] -->
- <string name="face_lock_screen_setup_skip_dialog_text" product="device">Protect your device with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+ <string name="face_lock_screen_setup_skip_dialog_text" product="device">Protect your device with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN, pattern, or password.</string>
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face authentication. (default) [CHAR LIMIT=NONE] -->
- <string name="face_lock_screen_setup_skip_dialog_text" product="default">Protect your phone with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+ <string name="face_lock_screen_setup_skip_dialog_text" product="default">Protect your phone with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN, pattern, or password.</string>
<!-- Title of dialog shown when the user tries to skip setting up a PIN, warning them of potential consequences of not doing so [CHAR LIMIT=48]-->
<string name="lock_screen_pin_skip_title">Skip PIN setup?</string>
<!-- Title of dialog shown when the user tries to skip setting up a password, warning them of potential consequences of not doing so [CHAR LIMIT=48]-->
@@ -1786,6 +1786,9 @@
<!-- Bluetooth device details. The body of a confirmation dialog for unpairing a paired device. -->
<string name="bluetooth_unpair_dialog_body" product="device">Your device will no longer be paired with <xliff:g id="device_name">%1$s</xliff:g></string>
+ <!-- Bluetooth device details. The body of a confirmation dialog for unpairing a paired device. [CHAR LIMIT=NONE] -->
+ <string name="bluetooth_untethered_unpair_dialog_body"><xliff:g id="device_name" example="Jack's headphone">%1$s</xliff:g> will no longer be paired with any device linked to this account</string>
+
<!-- Bluetooth device details. In the confirmation dialog for unpairing a paired device, this is the label on the button that will complete the unpairing action. -->
<string name="bluetooth_unpair_dialog_forget_confirm_button">Forget device</string>
@@ -2888,6 +2891,10 @@
<string name="wallpaper_suggestion_summary">Personalize your screen</string>
<!-- Wallpaper settings fragment title [CHAR LIMIT=30] -->
<string name="wallpaper_settings_fragment_title">Choose wallpaper from</string>
+ <!-- Styles and Wallpaper settings title [CHAR_LIMIT=46] -->
+ <string name="style_suggestion_title">Customize your Pixel</string>
+ <!-- Styles and Wallpapers summary [CHAR_LIMIT=55] -->
+ <string name="style_suggestion_summary">Try different styles, wallpapers, clocks, and more</string>
<!-- Display settings screen, trigger for screen saver options -->
<string name="screensaver_settings_title">Screen saver</string>
<!-- Display settings screen, summary fragment for screen saver options, activated when docked or asleep and charging -->
@@ -6019,6 +6026,9 @@
<string name="device_admin_warning">Activating this admin app will allow
the app <xliff:g id="app_name">%1$s</xliff:g> to perform the
following operations:</string>
+ <!-- Simplified device admin warning message [CHAR LIMIT=NONE]-->
+ <string name="device_admin_warning_simplified">This device will be managed and monitored by
+ <xliff:g id="app_name" example="Example Supervisor">%1$s</xliff:g>.</string>
<!-- Device admin warning message about policies an admin can use -->
<string name="device_admin_status">This admin app is active and allows
the app <xliff:g id="app_name">%1$s</xliff:g> to perform the
@@ -6026,6 +6036,8 @@
<!-- Title for screen to set a profile owner [CHAR LIMIT=40] -->
<string name="profile_owner_add_title">Activate Profile Manager?</string>
+ <!-- Simplified title for dialog to set a profile owner [CHAR LIMIT=40] -->
+ <string name="profile_owner_add_title_simplified">Allow supervision?</string>
<!-- Warning when trying to add a profile owner admin after setup has completed. [CHAR LIMIT=none] -->
<string name="adding_profile_owner_warning">By proceeding, your user will be managed by your
admin which may also be able to store associated data, in addition to your personal
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
index 7e0ca24..0d0bd20 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
@@ -46,6 +46,7 @@
import android.os.UserManager;
import android.text.TextUtils;
import android.text.TextUtils.TruncateAt;
+import android.text.method.ScrollingMovementMethod;
import android.util.EventLog;
import android.util.Log;
import android.view.Display;
@@ -273,15 +274,63 @@
}
}
- // If we're trying to add a profile owner and user setup hasn't completed yet, no
- // need to prompt for permission. Just add and finish.
- if (mAddingProfileOwner && !mDPM.hasUserSetupCompleted()) {
- addAndFinish();
- return;
- }
-
mAddMsgText = getIntent().getCharSequenceExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION);
+ if (mAddingProfileOwner) {
+ // If we're trying to add a profile owner and user setup hasn't completed yet, no
+ // need to prompt for permission. Just add and finish
+ if (!mDPM.hasUserSetupCompleted()) {
+ addAndFinish();
+ return;
+ }
+
+ // othewise, only the defined default supervision profile owner can be set after user
+ // setup.
+ final String supervisor = getString(
+ com.android.internal.R.string.config_defaultSupervisionProfileOwnerComponent);
+ if (supervisor == null) {
+ Log.w(TAG, "Unable to set profile owner post-setup, no default supervisor"
+ + "profile owner defined");
+ finish();
+ return;
+ }
+
+ final ComponentName supervisorComponent = ComponentName.unflattenFromString(
+ supervisor);
+ if (who.compareTo(supervisorComponent) != 0) {
+ Log.w(TAG, "Unable to set non-default profile owner post-setup " + who);
+ finish();
+ return;
+ }
+
+ // Build and show the simplified dialog
+ final Dialog dialog = new AlertDialog.Builder(this)
+ .setTitle(getText(R.string.profile_owner_add_title_simplified))
+ .setView(R.layout.profile_owner_add)
+ .setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ addAndFinish();
+ }
+ })
+ .setNeutralButton(R.string.cancel, null)
+ .setOnDismissListener(new DialogInterface.OnDismissListener() {
+ public void onDismiss(DialogInterface dialogInterface) {
+ finish();
+ }
+ })
+ .create();
+ dialog.show();
+
+ mActionButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE);
+ mActionButton.setFilterTouchesWhenObscured(true);
+ mAddMsg = dialog.findViewById(R.id.add_msg_simplified);
+ mAddMsg.setMovementMethod(new ScrollingMovementMethod());
+ mAddMsg.setText(mAddMsgText);
+ mAdminWarning = dialog.findViewById(R.id.admin_warning_simplified);
+ mAdminWarning.setText(getString(R.string.device_admin_warning_simplified,
+ mProfileOwnerName));
+ return;
+ }
setContentView(R.layout.device_admin_add);
mAdminIcon = (ImageView)findViewById(R.id.admin_icon);
@@ -501,7 +550,9 @@
protected void onResume() {
super.onResume();
mActionButton.setEnabled(true);
- updateInterface();
+ if (!mAddingProfileOwner) {
+ updateInterface();
+ }
// As long as we are running, don't let anyone overlay stuff on top of the screen.
mAppOps.setUserRestriction(AppOpsManager.OP_SYSTEM_ALERT_WINDOW, true, mToken);
mAppOps.setUserRestriction(AppOpsManager.OP_TOAST_WINDOW, true, mToken);
@@ -571,9 +622,6 @@
} catch (Resources.NotFoundException e) {
mAdminDescription.setVisibility(View.GONE);
}
- if (mAddingProfileOwner) {
- mProfileOwnerWarning.setVisibility(View.VISIBLE);
- }
if (mAddMsgText != null) {
mAddMsg.setText(mAddMsgText);
mAddMsg.setVisibility(View.VISIBLE);
@@ -634,11 +682,7 @@
addDeviceAdminPolicies(true /* showDescription */);
mAdminWarning.setText(getString(R.string.device_admin_warning,
mDeviceAdmin.getActivityInfo().applicationInfo.loadLabel(getPackageManager())));
- if (mAddingProfileOwner) {
- setTitle(getText(R.string.profile_owner_add_title));
- } else {
- setTitle(getText(R.string.add_device_admin_msg));
- }
+ setTitle(getText(R.string.add_device_admin_msg));
mActionButton.setText(getText(R.string.add_device_admin));
if (isAdminUninstallable()) {
mUninstallButton.setVisibility(View.VISIBLE);
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/ProfileOwnerAdd.java b/src/com/android/settings/applications/specialaccess/deviceadmin/ProfileOwnerAdd.java
new file mode 100644
index 0000000..6841ea4
--- /dev/null
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/ProfileOwnerAdd.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.applications.specialaccess.deviceadmin;
+
+import android.os.Bundle;
+
+/**
+ * ProfileOwnerAdd uses the DeviceAdminAdd logic to handle SET_PROFILE_OWNER intents
+ *
+ * TODO(b/131713071): Move profile owner add logic from DeviceAdminAdd to here
+ */
+public class ProfileOwnerAdd extends DeviceAdminAdd {
+ @Override
+ protected void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ }
+}
diff --git a/src/com/android/settings/bluetooth/ForgetDeviceDialogFragment.java b/src/com/android/settings/bluetooth/ForgetDeviceDialogFragment.java
index db6b832..6d8fb33 100644
--- a/src/com/android/settings/bluetooth/ForgetDeviceDialogFragment.java
+++ b/src/com/android/settings/bluetooth/ForgetDeviceDialogFragment.java
@@ -29,6 +29,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -72,13 +73,18 @@
};
Context context = getContext();
mDevice = getDevice(context);
+ final boolean untetheredHeadset = BluetoothUtils.getBooleanMetaData(
+ mDevice.getDevice(), BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET);
+
AlertDialog dialog = new AlertDialog.Builder(context)
.setPositiveButton(R.string.bluetooth_unpair_dialog_forget_confirm_button,
onConfirm)
.setNegativeButton(android.R.string.cancel, null)
.create();
dialog.setTitle(R.string.bluetooth_unpair_dialog_title);
- dialog.setMessage(context.getString(R.string.bluetooth_unpair_dialog_body,
+ dialog.setMessage(context.getString(untetheredHeadset
+ ? R.string.bluetooth_untethered_unpair_dialog_body
+ : R.string.bluetooth_unpair_dialog_body,
mDevice.getName()));
return dialog;
}
diff --git a/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceController.java b/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceController.java
index 11ff094..337ad2e 100644
--- a/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceController.java
+++ b/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceController.java
@@ -43,11 +43,6 @@
}
@Override
- public boolean isSliceable() {
- return TextUtils.equals(PREF_KEY_EDGE_TO_EDGE, getPreferenceKey());
- }
-
- @Override
public void onRadioButtonClicked(RadioButtonPreference preference) {
setNavBarInteractionMode(mOverlayManager, NAV_BAR_MODE_GESTURAL_OVERLAY);
selectRadioButtonInGroup(PREF_KEY_EDGE_TO_EDGE, mPreferenceScreen);
diff --git a/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceController.java b/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceController.java
index 0b19784..728c5df 100644
--- a/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceController.java
+++ b/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceController.java
@@ -43,11 +43,6 @@
}
@Override
- public boolean isSliceable() {
- return TextUtils.equals(PREF_KEY_LEGACY, getPreferenceKey());
- }
-
- @Override
public void onRadioButtonClicked(RadioButtonPreference preference) {
setNavBarInteractionMode(mOverlayManager, NAV_BAR_MODE_3BUTTON_OVERLAY);
selectRadioButtonInGroup(PREF_KEY_LEGACY, mPreferenceScreen);
diff --git a/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceController.java b/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceController.java
index 26c2201..cf2886f 100644
--- a/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceController.java
+++ b/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceController.java
@@ -43,11 +43,6 @@
}
@Override
- public boolean isSliceable() {
- return TextUtils.equals(PREF_KEY_SWIPE_UP, getPreferenceKey());
- }
-
- @Override
public void onRadioButtonClicked(RadioButtonPreference preference) {
setNavBarInteractionMode(mOverlayManager, NAV_BAR_MODE_2BUTTON_OVERLAY);
selectRadioButtonInGroup(PREF_KEY_SWIPE_UP, mPreferenceScreen);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/ForgetDeviceDialogFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/ForgetDeviceDialogFragmentTest.java
index 44ffa54..b4f4f97 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/ForgetDeviceDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/ForgetDeviceDialogFragmentTest.java
@@ -25,10 +25,15 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.bluetooth.BluetoothDevice;
+import android.content.Context;
+
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
+import com.android.settings.R;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import org.junit.Before;
@@ -39,33 +44,46 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowDialog;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowAlertDialogCompat.class})
public class ForgetDeviceDialogFragmentTest {
+ private static final String DEVICE_NAME = "Nightshade";
+
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private CachedBluetoothDevice mCachedDevice;
+ @Mock
+ private BluetoothDevice mBluetoothDevice;
private ForgetDeviceDialogFragment mFragment;
private FragmentActivity mActivity;
private AlertDialog mDialog;
+ private Context mContext;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+
+ mContext = RuntimeEnvironment.application;
FakeFeatureFactory.setupForTest();
String deviceAddress = "55:66:77:88:99:AA";
when(mCachedDevice.getAddress()).thenReturn(deviceAddress);
+ when(mCachedDevice.getDevice()).thenReturn(mBluetoothDevice);
+ when(mCachedDevice.getName()).thenReturn(DEVICE_NAME);
mFragment = spy(ForgetDeviceDialogFragment.newInstance(deviceAddress));
doReturn(mCachedDevice).when(mFragment).getDevice(any());
mActivity = Robolectric.setupActivity(FragmentActivity.class);
- mActivity.getSupportFragmentManager().beginTransaction().add(mFragment, null).commit();
- mDialog = (AlertDialog) ShadowDialog.getLatestDialog();
}
@Test
public void cancelDialog() {
+ initDialog();
+
mDialog.getButton(AlertDialog.BUTTON_NEGATIVE).performClick();
verify(mCachedDevice, never()).unpair();
assertThat(mActivity.isFinishing()).isFalse();
@@ -73,8 +91,43 @@
@Test
public void confirmDialog() {
+ initDialog();
+
mDialog.getButton(AlertDialog.BUTTON_POSITIVE).performClick();
verify(mCachedDevice).unpair();
assertThat(mActivity.isFinishing()).isTrue();
}
+
+ @Test
+ public void createDialog_untetheredDevice_showUntetheredMessage() {
+ when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
+ .thenReturn("true".getBytes());
+
+ FragmentController.setupFragment(mFragment, FragmentActivity.class,
+ 0 /* containerViewId */, null /* bundle */);
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
+
+ assertThat(shadowDialog.getMessage()).isEqualTo(
+ mContext.getString(R.string.bluetooth_untethered_unpair_dialog_body, DEVICE_NAME));
+ }
+
+ @Test
+ public void createDialog_normalDevice_showNormalMessage() {
+ when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
+ .thenReturn("false".getBytes());
+
+ FragmentController.setupFragment(mFragment, FragmentActivity.class,
+ 0 /* containerViewId */, null /* bundle */);
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
+
+ assertThat(shadowDialog.getMessage()).isEqualTo(
+ mContext.getString(R.string.bluetooth_unpair_dialog_body, DEVICE_NAME));
+ }
+
+ private void initDialog() {
+ mActivity.getSupportFragmentManager().beginTransaction().add(mFragment, null).commit();
+ mDialog = (AlertDialog) ShadowDialog.getLatestDialog();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceControllerTest.java
index 740ff2c..a23f8da 100644
--- a/tests/robotests/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceControllerTest.java
@@ -180,8 +180,8 @@
}
@Test
- public void isSliceableCorrectKey_returnsTrue() {
- assertThat(mController.isSliceable()).isTrue();
+ public void isSliceable_returnsFalse() {
+ assertThat(mController.isSliceable()).isFalse();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceControllerTest.java
index 2c4f88a..dc9e3d9 100644
--- a/tests/robotests/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceControllerTest.java
@@ -182,8 +182,8 @@
}
@Test
- public void isSliceableCorrectKey_returnsTrue() {
- assertThat(mController.isSliceable()).isTrue();
+ public void isSliceable_returnsFalse() {
+ assertThat(mController.isSliceable()).isFalse();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceControllerTest.java
index 177d498..955ea0c 100644
--- a/tests/robotests/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceControllerTest.java
@@ -180,8 +180,8 @@
}
@Test
- public void isSliceableCorrectKey_returnsTrue() {
- assertThat(mController.isSliceable()).isTrue();
+ public void isSliceable_returnsFalse() {
+ assertThat(mController.isSliceable()).isFalse();
}
@Test