Snap for 7949225 from 13d7e086e6 to tm-release
Change-Id: Icf37aeba4ae9db053c6f425ba7feff222e833c8e
This commit is contained in:
@@ -4174,7 +4174,7 @@
|
|||||||
|
|
||||||
<activity android:name="Settings$MediaControlsSettingsActivity"
|
<activity android:name="Settings$MediaControlsSettingsActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:label="@strings/media_controls_title">
|
android:label="@string/media_controls_title">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS" />
|
<action android:name="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
|||||||
@@ -7462,7 +7462,7 @@
|
|||||||
<!-- Button label to disconnect from a VPN profile. [CHAR LIMIT=40] -->
|
<!-- Button label to disconnect from a VPN profile. [CHAR LIMIT=40] -->
|
||||||
<string name="vpn_disconnect">Disconnect</string>
|
<string name="vpn_disconnect">Disconnect</string>
|
||||||
<!-- Field label to show the version number for a VPN app. [CHAR LIMIT=40] -->
|
<!-- Field label to show the version number for a VPN app. [CHAR LIMIT=40] -->
|
||||||
<string name="vpn_version">Version <xliff:g id="version" example="3.3.0">%s</xliff:g></string>
|
<string name="vpn_version">Version</string>
|
||||||
<!-- Button label to forget a VPN profile [CHAR LIMIT=40] -->
|
<!-- Button label to forget a VPN profile [CHAR LIMIT=40] -->
|
||||||
<string name="vpn_forget_long">Forget VPN</string>
|
<string name="vpn_forget_long">Forget VPN</string>
|
||||||
<!-- Dialog message title to set another VPN app to be always-on [CHAR LIMIT=40] -->
|
<!-- Dialog message title to set another VPN app to be always-on [CHAR LIMIT=40] -->
|
||||||
|
|||||||
@@ -237,6 +237,16 @@
|
|||||||
<item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault.Small</item>
|
<item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault.Small</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="vpn_app_management_version_title">
|
||||||
|
<item name="android:textAppearance">?android:attr/textAppearanceListItem</item>
|
||||||
|
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="vpn_app_management_version_summary">
|
||||||
|
<item name="android:textAppearance">?android:attr/textAppearanceListItemSecondary</item>
|
||||||
|
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="screen_size_imageview_style">
|
<style name="screen_size_imageview_style">
|
||||||
<item name="android:layout_width">48dp</item>
|
<item name="android:layout_width">48dp</item>
|
||||||
<item name="android:layout_height">48dp</item>
|
<item name="android:layout_height">48dp</item>
|
||||||
|
|||||||
@@ -15,14 +15,24 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:settings="http://schemas.android.com/apk/res-auto">
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
|
orderingFromXml="false"
|
||||||
|
>
|
||||||
|
|
||||||
|
<!-- To limit the size (in height) of version Preference displayed here,
|
||||||
|
maximum height of TextView need to be set programmingly.
|
||||||
|
Therefore, this Preference got removed from here and will be added
|
||||||
|
dynamically through source code.
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
|
android:order="0"
|
||||||
android:key="version"
|
android:key="version"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
android:selectable="false"/>
|
android:selectable="false"/>
|
||||||
|
-->
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedSwitchPreference
|
<com.android.settingslib.RestrictedSwitchPreference
|
||||||
|
android:order="10"
|
||||||
android:key="always_on_vpn"
|
android:key="always_on_vpn"
|
||||||
android:title="@string/vpn_menu_lockdown"
|
android:title="@string/vpn_menu_lockdown"
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
@@ -32,6 +42,7 @@
|
|||||||
settings:restrictedSwitchSummary="@string/disabled_by_admin_summary_text" />
|
settings:restrictedSwitchSummary="@string/disabled_by_admin_summary_text" />
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedSwitchPreference
|
<com.android.settingslib.RestrictedSwitchPreference
|
||||||
|
android:order="20"
|
||||||
android:key="lockdown_vpn"
|
android:key="lockdown_vpn"
|
||||||
android:title="@string/vpn_require_connection"
|
android:title="@string/vpn_require_connection"
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
@@ -41,6 +52,7 @@
|
|||||||
settings:restrictedSwitchSummary="@string/disabled_by_admin_summary_text" />
|
settings:restrictedSwitchSummary="@string/disabled_by_admin_summary_text" />
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedPreference
|
<com.android.settingslib.RestrictedPreference
|
||||||
|
android:order="30"
|
||||||
android:key="forget_vpn"
|
android:key="forget_vpn"
|
||||||
android:title="@string/vpn_forget_long"
|
android:title="@string/vpn_forget_long"
|
||||||
android:icon="@drawable/ic_delete"
|
android:icon="@drawable/ic_delete"
|
||||||
|
|||||||
@@ -295,8 +295,8 @@ public class AccessibilitySettings extends DashboardFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean isRampingRingerEnabled(final Context context) {
|
static boolean isRampingRingerEnabled(final Context context) {
|
||||||
return Settings.Global.getInt(
|
return Settings.System.getInt(
|
||||||
context.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 0) == 1;
|
context.getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class RingVibrationPreferenceFragment extends VibrationPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
protected String getVibrationEnabledSetting() {
|
protected String getVibrationEnabledSetting() {
|
||||||
if (AccessibilitySettings.isRampingRingerEnabled(getContext())) {
|
if (AccessibilitySettings.isRampingRingerEnabled(getContext())) {
|
||||||
return Settings.Global.APPLY_RAMPING_RINGER;
|
return Settings.System.APPLY_RAMPING_RINGER;
|
||||||
} else {
|
} else {
|
||||||
return Settings.System.VIBRATE_WHEN_RINGING;
|
return Settings.System.VIBRATE_WHEN_RINGING;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,12 +116,12 @@ public abstract class VibrationPreferenceFragment extends RadioButtonPickerFragm
|
|||||||
// Update vibration enabled setting
|
// Update vibration enabled setting
|
||||||
final String vibrationEnabledSetting = getVibrationEnabledSetting();
|
final String vibrationEnabledSetting = getVibrationEnabledSetting();
|
||||||
final boolean wasEnabled = TextUtils.equals(
|
final boolean wasEnabled = TextUtils.equals(
|
||||||
vibrationEnabledSetting, Settings.Global.APPLY_RAMPING_RINGER)
|
vibrationEnabledSetting, Settings.System.APPLY_RAMPING_RINGER)
|
||||||
? true
|
? true
|
||||||
: (Settings.System.getInt(
|
: (Settings.System.getInt(
|
||||||
getContext().getContentResolver(), vibrationEnabledSetting, 1) == 1);
|
getContext().getContentResolver(), vibrationEnabledSetting, 1) == 1);
|
||||||
if (vibrationEnabled != wasEnabled) {
|
if (vibrationEnabled != wasEnabled) {
|
||||||
if (vibrationEnabledSetting.equals(Settings.Global.APPLY_RAMPING_RINGER)) {
|
if (vibrationEnabledSetting.equals(Settings.System.APPLY_RAMPING_RINGER)) {
|
||||||
Settings.Global.putInt(getContext().getContentResolver(),
|
Settings.Global.putInt(getContext().getContentResolver(),
|
||||||
vibrationEnabledSetting, 0);
|
vibrationEnabledSetting, 0);
|
||||||
} else {
|
} else {
|
||||||
@@ -212,7 +212,7 @@ public abstract class VibrationPreferenceFragment extends RadioButtonPickerFragm
|
|||||||
getVibrationIntensitySetting(), getDefaultVibrationIntensity());
|
getVibrationIntensitySetting(), getDefaultVibrationIntensity());
|
||||||
final String vibrationEnabledSetting = getVibrationEnabledSetting();
|
final String vibrationEnabledSetting = getVibrationEnabledSetting();
|
||||||
final boolean vibrationEnabled = TextUtils.equals(
|
final boolean vibrationEnabled = TextUtils.equals(
|
||||||
vibrationEnabledSetting, Settings.Global.APPLY_RAMPING_RINGER)
|
vibrationEnabledSetting, Settings.System.APPLY_RAMPING_RINGER)
|
||||||
? true
|
? true
|
||||||
: (Settings.System.getInt(
|
: (Settings.System.getInt(
|
||||||
getContext().getContentResolver(), vibrationEnabledSetting, 1) == 1);
|
getContext().getContentResolver(), vibrationEnabledSetting, 1) == 1);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import android.graphics.drawable.Drawable;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.provider.DeviceConfig;
|
import android.provider.DeviceConfig;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -126,8 +127,8 @@ public class BluetoothDetailsCompanionAppsController extends BluetoothDetailsCon
|
|||||||
try {
|
try {
|
||||||
java.util.Objects.requireNonNull(ICompanionDeviceManager.Stub.asInterface(
|
java.util.Objects.requireNonNull(ICompanionDeviceManager.Stub.asInterface(
|
||||||
ServiceManager.getService(
|
ServiceManager.getService(
|
||||||
Context.COMPANION_DEVICE_SERVICE))).disassociate(
|
Context.COMPANION_DEVICE_SERVICE))).legacyDisassociate(
|
||||||
address, packageName);
|
address, packageName, UserHandle.myUserId());
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
|
import com.android.internal.util.CollectionUtils;
|
||||||
import com.android.settingslib.R;
|
import com.android.settingslib.R;
|
||||||
import com.android.settingslib.Utils;
|
import com.android.settingslib.Utils;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
@@ -159,7 +160,9 @@ public class NotificationBackend {
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<String> associatedMacAddrs = cdm.getAssociations(pkg, userId);
|
List<String> associatedMacAddrs = CollectionUtils.mapNotNull(
|
||||||
|
cdm.getAssociations(pkg, userId),
|
||||||
|
a -> a.isSelfManaged() ? null : a.getDeviceMacAddress().toString());
|
||||||
if (associatedMacAddrs != null) {
|
if (associatedMacAddrs != null) {
|
||||||
for (String assocMac : associatedMacAddrs) {
|
for (String assocMac : associatedMacAddrs) {
|
||||||
final Collection<CachedBluetoothDevice> cachedDevices =
|
final Collection<CachedBluetoothDevice> cachedDevices =
|
||||||
|
|||||||
@@ -51,9 +51,9 @@ public class VibrateForCallsPreferenceController extends BasePreferenceControlle
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary() {
|
public CharSequence getSummary() {
|
||||||
if (Settings.Global.getInt(
|
if (Settings.System.getInt(
|
||||||
mContext.getContentResolver(),
|
mContext.getContentResolver(),
|
||||||
Settings.Global.APPLY_RAMPING_RINGER, OFF) == ON) {
|
Settings.System.APPLY_RAMPING_RINGER, OFF) == ON) {
|
||||||
return mContext.getText(R.string.vibrate_when_ringing_option_ramping_ringer);
|
return mContext.getText(R.string.vibrate_when_ringing_option_ramping_ringer);
|
||||||
} else if (Settings.System.getInt(
|
} else if (Settings.System.getInt(
|
||||||
mContext.getContentResolver(),
|
mContext.getContentResolver(),
|
||||||
|
|||||||
@@ -78,18 +78,18 @@ public class VibrateForCallsPreferenceFragment extends RadioButtonPickerFragment
|
|||||||
if (TextUtils.equals(key, KEY_ALWAYS_VIBRATE)) {
|
if (TextUtils.equals(key, KEY_ALWAYS_VIBRATE)) {
|
||||||
Settings.System.putInt(
|
Settings.System.putInt(
|
||||||
getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, ON);
|
getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, ON);
|
||||||
Settings.Global.putInt(
|
Settings.System.putInt(
|
||||||
getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, OFF);
|
getContext().getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, OFF);
|
||||||
} else if (TextUtils.equals(key, KEY_RAMPING_RINGER)) {
|
} else if (TextUtils.equals(key, KEY_RAMPING_RINGER)) {
|
||||||
Settings.System.putInt(
|
Settings.System.putInt(
|
||||||
getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
||||||
Settings.Global.putInt(
|
Settings.System.putInt(
|
||||||
getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, ON);
|
getContext().getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, ON);
|
||||||
} else {
|
} else {
|
||||||
Settings.System.putInt(
|
Settings.System.putInt(
|
||||||
getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
||||||
Settings.Global.putInt(
|
Settings.System.putInt(
|
||||||
getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, OFF);
|
getContext().getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,9 +104,9 @@ public class VibrateForCallsPreferenceFragment extends RadioButtonPickerFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getDefaultKey() {
|
protected String getDefaultKey() {
|
||||||
if (Settings.Global.getInt(
|
if (Settings.System.getInt(
|
||||||
getContext().getContentResolver(),
|
getContext().getContentResolver(),
|
||||||
Settings.Global.APPLY_RAMPING_RINGER, OFF) == ON) {
|
Settings.System.APPLY_RAMPING_RINGER, OFF) == ON) {
|
||||||
return KEY_RAMPING_RINGER;
|
return KEY_RAMPING_RINGER;
|
||||||
} else if (Settings.System.getInt(
|
} else if (Settings.System.getInt(
|
||||||
getContext().getContentResolver(),
|
getContext().getContentResolver(),
|
||||||
|
|||||||
@@ -34,11 +34,13 @@ import android.os.UserHandle;
|
|||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceViewHolder;
|
||||||
|
|
||||||
import com.android.internal.net.VpnConfig;
|
import com.android.internal.net.VpnConfig;
|
||||||
import com.android.internal.util.ArrayUtils;
|
import com.android.internal.util.ArrayUtils;
|
||||||
@@ -77,7 +79,6 @@ public class AppManagementFragment extends SettingsPreferenceFragment
|
|||||||
private String mVpnLabel;
|
private String mVpnLabel;
|
||||||
|
|
||||||
// UI preference
|
// UI preference
|
||||||
private Preference mPreferenceVersion;
|
|
||||||
private RestrictedSwitchPreference mPreferenceAlwaysOn;
|
private RestrictedSwitchPreference mPreferenceAlwaysOn;
|
||||||
private RestrictedSwitchPreference mPreferenceLockdown;
|
private RestrictedSwitchPreference mPreferenceLockdown;
|
||||||
private RestrictedPreference mPreferenceForget;
|
private RestrictedPreference mPreferenceForget;
|
||||||
@@ -122,7 +123,6 @@ public class AppManagementFragment extends SettingsPreferenceFragment
|
|||||||
mDevicePolicyManager = getContext().getSystemService(DevicePolicyManager.class);
|
mDevicePolicyManager = getContext().getSystemService(DevicePolicyManager.class);
|
||||||
mVpnManager = getContext().getSystemService(VpnManager.class);
|
mVpnManager = getContext().getSystemService(VpnManager.class);
|
||||||
|
|
||||||
mPreferenceVersion = findPreference(KEY_VERSION);
|
|
||||||
mPreferenceAlwaysOn = (RestrictedSwitchPreference) findPreference(KEY_ALWAYS_ON_VPN);
|
mPreferenceAlwaysOn = (RestrictedSwitchPreference) findPreference(KEY_ALWAYS_ON_VPN);
|
||||||
mPreferenceLockdown = (RestrictedSwitchPreference) findPreference(KEY_LOCKDOWN_VPN);
|
mPreferenceLockdown = (RestrictedSwitchPreference) findPreference(KEY_LOCKDOWN_VPN);
|
||||||
mPreferenceForget = (RestrictedPreference) findPreference(KEY_FORGET_VPN);
|
mPreferenceForget = (RestrictedPreference) findPreference(KEY_FORGET_VPN);
|
||||||
@@ -138,9 +138,52 @@ public class AppManagementFragment extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
boolean isInfoLoaded = loadInfo();
|
boolean isInfoLoaded = loadInfo();
|
||||||
if (isInfoLoaded) {
|
if (isInfoLoaded) {
|
||||||
mPreferenceVersion.setTitle(
|
|
||||||
getPrefContext().getString(R.string.vpn_version, mPackageInfo.versionName));
|
|
||||||
updateUI();
|
updateUI();
|
||||||
|
|
||||||
|
Preference version = getPreferenceScreen().findPreference(KEY_VERSION);
|
||||||
|
if (version != null) {
|
||||||
|
// Version field has been added.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create version field at runtime, and set max height on the display area.
|
||||||
|
*
|
||||||
|
* When long length of text given within version field, a large text area
|
||||||
|
* might be created and inconvenient to the user (User need to scroll
|
||||||
|
* for a long time in order to get to the Preferences after this field.)
|
||||||
|
*/
|
||||||
|
version = new Preference(getPrefContext()) {
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||||
|
super.onBindViewHolder(holder);
|
||||||
|
|
||||||
|
TextView titleView =
|
||||||
|
(TextView) holder.findViewById(android.R.id.title);
|
||||||
|
if (titleView != null) {
|
||||||
|
titleView.setTextAppearance(R.style.vpn_app_management_version_title);
|
||||||
|
}
|
||||||
|
|
||||||
|
TextView summaryView =
|
||||||
|
(TextView) holder.findViewById(android.R.id.summary);
|
||||||
|
if (summaryView != null) {
|
||||||
|
summaryView.setTextAppearance(R.style.vpn_app_management_version_summary);
|
||||||
|
|
||||||
|
// Set max height in summary area.
|
||||||
|
int versionMaxHeight = getListView().getHeight();
|
||||||
|
summaryView.setMaxHeight(versionMaxHeight);
|
||||||
|
summaryView.setVerticalScrollBarEnabled(false);
|
||||||
|
summaryView.setHorizontallyScrolling(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
version.setOrder(0); // Set order to 0 in order to be placed
|
||||||
|
// in front of other Preference(s).
|
||||||
|
version.setKey(KEY_VERSION); // Set key to avoid from creating multi instance.
|
||||||
|
version.setTitle(R.string.vpn_version);
|
||||||
|
version.setSummary(mPackageInfo.versionName);
|
||||||
|
version.setSelectable(false);
|
||||||
|
getPreferenceScreen().addPreference(version);
|
||||||
} else {
|
} else {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,16 +146,16 @@ public class AccessibilitySettingsTest {
|
|||||||
@Test
|
@Test
|
||||||
@Config(shadows = {ShadowDeviceConfig.class})
|
@Config(shadows = {ShadowDeviceConfig.class})
|
||||||
public void isRampingRingerEnabled_settingsFlagOn_Enabled() {
|
public void isRampingRingerEnabled_settingsFlagOn_Enabled() {
|
||||||
Settings.Global.putInt(
|
Settings.System.putInt(
|
||||||
mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, ON);
|
mContext.getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, ON);
|
||||||
assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isTrue();
|
assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Config(shadows = {ShadowDeviceConfig.class})
|
@Config(shadows = {ShadowDeviceConfig.class})
|
||||||
public void isRampingRingerEnabled_settingsFlagOff_Disabled() {
|
public void isRampingRingerEnabled_settingsFlagOff_Disabled() {
|
||||||
Settings.Global.putInt(
|
Settings.System.putInt(
|
||||||
mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, OFF);
|
mContext.getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, OFF);
|
||||||
assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isFalse();
|
assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,17 +50,17 @@ public class RingVibrationPreferenceFragmentTest {
|
|||||||
@Config(shadows = {ShadowDeviceConfig.class})
|
@Config(shadows = {ShadowDeviceConfig.class})
|
||||||
public void getVibrationEnabledSetting_rampingRingerEnabled_returnApplyRampingRinger() {
|
public void getVibrationEnabledSetting_rampingRingerEnabled_returnApplyRampingRinger() {
|
||||||
// Turn on both flags to enable ramping ringer.
|
// Turn on both flags to enable ramping ringer.
|
||||||
Settings.Global.putInt(
|
Settings.System.putInt(
|
||||||
mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 1 /* ON */);
|
mContext.getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, 1 /* ON */);
|
||||||
assertThat(mFragment.getVibrationEnabledSetting()).isEqualTo(
|
assertThat(mFragment.getVibrationEnabledSetting()).isEqualTo(
|
||||||
Settings.Global.APPLY_RAMPING_RINGER);
|
Settings.System.APPLY_RAMPING_RINGER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getVibrationEnabledSetting_rampingRingerDisabled_returnVibrationWhenRinging() {
|
public void getVibrationEnabledSetting_rampingRingerDisabled_returnVibrationWhenRinging() {
|
||||||
// Turn off Settings.Global.APPLY_RAMPING_RINGER to disable ramping ringer.
|
// Turn off Settings.System.APPLY_RAMPING_RINGER to disable ramping ringer.
|
||||||
Settings.Global.putInt(
|
Settings.System.putInt(
|
||||||
mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 0 /* OFF */);
|
mContext.getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, 0 /* OFF */);
|
||||||
assertThat(mFragment.getVibrationEnabledSetting()).isEqualTo(
|
assertThat(mFragment.getVibrationEnabledSetting()).isEqualTo(
|
||||||
Settings.System.VIBRATE_WHEN_RINGING);
|
Settings.System.VIBRATE_WHEN_RINGING);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import android.companion.AssociationInfo;
|
import android.companion.AssociationInfo;
|
||||||
import android.companion.CompanionDeviceManager;
|
import android.companion.CompanionDeviceManager;
|
||||||
import android.companion.DeviceId;
|
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.net.MacAddress;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceCategory;
|
import androidx.preference.PreferenceCategory;
|
||||||
@@ -100,15 +100,14 @@ public class BluetoothDetailsCompanionAppsControllerTest extends
|
|||||||
setupFakeLabelAndInfo(packageName, appName);
|
setupFakeLabelAndInfo(packageName, appName);
|
||||||
|
|
||||||
final int associationId = mAssociations.size() + 1;
|
final int associationId = mAssociations.size() + 1;
|
||||||
final DeviceId deviceId =
|
|
||||||
new DeviceId(DeviceId.TYPE_MAC_ADDRESS, mCachedDevice.getAddress());
|
|
||||||
final AssociationInfo association = new AssociationInfo(
|
final AssociationInfo association = new AssociationInfo(
|
||||||
associationId,
|
associationId,
|
||||||
/* userId */ 0,
|
/* userId */ 0,
|
||||||
packageName,
|
packageName,
|
||||||
Arrays.asList(deviceId),
|
MacAddress.fromString(mCachedDevice.getAddress()),
|
||||||
|
/* displayName */ null,
|
||||||
/* deviceProfile */ "",
|
/* deviceProfile */ "",
|
||||||
/* managedByCompanionApp */ false,
|
/* selfManaged */ false,
|
||||||
/* notifyOnDeviceNearby */ true,
|
/* notifyOnDeviceNearby */ true,
|
||||||
/* timeApprovedMs */ System.currentTimeMillis());
|
/* timeApprovedMs */ System.currentTimeMillis());
|
||||||
|
|
||||||
|
|||||||
@@ -31,11 +31,13 @@ import android.app.INotificationManager;
|
|||||||
import android.app.role.RoleManager;
|
import android.app.role.RoleManager;
|
||||||
import android.app.usage.UsageEvents;
|
import android.app.usage.UsageEvents;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
|
import android.companion.AssociationInfo;
|
||||||
import android.companion.ICompanionDeviceManager;
|
import android.companion.ICompanionDeviceManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.net.MacAddress;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
@@ -234,8 +236,9 @@ public class NotificationBackendTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getDeviceList_associationsButNoDevice() throws Exception {
|
public void getDeviceList_associationsButNoDevice() throws Exception {
|
||||||
List<String> macs = ImmutableList.of("00:00:00:00:00:10", "00:00:00:00:00:20");
|
List<AssociationInfo> associations =
|
||||||
when(mCdm.getAssociations(mCn.getPackageName(), 0)).thenReturn(macs);
|
mockAssociations("00:00:00:00:00:10", "00:00:00:00:00:20");
|
||||||
|
when(mCdm.getAssociations(mCn.getPackageName(), 0)).thenReturn(associations);
|
||||||
|
|
||||||
when(mCbm.getCachedDevicesCopy()).thenReturn(new ArrayList<>());
|
when(mCbm.getCachedDevicesCopy()).thenReturn(new ArrayList<>());
|
||||||
|
|
||||||
@@ -245,12 +248,13 @@ public class NotificationBackendTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getDeviceList_singleDevice() throws Exception {
|
public void getDeviceList_singleDevice() throws Exception {
|
||||||
List<String> macs = ImmutableList.of("00:00:00:00:00:10", "00:00:00:00:00:20");
|
String[] macs = { "00:00:00:00:00:10", "00:00:00:00:00:20" };
|
||||||
when(mCdm.getAssociations(mCn.getPackageName(), 0)).thenReturn(macs);
|
List<AssociationInfo> associations = mockAssociations(macs);
|
||||||
|
when(mCdm.getAssociations(mCn.getPackageName(), 0)).thenReturn(associations);
|
||||||
|
|
||||||
Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
||||||
CachedBluetoothDevice cbd1 = mock(CachedBluetoothDevice.class);
|
CachedBluetoothDevice cbd1 = mock(CachedBluetoothDevice.class);
|
||||||
when(cbd1.getAddress()).thenReturn(macs.get(0));
|
when(cbd1.getAddress()).thenReturn(macs[0]);
|
||||||
when(cbd1.getName()).thenReturn("Device 1");
|
when(cbd1.getName()).thenReturn("Device 1");
|
||||||
cachedDevices.add(cbd1);
|
cachedDevices.add(cbd1);
|
||||||
when(mCbm.getCachedDevicesCopy()).thenReturn(cachedDevices);
|
when(mCbm.getCachedDevicesCopy()).thenReturn(cachedDevices);
|
||||||
@@ -261,17 +265,18 @@ public class NotificationBackendTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getDeviceList_multipleDevices() throws Exception {
|
public void getDeviceList_multipleDevices() throws Exception {
|
||||||
List<String> macs = ImmutableList.of("00:00:00:00:00:10", "00:00:00:00:00:20");
|
String[] macs = { "00:00:00:00:00:10", "00:00:00:00:00:20" };
|
||||||
when(mCdm.getAssociations(mCn.getPackageName(), 0)).thenReturn(macs);
|
List<AssociationInfo> associations = mockAssociations(macs);
|
||||||
|
when(mCdm.getAssociations(mCn.getPackageName(), 0)).thenReturn(associations);
|
||||||
|
|
||||||
Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
|
||||||
CachedBluetoothDevice cbd1 = mock(CachedBluetoothDevice.class);
|
CachedBluetoothDevice cbd1 = mock(CachedBluetoothDevice.class);
|
||||||
when(cbd1.getAddress()).thenReturn(macs.get(0));
|
when(cbd1.getAddress()).thenReturn(macs[0]);
|
||||||
when(cbd1.getName()).thenReturn("Device 1");
|
when(cbd1.getName()).thenReturn("Device 1");
|
||||||
cachedDevices.add(cbd1);
|
cachedDevices.add(cbd1);
|
||||||
|
|
||||||
CachedBluetoothDevice cbd2 = mock(CachedBluetoothDevice.class);
|
CachedBluetoothDevice cbd2 = mock(CachedBluetoothDevice.class);
|
||||||
when(cbd2.getAddress()).thenReturn(macs.get(1));
|
when(cbd2.getAddress()).thenReturn(macs[1]);
|
||||||
when(cbd2.getName()).thenReturn("Device 2");
|
when(cbd2.getName()).thenReturn("Device 2");
|
||||||
cachedDevices.add(cbd2);
|
cachedDevices.add(cbd2);
|
||||||
when(mCbm.getCachedDevicesCopy()).thenReturn(cachedDevices);
|
when(mCbm.getCachedDevicesCopy()).thenReturn(cachedDevices);
|
||||||
@@ -279,4 +284,16 @@ public class NotificationBackendTest {
|
|||||||
assertThat(new NotificationBackend().getDeviceList(
|
assertThat(new NotificationBackend().getDeviceList(
|
||||||
mCdm, mBm, mCn.getPackageName(), 0).toString()).isEqualTo("Device 1, Device 2");
|
mCdm, mBm, mCn.getPackageName(), 0).toString()).isEqualTo("Device 1, Device 2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ImmutableList<AssociationInfo> mockAssociations(String... macAddresses) {
|
||||||
|
final AssociationInfo[] associations = new AssociationInfo[macAddresses.length];
|
||||||
|
for (int index = 0; index < macAddresses.length; index++) {
|
||||||
|
final AssociationInfo association = mock(AssociationInfo.class);
|
||||||
|
when(association.isSelfManaged()).thenReturn(false);
|
||||||
|
when(association.getDeviceMacAddress())
|
||||||
|
.thenReturn(MacAddress.fromString(macAddresses[index]));
|
||||||
|
associations[index] = association;
|
||||||
|
}
|
||||||
|
return ImmutableList.copyOf(associations);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class VibrateForCallsPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getSummary_applyRampingRinger_rampingRingerSummary() {
|
public void getSummary_applyRampingRinger_rampingRingerSummary() {
|
||||||
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
||||||
Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, ON);
|
Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, ON);
|
||||||
|
|
||||||
assertThat(mController.getSummary()).isEqualTo(
|
assertThat(mController.getSummary()).isEqualTo(
|
||||||
mContext.getText(R.string.vibrate_when_ringing_option_ramping_ringer));
|
mContext.getText(R.string.vibrate_when_ringing_option_ramping_ringer));
|
||||||
@@ -103,7 +103,7 @@ public class VibrateForCallsPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getSummary_enableVibrateWhenRinging_alwaysVibrateSummary() {
|
public void getSummary_enableVibrateWhenRinging_alwaysVibrateSummary() {
|
||||||
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, ON);
|
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, ON);
|
||||||
Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
|
Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF);
|
||||||
|
|
||||||
assertThat(mController.getSummary()).isEqualTo(
|
assertThat(mController.getSummary()).isEqualTo(
|
||||||
mContext.getText(R.string.vibrate_when_ringing_option_always_vibrate));
|
mContext.getText(R.string.vibrate_when_ringing_option_always_vibrate));
|
||||||
@@ -112,7 +112,7 @@ public class VibrateForCallsPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getSummary_notApplyRampingRingerDisableVibrateWhenRinging_neverVibrateSummary() {
|
public void getSummary_notApplyRampingRingerDisableVibrateWhenRinging_neverVibrateSummary() {
|
||||||
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
||||||
Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
|
Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF);
|
||||||
|
|
||||||
assertThat(mController.getSummary()).isEqualTo(
|
assertThat(mController.getSummary()).isEqualTo(
|
||||||
mContext.getText(R.string.vibrate_when_ringing_option_never_vibrate));
|
mContext.getText(R.string.vibrate_when_ringing_option_never_vibrate));
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class VibrateForCallsPreferenceFragmentTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getDefaultKey_applyRampingRinger_keyRampingRinger() {
|
public void getDefaultKey_applyRampingRinger_keyRampingRinger() {
|
||||||
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
||||||
Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, ON);
|
Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, ON);
|
||||||
|
|
||||||
assertThat(mFragment.getDefaultKey()).isEqualTo(
|
assertThat(mFragment.getDefaultKey()).isEqualTo(
|
||||||
VibrateForCallsPreferenceFragment.KEY_RAMPING_RINGER);
|
VibrateForCallsPreferenceFragment.KEY_RAMPING_RINGER);
|
||||||
@@ -61,7 +61,7 @@ public class VibrateForCallsPreferenceFragmentTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getDefaultKey_enableVibrateWhenRinging_keyAlwaysVibrate() {
|
public void getDefaultKey_enableVibrateWhenRinging_keyAlwaysVibrate() {
|
||||||
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, ON);
|
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, ON);
|
||||||
Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
|
Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF);
|
||||||
|
|
||||||
assertThat(mFragment.getDefaultKey()).isEqualTo(
|
assertThat(mFragment.getDefaultKey()).isEqualTo(
|
||||||
VibrateForCallsPreferenceFragment.KEY_ALWAYS_VIBRATE);
|
VibrateForCallsPreferenceFragment.KEY_ALWAYS_VIBRATE);
|
||||||
@@ -70,7 +70,7 @@ public class VibrateForCallsPreferenceFragmentTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getDefaultKey_notApplyRampingRingerDisableVibrateWhenRinging_keyNeverVibrate() {
|
public void getDefaultKey_notApplyRampingRingerDisableVibrateWhenRinging_keyNeverVibrate() {
|
||||||
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
||||||
Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
|
Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF);
|
||||||
|
|
||||||
assertThat(mFragment.getDefaultKey()).isEqualTo(
|
assertThat(mFragment.getDefaultKey()).isEqualTo(
|
||||||
VibrateForCallsPreferenceFragment.KEY_NEVER_VIBRATE);
|
VibrateForCallsPreferenceFragment.KEY_NEVER_VIBRATE);
|
||||||
@@ -80,8 +80,8 @@ public class VibrateForCallsPreferenceFragmentTest {
|
|||||||
public void setDefaultKey_keyRampingRinger_applyRampingRingerDisableVibrateWhenRinging() {
|
public void setDefaultKey_keyRampingRinger_applyRampingRingerDisableVibrateWhenRinging() {
|
||||||
mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_RAMPING_RINGER);
|
mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_RAMPING_RINGER);
|
||||||
|
|
||||||
assertThat(Settings.Global.getInt(
|
assertThat(Settings.System.getInt(
|
||||||
mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(ON);
|
mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF)).isEqualTo(ON);
|
||||||
assertThat(Settings.System.getInt(
|
assertThat(Settings.System.getInt(
|
||||||
mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(OFF);
|
mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(OFF);
|
||||||
}
|
}
|
||||||
@@ -90,8 +90,8 @@ public class VibrateForCallsPreferenceFragmentTest {
|
|||||||
public void setDefaultKey_keyAlwaysVibrate_notApplyRampingRingerEnableVibrateWhenRinging() {
|
public void setDefaultKey_keyAlwaysVibrate_notApplyRampingRingerEnableVibrateWhenRinging() {
|
||||||
mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_ALWAYS_VIBRATE);
|
mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_ALWAYS_VIBRATE);
|
||||||
|
|
||||||
assertThat(Settings.Global.getInt(
|
assertThat(Settings.System.getInt(
|
||||||
mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF);
|
mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF);
|
||||||
assertThat(Settings.System.getInt(
|
assertThat(Settings.System.getInt(
|
||||||
mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(ON);
|
mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(ON);
|
||||||
}
|
}
|
||||||
@@ -100,8 +100,8 @@ public class VibrateForCallsPreferenceFragmentTest {
|
|||||||
public void setDefaultKey_keyNeverVibrate_notApplyRampingRingerDisableVibrateWhenRinging() {
|
public void setDefaultKey_keyNeverVibrate_notApplyRampingRingerDisableVibrateWhenRinging() {
|
||||||
mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_NEVER_VIBRATE);
|
mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_NEVER_VIBRATE);
|
||||||
|
|
||||||
assertThat(Settings.Global.getInt(
|
assertThat(Settings.System.getInt(
|
||||||
mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF);
|
mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF);
|
||||||
assertThat(Settings.System.getInt(
|
assertThat(Settings.System.getInt(
|
||||||
mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(OFF);
|
mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(OFF);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user