Snap for 6508895 from 2f0290bdc6 to mainline-release

Change-Id: I7bfd28bb3d4bfd802e0de49b5c7b6b3f4935ba25
This commit is contained in:
android-build-team Robot
2020-05-19 07:05:41 +00:00
16 changed files with 110 additions and 229 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

@@ -1,31 +0,0 @@
<!--
~ Copyright (C) 2016 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
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="360dp"
android:height="184dp"
android:viewportWidth="360"
android:viewportHeight="184">
<path
android:fillColor="#E9F0F9"
android:pathData="M 0 0 H 360 V 184 H 0 V 0 Z" />
<path
android:fillColor="#444445"
android:pathData="M217.6,179h-75.1c-5,0-9-4-9-9V14c0-5,4-9,9-9h75.1c5,0,9,4,9,9V170C226.6,174.9,222.5,179,217.6,179z" />
<path
android:fillColor="#000000"
android:pathData="M 180 9.6 C 181.1045695 9.6 182 10.4954305003 182 11.6 C 182 12.7045694997 181.1045695 13.6 180 13.6 C 178.8954305 13.6 178 12.7045694997 178 11.6 C 178 10.4954305003 178.8954305 9.6 180 9.6 Z" />
</vector>

View File

@@ -1,40 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 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.
-->
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="true"
android:clipToPadding="true">
<ImageView
android:id="@+id/video_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/accessibility_screen_magnification_background"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:importantForAccessibility="noHideDescendants" />
<VideoView
android:id="@+id/video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/video_background"
android:layout_centerHorizontal="true"
android:importantForAccessibility="noHideDescendants" />
</RelativeLayout>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2020 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:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingTop="16dp"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
</LinearLayout>

View File

@@ -280,13 +280,6 @@
<dimen name="accessibility_layout_margin_start_end">16dp</dimen>
<dimen name="accessibility_button_preference_padding_top_bottom">18dp</dimen>
<!-- Accessibility, Screen magnification. These values are meant to be relative values and the actual layout value will be set programmatically. -->
<dimen name="screen_magnification_video_background_width">750dp</dimen>
<dimen name="screen_magnification_video_background_height">383dp</dimen>
<dimen name="screen_magnification_video_width">170dp</dimen>
<dimen name="screen_magnification_video_height">311dp</dimen>
<dimen name="screen_magnification_video_margin_top">40dp</dimen>
<!-- Restricted icon in switch bar -->
<dimen name="restricted_icon_margin_end">16dp</dimen>
<!-- Restricted icon size in switch bar -->

View File

@@ -41,16 +41,16 @@
android:title="@string/wifi_hotspot_auto_off_title"
android:summary="@string/wifi_hotspot_auto_off_summary"/>
<ListPreference
android:key="wifi_tether_network_ap_band_2"
android:title="@string/wifi_hotspot_ap_band_title"/>
<ListPreference
android:key="wifi_tether_security_2"
android:title="@string/wifi_security"
android:summary="@string/summary_placeholder"
android:entries="@array/wifi_tether_security"
android:entryValues="@array/wifi_tether_security_values"/>
<ListPreference
android:key="wifi_tether_network_ap_band_2"
android:title="@string/wifi_hotspot_ap_band_title"/>
</PreferenceCategory>
<PreferenceCategory

View File

@@ -37,12 +37,12 @@
android:persistent="false"
android:title="@string/wifi_hotspot_password_title"/>
<ListPreference
android:key="wifi_tether_network_ap_band"
android:title="@string/wifi_hotspot_ap_band_title"/>
<SwitchPreference
android:key="wifi_tether_auto_turn_off"
android:title="@string/wifi_hotspot_auto_off_title"
android:summary="@string/wifi_hotspot_auto_off_summary"/>
<ListPreference
android:key="wifi_tether_network_ap_band"
android:title="@string/wifi_hotspot_ap_band_title"/>
</PreferenceScreen>

View File

@@ -98,9 +98,9 @@ public class AllInOneTetherSettings extends RestrictedDashboardFragment
public static final String ETHERNET_TETHER_KEY = "enable_ethernet_tethering" + DEDUP_POSTFIX;
@VisibleForTesting
static final int EXPANDED_CHILD_COUNT_DEFAULT = 3;
static final int EXPANDED_CHILD_COUNT_DEFAULT = 4;
@VisibleForTesting
static final int EXPANDED_CHILD_COUNT_WITH_SECURITY_NON = 2;
static final int EXPANDED_CHILD_COUNT_WITH_SECURITY_NON = 3;
@VisibleForTesting
static final int EXPANDED_CHILD_COUNT_MAX = Integer.MAX_VALUE;
private static final String TAG = "AllInOneTetherSettings";

