Snap for 4885240 from 7adfcf6819 to qt-release
Change-Id: I860ce3c25cdbc23904f7fdb5364268c67c665662
This commit is contained in:
@@ -2438,7 +2438,7 @@
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.applications.appinfo.PictureInPictureSettings" />
|
||||
android:value="com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureSettings" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
@@ -2452,7 +2452,7 @@
|
||||
<data android:scheme="package" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.applications.appinfo.PictureInPictureDetails" />
|
||||
android:value="com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetails" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2015 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.
|
||||
-->
|
||||
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="25dp"
|
||||
android:paddingEnd="25dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/bluetooth_preference_paired_dialog_name_label"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Body1"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textDirection="locale"
|
||||
android:paddingTop="16dp"
|
||||
style="@style/bt_item_label"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:maxLength="@integer/bluetooth_name_length"
|
||||
android:singleLine="true"
|
||||
android:paddingBottom="@dimen/bluetooth_dialog_padding"
|
||||
android:textDirection="locale"
|
||||
style="@style/bt_item_edit_content"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/profiles_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:text="@string/bluetooth_device_advanced_profile_header_title"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Body1"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/profiles_section"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
@@ -185,7 +185,6 @@
|
||||
<!-- Bluetooth Preferences -->
|
||||
<dimen name="bluetooth_dialog_padding">8dip</dimen>
|
||||
<dimen name="bluetooth_dialog_padding_top">20dp</dimen>
|
||||
<integer name="bluetooth_name_length">32</integer>
|
||||
<dimen name="bluetooth_pairing_padding">24dp</dimen>
|
||||
<dimen name="bluetooth_pairing_edittext_padding">21dp</dimen>
|
||||
<dimen name="bluetooth_checkbox_padding">16dp</dimen>
|
||||
|
||||
@@ -268,10 +268,6 @@
|
||||
<string name="bluetooth_is_disconnect_question">Disconnect <xliff:g id="device_name">%1$s</xliff:g>?</string>
|
||||
<!-- Bluetooth broadcasting settings, option to enable/disable broadcasting -->
|
||||
<string name="bluetooth_broadcasting">Broadcasting</string>
|
||||
<!-- Bluetooth settings. Dialog title to disable a single profile of a device. [CHAR LIMIT=40] -->
|
||||
<string name="bluetooth_disable_profile_title">Disable profile?</string>
|
||||
<!-- Bluetooth settings. Message for disabling a profile of a bluetooth device. [CHAR LIMIT=NONE] -->
|
||||
<string name="bluetooth_disable_profile_message">This will disable:<br><b><xliff:g id="profile_name">%1$s</xliff:g></b><br><br>From:<br><b><xliff:g id="device_name">%2$s</xliff:g></b></string>
|
||||
|
||||
<!-- Bluetooth settings. Message when the device state is unknown -->
|
||||
<string name="bluetooth_unknown" />
|
||||
@@ -879,26 +875,26 @@
|
||||
<string name="security_dashboard_summary_no_fingerprint">Screen lock</string>
|
||||
|
||||
<!-- Face enrollment and settings --><skip />
|
||||
<!-- Message shown in summary field when face authentication is set up. [CHAR LIMIT=22] -->
|
||||
<!-- Message shown in summary field when face authentication is set up. [CHAR LIMIT=40] -->
|
||||
<string name="security_settings_face_preference_summary">Face added</string>
|
||||
<!-- Message shown in summary field when face authentication is not set up. [CHAR LIMIT=40] -->
|
||||
<!-- Message shown in summary field when face authentication is not set up. [CHAR LIMIT=54] -->
|
||||
<string name="security_settings_face_preference_summary_none">Tap to set up face authentication</string>
|
||||
<!-- Title shown for menu item that launches face settings or enrollment. [CHAR LIMIT=22] -->
|
||||
<!-- Title shown for menu item that launches face settings or enrollment. [CHAR LIMIT=32] -->
|
||||
<string name="security_settings_face_preference_title">Face authentication</string>
|
||||
<!-- Button text to cancel enrollment from the introduction [CHAR LIMIT=22] -->
|
||||
<string name="security_settings_face_enroll_introduction_cancel">Cancel</string>
|
||||
<!-- Introduction title shown in face enrollment to introduce the face unlock feature [CHAR LIMIT=30] -->
|
||||
<!-- Introduction title shown in face enrollment to introduce the face unlock feature [CHAR LIMIT=40] -->
|
||||
<string name="security_settings_face_enroll_introduction_title">Unlock with your face</string>
|
||||
<!-- Introduction title shown in face enrollment to introduce the face authentication feature, when face unlock is disabled by device admin [CHAR LIMIT=40] -->
|
||||
<string name="security_settings_face_enroll_introduction_title_unlock_disabled">Use your face to authenticate</string>
|
||||
<!-- Introduction detail message shown in face enrollment dialog [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_face_enroll_introduction_message">Use your face to unlock your phone, authorize purchases, or sign in to apps.</string>
|
||||
<!-- Introduction detail message shown in face enrollment dialog, when face unlock is disabled by device admin [CHAR LIMIT=NONE] -->
|
||||
<string name="security_settings_face_enroll_introduction_message_unlock_disabled">Use you</string>
|
||||
<string name="security_settings_face_enroll_introduction_message_unlock_disabled">Use your face to unlock your phone or approve purchases.\n\nNote: You can\u2019t use your face to unlock this device. For more information, contact your organization\u2019s admin.</string>
|
||||
<!-- Introduction detail message shwon in face enrollment screen in setup wizard. [CHAR LIMIT=NONE] -->
|
||||
<string name="security_settings_face_enroll_introduction_message_setup">Use your face to unlock your phone, authorize purchases, or sign in to apps</string>
|
||||
<!-- Text shown when "Add face" button is disabled -->
|
||||
<string name="face_add_max">You can add up to <xliff:g id="count" example="5">%d</xliff:g> fingerprints</string>
|
||||
<string name="face_add_max">You can add up to <xliff:g id="count" example="5">%d</xliff:g> faces</string>
|
||||
<!-- Text shown when users has enrolled a maximum number of faces [CHAR LIMIT=NONE] -->
|
||||
<string name="face_intro_error_max">You\u2019ve added the maximum number of faces</string>
|
||||
<!-- Text shown when an unknown error caused the device to be unable to add faces [CHAR LIMIT=NONE] -->
|
||||
@@ -1637,8 +1633,6 @@
|
||||
<string name="bluetooth_preference_device_settings">Device settings</string>
|
||||
<!-- Bluetooth settings: Paired dialog title [CHAR LIMIT=40] -->
|
||||
<string name="bluetooth_preference_paired_dialog_title">Paired device</string>
|
||||
<!-- Bluetooth settings: Name label [CHAR LIMIT=40] -->
|
||||
<string name="bluetooth_preference_paired_dialog_name_label">Name</string>
|
||||
<!-- Bluetooth settings: Checkbox label for enable/disable internet connection. [CHAR LIMIT=40] -->
|
||||
<string name="bluetooth_preference_paired_dialog_internet_option">Internet connection</string>
|
||||
<!-- Bluetooth settings: Checkbox label for enable/disable keyboard connection. [CHAR LIMIT=40] -->
|
||||
@@ -1653,8 +1647,6 @@
|
||||
<string name="bluetooth_pairing_dialog_contants_request"><xliff:g id="device_name">%1$s</xliff:g> wants to access your contacts and call history.</string>
|
||||
<!-- Bluetooth settings: paring permission message. [CHAR LIMIT=100] -->
|
||||
<string name="bluetooth_pairing_dialog_paring_request"><xliff:g id="device_name">%1$s</xliff:g> wants to pair with Bluetooth. When connected, it will have access to your contacts and call history.</string>
|
||||
<!-- Bluetooth settings: The sub heading for devices which have already been paired with this device. [CHAR LIMIT=40] -->
|
||||
<string name="bluetooth_preference_paired_devices">Paired devices</string>
|
||||
<!-- Bluetooth settings: The sub heading for available devices during and after scanning. [CHAR LIMIT=40] -->
|
||||
<string name="bluetooth_preference_found_media_devices">Available devices</string>
|
||||
<!-- Bluetooth settings: The message displayed if no Bluetooth devices were found. [CHAR LIMIT=40] -->
|
||||
@@ -2568,9 +2560,9 @@
|
||||
<string name="brightness_summary">Adjust the brightness of the screen</string>
|
||||
<!-- Sound & display settings screen, setting option name to enable adaptive brightness [CHAR LIMIT=30] -->
|
||||
<string name="auto_brightness_title">Adaptive brightness</string>
|
||||
<!-- Sound & display settings screen, setting option summary to enable adaptive brightness [CHAR LIMIT=100] -->
|
||||
<string name="auto_brightness_summary">Optimize brightness level for available light</string>
|
||||
<!-- Sound & display settings screen, setting option summary when adaptive brightness is off [CHAR LIMIT=100] -->
|
||||
<!-- Setting option summary when adaptive brightness is on [CHAR LIMIT=NONE] -->
|
||||
<string name="auto_brightness_summary_on">On</string>
|
||||
<!-- Setting option summary when adaptive brightness is off [CHAR LIMIT=NONE] -->
|
||||
<string name="auto_brightness_summary_off">Off</string>
|
||||
<!-- Sound & display settings screen, setting option summary when preferred adaptive brightness is very low [CHAR LIMIT=100] -->
|
||||
<string name="auto_brightness_summary_very_low">Preferred brightness is very low</string>
|
||||
|
||||
@@ -157,13 +157,6 @@
|
||||
<item name="android:gravity">start</item>
|
||||
</style>
|
||||
|
||||
<style name="bt_item_label">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:textAlignment">viewStart</item>
|
||||
</style>
|
||||
|
||||
<style name="bt_item_edit_content">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
|
||||
@@ -138,7 +138,7 @@
|
||||
android:key="picture_in_picture"
|
||||
android:title="@string/picture_in_picture_app_detail_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.applications.appinfo.PictureInPictureDetailPreferenceController" />
|
||||
settings:controller="com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetailPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="install_other_apps"
|
||||
|
||||
@@ -14,13 +14,17 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/data_saver_title">
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="data_saver_screen"
|
||||
android:title="@string/data_saver_title">
|
||||
|
||||
<Preference
|
||||
android:key="unrestricted_access"
|
||||
android:title="@string/unrestricted_data_saver"
|
||||
android:summary="@string/summary_two_lines_placeholder"
|
||||
android:fragment="com.android.settings.datausage.UnrestrictedDataAccess" />
|
||||
android:fragment="com.android.settings.datausage.UnrestrictedDataAccess"
|
||||
settings:controller="com.android.settings.applications.specialaccess.DataSaverController" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<Preference
|
||||
android:key="auto_brightness_entry"
|
||||
android:title="@string/auto_brightness_title"
|
||||
android:summary="@string/auto_brightness_summary"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.display.AutoBrightnessSettings"
|
||||
settings:controller="com.android.settings.display.AutoBrightnessPreferenceController" />
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
settings:useAdminDisabledSummary="true" />
|
||||
|
||||
<com.android.settingslib.RestrictedSwitchPreference
|
||||
android:key="airplane_mode"
|
||||
android:key="toggle_airplane"
|
||||
android:title="@string/airplane_mode"
|
||||
android:icon="@drawable/ic_airplanemode_active"
|
||||
android:disableDependentsState="true"
|
||||
|
||||
@@ -17,4 +17,7 @@
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/picture_in_picture_title" />
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="picture_in_picture_screen"
|
||||
android:title="@string/picture_in_picture_title"
|
||||
settings:controller="com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureScreenPreferenceController" />
|
||||
|
||||
@@ -17,4 +17,7 @@
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/premium_sms_access" />
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="premium_sms_screen"
|
||||
android:title="@string/premium_sms_access"
|
||||
settings:controller="com.android.settings.applications.specialaccess.premiumsms.PremiumSmsScreenPreferenceController" />
|
||||
|
||||
@@ -73,15 +73,15 @@
|
||||
<Preference
|
||||
android:key="picture_in_picture"
|
||||
android:title="@string/picture_in_picture_title"
|
||||
android:fragment="com.android.settings.applications.appinfo.PictureInPictureSettings"
|
||||
android:fragment="com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureSettings"
|
||||
settings:keywords="@string/picture_in_picture_keywords"
|
||||
settings:controller="com.android.settings.applications.specialaccess.PictureInPictureController" />
|
||||
settings:controller="com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureController" />
|
||||
|
||||
<Preference
|
||||
android:key="premium_sms"
|
||||
android:title="@string/premium_sms_access"
|
||||
android:fragment="com.android.settings.applications.PremiumSmsAccess"
|
||||
settings:controller="com.android.settings.applications.specialaccess.PremiumSmsController" />
|
||||
android:fragment="com.android.settings.applications.specialaccess.premiumsms.PremiumSmsAccess"
|
||||
settings:controller="com.android.settings.applications.specialaccess.premiumsms.PremiumSmsController" />
|
||||
|
||||
<Preference
|
||||
android:key="data_saver"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="unrestricted_data"
|
||||
android:key="unrestricted_data_screen"
|
||||
android:title="@string/unrestricted_data_saver"
|
||||
settings:controller="com.android.settings.datausage.UnrestrictedDataAccessPreferenceController">
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:key="zen_access_screen"
|
||||
android:title="@string/manage_zen_access_title" />
|
||||
|
||||
@@ -44,6 +44,8 @@ import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.applications.manageapplications.ManageApplications;
|
||||
import com.android.settings.applications.specialaccess.pictureinpicture
|
||||
.PictureInPictureDetailPreferenceController;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
@@ -281,7 +283,7 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
mAppEntry = appEntry;
|
||||
}
|
||||
|
||||
PackageInfo getPackageInfo() {
|
||||
public PackageInfo getPackageInfo() {
|
||||
return mPackageInfo;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class DataSaverController extends BasePreferenceController {
|
||||
@AvailabilityStatus
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_data_saver)
|
||||
? AVAILABLE
|
||||
? AVAILABLE_UNSEARCHABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class ZenAccessController extends BasePreferenceController {
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return !ActivityManager.isLowRamDeviceStatic()
|
||||
? AVAILABLE
|
||||
? AVAILABLE_UNSEARCHABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications.specialaccess;
|
||||
package com.android.settings.applications.specialaccess.pictureinpicture;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
@@ -30,7 +30,7 @@ public class PictureInPictureController extends BasePreferenceController {
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return !ActivityManager.isLowRamDeviceStatic()
|
||||
? AVAILABLE
|
||||
? AVAILABLE_UNSEARCHABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
* Copyright (C) 2018 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.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications.appinfo;
|
||||
package com.android.settings.applications.specialaccess.pictureinpicture;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
@@ -23,6 +23,7 @@ import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.applications.appinfo.AppInfoPreferenceControllerBase;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.settings.applications.appinfo;
|
||||
package com.android.settings.applications.specialaccess.pictureinpicture;
|
||||
|
||||
import static android.app.AppOpsManager.MODE_ALLOWED;
|
||||
import static android.app.AppOpsManager.MODE_ERRORED;
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications.specialaccess.pictureinpicture;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
public class PictureInPictureScreenPreferenceController extends BasePreferenceController {
|
||||
|
||||
public PictureInPictureScreenPreferenceController(Context context,
|
||||
String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return !ActivityManager.isLowRamDeviceStatic()
|
||||
? AVAILABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.settings.applications.appinfo;
|
||||
package com.android.settings.applications.specialaccess.pictureinpicture;
|
||||
|
||||
import static android.content.pm.PackageManager.GET_ACTIVITIES;
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.content.pm.UserInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.util.IconDrawableFactory;
|
||||
import android.util.Pair;
|
||||
import android.view.View;
|
||||
@@ -35,8 +36,11 @@ import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.AppInfoBase;
|
||||
import com.android.settings.notification.EmptyTextSettings;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.widget.AppPreference;
|
||||
import com.android.settings.widget.EmptyTextSettings;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
@@ -48,11 +52,12 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.Preference.OnPreferenceClickListener;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
@SearchIndexable
|
||||
public class PictureInPictureSettings extends EmptyTextSettings {
|
||||
|
||||
private static final String TAG = PictureInPictureSettings.class.getSimpleName();
|
||||
@VisibleForTesting
|
||||
static final List<String> IGNORE_PACKAGE_LIST = new ArrayList<>();
|
||||
|
||||
static {
|
||||
IGNORE_PACKAGE_LIST.add("com.android.systemui");
|
||||
}
|
||||
@@ -72,9 +77,9 @@ public class PictureInPictureSettings extends EmptyTextSettings {
|
||||
|
||||
public final int compare(Pair<ApplicationInfo, Integer> a,
|
||||
Pair<ApplicationInfo, Integer> b) {
|
||||
CharSequence sa = a.first.loadLabel(mPm);
|
||||
CharSequence sa = a.first.loadLabel(mPm);
|
||||
if (sa == null) sa = a.first.name;
|
||||
CharSequence sb = b.first.loadLabel(mPm);
|
||||
CharSequence sb = b.first.loadLabel(mPm);
|
||||
if (sb == null) sb = b.first.name;
|
||||
int nameCmp = mCollator.compare(sa.toString(), sb.toString());
|
||||
if (nameCmp != 0) {
|
||||
@@ -92,7 +97,7 @@ public class PictureInPictureSettings extends EmptyTextSettings {
|
||||
|
||||
/**
|
||||
* @return true if the package has any activities that declare that they support
|
||||
* picture-in-picture.
|
||||
* picture-in-picture.
|
||||
*/
|
||||
|
||||
public static boolean checkPackageHasPictureInPictureActivities(String packageName,
|
||||
@@ -192,7 +197,7 @@ public class PictureInPictureSettings extends EmptyTextSettings {
|
||||
|
||||
/**
|
||||
* @return the list of applications for the given user and all their profiles that have
|
||||
* activities which support PiP.
|
||||
* activities which support PiP.
|
||||
*/
|
||||
ArrayList<Pair<ApplicationInfo, Integer>> collectPipApps(int userId) {
|
||||
final ArrayList<Pair<ApplicationInfo, Integer>> pipApps = new ArrayList<>();
|
||||
@@ -213,4 +218,18 @@ public class PictureInPictureSettings extends EmptyTextSettings {
|
||||
}
|
||||
return pipApps;
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.picture_in_picture_settings;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,23 +1,26 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications;
|
||||
package com.android.settings.applications.specialaccess.premiumsms;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
@@ -25,16 +28,21 @@ import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.internal.telephony.SmsUsageMonitor;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.AppStateBaseBridge.Callback;
|
||||
import com.android.settings.applications.AppStateSmsPremBridge;
|
||||
import com.android.settings.applications.AppStateSmsPremBridge.SmsState;
|
||||
import com.android.settings.notification.EmptyTextSettings;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.widget.EmptyTextSettings;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||
import com.android.settingslib.applications.ApplicationsState.Callbacks;
|
||||
import com.android.settingslib.applications.ApplicationsState.Session;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.preference.DropDownPreference;
|
||||
import androidx.preference.Preference;
|
||||
@@ -42,7 +50,9 @@ import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
public class PremiumSmsAccess extends EmptyTextSettings implements Callback, Callbacks, OnPreferenceChangeListener {
|
||||
@SearchIndexable
|
||||
public class PremiumSmsAccess extends EmptyTextSettings
|
||||
implements Callback, Callbacks, OnPreferenceChangeListener {
|
||||
|
||||
private ApplicationsState mApplicationsState;
|
||||
private AppStateSmsPremBridge mSmsBackend;
|
||||
@@ -233,4 +243,18 @@ public class PremiumSmsAccess extends EmptyTextSettings implements Callback, Cal
|
||||
super.onBindViewHolder(holder);
|
||||
}
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.premium_sms_settings;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications.specialaccess;
|
||||
package com.android.settings.applications.specialaccess.premiumsms;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class PremiumSmsController extends BasePreferenceController {
|
||||
@AvailabilityStatus
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_premium_sms)
|
||||
? AVAILABLE
|
||||
? AVAILABLE_UNSEARCHABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications.specialaccess.premiumsms;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
public class PremiumSmsScreenPreferenceController extends BasePreferenceController {
|
||||
|
||||
public PremiumSmsScreenPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
@AvailabilityStatus
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_premium_sms)
|
||||
? AVAILABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
@@ -1,434 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2011 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.bluetooth;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settingslib.bluetooth.A2dpProfile;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothProfile;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||
import com.android.settingslib.bluetooth.MapProfile;
|
||||
import com.android.settingslib.bluetooth.PanProfile;
|
||||
import com.android.settingslib.bluetooth.PbapServerProfile;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
public final class DeviceProfilesSettings extends InstrumentedDialogFragment implements
|
||||
CachedBluetoothDevice.Callback, DialogInterface.OnClickListener, OnClickListener {
|
||||
private static final String TAG = "DeviceProfilesSettings";
|
||||
|
||||
public static final String ARG_DEVICE_ADDRESS = "device_address";
|
||||
|
||||
private static final String KEY_PROFILE_CONTAINER = "profile_container";
|
||||
private static final String KEY_UNPAIR = "unpair";
|
||||
private static final String KEY_PBAP_SERVER = "PBAP Server";
|
||||
@VisibleForTesting
|
||||
static final String HIGH_QUALITY_AUDIO_PREF_TAG = "A2dpProfileHighQualityAudio";
|
||||
|
||||
private CachedBluetoothDevice mCachedDevice;
|
||||
private LocalBluetoothManager mManager;
|
||||
private LocalBluetoothProfileManager mProfileManager;
|
||||
|
||||
private ViewGroup mProfileContainer;
|
||||
private TextView mProfileLabel;
|
||||
|
||||
private AlertDialog mDisconnectDialog;
|
||||
private boolean mProfileGroupIsRemoved;
|
||||
|
||||
private View mRootView;
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.DIALOG_BLUETOOTH_PAIRED_DEVICE_PROFILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mManager = Utils.getLocalBtManager(getActivity());
|
||||
CachedBluetoothDeviceManager deviceManager = mManager.getCachedDeviceManager();
|
||||
|
||||
String address = getArguments().getString(ARG_DEVICE_ADDRESS);
|
||||
BluetoothDevice remoteDevice = mManager.getBluetoothAdapter().getRemoteDevice(address);
|
||||
|
||||
mCachedDevice = deviceManager.findDevice(remoteDevice);
|
||||
if (mCachedDevice == null) {
|
||||
mCachedDevice = deviceManager.addDevice(mManager.getBluetoothAdapter(),
|
||||
mManager.getProfileManager(), remoteDevice);
|
||||
}
|
||||
mProfileManager = mManager.getProfileManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
mRootView = LayoutInflater.from(getContext()).inflate(R.layout.device_profiles_settings,
|
||||
null);
|
||||
mProfileContainer = (ViewGroup) mRootView.findViewById(R.id.profiles_section);
|
||||
mProfileLabel = (TextView) mRootView.findViewById(R.id.profiles_label);
|
||||
final EditText deviceName = (EditText) mRootView.findViewById(R.id.name);
|
||||
deviceName.setText(mCachedDevice.getName(), TextView.BufferType.EDITABLE);
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setView(mRootView)
|
||||
.setNeutralButton(R.string.forget, this)
|
||||
.setPositiveButton(R.string.okay, this)
|
||||
.setTitle(R.string.bluetooth_preference_paired_devices)
|
||||
.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_POSITIVE:
|
||||
EditText deviceName = (EditText) mRootView.findViewById(R.id.name);
|
||||
mCachedDevice.setName(deviceName.getText().toString());
|
||||
break;
|
||||
case DialogInterface.BUTTON_NEUTRAL:
|
||||
mCachedDevice.unpair();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mDisconnectDialog != null) {
|
||||
mDisconnectDialog.dismiss();
|
||||
mDisconnectDialog = null;
|
||||
}
|
||||
if (mCachedDevice != null) {
|
||||
mCachedDevice.unregisterCallback(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
mManager.setForegroundActivity(getActivity());
|
||||
if (mCachedDevice != null) {
|
||||
mCachedDevice.registerCallback(this);
|
||||
if (mCachedDevice.getBondState() == BluetoothDevice.BOND_NONE) {
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
addPreferencesForProfiles();
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
if (mCachedDevice != null) {
|
||||
mCachedDevice.unregisterCallback(this);
|
||||
}
|
||||
|
||||
mManager.setForegroundActivity(null);
|
||||
}
|
||||
|
||||
private void addPreferencesForProfiles() {
|
||||
mProfileContainer.removeAllViews();
|
||||
for (LocalBluetoothProfile profile : mCachedDevice.getConnectableProfiles()) {
|
||||
CheckBox pref = createProfilePreference(profile);
|
||||
// MAP and PBAP profiles would be added based on permission access
|
||||
if (!((profile instanceof PbapServerProfile) ||
|
||||
(profile instanceof MapProfile))) {
|
||||
mProfileContainer.addView(pref);
|
||||
}
|
||||
|
||||
if (profile instanceof A2dpProfile) {
|
||||
BluetoothDevice device = mCachedDevice.getDevice();
|
||||
A2dpProfile a2dpProfile = (A2dpProfile) profile;
|
||||
if (a2dpProfile.supportsHighQualityAudio(device)) {
|
||||
CheckBox highQualityPref = new CheckBox(getActivity());
|
||||
highQualityPref.setTag(HIGH_QUALITY_AUDIO_PREF_TAG);
|
||||
highQualityPref.setOnClickListener(v -> {
|
||||
a2dpProfile.setHighQualityAudioEnabled(device, highQualityPref.isChecked());
|
||||
});
|
||||
highQualityPref.setVisibility(View.GONE);
|
||||
mProfileContainer.addView(highQualityPref);
|
||||
}
|
||||
refreshProfilePreference(pref, profile);
|
||||
}
|
||||
}
|
||||
|
||||
final int pbapPermission = mCachedDevice.getPhonebookPermissionChoice();
|
||||
Log.d(TAG, "addPreferencesForProfiles: pbapPermission = " + pbapPermission);
|
||||
// Only provide PBAP cabability if the client device has requested PBAP.
|
||||
if (pbapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) {
|
||||
final PbapServerProfile psp = mManager.getProfileManager().getPbapProfile();
|
||||
CheckBox pbapPref = createProfilePreference(psp);
|
||||
mProfileContainer.addView(pbapPref);
|
||||
}
|
||||
|
||||
final MapProfile mapProfile = mManager.getProfileManager().getMapProfile();
|
||||
final int mapPermission = mCachedDevice.getMessagePermissionChoice();
|
||||
Log.d(TAG, "addPreferencesForProfiles: mapPermission = " + mapPermission);
|
||||
if (mapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) {
|
||||
CheckBox mapPreference = createProfilePreference(mapProfile);
|
||||
mProfileContainer.addView(mapPreference);
|
||||
}
|
||||
|
||||
showOrHideProfileGroup();
|
||||
}
|
||||
|
||||
private void showOrHideProfileGroup() {
|
||||
int numProfiles = mProfileContainer.getChildCount();
|
||||
if (!mProfileGroupIsRemoved && numProfiles == 0) {
|
||||
mProfileContainer.setVisibility(View.GONE);
|
||||
mProfileLabel.setVisibility(View.GONE);
|
||||
mProfileGroupIsRemoved = true;
|
||||
} else if (mProfileGroupIsRemoved && numProfiles != 0) {
|
||||
mProfileContainer.setVisibility(View.VISIBLE);
|
||||
mProfileLabel.setVisibility(View.VISIBLE);
|
||||
mProfileGroupIsRemoved = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a checkbox preference for the particular profile. The key will be
|
||||
* the profile's name.
|
||||
*
|
||||
* @param profile The profile for which the preference controls.
|
||||
* @return A preference that allows the user to choose whether this profile
|
||||
* will be connected to.
|
||||
*/
|
||||
private CheckBox createProfilePreference(LocalBluetoothProfile profile) {
|
||||
CheckBox pref = new CheckBox(getActivity());
|
||||
pref.setTag(profile.toString());
|
||||
pref.setText(profile.getNameResource(mCachedDevice.getDevice()));
|
||||
pref.setOnClickListener(this);
|
||||
|
||||
refreshProfilePreference(pref, profile);
|
||||
|
||||
return pref;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v instanceof CheckBox) {
|
||||
LocalBluetoothProfile prof = getProfileOf(v);
|
||||
onProfileClicked(prof, (CheckBox) v);
|
||||
}
|
||||
}
|
||||
|
||||
private void onProfileClicked(LocalBluetoothProfile profile, CheckBox profilePref) {
|
||||
BluetoothDevice device = mCachedDevice.getDevice();
|
||||
|
||||
if (!profilePref.isChecked()) {
|
||||
// Recheck it, until the dialog is done.
|
||||
profilePref.setChecked(true);
|
||||
askDisconnect(mManager.getForegroundActivity(), profile);
|
||||
} else {
|
||||
if (profile instanceof MapProfile) {
|
||||
mCachedDevice.setMessagePermissionChoice(BluetoothDevice.ACCESS_ALLOWED);
|
||||
}
|
||||
if (profile instanceof PbapServerProfile) {
|
||||
mCachedDevice.setPhonebookPermissionChoice(BluetoothDevice.ACCESS_ALLOWED);
|
||||
refreshProfilePreference(profilePref, profile);
|
||||
// PBAP server is not preffered profile and cannot initiate connection, so return
|
||||
return;
|
||||
}
|
||||
if (profile.isPreferred(device)) {
|
||||
// profile is preferred but not connected: disable auto-connect
|
||||
if (profile instanceof PanProfile) {
|
||||
mCachedDevice.connectProfile(profile);
|
||||
} else {
|
||||
profile.setPreferred(device, false);
|
||||
}
|
||||
} else {
|
||||
profile.setPreferred(device, true);
|
||||
mCachedDevice.connectProfile(profile);
|
||||
}
|
||||
refreshProfilePreference(profilePref, profile);
|
||||
}
|
||||
}
|
||||
|
||||
private void askDisconnect(Context context,
|
||||
final LocalBluetoothProfile profile) {
|
||||
// local reference for callback
|
||||
final CachedBluetoothDevice device = mCachedDevice;
|
||||
String name = device.getName();
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
name = context.getString(R.string.bluetooth_device);
|
||||
}
|
||||
|
||||
String profileName = context.getString(profile.getNameResource(device.getDevice()));
|
||||
|
||||
String title = context.getString(R.string.bluetooth_disable_profile_title);
|
||||
String message = context.getString(R.string.bluetooth_disable_profile_message,
|
||||
profileName, name);
|
||||
|
||||
DialogInterface.OnClickListener disconnectListener =
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
// Disconnect only when user has selected OK otherwise ignore
|
||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||
device.disconnect(profile);
|
||||
profile.setPreferred(device.getDevice(), false);
|
||||
if (profile instanceof MapProfile) {
|
||||
device.setMessagePermissionChoice(BluetoothDevice.ACCESS_REJECTED);
|
||||
}
|
||||
if (profile instanceof PbapServerProfile) {
|
||||
device.setPhonebookPermissionChoice(BluetoothDevice.ACCESS_REJECTED);
|
||||
}
|
||||
}
|
||||
refreshProfilePreference(findProfile(profile.toString()), profile);
|
||||
}
|
||||
};
|
||||
|
||||
mDisconnectDialog = Utils.showDisconnectDialog(context,
|
||||
mDisconnectDialog, disconnectListener, title, Html.fromHtml(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeviceAttributesChanged() {
|
||||
refresh();
|
||||
}
|
||||
|
||||
private void refresh() {
|
||||
final EditText deviceNameField = (EditText) mRootView.findViewById(R.id.name);
|
||||
if (deviceNameField != null) {
|
||||
deviceNameField.setText(mCachedDevice.getName());
|
||||
com.android.settings.Utils.setEditTextCursorPosition(deviceNameField);
|
||||
}
|
||||
|
||||
refreshProfiles();
|
||||
}
|
||||
|
||||
private void refreshProfiles() {
|
||||
for (LocalBluetoothProfile profile : mCachedDevice.getConnectableProfiles()) {
|
||||
CheckBox profilePref = findProfile(profile.toString());
|
||||
if (profilePref == null) {
|
||||
profilePref = createProfilePreference(profile);
|
||||
mProfileContainer.addView(profilePref);
|
||||
} else {
|
||||
refreshProfilePreference(profilePref, profile);
|
||||
}
|
||||
}
|
||||
for (LocalBluetoothProfile profile : mCachedDevice.getRemovedProfiles()) {
|
||||
CheckBox profilePref = findProfile(profile.toString());
|
||||
if (profilePref != null) {
|
||||
|
||||
if (profile instanceof PbapServerProfile) {
|
||||
final int pbapPermission = mCachedDevice.getPhonebookPermissionChoice();
|
||||
Log.d(TAG, "refreshProfiles: pbapPermission = " + pbapPermission);
|
||||
if (pbapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN)
|
||||
continue;
|
||||
}
|
||||
if (profile instanceof MapProfile) {
|
||||
final int mapPermission = mCachedDevice.getMessagePermissionChoice();
|
||||
Log.d(TAG, "refreshProfiles: mapPermission = " + mapPermission);
|
||||
if (mapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN)
|
||||
continue;
|
||||
}
|
||||
Log.d(TAG, "Removing " + profile.toString() + " from profile list");
|
||||
mProfileContainer.removeView(profilePref);
|
||||
}
|
||||
}
|
||||
|
||||
showOrHideProfileGroup();
|
||||
}
|
||||
|
||||
private CheckBox findProfile(String profile) {
|
||||
return (CheckBox) mProfileContainer.findViewWithTag(profile);
|
||||
}
|
||||
|
||||
private void refreshProfilePreference(CheckBox profilePref,
|
||||
LocalBluetoothProfile profile) {
|
||||
BluetoothDevice device = mCachedDevice.getDevice();
|
||||
|
||||
// Gray out checkbox while connecting and disconnecting.
|
||||
profilePref.setEnabled(!mCachedDevice.isBusy());
|
||||
|
||||
if (profile instanceof MapProfile) {
|
||||
profilePref.setChecked(mCachedDevice.getMessagePermissionChoice()
|
||||
== CachedBluetoothDevice.ACCESS_ALLOWED);
|
||||
|
||||
} else if (profile instanceof PbapServerProfile) {
|
||||
profilePref.setChecked(mCachedDevice.getPhonebookPermissionChoice()
|
||||
== CachedBluetoothDevice.ACCESS_ALLOWED);
|
||||
|
||||
} else if (profile instanceof PanProfile) {
|
||||
profilePref.setChecked(profile.getConnectionStatus(device) ==
|
||||
BluetoothProfile.STATE_CONNECTED);
|
||||
|
||||
} else {
|
||||
profilePref.setChecked(profile.isPreferred(device));
|
||||
}
|
||||
if (profile instanceof A2dpProfile) {
|
||||
A2dpProfile a2dpProfile = (A2dpProfile) profile;
|
||||
View v = mProfileContainer.findViewWithTag(HIGH_QUALITY_AUDIO_PREF_TAG);
|
||||
if (v instanceof CheckBox) {
|
||||
CheckBox highQualityPref = (CheckBox) v;
|
||||
highQualityPref.setText(a2dpProfile.getHighQualityAudioOptionLabel(device));
|
||||
highQualityPref.setChecked(a2dpProfile.isHighQualityAudioEnabled(device));
|
||||
|
||||
if (a2dpProfile.isPreferred(device)) {
|
||||
v.setVisibility(View.VISIBLE);
|
||||
v.setEnabled(!mCachedDevice.isBusy());
|
||||
} else {
|
||||
v.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private LocalBluetoothProfile getProfileOf(View v) {
|
||||
if (!(v instanceof CheckBox)) {
|
||||
return null;
|
||||
}
|
||||
String key = (String) v.getTag();
|
||||
if (TextUtils.isEmpty(key)) return null;
|
||||
|
||||
try {
|
||||
return mProfileManager.getProfileByName(key);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,14 +42,14 @@ import com.android.settings.applications.VrListenerSettings;
|
||||
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
|
||||
import com.android.settings.applications.appinfo.DrawOverlayDetails;
|
||||
import com.android.settings.applications.appinfo.ExternalSourcesDetails;
|
||||
import com.android.settings.applications.appinfo.PictureInPictureDetails;
|
||||
import com.android.settings.applications.appinfo.PictureInPictureSettings;
|
||||
import com.android.settings.applications.appinfo.WriteSettingsDetails;
|
||||
import com.android.settings.applications.appops.BackgroundCheckSummary;
|
||||
import com.android.settings.applications.assist.ManageAssist;
|
||||
import com.android.settings.applications.manageapplications.ManageApplications;
|
||||
import com.android.settings.applications.managedomainurls.ManageDomainUrls;
|
||||
import com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminSettings;
|
||||
import com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetails;
|
||||
import com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureSettings;
|
||||
import com.android.settings.backup.PrivacySettings;
|
||||
import com.android.settings.backup.ToggleBackupSettingFragment;
|
||||
import com.android.settings.bluetooth.BluetoothDeviceDetailsFragment;
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
package com.android.settings.datausage;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
@@ -24,17 +27,22 @@ import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.applications.AppStateBaseBridge.Callback;
|
||||
import com.android.settings.datausage.DataSaverBackend.Listener;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settings.widget.SwitchBar.OnSwitchChangeListener;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||
import com.android.settingslib.applications.ApplicationsState.Callbacks;
|
||||
import com.android.settingslib.applications.ApplicationsState.Session;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@SearchIndexable
|
||||
public class DataSaverSummary extends SettingsPreferenceFragment
|
||||
implements OnSwitchChangeListener, Listener, Callback, Callbacks {
|
||||
|
||||
@@ -94,7 +102,7 @@ public class DataSaverSummary extends SettingsPreferenceFragment
|
||||
|
||||
@Override
|
||||
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
||||
synchronized(this) {
|
||||
synchronized (this) {
|
||||
if (mSwitching) {
|
||||
return;
|
||||
}
|
||||
@@ -115,7 +123,7 @@ public class DataSaverSummary extends SettingsPreferenceFragment
|
||||
|
||||
@Override
|
||||
public void onDataSaverChanged(boolean isDataSaving) {
|
||||
synchronized(this) {
|
||||
synchronized (this) {
|
||||
mSwitchBar.setChecked(isDataSaving);
|
||||
mSwitching = false;
|
||||
}
|
||||
@@ -190,4 +198,25 @@ public class DataSaverSummary extends SettingsPreferenceFragment
|
||||
public void onLoadEntriesCompleted() {
|
||||
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.data_saver;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return DataUsageUtils.hasMobileData(context)
|
||||
&& DataUsageUtils.getDefaultSubscriptionId(context)
|
||||
!= SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -51,8 +51,7 @@ import androidx.preference.PreferenceScreen;
|
||||
* Settings preference fragment that displays data usage summary.
|
||||
*/
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
public class DataUsageSummary extends DataUsageBaseFragment implements Indexable,
|
||||
DataUsageEditController {
|
||||
public class DataUsageSummary extends DataUsageBaseFragment implements DataUsageEditController {
|
||||
|
||||
private static final String TAG = "DataUsageSummary";
|
||||
|
||||
@@ -379,6 +378,9 @@ public class DataUsageSummary extends DataUsageBaseFragment implements Indexable
|
||||
// This title is named Wifi, and will confuse users.
|
||||
keys.add(KEY_WIFI_USAGE_TITLE);
|
||||
|
||||
// Duplicate entry for "Data saver"
|
||||
keys.add(KEY_RESTRICT_BACKGROUND);
|
||||
|
||||
return keys;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.android.settings.datausage;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
@@ -24,9 +25,16 @@ import android.view.View;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.applications.ApplicationsState.AppFilter;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class UnrestrictedDataAccess extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "UnrestrictedDataAccess";
|
||||
@@ -108,4 +116,18 @@ public class UnrestrictedDataAccess extends DashboardFragment {
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.unrestricted_data_access_settings;
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.unrestricted_data_access_settings;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.os.UserHandle;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.AppStateBaseBridge;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
@@ -83,7 +84,9 @@ public class UnrestrictedDataAccessPreferenceController extends BasePreferenceCo
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_data_saver)
|
||||
? AVAILABLE_UNSEARCHABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -68,7 +68,7 @@ public class AmbientDisplayNotificationsPreferenceController extends
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return mConfig.pulseOnNotificationEnabled(MY_USER);
|
||||
return getAmbientConfig().pulseOnNotificationEnabled(MY_USER);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,14 +79,20 @@ public class AmbientDisplayNotificationsPreferenceController extends
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (mConfig == null) {
|
||||
mConfig = new AmbientDisplayConfiguration(mContext);
|
||||
}
|
||||
return mConfig.pulseOnNotificationAvailable() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
return getAmbientConfig().pulseOnNotificationAvailable()
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSliceable() {
|
||||
return TextUtils.equals(getPreferenceKey(), "ambient_display_notification");
|
||||
}
|
||||
|
||||
private AmbientDisplayConfiguration getAmbientConfig() {
|
||||
if (mConfig == null) {
|
||||
mConfig = new AmbientDisplayConfiguration(mContext);
|
||||
}
|
||||
|
||||
return mConfig;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
|
||||
@@ -59,4 +60,11 @@ public class AutoBrightnessPreferenceController extends TogglePreferenceControll
|
||||
public boolean isSliceable() {
|
||||
return TextUtils.equals(getPreferenceKey(), "auto_brightness");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return mContext.getText(isChecked()
|
||||
? R.string.auto_brightness_summary_on
|
||||
: R.string.auto_brightness_summary_off);
|
||||
}
|
||||
}
|
||||
@@ -62,17 +62,13 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (mAmbientConfig == null) {
|
||||
mAmbientConfig = new AmbientDisplayConfiguration(mContext);
|
||||
}
|
||||
|
||||
// No hardware support for Pickup Gesture
|
||||
if (!mAmbientConfig.dozePulsePickupSensorAvailable()) {
|
||||
if (!getAmbientConfig().dozePulsePickupSensorAvailable()) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
// Can't change Pickup Gesture when AOD is enabled.
|
||||
if (!mAmbientConfig.ambientDisplayAvailable()) {
|
||||
if (!getAmbientConfig().ambientDisplayAvailable()) {
|
||||
return DISABLED_DEPENDENT_SETTING;
|
||||
}
|
||||
|
||||
@@ -91,7 +87,7 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return mAmbientConfig.pulseOnPickupEnabled(mUserId);
|
||||
return getAmbientConfig().pulseOnPickupEnabled(mUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,6 +108,14 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll
|
||||
|
||||
@VisibleForTesting
|
||||
boolean pulseOnPickupCanBeModified() {
|
||||
return mAmbientConfig.pulseOnPickupCanBeModified(mUserId);
|
||||
return getAmbientConfig().pulseOnPickupCanBeModified(mUserId);
|
||||
}
|
||||
|
||||
private AmbientDisplayConfiguration getAmbientConfig() {
|
||||
if (mAmbientConfig == null) {
|
||||
mAmbientConfig = new AmbientDisplayConfiguration(mContext);
|
||||
}
|
||||
|
||||
return mAmbientConfig;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings.Secure;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArraySet;
|
||||
@@ -47,7 +48,11 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.widget.AppSwitchPreference;
|
||||
import com.android.settings.widget.EmptyTextSettings;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -58,6 +63,7 @@ import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
@SearchIndexable
|
||||
public class ZenAccessSettings extends EmptyTextSettings {
|
||||
private final String TAG = "ZenAccessSettings";
|
||||
|
||||
@@ -336,4 +342,18 @@ public class ZenAccessSettings extends EmptyTextSettings {
|
||||
.create();
|
||||
}
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.zen_access_settings;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settings.notification.EmptyTextSettings;
|
||||
import com.android.settings.widget.AppSwitchPreference;
|
||||
import com.android.settings.widget.EmptyTextSettings;
|
||||
import com.android.settingslib.applications.ServiceListing;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.notification;
|
||||
package com.android.settings.widget;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.os.Bundle;
|
||||
@@ -104,7 +104,7 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
|
||||
// 3: With Dual mode support we can't have AP_BAND_5GHZ - default to ANY
|
||||
if (!isDualMode && WifiConfiguration.AP_BAND_ANY == band) {
|
||||
return WifiConfiguration.AP_BAND_5GHZ;
|
||||
} else if (!mWifiManager.is5GHzBandSupported() && WifiConfiguration.AP_BAND_5GHZ == band) {
|
||||
} else if (!is5GhzBandSupported() && WifiConfiguration.AP_BAND_5GHZ == band) {
|
||||
return WifiConfiguration.AP_BAND_2GHZ;
|
||||
} else if (isDualMode && WifiConfiguration.AP_BAND_5GHZ == band) {
|
||||
return WifiConfiguration.AP_BAND_ANY;
|
||||
|
||||
@@ -13,18 +13,16 @@ com.android.settings.accounts.ManagedProfileSettings
|
||||
com.android.settings.applications.appinfo.AppInfoDashboardFragment
|
||||
com.android.settings.applications.appinfo.DrawOverlayDetails
|
||||
com.android.settings.applications.appinfo.ExternalSourcesDetails
|
||||
com.android.settings.applications.appinfo.PictureInPictureDetails
|
||||
com.android.settings.applications.appinfo.PictureInPictureSettings
|
||||
com.android.settings.applications.appinfo.WriteSettingsDetails
|
||||
com.android.settings.applications.AppLaunchSettings
|
||||
com.android.settings.applications.AppStorageSettings
|
||||
com.android.settings.applications.ConfirmConvertToFbe
|
||||
com.android.settings.applications.DirectoryAccessDetails
|
||||
com.android.settings.applications.PremiumSmsAccess
|
||||
com.android.settings.applications.ProcessStatsDetail
|
||||
com.android.settings.applications.ProcessStatsSummary
|
||||
com.android.settings.applications.ProcessStatsUi
|
||||
com.android.settings.applications.RunningServices
|
||||
com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetails
|
||||
com.android.settings.applications.UsageAccessDetails
|
||||
com.android.settings.applications.VrListenerSettings
|
||||
com.android.settings.backup.ToggleBackupSettingFragment
|
||||
@@ -34,9 +32,7 @@ com.android.settings.bluetooth.BluetoothPairingDetail
|
||||
com.android.settings.bluetooth.DevicePickerFragment
|
||||
com.android.settings.datausage.AppDataUsage
|
||||
com.android.settings.datausage.BillingCycleSettings
|
||||
com.android.settings.datausage.DataSaverSummary
|
||||
com.android.settings.datausage.DataUsageList
|
||||
com.android.settings.datausage.UnrestrictedDataAccess
|
||||
com.android.settings.datetime.timezone.TimeZoneSettings
|
||||
com.android.settings.development.featureflags.FeatureFlagsDashboard
|
||||
com.android.settings.development.qstile.DevelopmentTileConfigFragment
|
||||
@@ -67,7 +63,6 @@ com.android.settings.notification.ChannelNotificationSettings
|
||||
com.android.settings.notification.NotificationAccessSettings
|
||||
com.android.settings.notification.NotificationStation
|
||||
com.android.settings.notification.RedactionInterstitial$RedactionInterstitialFragment
|
||||
com.android.settings.notification.ZenAccessSettings
|
||||
com.android.settings.notification.ZenModeEventRuleSettings
|
||||
com.android.settings.notification.ZenModeScheduleRuleSettings
|
||||
com.android.settings.password.ChooseLockGeneric$ChooseLockGenericFragment
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications.appinfo;
|
||||
package com.android.settings.applications.specialaccess.pictureinpicture;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.when;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
* 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
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications.appinfo;
|
||||
package com.android.settings.applications.specialaccess.pictureinpicture;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
@@ -11,10 +11,10 @@
|
||||
* 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
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications.appinfo;
|
||||
package com.android.settings.applications.specialaccess.pictureinpicture;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
@@ -11,10 +11,10 @@
|
||||
* 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
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications;
|
||||
package com.android.settings.applications.specialaccess.premiumsms;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
import static org.mockito.Matchers.eq;
|
||||
@@ -24,6 +24,7 @@ import android.content.Context;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.internal.telephony.SmsUsageMonitor;
|
||||
import com.android.settings.applications.specialaccess.premiumsms.PremiumSmsAccess;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications.specialaccess;
|
||||
package com.android.settings.applications.specialaccess.premiumsms;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
@@ -44,13 +45,13 @@ public class PremiumSmsControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPremiumSms_byDefault_shouldBeShown() {
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
public void getAvailability_byDefault_shouldBeShown() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(qualifiers = "mcc999")
|
||||
public void testPremiumSms_ifDisabled_shouldNotBeShown() {
|
||||
public void getAvailability_disabled_returnUnavailable() {
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications.specialaccess.premiumsms;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public class PremiumSmsScreenPreferenceControllerTest {
|
||||
|
||||
private Context mContext;
|
||||
private PremiumSmsScreenPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
|
||||
mController = new PremiumSmsScreenPreferenceController(mContext, "key");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailability_byDefault_shouldBeShown() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(qualifiers = "mcc999")
|
||||
public void getAvailability_disabled_returnUnavailable() {
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -1,204 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.bluetooth;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settingslib.R;
|
||||
import com.android.settingslib.bluetooth.A2dpProfile;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothProfile;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.util.FragmentTestUtil;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public class DeviceProfilesSettingsTest {
|
||||
|
||||
@Mock
|
||||
private LocalBluetoothManager mManager;
|
||||
@Mock
|
||||
private LocalBluetoothAdapter mAdapter;
|
||||
@Mock
|
||||
private LocalBluetoothProfileManager mProfileManager;
|
||||
@Mock
|
||||
private CachedBluetoothDeviceManager mDeviceManager;
|
||||
@Mock
|
||||
private CachedBluetoothDevice mCachedDevice;
|
||||
@Mock
|
||||
private A2dpProfile mProfile;
|
||||
|
||||
private DeviceProfilesSettings mFragment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
when(mProfile.getNameResource(any())).thenReturn(R.string.bluetooth_profile_a2dp);
|
||||
List<LocalBluetoothProfile> profiles = new ArrayList<>();
|
||||
profiles.add(mProfile);
|
||||
when(mCachedDevice.getConnectableProfiles()).thenReturn(profiles);
|
||||
|
||||
mFragment = new DeviceProfilesSettings();
|
||||
mFragment.setArguments(new Bundle());
|
||||
|
||||
ReflectionHelpers.setStaticField(LocalBluetoothManager.class, "sInstance", mManager);
|
||||
when(mManager.getCachedDeviceManager()).thenReturn(mDeviceManager);
|
||||
when(mManager.getBluetoothAdapter()).thenReturn(mAdapter);
|
||||
when(mManager.getProfileManager()).thenReturn(mProfileManager);
|
||||
when(mProfileManager.getMapProfile()).thenReturn(null);
|
||||
when(mDeviceManager.findDevice(any())).thenReturn(mCachedDevice);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
ReflectionHelpers.setStaticField(LocalBluetoothManager.class, "sInstance", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deviceHasHighQualityAudio() {
|
||||
when(mProfile.supportsHighQualityAudio(any())).thenReturn(true);
|
||||
when(mProfile.isHighQualityAudioEnabled(any())).thenReturn(true);
|
||||
when(mProfile.isPreferred(any())).thenReturn(true);
|
||||
FragmentTestUtil.startFragment(mFragment);
|
||||
|
||||
ViewGroup profilesGroup = mFragment.getDialog().findViewById(R.id.profiles_section);
|
||||
CheckBox box =
|
||||
profilesGroup.findViewWithTag(DeviceProfilesSettings.HIGH_QUALITY_AUDIO_PREF_TAG);
|
||||
assertThat(box).isNotNull();
|
||||
assertThat(box.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(box.isEnabled()).isTrue();
|
||||
assertThat(box.isChecked()).isTrue();
|
||||
|
||||
box.performClick();
|
||||
verify(mProfile).setHighQualityAudioEnabled(any(), eq(false));
|
||||
box.performClick();
|
||||
verify(mProfile).setHighQualityAudioEnabled(any(), eq(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void busyDeviceDisablesControl() {
|
||||
when(mProfile.supportsHighQualityAudio(any())).thenReturn(true);
|
||||
when(mProfile.isHighQualityAudioEnabled(any())).thenReturn(true);
|
||||
when(mProfile.isPreferred(any())).thenReturn(true);
|
||||
when(mCachedDevice.isBusy()).thenReturn(true);
|
||||
FragmentTestUtil.startFragment(mFragment);
|
||||
|
||||
// Make sure that the high quality audio option is present but disabled when the device
|
||||
// is busy.
|
||||
ViewGroup profilesGroup = mFragment.getDialog().findViewById(R.id.profiles_section);
|
||||
CheckBox box =
|
||||
profilesGroup.findViewWithTag(DeviceProfilesSettings.HIGH_QUALITY_AUDIO_PREF_TAG);
|
||||
assertThat(box).isNotNull();
|
||||
assertThat(box.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(box.isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mediaAudioGetsDisabledAndReEnabled() {
|
||||
when(mProfile.supportsHighQualityAudio(any())).thenReturn(true);
|
||||
when(mProfile.isHighQualityAudioEnabled(any())).thenReturn(true);
|
||||
when(mProfile.isPreferred(any())).thenReturn(true);
|
||||
FragmentTestUtil.startFragment(mFragment);
|
||||
|
||||
ViewGroup profilesGroup = mFragment.getDialog().findViewById(R.id.profiles_section);
|
||||
CheckBox audioBox = profilesGroup.findViewWithTag(mProfile.toString());
|
||||
CheckBox highQualityAudioBox =
|
||||
profilesGroup.findViewWithTag(DeviceProfilesSettings.HIGH_QUALITY_AUDIO_PREF_TAG);
|
||||
assertThat(audioBox).isNotNull();
|
||||
assertThat(audioBox.isChecked()).isTrue();
|
||||
assertThat(highQualityAudioBox).isNotNull();
|
||||
assertThat(highQualityAudioBox.isChecked()).isTrue();
|
||||
|
||||
// Disabling media audio should cause the high quality audio box to disappear.
|
||||
when(mProfile.isPreferred(any())).thenReturn(false);
|
||||
mFragment.onDeviceAttributesChanged();
|
||||
audioBox = profilesGroup.findViewWithTag(mProfile.toString());
|
||||
highQualityAudioBox =
|
||||
profilesGroup.findViewWithTag(DeviceProfilesSettings.HIGH_QUALITY_AUDIO_PREF_TAG);
|
||||
assertThat(audioBox).isNotNull();
|
||||
assertThat(audioBox.isChecked()).isFalse();
|
||||
assertThat(highQualityAudioBox).isNotNull();
|
||||
assertThat(highQualityAudioBox.getVisibility()).isEqualTo(View.GONE);
|
||||
|
||||
// And re-enabling media audio should make it reappear.
|
||||
when(mProfile.isPreferred(any())).thenReturn(true);
|
||||
mFragment.onDeviceAttributesChanged();
|
||||
audioBox = profilesGroup.findViewWithTag(mProfile.toString());
|
||||
highQualityAudioBox =
|
||||
profilesGroup.findViewWithTag(DeviceProfilesSettings.HIGH_QUALITY_AUDIO_PREF_TAG);
|
||||
assertThat(audioBox).isNotNull();
|
||||
assertThat(audioBox.isChecked()).isTrue();
|
||||
assertThat(highQualityAudioBox).isNotNull();
|
||||
assertThat(highQualityAudioBox.isChecked()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mediaAudioStartsDisabled() {
|
||||
when(mProfile.supportsHighQualityAudio(any())).thenReturn(true);
|
||||
when(mProfile.isHighQualityAudioEnabled(any())).thenReturn(true);
|
||||
when(mProfile.isPreferred(any())).thenReturn(false);
|
||||
|
||||
FragmentTestUtil.startFragment(mFragment);
|
||||
ViewGroup profilesGroup = mFragment.getDialog().findViewById(R.id.profiles_section);
|
||||
CheckBox audioBox = profilesGroup.findViewWithTag(mProfile.toString());
|
||||
CheckBox highQualityAudioBox =
|
||||
profilesGroup.findViewWithTag(DeviceProfilesSettings.HIGH_QUALITY_AUDIO_PREF_TAG);
|
||||
|
||||
assertThat(audioBox).isNotNull();
|
||||
assertThat(audioBox.isChecked()).isFalse();
|
||||
assertThat(highQualityAudioBox).isNotNull();
|
||||
assertThat(highQualityAudioBox.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deviceDoesntHaveHighQualityAudio() {
|
||||
when(mProfile.supportsHighQualityAudio(any())).thenReturn(false);
|
||||
when(mProfile.isPreferred(any())).thenReturn(true);
|
||||
FragmentTestUtil.startFragment(mFragment);
|
||||
|
||||
// A device that doesn't support high quality audio shouldn't have the checkbox for
|
||||
// high quality audio support.
|
||||
ViewGroup profilesGroup = mFragment.getDialog().findViewById(R.id.profiles_section);
|
||||
CheckBox box =
|
||||
profilesGroup.findViewWithTag(DeviceProfilesSettings.HIGH_QUALITY_AUDIO_PREF_TAG);
|
||||
assertThat(box).isNull();
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -52,50 +53,68 @@ public class AutoBrightnessPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnPreferenceChange_TurnOnAuto_ReturnAuto() {
|
||||
public void onPreferenceChange_TurnOnAuto_ReturnAuto() {
|
||||
mController.onPreferenceChange(null, true);
|
||||
|
||||
final int mode = Settings.System.getInt(mContentResolver, SCREEN_BRIGHTNESS_MODE,
|
||||
SCREEN_BRIGHTNESS_MODE_MANUAL);
|
||||
SCREEN_BRIGHTNESS_MODE_MANUAL);
|
||||
assertThat(mode).isEqualTo(SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnPreferenceChange_TurnOffAuto_ReturnManual() {
|
||||
public void onPreferenceChange_TurnOffAuto_ReturnManual() {
|
||||
mController.onPreferenceChange(null, false);
|
||||
|
||||
final int mode = Settings.System.getInt(mContentResolver, SCREEN_BRIGHTNESS_MODE,
|
||||
SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
|
||||
SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
|
||||
assertThat(mode).isEqualTo(SCREEN_BRIGHTNESS_MODE_MANUAL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetValue_updatesCorrectly() {
|
||||
boolean newValue = true;
|
||||
Settings.System.putInt(mContentResolver, SCREEN_BRIGHTNESS_MODE,
|
||||
SCREEN_BRIGHTNESS_MODE_MANUAL);
|
||||
public void setChecked_updatesCorrectly() {
|
||||
mController.setChecked(true);
|
||||
|
||||
mController.setChecked(newValue);
|
||||
boolean updatedValue = Settings.System.getInt(mContentResolver, SCREEN_BRIGHTNESS_MODE, -1)
|
||||
!= SCREEN_BRIGHTNESS_MODE_MANUAL;
|
||||
assertThat(mController.isChecked()).isTrue();
|
||||
|
||||
assertThat(updatedValue).isEqualTo(newValue);
|
||||
mController.setChecked(false);
|
||||
|
||||
assertThat(mController.isChecked()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetValue_correctValueReturned() {
|
||||
public void isChecked_no() {
|
||||
Settings.System.putInt(mContentResolver, SCREEN_BRIGHTNESS_MODE,
|
||||
SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
|
||||
SCREEN_BRIGHTNESS_MODE_MANUAL);
|
||||
|
||||
int newValue = mController.isChecked() ?
|
||||
SCREEN_BRIGHTNESS_MODE_AUTOMATIC
|
||||
: SCREEN_BRIGHTNESS_MODE_MANUAL;
|
||||
|
||||
assertThat(newValue).isEqualTo(SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
|
||||
assertThat(mController.isChecked()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSliceableCorrectKey_returnsTrue() {
|
||||
public void isChecked_yes() {
|
||||
Settings.System.putInt(mContentResolver, SCREEN_BRIGHTNESS_MODE,
|
||||
SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
|
||||
|
||||
assertThat(mController.isChecked()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_settingOn_shouldReturnOnSummary() {
|
||||
mController.setChecked(true);
|
||||
|
||||
assertThat(mController.getSummary())
|
||||
.isEqualTo(mContext.getText(R.string.auto_brightness_summary_on));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_settingOff_shouldReturnOffSummary() {
|
||||
mController.setChecked(false);
|
||||
|
||||
assertThat(mController.getSummary())
|
||||
.isEqualTo(mContext.getText(R.string.auto_brightness_summary_off));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSliceable_correctKey_returnsTrue() {
|
||||
final AutoBrightnessPreferenceController controller =
|
||||
new AutoBrightnessPreferenceController(mContext,
|
||||
"auto_brightness");
|
||||
@@ -103,7 +122,7 @@ public class AutoBrightnessPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSliceableIncorrectKey_returnsFalse() {
|
||||
public void isSliceable_incorrectKey_returnsFalse() {
|
||||
final AutoBrightnessPreferenceController controller =
|
||||
new AutoBrightnessPreferenceController(mContext, "bad_key");
|
||||
assertThat(controller.isSliceable()).isFalse();
|
||||
|
||||
@@ -105,6 +105,7 @@ public class WifiTetherApBandPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void display_5GhzNotSupported_shouldDisable() {
|
||||
when(mWifiManager.getCountryCode()).thenReturn("US");
|
||||
when(mWifiManager.isDualBandSupported()).thenReturn(false);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
@@ -116,7 +117,8 @@ public class WifiTetherApBandPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void changePreference_noDualModeWith5G_shouldUpdateValue() {
|
||||
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
|
||||
when(mWifiManager.getCountryCode()).thenReturn("US");
|
||||
when(mWifiManager.isDualBandSupported()).thenReturn(true);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
@@ -142,7 +144,8 @@ public class WifiTetherApBandPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void changePreference_dualModeWith5G_shouldUpdateValue() {
|
||||
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
|
||||
when(mWifiManager.getCountryCode()).thenReturn("US");
|
||||
when(mWifiManager.isDualBandSupported()).thenReturn(true);
|
||||
when(mWifiManager.isDualModeSupported()).thenReturn(true);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
@@ -168,14 +171,16 @@ public class WifiTetherApBandPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void updateDisplay_shouldUpdateValue() {
|
||||
when(mWifiManager.getCountryCode()).thenReturn("US");
|
||||
when(mWifiManager.isDualBandSupported()).thenReturn(true);
|
||||
|
||||
// Set controller band index to 1 and verify is set.
|
||||
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
|
||||
mController.displayPreference(mScreen);
|
||||
mController.onPreferenceChange(mPreference, "1");
|
||||
assertThat(mController.getBandIndex()).isEqualTo(1);
|
||||
|
||||
// Disable 5Ghz band
|
||||
when(mWifiManager.is5GHzBandSupported()).thenReturn(false);
|
||||
when(mWifiManager.isDualBandSupported()).thenReturn(false);
|
||||
|
||||
// Call updateDisplay and verify it's changed.
|
||||
mController.updateDisplay();
|
||||
|
||||
Reference in New Issue
Block a user