Snap for 8115127 from 47d115c3ff to tm-release
Change-Id: Ie35679a60985a07bcc6d914efce579ea82df2914
This commit is contained in:
@@ -63,6 +63,7 @@ android_library {
|
|||||||
"androidx.lifecycle_lifecycle-extensions",
|
"androidx.lifecycle_lifecycle-extensions",
|
||||||
"guava",
|
"guava",
|
||||||
"jsr305",
|
"jsr305",
|
||||||
|
"net-utils-framework-common",
|
||||||
"settings-contextual-card-protos-lite",
|
"settings-contextual-card-protos-lite",
|
||||||
"settings-log-bridge-protos-lite",
|
"settings-log-bridge-protos-lite",
|
||||||
"contextualcards",
|
"contextualcards",
|
||||||
|
|||||||
@@ -5463,6 +5463,8 @@
|
|||||||
<string name="accessibility_vibration_settings_title">Vibration & haptics</string>
|
<string name="accessibility_vibration_settings_title">Vibration & haptics</string>
|
||||||
<!-- Summary for preference screen for configuring vibrations. [CHAR LIMIT=NONE] -->
|
<!-- Summary for preference screen for configuring vibrations. [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_vibration_settings_summary">Control the vibration strength for different usages</string>
|
<string name="accessibility_vibration_settings_summary">Control the vibration strength for different usages</string>
|
||||||
|
<!-- Summary for vibration preference shown when it is disabled because the device is in silent mode. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_vibration_setting_disabled_for_silent_mode_summary">Setting disabled because device is set to silent</string>
|
||||||
<!-- Title for the category of preferences to configure device vibrations related to calls. [CHAR LIMIT=NONE] -->
|
<!-- Title for the category of preferences to configure device vibrations related to calls. [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_call_vibration_category_title">Calls</string>
|
<string name="accessibility_call_vibration_category_title">Calls</string>
|
||||||
<!-- Title for the category of preferences to configure device vibrations related to notifications and alarms. [CHAR LIMIT=NONE] -->
|
<!-- Title for the category of preferences to configure device vibrations related to notifications and alarms. [CHAR LIMIT=NONE] -->
|
||||||
|
|||||||
@@ -37,6 +37,12 @@ public class HapticFeedbackIntensityPreferenceController
|
|||||||
VibrationAttributes.USAGE_TOUCH);
|
VibrationAttributes.USAGE_TOUCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRestrictedByRingerModeSilent() {
|
||||||
|
// Touch feedback is disabled when the phone is in silent mode.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int readIntensity() {
|
public int readIntensity() {
|
||||||
final int hapticFeedbackEnabled = Settings.System.getInt(mContentResolver,
|
final int hapticFeedbackEnabled = Settings.System.getInt(mContentResolver,
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ public class NotificationVibrationIntensityPreferenceController
|
|||||||
super(context, Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
|
super(context, Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
|
||||||
VibrationAttributes.USAGE_NOTIFICATION);
|
VibrationAttributes.USAGE_NOTIFICATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRestrictedByRingerModeSilent() {
|
||||||
|
// Notifications never vibrate when the phone is in silent mode.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotificationVibrationIntensityPreferenceController(Context context,
|
public NotificationVibrationIntensityPreferenceController(Context context,
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ public class RingVibrationPreferenceConfig extends VibrationPreferenceConfig {
|
|||||||
mAudioManager = context.getSystemService(AudioManager.class);
|
mAudioManager = context.getSystemService(AudioManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRestrictedByRingerModeSilent() {
|
||||||
|
// Incoming calls never vibrate when the phone is in silent mode.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int readIntensity() {
|
public int readIntensity() {
|
||||||
final int vibrateWhenRinging = Settings.System.getInt(mContentResolver,
|
final int vibrateWhenRinging = Settings.System.getInt(mContentResolver,
|
||||||
|
|||||||
@@ -58,12 +58,12 @@ public abstract class VibrationIntensityPreferenceController extends SliderPrefe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
mSettingsContentObserver.register(mContext.getContentResolver());
|
mSettingsContentObserver.register(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
mSettingsContentObserver.unregister(mContext.getContentResolver());
|
mSettingsContentObserver.unregister(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,6 +72,7 @@ public abstract class VibrationIntensityPreferenceController extends SliderPrefe
|
|||||||
final SeekBarPreference preference = screen.findPreference(getPreferenceKey());
|
final SeekBarPreference preference = screen.findPreference(getPreferenceKey());
|
||||||
mSettingsContentObserver.onDisplayPreference(this, preference);
|
mSettingsContentObserver.onDisplayPreference(this, preference);
|
||||||
preference.setEnabled(mPreferenceConfig.isPreferenceEnabled());
|
preference.setEnabled(mPreferenceConfig.isPreferenceEnabled());
|
||||||
|
preference.setSummaryProvider(unused -> mPreferenceConfig.getSummary());
|
||||||
// TODO: remove setContinuousUpdates and replace with a different way to play the haptic
|
// TODO: remove setContinuousUpdates and replace with a different way to play the haptic
|
||||||
// preview without relying on the setting being propagated to the service.
|
// preview without relying on the setting being propagated to the service.
|
||||||
preference.setContinuousUpdates(true);
|
preference.setContinuousUpdates(true);
|
||||||
|
|||||||
@@ -18,9 +18,13 @@ package com.android.settings.accessibility;
|
|||||||
|
|
||||||
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
|
import android.media.AudioManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.VibrationAttributes;
|
import android.os.VibrationAttributes;
|
||||||
@@ -28,8 +32,10 @@ import android.os.VibrationEffect;
|
|||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,8 +51,10 @@ public abstract class VibrationPreferenceConfig {
|
|||||||
public static final String MAIN_SWITCH_SETTING_KEY = Settings.System.VIBRATE_ON;
|
public static final String MAIN_SWITCH_SETTING_KEY = Settings.System.VIBRATE_ON;
|
||||||
|
|
||||||
protected final ContentResolver mContentResolver;
|
protected final ContentResolver mContentResolver;
|
||||||
|
private final AudioManager mAudioManager;
|
||||||
private final Vibrator mVibrator;
|
private final Vibrator mVibrator;
|
||||||
private final String mSettingKey;
|
private final String mSettingKey;
|
||||||
|
private final String mRingerModeSilentSummary;
|
||||||
private final int mDefaultIntensity;
|
private final int mDefaultIntensity;
|
||||||
private final VibrationAttributes mVibrationAttributes;
|
private final VibrationAttributes mVibrationAttributes;
|
||||||
|
|
||||||
@@ -58,6 +66,9 @@ public abstract class VibrationPreferenceConfig {
|
|||||||
public VibrationPreferenceConfig(Context context, String settingKey, int vibrationUsage) {
|
public VibrationPreferenceConfig(Context context, String settingKey, int vibrationUsage) {
|
||||||
mContentResolver = context.getContentResolver();
|
mContentResolver = context.getContentResolver();
|
||||||
mVibrator = context.getSystemService(Vibrator.class);
|
mVibrator = context.getSystemService(Vibrator.class);
|
||||||
|
mAudioManager = context.getSystemService(AudioManager.class);
|
||||||
|
mRingerModeSilentSummary = context.getString(
|
||||||
|
R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary);
|
||||||
mSettingKey = settingKey;
|
mSettingKey = settingKey;
|
||||||
mDefaultIntensity = mVibrator.getDefaultVibrationIntensity(vibrationUsage);
|
mDefaultIntensity = mVibrator.getDefaultVibrationIntensity(vibrationUsage);
|
||||||
mVibrationAttributes = new VibrationAttributes.Builder()
|
mVibrationAttributes = new VibrationAttributes.Builder()
|
||||||
@@ -70,9 +81,24 @@ public abstract class VibrationPreferenceConfig {
|
|||||||
return mSettingKey;
|
return mSettingKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns the summary string for this setting preference. */
|
||||||
|
@Nullable
|
||||||
|
public CharSequence getSummary() {
|
||||||
|
return isRestrictedByRingerModeSilent() && isRingerModeSilent()
|
||||||
|
? mRingerModeSilentSummary : null;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns true if this setting preference is enabled for user update. */
|
/** Returns true if this setting preference is enabled for user update. */
|
||||||
public boolean isPreferenceEnabled() {
|
public boolean isPreferenceEnabled() {
|
||||||
return isMainVibrationSwitchEnabled(mContentResolver);
|
return isMainVibrationSwitchEnabled(mContentResolver)
|
||||||
|
&& (!isRestrictedByRingerModeSilent() || !isRingerModeSilent());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this setting preference should be disabled when the device is in silent mode.
|
||||||
|
*/
|
||||||
|
public boolean isRestrictedByRingerModeSilent() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the default intensity to be displayed when the setting value is not set. */
|
/** Returns the default intensity to be displayed when the setting value is not set. */
|
||||||
@@ -96,12 +122,23 @@ public abstract class VibrationPreferenceConfig {
|
|||||||
mVibrationAttributes);
|
mVibrationAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isRingerModeSilent() {
|
||||||
|
// AudioManager.isSilentMode() also returns true when ringer mode is VIBRATE.
|
||||||
|
// The vibration preferences are only disabled when the ringer mode is SILENT.
|
||||||
|
return mAudioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_SILENT;
|
||||||
|
}
|
||||||
|
|
||||||
/** {@link ContentObserver} for a setting described by a {@link VibrationPreferenceConfig}. */
|
/** {@link ContentObserver} for a setting described by a {@link VibrationPreferenceConfig}. */
|
||||||
public static final class SettingObserver extends ContentObserver {
|
public static final class SettingObserver extends ContentObserver {
|
||||||
private static final Uri MAIN_SWITCH_SETTING_URI =
|
private static final Uri MAIN_SWITCH_SETTING_URI =
|
||||||
Settings.System.getUriFor(MAIN_SWITCH_SETTING_KEY);
|
Settings.System.getUriFor(MAIN_SWITCH_SETTING_KEY);
|
||||||
|
private static final IntentFilter INTERNAL_RINGER_MODE_CHANGED_INTENT_FILTER =
|
||||||
|
new IntentFilter(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION);
|
||||||
|
|
||||||
private final Uri mUri;
|
private final Uri mUri;
|
||||||
|
@Nullable
|
||||||
|
private final BroadcastReceiver mRingerModeChangeReceiver;
|
||||||
|
|
||||||
private AbstractPreferenceController mPreferenceController;
|
private AbstractPreferenceController mPreferenceController;
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
|
|
||||||
@@ -109,35 +146,63 @@ public abstract class VibrationPreferenceConfig {
|
|||||||
public SettingObserver(VibrationPreferenceConfig preferenceConfig) {
|
public SettingObserver(VibrationPreferenceConfig preferenceConfig) {
|
||||||
super(new Handler(/* async= */ true));
|
super(new Handler(/* async= */ true));
|
||||||
mUri = Settings.System.getUriFor(preferenceConfig.getSettingKey());
|
mUri = Settings.System.getUriFor(preferenceConfig.getSettingKey());
|
||||||
|
|
||||||
|
if (preferenceConfig.isRestrictedByRingerModeSilent()) {
|
||||||
|
// If this preference is restricted by AudioManager.getRingerModeInternal() result
|
||||||
|
// for the device mode, then listen to changes in that value using the broadcast
|
||||||
|
// intent action INTERNAL_RINGER_MODE_CHANGED_ACTION.
|
||||||
|
mRingerModeChangeReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
final String action = intent.getAction();
|
||||||
|
if (AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION.equals(action)) {
|
||||||
|
notifyChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// No need to register a receiver if this preference is not affected by ringer mode.
|
||||||
|
mRingerModeChangeReceiver = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChange(boolean selfChange, Uri uri) {
|
public void onChange(boolean selfChange, Uri uri) {
|
||||||
if (mPreferenceController == null || mPreference == null) {
|
|
||||||
// onDisplayPreference not triggered yet, nothing to update.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mUri.equals(uri) || MAIN_SWITCH_SETTING_URI.equals(uri)) {
|
if (mUri.equals(uri) || MAIN_SWITCH_SETTING_URI.equals(uri)) {
|
||||||
|
notifyChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyChange() {
|
||||||
|
if (mPreferenceController != null && mPreference != null) {
|
||||||
mPreferenceController.updateState(mPreference);
|
mPreferenceController.updateState(mPreference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register this observer to given {@link ContentResolver}, to be called from lifecycle
|
* Register this observer to given {@link Context}, to be called from lifecycle
|
||||||
* {@code onStart} method.
|
* {@code onStart} method.
|
||||||
*/
|
*/
|
||||||
public void register(ContentResolver contentResolver) {
|
public void register(Context context) {
|
||||||
contentResolver.registerContentObserver(mUri, /* notifyForDescendants= */ false, this);
|
if (mRingerModeChangeReceiver != null) {
|
||||||
contentResolver.registerContentObserver(MAIN_SWITCH_SETTING_URI,
|
context.registerReceiver(mRingerModeChangeReceiver,
|
||||||
/* notifyForDescendants= */ false, this);
|
INTERNAL_RINGER_MODE_CHANGED_INTENT_FILTER);
|
||||||
|
}
|
||||||
|
context.getContentResolver().registerContentObserver(
|
||||||
|
mUri, /* notifyForDescendants= */ false, this);
|
||||||
|
context.getContentResolver().registerContentObserver(
|
||||||
|
MAIN_SWITCH_SETTING_URI, /* notifyForDescendants= */ false, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregister this observer from given {@link ContentResolver}, to be called from lifecycle
|
* Unregister this observer from given {@link Context}, to be called from lifecycle
|
||||||
* {@code onStop} method.
|
* {@code onStop} method.
|
||||||
*/
|
*/
|
||||||
public void unregister(ContentResolver contentResolver) {
|
public void unregister(Context context) {
|
||||||
contentResolver.unregisterContentObserver(this);
|
if (mRingerModeChangeReceiver != null) {
|
||||||
|
context.unregisterReceiver(mRingerModeChangeReceiver);
|
||||||
|
}
|
||||||
|
context.getContentResolver().unregisterContentObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class VibrationRampingRingerTogglePreferenceController
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
mRingSettingObserver.register(mContext.getContentResolver());
|
mRingSettingObserver.register(mContext);
|
||||||
mContext.getContentResolver().registerContentObserver(
|
mContext.getContentResolver().registerContentObserver(
|
||||||
Settings.System.getUriFor(Settings.System.APPLY_RAMPING_RINGER),
|
Settings.System.getUriFor(Settings.System.APPLY_RAMPING_RINGER),
|
||||||
/* notifyForDescendants= */ false,
|
/* notifyForDescendants= */ false,
|
||||||
@@ -102,7 +102,7 @@ public class VibrationRampingRingerTogglePreferenceController
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
mRingSettingObserver.unregister(mContext.getContentResolver());
|
mRingSettingObserver.unregister(mContext);
|
||||||
mContext.getContentResolver().unregisterContentObserver(mSettingObserver);
|
mContext.getContentResolver().unregisterContentObserver(mSettingObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,12 +45,12 @@ public abstract class VibrationTogglePreferenceController extends TogglePreferen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
mSettingsContentObserver.register(mContext.getContentResolver());
|
mSettingsContentObserver.register(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
mSettingsContentObserver.unregister(mContext.getContentResolver());
|
mSettingsContentObserver.unregister(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -66,6 +66,7 @@ public abstract class VibrationTogglePreferenceController extends TogglePreferen
|
|||||||
super.updateState(preference);
|
super.updateState(preference);
|
||||||
if (preference != null) {
|
if (preference != null) {
|
||||||
preference.setEnabled(mPreferenceConfig.isPreferenceEnabled());
|
preference.setEnabled(mPreferenceConfig.isPreferenceEnabled());
|
||||||
|
preference.setSummary(mPreferenceConfig.getSummary());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,14 +13,17 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.datausage;
|
package com.android.settings.datausage;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.app.usage.NetworkStats;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.NetworkPolicy;
|
import android.net.NetworkPolicy;
|
||||||
import android.net.NetworkPolicyManager;
|
import android.net.NetworkPolicyManager;
|
||||||
import android.net.NetworkStatsHistory;
|
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
import android.util.Range;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
|
|
||||||
|
import com.android.net.module.util.NetworkStatsUtils;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settingslib.net.ChartData;
|
import com.android.settingslib.net.ChartData;
|
||||||
import com.android.settingslib.net.NetworkCycleData;
|
import com.android.settingslib.net.NetworkCycleData;
|
||||||
@@ -62,9 +65,43 @@ public class CycleAdapter extends SettingsSpinnerAdapter<CycleAdapter.CycleItem>
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static long getTotalBytesForTimeRange(List<NetworkStats.Bucket> stats,
|
||||||
|
Range<Long> range) {
|
||||||
|
long bytes = 0L;
|
||||||
|
for (NetworkStats.Bucket bucket : stats) {
|
||||||
|
final Range<Long> bucketSpan = new Range<>(
|
||||||
|
bucket.getStartTimeStamp(), bucket.getEndTimeStamp());
|
||||||
|
// Only record bytes that overlapped with the given time range. For partially
|
||||||
|
// overlapped bucket, record rational bytes assuming the traffic is uniform
|
||||||
|
// distributed within the bucket.
|
||||||
|
try {
|
||||||
|
final Range<Long> overlapped = range.intersect(bucketSpan);
|
||||||
|
final long totalOfBucket = bucket.getRxBytes() + bucket.getTxBytes();
|
||||||
|
bytes += NetworkStatsUtils.multiplySafeByRational(totalOfBucket,
|
||||||
|
overlapped.getUpper() - overlapped.getLower(),
|
||||||
|
bucketSpan.getUpper() - bucketSpan.getLower());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// Range disjoint, ignore.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private Range getTimeRangeOf(@NonNull List<NetworkStats.Bucket> stats) {
|
||||||
|
long start = Long.MAX_VALUE;
|
||||||
|
long end = Long.MIN_VALUE;
|
||||||
|
for (NetworkStats.Bucket bucket : stats) {
|
||||||
|
start = Math.min(start, bucket.getStartTimeStamp());
|
||||||
|
end = Math.max(end, bucket.getEndTimeStamp());
|
||||||
|
}
|
||||||
|
return new Range(start, end);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rebuild list based on {@link NetworkPolicy} and available
|
* Rebuild list based on {@link NetworkPolicy} and available
|
||||||
* {@link NetworkStatsHistory} data. Always selects the newest item,
|
* {@link List<NetworkStats.Bucket>} data. Always selects the newest item,
|
||||||
* updating the inspection range on chartData.
|
* updating the inspection range on chartData.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -75,18 +112,19 @@ public class CycleAdapter extends SettingsSpinnerAdapter<CycleAdapter.CycleItem>
|
|||||||
clear();
|
clear();
|
||||||
|
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
NetworkStatsHistory.Entry entry = null;
|
|
||||||
|
|
||||||
long historyStart = Long.MAX_VALUE;
|
|
||||||
long historyEnd = Long.MIN_VALUE;
|
|
||||||
if (chartData != null) {
|
|
||||||
historyStart = chartData.network.getStart();
|
|
||||||
historyEnd = chartData.network.getEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
long historyStart;
|
||||||
|
long historyEnd;
|
||||||
|
try {
|
||||||
|
final Range<Long> historyTimeRange = getTimeRangeOf(chartData.network);
|
||||||
|
historyStart = historyTimeRange.getLower();
|
||||||
|
historyEnd = historyTimeRange.getUpper();
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// Empty history.
|
||||||
final long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
if (historyStart == Long.MAX_VALUE) historyStart = now;
|
historyStart = now;
|
||||||
if (historyEnd == Long.MIN_VALUE) historyEnd = now + 1;
|
historyEnd = now + 1;
|
||||||
|
}
|
||||||
|
|
||||||
boolean hasCycles = false;
|
boolean hasCycles = false;
|
||||||
if (policy != null) {
|
if (policy != null) {
|
||||||
@@ -99,8 +137,9 @@ public class CycleAdapter extends SettingsSpinnerAdapter<CycleAdapter.CycleItem>
|
|||||||
|
|
||||||
final boolean includeCycle;
|
final boolean includeCycle;
|
||||||
if (chartData != null) {
|
if (chartData != null) {
|
||||||
entry = chartData.network.getValues(cycleStart, cycleEnd, entry);
|
final long bytesInCycle = getTotalBytesForTimeRange(chartData.network,
|
||||||
includeCycle = (entry.rxBytes + entry.txBytes) > 0;
|
new Range<>(cycleStart, cycleEnd));
|
||||||
|
includeCycle = bytesInCycle > 0;
|
||||||
} else {
|
} else {
|
||||||
includeCycle = true;
|
includeCycle = true;
|
||||||
}
|
}
|
||||||
@@ -120,8 +159,9 @@ public class CycleAdapter extends SettingsSpinnerAdapter<CycleAdapter.CycleItem>
|
|||||||
|
|
||||||
final boolean includeCycle;
|
final boolean includeCycle;
|
||||||
if (chartData != null) {
|
if (chartData != null) {
|
||||||
entry = chartData.network.getValues(cycleStart, cycleEnd, entry);
|
final long bytesInCycle = getTotalBytesForTimeRange(chartData.network,
|
||||||
includeCycle = (entry.rxBytes + entry.txBytes) > 0;
|
new Range<>(cycleStart, cycleEnd));
|
||||||
|
includeCycle = bytesInCycle > 0;
|
||||||
} else {
|
} else {
|
||||||
includeCycle = true;
|
includeCycle = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.development;
|
package com.android.settings.development;
|
||||||
|
|
||||||
|
import android.bluetooth.BluetoothManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
|
|
||||||
@@ -42,8 +43,9 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceController extends
|
|||||||
|
|
||||||
public BluetoothMaxConnectedAudioDevicesPreferenceController(Context context) {
|
public BluetoothMaxConnectedAudioDevicesPreferenceController(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
mDefaultMaxConnectedAudioDevices = mContext.getResources().getInteger(
|
BluetoothManager mBluetoothManager = context.getSystemService(BluetoothManager.class);
|
||||||
com.android.internal.R.integer.config_bluetooth_max_connected_audio_devices);
|
mDefaultMaxConnectedAudioDevices = mBluetoothManager.getAdapter()
|
||||||
|
.getMaxConnectedAudioDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
|||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
@@ -62,6 +63,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Ignore
|
||||||
@Config(shadows = {ShadowBluetoothAdapter.class, ShadowBluetoothUtils.class})
|
@Config(shadows = {ShadowBluetoothAdapter.class, ShadowBluetoothUtils.class})
|
||||||
public class AccessibilityHearingAidPreferenceControllerTest {
|
public class AccessibilityHearingAidPreferenceControllerTest {
|
||||||
private static final String TEST_DEVICE_ADDRESS = "00:A1:A1:A1:A1:A1";
|
private static final String TEST_DEVICE_ADDRESS = "00:A1:A1:A1:A1:A1";
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ package com.android.settings.accessibility;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.media.AudioManager;
|
||||||
import android.os.VibrationAttributes;
|
import android.os.VibrationAttributes;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -48,6 +50,7 @@ public class HapticFeedbackIntensityPreferenceControllerTest {
|
|||||||
private static final int ON = 1;
|
private static final int ON = 1;
|
||||||
|
|
||||||
@Mock private PreferenceScreen mScreen;
|
@Mock private PreferenceScreen mScreen;
|
||||||
|
@Mock private AudioManager mAudioManager;
|
||||||
|
|
||||||
private Lifecycle mLifecycle;
|
private Lifecycle mLifecycle;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -59,7 +62,9 @@ public class HapticFeedbackIntensityPreferenceControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mLifecycle = new Lifecycle(() -> mLifecycle);
|
mLifecycle = new Lifecycle(() -> mLifecycle);
|
||||||
mContext = ApplicationProvider.getApplicationContext();
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
|
when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
|
||||||
mVibrator = mContext.getSystemService(Vibrator.class);
|
mVibrator = mContext.getSystemService(Vibrator.class);
|
||||||
mController = new HapticFeedbackIntensityPreferenceController(mContext, PREFERENCE_KEY,
|
mController = new HapticFeedbackIntensityPreferenceController(mContext, PREFERENCE_KEY,
|
||||||
Vibrator.VIBRATION_INTENSITY_HIGH);
|
Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||||
@@ -88,6 +93,54 @@ public class HapticFeedbackIntensityPreferenceControllerTest {
|
|||||||
.isEqualTo(mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_TOUCH));
|
.isEqualTo(mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_TOUCH));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_ringerModeUpdates_shouldPreserveSettingAndDisplaySummary() {
|
||||||
|
updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
assertThat(mPreference.getSummary()).isNull();
|
||||||
|
assertThat(mPreference.isEnabled()).isTrue();
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
|
// TODO(b/136805769): summary is broken in SeekBarPreference, enable this once fixed
|
||||||
|
// assertThat(mPreference.getSummary()).isNotNull();
|
||||||
|
// assertThat(mPreference.getSummary().toString()).isEqualTo(mContext.getString(
|
||||||
|
// R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary));
|
||||||
|
assertThat(mPreference.isEnabled()).isFalse();
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
assertThat(mPreference.getSummary()).isNull();
|
||||||
|
assertThat(mPreference.isEnabled()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_hapticFeedbackDisabled_shouldDisplayAlwaysOff() {
|
||||||
|
updateSetting(Settings.System.HAPTIC_FEEDBACK_ENABLED, OFF);
|
||||||
|
|
||||||
|
updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
|
|
||||||
|
updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY,
|
||||||
|
Vibrator.VIBRATION_INTENSITY_MEDIUM);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
|
|
||||||
|
updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
|
|
||||||
|
updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_shouldDisplayIntensityInSliderPosition() {
|
public void updateState_shouldDisplayIntensityInSliderPosition() {
|
||||||
updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ package com.android.settings.accessibility;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.media.AudioManager;
|
||||||
import android.os.VibrationAttributes;
|
import android.os.VibrationAttributes;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -29,6 +31,7 @@ import androidx.preference.PreferenceScreen;
|
|||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
@@ -48,6 +51,7 @@ public class HapticFeedbackTogglePreferenceControllerTest {
|
|||||||
private static final int ON = 1;
|
private static final int ON = 1;
|
||||||
|
|
||||||
@Mock private PreferenceScreen mScreen;
|
@Mock private PreferenceScreen mScreen;
|
||||||
|
@Mock AudioManager mAudioManager;
|
||||||
|
|
||||||
private Lifecycle mLifecycle;
|
private Lifecycle mLifecycle;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -59,7 +63,9 @@ public class HapticFeedbackTogglePreferenceControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mLifecycle = new Lifecycle(() -> mLifecycle);
|
mLifecycle = new Lifecycle(() -> mLifecycle);
|
||||||
mContext = ApplicationProvider.getApplicationContext();
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
|
when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
|
||||||
mVibrator = mContext.getSystemService(Vibrator.class);
|
mVibrator = mContext.getSystemService(Vibrator.class);
|
||||||
mController = new HapticFeedbackTogglePreferenceController(mContext, PREFERENCE_KEY);
|
mController = new HapticFeedbackTogglePreferenceController(mContext, PREFERENCE_KEY);
|
||||||
mLifecycle.addObserver(mController);
|
mLifecycle.addObserver(mController);
|
||||||
@@ -84,6 +90,54 @@ public class HapticFeedbackTogglePreferenceControllerTest {
|
|||||||
assertThat(mPreference.isChecked()).isTrue();
|
assertThat(mPreference.isChecked()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_ringerModeUpdates_shouldPreserveSettingAndDisplaySummary() {
|
||||||
|
updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isTrue();
|
||||||
|
assertThat(mPreference.getSummary()).isNull();
|
||||||
|
assertThat(mPreference.isEnabled()).isTrue();
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isFalse();
|
||||||
|
assertThat(mPreference.getSummary()).isNotNull();
|
||||||
|
assertThat(mPreference.getSummary().toString()).isEqualTo(mContext.getString(
|
||||||
|
R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary));
|
||||||
|
assertThat(mPreference.isEnabled()).isFalse();
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isTrue();
|
||||||
|
assertThat(mPreference.getSummary()).isNull();
|
||||||
|
assertThat(mPreference.isEnabled()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_hapticFeedbackDisabled_shouldDisplayAlwaysOff() {
|
||||||
|
updateSetting(Settings.System.HAPTIC_FEEDBACK_ENABLED, OFF);
|
||||||
|
|
||||||
|
updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isFalse();
|
||||||
|
|
||||||
|
updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY,
|
||||||
|
Vibrator.VIBRATION_INTENSITY_MEDIUM);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isFalse();
|
||||||
|
|
||||||
|
updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isFalse();
|
||||||
|
|
||||||
|
updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_shouldDisplayOnOffState() {
|
public void updateState_shouldDisplayOnOffState() {
|
||||||
updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ package com.android.settings.accessibility;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.media.AudioManager;
|
||||||
import android.os.VibrationAttributes;
|
import android.os.VibrationAttributes;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -46,6 +48,7 @@ public class NotificationVibrationIntensityPreferenceControllerTest {
|
|||||||
private static final String PREFERENCE_KEY = "preference_key";
|
private static final String PREFERENCE_KEY = "preference_key";
|
||||||
|
|
||||||
@Mock private PreferenceScreen mScreen;
|
@Mock private PreferenceScreen mScreen;
|
||||||
|
@Mock private AudioManager mAudioManager;
|
||||||
|
|
||||||
private Lifecycle mLifecycle;
|
private Lifecycle mLifecycle;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -57,7 +60,9 @@ public class NotificationVibrationIntensityPreferenceControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mLifecycle = new Lifecycle(() -> mLifecycle);
|
mLifecycle = new Lifecycle(() -> mLifecycle);
|
||||||
mContext = ApplicationProvider.getApplicationContext();
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
|
when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
|
||||||
mVibrator = mContext.getSystemService(Vibrator.class);
|
mVibrator = mContext.getSystemService(Vibrator.class);
|
||||||
mController = new NotificationVibrationIntensityPreferenceController(mContext,
|
mController = new NotificationVibrationIntensityPreferenceController(mContext,
|
||||||
PREFERENCE_KEY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
PREFERENCE_KEY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||||
@@ -86,6 +91,34 @@ public class NotificationVibrationIntensityPreferenceControllerTest {
|
|||||||
mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_NOTIFICATION));
|
mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_NOTIFICATION));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_ringerModeUpdates_shouldPreserveSettingAndDisplaySummary() {
|
||||||
|
updateSetting(Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
|
||||||
|
Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
assertThat(mPreference.getSummary()).isNull();
|
||||||
|
assertThat(mPreference.isEnabled()).isTrue();
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
|
// TODO(b/136805769): summary is broken in SeekBarPreference, enable this once fixed
|
||||||
|
// assertThat(mPreference.getSummary()).isNotNull();
|
||||||
|
// assertThat(mPreference.getSummary().toString()).isEqualTo(mContext.getString(
|
||||||
|
// R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary));
|
||||||
|
assertThat(mPreference.isEnabled()).isFalse();
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
assertThat(mPreference.getSummary()).isNull();
|
||||||
|
assertThat(mPreference.isEnabled()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_shouldDisplayIntensityInSliderPosition() {
|
public void updateState_shouldDisplayIntensityInSliderPosition() {
|
||||||
updateSetting(Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
|
updateSetting(Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ package com.android.settings.accessibility;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.media.AudioManager;
|
||||||
import android.os.VibrationAttributes;
|
import android.os.VibrationAttributes;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -29,6 +31,7 @@ import androidx.preference.PreferenceScreen;
|
|||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
@@ -46,6 +49,7 @@ public class NotificationVibrationTogglePreferenceControllerTest {
|
|||||||
private static final String PREFERENCE_KEY = "preference_key";
|
private static final String PREFERENCE_KEY = "preference_key";
|
||||||
|
|
||||||
@Mock private PreferenceScreen mScreen;
|
@Mock private PreferenceScreen mScreen;
|
||||||
|
@Mock private AudioManager mAudioManager;
|
||||||
|
|
||||||
private Lifecycle mLifecycle;
|
private Lifecycle mLifecycle;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -57,7 +61,9 @@ public class NotificationVibrationTogglePreferenceControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mLifecycle = new Lifecycle(() -> mLifecycle);
|
mLifecycle = new Lifecycle(() -> mLifecycle);
|
||||||
mContext = ApplicationProvider.getApplicationContext();
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
|
when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
|
||||||
mVibrator = mContext.getSystemService(Vibrator.class);
|
mVibrator = mContext.getSystemService(Vibrator.class);
|
||||||
mController = new NotificationVibrationTogglePreferenceController(mContext, PREFERENCE_KEY);
|
mController = new NotificationVibrationTogglePreferenceController(mContext, PREFERENCE_KEY);
|
||||||
mLifecycle.addObserver(mController);
|
mLifecycle.addObserver(mController);
|
||||||
@@ -82,6 +88,32 @@ public class NotificationVibrationTogglePreferenceControllerTest {
|
|||||||
assertThat(mPreference.isChecked()).isTrue();
|
assertThat(mPreference.isChecked()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_ringerModeUpdates_shouldPreserveSettingAndDisplaySummary() {
|
||||||
|
updateSetting(Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
|
||||||
|
Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isTrue();
|
||||||
|
assertThat(mPreference.getSummary()).isNull();
|
||||||
|
assertThat(mPreference.isEnabled()).isTrue();
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isFalse();
|
||||||
|
assertThat(mPreference.getSummary()).isNotNull();
|
||||||
|
assertThat(mPreference.getSummary().toString()).isEqualTo(mContext.getString(
|
||||||
|
R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary));
|
||||||
|
assertThat(mPreference.isEnabled()).isFalse();
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isTrue();
|
||||||
|
assertThat(mPreference.getSummary()).isNull();
|
||||||
|
assertThat(mPreference.isEnabled()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_shouldDisplayOnOffState() {
|
public void updateState_shouldDisplayOnOffState() {
|
||||||
updateSetting(Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
|
updateSetting(Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ package com.android.settings.accessibility;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.media.AudioManager;
|
||||||
import android.os.VibrationAttributes;
|
import android.os.VibrationAttributes;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -49,6 +51,7 @@ public class RingVibrationIntensityPreferenceControllerTest {
|
|||||||
private static final int ON = 1;
|
private static final int ON = 1;
|
||||||
|
|
||||||
@Mock private PreferenceScreen mScreen;
|
@Mock private PreferenceScreen mScreen;
|
||||||
|
@Mock private AudioManager mAudioManager;
|
||||||
|
|
||||||
private Lifecycle mLifecycle;
|
private Lifecycle mLifecycle;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -60,7 +63,9 @@ public class RingVibrationIntensityPreferenceControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mLifecycle = new Lifecycle(() -> mLifecycle);
|
mLifecycle = new Lifecycle(() -> mLifecycle);
|
||||||
mContext = ApplicationProvider.getApplicationContext();
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
|
when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
|
||||||
mVibrator = mContext.getSystemService(Vibrator.class);
|
mVibrator = mContext.getSystemService(Vibrator.class);
|
||||||
mController = new RingVibrationIntensityPreferenceController(mContext, PREFERENCE_KEY,
|
mController = new RingVibrationIntensityPreferenceController(mContext, PREFERENCE_KEY,
|
||||||
Vibrator.VIBRATION_INTENSITY_HIGH);
|
Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||||
@@ -89,6 +94,55 @@ public class RingVibrationIntensityPreferenceControllerTest {
|
|||||||
mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_RINGTONE));
|
mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_RINGTONE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_ringerModeUpdates_shouldPreserveSettingAndDisplaySummary() {
|
||||||
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
assertThat(mPreference.getSummary()).isNull();
|
||||||
|
assertThat(mPreference.isEnabled()).isTrue();
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
|
// TODO(b/136805769): summary is broken in SeekBarPreference, enable this once fixed
|
||||||
|
// assertThat(mPreference.getSummary()).isNotNull();
|
||||||
|
// assertThat(mPreference.getSummary().toString()).isEqualTo(mContext.getString(
|
||||||
|
// R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary));
|
||||||
|
assertThat(mPreference.isEnabled()).isFalse();
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
assertThat(mPreference.getSummary()).isNull();
|
||||||
|
assertThat(mPreference.isEnabled()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldDisplayAlwaysOff() {
|
||||||
|
when(mAudioManager.isRampingRingerEnabled()).thenReturn(false);
|
||||||
|
updateSetting(Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
||||||
|
|
||||||
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
|
|
||||||
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY,
|
||||||
|
Vibrator.VIBRATION_INTENSITY_MEDIUM);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
|
|
||||||
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
|
|
||||||
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_shouldDisplayIntensityInSliderPosition() {
|
public void updateState_shouldDisplayIntensityInSliderPosition() {
|
||||||
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||||
@@ -109,7 +163,6 @@ public class RingVibrationIntensityPreferenceControllerTest {
|
|||||||
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void setProgress_updatesIntensityAndDependentSettings() throws Exception {
|
public void setProgress_updatesIntensityAndDependentSettings() throws Exception {
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ package com.android.settings.accessibility;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.media.AudioManager;
|
||||||
import android.os.VibrationAttributes;
|
import android.os.VibrationAttributes;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -29,6 +31,7 @@ import androidx.preference.PreferenceScreen;
|
|||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
@@ -48,6 +51,7 @@ public class RingVibrationTogglePreferenceControllerTest {
|
|||||||
private static final int ON = 1;
|
private static final int ON = 1;
|
||||||
|
|
||||||
@Mock private PreferenceScreen mScreen;
|
@Mock private PreferenceScreen mScreen;
|
||||||
|
@Mock private AudioManager mAudioManager;
|
||||||
|
|
||||||
private Lifecycle mLifecycle;
|
private Lifecycle mLifecycle;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -59,7 +63,9 @@ public class RingVibrationTogglePreferenceControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mLifecycle = new Lifecycle(() -> mLifecycle);
|
mLifecycle = new Lifecycle(() -> mLifecycle);
|
||||||
mContext = ApplicationProvider.getApplicationContext();
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
|
when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
|
||||||
mVibrator = mContext.getSystemService(Vibrator.class);
|
mVibrator = mContext.getSystemService(Vibrator.class);
|
||||||
mController = new RingVibrationTogglePreferenceController(mContext, PREFERENCE_KEY);
|
mController = new RingVibrationTogglePreferenceController(mContext, PREFERENCE_KEY);
|
||||||
mLifecycle.addObserver(mController);
|
mLifecycle.addObserver(mController);
|
||||||
@@ -84,6 +90,54 @@ public class RingVibrationTogglePreferenceControllerTest {
|
|||||||
assertThat(mPreference.isChecked()).isTrue();
|
assertThat(mPreference.isChecked()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_ringerModeUpdates_shouldPreserveSettingAndDisplaySummary() {
|
||||||
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isTrue();
|
||||||
|
assertThat(mPreference.getSummary()).isNull();
|
||||||
|
assertThat(mPreference.isEnabled()).isTrue();
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isFalse();
|
||||||
|
assertThat(mPreference.getSummary()).isNotNull();
|
||||||
|
assertThat(mPreference.getSummary().toString()).isEqualTo(mContext.getString(
|
||||||
|
R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary));
|
||||||
|
assertThat(mPreference.isEnabled()).isFalse();
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isTrue();
|
||||||
|
assertThat(mPreference.getSummary()).isNull();
|
||||||
|
assertThat(mPreference.isEnabled()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldDisplayAlwaysOff() {
|
||||||
|
when(mAudioManager.isRampingRingerEnabled()).thenReturn(false);
|
||||||
|
updateSetting(Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
||||||
|
|
||||||
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isFalse();
|
||||||
|
|
||||||
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY,
|
||||||
|
Vibrator.VIBRATION_INTENSITY_MEDIUM);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isFalse();
|
||||||
|
|
||||||
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isFalse();
|
||||||
|
|
||||||
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
assertThat(mPreference.isChecked()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_shouldDisplayOnOffState() {
|
public void updateState_shouldDisplayOnOffState() {
|
||||||
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ public class VibrationRampingRingerTogglePreferenceControllerTest {
|
|||||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
|
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
|
||||||
when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
|
when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
|
||||||
mController = new VibrationRampingRingerTogglePreferenceController(mContext,
|
mController = new VibrationRampingRingerTogglePreferenceController(mContext,
|
||||||
PREFERENCE_KEY, mDeviceConfigProvider);
|
PREFERENCE_KEY, mDeviceConfigProvider);
|
||||||
mLifecycle.addObserver(mController);
|
mLifecycle.addObserver(mController);
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import androidx.fragment.app.FragmentTransaction;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settingslib.widget.ActionButtonsPreference;
|
import com.android.settingslib.widget.ActionButtonsPreference;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
@@ -42,6 +43,7 @@ import org.robolectric.RobolectricTestRunner;
|
|||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Ignore
|
||||||
public class BluetoothDetailsButtonsControllerTest extends BluetoothDetailsControllerTestBase {
|
public class BluetoothDetailsButtonsControllerTest extends BluetoothDetailsControllerTestBase {
|
||||||
private BluetoothDetailsButtonsController mController;
|
private BluetoothDetailsButtonsController mController;
|
||||||
private ActionButtonsPreference mButtonsPref;
|
private ActionButtonsPreference mButtonsPref;
|
||||||
|
|||||||
@@ -29,11 +29,13 @@ import androidx.preference.PreferenceScreen;
|
|||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Ignore
|
||||||
public class BluetoothDetailsControllerEventsTest extends BluetoothDetailsControllerTestBase {
|
public class BluetoothDetailsControllerEventsTest extends BluetoothDetailsControllerTestBase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
|||||||
import com.android.settingslib.widget.LayoutPreference;
|
import com.android.settingslib.widget.LayoutPreference;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Answers;
|
import org.mockito.Answers;
|
||||||
@@ -46,6 +47,7 @@ import org.robolectric.RobolectricTestRunner;
|
|||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Ignore
|
||||||
@Config(shadows = {ShadowEntityHeaderController.class, ShadowDeviceConfig.class})
|
@Config(shadows = {ShadowEntityHeaderController.class, ShadowDeviceConfig.class})
|
||||||
public class BluetoothDetailsHeaderControllerTest extends BluetoothDetailsControllerTestBase {
|
public class BluetoothDetailsHeaderControllerTest extends BluetoothDetailsControllerTestBase {
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,13 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
|
|
||||||
import com.android.settingslib.widget.FooterPreference;
|
import com.android.settingslib.widget.FooterPreference;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Ignore
|
||||||
public class BluetoothDetailsMacAddressControllerTest extends BluetoothDetailsControllerTestBase {
|
public class BluetoothDetailsMacAddressControllerTest extends BluetoothDetailsControllerTestBase {
|
||||||
private BluetoothDetailsMacAddressController mController;
|
private BluetoothDetailsMacAddressController mController;
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
|||||||
import com.android.settingslib.bluetooth.MapProfile;
|
import com.android.settingslib.bluetooth.MapProfile;
|
||||||
import com.android.settingslib.bluetooth.PbapServerProfile;
|
import com.android.settingslib.bluetooth.PbapServerProfile;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
@@ -56,6 +57,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Ignore
|
||||||
@Config(shadows = ShadowBluetoothDevice.class)
|
@Config(shadows = ShadowBluetoothDevice.class)
|
||||||
public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsControllerTestBase {
|
public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsControllerTestBase {
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,9 @@ 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.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.bluetooth.BluetoothAdapter;
|
||||||
|
import android.bluetooth.BluetoothManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
|
|
||||||
import androidx.preference.ListPreference;
|
import androidx.preference.ListPreference;
|
||||||
@@ -52,7 +53,10 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceControllerTest {
|
|||||||
@Spy
|
@Spy
|
||||||
private Context mSpyContext = RuntimeEnvironment.application;
|
private Context mSpyContext = RuntimeEnvironment.application;
|
||||||
@Spy
|
@Spy
|
||||||
private Resources mSpyResources = RuntimeEnvironment.application.getResources();
|
private BluetoothManager mBluetoothManager =
|
||||||
|
mSpyContext.getSystemService(BluetoothManager.class);
|
||||||
|
@Spy
|
||||||
|
private BluetoothAdapter mBluetoothAdapter = mBluetoothManager.getAdapter();
|
||||||
|
|
||||||
private ListPreference mPreference;
|
private ListPreference mPreference;
|
||||||
private BluetoothMaxConnectedAudioDevicesPreferenceController mController;
|
private BluetoothMaxConnectedAudioDevicesPreferenceController mController;
|
||||||
@@ -63,15 +67,16 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceControllerTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
doReturn(mSpyResources).when(mSpyContext).getResources();
|
doReturn(mBluetoothManager).when(mSpyContext).getSystemService(BluetoothManager.class);
|
||||||
|
doReturn(mBluetoothAdapter).when(mBluetoothManager).getAdapter();
|
||||||
// Get XML values without mock
|
// Get XML values without mock
|
||||||
// Setup test list preference using XML values
|
// Setup test list preference using XML values
|
||||||
mPreference = new ListPreference(mSpyContext);
|
mPreference = new ListPreference(mSpyContext);
|
||||||
mPreference.setEntries(R.array.bluetooth_max_connected_audio_devices);
|
mPreference.setEntries(R.array.bluetooth_max_connected_audio_devices);
|
||||||
mPreference.setEntryValues(R.array.bluetooth_max_connected_audio_devices_values);
|
mPreference.setEntryValues(R.array.bluetooth_max_connected_audio_devices_values);
|
||||||
// Stub default max connected audio devices to a test controlled value
|
// Stub default max connected audio devices to a test controlled value
|
||||||
doReturn(TEST_MAX_CONNECTED_AUDIO_DEVICES).when(mSpyResources).getInteger(
|
doReturn(TEST_MAX_CONNECTED_AUDIO_DEVICES).when(mBluetoothAdapter)
|
||||||
com.android.internal.R.integer.config_bluetooth_max_connected_audio_devices);
|
.getMaxConnectedAudioDevices();
|
||||||
// Init the actual controller
|
// Init the actual controller
|
||||||
mController = new BluetoothMaxConnectedAudioDevicesPreferenceController(mSpyContext);
|
mController = new BluetoothMaxConnectedAudioDevicesPreferenceController(mSpyContext);
|
||||||
// Construct preference in the controller via a mocked preference screen object
|
// Construct preference in the controller via a mocked preference screen object
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
|||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
@@ -73,6 +74,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Ignore
|
||||||
@Config(shadows = {
|
@Config(shadows = {
|
||||||
ShadowAudioManager.class,
|
ShadowAudioManager.class,
|
||||||
ShadowBluetoothUtils.class,
|
ShadowBluetoothUtils.class,
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Ignore
|
||||||
@Config(shadows = {
|
@Config(shadows = {
|
||||||
ShadowAudioManager.class,
|
ShadowAudioManager.class,
|
||||||
ShadowBluetoothUtils.class,
|
ShadowBluetoothUtils.class,
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Ignore
|
||||||
@Config(shadows = {
|
@Config(shadows = {
|
||||||
ShadowAudioManager.class,
|
ShadowAudioManager.class,
|
||||||
ShadowBluetoothUtils.class,
|
ShadowBluetoothUtils.class,
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ import com.android.wifitrackerlib.WifiEntry;
|
|||||||
import com.android.wifitrackerlib.WifiPickerTracker;
|
import com.android.wifitrackerlib.WifiPickerTracker;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
@@ -71,7 +70,6 @@ import org.robolectric.annotation.Config;
|
|||||||
import org.robolectric.shadows.ShadowToast;
|
import org.robolectric.shadows.ShadowToast;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Ignore
|
|
||||||
public class WifiSettingsTest {
|
public class WifiSettingsTest {
|
||||||
|
|
||||||
private static final int NUM_NETWORKS = 4;
|
private static final int NUM_NETWORKS = 4;
|
||||||
@@ -94,6 +92,7 @@ public class WifiSettingsTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
|
when(mContext.getSystemService(UserManager.class)).thenReturn(mock(UserManager.class));
|
||||||
|
|
||||||
mWifiSettings = spy(new WifiSettings());
|
mWifiSettings = spy(new WifiSettings());
|
||||||
doReturn(mContext).when(mWifiSettings).getContext();
|
doReturn(mContext).when(mWifiSettings).getContext();
|
||||||
|
|||||||
Reference in New Issue
Block a user