Snap for 8146528 from 93da780888 to tm-release
Change-Id: I27d797095cbee7b3d323d4a9dfedb46e3d68a110
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
package="com.android.settings"
|
||||||
package="com.android.settings"
|
coreApp="true"
|
||||||
coreApp="true"
|
android:sharedUserId="android.uid.system">
|
||||||
android:sharedUserId="android.uid.system">
|
|
||||||
|
|
||||||
<original-package android:name="com.android.settings" />
|
<original-package android:name="com.android.settings"/>
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.REQUEST_NETWORK_SCORES" />
|
<uses-permission android:name="android.permission.REQUEST_NETWORK_SCORES" />
|
||||||
<uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" />
|
||||||
@@ -2921,6 +2920,24 @@
|
|||||||
android:value="true" />
|
android:value="true" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".dream.DreamSetupActivity"
|
||||||
|
android:exported="true"
|
||||||
|
android:immersive="true"
|
||||||
|
android:theme="@style/SudThemeGlif.DayNight"
|
||||||
|
android:icon="@drawable/ic_settings_display">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
<category android:name="com.android.settings.suggested.category.SCREEN_SAVER"/>
|
||||||
|
</intent-filter>
|
||||||
|
<meta-data android:name="com.android.settings.is_supported"
|
||||||
|
android:resource="@bool/dream_setup_supported"/>
|
||||||
|
<meta-data android:name="com.android.settings.title"
|
||||||
|
android:resource="@string/dream_setup_title"/>
|
||||||
|
<meta-data android:name="com.android.settings.summary"
|
||||||
|
android:resource="@string/dream_setup_description"/>
|
||||||
|
<meta-data android:name="com.android.settings.icon_tintable" android:value="true"/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="Settings$UserSettingsActivity"
|
android:name="Settings$UserSettingsActivity"
|
||||||
android:label="@string/user_settings_title"
|
android:label="@string/user_settings_title"
|
||||||
|
|||||||
@@ -17,6 +17,6 @@
|
|||||||
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
||||||
<item android:state_activated="true" android:color="?androidprv:attr/colorSurfaceVariant"/>
|
<item android:state_selected="true" android:color="?androidprv:attr/colorSurfaceVariant"/>
|
||||||
<item android:color="?androidprv:attr/colorSurfaceHighlight"/>
|
<item android:color="?androidprv:attr/colorSurfaceHighlight"/>
|
||||||
</selector>
|
</selector>
|
||||||
@@ -15,12 +15,18 @@
|
|||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:orientation="vertical">
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/createSupervisedUser"
|
android:id="@+id/createSupervisedUser"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:text="@*android:string/supervised_user_creation_label" />
|
android:text="@*android:string/supervised_user_creation_label" />
|
||||||
</FrameLayout>
|
<TextView
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:text="@string/placeholder_activity" />
|
||||||
|
</LinearLayout>
|
||||||
39
res/layout/dream_setup_layout.xml
Normal file
39
res/layout/dream_setup_layout.xml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (C) 2022 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<com.google.android.setupdesign.GlifLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/setup_wizard_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:icon="@drawable/ic_settings_display"
|
||||||
|
app:sucHeaderText="@string/dream_setup_title"
|
||||||
|
app:sudDescriptionText="@string/dream_setup_description">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/dream_container"
|
||||||
|
style="@style/SudContentFrame"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/dream_setup_list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</com.google.android.setupdesign.GlifLayout>
|
||||||
@@ -590,4 +590,7 @@
|
|||||||
Take the "Unrestricted data" page as the example, the visible app icons could be 15
|
Take the "Unrestricted data" page as the example, the visible app icons could be 15
|
||||||
on 6.4 inches screen size whether the font size and display size are both small. -->
|
on 6.4 inches screen size whether the font size and display size are both small. -->
|
||||||
<integer name="config_num_visible_app_icons">20</integer>
|
<integer name="config_num_visible_app_icons">20</integer>
|
||||||
|
|
||||||
|
<!-- Whether the dream setup activity should be enabled as part of setupwizard -->
|
||||||
|
<bool name="dream_setup_supported">false</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -5846,6 +5846,8 @@
|
|||||||
<string name="fast_pair_settings_summary">Nearby detection of Fast Pair bluetooth devices.</string>
|
<string name="fast_pair_settings_summary">Nearby detection of Fast Pair bluetooth devices.</string>
|
||||||
<!-- Title for Fast Pair main switch preferences. [CHAR LIMIT=50] -->
|
<!-- Title for Fast Pair main switch preferences. [CHAR LIMIT=50] -->
|
||||||
<string name="fast_pair_main_switch_title">Scan for nearby devices</string>
|
<string name="fast_pair_main_switch_title">Scan for nearby devices</string>
|
||||||
|
<!-- Title for Fast Pair saved devices preferences. [CHAR LIMIT=50] -->
|
||||||
|
<string name="fast_pair_saved_devices_title">Saved devices</string>
|
||||||
<!-- Printing settings -->
|
<!-- Printing settings -->
|
||||||
<skip />
|
<skip />
|
||||||
|
|
||||||
@@ -13850,6 +13852,10 @@
|
|||||||
<string name="dream_complications_picker_category">Choose more options</string>
|
<string name="dream_complications_picker_category">Choose more options</string>
|
||||||
<!-- The title of the category to show for the screensaver miscellaneous settings [CHAR LIMIT=none] -->
|
<!-- The title of the category to show for the screensaver miscellaneous settings [CHAR LIMIT=none] -->
|
||||||
<string name="dream_more_settings_category">More settings</string>
|
<string name="dream_more_settings_category">More settings</string>
|
||||||
|
<!-- The title of the screen saver setup page [CHAR LIMIT=none] -->
|
||||||
|
<string name="dream_setup_title">Customize your screen saver</string>
|
||||||
|
<!-- The description of the screen saver setup page [CHAR LIMIT=none] -->
|
||||||
|
<string name="dream_setup_description">Choose what you’ll see on your screen when your device is not in use.</string>
|
||||||
|
|
||||||
<!-- Button to customize the screensaver [CHAR LIMIT=20] -->
|
<!-- Button to customize the screensaver [CHAR LIMIT=20] -->
|
||||||
<string name="customize_button_title">Customize</string>
|
<string name="customize_button_title">Customize</string>
|
||||||
@@ -13866,4 +13872,7 @@
|
|||||||
<string name="reboot_dialog_reboot_now">Reboot now</string>
|
<string name="reboot_dialog_reboot_now">Reboot now</string>
|
||||||
<!-- Text on the dialog button to reboot the device later [CHAR LIMIT=50] -->
|
<!-- Text on the dialog button to reboot the device later [CHAR LIMIT=50] -->
|
||||||
<string name="reboot_dialog_reboot_later">Reboot later</string>
|
<string name="reboot_dialog_reboot_later">Reboot later</string>
|
||||||
|
|
||||||
|
<!-- Text to explain an activity is a temporary placeholder [CHAR LIMIT=none] -->
|
||||||
|
<string name="placeholder_activity" translatable="false">*This is a temporary placeholder fallback activity.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -25,4 +25,8 @@
|
|||||||
android:key="fast_pair_scan_switch"
|
android:key="fast_pair_scan_switch"
|
||||||
android:title="@string/fast_pair_main_switch_title" />
|
android:title="@string/fast_pair_main_switch_title" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="saved_devices"
|
||||||
|
android:title="@string/fast_pair_saved_devices_title" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|||||||
@@ -17,9 +17,12 @@
|
|||||||
package com.android.settings.development;
|
package com.android.settings.development;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothA2dp;
|
import android.bluetooth.BluetoothA2dp;
|
||||||
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothCodecConfig;
|
import android.bluetooth.BluetoothCodecConfig;
|
||||||
import android.bluetooth.BluetoothCodecStatus;
|
import android.bluetooth.BluetoothCodecStatus;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
import android.bluetooth.BluetoothManager;
|
||||||
|
import android.bluetooth.BluetoothProfile;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -34,6 +37,8 @@ import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
|||||||
import com.android.settingslib.core.lifecycle.events.OnDestroy;
|
import com.android.settingslib.core.lifecycle.events.OnDestroy;
|
||||||
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
|
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class AbstractBluetoothA2dpPreferenceController extends
|
public abstract class AbstractBluetoothA2dpPreferenceController extends
|
||||||
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
|
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
|
||||||
PreferenceControllerMixin, BluetoothServiceConnectionListener, LifecycleObserver,
|
PreferenceControllerMixin, BluetoothServiceConnectionListener, LifecycleObserver,
|
||||||
@@ -48,11 +53,15 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends
|
|||||||
private final String[] mListValues;
|
private final String[] mListValues;
|
||||||
private final String[] mListSummaries;
|
private final String[] mListSummaries;
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
BluetoothAdapter mBluetoothAdapter;
|
||||||
|
|
||||||
public AbstractBluetoothA2dpPreferenceController(Context context, Lifecycle lifecycle,
|
public AbstractBluetoothA2dpPreferenceController(Context context, Lifecycle lifecycle,
|
||||||
BluetoothA2dpConfigStore store) {
|
BluetoothA2dpConfigStore store) {
|
||||||
super(context);
|
super(context);
|
||||||
|
|
||||||
mBluetoothA2dpConfigStore = store;
|
mBluetoothA2dpConfigStore = store;
|
||||||
|
mBluetoothAdapter = context.getSystemService(BluetoothManager.class).getAdapter();
|
||||||
mListValues = getListValues();
|
mListValues = getListValues();
|
||||||
mListSummaries = getListSummaries();
|
mListSummaries = getListSummaries();
|
||||||
|
|
||||||
@@ -82,13 +91,11 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends
|
|||||||
|
|
||||||
final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig();
|
final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig();
|
||||||
synchronized (mBluetoothA2dpConfigStore) {
|
synchronized (mBluetoothA2dpConfigStore) {
|
||||||
if (mBluetoothA2dp != null) {
|
BluetoothDevice activeDevice = getA2dpActiveDevice();
|
||||||
BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice();
|
if (activeDevice == null) {
|
||||||
if (activeDevice == null) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
setCodecConfigPreference(activeDevice, codecConfig);
|
|
||||||
}
|
}
|
||||||
|
setCodecConfigPreference(activeDevice, codecConfig);
|
||||||
}
|
}
|
||||||
// Because the setting is not persisted into permanent storage, we cannot call update state
|
// Because the setting is not persisted into permanent storage, we cannot call update state
|
||||||
// here to update the preference.
|
// here to update the preference.
|
||||||
@@ -106,7 +113,7 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice();
|
BluetoothDevice activeDevice = getA2dpActiveDevice();
|
||||||
if (activeDevice == null || getCodecConfig(activeDevice) == null || mPreference == null) {
|
if (activeDevice == null || getCodecConfig(activeDevice) == null || mPreference == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -184,7 +191,7 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends
|
|||||||
void setCodecConfigPreference(BluetoothDevice device,
|
void setCodecConfigPreference(BluetoothDevice device,
|
||||||
BluetoothCodecConfig config) {
|
BluetoothCodecConfig config) {
|
||||||
BluetoothDevice bluetoothDevice =
|
BluetoothDevice bluetoothDevice =
|
||||||
(device != null) ? device : mBluetoothA2dp.getActiveDevice();
|
(device != null) ? device : getA2dpActiveDevice();
|
||||||
if (bluetoothDevice == null) {
|
if (bluetoothDevice == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -195,7 +202,7 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends
|
|||||||
BluetoothCodecConfig getCodecConfig(BluetoothDevice device) {
|
BluetoothCodecConfig getCodecConfig(BluetoothDevice device) {
|
||||||
if (mBluetoothA2dp != null) {
|
if (mBluetoothA2dp != null) {
|
||||||
BluetoothDevice bluetoothDevice =
|
BluetoothDevice bluetoothDevice =
|
||||||
(device != null) ? device : mBluetoothA2dp.getActiveDevice();
|
(device != null) ? device : getA2dpActiveDevice();
|
||||||
if (bluetoothDevice == null) {
|
if (bluetoothDevice == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -206,4 +213,13 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BluetoothDevice getA2dpActiveDevice() {
|
||||||
|
if (mBluetoothAdapter == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<BluetoothDevice> activeDevices =
|
||||||
|
mBluetoothAdapter.getActiveDevices(BluetoothProfile.A2DP);
|
||||||
|
return (activeDevices.size() > 0) ? activeDevices.get(0) : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
|
|||||||
}
|
}
|
||||||
writeConfigurationValues(index);
|
writeConfigurationValues(index);
|
||||||
final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig();
|
final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig();
|
||||||
BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice();
|
BluetoothDevice activeDevice = getA2dpActiveDevice();
|
||||||
if (activeDevice != null) {
|
if (activeDevice != null) {
|
||||||
bluetoothA2dp.setCodecConfigPreference(activeDevice, codecConfig);
|
bluetoothA2dp.setCodecConfigPreference(activeDevice, codecConfig);
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
|
|||||||
if (bluetoothA2dp == null) {
|
if (bluetoothA2dp == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
BluetoothDevice activeDevice = bluetoothA2dp.getActiveDevice();
|
BluetoothDevice activeDevice = getA2dpActiveDevice();
|
||||||
if (activeDevice == null) {
|
if (activeDevice == null) {
|
||||||
Log.d(TAG, "Unable to get current codec config. No active device.");
|
Log.d(TAG, "Unable to get current codec config. No active device.");
|
||||||
return null;
|
return null;
|
||||||
@@ -178,7 +178,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
BluetoothDevice bluetoothDevice =
|
BluetoothDevice bluetoothDevice =
|
||||||
(device != null) ? device : bluetoothA2dp.getActiveDevice();
|
(device != null) ? device : getA2dpActiveDevice();
|
||||||
if (bluetoothDevice == null) {
|
if (bluetoothDevice == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
|
|||||||
* @return {@link BluetoothCodecConfig}.
|
* @return {@link BluetoothCodecConfig}.
|
||||||
*/
|
*/
|
||||||
protected BluetoothCodecConfig getSelectableByCodecType(int codecTypeValue) {
|
protected BluetoothCodecConfig getSelectableByCodecType(int codecTypeValue) {
|
||||||
BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice();
|
BluetoothDevice activeDevice = getA2dpActiveDevice();
|
||||||
if (activeDevice == null) {
|
if (activeDevice == null) {
|
||||||
Log.d(TAG, "Unable to get selectable config. No active device.");
|
Log.d(TAG, "Unable to get selectable config. No active device.");
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -17,8 +17,14 @@
|
|||||||
package com.android.settings.development.bluetooth;
|
package com.android.settings.development.bluetooth;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothA2dp;
|
import android.bluetooth.BluetoothA2dp;
|
||||||
|
import android.bluetooth.BluetoothAdapter;
|
||||||
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
import android.bluetooth.BluetoothManager;
|
||||||
|
import android.bluetooth.BluetoothProfile;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
import com.android.settings.development.BluetoothA2dpConfigStore;
|
import com.android.settings.development.BluetoothA2dpConfigStore;
|
||||||
import com.android.settings.development.BluetoothServiceConnectionListener;
|
import com.android.settings.development.BluetoothServiceConnectionListener;
|
||||||
@@ -27,6 +33,8 @@ import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
|||||||
import com.android.settingslib.core.lifecycle.events.OnDestroy;
|
import com.android.settingslib.core.lifecycle.events.OnDestroy;
|
||||||
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
|
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for Bluetooth A2DP config controller in developer option.
|
* Abstract class for Bluetooth A2DP config controller in developer option.
|
||||||
*/
|
*/
|
||||||
@@ -36,12 +44,16 @@ public abstract class AbstractBluetoothPreferenceController extends
|
|||||||
|
|
||||||
protected volatile BluetoothA2dp mBluetoothA2dp;
|
protected volatile BluetoothA2dp mBluetoothA2dp;
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
BluetoothAdapter mBluetoothAdapter;
|
||||||
|
|
||||||
public AbstractBluetoothPreferenceController(Context context, Lifecycle lifecycle,
|
public AbstractBluetoothPreferenceController(Context context, Lifecycle lifecycle,
|
||||||
BluetoothA2dpConfigStore store) {
|
BluetoothA2dpConfigStore store) {
|
||||||
super(context);
|
super(context);
|
||||||
if (lifecycle != null) {
|
if (lifecycle != null) {
|
||||||
lifecycle.addObserver(this);
|
lifecycle.addObserver(this);
|
||||||
}
|
}
|
||||||
|
mBluetoothAdapter = context.getSystemService(BluetoothManager.class).getAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,4 +94,13 @@ public abstract class AbstractBluetoothPreferenceController extends
|
|||||||
*/
|
*/
|
||||||
void onBluetoothHDAudioEnabled(boolean enabled);
|
void onBluetoothHDAudioEnabled(boolean enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected BluetoothDevice getA2dpActiveDevice() {
|
||||||
|
if (mBluetoothAdapter == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<BluetoothDevice> activeDevices =
|
||||||
|
mBluetoothAdapter.getActiveDevices(BluetoothProfile.A2DP);
|
||||||
|
return (activeDevices.size() > 0) ? activeDevices.get(0) : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class BluetoothCodecDialogPreferenceController extends
|
|||||||
if (bluetoothA2dp == null) {
|
if (bluetoothA2dp == null) {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
final BluetoothDevice activeDevice = bluetoothA2dp.getActiveDevice();
|
final BluetoothDevice activeDevice = getA2dpActiveDevice();
|
||||||
if (activeDevice == null) {
|
if (activeDevice == null) {
|
||||||
Log.d(TAG, "Unable to get selectable index. No Active Bluetooth device");
|
Log.d(TAG, "Unable to get selectable index. No Active Bluetooth device");
|
||||||
return index;
|
return index;
|
||||||
@@ -93,7 +93,7 @@ public class BluetoothCodecDialogPreferenceController extends
|
|||||||
int codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT;
|
int codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT;
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
final BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice();
|
final BluetoothDevice activeDevice = getA2dpActiveDevice();
|
||||||
codecTypeValue = getHighestCodec(mBluetoothA2dp, activeDevice,
|
codecTypeValue = getHighestCodec(mBluetoothA2dp, activeDevice,
|
||||||
getSelectableConfigs(activeDevice));
|
getSelectableConfigs(activeDevice));
|
||||||
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class BluetoothHDAudioPreferenceController extends AbstractBluetoothPrefe
|
|||||||
mPreference.setEnabled(false);
|
mPreference.setEnabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final BluetoothDevice activeDevice = bluetoothA2dp.getActiveDevice();
|
final BluetoothDevice activeDevice = getA2dpActiveDevice();
|
||||||
if (activeDevice == null) {
|
if (activeDevice == null) {
|
||||||
Log.e(TAG, "Active device is null. To disable HD audio button");
|
Log.e(TAG, "Active device is null. To disable HD audio button");
|
||||||
mPreference.setEnabled(false);
|
mPreference.setEnabled(false);
|
||||||
@@ -84,7 +84,7 @@ public class BluetoothHDAudioPreferenceController extends AbstractBluetoothPrefe
|
|||||||
final int prefValue = enabled
|
final int prefValue = enabled
|
||||||
? BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED
|
? BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED
|
||||||
: BluetoothA2dp.OPTIONAL_CODECS_PREF_DISABLED;
|
: BluetoothA2dp.OPTIONAL_CODECS_PREF_DISABLED;
|
||||||
BluetoothDevice activeDevice = bluetoothA2dp.getActiveDevice();
|
BluetoothDevice activeDevice = getA2dpActiveDevice();
|
||||||
if (activeDevice == null) {
|
if (activeDevice == null) {
|
||||||
mPreference.setEnabled(false);
|
mPreference.setEnabled(false);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -39,11 +39,12 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
private final List<IDreamItem> mItemList;
|
private final List<IDreamItem> mItemList;
|
||||||
|
private int mLastSelectedPos = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View holder for each {@link IDreamItem}.
|
* View holder for each {@link IDreamItem}.
|
||||||
*/
|
*/
|
||||||
private static class DreamViewHolder extends RecyclerView.ViewHolder {
|
private class DreamViewHolder extends RecyclerView.ViewHolder {
|
||||||
private final ImageView mIconView;
|
private final ImageView mIconView;
|
||||||
private final TextView mTitleView;
|
private final TextView mTitleView;
|
||||||
private final ImageView mPreviewView;
|
private final ImageView mPreviewView;
|
||||||
@@ -62,7 +63,7 @@ class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|||||||
/**
|
/**
|
||||||
* Bind the view at the given position, populating the view with the provided data.
|
* Bind the view at the given position, populating the view with the provided data.
|
||||||
*/
|
*/
|
||||||
public void bindView(IDreamItem item) {
|
public void bindView(IDreamItem item, int position) {
|
||||||
mTitleView.setText(item.getTitle());
|
mTitleView.setText(item.getTitle());
|
||||||
|
|
||||||
final Drawable previewImage = item.getPreviewImage();
|
final Drawable previewImage = item.getPreviewImage();
|
||||||
@@ -73,20 +74,32 @@ class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|||||||
mPreviewView.setVisibility(View.GONE);
|
mPreviewView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Drawable icon = item.getIcon();
|
final Drawable icon = item.isActive()
|
||||||
|
? mContext.getDrawable(R.drawable.ic_dream_check_circle)
|
||||||
|
: item.getIcon();
|
||||||
if (icon instanceof VectorDrawable) {
|
if (icon instanceof VectorDrawable) {
|
||||||
icon.setTint(Utils.getColorAttrDefaultColor(mContext,
|
icon.setTint(Utils.getColorAttrDefaultColor(mContext,
|
||||||
com.android.internal.R.attr.colorAccentPrimaryVariant));
|
com.android.internal.R.attr.colorAccentPrimaryVariant));
|
||||||
}
|
}
|
||||||
mIconView.setImageDrawable(icon);
|
mIconView.setImageDrawable(icon);
|
||||||
if (item.allowCustomization()) {
|
|
||||||
mCustomizeButton.setVisibility(View.VISIBLE);
|
if (item.isActive()) {
|
||||||
mCustomizeButton.setOnClickListener(v -> item.onCustomizeClicked());
|
mLastSelectedPos = position;
|
||||||
|
itemView.setSelected(true);
|
||||||
} else {
|
} else {
|
||||||
mCustomizeButton.setVisibility(View.GONE);
|
itemView.setSelected(false);
|
||||||
}
|
}
|
||||||
itemView.setOnClickListener(v -> item.onItemClicked());
|
|
||||||
itemView.setActivated(item.isActive());
|
mCustomizeButton.setOnClickListener(v -> item.onCustomizeClicked());
|
||||||
|
mCustomizeButton.setVisibility(item.allowCustomization() ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
itemView.setOnClickListener(v -> {
|
||||||
|
item.onItemClicked();
|
||||||
|
if (mLastSelectedPos > -1 && mLastSelectedPos != position) {
|
||||||
|
notifyItemChanged(mLastSelectedPos);
|
||||||
|
}
|
||||||
|
notifyItemChanged(position);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +117,7 @@ class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
|
||||||
((DreamViewHolder) viewHolder).bindView(mItemList.get(i));
|
((DreamViewHolder) viewHolder).bindView(mItemList.get(i), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -37,9 +37,7 @@ public class DreamComplicationPickerController extends BasePreferenceController
|
|||||||
private static final String KEY = "dream_complication_picker";
|
private static final String KEY = "dream_complication_picker";
|
||||||
|
|
||||||
private final DreamBackend mBackend;
|
private final DreamBackend mBackend;
|
||||||
private final Drawable mEnabledDrawable;
|
|
||||||
private final Set<Integer> mSupportedComplications;
|
private final Set<Integer> mSupportedComplications;
|
||||||
private DreamAdapter mAdapter;
|
|
||||||
|
|
||||||
private class ComplicationItem implements IDreamItem {
|
private class ComplicationItem implements IDreamItem {
|
||||||
private final int mComplicationType;
|
private final int mComplicationType;
|
||||||
@@ -58,14 +56,13 @@ public class DreamComplicationPickerController extends BasePreferenceController
|
|||||||
@Override
|
@Override
|
||||||
public Drawable getIcon() {
|
public Drawable getIcon() {
|
||||||
// TODO(b/215703483): add icon for each complication
|
// TODO(b/215703483): add icon for each complication
|
||||||
return mEnabled ? mEnabledDrawable : null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClicked() {
|
public void onItemClicked() {
|
||||||
mEnabled = !mEnabled;
|
mEnabled = !mEnabled;
|
||||||
mBackend.setComplicationEnabled(mComplicationType, mEnabled);
|
mBackend.setComplicationEnabled(mComplicationType, mEnabled);
|
||||||
mAdapter.notifyDataSetChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -84,7 +81,6 @@ public class DreamComplicationPickerController extends BasePreferenceController
|
|||||||
super(context, KEY);
|
super(context, KEY);
|
||||||
mBackend = DreamBackend.getInstance(context);
|
mBackend = DreamBackend.getInstance(context);
|
||||||
mSupportedComplications = mBackend.getSupportedComplications();
|
mSupportedComplications = mBackend.getSupportedComplications();
|
||||||
mEnabledDrawable = context.getDrawable(R.drawable.ic_dream_check_circle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -102,7 +98,7 @@ public class DreamComplicationPickerController extends BasePreferenceController
|
|||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
|
|
||||||
mAdapter = new DreamAdapter(mSupportedComplications.stream()
|
DreamAdapter adapter = new DreamAdapter(mSupportedComplications.stream()
|
||||||
.map(ComplicationItem::new)
|
.map(ComplicationItem::new)
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
@@ -110,7 +106,8 @@ public class DreamComplicationPickerController extends BasePreferenceController
|
|||||||
if (pref != null) {
|
if (pref != null) {
|
||||||
final RecyclerView recyclerView = pref.findViewById(R.id.dream_list);
|
final RecyclerView recyclerView = pref.findViewById(R.id.dream_list);
|
||||||
recyclerView.setLayoutManager(new AutoFitGridLayoutManager(mContext));
|
recyclerView.setLayoutManager(new AutoFitGridLayoutManager(mContext));
|
||||||
recyclerView.setAdapter(mAdapter);
|
recyclerView.setHasFixedSize(true);
|
||||||
|
recyclerView.setAdapter(adapter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import com.android.settings.core.BasePreferenceController;
|
|||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
import com.android.settingslib.dream.DreamBackend;
|
import com.android.settingslib.dream.DreamBackend;
|
||||||
|
import com.android.settingslib.dream.DreamBackend.DreamInfo;
|
||||||
import com.android.settingslib.widget.LayoutPreference;
|
import com.android.settingslib.widget.LayoutPreference;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -44,11 +45,10 @@ public class DreamPickerController extends BasePreferenceController {
|
|||||||
|
|
||||||
private final DreamBackend mBackend;
|
private final DreamBackend mBackend;
|
||||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||||
private final List<DreamBackend.DreamInfo> mDreamInfos;
|
private final List<DreamInfo> mDreamInfos;
|
||||||
private final Drawable mActiveDrawable;
|
|
||||||
private Button mPreviewButton;
|
private Button mPreviewButton;
|
||||||
@Nullable
|
@Nullable
|
||||||
private DreamBackend.DreamInfo mActiveDream;
|
private DreamInfo mActiveDream;
|
||||||
private DreamAdapter mAdapter;
|
private DreamAdapter mAdapter;
|
||||||
|
|
||||||
public DreamPickerController(Context context) {
|
public DreamPickerController(Context context) {
|
||||||
@@ -59,7 +59,7 @@ public class DreamPickerController extends BasePreferenceController {
|
|||||||
super(context, KEY);
|
super(context, KEY);
|
||||||
mBackend = backend;
|
mBackend = backend;
|
||||||
mDreamInfos = mBackend.getDreamInfos();
|
mDreamInfos = mBackend.getDreamInfos();
|
||||||
mActiveDrawable = context.getDrawable(R.drawable.ic_dream_check_circle);
|
mActiveDream = getActiveDreamInfo(mDreamInfos);
|
||||||
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
|
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,8 +77,6 @@ public class DreamPickerController extends BasePreferenceController {
|
|||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
super.updateState(preference);
|
super.updateState(preference);
|
||||||
|
|
||||||
mActiveDream = getActiveDreamInfo();
|
|
||||||
|
|
||||||
mAdapter = new DreamAdapter(mDreamInfos.stream()
|
mAdapter = new DreamAdapter(mDreamInfos.stream()
|
||||||
.map(DreamItem::new)
|
.map(DreamItem::new)
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
@@ -86,6 +84,7 @@ public class DreamPickerController extends BasePreferenceController {
|
|||||||
final RecyclerView recyclerView =
|
final RecyclerView recyclerView =
|
||||||
((LayoutPreference) preference).findViewById(R.id.dream_list);
|
((LayoutPreference) preference).findViewById(R.id.dream_list);
|
||||||
recyclerView.setLayoutManager(new AutoFitGridLayoutManager(mContext));
|
recyclerView.setLayoutManager(new AutoFitGridLayoutManager(mContext));
|
||||||
|
recyclerView.setHasFixedSize(true);
|
||||||
recyclerView.setAdapter(mAdapter);
|
recyclerView.setAdapter(mAdapter);
|
||||||
|
|
||||||
mPreviewButton = ((LayoutPreference) preference).findViewById(R.id.preview_button);
|
mPreviewButton = ((LayoutPreference) preference).findViewById(R.id.preview_button);
|
||||||
@@ -101,8 +100,8 @@ public class DreamPickerController extends BasePreferenceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private DreamBackend.DreamInfo getActiveDreamInfo() {
|
private static DreamInfo getActiveDreamInfo(List<DreamInfo> dreamInfos) {
|
||||||
return mDreamInfos
|
return dreamInfos
|
||||||
.stream()
|
.stream()
|
||||||
.filter(d -> d.isActive)
|
.filter(d -> d.isActive)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
@@ -110,9 +109,9 @@ public class DreamPickerController extends BasePreferenceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class DreamItem implements IDreamItem {
|
private class DreamItem implements IDreamItem {
|
||||||
DreamBackend.DreamInfo mDreamInfo;
|
DreamInfo mDreamInfo;
|
||||||
|
|
||||||
DreamItem(DreamBackend.DreamInfo dreamInfo) {
|
DreamItem(DreamInfo dreamInfo) {
|
||||||
mDreamInfo = dreamInfo;
|
mDreamInfo = dreamInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,14 +122,13 @@ public class DreamPickerController extends BasePreferenceController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Drawable getIcon() {
|
public Drawable getIcon() {
|
||||||
return isActive() ? mActiveDrawable : mDreamInfo.icon;
|
return mDreamInfo.icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClicked() {
|
public void onItemClicked() {
|
||||||
mActiveDream = mDreamInfo;
|
mActiveDream = mDreamInfo;
|
||||||
mBackend.setActiveDream(mDreamInfo.componentName);
|
mBackend.setActiveDream(mDreamInfo.componentName);
|
||||||
mAdapter.notifyDataSetChanged();
|
|
||||||
updatePreviewButtonState();
|
updatePreviewButtonState();
|
||||||
mMetricsFeatureProvider.action(
|
mMetricsFeatureProvider.action(
|
||||||
mContext,
|
mContext,
|
||||||
|
|||||||
177
src/com/android/settings/dream/DreamSetupActivity.java
Normal file
177
src/com/android/settings/dream/DreamSetupActivity.java
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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.dream;
|
||||||
|
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.SettingsActivity;
|
||||||
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
|
import com.android.settingslib.dream.DreamBackend;
|
||||||
|
|
||||||
|
import com.google.android.setupcompat.template.FooterBarMixin;
|
||||||
|
import com.google.android.setupcompat.template.FooterButton;
|
||||||
|
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||||
|
import com.google.android.setupdesign.GlifLayout;
|
||||||
|
import com.google.android.setupdesign.util.ThemeHelper;
|
||||||
|
import com.google.android.setupdesign.util.ThemeResolver;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The setup activity for dreams which is displayed during setup wizard.
|
||||||
|
*/
|
||||||
|
public class DreamSetupActivity extends SettingsActivity {
|
||||||
|
@Override
|
||||||
|
public Intent getIntent() {
|
||||||
|
Intent modIntent = new Intent(super.getIntent());
|
||||||
|
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, DreamSetupFragment.class.getName());
|
||||||
|
return modIntent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isValidFragment(String fragmentName) {
|
||||||
|
return DreamSetupFragment.class.getName().equals(fragmentName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstance) {
|
||||||
|
setTheme(ThemeResolver.getDefault().resolve(getIntent()));
|
||||||
|
ThemeHelper.trySetDynamicColor(this);
|
||||||
|
super.onCreate(savedInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isToolbarEnabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fragment used to control the active dream.
|
||||||
|
*/
|
||||||
|
public static class DreamSetupFragment extends SettingsPreferenceFragment {
|
||||||
|
private DreamBackend mBackend;
|
||||||
|
private DreamBackend.DreamInfo mActiveDream;
|
||||||
|
private FooterButton mFooterButton;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetricsCategory() {
|
||||||
|
return SettingsEnums.DREAM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
return inflater.inflate(R.layout.dream_setup_layout, container, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
|
mBackend = DreamBackend.getInstance(getContext());
|
||||||
|
final List<DreamBackend.DreamInfo> dreamInfos = mBackend.getDreamInfos();
|
||||||
|
mActiveDream = dreamInfos.stream().filter(d -> d.isActive).findFirst().orElse(null);
|
||||||
|
DreamAdapter dreamAdapter = new DreamAdapter(dreamInfos.stream()
|
||||||
|
.map(DreamItem::new)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
|
final RecyclerView recyclerView = view.findViewById(R.id.dream_setup_list);
|
||||||
|
recyclerView.setLayoutManager(new AutoFitGridLayoutManager(getContext()));
|
||||||
|
recyclerView.setHasFixedSize(true);
|
||||||
|
recyclerView.setAdapter(dreamAdapter);
|
||||||
|
|
||||||
|
final GlifLayout layout = view.findViewById(R.id.setup_wizard_layout);
|
||||||
|
final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
|
||||||
|
mFooterButton = new FooterButton.Builder(getContext())
|
||||||
|
.setListener(this::onPrimaryButtonClicked)
|
||||||
|
.setButtonType(FooterButton.ButtonType.NEXT)
|
||||||
|
.setTheme(R.style.SudGlifButton_Primary)
|
||||||
|
.build();
|
||||||
|
updateFooterButtonText();
|
||||||
|
mixin.setPrimaryButton(mFooterButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateFooterButtonText() {
|
||||||
|
final int res = canCustomizeDream() ? R.string.wizard_next : R.string.wizard_finish;
|
||||||
|
mFooterButton.setText(getContext().getString(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canCustomizeDream() {
|
||||||
|
return mActiveDream != null && mActiveDream.settingsComponentName != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onPrimaryButtonClicked(View view) {
|
||||||
|
if (canCustomizeDream()) {
|
||||||
|
final Intent intent = new Intent().setComponent(mActiveDream.settingsComponentName);
|
||||||
|
WizardManagerHelper.copyWizardManagerExtras(getIntent(), intent);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use RESULT_CANCELED here so that the user may go back and change this if they wish.
|
||||||
|
setResult(RESULT_CANCELED);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DreamItem implements IDreamItem {
|
||||||
|
private final DreamBackend.DreamInfo mDreamInfo;
|
||||||
|
|
||||||
|
private DreamItem(DreamBackend.DreamInfo dreamInfo) {
|
||||||
|
mDreamInfo = dreamInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharSequence getTitle() {
|
||||||
|
return mDreamInfo.caption;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Drawable getIcon() {
|
||||||
|
return mDreamInfo.icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClicked() {
|
||||||
|
mActiveDream = mDreamInfo;
|
||||||
|
mBackend.setActiveDream(mDreamInfo.componentName);
|
||||||
|
updateFooterButtonText();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Drawable getPreviewImage() {
|
||||||
|
return mDreamInfo.previewImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isActive() {
|
||||||
|
if (mActiveDream == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return mDreamInfo.componentName.equals(mActiveDream.componentName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,8 +17,17 @@
|
|||||||
package com.android.settings.nearby;
|
package com.android.settings.nearby;
|
||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
@@ -34,7 +43,10 @@ import java.util.Objects;
|
|||||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||||
public class FastPairSettingsFragment extends SettingsPreferenceFragment {
|
public class FastPairSettingsFragment extends SettingsPreferenceFragment {
|
||||||
|
|
||||||
|
private static final String TAG = "FastPairSettingsFrag";
|
||||||
|
|
||||||
private static final String SCAN_SWITCH_KEY = "fast_pair_scan_switch";
|
private static final String SCAN_SWITCH_KEY = "fast_pair_scan_switch";
|
||||||
|
private static final String SAVED_DEVICES_PREF_KEY = "saved_devices";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
@@ -47,6 +59,16 @@ public class FastPairSettingsFragment extends SettingsPreferenceFragment {
|
|||||||
Settings.Secure.putInt(getContentResolver(),
|
Settings.Secure.putInt(getContentResolver(),
|
||||||
Settings.Secure.FAST_PAIR_SCAN_ENABLED, isChecked ? 1 : 0));
|
Settings.Secure.FAST_PAIR_SCAN_ENABLED, isChecked ? 1 : 0));
|
||||||
mainSwitchPreference.setChecked(isFastPairScanAvailable());
|
mainSwitchPreference.setChecked(isFastPairScanAvailable());
|
||||||
|
|
||||||
|
Preference savedDevicePref = Objects.requireNonNull(
|
||||||
|
findPreference(SAVED_DEVICES_PREF_KEY));
|
||||||
|
savedDevicePref.setOnPreferenceClickListener(preference -> {
|
||||||
|
Intent savedDevicesIntent = getSavedDevicesIntent();
|
||||||
|
if (savedDevicesIntent != null && getActivity() != null) {
|
||||||
|
getActivity().startActivity(savedDevicesIntent);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -71,4 +93,42 @@ public class FastPairSettingsFragment extends SettingsPreferenceFragment {
|
|||||||
return Settings.Secure.getInt(getContentResolver(),
|
return Settings.Secure.getInt(getContentResolver(),
|
||||||
Settings.Secure.FAST_PAIR_SCAN_ENABLED, 1) != 0;
|
Settings.Secure.FAST_PAIR_SCAN_ENABLED, 1) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private ComponentName getSavedDevicesComponent() {
|
||||||
|
String savedDevicesComponent = Settings.Secure.getString(
|
||||||
|
getContentResolver(),
|
||||||
|
Settings.Secure.NEARBY_FAST_PAIR_SETTINGS_DEVICES_COMPONENT);
|
||||||
|
if (TextUtils.isEmpty(savedDevicesComponent)) {
|
||||||
|
savedDevicesComponent = getString(
|
||||||
|
com.android.internal.R.string.config_defaultNearbyFastPairSettingsDevicesComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(savedDevicesComponent)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ComponentName.unflattenFromString(savedDevicesComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private Intent getSavedDevicesIntent() {
|
||||||
|
ComponentName componentName = getSavedDevicesComponent();
|
||||||
|
if (componentName == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
PackageManager pm = getPackageManager();
|
||||||
|
Intent intent = getIntent();
|
||||||
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
|
intent.setComponent(componentName);
|
||||||
|
|
||||||
|
final ResolveInfo resolveInfo = pm.resolveActivity(intent, PackageManager.GET_META_DATA);
|
||||||
|
if (resolveInfo == null || resolveInfo.activityInfo == null) {
|
||||||
|
Log.e(TAG, "Device-specified fast pair component (" + componentName
|
||||||
|
+ ") not available");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return intent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,9 @@ public class AddSupervisedUserActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createUser() {
|
private void createUser() {
|
||||||
final NewUserRequest request = new NewUserRequest.Builder().build();
|
final NewUserRequest request = new NewUserRequest.Builder()
|
||||||
|
.setName(getString(R.string.user_new_user_name))
|
||||||
|
.build();
|
||||||
|
|
||||||
final AlertDialog pleaseWaitDialog = new AlertDialog.Builder(this)
|
final AlertDialog pleaseWaitDialog = new AlertDialog.Builder(this)
|
||||||
.setMessage(getString(R.string.creating_new_user_dialog_message))
|
.setMessage(getString(R.string.creating_new_user_dialog_message))
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ public class AbstractBluetoothA2dpPreferenceControllerTest {
|
|||||||
mLifecycle = new Lifecycle(mLifecycleOwner);
|
mLifecycle = new Lifecycle(mLifecycleOwner);
|
||||||
mController = spy(new AbstractBluetoothA2dpPreferenceControllerImpl(mContext, mLifecycle,
|
mController = spy(new AbstractBluetoothA2dpPreferenceControllerImpl(mContext, mLifecycle,
|
||||||
mBluetoothA2dpConfigStore));
|
mBluetoothA2dpConfigStore));
|
||||||
|
mController.mBluetoothAdapter = null;
|
||||||
doReturn(mBluetoothCodecConfig).when(mController).getCodecConfig(null);
|
doReturn(mBluetoothCodecConfig).when(mController).getCodecConfig(null);
|
||||||
doNothing().when(mController).setCodecConfigPreference(any(), any());
|
doNothing().when(mController).setCodecConfigPreference(any(), any());
|
||||||
when(mBluetoothA2dpConfigStore.createCodecConfig()).thenReturn(mBluetoothCodecConfig);
|
when(mBluetoothA2dpConfigStore.createCodecConfig()).thenReturn(mBluetoothCodecConfig);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import static android.bluetooth.BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.eq;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -30,6 +31,7 @@ import android.bluetooth.BluetoothAdapter;
|
|||||||
import android.bluetooth.BluetoothCodecConfig;
|
import android.bluetooth.BluetoothCodecConfig;
|
||||||
import android.bluetooth.BluetoothCodecStatus;
|
import android.bluetooth.BluetoothCodecStatus;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
import android.bluetooth.BluetoothProfile;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
@@ -59,6 +61,8 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private BluetoothA2dp mBluetoothA2dp;
|
private BluetoothA2dp mBluetoothA2dp;
|
||||||
@Mock
|
@Mock
|
||||||
|
private BluetoothAdapter mBluetoothAdapter;
|
||||||
|
@Mock
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
|
|
||||||
private AbstractBluetoothDialogPreferenceController mController;
|
private AbstractBluetoothDialogPreferenceController mController;
|
||||||
@@ -84,6 +88,7 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
|
|||||||
mActiveDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(DEVICE_ADDRESS);
|
mActiveDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(DEVICE_ADDRESS);
|
||||||
mController = spy(new AbstractBluetoothDialogPreferenceControllerImpl(mContext, mLifecycle,
|
mController = spy(new AbstractBluetoothDialogPreferenceControllerImpl(mContext, mLifecycle,
|
||||||
mBluetoothA2dpConfigStore));
|
mBluetoothA2dpConfigStore));
|
||||||
|
mController.mBluetoothAdapter = mBluetoothAdapter;
|
||||||
mPreference = spy(new BaseBluetoothDialogPreferenceImpl(mContext));
|
mPreference = spy(new BaseBluetoothDialogPreferenceImpl(mContext));
|
||||||
|
|
||||||
mCodecConfigAAC = new BluetoothCodecConfig.Builder()
|
mCodecConfigAAC = new BluetoothCodecConfig.Builder()
|
||||||
@@ -99,7 +104,8 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
|
|||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
mCurrentConfig = mController.getCurrentConfigIndex();
|
mCurrentConfig = mController.getCurrentConfigIndex();
|
||||||
when(mPreference.generateSummary(mCurrentConfig)).thenReturn(SUMMARY);
|
when(mPreference.generateSummary(mCurrentConfig)).thenReturn(SUMMARY);
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
||||||
|
.thenReturn(Arrays.asList(mActiveDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.settings.development.bluetooth;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.eq;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -27,6 +28,7 @@ import android.bluetooth.BluetoothAdapter;
|
|||||||
import android.bluetooth.BluetoothCodecConfig;
|
import android.bluetooth.BluetoothCodecConfig;
|
||||||
import android.bluetooth.BluetoothCodecStatus;
|
import android.bluetooth.BluetoothCodecStatus;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
import android.bluetooth.BluetoothProfile;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
@@ -55,6 +57,8 @@ public class BluetoothBitPerSampleDialogPreferenceControllerTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private BluetoothA2dp mBluetoothA2dp;
|
private BluetoothA2dp mBluetoothA2dp;
|
||||||
@Mock
|
@Mock
|
||||||
|
private BluetoothAdapter mBluetoothAdapter;
|
||||||
|
@Mock
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
|
|
||||||
private BluetoothBitPerSampleDialogPreferenceController mController;
|
private BluetoothBitPerSampleDialogPreferenceController mController;
|
||||||
@@ -81,6 +85,7 @@ public class BluetoothBitPerSampleDialogPreferenceControllerTest {
|
|||||||
mPreference = new BluetoothBitPerSampleDialogPreference(mContext);
|
mPreference = new BluetoothBitPerSampleDialogPreference(mContext);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
mController.mBluetoothAdapter = mBluetoothAdapter;
|
||||||
mCodecConfigAAC = new BluetoothCodecConfig.Builder()
|
mCodecConfigAAC = new BluetoothCodecConfig.Builder()
|
||||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
|
||||||
.setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_16
|
.setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_16
|
||||||
@@ -90,7 +95,8 @@ public class BluetoothBitPerSampleDialogPreferenceControllerTest {
|
|||||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
|
||||||
.setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_24)
|
.setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_24)
|
||||||
.build();
|
.build();
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
||||||
|
.thenReturn(Arrays.asList(mActiveDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.settings.development.bluetooth;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.eq;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -27,6 +28,7 @@ import android.bluetooth.BluetoothAdapter;
|
|||||||
import android.bluetooth.BluetoothCodecConfig;
|
import android.bluetooth.BluetoothCodecConfig;
|
||||||
import android.bluetooth.BluetoothCodecStatus;
|
import android.bluetooth.BluetoothCodecStatus;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
import android.bluetooth.BluetoothProfile;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
@@ -55,6 +57,8 @@ public class BluetoothChannelModeDialogPreferenceControllerTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private BluetoothA2dp mBluetoothA2dp;
|
private BluetoothA2dp mBluetoothA2dp;
|
||||||
@Mock
|
@Mock
|
||||||
|
private BluetoothAdapter mBluetoothAdapter;
|
||||||
|
@Mock
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
|
|
||||||
private BluetoothChannelModeDialogPreferenceController mController;
|
private BluetoothChannelModeDialogPreferenceController mController;
|
||||||
@@ -78,6 +82,7 @@ public class BluetoothChannelModeDialogPreferenceControllerTest {
|
|||||||
mActiveDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(DEVICE_ADDRESS);
|
mActiveDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(DEVICE_ADDRESS);
|
||||||
mController = new BluetoothChannelModeDialogPreferenceController(mContext, mLifecycle,
|
mController = new BluetoothChannelModeDialogPreferenceController(mContext, mLifecycle,
|
||||||
mBluetoothA2dpConfigStore);
|
mBluetoothA2dpConfigStore);
|
||||||
|
mController.mBluetoothAdapter = mBluetoothAdapter;
|
||||||
mPreference = new BluetoothChannelModeDialogPreference(mContext);
|
mPreference = new BluetoothChannelModeDialogPreference(mContext);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
@@ -90,7 +95,8 @@ public class BluetoothChannelModeDialogPreferenceControllerTest {
|
|||||||
.setChannelMode(BluetoothCodecConfig.CHANNEL_MODE_MONO
|
.setChannelMode(BluetoothCodecConfig.CHANNEL_MODE_MONO
|
||||||
| BluetoothCodecConfig.CHANNEL_MODE_STEREO)
|
| BluetoothCodecConfig.CHANNEL_MODE_STEREO)
|
||||||
.build();
|
.build();
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
||||||
|
.thenReturn(Arrays.asList(mActiveDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import android.bluetooth.BluetoothAdapter;
|
|||||||
import android.bluetooth.BluetoothCodecConfig;
|
import android.bluetooth.BluetoothCodecConfig;
|
||||||
import android.bluetooth.BluetoothCodecStatus;
|
import android.bluetooth.BluetoothCodecStatus;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
import android.bluetooth.BluetoothProfile;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
@@ -56,6 +57,8 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private BluetoothA2dp mBluetoothA2dp;
|
private BluetoothA2dp mBluetoothA2dp;
|
||||||
@Mock
|
@Mock
|
||||||
|
private BluetoothAdapter mBluetoothAdapter;
|
||||||
|
@Mock
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
@Mock
|
@Mock
|
||||||
private AbstractBluetoothPreferenceController.Callback mCallback;
|
private AbstractBluetoothPreferenceController.Callback mCallback;
|
||||||
@@ -85,6 +88,7 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
|||||||
mActiveDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(DEVICE_ADDRESS);
|
mActiveDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(DEVICE_ADDRESS);
|
||||||
mController = new BluetoothCodecDialogPreferenceController(mContext, mLifecycle,
|
mController = new BluetoothCodecDialogPreferenceController(mContext, mLifecycle,
|
||||||
mBluetoothA2dpConfigStore, mCallback);
|
mBluetoothA2dpConfigStore, mCallback);
|
||||||
|
mController.mBluetoothAdapter = mBluetoothAdapter;
|
||||||
mPreference = new BluetoothCodecDialogPreference(mContext);
|
mPreference = new BluetoothCodecDialogPreference(mContext);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
@@ -115,7 +119,8 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
|||||||
mCodecConfigLDAC = new BluetoothCodecConfig.Builder()
|
mCodecConfigLDAC = new BluetoothCodecConfig.Builder()
|
||||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC)
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC)
|
||||||
.build();
|
.build();
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
||||||
|
.thenReturn(Arrays.asList(mActiveDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -18,12 +18,15 @@ package com.android.settings.development.bluetooth;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.eq;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothA2dp;
|
import android.bluetooth.BluetoothA2dp;
|
||||||
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
import android.bluetooth.BluetoothProfile;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
@@ -43,6 +46,9 @@ import org.robolectric.RuntimeEnvironment;
|
|||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowBluetoothDevice;
|
import org.robolectric.shadows.ShadowBluetoothDevice;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = {ShadowBluetoothDevice.class})
|
@Config(shadows = {ShadowBluetoothDevice.class})
|
||||||
public class BluetoothHDAudioPreferenceControllerTest {
|
public class BluetoothHDAudioPreferenceControllerTest {
|
||||||
@@ -52,6 +58,8 @@ public class BluetoothHDAudioPreferenceControllerTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private BluetoothA2dp mBluetoothA2dp;
|
private BluetoothA2dp mBluetoothA2dp;
|
||||||
@Mock
|
@Mock
|
||||||
|
private BluetoothAdapter mBluetoothAdapter;
|
||||||
|
@Mock
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
@Mock
|
@Mock
|
||||||
private AbstractBluetoothPreferenceController.Callback mCallback;
|
private AbstractBluetoothPreferenceController.Callback mCallback;
|
||||||
@@ -73,6 +81,7 @@ public class BluetoothHDAudioPreferenceControllerTest {
|
|||||||
mBluetoothA2dpConfigStore = spy(new BluetoothA2dpConfigStore());
|
mBluetoothA2dpConfigStore = spy(new BluetoothA2dpConfigStore());
|
||||||
mController = new BluetoothHDAudioPreferenceController(mContext, mLifecycle,
|
mController = new BluetoothHDAudioPreferenceController(mContext, mLifecycle,
|
||||||
mBluetoothA2dpConfigStore, mCallback);
|
mBluetoothA2dpConfigStore, mCallback);
|
||||||
|
mController.mBluetoothAdapter = mBluetoothAdapter;
|
||||||
mPreference = new SwitchPreference(mContext);
|
mPreference = new SwitchPreference(mContext);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
@@ -81,7 +90,8 @@ public class BluetoothHDAudioPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_noActiveDevice_setDisable() {
|
public void updateState_noActiveDevice_setDisable() {
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(null);
|
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
||||||
|
.thenReturn(Collections.emptyList());
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
@@ -90,7 +100,8 @@ public class BluetoothHDAudioPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_codecSupported_setEnable() {
|
public void updateState_codecSupported_setEnable() {
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
||||||
|
.thenReturn(Arrays.asList(mActiveDevice));
|
||||||
when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
|
when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
|
||||||
mBluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
|
mBluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
@@ -101,7 +112,8 @@ public class BluetoothHDAudioPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_codecNotSupported_setDisable() {
|
public void updateState_codecNotSupported_setDisable() {
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
||||||
|
.thenReturn(Arrays.asList(mActiveDevice));
|
||||||
when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
|
when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
|
||||||
mBluetoothA2dp.OPTIONAL_CODECS_NOT_SUPPORTED);
|
mBluetoothA2dp.OPTIONAL_CODECS_NOT_SUPPORTED);
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
@@ -112,7 +124,8 @@ public class BluetoothHDAudioPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_codecSupportedAndEnabled_checked() {
|
public void updateState_codecSupportedAndEnabled_checked() {
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
||||||
|
.thenReturn(Arrays.asList(mActiveDevice));
|
||||||
when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
|
when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
|
||||||
mBluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
|
mBluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
|
||||||
when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
|
when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
|
||||||
@@ -125,7 +138,8 @@ public class BluetoothHDAudioPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_codecSupportedAndDisabled_notChecked() {
|
public void updateState_codecSupportedAndDisabled_notChecked() {
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
||||||
|
.thenReturn(Arrays.asList(mActiveDevice));
|
||||||
when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
|
when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
|
||||||
mBluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
|
mBluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
|
||||||
when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
|
when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
|
||||||
@@ -138,7 +152,8 @@ public class BluetoothHDAudioPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onPreferenceChange_disable_verifyFlow() {
|
public void onPreferenceChange_disable_verifyFlow() {
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
||||||
|
.thenReturn(Arrays.asList(mActiveDevice));
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
final boolean enabled = false;
|
final boolean enabled = false;
|
||||||
mController.onPreferenceChange(mPreference, enabled);
|
mController.onPreferenceChange(mPreference, enabled);
|
||||||
@@ -151,7 +166,8 @@ public class BluetoothHDAudioPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onPreferenceChange_enable_verifyFlow() {
|
public void onPreferenceChange_enable_verifyFlow() {
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
||||||
|
.thenReturn(Arrays.asList(mActiveDevice));
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
final boolean enabled = true;
|
final boolean enabled = true;
|
||||||
mController.onPreferenceChange(mPreference, enabled);
|
mController.onPreferenceChange(mPreference, enabled);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.settings.development.bluetooth;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.eq;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -27,6 +28,7 @@ import android.bluetooth.BluetoothAdapter;
|
|||||||
import android.bluetooth.BluetoothCodecConfig;
|
import android.bluetooth.BluetoothCodecConfig;
|
||||||
import android.bluetooth.BluetoothCodecStatus;
|
import android.bluetooth.BluetoothCodecStatus;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
import android.bluetooth.BluetoothProfile;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
@@ -53,6 +55,8 @@ public class BluetoothQualityDialogPreferenceControllerTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private BluetoothA2dp mBluetoothA2dp;
|
private BluetoothA2dp mBluetoothA2dp;
|
||||||
@Mock
|
@Mock
|
||||||
|
private BluetoothAdapter mBluetoothAdapter;
|
||||||
|
@Mock
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
|
|
||||||
private BluetoothQualityDialogPreferenceController mController;
|
private BluetoothQualityDialogPreferenceController mController;
|
||||||
@@ -76,6 +80,7 @@ public class BluetoothQualityDialogPreferenceControllerTest {
|
|||||||
mActiveDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(DEVICE_ADDRESS);
|
mActiveDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(DEVICE_ADDRESS);
|
||||||
mController = new BluetoothQualityDialogPreferenceController(mContext, mLifecycle,
|
mController = new BluetoothQualityDialogPreferenceController(mContext, mLifecycle,
|
||||||
mBluetoothA2dpConfigStore);
|
mBluetoothA2dpConfigStore);
|
||||||
|
mController.mBluetoothAdapter = mBluetoothAdapter;
|
||||||
mPreference = new BluetoothQualityDialogPreference(mContext);
|
mPreference = new BluetoothQualityDialogPreference(mContext);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
@@ -89,7 +94,8 @@ public class BluetoothQualityDialogPreferenceControllerTest {
|
|||||||
.setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_96000)
|
.setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_96000)
|
||||||
.setCodecSpecific1(1001)
|
.setCodecSpecific1(1001)
|
||||||
.build();
|
.build();
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
||||||
|
.thenReturn(Arrays.asList(mActiveDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.settings.development.bluetooth;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.eq;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -27,6 +28,7 @@ import android.bluetooth.BluetoothAdapter;
|
|||||||
import android.bluetooth.BluetoothCodecConfig;
|
import android.bluetooth.BluetoothCodecConfig;
|
||||||
import android.bluetooth.BluetoothCodecStatus;
|
import android.bluetooth.BluetoothCodecStatus;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
import android.bluetooth.BluetoothProfile;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
@@ -55,6 +57,8 @@ public class BluetoothSampleRateDialogPreferenceControllerTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private BluetoothA2dp mBluetoothA2dp;
|
private BluetoothA2dp mBluetoothA2dp;
|
||||||
@Mock
|
@Mock
|
||||||
|
private BluetoothAdapter mBluetoothAdapter;
|
||||||
|
@Mock
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
|
|
||||||
private BluetoothSampleRateDialogPreferenceController mController;
|
private BluetoothSampleRateDialogPreferenceController mController;
|
||||||
@@ -79,6 +83,7 @@ public class BluetoothSampleRateDialogPreferenceControllerTest {
|
|||||||
mActiveDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(DEVICE_ADDRESS);
|
mActiveDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(DEVICE_ADDRESS);
|
||||||
mController = spy(new BluetoothSampleRateDialogPreferenceController(mContext, mLifecycle,
|
mController = spy(new BluetoothSampleRateDialogPreferenceController(mContext, mLifecycle,
|
||||||
mBluetoothA2dpConfigStore));
|
mBluetoothA2dpConfigStore));
|
||||||
|
mController.mBluetoothAdapter = mBluetoothAdapter;
|
||||||
mPreference = new BluetoothSampleRateDialogPreference(mContext);
|
mPreference = new BluetoothSampleRateDialogPreference(mContext);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
@@ -91,7 +96,8 @@ public class BluetoothSampleRateDialogPreferenceControllerTest {
|
|||||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
|
||||||
.setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_96000)
|
.setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_96000)
|
||||||
.build();
|
.build();
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
||||||
|
.thenReturn(Arrays.asList(mActiveDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user