Snap for 4628106 from e00a14b14c to pi-release
Change-Id: Ic6cf6a44c4f7196ae176336b2b1441db88d74dd6
This commit is contained in:
@@ -313,7 +313,8 @@
|
|||||||
|
|
||||||
<!-- Bluetooth developer settings: Titles for maximum number of connected audio devices -->
|
<!-- Bluetooth developer settings: Titles for maximum number of connected audio devices -->
|
||||||
<string-array name="bluetooth_max_connected_audio_devices">
|
<string-array name="bluetooth_max_connected_audio_devices">
|
||||||
<item>1 (Default)</item>
|
<item>Use System Default: <xliff:g id="default_bluetooth_max_connected_audio_devices">%1$d</xliff:g></item>
|
||||||
|
<item>1</item>
|
||||||
<item>2</item>
|
<item>2</item>
|
||||||
<item>3</item>
|
<item>3</item>
|
||||||
<item>4</item>
|
<item>4</item>
|
||||||
@@ -321,7 +322,8 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<!-- Bluetooth developer settings: Values for maximum number of connected audio devices -->
|
<!-- Bluetooth developer settings: Values for maximum number of connected audio devices -->
|
||||||
<string-array name="bluetooth_max_connected_audio_devices_values">
|
<string-array translatable="false" name="bluetooth_max_connected_audio_devices_values">
|
||||||
|
<item></item>
|
||||||
<item>1</item>
|
<item>1</item>
|
||||||
<item>2</item>
|
<item>2</item>
|
||||||
<item>3</item>
|
<item>3</item>
|
||||||
|
|||||||
@@ -3371,6 +3371,8 @@
|
|||||||
<string name="location_app_level_permissions">App-level permissions</string>
|
<string name="location_app_level_permissions">App-level permissions</string>
|
||||||
<!-- [CHAR LIMIT=42] Location settings screen, sub category for recent location requests -->
|
<!-- [CHAR LIMIT=42] Location settings screen, sub category for recent location requests -->
|
||||||
<string name="location_category_recent_location_requests">Recent location requests</string>
|
<string name="location_category_recent_location_requests">Recent location requests</string>
|
||||||
|
<!-- Location settings screen, displayed when there're more than three recent location requests -->
|
||||||
|
<string name="location_recent_location_requests_see_all">See all</string>
|
||||||
<!-- Location settings screen, displayed when there's no recent app accessing location -->
|
<!-- Location settings screen, displayed when there's no recent app accessing location -->
|
||||||
<string name="location_no_recent_apps">No apps have requested location recently</string>
|
<string name="location_no_recent_apps">No apps have requested location recently</string>
|
||||||
<!-- [CHAR LIMIT=30] Location settings screen, sub category for location services -->
|
<!-- [CHAR LIMIT=30] Location settings screen, sub category for location services -->
|
||||||
|
|||||||
@@ -55,7 +55,8 @@
|
|||||||
android:key="manage_perms"
|
android:key="manage_perms"
|
||||||
android:title="@string/app_permissions"
|
android:title="@string/app_permissions"
|
||||||
android:order="12"
|
android:order="12"
|
||||||
settings:keywords="@string/keywords_app_permissions">
|
settings:keywords="@string/keywords_app_permissions"
|
||||||
|
settings:controller="com.android.settings.applications.AppPermissionsPreferenceController">
|
||||||
<intent android:action="android.intent.action.MANAGE_PERMISSIONS" />
|
<intent android:action="android.intent.action.MANAGE_PERMISSIONS" />
|
||||||
</Preference>
|
</Preference>
|
||||||
|
|
||||||
|
|||||||
24
res/xml/location_recent_requests_see_all.xml
Normal file
24
res/xml/location_recent_requests_see_all.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:title="@string/location_category_recent_location_requests"
|
||||||
|
android:key="recent_location_requests_see_all">
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="all_recent_location_requests"/>
|
||||||
|
</PreferenceScreen>
|
||||||
@@ -24,6 +24,13 @@
|
|||||||
android:key="recent_location_requests"
|
android:key="recent_location_requests"
|
||||||
android:title="@string/location_category_recent_location_requests"/>
|
android:title="@string/location_category_recent_location_requests"/>
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="recent_location_requests_see_all"
|
||||||
|
android:title="@string/location_recent_location_requests_see_all"
|
||||||
|
android:icon="@drawable/ic_chevron_right_24dp"
|
||||||
|
android:selectable="true"
|
||||||
|
android:fragment="com.android.settings.location.RecentLocationRequestSeeAllFragment"/>
|
||||||
|
|
||||||
<!-- This preference category gets removed if new_recent_location_ui is disabled -->
|
<!-- This preference category gets removed if new_recent_location_ui is disabled -->
|
||||||
<Preference
|
<Preference
|
||||||
android:key="app_level_permissions"
|
android:key="app_level_permissions"
|
||||||
|
|||||||
@@ -702,16 +702,16 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
|| somethingChanged;
|
|| somethingChanged;
|
||||||
|
|
||||||
// Enable/disable the Me Card page.
|
// Enable/disable the Me Card page.
|
||||||
final boolean isMeCardEnabled = featureFactory
|
final boolean aboutPhoneV2Enabled = featureFactory
|
||||||
.getAccountFeatureProvider()
|
.getAccountFeatureProvider()
|
||||||
.isMeCardEnabled(this);
|
.isAboutPhoneV2Enabled(this);
|
||||||
somethingChanged = setTileEnabled(new ComponentName(packageName,
|
somethingChanged = setTileEnabled(new ComponentName(packageName,
|
||||||
Settings.MyDeviceInfoActivity.class.getName()),
|
Settings.MyDeviceInfoActivity.class.getName()),
|
||||||
isMeCardEnabled, isAdmin)
|
aboutPhoneV2Enabled, isAdmin)
|
||||||
|| somethingChanged;
|
|| somethingChanged;
|
||||||
somethingChanged = setTileEnabled(new ComponentName(packageName,
|
somethingChanged = setTileEnabled(new ComponentName(packageName,
|
||||||
Settings.DeviceInfoSettingsActivity.class.getName()),
|
Settings.DeviceInfoSettingsActivity.class.getName()),
|
||||||
!isMeCardEnabled, isAdmin)
|
!aboutPhoneV2Enabled, isAdmin)
|
||||||
|| somethingChanged;
|
|| somethingChanged;
|
||||||
|
|
||||||
if (UserHandle.MU_ENABLED && !isAdmin) {
|
if (UserHandle.MU_ENABLED && !isAdmin) {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public abstract class VibrationIntensityPreferenceController extends BasePrefere
|
|||||||
mSettingsContentObserver = new SettingObserver(settingKey) {
|
mSettingsContentObserver = new SettingObserver(settingKey) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(boolean selfChange, Uri uri) {
|
public void onChange(boolean selfChange, Uri uri) {
|
||||||
updateState(null);
|
updateState(mPreference);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -74,27 +74,19 @@ public abstract class VibrationIntensityPreferenceController extends BasePrefere
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public CharSequence getSummary() {
|
||||||
if (mPreference == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mPreference.setSummary(getSummary());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSummary() {
|
|
||||||
final int intensity = Settings.System.getInt(mContext.getContentResolver(),
|
final int intensity = Settings.System.getInt(mContext.getContentResolver(),
|
||||||
mSettingKey, getDefaultIntensity());
|
mSettingKey, getDefaultIntensity());
|
||||||
|
|
||||||
switch (intensity) {
|
switch (intensity) {
|
||||||
case Vibrator.VIBRATION_INTENSITY_OFF:
|
case Vibrator.VIBRATION_INTENSITY_OFF:
|
||||||
return mContext.getString(R.string.accessibility_vibration_intensity_off);
|
return mContext.getText(R.string.accessibility_vibration_intensity_off);
|
||||||
case Vibrator.VIBRATION_INTENSITY_LOW:
|
case Vibrator.VIBRATION_INTENSITY_LOW:
|
||||||
return mContext.getString(R.string.accessibility_vibration_intensity_low);
|
return mContext.getText(R.string.accessibility_vibration_intensity_low);
|
||||||
case Vibrator.VIBRATION_INTENSITY_MEDIUM:
|
case Vibrator.VIBRATION_INTENSITY_MEDIUM:
|
||||||
return mContext.getString(R.string.accessibility_vibration_intensity_medium);
|
return mContext.getText(R.string.accessibility_vibration_intensity_medium);
|
||||||
case Vibrator.VIBRATION_INTENSITY_HIGH:
|
case Vibrator.VIBRATION_INTENSITY_HIGH:
|
||||||
return mContext.getString(R.string.accessibility_vibration_intensity_high);
|
return mContext.getText(R.string.accessibility_vibration_intensity_high);
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public interface AccountFeatureProvider {
|
|||||||
/**
|
/**
|
||||||
* Checks whether or not to display the new About Phone page.
|
* Checks whether or not to display the new About Phone page.
|
||||||
*/
|
*/
|
||||||
default boolean isMeCardEnabled(Context context) {
|
default boolean isAboutPhoneV2Enabled(Context context) {
|
||||||
return FeatureFlagUtils.isEnabled(context, FeatureFlags.ABOUT_PHONE_V2);
|
return FeatureFlagUtils.isEnabled(context, FeatureFlags.ABOUT_PHONE_V2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ public class AppAndNotificationDashboardFragment extends DashboardFragment {
|
|||||||
controllers.add(new EmergencyBroadcastPreferenceController(context,
|
controllers.add(new EmergencyBroadcastPreferenceController(context,
|
||||||
"app_and_notif_cell_broadcast_settings"));
|
"app_and_notif_cell_broadcast_settings"));
|
||||||
controllers.add(new SpecialAppAccessPreferenceController(context));
|
controllers.add(new SpecialAppAccessPreferenceController(context));
|
||||||
controllers.add(new AppPermissionsPreferenceController(context));
|
|
||||||
controllers.add(new RecentAppsPreferenceController(context, app, host));
|
controllers.add(new RecentAppsPreferenceController(context, app, host));
|
||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,19 +19,17 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.pm.PermissionGroupInfo;
|
import android.content.pm.PermissionGroupInfo;
|
||||||
import android.content.pm.PermissionInfo;
|
import android.content.pm.PermissionInfo;
|
||||||
import android.support.v7.preference.Preference;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class AppPermissionsPreferenceController extends AbstractPreferenceController
|
public class AppPermissionsPreferenceController extends BasePreferenceController {
|
||||||
implements PreferenceControllerMixin {
|
|
||||||
|
|
||||||
private static final String TAG = "AppPermissionPrefCtrl";
|
private static final String TAG = "AppPermissionPrefCtrl";
|
||||||
private static final String KEY_APP_PERMISSION_GROUPS = "manage_perms";
|
private static final String KEY_APP_PERMISSION_GROUPS = "manage_perms";
|
||||||
@@ -48,26 +46,13 @@ public class AppPermissionsPreferenceController extends AbstractPreferenceContro
|
|||||||
private final PackageManager mPackageManager;
|
private final PackageManager mPackageManager;
|
||||||
|
|
||||||
public AppPermissionsPreferenceController(Context context) {
|
public AppPermissionsPreferenceController(Context context) {
|
||||||
super(context);
|
super(context, KEY_APP_PERMISSION_GROUPS);
|
||||||
mPackageManager = context.getPackageManager();
|
mPackageManager = context.getPackageManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public int getAvailabilityStatus() {
|
||||||
return true;
|
return AVAILABLE;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPreferenceKey() {
|
|
||||||
return KEY_APP_PERMISSION_GROUPS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateState(Preference preference) {
|
|
||||||
final String summary = getSummary();
|
|
||||||
if (summary != null) {
|
|
||||||
preference.setSummary(summary);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -76,7 +61,7 @@ public class AppPermissionsPreferenceController extends AbstractPreferenceContro
|
|||||||
Location, Microphone, Camera, Sms, Contacts, and Phone
|
Location, Microphone, Camera, Sms, Contacts, and Phone
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getSummary() {
|
public CharSequence getSummary() {
|
||||||
final Set<String> permissions = getAllPermissionsInGroups();
|
final Set<String> permissions = getAllPermissionsInGroups();
|
||||||
Set<String> grantedPermissionGroups = getGrantedPermissionGroups(permissions);
|
Set<String> grantedPermissionGroups = getGrantedPermissionGroups(permissions);
|
||||||
CharSequence summary = null;
|
CharSequence summary = null;
|
||||||
@@ -139,7 +124,7 @@ public class AppPermissionsPreferenceController extends AbstractPreferenceContro
|
|||||||
result.add(permissionInfo.name);
|
result.add(permissionInfo.name);
|
||||||
}
|
}
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
Log.e(TAG, "Error getting permissions in group "+group, e);
|
Log.e(TAG, "Error getting permissions in group " + group, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -50,14 +50,9 @@ public abstract class DefaultAppShortcutPreferenceControllerBase extends BasePre
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public CharSequence getSummary() {
|
||||||
preference.setSummary(getSummary());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSummary() {
|
|
||||||
int summaryResId = isDefaultApp() ? R.string.yes : R.string.no;
|
int summaryResId = isDefaultApp() ? R.string.yes : R.string.no;
|
||||||
return mContext.getString(summaryResId);
|
return mContext.getText(summaryResId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import static android.Manifest.permission.SYSTEM_ALERT_WINDOW;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.support.v7.preference.Preference;
|
|
||||||
|
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
|
|
||||||
@@ -50,18 +49,13 @@ public class DrawOverlayDetailPreferenceController extends AppInfoPreferenceCont
|
|||||||
return DISABLED_FOR_USER;
|
return DISABLED_FOR_USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateState(Preference preference) {
|
|
||||||
preference.setSummary(getSummary());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<? extends SettingsPreferenceFragment> getDetailFragmentClass() {
|
protected Class<? extends SettingsPreferenceFragment> getDetailFragmentClass() {
|
||||||
return DrawOverlayDetails.class;
|
return DrawOverlayDetails.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSummary() {
|
public CharSequence getSummary() {
|
||||||
return DrawOverlayDetails.getSummary(mContext, mParent.getAppEntry()).toString();
|
return DrawOverlayDetails.getSummary(mContext, mParent.getAppEntry());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import static android.Manifest.permission.WRITE_SETTINGS;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.support.v7.preference.Preference;
|
|
||||||
|
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
|
|
||||||
@@ -51,19 +50,14 @@ public class WriteSystemSettingsPreferenceController extends AppInfoPreferenceCo
|
|||||||
return DISABLED_FOR_USER;
|
return DISABLED_FOR_USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateState(Preference preference) {
|
|
||||||
preference.setSummary(getSummary());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<? extends SettingsPreferenceFragment> getDetailFragmentClass() {
|
protected Class<? extends SettingsPreferenceFragment> getDetailFragmentClass() {
|
||||||
return WriteSettingsDetails.class;
|
return WriteSettingsDetails.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSummary() {
|
public CharSequence getSummary() {
|
||||||
return WriteSettingsDetails.getSummary(mContext, mParent.getAppEntry()).toString();
|
return WriteSettingsDetails.getSummary(mContext, mParent.getAppEntry());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package com.android.settings.backup;
|
|||||||
import android.app.backup.BackupManager;
|
import android.app.backup.BackupManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.support.v7.preference.Preference;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
@@ -46,16 +45,11 @@ public class BackupSettingsActivityPreferenceController extends BasePreferenceCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public CharSequence getSummary() {
|
||||||
preference.setSummary(getSummary());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSummary() {
|
|
||||||
final boolean backupEnabled = mBackupManager.isBackupEnabled();
|
final boolean backupEnabled = mBackupManager.isBackupEnabled();
|
||||||
|
|
||||||
return backupEnabled
|
return backupEnabled
|
||||||
? mContext.getString(R.string.accessibility_feature_state_on)
|
? mContext.getText(R.string.accessibility_feature_state_on)
|
||||||
: mContext.getString(R.string.accessibility_feature_state_off);
|
: mContext.getText(R.string.accessibility_feature_state_off);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ public class BluetoothDeviceNamePreferenceController extends BasePreferenceContr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSummary() {
|
public CharSequence getSummary() {
|
||||||
String deviceName = getDeviceName();
|
String deviceName = getDeviceName();
|
||||||
if (TextUtils.isEmpty(deviceName)) {
|
if (TextUtils.isEmpty(deviceName)) {
|
||||||
return super.getSummary();
|
return super.getSummary();
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class BluetoothDeviceRenamePreferenceController extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSummary() {
|
public CharSequence getSummary() {
|
||||||
return getDeviceName();
|
return getDeviceName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import java.util.TreeSet;
|
|||||||
*/
|
*/
|
||||||
public class PreferenceControllerListHelper {
|
public class PreferenceControllerListHelper {
|
||||||
|
|
||||||
private static final String TAG = "PrefCtrlListCreator";
|
private static final String TAG = "PrefCtrlListHelper";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a list of controller based on xml definition.
|
* Instantiates a list of controller based on xml definition.
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ public class SubSettingLauncher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void launchForResult(Fragment listener, Intent intent, int requestCode) {
|
private void launchForResult(Fragment listener, Intent intent, int requestCode) {
|
||||||
listener.getActivity().startActivityForResult(intent, requestCode);
|
listener.startActivityForResult(intent, requestCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.android.settings.Settings;
|
|||||||
import com.android.settings.TestingSettings;
|
import com.android.settings.TestingSettings;
|
||||||
import com.android.settings.TetherSettings;
|
import com.android.settings.TetherSettings;
|
||||||
import com.android.settings.TrustedCredentialsSettings;
|
import com.android.settings.TrustedCredentialsSettings;
|
||||||
|
import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
|
||||||
import com.android.settings.wifi.calling.WifiCallingSettings;
|
import com.android.settings.wifi.calling.WifiCallingSettings;
|
||||||
import com.android.settings.accessibility.AccessibilitySettings;
|
import com.android.settings.accessibility.AccessibilitySettings;
|
||||||
import com.android.settings.accessibility.AccessibilitySettingsForSetupWizard;
|
import com.android.settings.accessibility.AccessibilitySettingsForSetupWizard;
|
||||||
@@ -154,6 +155,7 @@ public class SettingsGateway {
|
|||||||
UserDictionarySettings.class.getName(),
|
UserDictionarySettings.class.getName(),
|
||||||
DisplaySettings.class.getName(),
|
DisplaySettings.class.getName(),
|
||||||
DeviceInfoSettings.class.getName(),
|
DeviceInfoSettings.class.getName(),
|
||||||
|
MyDeviceInfoFragment.class.getName(),
|
||||||
ManageApplications.class.getName(),
|
ManageApplications.class.getName(),
|
||||||
ManageAssist.class.getName(),
|
ManageAssist.class.getName(),
|
||||||
ProcessStatsUi.class.getName(),
|
ProcessStatsUi.class.getName(),
|
||||||
|
|||||||
@@ -18,9 +18,12 @@ package com.android.settings.dashboard.conditional;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Icon;
|
import android.graphics.drawable.Icon;
|
||||||
import android.net.NetworkPolicyManager;
|
import android.net.NetworkPolicyManager;
|
||||||
|
import android.util.FeatureFlagUtils;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Settings;
|
import com.android.settings.Settings;
|
||||||
|
import com.android.settings.core.FeatureFlags;
|
||||||
|
|
||||||
public class BackgroundDataCondition extends Condition {
|
public class BackgroundDataCondition extends Condition {
|
||||||
|
|
||||||
@@ -55,8 +58,12 @@ public class BackgroundDataCondition extends Condition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrimaryClick() {
|
public void onPrimaryClick() {
|
||||||
mManager.getContext().startActivity(new Intent(mManager.getContext(),
|
final Class activityClass = FeatureFlagUtils.isEnabled(mManager.getContext(),
|
||||||
Settings.DataUsageSummaryActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
FeatureFlags.DATA_USAGE_SETTINGS_V2)
|
||||||
|
? Settings.DataUsageSummaryActivity.class
|
||||||
|
: Settings.DataUsageSummaryLegacyActivity.class;
|
||||||
|
mManager.getContext().startActivity(new Intent(mManager.getContext(), activityClass)
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -22,9 +22,7 @@ import android.support.annotation.VisibleForTesting;
|
|||||||
import android.support.v7.preference.ListPreference;
|
import android.support.v7.preference.ListPreference;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
|
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
|
||||||
|
|
||||||
@@ -32,58 +30,65 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceController extends
|
|||||||
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
|
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
|
||||||
PreferenceControllerMixin {
|
PreferenceControllerMixin {
|
||||||
|
|
||||||
private static final String BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_KEY =
|
private static final String MAX_CONNECTED_AUDIO_DEVICES_PREFERENCE_KEY =
|
||||||
"bluetooth_max_connected_audio_devices";
|
"bluetooth_max_connected_audio_devices";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY =
|
static final String MAX_CONNECTED_AUDIO_DEVICES_PROPERTY =
|
||||||
"persist.bluetooth.maxconnectedaudiodevices";
|
"persist.bluetooth.maxconnectedaudiodevices";
|
||||||
|
|
||||||
private final String[] mListValues;
|
private final int mDefaultMaxConnectedAudioDevices;
|
||||||
private final String[] mListSummaries;
|
|
||||||
private ListPreference mPreference;
|
private ListPreference mPreference;
|
||||||
|
|
||||||
public BluetoothMaxConnectedAudioDevicesPreferenceController(Context context) {
|
public BluetoothMaxConnectedAudioDevicesPreferenceController(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
mDefaultMaxConnectedAudioDevices = mContext.getResources().getInteger(
|
||||||
mListValues = context.getResources()
|
com.android.internal.R.integer.config_bluetooth_max_connected_audio_devices);
|
||||||
.getStringArray(R.array.bluetooth_max_connected_audio_devices_values);
|
|
||||||
mListSummaries = context.getResources()
|
|
||||||
.getStringArray(R.array.bluetooth_max_connected_audio_devices);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPreferenceKey() {
|
public String getPreferenceKey() {
|
||||||
return BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_KEY;
|
return MAX_CONNECTED_AUDIO_DEVICES_PREFERENCE_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
|
|
||||||
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
|
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
|
||||||
|
final CharSequence[] entries = mPreference.getEntries();
|
||||||
|
entries[0] = String.format(entries[0].toString(), mDefaultMaxConnectedAudioDevices);
|
||||||
|
mPreference.setEntries(entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, newValue.toString());
|
String newValueString = newValue.toString();
|
||||||
|
final ListPreference listPreference = (ListPreference) preference;
|
||||||
|
if (listPreference.findIndexOfValue(newValueString) <= 0) {
|
||||||
|
// Reset property value when default is chosen or when value is illegal
|
||||||
|
newValueString = "";
|
||||||
|
}
|
||||||
|
SystemProperties.set(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, newValueString);
|
||||||
updateState(preference);
|
updateState(preference);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
final String currentValue = SystemProperties.get(
|
final ListPreference listPreference = (ListPreference) preference;
|
||||||
BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY);
|
final CharSequence[] entries = listPreference.getEntries();
|
||||||
int index = 0; // Defaults to 1 device
|
final String currentValue = SystemProperties.get(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY);
|
||||||
for (int i = 0; i < mListValues.length; i++) {
|
int index = 0;
|
||||||
if (TextUtils.equals(currentValue, mListValues[i])) {
|
if (!currentValue.isEmpty()) {
|
||||||
index = i;
|
index = listPreference.findIndexOfValue(currentValue);
|
||||||
break;
|
if (index < 0) {
|
||||||
|
// Reset property value when value is illegal
|
||||||
|
SystemProperties.set(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, "");
|
||||||
|
index = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mPreference.setValue(mListValues[index]);
|
listPreference.setValueIndex(index);
|
||||||
mPreference.setSummary(mListSummaries[index]);
|
listPreference.setSummary(entries[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -95,9 +100,8 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceController extends
|
|||||||
@Override
|
@Override
|
||||||
protected void onDeveloperOptionsSwitchDisabled() {
|
protected void onDeveloperOptionsSwitchDisabled() {
|
||||||
mPreference.setEnabled(false);
|
mPreference.setEnabled(false);
|
||||||
SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, mListValues[0]);
|
SystemProperties.set(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, "");
|
||||||
mPreference.setValue(mListValues[0]);
|
updateState(mPreference);
|
||||||
mPreference.setSummary(mListSummaries[0]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class DeviceNamePreferenceController extends BasePreferenceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSummary() {
|
public CharSequence getSummary() {
|
||||||
return mDeviceName;
|
return mDeviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MyDeviceInfoFragment extends DashboardFragment {
|
public class MyDeviceInfoFragment extends DashboardFragment {
|
||||||
private static final String LOG_TAG = "MeCardFragment";
|
private static final String LOG_TAG = "MyDeviceInfoFragment";
|
||||||
|
|
||||||
private static final String KEY_MY_DEVICE_INFO_HEADER = "my_device_info_header";
|
private static final String KEY_MY_DEVICE_INFO_HEADER = "my_device_info_header";
|
||||||
private static final String KEY_LEGAL_CONTAINER = "legal_container";
|
private static final String KEY_LEGAL_CONTAINER = "legal_container";
|
||||||
|
|||||||
@@ -21,31 +21,47 @@ import android.os.ServiceManager;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
import com.android.internal.app.ColorDisplayController;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
public class ColorModePreferenceController extends AbstractPreferenceController implements
|
public class ColorModePreferenceController extends BasePreferenceController {
|
||||||
PreferenceControllerMixin {
|
|
||||||
private static final String TAG = "ColorModePreference";
|
private static final String TAG = "ColorModePreference";
|
||||||
private static final String KEY_COLOR_MODE = "color_mode";
|
private static final String KEY_COLOR_MODE = "color_mode";
|
||||||
|
|
||||||
private static final int SURFACE_FLINGER_TRANSACTION_QUERY_WIDE_COLOR = 1024;
|
private static final int SURFACE_FLINGER_TRANSACTION_QUERY_WIDE_COLOR = 1024;
|
||||||
|
|
||||||
private final ConfigurationWrapper mConfigWrapper;
|
private final ConfigurationWrapper mConfigWrapper;
|
||||||
|
private ColorDisplayController mColorDisplayController;
|
||||||
|
|
||||||
public ColorModePreferenceController(Context context) {
|
public ColorModePreferenceController(Context context) {
|
||||||
super(context);
|
super(context, KEY_COLOR_MODE);
|
||||||
mConfigWrapper = new ConfigurationWrapper();
|
mConfigWrapper = new ConfigurationWrapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPreferenceKey() {
|
public int getAvailabilityStatus() {
|
||||||
return KEY_COLOR_MODE;
|
return mConfigWrapper.isScreenWideColorGamut() ? AVAILABLE : DISABLED_FOR_USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public CharSequence getSummary() {
|
||||||
return mConfigWrapper.isScreenWideColorGamut();
|
final int colorMode = getColorDisplayController().getColorMode();
|
||||||
|
if (colorMode == ColorDisplayController.COLOR_MODE_SATURATED) {
|
||||||
|
return mContext.getText(R.string.color_mode_option_saturated);
|
||||||
|
}
|
||||||
|
if (colorMode == ColorDisplayController.COLOR_MODE_BOOSTED) {
|
||||||
|
return mContext.getText(R.string.color_mode_option_boosted);
|
||||||
|
}
|
||||||
|
return mContext.getText(R.string.color_mode_option_natural);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
ColorDisplayController getColorDisplayController() {
|
||||||
|
if (mColorDisplayController == null) {
|
||||||
|
mColorDisplayController = new ColorDisplayController(mContext);
|
||||||
|
}
|
||||||
|
return mColorDisplayController;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class BatterySaverController extends TogglePreferenceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSummary() {
|
public CharSequence getSummary() {
|
||||||
final boolean mode = mPowerManager.isPowerSaveMode();
|
final boolean mode = mPowerManager.isPowerSaveMode();
|
||||||
final int format = mode ? R.string.battery_saver_on_summary
|
final int format = mode ? R.string.battery_saver_on_summary
|
||||||
: R.string.battery_saver_off_summary;
|
: R.string.battery_saver_off_summary;
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package com.android.settings.gestures;
|
|||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v7.preference.Preference;
|
|
||||||
|
|
||||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -56,12 +55,7 @@ public class GesturesSettingPreferenceController extends BasePreferenceControlle
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public CharSequence getSummary() {
|
||||||
preference.setSummary(getSummary());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSummary() {
|
|
||||||
if (!mFeatureProvider.isSensorAvailable(mContext)) {
|
if (!mFeatureProvider.isSensorAvailable(mContext)) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -72,13 +66,13 @@ public class GesturesSettingPreferenceController extends BasePreferenceControlle
|
|||||||
contentResolver, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 1) != 0;
|
contentResolver, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 1) != 0;
|
||||||
|
|
||||||
if (mFeatureProvider.isSupported(mContext) && assistGestureEnabled) {
|
if (mFeatureProvider.isSupported(mContext) && assistGestureEnabled) {
|
||||||
return mContext.getString(
|
return mContext.getText(
|
||||||
R.string.language_input_gesture_summary_on_with_assist);
|
R.string.language_input_gesture_summary_on_with_assist);
|
||||||
}
|
}
|
||||||
if (assistGestureSilenceEnabled) {
|
if (assistGestureSilenceEnabled) {
|
||||||
return mContext.getString(
|
return mContext.getText(
|
||||||
R.string.language_input_gesture_summary_on_non_assist);
|
R.string.language_input_gesture_summary_on_non_assist);
|
||||||
}
|
}
|
||||||
return mContext.getString(R.string.language_input_gesture_summary_off);
|
return mContext.getText(R.string.language_input_gesture_summary_off);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,8 +70,10 @@ public class LocationSettings extends DashboardFragment {
|
|||||||
public int getInitialExpandedChildCount() {
|
public int getInitialExpandedChildCount() {
|
||||||
final RecentLocationApps recentLocationApps = new RecentLocationApps(getActivity());
|
final RecentLocationApps recentLocationApps = new RecentLocationApps(getActivity());
|
||||||
final int locationRequestsApps = recentLocationApps.getAppList().size();
|
final int locationRequestsApps = recentLocationApps.getAppList().size();
|
||||||
final int locationRequestsPrefs = locationRequestsApps == 0 ? 1 : locationRequestsApps;
|
final int locationRequestsPrefs =
|
||||||
return locationRequestsPrefs + 2;
|
locationRequestsApps == 0
|
||||||
|
? 1 : (locationRequestsApps > 3 ? 4 : locationRequestsApps);
|
||||||
|
return locationRequestsPrefs + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -20,32 +20,33 @@ import android.support.annotation.VisibleForTesting;
|
|||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceCategory;
|
import android.support.v7.preference.PreferenceCategory;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
|
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
|
||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
import com.android.settings.widget.AppPreference;
|
import com.android.settings.widget.AppPreference;
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
import com.android.settingslib.location.RecentLocationApps;
|
import com.android.settingslib.location.RecentLocationApps;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class RecentLocationRequestPreferenceController extends LocationBasePreferenceController {
|
public class RecentLocationRequestPreferenceController extends LocationBasePreferenceController {
|
||||||
|
|
||||||
/** Key for preference category "Recent location requests" */
|
/** Key for preference category "Recent location requests" */
|
||||||
private static final String KEY_RECENT_LOCATION_REQUESTS = "recent_location_requests";
|
private static final String KEY_RECENT_LOCATION_REQUESTS = "recent_location_requests";
|
||||||
|
@VisibleForTesting
|
||||||
|
static final String KEY_SEE_ALL = "recent_location_requests_see_all";
|
||||||
private final LocationSettings mFragment;
|
private final LocationSettings mFragment;
|
||||||
private final RecentLocationApps mRecentLocationApps;
|
private final RecentLocationApps mRecentLocationApps;
|
||||||
private PreferenceCategory mCategoryRecentLocationRequests;
|
private PreferenceCategory mCategoryRecentLocationRequests;
|
||||||
|
private Preference mSeeAllButton;
|
||||||
|
|
||||||
@VisibleForTesting
|
/** Used in this class and {@link RecentLocationRequestSeeAllPreferenceController}*/
|
||||||
static class PackageEntryClickedListener implements Preference.OnPreferenceClickListener {
|
static class PackageEntryClickedListener implements Preference.OnPreferenceClickListener {
|
||||||
private final LocationSettings mFragment;
|
private final DashboardFragment mFragment;
|
||||||
private final String mPackage;
|
private final String mPackage;
|
||||||
private final UserHandle mUserHandle;
|
private final UserHandle mUserHandle;
|
||||||
|
|
||||||
public PackageEntryClickedListener(LocationSettings fragment, String packageName,
|
public PackageEntryClickedListener(DashboardFragment fragment, String packageName,
|
||||||
UserHandle userHandle) {
|
UserHandle userHandle) {
|
||||||
mFragment = fragment;
|
mFragment = fragment;
|
||||||
mPackage = packageName;
|
mPackage = packageName;
|
||||||
@@ -92,24 +93,32 @@ public class RecentLocationRequestPreferenceController extends LocationBasePrefe
|
|||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
mCategoryRecentLocationRequests =
|
mCategoryRecentLocationRequests =
|
||||||
(PreferenceCategory) screen.findPreference(KEY_RECENT_LOCATION_REQUESTS);
|
(PreferenceCategory) screen.findPreference(KEY_RECENT_LOCATION_REQUESTS);
|
||||||
|
mSeeAllButton = screen.findPreference(KEY_SEE_ALL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
mCategoryRecentLocationRequests.removeAll();
|
mCategoryRecentLocationRequests.removeAll();
|
||||||
|
mSeeAllButton.setVisible(false);
|
||||||
|
|
||||||
final Context prefContext = preference.getContext();
|
final Context prefContext = preference.getContext();
|
||||||
final List<RecentLocationApps.Request> recentLocationRequests =
|
final List<RecentLocationApps.Request> recentLocationRequests =
|
||||||
mRecentLocationApps.getAppListSorted();
|
mRecentLocationApps.getAppListSorted();
|
||||||
|
|
||||||
final List<Preference> recentLocationPrefs = new ArrayList<>(recentLocationRequests.size());
|
if (recentLocationRequests.size() > 3) {
|
||||||
for (final RecentLocationApps.Request request : recentLocationRequests) {
|
// Display the top 3 preferences to container in original order.
|
||||||
recentLocationPrefs.add(createAppPreference(prefContext, request));
|
for (int i = 0; i < 3; i ++) {
|
||||||
|
mCategoryRecentLocationRequests.addPreference(
|
||||||
|
createAppPreference(prefContext, recentLocationRequests.get(i)));
|
||||||
}
|
}
|
||||||
if (recentLocationRequests.size() > 0) {
|
// Display a button to list all requests
|
||||||
|
mSeeAllButton.setVisible(true);
|
||||||
|
} else if (recentLocationRequests.size() > 0) {
|
||||||
// Add preferences to container in original order (already sorted by recency).
|
// Add preferences to container in original order (already sorted by recency).
|
||||||
for (Preference entry : recentLocationPrefs) {
|
for (RecentLocationApps.Request request : recentLocationRequests) {
|
||||||
mCategoryRecentLocationRequests.addPreference(entry);
|
mCategoryRecentLocationRequests.addPreference(
|
||||||
|
createAppPreference(prefContext, request));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If there's no item to display, add a "No recent apps" item.
|
// If there's no item to display, add a "No recent apps" item.
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 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.location;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.provider.SearchIndexableResource;
|
||||||
|
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.core.AbstractPreferenceController;
|
||||||
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/** Dashboard Fragment to display all recent location requests, sorted by recency. */
|
||||||
|
public class RecentLocationRequestSeeAllFragment extends DashboardFragment {
|
||||||
|
|
||||||
|
private static final String TAG = "RecentLocationReqAll";
|
||||||
|
|
||||||
|
public static final String PATH =
|
||||||
|
"com.android.settings.location.RecentLocationRequestSeeAllFragment";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetricsCategory() {
|
||||||
|
return MetricsEvent.RECENT_LOCATION_REQUESTS_ALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getPreferenceScreenResId() {
|
||||||
|
return R.xml.location_recent_requests_see_all;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getLogTag() {
|
||||||
|
return TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||||
|
return buildPreferenceControllers(context, getLifecycle(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<AbstractPreferenceController> buildPreferenceControllers(
|
||||||
|
Context context, Lifecycle lifecycle, RecentLocationRequestSeeAllFragment fragment) {
|
||||||
|
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||||
|
controllers.add(
|
||||||
|
new RecentLocationRequestSeeAllPreferenceController(context, lifecycle, fragment));
|
||||||
|
return controllers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For Search.
|
||||||
|
*/
|
||||||
|
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
|
new BaseSearchIndexProvider() {
|
||||||
|
@Override
|
||||||
|
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
||||||
|
Context context, boolean enabled) {
|
||||||
|
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||||
|
sir.xmlResId = R.xml.location_recent_requests_see_all;
|
||||||
|
return Arrays.asList(sir);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AbstractPreferenceController> getPreferenceControllers(Context
|
||||||
|
context) {
|
||||||
|
return buildPreferenceControllers(
|
||||||
|
context, /* lifecycle = */ null, /* fragment = */ null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 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.location;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.annotation.VisibleForTesting;
|
||||||
|
import android.support.v7.preference.Preference;
|
||||||
|
import android.support.v7.preference.PreferenceCategory;
|
||||||
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
|
import com.android.settings.widget.AppPreference;
|
||||||
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
import com.android.settingslib.location.RecentLocationApps;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/** Preference controller for preference category displaying all recent location requests. */
|
||||||
|
public class RecentLocationRequestSeeAllPreferenceController
|
||||||
|
extends LocationBasePreferenceController {
|
||||||
|
|
||||||
|
/** Key for preference category "All recent location requests" */
|
||||||
|
private static final String KEY_ALL_RECENT_LOCATION_REQUESTS = "all_recent_location_requests";
|
||||||
|
private final RecentLocationRequestSeeAllFragment mFragment;
|
||||||
|
private PreferenceCategory mCategoryAllRecentLocationRequests;
|
||||||
|
private RecentLocationApps mRecentLocationApps;
|
||||||
|
|
||||||
|
public RecentLocationRequestSeeAllPreferenceController(
|
||||||
|
Context context, Lifecycle lifecycle, RecentLocationRequestSeeAllFragment fragment) {
|
||||||
|
this(context, lifecycle, fragment, new RecentLocationApps(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
RecentLocationRequestSeeAllPreferenceController(
|
||||||
|
Context context,
|
||||||
|
Lifecycle lifecycle,
|
||||||
|
RecentLocationRequestSeeAllFragment fragment,
|
||||||
|
RecentLocationApps recentLocationApps) {
|
||||||
|
super(context, lifecycle);
|
||||||
|
mFragment = fragment;
|
||||||
|
mRecentLocationApps = recentLocationApps;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPreferenceKey() {
|
||||||
|
return KEY_ALL_RECENT_LOCATION_REQUESTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLocationModeChanged(int mode, boolean restricted) {
|
||||||
|
mCategoryAllRecentLocationRequests.setEnabled(mLocationEnabler.isEnabled(mode));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
|
super.displayPreference(screen);
|
||||||
|
mCategoryAllRecentLocationRequests =
|
||||||
|
(PreferenceCategory) screen.findPreference(KEY_ALL_RECENT_LOCATION_REQUESTS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateState(Preference preference) {
|
||||||
|
mCategoryAllRecentLocationRequests.removeAll();
|
||||||
|
List<RecentLocationApps.Request> requests = mRecentLocationApps.getAppListSorted();
|
||||||
|
for (RecentLocationApps.Request request : requests) {
|
||||||
|
Preference appPreference = createAppPreference(preference.getContext(), request);
|
||||||
|
mCategoryAllRecentLocationRequests.addPreference(appPreference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
AppPreference createAppPreference(
|
||||||
|
Context prefContext, RecentLocationApps.Request request) {
|
||||||
|
final AppPreference pref = new AppPreference(prefContext);
|
||||||
|
pref.setSummary(request.contentDescription);
|
||||||
|
pref.setIcon(request.icon);
|
||||||
|
pref.setTitle(request.label);
|
||||||
|
pref.setOnPreferenceClickListener(
|
||||||
|
new RecentLocationRequestPreferenceController.PackageEntryClickedListener(
|
||||||
|
mFragment, request.packageName, request.userHandle));
|
||||||
|
return pref;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,11 +32,11 @@ import com.android.settings.wrapper.RestrictedLockUtilsWrapper;
|
|||||||
import com.android.settingslib.Utils;
|
import com.android.settingslib.Utils;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||||
|
|
||||||
public class MobileNetworkPreferenceController extends AbstractPreferenceController
|
public class MobileNetworkPreferenceController extends AbstractPreferenceController
|
||||||
implements PreferenceControllerMixin, LifecycleObserver, OnResume, OnPause {
|
implements PreferenceControllerMixin, LifecycleObserver, OnStart, OnStop {
|
||||||
|
|
||||||
private static final String KEY_MOBILE_NETWORK_SETTINGS = "mobile_network_settings";
|
private static final String KEY_MOBILE_NETWORK_SETTINGS = "mobile_network_settings";
|
||||||
|
|
||||||
@@ -71,10 +71,8 @@ public class MobileNetworkPreferenceController extends AbstractPreferenceControl
|
|||||||
@Override
|
@Override
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
if (isAvailable()) {
|
|
||||||
mPreference = screen.findPreference(getPreferenceKey());
|
mPreference = screen.findPreference(getPreferenceKey());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPreferenceKey() {
|
public String getPreferenceKey() {
|
||||||
@@ -82,15 +80,13 @@ public class MobileNetworkPreferenceController extends AbstractPreferenceControl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onStart() {
|
||||||
if (isAvailable()) {
|
if (isAvailable()) {
|
||||||
if (mPhoneStateListener == null) {
|
if (mPhoneStateListener == null) {
|
||||||
mPhoneStateListener = new PhoneStateListener() {
|
mPhoneStateListener = new PhoneStateListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onServiceStateChanged(ServiceState serviceState) {
|
public void onServiceStateChanged(ServiceState serviceState) {
|
||||||
if (mPreference != null) {
|
updateState(mPreference);
|
||||||
mPreference.setSummary(mTelephonyManager.getNetworkOperatorName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -99,9 +95,14 @@ public class MobileNetworkPreferenceController extends AbstractPreferenceControl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onStop() {
|
||||||
if (mPhoneStateListener != null) {
|
if (mPhoneStateListener != null) {
|
||||||
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
|
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharSequence getSummary() {
|
||||||
|
return mTelephonyManager.getNetworkOperatorName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ public class HeaderPreferenceController extends NotificationPreferenceController
|
|||||||
return mAppRow != null;
|
return mAppRow != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
if (mAppRow != null && mFragment != null) {
|
if (mAppRow != null && mFragment != null) {
|
||||||
LayoutPreference pref = (LayoutPreference) preference;
|
LayoutPreference pref = (LayoutPreference) preference;
|
||||||
@@ -78,7 +79,7 @@ public class HeaderPreferenceController extends NotificationPreferenceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSummary() {
|
public CharSequence getSummary() {
|
||||||
if (mChannel != null) {
|
if (mChannel != null) {
|
||||||
if (mChannelGroup != null && mChannelGroup.getGroup() != null
|
if (mChannelGroup != null && mChannelGroup.getGroup() != null
|
||||||
&& !TextUtils.isEmpty(mChannelGroup.getGroup().getName())) {
|
&& !TextUtils.isEmpty(mChannelGroup.getGroup().getName())) {
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
R.string.next_label);
|
R.string.lockpassword_confirm_label);
|
||||||
|
|
||||||
Stage(int hintInAlpha, int hintInAlphaForFingerprint,
|
Stage(int hintInAlpha, int hintInAlphaForFingerprint,
|
||||||
int hintInNumeric, int hintInNumericForFingerprint,
|
int hintInNumeric, int hintInNumericForFingerprint,
|
||||||
@@ -885,7 +885,7 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
// Hide password requirement view when we are just asking user to confirm the pw.
|
// Hide password requirement view when we are just asking user to confirm the pw.
|
||||||
mPasswordRestrictionView.setVisibility(View.GONE);
|
mPasswordRestrictionView.setVisibility(View.GONE);
|
||||||
setHeaderText(getString(mUiStage.getHint(mIsAlphaMode, mForFingerprint)));
|
setHeaderText(getString(mUiStage.getHint(mIsAlphaMode, mForFingerprint)));
|
||||||
setNextEnabled(canInput && length > 0);
|
setNextEnabled(canInput && length >= mPasswordMinLength);
|
||||||
mClearButton.setEnabled(canInput && length > 0);
|
mClearButton.setEnabled(canInput && length > 0);
|
||||||
}
|
}
|
||||||
int message = mUiStage.getMessage(mIsAlphaMode, mForFingerprint);
|
int message = mUiStage.getMessage(mIsAlphaMode, mForFingerprint);
|
||||||
|
|||||||
@@ -84,16 +84,13 @@ public class PrintSettingPreferenceController extends BasePreferenceController i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
if (preference == null) {
|
super.updateState(preference);
|
||||||
return;
|
|
||||||
}
|
|
||||||
preference.setSummary(getSummary());
|
|
||||||
((RestrictedPreference) preference).checkRestrictionAndSetDisabled(
|
((RestrictedPreference) preference).checkRestrictionAndSetDisabled(
|
||||||
UserManager.DISALLOW_PRINTING);
|
UserManager.DISALLOW_PRINTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSummary() {
|
public CharSequence getSummary() {
|
||||||
final List<PrintJob> printJobs = mPrintManager.getPrintJobs();
|
final List<PrintJob> printJobs = mPrintManager.getPrintJobs();
|
||||||
|
|
||||||
int numActivePrintJobs = 0;
|
int numActivePrintJobs = 0;
|
||||||
@@ -112,7 +109,7 @@ public class PrintSettingPreferenceController extends BasePreferenceController i
|
|||||||
final List<PrintServiceInfo> services =
|
final List<PrintServiceInfo> services =
|
||||||
mPrintManager.getPrintServices(PrintManager.ENABLED_SERVICES);
|
mPrintManager.getPrintServices(PrintManager.ENABLED_SERVICES);
|
||||||
if (services == null || services.isEmpty()) {
|
if (services == null || services.isEmpty()) {
|
||||||
return mContext.getString(R.string.print_settings_summary_no_service);
|
return mContext.getText(R.string.print_settings_summary_no_service);
|
||||||
} else {
|
} else {
|
||||||
final int count = services.size();
|
final int count = services.size();
|
||||||
return mContext.getResources().getQuantityString(
|
return mContext.getResources().getQuantityString(
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ import com.android.settings.inputmethod.PhysicalKeyboardFragment;
|
|||||||
import com.android.settings.inputmethod.VirtualKeyboardFragment;
|
import com.android.settings.inputmethod.VirtualKeyboardFragment;
|
||||||
import com.android.settings.language.LanguageAndInputSettings;
|
import com.android.settings.language.LanguageAndInputSettings;
|
||||||
import com.android.settings.location.LocationSettings;
|
import com.android.settings.location.LocationSettings;
|
||||||
|
import com.android.settings.location.RecentLocationRequestSeeAllFragment;
|
||||||
import com.android.settings.location.ScanningSettings;
|
import com.android.settings.location.ScanningSettings;
|
||||||
import com.android.settings.network.NetworkDashboardFragment;
|
import com.android.settings.network.NetworkDashboardFragment;
|
||||||
import com.android.settings.nfc.PaymentSettings;
|
import com.android.settings.nfc.PaymentSettings;
|
||||||
@@ -177,6 +178,7 @@ public class SearchIndexableResourcesImpl implements SearchIndexableResources {
|
|||||||
addIndex(SmartBatterySettings.class);
|
addIndex(SmartBatterySettings.class);
|
||||||
addIndex(MyDeviceInfoFragment.class);
|
addIndex(MyDeviceInfoFragment.class);
|
||||||
addIndex(VibrationSettings.class);
|
addIndex(VibrationSettings.class);
|
||||||
|
addIndex(RecentLocationRequestSeeAllFragment.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package com.android.settings.security;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v7.preference.Preference;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
@@ -38,16 +37,10 @@ public class ScreenPinningPreferenceController extends BasePreferenceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSummary() {
|
public CharSequence getSummary() {
|
||||||
return Settings.System.getInt(mContext.getContentResolver(),
|
return Settings.System.getInt(mContext.getContentResolver(),
|
||||||
Settings.System.LOCK_TO_APP_ENABLED, 0) != 0
|
Settings.System.LOCK_TO_APP_ENABLED, 0) != 0
|
||||||
? mContext.getString(R.string.switch_on_text)
|
? mContext.getText(R.string.switch_on_text)
|
||||||
: mContext.getString(R.string.switch_off_text);
|
: mContext.getText(R.string.switch_off_text);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateState(Preference preference) {
|
|
||||||
super.updateState(preference);
|
|
||||||
preference.setSummary(getSummary());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class CreateShortcut extends LauncherActivity {
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Intent createResultIntent(Intent shortcutIntent, ResolveInfo resolveInfo,
|
Intent createResultIntent(Intent shortcutIntent, ResolveInfo resolveInfo,
|
||||||
CharSequence label) {
|
CharSequence label) {
|
||||||
shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
|
shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
ShortcutManager sm = getSystemService(ShortcutManager.class);
|
ShortcutManager sm = getSystemService(ShortcutManager.class);
|
||||||
ActivityInfo activityInfo = resolveInfo.activityInfo;
|
ActivityInfo activityInfo = resolveInfo.activityInfo;
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class SliceBuilderUtils {
|
|||||||
final Icon icon = Icon.createWithResource(context, sliceData.getIconResource());
|
final Icon icon = Icon.createWithResource(context, sliceData.getIconResource());
|
||||||
final BasePreferenceController controller = getPreferenceController(context, sliceData);
|
final BasePreferenceController controller = getPreferenceController(context, sliceData);
|
||||||
|
|
||||||
final String subtitleText = getSubtitleText(context, controller, sliceData);
|
final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
|
||||||
|
|
||||||
final RowBuilder builder = new RowBuilder(context, sliceData.getUri())
|
final RowBuilder builder = new RowBuilder(context, sliceData.getUri())
|
||||||
.setTitle(sliceData.getTitle())
|
.setTitle(sliceData.getTitle())
|
||||||
@@ -120,9 +120,9 @@ public class SliceBuilderUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static String getSubtitleText(Context context, AbstractPreferenceController controller,
|
static CharSequence getSubtitleText(Context context, AbstractPreferenceController controller,
|
||||||
SliceData sliceData) {
|
SliceData sliceData) {
|
||||||
String summaryText = sliceData.getSummary();
|
CharSequence summaryText = sliceData.getSummary();
|
||||||
if (isValidSummary(context, summaryText)) {
|
if (isValidSummary(context, summaryText)) {
|
||||||
return summaryText;
|
return summaryText;
|
||||||
}
|
}
|
||||||
@@ -138,13 +138,14 @@ public class SliceBuilderUtils {
|
|||||||
return sliceData.getScreenTitle();
|
return sliceData.getScreenTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isValidSummary(Context context, String summary) {
|
private static boolean isValidSummary(Context context, CharSequence summary) {
|
||||||
if (summary == null || TextUtils.isEmpty(summary.trim())) {
|
if (summary == null || TextUtils.isEmpty(summary.toString().trim())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String placeHolder = context.getString(R.string.summary_placeholder);
|
final CharSequence placeHolder = context.getText(R.string.summary_placeholder);
|
||||||
final String doublePlaceHolder = context.getString(R.string.summary_two_lines_placeholder);
|
final CharSequence doublePlaceHolder =
|
||||||
|
context.getText(R.string.summary_two_lines_placeholder);
|
||||||
|
|
||||||
return !(TextUtils.equals(summary, placeHolder)
|
return !(TextUtils.equals(summary, placeHolder)
|
||||||
|| TextUtils.equals(summary, doublePlaceHolder));
|
|| TextUtils.equals(summary, doublePlaceHolder));
|
||||||
|
|||||||
@@ -83,21 +83,16 @@ public class SystemUpdatePreferenceController extends BasePreferenceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public CharSequence getSummary() {
|
||||||
preference.setSummary(getSummary());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSummary() {
|
|
||||||
final Bundle updateInfo = mUpdateManager.retrieveSystemUpdateInfo();
|
final Bundle updateInfo = mUpdateManager.retrieveSystemUpdateInfo();
|
||||||
String summary = mContext.getString(R.string.android_version_summary,
|
CharSequence summary = mContext.getString(R.string.android_version_summary,
|
||||||
Build.VERSION.RELEASE);
|
Build.VERSION.RELEASE);
|
||||||
switch (updateInfo.getInt(SystemUpdateManager.KEY_STATUS)) {
|
switch (updateInfo.getInt(SystemUpdateManager.KEY_STATUS)) {
|
||||||
case SystemUpdateManager.STATUS_WAITING_DOWNLOAD:
|
case SystemUpdateManager.STATUS_WAITING_DOWNLOAD:
|
||||||
case SystemUpdateManager.STATUS_IN_PROGRESS:
|
case SystemUpdateManager.STATUS_IN_PROGRESS:
|
||||||
case SystemUpdateManager.STATUS_WAITING_INSTALL:
|
case SystemUpdateManager.STATUS_WAITING_INSTALL:
|
||||||
case SystemUpdateManager.STATUS_WAITING_REBOOT:
|
case SystemUpdateManager.STATUS_WAITING_REBOOT:
|
||||||
summary = mContext.getString(R.string.android_version_pending_update_summary);
|
summary = mContext.getText(R.string.android_version_pending_update_summary);
|
||||||
break;
|
break;
|
||||||
case SystemUpdateManager.STATUS_UNKNOWN:
|
case SystemUpdateManager.STATUS_UNKNOWN:
|
||||||
Log.d(TAG, "Update statue unknown");
|
Log.d(TAG, "Update statue unknown");
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
com.android.settings.display.ScreenZoomPreferenceFragmentForSetupWizard
|
com.android.settings.display.ScreenZoomPreferenceFragmentForSetupWizard
|
||||||
|
com.android.settings.search.indexing.FakeSettingsFragment
|
||||||
|
|||||||
@@ -1,5 +1 @@
|
|||||||
com.android.settings.datausage.DataUsageSummaryLegacy
|
|
||||||
com.android.settings.fuelgauge.PowerUsageSummary
|
com.android.settings.fuelgauge.PowerUsageSummary
|
||||||
com.android.settings.fuelgauge.PowerUsageAdvanced
|
|
||||||
com.android.settings.search.indexing.FakeSettingsFragment
|
|
||||||
com.android.settings.system.SystemDashboardFragment
|
|
||||||
@@ -86,25 +86,25 @@ public class NotificationVibrationIntensityPreferenceControllerTest {
|
|||||||
public void updateState_shouldRefreshSummary() {
|
public void updateState_shouldRefreshSummary() {
|
||||||
Settings.System.putInt(mContext.getContentResolver(),
|
Settings.System.putInt(mContext.getContentResolver(),
|
||||||
NOTIFICATION_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
|
NOTIFICATION_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
mController.updateState(null);
|
mController.updateState(mPreference);
|
||||||
assertThat(mPreference.getSummary())
|
assertThat(mPreference.getSummary())
|
||||||
.isEqualTo(mContext.getString(R.string.accessibility_vibration_intensity_low));
|
.isEqualTo(mContext.getString(R.string.accessibility_vibration_intensity_low));
|
||||||
|
|
||||||
Settings.System.putInt(mContext.getContentResolver(),
|
Settings.System.putInt(mContext.getContentResolver(),
|
||||||
NOTIFICATION_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
NOTIFICATION_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||||
mController.updateState(null);
|
mController.updateState(mPreference);
|
||||||
assertThat(mPreference.getSummary())
|
assertThat(mPreference.getSummary())
|
||||||
.isEqualTo(mContext.getString(R.string.accessibility_vibration_intensity_high));
|
.isEqualTo(mContext.getString(R.string.accessibility_vibration_intensity_high));
|
||||||
|
|
||||||
Settings.System.putInt(mContext.getContentResolver(),
|
Settings.System.putInt(mContext.getContentResolver(),
|
||||||
NOTIFICATION_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_MEDIUM);
|
NOTIFICATION_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_MEDIUM);
|
||||||
mController.updateState(null);
|
mController.updateState(mPreference);
|
||||||
assertThat(mPreference.getSummary())
|
assertThat(mPreference.getSummary())
|
||||||
.isEqualTo(mContext.getString(R.string.accessibility_vibration_intensity_medium));
|
.isEqualTo(mContext.getString(R.string.accessibility_vibration_intensity_medium));
|
||||||
|
|
||||||
Settings.System.putInt(mContext.getContentResolver(),
|
Settings.System.putInt(mContext.getContentResolver(),
|
||||||
NOTIFICATION_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
|
NOTIFICATION_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
mController.updateState(null);
|
mController.updateState(mPreference);
|
||||||
assertThat(mPreference.getSummary())
|
assertThat(mPreference.getSummary())
|
||||||
.isEqualTo(mContext.getString(R.string.accessibility_vibration_intensity_off));
|
.isEqualTo(mContext.getString(R.string.accessibility_vibration_intensity_off));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -335,7 +335,6 @@ public final class AppInfoDashboardFragmentTest {
|
|||||||
public void startAppInfoFragment_includesNewAndOldArgs() {
|
public void startAppInfoFragment_includesNewAndOldArgs() {
|
||||||
final SettingsPreferenceFragment caller = mock(SettingsPreferenceFragment.class);
|
final SettingsPreferenceFragment caller = mock(SettingsPreferenceFragment.class);
|
||||||
final SettingsActivity sa = mock (SettingsActivity.class);
|
final SettingsActivity sa = mock (SettingsActivity.class);
|
||||||
when(caller.getActivity()).thenReturn(sa);
|
|
||||||
when(caller.getContext()).thenReturn(sa);
|
when(caller.getContext()).thenReturn(sa);
|
||||||
final AppEntry appEntry = mock(AppEntry.class);
|
final AppEntry appEntry = mock(AppEntry.class);
|
||||||
appEntry.info = mock(ApplicationInfo.class);
|
appEntry.info = mock(ApplicationInfo.class);
|
||||||
@@ -348,7 +347,7 @@ public final class AppInfoDashboardFragmentTest {
|
|||||||
|
|
||||||
final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
|
final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
|
||||||
|
|
||||||
verify(sa).startActivityForResult(intent.capture(), any(Integer.class));
|
verify(caller).startActivityForResult(intent.capture(), any(Integer.class));
|
||||||
assertThat(intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
assertThat(intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
||||||
.containsKey("test"))
|
.containsKey("test"))
|
||||||
.isTrue();
|
.isTrue();
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class AppInfoPreferenceControllerBaseTest {
|
|||||||
mController.handlePreferenceTreeClick(mPreference);
|
mController.handlePreferenceTreeClick(mPreference);
|
||||||
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||||
|
|
||||||
verify(mActivity).startActivityForResult(intentCaptor.capture(), eq(SUB_INFO_FRAGMENT));
|
verify(mFragment).startActivityForResult(intentCaptor.capture(), eq(SUB_INFO_FRAGMENT));
|
||||||
assertThat(intentCaptor.getValue().getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT))
|
assertThat(intentCaptor.getValue().getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT))
|
||||||
.isEqualTo(mController.getDetailFragmentClass().getName());
|
.isEqualTo(mController.getDetailFragmentClass().getName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public class SubSettingLauncherTest {
|
|||||||
.setResultListener(mFragment, requestCode)
|
.setResultListener(mFragment, requestCode)
|
||||||
.launch();
|
.launch();
|
||||||
|
|
||||||
verify(mActivity).startActivityForResult(any(Intent.class), eq(requestCode));
|
verify(mFragment).startActivityForResult(any(Intent.class), eq(requestCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ package com.android.settings.dashboard;
|
|||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
import com.android.settings.core.PreferenceControllerListHelper;
|
||||||
import com.android.settings.search.DatabaseIndexingUtils;
|
import com.android.settings.search.DatabaseIndexingUtils;
|
||||||
import com.android.settings.search.Indexable;
|
import com.android.settings.search.Indexable;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
@@ -58,6 +60,14 @@ public class DashboardFragmentSearchIndexProviderInspector {
|
|||||||
try {
|
try {
|
||||||
controllersFromFragment =
|
controllersFromFragment =
|
||||||
((DashboardFragment) fragment).createPreferenceControllers(context);
|
((DashboardFragment) fragment).createPreferenceControllers(context);
|
||||||
|
List<BasePreferenceController> controllersFromXml = PreferenceControllerListHelper
|
||||||
|
.getPreferenceControllersFromXml(context,
|
||||||
|
((DashboardFragment) fragment).getPreferenceScreenResId());
|
||||||
|
final List<BasePreferenceController> uniqueControllerFromXml =
|
||||||
|
PreferenceControllerListHelper.filterControllers(
|
||||||
|
controllersFromXml, controllersFromFragment);
|
||||||
|
controllersFromFragment.addAll(uniqueControllerFromXml);
|
||||||
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
// Can't do much with exception, assume the test passed.
|
// Can't do much with exception, assume the test passed.
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* 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.dashboard.conditional;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.util.FeatureFlagUtils;
|
||||||
|
|
||||||
|
import com.android.settings.Settings;
|
||||||
|
import com.android.settings.TestConfig;
|
||||||
|
import com.android.settings.core.FeatureFlags;
|
||||||
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
|
import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
|
||||||
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows =
|
||||||
|
SettingsShadowSystemProperties.class)
|
||||||
|
public class BackgroundDataConditionTest {
|
||||||
|
@Mock
|
||||||
|
private ConditionManager mConditionManager;
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
|
when(mConditionManager.getContext()).thenReturn(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onPrimaryClick_v2enabled_shouldReturnv2SummaryActivity() {
|
||||||
|
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.DATA_USAGE_SETTINGS_V2, true);
|
||||||
|
|
||||||
|
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||||
|
BackgroundDataCondition backgroundDataCondition
|
||||||
|
= new BackgroundDataCondition(mConditionManager);
|
||||||
|
backgroundDataCondition.onPrimaryClick();
|
||||||
|
verify(mContext).startActivity(argumentCaptor.capture());
|
||||||
|
Intent intent = argumentCaptor.getValue();
|
||||||
|
|
||||||
|
assertThat(intent.getComponent().getClassName()).isEqualTo(
|
||||||
|
Settings.DataUsageSummaryActivity.class.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onPrimaryClick_v2disabled_shouldReturnLegacySummaryActivity() {
|
||||||
|
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.DATA_USAGE_SETTINGS_V2, false);
|
||||||
|
|
||||||
|
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||||
|
BackgroundDataCondition backgroundDataCondition
|
||||||
|
= new BackgroundDataCondition(mConditionManager);
|
||||||
|
backgroundDataCondition.onPrimaryClick();
|
||||||
|
verify(mContext).startActivity(argumentCaptor.capture());
|
||||||
|
Intent intent = argumentCaptor.getValue();
|
||||||
|
|
||||||
|
assertThat(intent.getComponent().getClassName()).isEqualTo(
|
||||||
|
Settings.DataUsageSummaryLegacyActivity.class.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,13 +17,15 @@
|
|||||||
package com.android.settings.development;
|
package com.android.settings.development;
|
||||||
|
|
||||||
import static com.android.settings.development.BluetoothMaxConnectedAudioDevicesPreferenceController
|
import static com.android.settings.development.BluetoothMaxConnectedAudioDevicesPreferenceController
|
||||||
.BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY;
|
.MAX_CONNECTED_AUDIO_DEVICES_PROPERTY;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.support.v7.preference.ListPreference;
|
import android.support.v7.preference.ListPreference;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
@@ -39,6 +41,7 @@ import org.junit.Test;
|
|||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.mockito.Spy;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
@@ -47,37 +50,41 @@ import org.robolectric.annotation.Config;
|
|||||||
sdk = TestConfig.SDK_VERSION,
|
sdk = TestConfig.SDK_VERSION,
|
||||||
shadows = {SettingsShadowSystemProperties.class})
|
shadows = {SettingsShadowSystemProperties.class})
|
||||||
public class BluetoothMaxConnectedAudioDevicesPreferenceControllerTest {
|
public class BluetoothMaxConnectedAudioDevicesPreferenceControllerTest {
|
||||||
|
private static final int TEST_MAX_CONNECTED_AUDIO_DEVICES = 3;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private PreferenceScreen mPreferenceScreen;
|
private PreferenceScreen mPreferenceScreen;
|
||||||
|
@Spy
|
||||||
|
private Context mSpyContext = RuntimeEnvironment.application;
|
||||||
|
@Spy
|
||||||
|
private Resources mSpyResources = RuntimeEnvironment.application.getResources();
|
||||||
|
|
||||||
private Context mContext;
|
|
||||||
private ListPreference mPreference;
|
private ListPreference mPreference;
|
||||||
private BluetoothMaxConnectedAudioDevicesPreferenceController mController;
|
private BluetoothMaxConnectedAudioDevicesPreferenceController mController;
|
||||||
|
|
||||||
/**
|
private CharSequence[] mListValues;
|
||||||
* 0: 1 device maximum (Default)
|
private CharSequence[] mListEntries;
|
||||||
* 1: 2 devices maximum
|
|
||||||
* 2: 3 devices maximum
|
|
||||||
* 3: 4 devices maximum
|
|
||||||
* 4: 5 devices maximum
|
|
||||||
*/
|
|
||||||
private String[] mListValues;
|
|
||||||
private String[] mListSummaries;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = RuntimeEnvironment.application;
|
doReturn(mSpyResources).when(mSpyContext).getResources();
|
||||||
mPreference = new ListPreference(mContext);
|
// Get XML values without mock
|
||||||
mListValues = mContext.getResources().getStringArray(
|
// Setup test list preference using XML values
|
||||||
R.array.bluetooth_max_connected_audio_devices_values);
|
mPreference = new ListPreference(mSpyContext);
|
||||||
mListSummaries = mContext.getResources().getStringArray(
|
mPreference.setEntries(R.array.bluetooth_max_connected_audio_devices);
|
||||||
R.array.bluetooth_max_connected_audio_devices);
|
mPreference.setEntryValues(R.array.bluetooth_max_connected_audio_devices_values);
|
||||||
mController = new BluetoothMaxConnectedAudioDevicesPreferenceController(mContext);
|
// Stub default max connected audio devices to a test controlled value
|
||||||
|
doReturn(TEST_MAX_CONNECTED_AUDIO_DEVICES).when(mSpyResources).getInteger(
|
||||||
|
com.android.internal.R.integer.config_bluetooth_max_connected_audio_devices);
|
||||||
|
// Init the actual controller
|
||||||
|
mController = new BluetoothMaxConnectedAudioDevicesPreferenceController(mSpyContext);
|
||||||
|
// Construct preference in the controller via a mocked preference screen object
|
||||||
when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
|
when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
|
||||||
mPreference);
|
mPreference);
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
|
mListValues = mPreference.getEntryValues();
|
||||||
|
mListEntries = mPreference.getEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -85,40 +92,68 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceControllerTest {
|
|||||||
SettingsShadowSystemProperties.clear();
|
SettingsShadowSystemProperties.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void verifyResourceSizeAndRange() {
|
||||||
|
// Verify normal list entries and default preference entries have the same size
|
||||||
|
assertThat(mListEntries.length).isEqualTo(mListValues.length);
|
||||||
|
// Verify that list entries are formatted correctly
|
||||||
|
final String defaultEntry = String.format(mListEntries[0].toString(),
|
||||||
|
TEST_MAX_CONNECTED_AUDIO_DEVICES);
|
||||||
|
assertThat(mListEntries[0]).isEqualTo(defaultEntry);
|
||||||
|
// Update the preference
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
// Verify default preference value, entry and summary
|
||||||
|
assertThat(mPreference.getValue()).isEqualTo(mListValues[0]);
|
||||||
|
assertThat(mPreference.getEntry()).isEqualTo(mListEntries[0]);
|
||||||
|
assertThat(mPreference.getSummary()).isEqualTo(mListEntries[0]);
|
||||||
|
// Verify that default system property is empty
|
||||||
|
assertThat(SystemProperties.get(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY)).isEmpty();
|
||||||
|
// Verify default property integer value
|
||||||
|
assertThat(SystemProperties.getInt(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY,
|
||||||
|
TEST_MAX_CONNECTED_AUDIO_DEVICES)).isEqualTo(TEST_MAX_CONNECTED_AUDIO_DEVICES);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onPreferenceChange_setNumberOfDevices() {
|
public void onPreferenceChange_setNumberOfDevices() {
|
||||||
for (int numberOfDevices = 0; numberOfDevices < mListValues.length; numberOfDevices++) {
|
for (final CharSequence newValue : mListValues) {
|
||||||
mController.onPreferenceChange(mPreference, mListValues[numberOfDevices]);
|
// Change preference using a list value
|
||||||
|
mController.onPreferenceChange(mPreference, newValue);
|
||||||
final String currentValue = SystemProperties.get(
|
// Verify that value is set on the preference
|
||||||
BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY);
|
assertThat(mPreference.getValue()).isEqualTo(newValue);
|
||||||
|
int index = mPreference.findIndexOfValue(newValue.toString());
|
||||||
assertThat(currentValue).isEqualTo(mListValues[numberOfDevices]);
|
assertThat(mPreference.getEntry()).isEqualTo(mListEntries[index]);
|
||||||
assertThat(mPreference.getValue()).isEqualTo(mListValues[numberOfDevices]);
|
// Verify that system property is set correctly after the change
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[numberOfDevices]);
|
final String currentValue = SystemProperties.get(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY);
|
||||||
|
assertThat(currentValue).isEqualTo(mListValues[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_NumberOfDevicesUpdated_shouldSetPreference() {
|
public void updateState_NumberOfDevicesUpdated_shouldSetPreference() {
|
||||||
for (int numberOfDevices = 0; numberOfDevices < mListValues.length; numberOfDevices++) {
|
for (int i = 0; i < mListValues.length; ++i) {
|
||||||
SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY,
|
final String propertyValue = mListValues[i].toString();
|
||||||
mListValues[numberOfDevices]);
|
SystemProperties.set(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, propertyValue);
|
||||||
|
// Verify that value is set on the preference
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getValue()).isEqualTo(mListValues[i]);
|
||||||
assertThat(mPreference.getValue()).isEqualTo(mListValues[numberOfDevices]);
|
assertThat(mPreference.getEntry()).isEqualTo(mListEntries[i]);
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[numberOfDevices]);
|
assertThat(mPreference.getSummary()).isEqualTo(mListEntries[i]);
|
||||||
|
// Verify that property value remain unchanged
|
||||||
|
assertThat(SystemProperties.get(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY))
|
||||||
|
.isEqualTo(propertyValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_noValueSet_shouldSetDefaultTo1device() {
|
public void updateState_noValueSet_shouldSetDefaultTo1device() {
|
||||||
SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, "garbage");
|
SystemProperties.set(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, "garbage");
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
|
// Verify that preference is reset back to default and property is reset to default
|
||||||
assertThat(mPreference.getValue()).isEqualTo(mListValues[0]);
|
assertThat(mPreference.getValue()).isEqualTo(mListValues[0]);
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[0]);
|
assertThat(mPreference.getEntry()).isEqualTo(mListEntries[0]);
|
||||||
|
assertThat(mPreference.getSummary()).isEqualTo(mListEntries[0]);
|
||||||
|
assertThat(SystemProperties.get(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY)).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -126,26 +161,30 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceControllerTest {
|
|||||||
mController.onDeveloperOptionsSwitchDisabled();
|
mController.onDeveloperOptionsSwitchDisabled();
|
||||||
|
|
||||||
assertThat(mPreference.isEnabled()).isFalse();
|
assertThat(mPreference.isEnabled()).isFalse();
|
||||||
|
// Verify that preference is reset back to default and property is reset to default
|
||||||
assertThat(mPreference.getValue()).isEqualTo(mListValues[0]);
|
assertThat(mPreference.getValue()).isEqualTo(mListValues[0]);
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[0]);
|
assertThat(mPreference.getEntry()).isEqualTo(mListEntries[0]);
|
||||||
final String currentValue = SystemProperties.get(
|
assertThat(mPreference.getSummary()).isEqualTo(mListEntries[0]);
|
||||||
BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY);
|
assertThat(SystemProperties.get(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY)).isEmpty();
|
||||||
assertThat(currentValue).isEqualTo(mListValues[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
|
public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
|
||||||
for (int numberOfDevices = 0; numberOfDevices < mListValues.length; numberOfDevices++) {
|
for (int i = 0; i < mListValues.length; ++i) {
|
||||||
|
final String initialValue = mListValues[i].toString();
|
||||||
mController.onDeveloperOptionsSwitchDisabled();
|
mController.onDeveloperOptionsSwitchDisabled();
|
||||||
assertThat(mPreference.isEnabled()).isFalse();
|
assertThat(mPreference.isEnabled()).isFalse();
|
||||||
|
|
||||||
SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY,
|
SystemProperties.set(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, initialValue);
|
||||||
mListValues[numberOfDevices]);
|
|
||||||
mController.onDeveloperOptionsSwitchEnabled();
|
mController.onDeveloperOptionsSwitchEnabled();
|
||||||
|
|
||||||
assertThat(mPreference.isEnabled()).isTrue();
|
assertThat(mPreference.isEnabled()).isTrue();
|
||||||
assertThat(mPreference.getValue()).isEqualTo(mListValues[numberOfDevices]);
|
assertThat(mPreference.getValue()).isEqualTo(mListValues[i]);
|
||||||
assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[numberOfDevices]);
|
assertThat(mPreference.getEntry()).isEqualTo(mListEntries[i]);
|
||||||
|
assertThat(mPreference.getSummary()).isEqualTo(mListEntries[i]);
|
||||||
|
// Verify that property value remain unchanged
|
||||||
|
assertThat(SystemProperties.get(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY))
|
||||||
|
.isEqualTo(initialValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* 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.display;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.v7.preference.Preference;
|
||||||
|
|
||||||
|
import com.android.internal.app.ColorDisplayController;
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.TestConfig;
|
||||||
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||||
|
public class ColorModePreferenceControllerTest {
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private Preference mPreference;
|
||||||
|
@Mock
|
||||||
|
private ColorDisplayController mColorDisplayController;
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private ColorModePreferenceController mController;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mContext = RuntimeEnvironment.application;
|
||||||
|
mController = spy(new ColorModePreferenceController(mContext));
|
||||||
|
doReturn(mColorDisplayController).when(mController).getColorDisplayController();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_colorModeSaturated_shouldSetSummaryToSaturated() {
|
||||||
|
when(mColorDisplayController.getColorMode())
|
||||||
|
.thenReturn(ColorDisplayController.COLOR_MODE_SATURATED);
|
||||||
|
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
|
verify(mPreference).setSummary(mContext.getString(R.string.color_mode_option_saturated));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_colorModeBoosted_shouldSetSummaryToBoosted() {
|
||||||
|
when(mColorDisplayController.getColorMode())
|
||||||
|
.thenReturn(ColorDisplayController.COLOR_MODE_BOOSTED);
|
||||||
|
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
|
verify(mPreference).setSummary(mContext.getString(R.string.color_mode_option_boosted));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_colorModeNatural_shouldSetSummaryToNatural() {
|
||||||
|
when(mColorDisplayController.getColorMode())
|
||||||
|
.thenReturn(ColorDisplayController.COLOR_MODE_NATURAL);
|
||||||
|
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
|
verify(mPreference).setSummary(mContext.getString(R.string.color_mode_option_natural));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -71,7 +71,7 @@ public class BatteryInfoTest {
|
|||||||
private static final int PLUGGED_IN = 1;
|
private static final int PLUGGED_IN = 1;
|
||||||
private static final long REMAINING_TIME_NULL = -1;
|
private static final long REMAINING_TIME_NULL = -1;
|
||||||
private static final long REMAINING_TIME = 2;
|
private static final long REMAINING_TIME = 2;
|
||||||
public static final String ENHANCED_STRING_SUFFIX = "left based on your usage";
|
public static final String ENHANCED_STRING_SUFFIX = "based on your usage";
|
||||||
public static final long TEST_CHARGE_TIME_REMAINING = TimeUnit.MINUTES.toMicros(1);
|
public static final long TEST_CHARGE_TIME_REMAINING = TimeUnit.MINUTES.toMicros(1);
|
||||||
public static final String TEST_CHARGE_TIME_REMAINING_STRINGIFIED =
|
public static final String TEST_CHARGE_TIME_REMAINING_STRINGIFIED =
|
||||||
"1m left until fully charged";
|
"1m left until fully charged";
|
||||||
@@ -183,7 +183,7 @@ public class BatteryInfoTest {
|
|||||||
// Check that strings are showing less than 15 minutes remaining regardless of exact time.
|
// Check that strings are showing less than 15 minutes remaining regardless of exact time.
|
||||||
assertThat(info.chargeLabel.toString()).isEqualTo(
|
assertThat(info.chargeLabel.toString()).isEqualTo(
|
||||||
mContext.getString(R.string.power_remaining_less_than_duration,
|
mContext.getString(R.string.power_remaining_less_than_duration,
|
||||||
TEST_BATTERY_LEVEL_10, FIFTEEN_MIN_FORMATTED));
|
FIFTEEN_MIN_FORMATTED, TEST_BATTERY_LEVEL_10));
|
||||||
assertThat(info.remainingLabel.toString()).isEqualTo(
|
assertThat(info.remainingLabel.toString()).isEqualTo(
|
||||||
mContext.getString(R.string.power_remaining_less_than_duration_only,
|
mContext.getString(R.string.power_remaining_less_than_duration_only,
|
||||||
FIFTEEN_MIN_FORMATTED));
|
FIFTEEN_MIN_FORMATTED));
|
||||||
|
|||||||
@@ -445,19 +445,6 @@ public class PowerUsageSummaryLegacyTest {
|
|||||||
eq(Bundle.EMPTY), any());
|
eq(Bundle.EMPTY), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("b/73892008")
|
|
||||||
@Test
|
|
||||||
public void testShowBothEstimates_summariesAreBothModified() {
|
|
||||||
doReturn(new TextView(mRealContext)).when(mBatteryLayoutPref).findViewById(R.id.summary2);
|
|
||||||
doReturn(new TextView(mRealContext)).when(mBatteryLayoutPref).findViewById(R.id.summary1);
|
|
||||||
mFragment.onLongClick(new View(mRealContext));
|
|
||||||
TextView summary1 = mFragment.mBatteryLayoutPref.findViewById(R.id.summary1);
|
|
||||||
TextView summary2 = mFragment.mBatteryLayoutPref.findViewById(R.id.summary2);
|
|
||||||
Robolectric.flushBackgroundThreadScheduler();
|
|
||||||
assertThat(summary2.getText().toString()).contains(NEW_ML_EST_SUFFIX);
|
|
||||||
assertThat(summary1.getText().toString()).contains(OLD_EST_SUFFIX);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSaveInstanceState_showAllAppsRestored() {
|
public void testSaveInstanceState_showAllAppsRestored() {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
|||||||
@@ -106,17 +106,17 @@ public class GesturesSettingsPreferenceControllerTest {
|
|||||||
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_ENABLED, 0);
|
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_ENABLED, 0);
|
||||||
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 0);
|
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 0);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
verify(mActivity).getString(R.string.language_input_gesture_summary_off);
|
verify(mActivity).getText(R.string.language_input_gesture_summary_off);
|
||||||
|
|
||||||
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_ENABLED, 1);
|
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_ENABLED, 1);
|
||||||
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 0);
|
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 0);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
verify(mActivity).getString(R.string.language_input_gesture_summary_on_with_assist);
|
verify(mActivity).getText(R.string.language_input_gesture_summary_on_with_assist);
|
||||||
|
|
||||||
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_ENABLED, 0);
|
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_ENABLED, 0);
|
||||||
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 1);
|
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 1);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
verify(mActivity).getString(R.string.language_input_gesture_summary_on_non_assist);
|
verify(mActivity).getText(R.string.language_input_gesture_summary_on_non_assist);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import static org.mockito.ArgumentMatchers.argThat;
|
|||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
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;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -34,7 +35,6 @@ import android.support.v7.preference.Preference;
|
|||||||
import android.support.v7.preference.PreferenceCategory;
|
import android.support.v7.preference.PreferenceCategory;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.TestConfig;
|
import com.android.settings.TestConfig;
|
||||||
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
|
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
|
||||||
@@ -43,7 +43,8 @@ import com.android.settings.widget.AppPreference;
|
|||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
import com.android.settingslib.location.RecentLocationApps;
|
import com.android.settingslib.location.RecentLocationApps;
|
||||||
import com.android.settingslib.location.RecentLocationApps.Request;
|
import com.android.settingslib.location.RecentLocationApps.Request;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -56,9 +57,6 @@ import org.mockito.MockitoAnnotations;
|
|||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||||
public class RecentLocationRequestPreferenceControllerTest {
|
public class RecentLocationRequestPreferenceControllerTest {
|
||||||
@@ -71,6 +69,8 @@ public class RecentLocationRequestPreferenceControllerTest {
|
|||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
@Mock
|
@Mock
|
||||||
private RecentLocationApps mRecentLocationApps;
|
private RecentLocationApps mRecentLocationApps;
|
||||||
|
@Mock
|
||||||
|
private Preference mSeeAllButton;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private RecentLocationRequestPreferenceController mController;
|
private RecentLocationRequestPreferenceController mController;
|
||||||
@@ -86,6 +86,7 @@ public class RecentLocationRequestPreferenceControllerTest {
|
|||||||
mController = spy(new RecentLocationRequestPreferenceController(
|
mController = spy(new RecentLocationRequestPreferenceController(
|
||||||
mContext, mFragment, mLifecycle, mRecentLocationApps));
|
mContext, mFragment, mLifecycle, mRecentLocationApps));
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mCategory);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mCategory);
|
||||||
|
when(mScreen.findPreference(mController.KEY_SEE_ALL)).thenReturn(mSeeAllButton);
|
||||||
final String key = mController.getPreferenceKey();
|
final String key = mController.getPreferenceKey();
|
||||||
when(mCategory.getKey()).thenReturn(key);
|
when(mCategory.getKey()).thenReturn(key);
|
||||||
when(mCategory.getContext()).thenReturn(mContext);
|
when(mCategory.getContext()).thenReturn(mContext);
|
||||||
@@ -123,38 +124,43 @@ public class RecentLocationRequestPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_hasRecentRequest_shouldRemoveAllAndAddInjectedSettings() {
|
public void updateState_hasRecentRequest_shouldRemoveAllAndAddInjectedSettings() {
|
||||||
final List<RecentLocationApps.Request> requests = new ArrayList<>();
|
List<Request> requests = createMockRequests(2);
|
||||||
final Request req1 = mock(Request.class);
|
|
||||||
final Request req2 = mock(Request.class);
|
|
||||||
requests.add(req1);
|
|
||||||
requests.add(req2);
|
|
||||||
doReturn(requests).when(mRecentLocationApps).getAppListSorted();
|
doReturn(requests).when(mRecentLocationApps).getAppListSorted();
|
||||||
final String title1 = "testTitle1";
|
|
||||||
final String title2 = "testTitle2";
|
|
||||||
final AppPreference preference1 = mock(AppPreference.class);
|
|
||||||
final AppPreference preference2 = mock(AppPreference.class);
|
|
||||||
when(preference1.getTitle()).thenReturn(title1);
|
|
||||||
when(preference2.getTitle()).thenReturn(title2);
|
|
||||||
doReturn(preference1).when(mController)
|
|
||||||
.createAppPreference(any(Context.class), eq(req1));
|
|
||||||
doReturn(preference2).when(mController)
|
|
||||||
.createAppPreference(any(Context.class), eq(req2));
|
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
mController.updateState(mCategory);
|
mController.updateState(mCategory);
|
||||||
|
|
||||||
verify(mCategory).removeAll();
|
verify(mCategory).removeAll();
|
||||||
// Verifies two preferences are added in original order
|
// Verifies two preferences are added in original order
|
||||||
InOrder inOrder = Mockito.inOrder(mCategory);
|
InOrder inOrder = Mockito.inOrder(mCategory);
|
||||||
inOrder.verify(mCategory).addPreference(argThat(titleMatches(title1)));
|
inOrder.verify(mCategory).addPreference(argThat(titleMatches("appTitle0")));
|
||||||
inOrder.verify(mCategory).addPreference(argThat(titleMatches(title2)));
|
inOrder.verify(mCategory).addPreference(argThat(titleMatches("appTitle1")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_hasOverThreeRequests_shouldDisplaySeeAllButton() {
|
||||||
|
List<Request> requests = createMockRequests(6);
|
||||||
|
when(mRecentLocationApps.getAppListSorted()).thenReturn(requests);
|
||||||
|
|
||||||
|
mController.displayPreference(mScreen);
|
||||||
|
mController.updateState(mCategory);
|
||||||
|
|
||||||
|
verify(mCategory).removeAll();
|
||||||
|
// Verifies the first three preferences are added
|
||||||
|
InOrder inOrder = Mockito.inOrder(mCategory);
|
||||||
|
inOrder.verify(mCategory).addPreference(argThat(titleMatches("appTitle0")));
|
||||||
|
inOrder.verify(mCategory).addPreference(argThat(titleMatches("appTitle1")));
|
||||||
|
inOrder.verify(mCategory).addPreference(argThat(titleMatches("appTitle2")));
|
||||||
|
verify(mCategory, never()).addPreference(argThat(titleMatches("appTitle3")));
|
||||||
|
// Verifies the "See all" preference is visible
|
||||||
|
verify(mSeeAllButton).setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createAppPreference_shouldAddClickListener() {
|
public void createAppPreference_shouldAddClickListener() {
|
||||||
final Request request = mock(Request.class);
|
final Request request = mock(Request.class);
|
||||||
final AppPreference preference = mock(AppPreference.class);
|
final AppPreference preference = mock(AppPreference.class);
|
||||||
doReturn(preference).when(mController)
|
doReturn(preference).when(mController).createAppPreference(any(Context.class));
|
||||||
.createAppPreference(any(Context.class));
|
|
||||||
|
|
||||||
mController.createAppPreference(mContext, request);
|
mController.createAppPreference(mContext, request);
|
||||||
|
|
||||||
@@ -190,4 +196,19 @@ public class RecentLocationRequestPreferenceControllerTest {
|
|||||||
return preference -> TextUtils.equals(expected, preference.getTitle());
|
return preference -> TextUtils.equals(expected, preference.getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<RecentLocationApps.Request> createMockRequests(int count) {
|
||||||
|
List<RecentLocationApps.Request> requests = new ArrayList<>();
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
// Add mock requests
|
||||||
|
Request req = mock(Request.class, "request" + i);
|
||||||
|
requests.add(req);
|
||||||
|
// Map mock AppPreferences with mock requests
|
||||||
|
String title = "appTitle" + i;
|
||||||
|
AppPreference appPreference = mock(AppPreference.class, "AppPreference" + i);
|
||||||
|
doReturn(title).when(appPreference).getTitle();
|
||||||
|
doReturn(appPreference)
|
||||||
|
.when(mController).createAppPreference(any(Context.class), eq(req));
|
||||||
|
}
|
||||||
|
return requests;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 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.location;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.arch.lifecycle.LifecycleOwner;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.provider.Settings.Secure;
|
||||||
|
import android.support.v7.preference.PreferenceCategory;
|
||||||
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
|
import com.android.settings.TestConfig;
|
||||||
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
|
import com.android.settings.widget.AppPreference;
|
||||||
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
import com.android.settingslib.location.RecentLocationApps;
|
||||||
|
import com.android.settingslib.location.RecentLocationApps.Request;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
|
/** Unit tests for {@link RecentLocationRequestSeeAllPreferenceController} */
|
||||||
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||||
|
public class RecentLocationRequestSeeAllPreferenceControllerTest {
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
RecentLocationRequestSeeAllFragment mFragment;
|
||||||
|
@Mock
|
||||||
|
private PreferenceScreen mScreen;
|
||||||
|
@Mock
|
||||||
|
private PreferenceCategory mCategory;
|
||||||
|
@Mock
|
||||||
|
private RecentLocationApps mRecentLocationApps;
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private LifecycleOwner mLifecycleOwner;
|
||||||
|
private Lifecycle mLifecycle;
|
||||||
|
private RecentLocationRequestSeeAllPreferenceController mController;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
|
mLifecycleOwner = () -> mLifecycle;
|
||||||
|
mLifecycle = new Lifecycle(mLifecycleOwner);
|
||||||
|
mController = spy(
|
||||||
|
new RecentLocationRequestSeeAllPreferenceController(
|
||||||
|
mContext, mLifecycle, mFragment, mRecentLocationApps));
|
||||||
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mCategory);
|
||||||
|
final String key = mController.getPreferenceKey();
|
||||||
|
when(mCategory.getKey()).thenReturn(key);
|
||||||
|
when(mCategory.getContext()).thenReturn(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onLocationModeChanged_locationOn_shouldEnablePreference() {
|
||||||
|
mController.displayPreference(mScreen);
|
||||||
|
|
||||||
|
mController.onLocationModeChanged(Secure.LOCATION_MODE_HIGH_ACCURACY, false);
|
||||||
|
|
||||||
|
verify(mCategory).setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onLocationModeChanged_locationOff_shouldDisablePreference() {
|
||||||
|
mController.displayPreference(mScreen);
|
||||||
|
|
||||||
|
mController.onLocationModeChanged(Secure.LOCATION_MODE_OFF, false);
|
||||||
|
|
||||||
|
verify(mCategory).setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_shouldRemoveAll() {
|
||||||
|
doReturn(Collections.EMPTY_LIST).when(mRecentLocationApps).getAppListSorted();
|
||||||
|
|
||||||
|
mController.displayPreference(mScreen);
|
||||||
|
mController.updateState(mCategory);
|
||||||
|
|
||||||
|
verify(mCategory).removeAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_hasRecentLocationRequest_shouldAddPreference() {
|
||||||
|
Request request = mock(Request.class);
|
||||||
|
AppPreference appPreference = mock(AppPreference.class);
|
||||||
|
doReturn(appPreference)
|
||||||
|
.when(mController).createAppPreference(any(Context.class), eq(request));
|
||||||
|
when(mRecentLocationApps.getAppListSorted())
|
||||||
|
.thenReturn(new ArrayList<>(Arrays.asList(request)));
|
||||||
|
|
||||||
|
mController.displayPreference(mScreen);
|
||||||
|
mController.updateState(mCategory);
|
||||||
|
|
||||||
|
verify(mCategory).removeAll();
|
||||||
|
verify(mCategory).addPreference(appPreference);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,11 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.network;
|
package com.android.settings.network;
|
||||||
|
|
||||||
import static android.arch.lifecycle.Lifecycle.Event.ON_PAUSE;
|
import static android.arch.lifecycle.Lifecycle.Event.ON_START;
|
||||||
import static android.arch.lifecycle.Lifecycle.Event.ON_RESUME;
|
import static android.arch.lifecycle.Lifecycle.Event.ON_STOP;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
@@ -110,11 +108,11 @@ public class MobileNetworkPreferenceControllerTest {
|
|||||||
mLifecycle.addObserver(mController);
|
mLifecycle.addObserver(mController);
|
||||||
doReturn(true).when(mController).isAvailable();
|
doReturn(true).when(mController).isAvailable();
|
||||||
|
|
||||||
mLifecycle.handleLifecycleEvent(ON_RESUME);
|
mLifecycle.handleLifecycleEvent(ON_START);
|
||||||
verify(mTelephonyManager).listen(mController.mPhoneStateListener,
|
verify(mTelephonyManager).listen(mController.mPhoneStateListener,
|
||||||
PhoneStateListener.LISTEN_SERVICE_STATE);
|
PhoneStateListener.LISTEN_SERVICE_STATE);
|
||||||
|
|
||||||
mLifecycle.handleLifecycleEvent(ON_PAUSE);
|
mLifecycle.handleLifecycleEvent(ON_STOP);
|
||||||
verify(mTelephonyManager).listen(mController.mPhoneStateListener,
|
verify(mTelephonyManager).listen(mController.mPhoneStateListener,
|
||||||
PhoneStateListener.LISTEN_NONE);
|
PhoneStateListener.LISTEN_NONE);
|
||||||
}
|
}
|
||||||
@@ -131,8 +129,8 @@ public class MobileNetworkPreferenceControllerTest {
|
|||||||
|
|
||||||
// Display pref and go through lifecycle to set up listener.
|
// Display pref and go through lifecycle to set up listener.
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
mLifecycle.handleLifecycleEvent(ON_RESUME);
|
mLifecycle.handleLifecycleEvent(ON_START);
|
||||||
verify(mController).onResume();
|
verify(mController).onStart();
|
||||||
verify(mTelephonyManager).listen(mController.mPhoneStateListener,
|
verify(mTelephonyManager).listen(mController.mPhoneStateListener,
|
||||||
PhoneStateListener.LISTEN_SERVICE_STATE);
|
PhoneStateListener.LISTEN_SERVICE_STATE);
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class SliceBuilderUtilsTest {
|
|||||||
SliceData data = getDummyData();
|
SliceData data = getDummyData();
|
||||||
FakePreferenceController controller = new FakePreferenceController(mContext, KEY);
|
FakePreferenceController controller = new FakePreferenceController(mContext, KEY);
|
||||||
|
|
||||||
String summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
||||||
|
|
||||||
assertThat(summary).isEqualTo(data.getSummary());
|
assertThat(summary).isEqualTo(data.getSummary());
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ public class SliceBuilderUtilsTest {
|
|||||||
String controllerSummary = "new_Summary";
|
String controllerSummary = "new_Summary";
|
||||||
doReturn(controllerSummary).when(controller).getSummary();
|
doReturn(controllerSummary).when(controller).getSummary();
|
||||||
|
|
||||||
String summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
||||||
|
|
||||||
assertThat(summary).isEqualTo(controllerSummary);
|
assertThat(summary).isEqualTo(controllerSummary);
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ public class SliceBuilderUtilsTest {
|
|||||||
SliceData data = getDummyData((String) null);
|
SliceData data = getDummyData((String) null);
|
||||||
FakePreferenceController controller = new FakePreferenceController(mContext, KEY);
|
FakePreferenceController controller = new FakePreferenceController(mContext, KEY);
|
||||||
|
|
||||||
String summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
||||||
|
|
||||||
assertThat(summary).isEqualTo(data.getScreenTitle());
|
assertThat(summary).isEqualTo(data.getScreenTitle());
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ public class SliceBuilderUtilsTest {
|
|||||||
public void testDynamicSummary_placeHolderString_returnsScreenTitle() {
|
public void testDynamicSummary_placeHolderString_returnsScreenTitle() {
|
||||||
SliceData data = getDummyData(mContext.getString(R.string.summary_placeholder));
|
SliceData data = getDummyData(mContext.getString(R.string.summary_placeholder));
|
||||||
FakePreferenceController controller = new FakePreferenceController(mContext, KEY);
|
FakePreferenceController controller = new FakePreferenceController(mContext, KEY);
|
||||||
String summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
||||||
|
|
||||||
assertThat(summary).isEqualTo(data.getScreenTitle());
|
assertThat(summary).isEqualTo(data.getScreenTitle());
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ public class SliceBuilderUtilsTest {
|
|||||||
FakePreferenceController controller = spy(new FakePreferenceController(mContext, KEY));
|
FakePreferenceController controller = spy(new FakePreferenceController(mContext, KEY));
|
||||||
doReturn(summaryPlaceholder).when(controller).getSummary();
|
doReturn(summaryPlaceholder).when(controller).getSummary();
|
||||||
|
|
||||||
String summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
||||||
|
|
||||||
assertThat(summary).isEqualTo(data.getScreenTitle());
|
assertThat(summary).isEqualTo(data.getScreenTitle());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,10 +52,8 @@ public class AboutPhoneSettingsTests {
|
|||||||
// TODO: retrieve using name/ids from com.android.settings package
|
// TODO: retrieve using name/ids from com.android.settings package
|
||||||
private static final String[] sResourceTexts = {
|
private static final String[] sResourceTexts = {
|
||||||
"Phone number",
|
"Phone number",
|
||||||
"SIM status",
|
"Legal information",
|
||||||
"Model & hardware",
|
"Regulatory labels"
|
||||||
"MEID",
|
|
||||||
"Android version"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private UiDevice mDevice;
|
private UiDevice mDevice;
|
||||||
@@ -94,11 +92,11 @@ public class AboutPhoneSettingsTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAllMenuEntriesExist() throws Exception {
|
public void testAllMenuEntriesExist() {
|
||||||
searchForItemsAndTakeAction(mDevice, sResourceTexts);
|
searchForItemsAndTakeAction(mDevice, sResourceTexts);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void launchAboutPhoneSettings(String aboutSetting) throws Exception {
|
private void launchAboutPhoneSettings(String aboutSetting) {
|
||||||
Intent aboutIntent = new Intent(aboutSetting);
|
Intent aboutIntent = new Intent(aboutSetting);
|
||||||
aboutIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
aboutIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
InstrumentationRegistry.getTargetContext().startActivity(aboutIntent);
|
InstrumentationRegistry.getTargetContext().startActivity(aboutIntent);
|
||||||
@@ -107,8 +105,7 @@ public class AboutPhoneSettingsTests {
|
|||||||
/**
|
/**
|
||||||
* Removes items found in the view and optionally takes some action.
|
* Removes items found in the view and optionally takes some action.
|
||||||
*/
|
*/
|
||||||
private void removeItemsAndTakeAction(UiDevice device, ArrayList<String> itemsLeftToFind)
|
private void removeItemsAndTakeAction(UiDevice device, ArrayList<String> itemsLeftToFind) {
|
||||||
throws Exception {
|
|
||||||
for (Iterator<String> iterator = itemsLeftToFind.iterator(); iterator.hasNext(); ) {
|
for (Iterator<String> iterator = itemsLeftToFind.iterator(); iterator.hasNext(); ) {
|
||||||
String itemText = iterator.next();
|
String itemText = iterator.next();
|
||||||
UiObject2 item = device.wait(Until.findObject(By.text(itemText)), TIMEOUT);
|
UiObject2 item = device.wait(Until.findObject(By.text(itemText)), TIMEOUT);
|
||||||
@@ -124,8 +121,7 @@ public class AboutPhoneSettingsTests {
|
|||||||
* <p>Will scroll down the screen until it has found all elements or reached the bottom.
|
* <p>Will scroll down the screen until it has found all elements or reached the bottom.
|
||||||
* This allows elements to be found and acted on even if they change order.
|
* This allows elements to be found and acted on even if they change order.
|
||||||
*/
|
*/
|
||||||
private void searchForItemsAndTakeAction(UiDevice device, String[] itemsToFind)
|
private void searchForItemsAndTakeAction(UiDevice device, String[] itemsToFind) {
|
||||||
throws Exception {
|
|
||||||
|
|
||||||
ArrayList<String> itemsLeftToFind = new ArrayList<>(Arrays.asList(itemsToFind));
|
ArrayList<String> itemsLeftToFind = new ArrayList<>(Arrays.asList(itemsToFind));
|
||||||
assertWithMessage("There must be at least one item to search for on the screen!")
|
assertWithMessage("There must be at least one item to search for on the screen!")
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* 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.development;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.test.InstrumentationRegistry;
|
||||||
|
import android.support.test.filters.SmallTest;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
import org.hamcrest.CoreMatchers;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
@SmallTest
|
||||||
|
public class BluetoothMaxConnectedAudioDevicesPreferenceControllerInstrumentationTest {
|
||||||
|
|
||||||
|
private Context mTargetContext;
|
||||||
|
private String[] mListValues;
|
||||||
|
private String[] mListEntries;
|
||||||
|
private String mDefaultMaxConnectedAudioDevices;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
mTargetContext = InstrumentationRegistry.getTargetContext();
|
||||||
|
// Get XML values without mock
|
||||||
|
mListValues = mTargetContext.getResources()
|
||||||
|
.getStringArray(R.array.bluetooth_max_connected_audio_devices_values);
|
||||||
|
mListEntries = mTargetContext.getResources()
|
||||||
|
.getStringArray(R.array.bluetooth_max_connected_audio_devices);
|
||||||
|
mDefaultMaxConnectedAudioDevices = String.valueOf(mTargetContext.getResources()
|
||||||
|
.getInteger(
|
||||||
|
com.android.internal.R.integer
|
||||||
|
.config_bluetooth_max_connected_audio_devices));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void verifyResource() {
|
||||||
|
// Verify normal list entries and default preference entries have the same size
|
||||||
|
Assert.assertEquals(mListEntries.length, mListValues.length);
|
||||||
|
Assert.assertThat(Arrays.asList(mListValues),
|
||||||
|
CoreMatchers.hasItem(mDefaultMaxConnectedAudioDevices));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user