View File

@@ -28,6 +28,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.Drawable;
import android.icu.text.CaseMap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -61,6 +62,7 @@ import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.StringJoiner;
import java.util.stream.Collectors;
@@ -581,7 +583,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
}
if ((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE) {
final CharSequence hardwareTitle = context.getText(
R.string.accessibility_shortcut_edit_dialog_title_hardware);
R.string.accessibility_shortcut_hardware_keyword);
list.add(hardwareTitle);
}
@@ -590,7 +592,9 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
list.add(softwareTitle);
}
final String joinStrings = TextUtils.join(/* delimiter= */", ", list);
return AccessibilityUtil.capitalize(joinStrings);
return CaseMap.toTitle().wholeString().noLowercase().apply(Locale.getDefault(), /* iter= */
null, joinStrings);
}
protected int getUserShortcutTypes(Context context, @UserShortcutType int defaultValue) {

View File

@@ -25,10 +25,7 @@ import android.app.settings.SettingsEnums;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnPreparedListener;
import android.icu.text.CaseMap;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
@@ -36,18 +33,11 @@ import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityManager.TouchExplorationStateChangeListener;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.VideoView;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.PreferenceViewHolder;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
@@ -56,6 +46,7 @@ import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.StringJoiner;
import java.util.stream.Collectors;
@@ -81,83 +72,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
private static final char COMPONENT_NAME_SEPARATOR = ':';
private static final TextUtils.SimpleStringSplitter sStringColonSplitter =
new TextUtils.SimpleStringSplitter(COMPONENT_NAME_SEPARATOR);
protected VideoPreference mVideoPreference;
protected class VideoPreference extends Preference {
private ImageView mVideoBackgroundView;
private OnGlobalLayoutListener mLayoutListener;
public VideoPreference(Context context) {
super(context);
}
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
Resources res = getPrefContext().getResources();
final int backgroundAssetWidth = res.getDimensionPixelSize(
R.dimen.screen_magnification_video_background_width);
final int videoAssetWidth = res
.getDimensionPixelSize(R.dimen.screen_magnification_video_width);
final int videoAssetHeight = res
.getDimensionPixelSize(R.dimen.screen_magnification_video_height);
final int videoAssetMarginTop = res.getDimensionPixelSize(
R.dimen.screen_magnification_video_margin_top);
view.setDividerAllowedAbove(false);
view.setDividerAllowedBelow(false);
mVideoBackgroundView = (ImageView) view.findViewById(R.id.video_background);
final VideoView videoView = (VideoView) view.findViewById(R.id.video);
// Loop the video.
videoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.setLooping(true);
}
});
// Make sure the VideoView does not request audio focus.
videoView.setAudioFocusRequest(AudioManager.AUDIOFOCUS_NONE);
// Resolve and set the video content
Bundle args = getArguments();
if ((args != null) && args.containsKey(
AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID)) {
videoView.setVideoURI(Uri.parse(String.format("%s://%s/%s",
ContentResolver.SCHEME_ANDROID_RESOURCE,
getPrefContext().getPackageName(),
args.getInt(AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID))));
}
// Make sure video controls (e.g. for pausing) are not displayed.
videoView.setMediaController(null);
// LayoutListener for adjusting the position of the VideoView on the background image.
mLayoutListener = new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
final int backgroundViewWidth = mVideoBackgroundView.getWidth();
LayoutParams videoLp = (LayoutParams) videoView.getLayoutParams();
videoLp.width = videoAssetWidth * backgroundViewWidth / backgroundAssetWidth;
videoLp.height = videoAssetHeight * backgroundViewWidth / backgroundAssetWidth;
videoLp.setMargins(0,
videoAssetMarginTop * backgroundViewWidth / backgroundAssetWidth, 0, 0);
videoView.setLayoutParams(videoLp);
videoView.invalidate();
videoView.start();
}
};
mVideoBackgroundView.getViewTreeObserver().addOnGlobalLayoutListener(mLayoutListener);
}
@Override
protected void onPrepareForRemoval() {
mVideoBackgroundView.getViewTreeObserver()
.removeOnGlobalLayoutListener(mLayoutListener);
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -169,6 +83,10 @@ public class ToggleScreenMagnificationPreferenceFragment extends
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mPackageName = getString(R.string.accessibility_screen_magnification_title);
mImageUri = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
.authority(getPrefContext().getPackageName())
.appendPath(String.valueOf(R.drawable.accessibility_magnification_banner))
.build();
mTouchExplorationStateChangeListener = isTouchExplorationEnabled -> {
removeDialog(DialogEnums.EDIT_SHORTCUT);
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
@@ -178,13 +96,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
final PreferenceScreen preferenceScreen = getPreferenceScreen();
mVideoPreference = new VideoPreference(getPrefContext());
mVideoPreference.setSelectable(false);
mVideoPreference.setPersistent(false);
mVideoPreference.setLayoutResource(R.layout.magnification_video_preference);
preferenceScreen.addPreference(mVideoPreference);
initShortcutPreference();
super.onViewCreated(view, savedInstanceState);
@@ -204,11 +115,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
AccessibilityManager.class);
am.addTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
VideoView videoView = (VideoView) getView().findViewById(R.id.video);
if (videoView != null) {
videoView.start();
}
updateShortcutPreferenceData();
updateShortcutPreference();
}
@@ -348,13 +254,13 @@ public class ToggleScreenMagnificationPreferenceFragment extends
}
if ((shortcutType & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE) {
final CharSequence hardwareTitle = context.getText(
R.string.accessibility_shortcut_edit_dialog_title_hardware);
R.string.accessibility_shortcut_hardware_keyword);
list.add(hardwareTitle);
}
if ((shortcutType & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP) {
final CharSequence tripleTapTitle = context.getText(
R.string.accessibility_shortcut_edit_dialog_title_triple_tap);
R.string.accessibility_shortcut_triple_tap_keyword);
list.add(tripleTapTitle);
}
@@ -363,7 +269,9 @@ public class ToggleScreenMagnificationPreferenceFragment extends
list.add(softwareTitle);
}
final String joinStrings = TextUtils.join(/* delimiter= */", ", list);
return AccessibilityUtil.capitalize(joinStrings);
return CaseMap.toTitle().wholeString().noLowercase().apply(Locale.getDefault(), /* iter= */
null, joinStrings);
}
@Override
@@ -432,20 +340,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
mToggleServiceDividerSwitchPreference.setVisible(false);
}
@Override
protected void onProcessArguments(Bundle arguments) {
super.onProcessArguments(arguments);
if (arguments == null) {
return;
}
if (arguments.containsKey(AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID)) {
mVideoPreference.setVisible(true);
} else {
mVideoPreference.setVisible(false);
}
}
@Override
public void onToggleClicked(ShortcutPreference preference) {
final int shortcutTypes = getUserShortcutTypes(getPrefContext(), UserShortcutType.SOFTWARE);

View File

@@ -28,6 +28,7 @@ import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import com.android.settings.R;
import com.android.settingslib.bluetooth.A2dpProfile;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -48,6 +49,8 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
implements Preference.OnPreferenceClickListener,
LocalBluetoothProfileManager.ServiceListener {
private static final String KEY_PROFILES_GROUP = "bluetooth_profiles";
private static final String KEY_BOTTOM_PREFERENCE = "bottom_preference";
private static final int ORDINAL = 99;
@VisibleForTesting
static final String HIGH_QUALITY_AUDIO_PREF_TAG = "A2dpProfileHighQualityAudio";
@@ -55,7 +58,9 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
private LocalBluetoothManager mManager;
private LocalBluetoothProfileManager mProfileManager;
private CachedBluetoothDevice mCachedDevice;
private PreferenceCategory mProfilesContainer;
@VisibleForTesting
PreferenceCategory mProfilesContainer;
public BluetoothDetailsProfilesController(Context context, PreferenceFragmentCompat fragment,
LocalBluetoothManager manager, CachedBluetoothDevice device, Lifecycle lifecycle) {
@@ -69,6 +74,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
@Override
protected void init(PreferenceScreen screen) {
mProfilesContainer = (PreferenceCategory)screen.findPreference(getPreferenceKey());
mProfilesContainer.setLayoutResource(R.layout.preference_bluetooth_profile_category);
// Call refresh here even though it will get called later in onResume, to avoid the
// list of switches appearing to "pop" into the page.
refresh();
@@ -283,6 +289,16 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
mProfilesContainer.removePreference(pref);
}
}
Preference preference = mProfilesContainer.findPreference(KEY_BOTTOM_PREFERENCE);
if (preference == null) {
preference = new Preference(mContext);
preference.setLayoutResource(R.layout.preference_bluetooth_profile_category);
preference.setEnabled(false);
preference.setKey(KEY_BOTTOM_PREFERENCE);
preference.setOrder(ORDINAL);
mProfilesContainer.addPreference(preference);
}
}
@Override

View File

@@ -18,6 +18,8 @@ package com.android.settings.gestures;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.provider.Settings;
import android.view.WindowManager;
@@ -45,8 +47,7 @@ public class GestureNavigationSettingsFragment extends DashboardFragment {
private WindowManager mWindowManager;
private BackGestureIndicatorView mIndicatorView;
private static final float[] BACK_GESTURE_INSET_SCALES = {0.75f, 1.0f, 1.33f, 1.66f};
private float[] mBackGestureInsetScales;
private float mDefaultBackGestureInset;
public GestureNavigationSettingsFragment() {
@@ -59,15 +60,18 @@ public class GestureNavigationSettingsFragment extends DashboardFragment {
mIndicatorView = new BackGestureIndicatorView(getActivity());
mWindowManager = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
mDefaultBackGestureInset = getActivity().getResources().getDimensionPixelSize(
com.android.internal.R.dimen.config_backGestureInset);
}
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
super.onCreatePreferences(savedInstanceState, rootKey);
final Resources res = getActivity().getResources();
mDefaultBackGestureInset = res.getDimensionPixelSize(
com.android.internal.R.dimen.config_backGestureInset);
mBackGestureInsetScales = getFloatArray(res.obtainTypedArray(
com.android.internal.R.array.config_backGestureInsetScales));
initSeekBarPreference(LEFT_EDGE_SEEKBAR_KEY);
initSeekBarPreference(RIGHT_EDGE_SEEKBAR_KEY);
}
@@ -121,8 +125,8 @@ public class GestureNavigationSettingsFragment extends DashboardFragment {
// Find the closest value to initScale
float minDistance = Float.MAX_VALUE;
int minDistanceIndex = -1;
for (int i = 0; i < BACK_GESTURE_INSET_SCALES.length; i++) {
float d = Math.abs(BACK_GESTURE_INSET_SCALES[i] - initScale);
for (int i = 0; i < mBackGestureInsetScales.length; i++) {
float d = Math.abs(mBackGestureInsetScales[i] - initScale);
if (d < minDistance) {
minDistance = d;
minDistanceIndex = i;
@@ -131,19 +135,29 @@ public class GestureNavigationSettingsFragment extends DashboardFragment {
pref.setProgress(minDistanceIndex);
pref.setOnPreferenceChangeListener((p, v) -> {
final int width = (int) (mDefaultBackGestureInset * BACK_GESTURE_INSET_SCALES[(int) v]);
final int width = (int) (mDefaultBackGestureInset * mBackGestureInsetScales[(int) v]);
mIndicatorView.setIndicatorWidth(width, key == LEFT_EDGE_SEEKBAR_KEY);
return true;
});
pref.setOnPreferenceChangeStopListener((p, v) -> {
mIndicatorView.setIndicatorWidth(0, key == LEFT_EDGE_SEEKBAR_KEY);
final float scale = BACK_GESTURE_INSET_SCALES[(int) v];
final float scale = mBackGestureInsetScales[(int) v];
Settings.Secure.putFloat(getContext().getContentResolver(), settingsKey, scale);
return true;
});
}
private static float[] getFloatArray(TypedArray array) {
int length = array.length();
float[] floatArray = new float[length];
for (int i = 0; i < length; i++) {
floatArray[i] = array.getFloat(i, 1.0f);
}
array.recycle();
return floatArray;
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.gesture_navigation_settings) {

View File

@@ -54,8 +54,8 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
private static final String TAG = "WifiTetherSettings";
private static final IntentFilter TETHER_STATE_CHANGE_FILTER;
private static final String KEY_WIFI_TETHER_SCREEN = "wifi_tether_settings_screen";
private static final int EXPANDED_CHILD_COUNT_WITH_SECURITY_NON = 2;
private static final int EXPANDED_CHILD_COUNT_DEFAULT = 3;
private static final int EXPANDED_CHILD_COUNT_WITH_SECURITY_NON = 3;
private static final int EXPANDED_CHILD_COUNT_DEFAULT = 4;
@VisibleForTesting
static final String KEY_WIFI_TETHER_NETWORK_NAME = "wifi_tether_network_name";

View File

@@ -29,6 +29,7 @@ import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.SwitchPreference;
@@ -84,6 +85,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
mController = new BluetoothDetailsProfilesController(mContext, mFragment, mLocalManager,
mCachedDevice, mLifecycle);
mProfiles.setKey(mController.getPreferenceKey());
mController.mProfilesContainer = mProfiles;
mScreen.addPreference(mProfiles);
}
@@ -193,11 +195,14 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
private List<SwitchPreference> getProfileSwitches(boolean expectOnlyMConnectable) {
if (expectOnlyMConnectable) {
assertThat(mConnectableProfiles).isNotEmpty();
assertThat(mProfiles.getPreferenceCount()).isEqualTo(mConnectableProfiles.size());
assertThat(mProfiles.getPreferenceCount() - 1).isEqualTo(mConnectableProfiles.size());
}
List<SwitchPreference> result = new ArrayList<>();
for (int i = 0; i < mProfiles.getPreferenceCount(); i++) {
result.add((SwitchPreference)mProfiles.getPreference(i));
final Preference preference = mProfiles.getPreference(i);
if (preference instanceof SwitchPreference) {
result.add((SwitchPreference) preference);
}
}
return result;
}
@@ -236,7 +241,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
mController.onDeviceAttributesChanged();
// There should have been no new switches added.
assertThat(mProfiles.getPreferenceCount()).isEqualTo(2);
assertThat(mProfiles.getPreferenceCount()).isEqualTo(3);
// Make sure both switches got disabled.
assertThat(switches.get(0).isEnabled()).isFalse();
@@ -258,7 +263,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
assertThat(mConnectableProfiles.get(0).isEnabled(mDevice)).isFalse();
// Make sure no new preferences were added.
assertThat(mProfiles.getPreferenceCount()).isEqualTo(2);
assertThat(mProfiles.getPreferenceCount()).isEqualTo(3);
// Clicking the pref again should make the profile once again preferred.
pref.performClick();
@@ -266,7 +271,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
assertThat(mConnectableProfiles.get(0).isEnabled(mDevice)).isTrue();
// Make sure we still haven't gotten any new preferences added.
assertThat(mProfiles.getPreferenceCount()).isEqualTo(2);
assertThat(mProfiles.getPreferenceCount()).isEqualTo(3);
}
@Test
@@ -295,7 +300,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
assertThat(pref.isChecked()).isTrue();
pref.performClick();
assertThat(mProfiles.getPreferenceCount()).isEqualTo(1);
assertThat(mProfiles.getPreferenceCount()).isEqualTo(2);
assertThat(mDevice.getPhonebookAccessPermission())
.isEqualTo(BluetoothDevice.ACCESS_REJECTED);
}
@@ -318,7 +323,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
assertThat(pref.isChecked()).isFalse();
pref.performClick();
assertThat(mProfiles.getPreferenceCount()).isEqualTo(1);
assertThat(mProfiles.getPreferenceCount()).isEqualTo(2);
assertThat(mDevice.getPhonebookAccessPermission())
.isEqualTo(BluetoothDevice.ACCESS_ALLOWED);
}
@@ -340,7 +345,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
assertThat(pref.isChecked()).isFalse();
pref.performClick();
assertThat(mProfiles.getPreferenceCount()).isEqualTo(1);
assertThat(mProfiles.getPreferenceCount()).isEqualTo(2);
assertThat(mDevice.getMessageAccessPermission()).isEqualTo(BluetoothDevice.ACCESS_ALLOWED);
}
@@ -386,7 +391,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
setupDevice(makeDefaultDeviceConfig());
addMockA2dpProfile(true, false, false);
showScreen(mController);
assertThat(mProfiles.getPreferenceCount()).isEqualTo(1);
assertThat(mProfiles.getPreferenceCount()).isEqualTo(2);
SwitchPreference pref = (SwitchPreference) mProfiles.getPreference(0);
assertThat(pref.getKey())
.isNotEqualTo(BluetoothDetailsProfilesController.HIGH_QUALITY_AUDIO_PREF_TAG);
@@ -408,7 +413,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
setupDevice(makeDefaultDeviceConfig());
A2dpProfile audioProfile = addMockA2dpProfile(true, true, true);
showScreen(mController);
assertThat(mProfiles.getPreferenceCount()).isEqualTo(2);
assertThat(mProfiles.getPreferenceCount()).isEqualTo(3);
// Disabling media audio should cause the high quality audio switch to disappear, but not
// the regular audio one.