Snap for 4773106 from 7e31e22f57 to pi-release
Change-Id: Ie2a30992c945baf4dc844858c2a793e9c2243a8b
This commit is contained in:
@@ -27,19 +27,15 @@
|
||||
<Button
|
||||
android:id="@+id/state_on_button"
|
||||
style="@style/ActionPrimaryButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:paddingEnd="8dp" />
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/state_off_button"
|
||||
style="@style/ActionSecondaryButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:paddingEnd="8dp" />
|
||||
android:layout_gravity="center" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -131,4 +131,7 @@
|
||||
<!-- List of a11y components on the device allowed to be enabled by Settings Slices -->
|
||||
<string-array name="config_settings_slices_accessibility_components" translatable="false"/>
|
||||
|
||||
<!-- Whether or not swipe up gesture's opt-in setting is available on this device -->
|
||||
<bool name="config_swipe_up_gesture_setting_available">false</bool>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -9199,7 +9199,7 @@
|
||||
<!-- Informational text about time left in billing cycle [CHAR LIMIT=60] -->
|
||||
<string name="billing_cycle_less_than_one_day_left">Less than 1 day left</string>
|
||||
|
||||
<!-- Informational text about carrier and update time [CHAR LIMIT=30] -->
|
||||
<!-- Informational text about carrier and update time [CHAR LIMIT=32] -->
|
||||
<string name="carrier_and_update_text">Updated by <xliff:g name="carrier" example="T-mobile">^1</xliff:g> <xliff:g name="time" example="3m">^2</xliff:g> ago</string>
|
||||
|
||||
<!-- Informational text about update time only, without carrier. First argument intentionally skipped. [CHAR LIMIT=30] -->
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import com.android.settings.accessibility.AccessibilitySettings;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settingslib.accessibility.AccessibilityUtils;
|
||||
|
||||
@@ -88,7 +87,7 @@ public class AccessibilitySlicePreferenceController extends TogglePreferenceCont
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
// Return unsupported when the service is disabled or not installed.
|
||||
return getAccessibilityServiceInfo() == null ? DISABLED_UNSUPPORTED : AVAILABLE;
|
||||
return getAccessibilityServiceInfo() == null ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
|
||||
}
|
||||
|
||||
private AccessibilityServiceInfo getAccessibilityServiceInfo() {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class MagnificationNavbarPreferenceController extends BasePreferenceContr
|
||||
public int getAvailabilityStatus() {
|
||||
return MagnificationPreferenceFragment.isApplicable(mContext.getResources())
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,6 +35,6 @@ public class DataSaverController extends BasePreferenceController {
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_data_saver)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,6 @@ public class DeviceAdministratorsController extends BasePreferenceController {
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_device_administrators)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,6 @@ public class EnabledVrListenersController extends BasePreferenceController {
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_enabled_vr_listeners)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,6 @@ public class HighPowerAppsController extends BasePreferenceController {
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_high_power_apps)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,6 @@ public class PremiumSmsController extends BasePreferenceController {
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_premium_sms)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class AppBatteryPreferenceController extends BasePreferenceController
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_app_info_settings_battery)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -56,7 +56,7 @@ public class AppDataUsagePreferenceController extends AppInfoPreferenceControlle
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return isBandwidthControlEnabled() ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return isBandwidthControlEnabled() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -105,11 +105,11 @@ public class AppMemoryPreferenceController extends BasePreferenceController
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (!mContext.getResources().getBoolean(R.bool.config_show_app_info_settings_memory)) {
|
||||
return DISABLED_UNSUPPORTED;
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)
|
||||
? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,7 +46,7 @@ public abstract class DefaultAppShortcutPreferenceControllerBase extends BasePre
|
||||
if (UserManager.get(mContext).isManagedProfile()) {
|
||||
return DISABLED_FOR_USER;
|
||||
}
|
||||
return hasAppCapability() ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return hasAppCapability() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -55,19 +55,19 @@ public class TimeSpentInAppPreferenceController extends BasePreferenceController
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (TextUtils.isEmpty(mPackageName)) {
|
||||
return DISABLED_UNSUPPORTED;
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
final List<ResolveInfo> resolved = mPackageManager.queryIntentActivities(mIntent,
|
||||
0 /* flags */);
|
||||
if (resolved == null || resolved.isEmpty()) {
|
||||
return DISABLED_UNSUPPORTED;
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
for (ResolveInfo info : resolved) {
|
||||
if (isSystemApp(info)) {
|
||||
return AVAILABLE;
|
||||
}
|
||||
}
|
||||
return DISABLED_UNSUPPORTED;
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,7 +41,7 @@ public class BackupSettingsActivityPreferenceController extends BasePreferenceCo
|
||||
public int getAvailabilityStatus() {
|
||||
return mUm.isAdminUser()
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -99,7 +99,7 @@ public class BluetoothDeviceNamePreferenceController extends BasePreferenceContr
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mLocalAdapter != null ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return mLocalAdapter != null ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
/**
|
||||
@@ -57,7 +56,7 @@ public class BluetoothFilesPreferenceController extends BasePreferenceController
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -75,7 +75,7 @@ public class AddDevicePreferenceController extends BasePreferenceController
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -84,7 +84,7 @@ public class AvailableMediaDeviceGroupController extends BasePreferenceControlle
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -128,7 +128,7 @@ public class BluetoothDashboardFragment extends DashboardFragment {
|
||||
BluetoothAdapter adapter = manager.getAdapter();
|
||||
final int status = adapter != null
|
||||
? TogglePreferenceController.AVAILABLE
|
||||
: TogglePreferenceController.DISABLED_UNSUPPORTED;
|
||||
: TogglePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
if (status != TogglePreferenceController.AVAILABLE) {
|
||||
keys.add(KEY_BLUETOOTH_SCREEN);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class BluetoothOnWhileDrivingPreferenceController extends TogglePreferenc
|
||||
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.BLUETOOTH_WHILE_DRIVING)) {
|
||||
return AVAILABLE;
|
||||
}
|
||||
return DISABLED_UNSUPPORTED;
|
||||
return CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,7 +33,6 @@ import com.android.settings.overlay.DockUpdaterFeatureProvider;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
|
||||
/**
|
||||
@@ -88,7 +87,7 @@ public class ConnectedDeviceGroupController extends BasePreferenceController
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.overlay.DockUpdaterFeatureProvider;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
@@ -86,7 +85,7 @@ public class SavedDeviceGroupController extends BasePreferenceController
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -49,8 +49,8 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
|
||||
* {@link #isSupported()}.
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({AVAILABLE, DISABLED_UNSUPPORTED, DISABLED_FOR_USER, DISABLED_DEPENDENT_SETTING,
|
||||
UNAVAILABLE_UNKNOWN})
|
||||
@IntDef({AVAILABLE, UNSUPPORTED_ON_DEVICE, DISABLED_FOR_USER, DISABLED_DEPENDENT_SETTING,
|
||||
CONDITIONALLY_UNAVAILABLE})
|
||||
public @interface AvailabilityStatus {
|
||||
}
|
||||
|
||||
@@ -60,12 +60,20 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
|
||||
public static final int AVAILABLE = 0;
|
||||
|
||||
/**
|
||||
* The setting is not supported by the device.
|
||||
* A generic catch for settings which are currently unavailable, but may become available in
|
||||
* the future. You should use {@link #DISABLED_FOR_USER} or {@link #DISABLED_DEPENDENT_SETTING}
|
||||
* if they describe the condition more accurately.
|
||||
*/
|
||||
public static final int CONDITIONALLY_UNAVAILABLE = 1;
|
||||
|
||||
/**
|
||||
* The setting is not, and will not supported by this device.
|
||||
* <p>
|
||||
* There is no guarantee that the setting page exists, and any links to the Setting should take
|
||||
* you to the home page of Settings.
|
||||
*/
|
||||
public static final int DISABLED_UNSUPPORTED = 1;
|
||||
public static final int UNSUPPORTED_ON_DEVICE = 2;
|
||||
|
||||
|
||||
/**
|
||||
* The setting cannot be changed by the current user.
|
||||
@@ -73,7 +81,7 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
|
||||
* Links to the Setting should take you to the page of the Setting, even if it cannot be
|
||||
* changed.
|
||||
*/
|
||||
public static final int DISABLED_FOR_USER = 2;
|
||||
public static final int DISABLED_FOR_USER = 3;
|
||||
|
||||
/**
|
||||
* The setting has a dependency in the Settings App which is currently blocking access.
|
||||
@@ -90,15 +98,8 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
|
||||
* Links to the Setting should take you to the page of the Setting, even if it cannot be
|
||||
* changed.
|
||||
*/
|
||||
public static final int DISABLED_DEPENDENT_SETTING = 3;
|
||||
public static final int DISABLED_DEPENDENT_SETTING = 4;
|
||||
|
||||
/**
|
||||
* A catch-all case for internal errors and inexplicable unavailability.
|
||||
* <p>
|
||||
* There is no guarantee that the setting page exists, and any links to the Setting should take
|
||||
* you to the home page of Settings.
|
||||
*/
|
||||
public static final int UNAVAILABLE_UNKNOWN = 4;
|
||||
|
||||
protected final String mPreferenceKey;
|
||||
|
||||
@@ -181,8 +182,8 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
|
||||
@Override
|
||||
public final boolean isAvailable() {
|
||||
final int availabilityStatus = getAvailabilityStatus();
|
||||
return (availabilityStatus == AVAILABLE) ||
|
||||
(availabilityStatus == DISABLED_DEPENDENT_SETTING);
|
||||
return (availabilityStatus == AVAILABLE
|
||||
|| availabilityStatus == DISABLED_DEPENDENT_SETTING);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,7 +194,7 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
|
||||
* Note that a return value of {@code true} does not mean that the setting is available.
|
||||
*/
|
||||
public final boolean isSupported() {
|
||||
return getAvailabilityStatus() != DISABLED_UNSUPPORTED;
|
||||
return getAvailabilityStatus() != UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,7 +28,6 @@ import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.SubscriptionPlan;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.Log;
|
||||
import android.util.RecurrenceRule;
|
||||
|
||||
@@ -182,7 +181,7 @@ public class DataUsageSummaryPreferenceController extends BasePreferenceControll
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return DataUsageUtils.hasSim(mActivity)
|
||||
|| DataUsageUtils.hasWifiRadio(mContext) ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
|| DataUsageUtils.hasWifiRadio(mContext) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -50,7 +50,7 @@ public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreference
|
||||
if (mConfig == null) {
|
||||
mConfig = new AmbientDisplayConfiguration(mContext);
|
||||
}
|
||||
return isAvailable(mConfig) ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return isAvailable(mConfig) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -86,7 +86,7 @@ public class AmbientDisplayNotificationsPreferenceController extends
|
||||
if (mConfig == null) {
|
||||
mConfig = new AmbientDisplayConfiguration(mContext);
|
||||
}
|
||||
return mConfig.pulseOnNotificationAvailable() ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return mConfig.pulseOnNotificationAvailable() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -57,7 +57,7 @@ public class AutoBrightnessPreferenceController extends TogglePreferenceControll
|
||||
return mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_automatic_brightness_available)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -71,7 +71,7 @@ public class AutoRotatePreferenceController extends TogglePreferenceController i
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return RotationPolicy.isRotationLockToggleVisible(mContext)
|
||||
? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -50,7 +50,7 @@ public class NightDisplayActivationPreferenceController extends TogglePreference
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return ColorDisplayController.isAvailable(mContext) ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return ColorDisplayController.isAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,7 @@ public class NightDisplayAutoModePreferenceController extends BasePreferenceCont
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return ColorDisplayController.isAvailable(mContext) ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return ColorDisplayController.isAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,7 +35,7 @@ public class NightDisplayCustomEndTimePreferenceController extends BasePreferenc
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return ColorDisplayController.isAvailable(mContext) ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return ColorDisplayController.isAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,7 +35,7 @@ public class NightDisplayCustomStartTimePreferenceController extends BasePrefere
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return ColorDisplayController.isAvailable(mContext) ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return ColorDisplayController.isAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,7 +31,7 @@ public class NightDisplayFooterPreferenceController extends BasePreferenceContro
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return ColorDisplayController.isAvailable(mContext) ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return ColorDisplayController.isAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,7 +35,7 @@ public class NightDisplayIntensityPreferenceController extends SliderPreferenceC
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (!ColorDisplayController.isAvailable(mContext)) {
|
||||
return DISABLED_UNSUPPORTED;
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
} else if (!mController.isActivated()) {
|
||||
return DISABLED_DEPENDENT_SETTING;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class FingerprintStatusPreferenceController extends BasePreferenceControl
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (mFingerprintManager == null || !mFingerprintManager.isHardwareDetected()) {
|
||||
return DISABLED_UNSUPPORTED;
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
if (isUserSupported()) {
|
||||
return AVAILABLE;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class AutoRestrictionPreferenceController extends BasePreferenceControlle
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mPowerUsageFeatureProvider.isSmartBatterySupported()
|
||||
? DISABLED_UNSUPPORTED
|
||||
? UNSUPPORTED_ON_DEVICE
|
||||
: AVAILABLE;
|
||||
}
|
||||
|
||||
|
||||
@@ -511,37 +511,6 @@ public class BatteryUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the app represented by {@code uid} has battery usage more than {@code threshold}
|
||||
*
|
||||
* @param batteryStatsHelper used to check the battery usage
|
||||
* @param userManager used to init the {@code batteryStatsHelper}
|
||||
* @param uid represent the app
|
||||
* @param threshold battery percentage threshold(e.g. 10 means 10% battery usage )
|
||||
* @return {@code true} if battery drain is more than the threshold
|
||||
*/
|
||||
public boolean isAppHeavilyUsed(BatteryStatsHelper batteryStatsHelper, UserManager userManager,
|
||||
int uid, int threshold) {
|
||||
initBatteryStatsHelper(batteryStatsHelper, null /* bundle */, userManager);
|
||||
final int dischargeAmount = batteryStatsHelper.getStats().getDischargeAmount(
|
||||
BatteryStats.STATS_SINCE_CHARGED);
|
||||
List<BatterySipper> batterySippers = batteryStatsHelper.getUsageList();
|
||||
final double hiddenAmount = removeHiddenBatterySippers(batterySippers);
|
||||
|
||||
for (int i = 0, size = batterySippers.size(); i < size; i++) {
|
||||
final BatterySipper batterySipper = batterySippers.get(i);
|
||||
if (batterySipper.getUid() == uid) {
|
||||
final int percent = (int) calculateBatteryPercent(
|
||||
batterySipper.totalPowerMah, batteryStatsHelper.getTotalPower(),
|
||||
hiddenAmount,
|
||||
dischargeAmount);
|
||||
return percent >= threshold;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return {@code true} if we should hide anomaly app represented by {@code uid}
|
||||
*/
|
||||
|
||||
@@ -45,7 +45,7 @@ public class SmartBatteryPreferenceController extends BasePreferenceController i
|
||||
public int getAvailabilityStatus() {
|
||||
return mPowerUsageFeatureProvider.isSmartBatterySupported()
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -143,7 +143,6 @@ public class AnomalyDetectionJobService extends JobService {
|
||||
StatsManager.EXTRA_STATS_BROADCAST_SUBSCRIBER_COOKIES);
|
||||
final AnomalyInfo anomalyInfo = new AnomalyInfo(
|
||||
!ArrayUtils.isEmpty(cookies) ? cookies.get(0) : "");
|
||||
final PackageManager packageManager = context.getPackageManager();
|
||||
Log.i(TAG, "Extra stats value: " + intentDimsValue.toString());
|
||||
|
||||
try {
|
||||
@@ -158,9 +157,7 @@ public class AnomalyDetectionJobService extends JobService {
|
||||
|
||||
final boolean anomalyDetected;
|
||||
if (isExcessiveBackgroundAnomaly(anomalyInfo)) {
|
||||
anomalyDetected = batteryUtils.isPreOApp(packageName)
|
||||
&& batteryUtils.isAppHeavilyUsed(batteryStatsHelper, userManager, uid,
|
||||
policy.excessiveBgDrainPercentage);
|
||||
anomalyDetected = batteryUtils.isPreOApp(packageName);
|
||||
} else {
|
||||
anomalyDetected = true;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class BatteryTipLoader extends AsyncLoader<List<BatteryTip>> {
|
||||
final BatteryInfo batteryInfo = mBatteryUtils.getBatteryInfo(mBatteryStatsHelper, TAG);
|
||||
final Context context = getContext();
|
||||
|
||||
tips.add(new LowBatteryDetector(policy, batteryInfo).detect());
|
||||
tips.add(new LowBatteryDetector(context, policy, batteryInfo).detect());
|
||||
tips.add(new HighUsageDetector(context, policy, mBatteryStatsHelper,
|
||||
batteryInfo.discharging).detect());
|
||||
tips.add(new SmartBatteryDetector(policy, context.getContentResolver()).detect());
|
||||
@@ -87,7 +87,8 @@ public class BatteryTipLoader extends AsyncLoader<List<BatteryTip>> {
|
||||
final List<BatteryTip> tips = new ArrayList<>();
|
||||
tips.add(new SummaryTip(BatteryTip.StateType.NEW,
|
||||
Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN));
|
||||
tips.add(new LowBatteryTip(BatteryTip.StateType.NEW));
|
||||
tips.add(new LowBatteryTip(BatteryTip.StateType.NEW, false /* powerSaveModeOn */,
|
||||
"Fake data"));
|
||||
|
||||
return tips;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ public class BatteryTipPolicy {
|
||||
private static final String KEY_TEST_BATTERY_SAVER_TIP = "test_battery_saver_tip";
|
||||
private static final String KEY_TEST_HIGH_USAGE_TIP = "test_high_usage_tip";
|
||||
private static final String KEY_TEST_SMART_BATTERY_TIP = "test_smart_battery_tip";
|
||||
private static final String KEY_TEST_LOW_BATTERY_TIP = "test_low_battery_tip";
|
||||
|
||||
/**
|
||||
* {@code true} if general battery tip is enabled
|
||||
@@ -192,6 +193,14 @@ public class BatteryTipPolicy {
|
||||
*/
|
||||
public final boolean testSmartBatteryTip;
|
||||
|
||||
/**
|
||||
* {@code true} if we want to test low battery tip.
|
||||
*
|
||||
* @see Settings.Global#BATTERY_TIP_CONSTANTS
|
||||
* @see #KEY_TEST_LOW_BATTERY_TIP
|
||||
*/
|
||||
public final boolean testLowBatteryTip;
|
||||
|
||||
private final KeyValueListParser mParser;
|
||||
|
||||
public BatteryTipPolicy(Context context) {
|
||||
@@ -222,13 +231,14 @@ public class BatteryTipPolicy {
|
||||
reducedBatteryEnabled = mParser.getBoolean(KEY_REDUCED_BATTERY_ENABLED, false);
|
||||
reducedBatteryPercent = mParser.getInt(KEY_REDUCED_BATTERY_PERCENT, 50);
|
||||
lowBatteryEnabled = mParser.getBoolean(KEY_LOW_BATTERY_ENABLED, false);
|
||||
lowBatteryHour = mParser.getInt(KEY_LOW_BATTERY_HOUR, 16);
|
||||
lowBatteryHour = mParser.getInt(KEY_LOW_BATTERY_HOUR, 3);
|
||||
dataHistoryRetainDay = mParser.getInt(KEY_DATA_HISTORY_RETAIN_DAY, 30);
|
||||
excessiveBgDrainPercentage = mParser.getInt(KEY_EXCESSIVE_BG_DRAIN_PERCENTAGE, 10);
|
||||
|
||||
testBatterySaverTip = mParser.getBoolean(KEY_TEST_BATTERY_SAVER_TIP, false);
|
||||
testHighUsageTip = mParser.getBoolean(KEY_TEST_HIGH_USAGE_TIP, false);
|
||||
testSmartBatteryTip = mParser.getBoolean(KEY_TEST_SMART_BATTERY_TIP, false);
|
||||
testLowBatteryTip = mParser.getBoolean(KEY_TEST_LOW_BATTERY_TIP, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,31 +16,52 @@
|
||||
|
||||
package com.android.settings.fuelgauge.batterytip.detectors;
|
||||
|
||||
import android.text.format.DateUtils;
|
||||
import android.content.Context;
|
||||
import android.os.PowerManager;
|
||||
|
||||
import com.android.settings.fuelgauge.BatteryInfo;
|
||||
import com.android.settings.fuelgauge.batterytip.BatteryTipPolicy;
|
||||
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
|
||||
import com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Detect whether the battery is too low
|
||||
*/
|
||||
public class LowBatteryDetector implements BatteryTipDetector {
|
||||
private BatteryInfo mBatteryInfo;
|
||||
private BatteryTipPolicy mPolicy;
|
||||
private PowerManager mPowerManager;
|
||||
private int mWarningLevel;
|
||||
|
||||
public LowBatteryDetector(BatteryTipPolicy policy, BatteryInfo batteryInfo) {
|
||||
public LowBatteryDetector(Context context, BatteryTipPolicy policy, BatteryInfo batteryInfo) {
|
||||
mPolicy = policy;
|
||||
mBatteryInfo = batteryInfo;
|
||||
mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
mWarningLevel = context.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_lowBatteryWarningLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BatteryTip detect() {
|
||||
// Show it if battery life is less than mPolicy.lowBatteryHour
|
||||
final boolean isShown = mPolicy.lowBatteryEnabled && mBatteryInfo.discharging
|
||||
&& mBatteryInfo.remainingTimeUs < mPolicy.lowBatteryHour * DateUtils.HOUR_IN_MILLIS;
|
||||
final boolean powerSaveModeOn = mPowerManager.isPowerSaveMode();
|
||||
final boolean lowBattery = mBatteryInfo.batteryLevel <= mWarningLevel
|
||||
|| (mBatteryInfo.discharging
|
||||
&& mBatteryInfo.remainingTimeUs < TimeUnit.HOURS.toMicros(mPolicy.lowBatteryHour));
|
||||
|
||||
int state = BatteryTip.StateType.INVISIBLE;
|
||||
if (mPolicy.lowBatteryEnabled) {
|
||||
if (powerSaveModeOn) {
|
||||
// Show it is handled if battery saver is on
|
||||
state = BatteryTip.StateType.HANDLED;
|
||||
} else if (mPolicy.testLowBatteryTip || (mBatteryInfo.discharging && lowBattery)) {
|
||||
// Show it is new if in test or in discharging low battery state
|
||||
state = BatteryTip.StateType.NEW;
|
||||
}
|
||||
}
|
||||
|
||||
return new LowBatteryTip(
|
||||
isShown ? BatteryTip.StateType.NEW : BatteryTip.StateType.INVISIBLE);
|
||||
state, powerSaveModeOn, mBatteryInfo.remainingLabel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,10 +74,10 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
|
||||
TIP_ORDER.append(TipType.APP_RESTRICTION, 0);
|
||||
TIP_ORDER.append(TipType.BATTERY_SAVER, 1);
|
||||
TIP_ORDER.append(TipType.HIGH_DEVICE_USAGE, 2);
|
||||
TIP_ORDER.append(TipType.SUMMARY, 3);
|
||||
TIP_ORDER.append(TipType.SMART_BATTERY_MANAGER, 4);
|
||||
TIP_ORDER.append(TipType.REDUCED_BATTERY, 5);
|
||||
TIP_ORDER.append(TipType.LOW_BATTERY, 6);
|
||||
TIP_ORDER.append(TipType.LOW_BATTERY, 3);
|
||||
TIP_ORDER.append(TipType.SUMMARY, 4);
|
||||
TIP_ORDER.append(TipType.SMART_BATTERY_MANAGER, 5);
|
||||
TIP_ORDER.append(TipType.REDUCED_BATTERY, 6);
|
||||
TIP_ORDER.append(TipType.REMOVE_APP_RESTRICTION, 7);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,36 +25,32 @@ import com.android.settings.R;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
/**
|
||||
* Tip to show current battery life is short
|
||||
* Tip to show current battery level is low or remaining time is less than a certain period
|
||||
*/
|
||||
public class LowBatteryTip extends BatteryTip {
|
||||
public class LowBatteryTip extends EarlyWarningTip {
|
||||
private CharSequence mSummary;
|
||||
|
||||
public LowBatteryTip(@StateType int state) {
|
||||
super(TipType.LOW_BATTERY, state, false /* showDialog */);
|
||||
public LowBatteryTip(@StateType int state, boolean powerSaveModeOn, CharSequence summary) {
|
||||
super(state, powerSaveModeOn);
|
||||
mType = TipType.LOW_BATTERY;
|
||||
mSummary = summary;
|
||||
}
|
||||
|
||||
private LowBatteryTip(Parcel in) {
|
||||
public LowBatteryTip(Parcel in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getTitle(Context context) {
|
||||
return context.getString(R.string.battery_tip_low_battery_title);
|
||||
mSummary = in.readCharSequence();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary(Context context) {
|
||||
return context.getString(R.string.battery_tip_low_battery_summary);
|
||||
return mState == StateType.HANDLED ? context.getString(
|
||||
R.string.battery_tip_early_heads_up_done_summary) : mSummary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconId() {
|
||||
return R.drawable.ic_perm_device_information_red_24dp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(BatteryTip tip) {
|
||||
mState = tip.mState;
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeCharSequence(mSummary);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -63,7 +63,7 @@ public class AssistGestureSettingsPreferenceController extends GesturePreference
|
||||
public int getAvailabilityStatus() {
|
||||
final boolean isAvailable = mAssistOnly ? mFeatureProvider.isSupported(mContext)
|
||||
: mFeatureProvider.isSensorAvailable(mContext);
|
||||
return isAvailable ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return isAvailable ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -58,7 +58,7 @@ public class DoubleTapPowerPreferenceController extends GesturePreferenceControl
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return isGestureAvailable(mContext) ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return isGestureAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -74,7 +74,7 @@ public class DoubleTapScreenPreferenceController extends GesturePreferenceContro
|
||||
if (mAmbientConfig == null) {
|
||||
mAmbientConfig = new AmbientDisplayConfiguration(mContext);
|
||||
}
|
||||
return mAmbientConfig.pulseOnDoubleTapAvailable() ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return mAmbientConfig.pulseOnDoubleTapAvailable() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -68,7 +68,7 @@ public class DoubleTwistPreferenceController extends GesturePreferenceController
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return isGestureAvailable(mContext) ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return isGestureAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,7 +51,7 @@ public class GesturesSettingPreferenceController extends BasePreferenceControlle
|
||||
for (AbstractPreferenceController controller : mGestureControllers) {
|
||||
isAvailable = isAvailable || controller.isAvailable();
|
||||
}
|
||||
return isAvailable ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return isAvailable ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,7 +68,7 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll
|
||||
if (mAmbientConfig == null) {
|
||||
mAmbientConfig = new AmbientDisplayConfiguration(mContext);
|
||||
}
|
||||
return mAmbientConfig.pulseOnPickupAvailable() ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return mAmbientConfig.pulseOnPickupAvailable() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,7 +61,7 @@ public class PreventRingingPreferenceController extends BasePreferenceController
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_volumeHushGestureEnabled)
|
||||
? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -56,7 +56,7 @@ public class SwipeToNotificationPreferenceController extends GesturePreferenceCo
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return isAvailable(mContext) ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return isAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,17 +19,12 @@ package com.android.settings.gestures;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
|
||||
public class SwipeUpPreferenceController extends GesturePreferenceController {
|
||||
|
||||
@@ -46,6 +41,10 @@ public class SwipeUpPreferenceController extends GesturePreferenceController {
|
||||
}
|
||||
|
||||
static boolean isGestureAvailable(Context context) {
|
||||
if (!context.getResources().getBoolean(R.bool.config_swipe_up_gesture_setting_available)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final ComponentName recentsComponentName = ComponentName.unflattenFromString(
|
||||
context.getString(com.android.internal.R.string.config_recentsComponentName));
|
||||
final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
|
||||
@@ -59,7 +58,7 @@ public class SwipeUpPreferenceController extends GesturePreferenceController {
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return isGestureAvailable(mContext) ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return isGestureAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,8 +80,10 @@ public class SwipeUpPreferenceController extends GesturePreferenceController {
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
final int defaultValue = mContext.getResources()
|
||||
.getBoolean(com.android.internal.R.bool.config_swipe_up_gesture_default) ? ON : OFF;
|
||||
final int swipeUpEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.SWIPE_UP_TO_SWITCH_APPS_ENABLED, OFF);
|
||||
Settings.Secure.SWIPE_UP_TO_SWITCH_APPS_ENABLED, defaultValue);
|
||||
return swipeUpEnabled != OFF;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class GameControllerPreferenceController extends TogglePreferenceControll
|
||||
public int getAvailabilityStatus() {
|
||||
// If device explicitly wants to hide this, return early.
|
||||
if (!mContext.getResources().getBoolean(R.bool.config_show_vibrate_input_devices)) {
|
||||
return DISABLED_UNSUPPORTED;
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
final int[] devices = mIm.getInputDeviceIds();
|
||||
@@ -74,7 +74,7 @@ public class GameControllerPreferenceController extends TogglePreferenceControll
|
||||
return AVAILABLE;
|
||||
}
|
||||
}
|
||||
return DISABLED_UNSUPPORTED;
|
||||
return CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,6 +36,6 @@ public class PointerSpeedController extends BasePreferenceController {
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_pointer_speed)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,6 @@ public class LocationScanningPreferenceController extends BasePreferenceControll
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_location_scanning)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class AirplaneModePreferenceController extends TogglePreferenceController
|
||||
@Override
|
||||
@AvailabilityStatus
|
||||
public int getAvailabilityStatus() {
|
||||
return isAvailable(mContext) ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
return isAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.settings.notification;
|
||||
import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.R;
|
||||
|
||||
public class AlarmVolumePreferenceController extends
|
||||
@@ -34,7 +33,7 @@ public class AlarmVolumePreferenceController extends
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_alarm_volume)
|
||||
&& !mHelper.isSingleVolume() ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
&& !mHelper.isSingleVolume() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -84,7 +84,7 @@ public class BadgingNotificationPreferenceController extends TogglePreferenceCon
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources()
|
||||
.getBoolean(com.android.internal.R.bool.config_notificationBadging)
|
||||
? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,9 +18,8 @@ package com.android.settings.notification;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
import com.android.settings.notification.VolumeSeekBarPreference.Callback;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
public class MediaVolumePreferenceController extends
|
||||
VolumeSeekBarPreferenceController {
|
||||
@@ -35,7 +34,7 @@ public class MediaVolumePreferenceController extends
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_media_volume)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.settings.notification;
|
||||
import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
|
||||
@@ -36,7 +35,7 @@ public class NotificationVolumePreferenceController extends
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_notification_volume)
|
||||
&& !Utils.isVoiceCapable(mContext) && !mHelper.isSingleVolume()
|
||||
? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,6 @@ import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.Vibrator;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
@@ -85,7 +84,7 @@ public class RingVolumePreferenceController extends VolumeSeekBarPreferenceContr
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return Utils.isVoiceCapable(mContext) && !mHelper.isSingleVolume()
|
||||
? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_OFF;
|
||||
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_ON;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AutomaticZenRule;
|
||||
import android.app.NotificationManager;
|
||||
@@ -146,19 +149,24 @@ public class ZenModeBackend {
|
||||
protected void savePolicy(int priorityCategories, int priorityCallSenders,
|
||||
int priorityMessageSenders, int suppressedVisualEffects) {
|
||||
mPolicy = new NotificationManager.Policy(priorityCategories, priorityCallSenders,
|
||||
priorityMessageSenders,
|
||||
suppressedVisualEffects);
|
||||
priorityMessageSenders, suppressedVisualEffects);
|
||||
mNotificationManager.setNotificationPolicy(mPolicy);
|
||||
}
|
||||
|
||||
protected int getNewSuppressedEffects(boolean suppress, int effectType) {
|
||||
private int getNewSuppressedEffects(boolean suppress, int effectType) {
|
||||
int effects = mPolicy.suppressedVisualEffects;
|
||||
|
||||
if (suppress) {
|
||||
effects |= effectType;
|
||||
} else {
|
||||
effects &= ~effectType;
|
||||
}
|
||||
return effects;
|
||||
|
||||
return clearDeprecatedEffects(effects);
|
||||
}
|
||||
|
||||
private int clearDeprecatedEffects(int effects) {
|
||||
return effects & ~(SUPPRESSED_EFFECT_SCREEN_ON | SUPPRESSED_EFFECT_SCREEN_OFF);
|
||||
}
|
||||
|
||||
protected boolean isEffectAllowed(int effect) {
|
||||
|
||||
@@ -68,7 +68,6 @@ public class ZenModeRestrictNotificationsSettings extends ZenModeSettingsBase im
|
||||
custom.displayPreference(getPreferenceScreen());
|
||||
|
||||
if (mShowMenuSelected) {
|
||||
custom.select();
|
||||
metrics.action(mContext, ACTION_ZEN_SHOW_CUSTOM, true);
|
||||
} else {
|
||||
metrics.action(mContext, ACTION_ZEN_SHOW_CUSTOM, false);
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.settings.notification;
|
||||
import android.app.NotificationManager.Policy;
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
@@ -57,15 +56,11 @@ public class ZenModeVisEffectsCustomPreferenceController
|
||||
pref.setChecked(areCustomOptionsSelected());
|
||||
|
||||
pref.setOnGearClickListener(p -> {
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(ZenModeBlockedEffectsSettings.class.getName())
|
||||
.setTitle(R.string.zen_mode_what_to_block_title)
|
||||
.setSourceMetricsCategory(MetricsProto.MetricsEvent.SETTINGS_ZEN_NOTIFICATIONS)
|
||||
.launch();
|
||||
launchCustomSettings();
|
||||
});
|
||||
|
||||
pref.setOnRadioButtonClickListener(p -> {
|
||||
select();
|
||||
launchCustomSettings();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -84,9 +79,14 @@ public class ZenModeVisEffectsCustomPreferenceController
|
||||
protected void select() {
|
||||
mMetricsFeatureProvider.action(mContext,
|
||||
MetricsProto.MetricsEvent.ACTION_ZEN_CUSTOM, true);
|
||||
mBackend.savePolicy(mBackend.mPolicy.priorityCategories,
|
||||
mBackend.mPolicy.priorityCallSenders,
|
||||
mBackend.mPolicy.priorityMessageSenders,
|
||||
INTERRUPTIVE_EFFECTS);
|
||||
}
|
||||
|
||||
private void launchCustomSettings() {
|
||||
select();
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(ZenModeBlockedEffectsSettings.class.getName())
|
||||
.setTitle(R.string.zen_mode_what_to_block_title)
|
||||
.setSourceMetricsCategory(MetricsProto.MetricsEvent.SETTINGS_ZEN_NOTIFICATIONS)
|
||||
.launch();
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class PrintSettingPreferenceController extends BasePreferenceController i
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mPackageManager.hasSystemFeature(PackageManager.FEATURE_PRINTING)
|
||||
? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -44,7 +44,7 @@ public class EncryptionStatusPreferenceController extends BasePreferenceControll
|
||||
if (TextUtils.equals(getPreferenceKey(), PREF_KEY_ENCRYPTION_DETAIL_PAGE) &&
|
||||
!mContext.getResources().getBoolean(
|
||||
R.bool.config_show_encryption_and_credentials_encryption_status)) {
|
||||
return DISABLED_UNSUPPORTED;
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
return mUserManager.isAdminUser() ? AVAILABLE : DISABLED_FOR_USER;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class ScreenPinningPreferenceController extends BasePreferenceController
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_screen_pinning_settings)
|
||||
? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ShowPasswordPreferenceController extends TogglePreferenceController
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_show_password)
|
||||
? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ManageTrustAgentsPreferenceController extends BasePreferenceControl
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_manage_trust_agents)
|
||||
? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,7 +32,6 @@ import android.provider.SettingsSlicesContract;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v4.graphics.drawable.IconCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
@@ -42,10 +41,10 @@ import com.android.settingslib.utils.ThreadUtils;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import androidx.slice.Slice;
|
||||
import androidx.slice.SliceProvider;
|
||||
@@ -117,6 +116,7 @@ public class SettingsSliceProvider extends SliceProvider {
|
||||
|
||||
@VisibleForTesting
|
||||
Map<Uri, SliceData> mSliceWeakDataCache;
|
||||
@VisibleForTesting
|
||||
Map<Uri, SliceData> mSliceDataCache;
|
||||
|
||||
public SettingsSliceProvider() {
|
||||
@@ -126,7 +126,7 @@ public class SettingsSliceProvider extends SliceProvider {
|
||||
@Override
|
||||
public boolean onCreateSliceProvider() {
|
||||
mSlicesDatabaseAccessor = new SlicesDatabaseAccessor(getContext());
|
||||
mSliceDataCache = new ArrayMap<>();
|
||||
mSliceDataCache = new ConcurrentHashMap<>();
|
||||
mSliceWeakDataCache = new WeakHashMap<>();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
package com.android.settings.slices;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_FOR_USER;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_UNSUPPORTED;
|
||||
import static com.android.settings.core.BasePreferenceController.UNAVAILABLE_UNKNOWN;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
import static com.android.settings.slices.SettingsSliceProvider.EXTRA_SLICE_KEY;
|
||||
import static com.android.settings.slices.SettingsSliceProvider.EXTRA_SLICE_PLATFORM_DEFINED;
|
||||
|
||||
@@ -238,7 +238,7 @@ public class SliceBuilderUtils {
|
||||
(TogglePreferenceController) controller;
|
||||
final SliceAction sliceAction = getToggleAction(context, sliceData,
|
||||
toggleController.isChecked());
|
||||
final List<String> keywords = buildSliceKeywords(sliceData.getKeywords());
|
||||
final List<String> keywords = buildSliceKeywords(sliceData);
|
||||
|
||||
return new ListBuilder(context, sliceData.getUri(), SLICE_TTL_MILLIS)
|
||||
.addRow(rowBuilder -> rowBuilder
|
||||
@@ -256,7 +256,7 @@ public class SliceBuilderUtils {
|
||||
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
|
||||
final IconCompat icon = IconCompat.createWithResource(context, sliceData.getIconResource());
|
||||
final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
|
||||
final List<String> keywords = buildSliceKeywords(sliceData.getKeywords());
|
||||
final List<String> keywords = buildSliceKeywords(sliceData);
|
||||
|
||||
return new ListBuilder(context, sliceData.getUri(), SLICE_TTL_MILLIS)
|
||||
.addRow(rowBuilder -> rowBuilder
|
||||
@@ -276,7 +276,7 @@ public class SliceBuilderUtils {
|
||||
final IconCompat icon = IconCompat.createWithResource(context, sliceData.getIconResource());
|
||||
final SliceAction primaryAction = new SliceAction(contentIntent, icon,
|
||||
sliceData.getTitle());
|
||||
final List<String> keywords = buildSliceKeywords(sliceData.getKeywords());
|
||||
final List<String> keywords = buildSliceKeywords(sliceData);
|
||||
|
||||
return new ListBuilder(context, sliceData.getUri(), SLICE_TTL_MILLIS)
|
||||
.addInputRange(builder -> builder
|
||||
@@ -324,25 +324,34 @@ public class SliceBuilderUtils {
|
||||
|| TextUtils.equals(summary, doublePlaceHolder));
|
||||
}
|
||||
|
||||
private static List<String> buildSliceKeywords(String keywordString) {
|
||||
if (keywordString == null) {
|
||||
return new ArrayList<>();
|
||||
private static List<String> buildSliceKeywords(SliceData data) {
|
||||
final List<String> keywords = new ArrayList<>();
|
||||
|
||||
keywords.add(data.getTitle());
|
||||
|
||||
if (!TextUtils.equals(data.getTitle(), data.getScreenTitle())) {
|
||||
keywords.add(data.getScreenTitle().toString());
|
||||
}
|
||||
|
||||
final String[] keywords = keywordString.split(",");
|
||||
return Arrays.asList(keywords);
|
||||
final String keywordString = data.getKeywords();
|
||||
if (keywordString != null) {
|
||||
final String[] keywordArray = keywordString.split(",");
|
||||
keywords.addAll(Arrays.asList(keywordArray));
|
||||
}
|
||||
|
||||
return keywords;
|
||||
}
|
||||
|
||||
private static Slice buildUnavailableSlice(Context context, SliceData data,
|
||||
BasePreferenceController controller) {
|
||||
final String title = data.getTitle();
|
||||
final List<String> keywords = buildSliceKeywords(data.getKeywords());
|
||||
final List<String> keywords = buildSliceKeywords(data);
|
||||
final String summary;
|
||||
final SliceAction primaryAction;
|
||||
final IconCompat icon = IconCompat.createWithResource(context, data.getIconResource());
|
||||
|
||||
switch (controller.getAvailabilityStatus()) {
|
||||
case DISABLED_UNSUPPORTED:
|
||||
case UNSUPPORTED_ON_DEVICE:
|
||||
summary = context.getString(R.string.unsupported_setting_summary);
|
||||
primaryAction = new SliceAction(getSettingsIntent(context), icon, title);
|
||||
break;
|
||||
@@ -356,7 +365,7 @@ public class SliceBuilderUtils {
|
||||
primaryAction = new SliceAction(getContentPendingIntent(context, data), icon,
|
||||
title);
|
||||
break;
|
||||
case UNAVAILABLE_UNKNOWN:
|
||||
case CONDITIONALLY_UNAVAILABLE:
|
||||
default:
|
||||
summary = context.getString(R.string.unknown_unavailability_setting_summary);
|
||||
primaryAction = new SliceAction(getSettingsIntent(context), icon, title);
|
||||
|
||||
@@ -185,7 +185,6 @@ class SliceDataConverter {
|
||||
| MetadataFlag.FLAG_NEED_PREF_TITLE
|
||||
| MetadataFlag.FLAG_NEED_PREF_ICON
|
||||
| MetadataFlag.FLAG_NEED_PREF_SUMMARY
|
||||
| MetadataFlag.FLAG_NEED_KEYWORDS
|
||||
| MetadataFlag.FLAG_NEED_PLATFORM_SLICE_FLAG);
|
||||
|
||||
for (Bundle bundle : metadata) {
|
||||
@@ -198,7 +197,6 @@ class SliceDataConverter {
|
||||
final String key = bundle.getString(METADATA_KEY);
|
||||
final String title = bundle.getString(METADATA_TITLE);
|
||||
final String summary = bundle.getString(METADATA_SUMMARY);
|
||||
final String keywords = bundle.getString(METADATA_KEYWORDS);
|
||||
final int iconResId = bundle.getInt(METADATA_ICON);
|
||||
final int sliceType = SliceBuilderUtils.getSliceType(mContext, controllerClassName,
|
||||
key);
|
||||
@@ -210,7 +208,6 @@ class SliceDataConverter {
|
||||
.setSummary(summary)
|
||||
.setIcon(iconResId)
|
||||
.setScreenTitle(screenTitle)
|
||||
.setKeywords(keywords)
|
||||
.setPreferenceControllerClassName(controllerClassName)
|
||||
.setFragmentName(fragmentName)
|
||||
.setSliceType(sliceType)
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
|
||||
package com.android.settings.sound;
|
||||
|
||||
|
||||
import static android.media.AudioManager.STREAM_DEVICES_CHANGED_ACTION;
|
||||
import static android.media.AudioManager.STREAM_MUSIC;
|
||||
import static android.media.AudioManager.STREAM_VOICE_CALL;
|
||||
import static android.media.AudioSystem.DEVICE_OUT_ALL_A2DP;
|
||||
import static android.media.AudioSystem.DEVICE_OUT_ALL_SCO;
|
||||
import static android.media.AudioSystem.DEVICE_OUT_HEARING_AID;
|
||||
import static android.media.MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY;
|
||||
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
@@ -38,19 +42,22 @@ import android.support.v7.preference.PreferenceScreen;
|
||||
import android.text.TextUtils;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.bluetooth.Utils;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settingslib.bluetooth.A2dpProfile;
|
||||
import com.android.settingslib.bluetooth.BluetoothCallback;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.HeadsetProfile;
|
||||
import com.android.settingslib.bluetooth.HearingAidProfile;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -65,12 +72,12 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
|
||||
|
||||
private static final int INVALID_INDEX = -1;
|
||||
|
||||
protected final List<BluetoothDevice> mConnectedDevices;
|
||||
protected final AudioManager mAudioManager;
|
||||
protected final MediaRouter mMediaRouter;
|
||||
protected final LocalBluetoothProfileManager mProfileManager;
|
||||
protected int mSelectedIndex;
|
||||
protected Preference mPreference;
|
||||
protected List<BluetoothDevice> mConnectedDevices;
|
||||
|
||||
private final AudioManagerAudioDeviceCallback mAudioManagerAudioDeviceCallback;
|
||||
private final LocalBluetoothManager mLocalBluetoothManager;
|
||||
@@ -89,6 +96,7 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
|
||||
mAudioManagerAudioDeviceCallback = new AudioManagerAudioDeviceCallback();
|
||||
mReceiver = new WiredHeadsetBroadcastReceiver();
|
||||
mMediaRouterCallback = new MediaRouterCallback();
|
||||
mConnectedDevices = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +106,7 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
|
||||
@Override
|
||||
public final int getAvailabilityStatus() {
|
||||
return FeatureFlagUtils.isEnabled(mContext, FeatureFlags.AUDIO_SWITCHER_SETTINGS)
|
||||
? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -195,12 +203,105 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
|
||||
}
|
||||
|
||||
protected boolean isStreamFromOutputDevice(int streamType, int device) {
|
||||
return mAudioManager.getDevicesForStream(streamType) == device;
|
||||
return (device & mAudioManager.getDevicesForStream(streamType)) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* get hands free profile(HFP) connected device
|
||||
*/
|
||||
protected List<BluetoothDevice> getConnectedHfpDevices() {
|
||||
final List<BluetoothDevice> connectedDevices = new ArrayList<>();
|
||||
final HeadsetProfile hfpProfile = mProfileManager.getHeadsetProfile();
|
||||
if (hfpProfile == null) {
|
||||
return connectedDevices;
|
||||
}
|
||||
final List<BluetoothDevice> devices = hfpProfile.getConnectedDevices();
|
||||
for (BluetoothDevice device : devices) {
|
||||
if (device.isConnected()) {
|
||||
connectedDevices.add(device);
|
||||
}
|
||||
}
|
||||
return connectedDevices;
|
||||
}
|
||||
|
||||
/**
|
||||
* get A2dp connected device
|
||||
*/
|
||||
protected List<BluetoothDevice> getConnectedA2dpDevices() {
|
||||
final List<BluetoothDevice> connectedDevices = new ArrayList<>();
|
||||
final A2dpProfile a2dpProfile = mProfileManager.getA2dpProfile();
|
||||
if (a2dpProfile == null) {
|
||||
return connectedDevices;
|
||||
}
|
||||
final List<BluetoothDevice> devices = a2dpProfile.getConnectedDevices();
|
||||
for (BluetoothDevice device : devices) {
|
||||
if (device.isConnected()) {
|
||||
connectedDevices.add(device);
|
||||
}
|
||||
}
|
||||
return connectedDevices;
|
||||
}
|
||||
|
||||
/**
|
||||
* get hearing aid profile connected device, exclude other devices with same hiSyncId.
|
||||
*/
|
||||
protected List<BluetoothDevice> getConnectedHearingAidDevices() {
|
||||
final List<BluetoothDevice> connectedDevices = new ArrayList<>();
|
||||
final HearingAidProfile hapProfile = mProfileManager.getHearingAidProfile();
|
||||
if (hapProfile == null) {
|
||||
return connectedDevices;
|
||||
}
|
||||
final List<Long> devicesHiSyncIds = new ArrayList<>();
|
||||
final List<BluetoothDevice> devices = hapProfile.getConnectedDevices();
|
||||
for (BluetoothDevice device : devices) {
|
||||
final long hiSyncId = hapProfile.getHiSyncId(device);
|
||||
// device with same hiSyncId should not be shown in the UI.
|
||||
// So do not add it into connectedDevices.
|
||||
if (!devicesHiSyncIds.contains(hiSyncId) && device.isConnected()) {
|
||||
devicesHiSyncIds.add(hiSyncId);
|
||||
connectedDevices.add(device);
|
||||
}
|
||||
}
|
||||
return connectedDevices;
|
||||
}
|
||||
|
||||
/**
|
||||
* According to different stream and output device, find the active device from
|
||||
* the corresponding profile. Hearing aid device could stream both STREAM_MUSIC
|
||||
* and STREAM_VOICE_CALL.
|
||||
*
|
||||
* @param streamType the type of audio streams.
|
||||
* @return the active device. Return null if the active device is current device
|
||||
* or streamType is not STREAM_MUSIC or STREAM_VOICE_CALL.
|
||||
*/
|
||||
protected BluetoothDevice findActiveDevice(int streamType) {
|
||||
if (streamType != STREAM_MUSIC && streamType != STREAM_VOICE_CALL) {
|
||||
return null;
|
||||
}
|
||||
if (isStreamFromOutputDevice(STREAM_MUSIC, DEVICE_OUT_ALL_A2DP)) {
|
||||
return mProfileManager.getA2dpProfile().getActiveDevice();
|
||||
} else if (isStreamFromOutputDevice(STREAM_VOICE_CALL, DEVICE_OUT_ALL_SCO)) {
|
||||
return mProfileManager.getHeadsetProfile().getActiveDevice();
|
||||
} else if (isStreamFromOutputDevice(streamType, DEVICE_OUT_HEARING_AID)) {
|
||||
// The first element is the left active device; the second element is
|
||||
// the right active device. And they will have same hiSyncId. If either
|
||||
// or both side is not active, it will be null on that position.
|
||||
List<BluetoothDevice> activeDevices =
|
||||
mProfileManager.getHearingAidProfile().getActiveDevices();
|
||||
for (BluetoothDevice btDevice : activeDevices) {
|
||||
if (btDevice != null && mConnectedDevices.contains(btDevice)) {
|
||||
// also need to check mConnectedDevices, because one of
|
||||
// the device(same hiSyncId) might not be shown in the UI.
|
||||
return btDevice;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
int getDefaultDeviceIndex() {
|
||||
// Default device is after all connected devices.
|
||||
return ArrayUtils.size(mConnectedDevices);
|
||||
return mConnectedDevices.size();
|
||||
}
|
||||
|
||||
void setupPreferenceEntries(CharSequence[] mediaOutputs, CharSequence[] mediaValues,
|
||||
@@ -261,7 +362,7 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
|
||||
mContext.unregisterReceiver(mReceiver);
|
||||
}
|
||||
|
||||
/** Callback for headset plugged and unplugged events. */
|
||||
/** Notifications of audio device connection and disconnection events. */
|
||||
private class AudioManagerAudioDeviceCallback extends AudioDeviceCallback {
|
||||
@Override
|
||||
public void onAudioDevicesAdded(AudioDeviceInfo[] addedDevices) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.sound;
|
||||
|
||||
import static android.bluetooth.IBluetoothHearingAid.HI_SYNC_ID_INVALID;
|
||||
import static android.media.AudioManager.STREAM_VOICE_CALL;
|
||||
import static android.media.AudioSystem.DEVICE_OUT_USB_HEADSET;
|
||||
|
||||
@@ -25,12 +26,12 @@ import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.bluetooth.HeadsetProfile;
|
||||
import com.android.settingslib.bluetooth.HearingAidProfile;
|
||||
|
||||
/**
|
||||
* This class allows switching between HFP-connected BT devices
|
||||
* This class allows switching between HFP-connected & HAP-connected BT devices
|
||||
* while in on-call state.
|
||||
*/
|
||||
public class HandsFreeProfileOutputPreferenceController extends
|
||||
@@ -57,16 +58,11 @@ public class HandsFreeProfileOutputPreferenceController extends
|
||||
// Ongoing call status, list all the connected devices support hands free profile.
|
||||
// Select current active device.
|
||||
// Disable switch entry if there is no connected device.
|
||||
mConnectedDevices = null;
|
||||
BluetoothDevice activeDevice = null;
|
||||
mConnectedDevices.clear();
|
||||
mConnectedDevices.addAll(getConnectedHfpDevices());
|
||||
mConnectedDevices.addAll(getConnectedHearingAidDevices());
|
||||
|
||||
final HeadsetProfile headsetProfile = mProfileManager.getHeadsetProfile();
|
||||
if (headsetProfile != null) {
|
||||
mConnectedDevices = headsetProfile.getConnectedDevices();
|
||||
activeDevice = headsetProfile.getActiveDevice();
|
||||
}
|
||||
|
||||
final int numDevices = ArrayUtils.size(mConnectedDevices);
|
||||
final int numDevices = mConnectedDevices.size();
|
||||
if (numDevices == 0) {
|
||||
// No connected devices, disable switch entry.
|
||||
mPreference.setVisible(false);
|
||||
@@ -79,7 +75,7 @@ public class HandsFreeProfileOutputPreferenceController extends
|
||||
CharSequence[] mediaValues = new CharSequence[numDevices + 1];
|
||||
|
||||
// Setup devices entries, select active connected device
|
||||
setupPreferenceEntries(mediaOutputs, mediaValues, activeDevice);
|
||||
setupPreferenceEntries(mediaOutputs, mediaValues, findActiveDevice(STREAM_VOICE_CALL));
|
||||
|
||||
if (isStreamFromOutputDevice(STREAM_VOICE_CALL, DEVICE_OUT_USB_HEADSET)) {
|
||||
// If wired headset is plugged in and active, select to default device.
|
||||
@@ -92,8 +88,21 @@ public class HandsFreeProfileOutputPreferenceController extends
|
||||
|
||||
@Override
|
||||
public void setActiveBluetoothDevice(BluetoothDevice device) {
|
||||
if (Utils.isAudioModeOngoingCall(mContext)) {
|
||||
mProfileManager.getHeadsetProfile().setActiveDevice(device);
|
||||
if (!Utils.isAudioModeOngoingCall(mContext)) {
|
||||
return;
|
||||
}
|
||||
final HearingAidProfile hapProfile = mProfileManager.getHearingAidProfile();
|
||||
final HeadsetProfile hfpProfile = mProfileManager.getHeadsetProfile();
|
||||
if (hapProfile != null && hfpProfile != null && device == null) {
|
||||
hfpProfile.setActiveDevice(null);
|
||||
hapProfile.setActiveDevice(null);
|
||||
return;
|
||||
}
|
||||
if (hapProfile != null && hapProfile.getHiSyncId(device) != HI_SYNC_ID_INVALID) {
|
||||
hapProfile.setActiveDevice(device);
|
||||
}
|
||||
if (hfpProfile != null) {
|
||||
hfpProfile.setActiveDevice(device);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.sound;
|
||||
|
||||
import static android.bluetooth.IBluetoothHearingAid.HI_SYNC_ID_INVALID;
|
||||
import static android.media.AudioManager.STREAM_MUSIC;
|
||||
import static android.media.AudioSystem.DEVICE_OUT_REMOTE_SUBMIX;
|
||||
import static android.media.AudioSystem.DEVICE_OUT_USB_HEADSET;
|
||||
@@ -27,13 +28,12 @@ import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.bluetooth.A2dpProfile;
|
||||
|
||||
import com.android.settingslib.bluetooth.HearingAidProfile;
|
||||
|
||||
/**
|
||||
* This class which allows switching between a2dp-connected BT devices.
|
||||
* This class which allows switching between A2dp-connected & HAP-connected BT devices.
|
||||
* A few conditions will disable this switcher:
|
||||
* - No available BT device(s)
|
||||
* - Media stream captured by cast device
|
||||
@@ -67,18 +67,14 @@ public class MediaOutputPreferenceController extends AudioSwitchPreferenceContro
|
||||
return;
|
||||
}
|
||||
|
||||
mConnectedDevices.clear();
|
||||
// Otherwise, list all of the A2DP connected device and display the active device.
|
||||
mConnectedDevices = null;
|
||||
BluetoothDevice activeDevice = null;
|
||||
if (mAudioManager.getMode() == AudioManager.MODE_NORMAL) {
|
||||
final A2dpProfile a2dpProfile = mProfileManager.getA2dpProfile();
|
||||
if (a2dpProfile != null) {
|
||||
mConnectedDevices = a2dpProfile.getConnectedDevices();
|
||||
activeDevice = a2dpProfile.getActiveDevice();
|
||||
}
|
||||
mConnectedDevices.addAll(getConnectedA2dpDevices());
|
||||
mConnectedDevices.addAll(getConnectedHearingAidDevices());
|
||||
}
|
||||
|
||||
final int numDevices = ArrayUtils.size(mConnectedDevices);
|
||||
final int numDevices = mConnectedDevices.size();
|
||||
if (numDevices == 0) {
|
||||
// Disable switch entry if there is no connected devices.
|
||||
mPreference.setVisible(false);
|
||||
@@ -91,7 +87,7 @@ public class MediaOutputPreferenceController extends AudioSwitchPreferenceContro
|
||||
CharSequence[] mediaValues = new CharSequence[numDevices + 1];
|
||||
|
||||
// Setup devices entries, select active connected device
|
||||
setupPreferenceEntries(mediaOutputs, mediaValues, activeDevice);
|
||||
setupPreferenceEntries(mediaOutputs, mediaValues, findActiveDevice(STREAM_MUSIC));
|
||||
|
||||
if (isStreamFromOutputDevice(STREAM_MUSIC, DEVICE_OUT_USB_HEADSET)) {
|
||||
// If wired headset is plugged in and active, select to default device.
|
||||
@@ -104,8 +100,21 @@ public class MediaOutputPreferenceController extends AudioSwitchPreferenceContro
|
||||
|
||||
@Override
|
||||
public void setActiveBluetoothDevice(BluetoothDevice device) {
|
||||
if (mAudioManager.getMode() == AudioManager.MODE_NORMAL) {
|
||||
mProfileManager.getA2dpProfile().setActiveDevice(device);
|
||||
if (mAudioManager.getMode() != AudioManager.MODE_NORMAL) {
|
||||
return;
|
||||
}
|
||||
final HearingAidProfile hapProfile = mProfileManager.getHearingAidProfile();
|
||||
final A2dpProfile a2dpProfile = mProfileManager.getA2dpProfile();
|
||||
if (hapProfile != null && a2dpProfile != null && device == null) {
|
||||
hapProfile.setActiveDevice(null);
|
||||
a2dpProfile.setActiveDevice(null);
|
||||
return;
|
||||
}
|
||||
if (hapProfile != null && hapProfile.getHiSyncId(device) != HI_SYNC_ID_INVALID) {
|
||||
hapProfile.setActiveDevice(device);
|
||||
}
|
||||
if (a2dpProfile != null) {
|
||||
a2dpProfile.setActiveDevice(device);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,6 @@ public class AdditionalSystemUpdatePreferenceController extends BasePreferenceCo
|
||||
return mContext.getResources().getBoolean(
|
||||
com.android.settings.R.bool.config_additional_system_update_setting_enable)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,6 @@ public class ResetPreferenceController extends BasePreferenceController {
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_reset_dashboard)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class SystemUpdatePreferenceController extends BasePreferenceController {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_system_update_settings)
|
||||
&& mUm.isAdminUser()
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,7 +43,7 @@ public class PreferenceCategoryController extends BasePreferenceController {
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (mChildren == null || mChildren.isEmpty()) {
|
||||
return DISABLED_UNSUPPORTED;
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
// Category is available if any child is available
|
||||
for (AbstractPreferenceController controller : mChildren) {
|
||||
@@ -51,7 +51,7 @@ public class PreferenceCategoryController extends BasePreferenceController {
|
||||
return AVAILABLE;
|
||||
}
|
||||
}
|
||||
return DISABLED_UNSUPPORTED;
|
||||
return CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -220,6 +220,7 @@ public class WifiConfigController implements TextWatcher,
|
||||
mMeteredSettingsSpinner = mView.findViewById(R.id.metered_settings);
|
||||
mHiddenSettingsSpinner = mView.findViewById(R.id.hidden_settings);
|
||||
mHiddenSettingsSpinner.setOnItemSelectedListener(this);
|
||||
mHiddenSettingsSpinner.setVisibility(View.GONE);
|
||||
mHiddenSettingsSpinner.setEnabled(false);
|
||||
mHiddenWarningView = mView.findViewById(R.id.hidden_settings_warning);
|
||||
mHiddenWarningView.setVisibility(
|
||||
@@ -240,6 +241,7 @@ public class WifiConfigController implements TextWatcher,
|
||||
showProxyFields();
|
||||
mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
|
||||
// Hidden option can be changed only when the user adds a network manually.
|
||||
mHiddenSettingsSpinner.setVisibility(View.VISIBLE);
|
||||
mHiddenSettingsSpinner.setEnabled(true);
|
||||
((CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox))
|
||||
.setOnCheckedChangeListener(this);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_UNSUPPORTED;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -30,7 +30,6 @@ import android.content.pm.ServiceInfo;
|
||||
import android.provider.Settings;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import com.android.settings.accessibility.AccessibilitySlicePreferenceController;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settingslib.accessibility.AccessibilityUtils;
|
||||
|
||||
@@ -85,7 +84,7 @@ public class AccessibilitySlicePreferenceControllerTest {
|
||||
AccessibilitySlicePreferenceController controller =
|
||||
new AccessibilitySlicePreferenceController(mContext, "fake_service/name");
|
||||
|
||||
assertThat(controller.getAvailabilityStatus()).isEqualTo(DISABLED_UNSUPPORTED);
|
||||
assertThat(controller.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -80,7 +80,7 @@ public class AppDataUsagePreferenceControllerTest {
|
||||
doReturn(false).when(mController).isBandwidthControlEnabled();
|
||||
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.DISABLED_UNSUPPORTED);
|
||||
.isEqualTo(BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -91,7 +91,7 @@ public class AppMemoryPreferenceControllerTest {
|
||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.DISABLED_UNSUPPORTED);
|
||||
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,7 +101,7 @@ public class AppMemoryPreferenceControllerTest {
|
||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.DISABLED_UNSUPPORTED);
|
||||
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -110,7 +110,7 @@ public class AppMemoryPreferenceControllerTest {
|
||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.DISABLED_UNSUPPORTED);
|
||||
.isEqualTo(BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.applications.appinfo;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -84,7 +85,8 @@ public class DefaultAppShortcutPreferenceControllerBaseTest {
|
||||
mController.capable = false;
|
||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(mController.DISABLED_UNSUPPORTED);
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||
mController.UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -110,9 +112,9 @@ public class DefaultAppShortcutPreferenceControllerBaseTest {
|
||||
public void handlePreferenceTreeClick_shouldStartDefaultAppSettings() {
|
||||
mController.handlePreferenceTreeClick(mPreference);
|
||||
|
||||
verify(mContext).startActivity(argThat(intent-> intent != null
|
||||
verify(mContext).startActivity(argThat(intent -> intent != null
|
||||
&& intent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT).equals(
|
||||
DefaultAppSettings.class.getName())
|
||||
DefaultAppSettings.class.getName())
|
||||
&& intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
||||
.getString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY).equals("TestKey")));
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class TimeSpentInAppPreferenceControllerTest {
|
||||
mController.setPackageName(null);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.DISABLED_UNSUPPORTED);
|
||||
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,7 +79,7 @@ public class TimeSpentInAppPreferenceControllerTest {
|
||||
mController.setPackageName(TEST_INTENT.getStringExtra(EXTRA_PACKAGE_NAME));
|
||||
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.DISABLED_UNSUPPORTED);
|
||||
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,7 +88,7 @@ public class TimeSpentInAppPreferenceControllerTest {
|
||||
mController.setPackageName(TEST_INTENT.getStringExtra(EXTRA_PACKAGE_NAME));
|
||||
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.DISABLED_UNSUPPORTED);
|
||||
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package com.android.settings.connecteddevice;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_UNSUPPORTED;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -121,7 +121,7 @@ public class AddDevicePreferenceControllerTest {
|
||||
public void addDevice_Availability_UnSupported() {
|
||||
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, false);
|
||||
assertThat(mAddDevicePreferenceController.getAvailabilityStatus())
|
||||
.isEqualTo(DISABLED_UNSUPPORTED);
|
||||
.isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package com.android.settings.connecteddevice;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_UNSUPPORTED;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
@@ -169,7 +169,7 @@ public class AvailableMediaDeviceGroupControllerTest {
|
||||
doReturn(false).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
|
||||
|
||||
assertThat(mAvailableMediaDeviceGroupController.getAvailabilityStatus()).isEqualTo(
|
||||
DISABLED_UNSUPPORTED);
|
||||
UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -54,7 +54,7 @@ public class BluetoothOnWhileDrivingPreferenceControllerTest {
|
||||
@Test
|
||||
public void getAvailabilityStatus_offWhenDisabled() {
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.DISABLED_UNSUPPORTED);
|
||||
.isEqualTo(BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package com.android.settings.connecteddevice;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_UNSUPPORTED;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -39,7 +39,6 @@ import com.android.settings.connecteddevice.dock.DockUpdater;
|
||||
import com.android.settings.connecteddevice.usb.ConnectedUsbDeviceUpdater;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -157,7 +156,7 @@ public class ConnectedDeviceGroupControllerTest {
|
||||
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, false);
|
||||
|
||||
assertThat(mConnectedDeviceGroupController.getAvailabilityStatus()).isEqualTo(
|
||||
DISABLED_UNSUPPORTED);
|
||||
UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package com.android.settings.connecteddevice;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_UNSUPPORTED;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
@@ -91,7 +91,7 @@ public class SavedDeviceGroupControllerTest {
|
||||
public void testGetAvailabilityStatus_noBluetoothFeature_returnUnSupported() {
|
||||
doReturn(false).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
|
||||
assertThat(mSavedDeviceGroupController.getAvailabilityStatus()).isEqualTo(
|
||||
DISABLED_UNSUPPORTED);
|
||||
UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
@Test
|
||||
public void testGetAvailabilityStatus_BluetoothFeature_returnSupported() {
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
package com.android.settings.core;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_FOR_USER;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_UNSUPPORTED;
|
||||
import static com.android.settings.core.BasePreferenceController.UNAVAILABLE_UNKNOWN;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
@@ -73,8 +73,16 @@ public class BasePreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_availableStatusUnsupported_returnsFalse() {
|
||||
mPreferenceController.setAvailability(DISABLED_UNSUPPORTED);
|
||||
public void isAvailable_availableStatusUnsupportedOnDevice_returnsFalse() {
|
||||
mPreferenceController.setAvailability(UNSUPPORTED_ON_DEVICE);
|
||||
|
||||
assertThat(mPreferenceController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void isAvailable_availableStatusConditionallyUnavailable_returnsFalse() {
|
||||
mPreferenceController.setAvailability(CONDITIONALLY_UNAVAILABLE);
|
||||
|
||||
assertThat(mPreferenceController.isAvailable()).isFalse();
|
||||
}
|
||||
@@ -93,13 +101,6 @@ public class BasePreferenceControllerTest {
|
||||
assertThat(mPreferenceController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_availableStatusUnavailable_returnsFalse() {
|
||||
mPreferenceController.setAvailability(UNAVAILABLE_UNKNOWN);
|
||||
|
||||
assertThat(mPreferenceController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSupported_availableStatusAvailable_returnsTrue() {
|
||||
mPreferenceController.setAvailability(AVAILABLE);
|
||||
@@ -109,7 +110,7 @@ public class BasePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isSupported_availableStatusUnsupported_returnsFalse() {
|
||||
mPreferenceController.setAvailability(DISABLED_UNSUPPORTED);
|
||||
mPreferenceController.setAvailability(UNSUPPORTED_ON_DEVICE);
|
||||
|
||||
assertThat(mPreferenceController.isSupported()).isFalse();
|
||||
}
|
||||
@@ -128,13 +129,6 @@ public class BasePreferenceControllerTest {
|
||||
assertThat(mPreferenceController.isSupported()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSupported_availableStatusUnavailable_returnsTrue() {
|
||||
mPreferenceController.setAvailability(UNAVAILABLE_UNKNOWN);
|
||||
|
||||
assertThat(mPreferenceController.isSupported()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSliceType_shouldReturnIntent() {
|
||||
assertThat(mPreferenceController.getSliceType()).isEqualTo(SliceData.SliceType.INTENT);
|
||||
|
||||
@@ -18,7 +18,8 @@ package com.android.settings.datausage;
|
||||
|
||||
import static android.net.ConnectivityManager.TYPE_WIFI;
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_UNSUPPORTED;
|
||||
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
@@ -342,7 +343,7 @@ public class DataUsageSummaryPreferenceControllerTest {
|
||||
|
||||
when(mTelephonyManager.getSimState()).thenReturn(TelephonyManager.SIM_STATE_ABSENT);
|
||||
when(mConnectivityManager.isNetworkSupported(TYPE_WIFI)).thenReturn(false);
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_UNSUPPORTED);
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -77,7 +77,7 @@ public class AmbientDisplayAlwaysOnPreferenceControllerTest {
|
||||
when(mConfig.alwaysOnAvailableForUser(anyInt())).thenReturn(false);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||
AmbientDisplayAlwaysOnPreferenceController.DISABLED_UNSUPPORTED);
|
||||
AmbientDisplayAlwaysOnPreferenceController.UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -104,7 +104,7 @@ public class AutoRotatePreferenceControllerTest {
|
||||
@Test
|
||||
public void testGetAvailabilityStatus() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(BasePreferenceController
|
||||
.DISABLED_UNSUPPORTED);
|
||||
.CONDITIONALLY_UNAVAILABLE);
|
||||
|
||||
enableAutoRotationPreference();
|
||||
|
||||
@@ -114,7 +114,7 @@ public class AutoRotatePreferenceControllerTest {
|
||||
disableAutoRotationPreference();
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(BasePreferenceController
|
||||
.DISABLED_UNSUPPORTED);
|
||||
.CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.android.settings.fingerprint;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_UNSUPPORTED;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -84,7 +84,7 @@ public class FingerprintStatusPreferenceControllerTest {
|
||||
public void getAvailabilityStatus_noFingerprintManger_DISABLED() {
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_UNSUPPORTED);
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -91,7 +91,7 @@ public class AutoRestrictionPreferenceControllerTest {
|
||||
doReturn(true).when(mFeatureFactory.powerUsageFeatureProvider).isSmartBatterySupported();
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||
BasePreferenceController.DISABLED_UNSUPPORTED);
|
||||
BasePreferenceController.UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -580,18 +580,6 @@ public class BatteryUtilsTest {
|
||||
assertThat(mBatteryUtils.isForceAppStandbyEnabled(UID, PACKAGE_NAME)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAppHeavilyUsed_usageMoreThanThreshold_returnTrue() {
|
||||
assertThat(mBatteryUtils.isAppHeavilyUsed(mBatteryStatsHelper, mUserManager, UID,
|
||||
10 /* threshold */ )).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAppHeavilyUsed_usageLessThanThreshold_returnFalse() {
|
||||
assertThat(mBatteryUtils.isAppHeavilyUsed(mBatteryStatsHelper, mUserManager, UID,
|
||||
DISCHARGE_AMOUNT /* threshold */ )).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldHideAnomaly_systemAppWithLauncher_returnTrue() {
|
||||
final List<ResolveInfo> resolveInfos = new ArrayList<>();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user