Snap for 5273885 from dbd48da49a to qt-release
Change-Id: Ib5c8333f7c9ad5ffa3e319d5fc441abe97feaffc
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
-keep public class com.android.settings.** extends androidx.fragment.app.Fragment
|
||||
|
||||
# Keep all preference controllers needed by slice and DashboardFragment.
|
||||
-keep class * extends com.android.settings.core.BasePreferenceController {
|
||||
-keep class !com.google.android.settings.aware.*, * extends com.android.settings.core.BasePreferenceController {
|
||||
*;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ message ContextualCard {
|
||||
SUGGESTION = 1;
|
||||
POSSIBLE = 2;
|
||||
IMPORTANT = 3;
|
||||
EXCLUSIVE = 4;
|
||||
EXCLUSIVE = 4 [deprecated = true];
|
||||
DEFERRED_SETUP = 5;
|
||||
}
|
||||
|
||||
|
||||
@@ -182,6 +182,14 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/cbrs_data_switch_string" />
|
||||
|
||||
<!-- Switch between SSSS(single sim single standby) and DSDS(dual sim dual standby). -->
|
||||
<Switch android:id="@+id/dsds_switch"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/dsds_switch_string" />
|
||||
|
||||
<!-- Horizontal Rule -->
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
|
||||
@@ -66,6 +66,21 @@
|
||||
<!-- Cbrs enable disable flag. Only shown in diagnostic screen, so precise translation is not needed -->
|
||||
<string name="cbrs_data_switch_string">Cbrs Data</string>
|
||||
|
||||
<!-- Dsds enable/disable flag. Only shown in diagnostic screen, so precise translation is not needed, [CHAR LIMIT=none] -->
|
||||
<string name="dsds_switch_string">Enable DSDS</string>
|
||||
|
||||
<!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
|
||||
<string name="dsds_dialog_title">Restart Device?</string>
|
||||
|
||||
<!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
|
||||
<string name="dsds_dialog_message">You need to restart your device to change this setting.</string>
|
||||
|
||||
<!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
|
||||
<string name="dsds_dialog_confirm">Restart</string>
|
||||
|
||||
<!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
|
||||
<string name="dsds_dialog_cancel">Cancel</string>
|
||||
|
||||
<!-- Title for controlling on/off for Mobile phone's radio power. Only shown in diagnostic screen, so precise translation is not needed. -->
|
||||
<string name="radio_info_radio_power">Mobile Radio Power</string>
|
||||
|
||||
@@ -9590,8 +9605,8 @@
|
||||
<item quantity="other"><xliff:g id="count" example="10">%d</xliff:g> apps can use unrestricted data</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Title for the More preference item in Special app access settings [CHAR LIMIT=30] -->
|
||||
<string name="special_access_more">More</string>
|
||||
<!-- Title for the See more preference item in Special app access settings [CHAR LIMIT=30] -->
|
||||
<string name="special_access_more">See more</string>
|
||||
|
||||
<!-- Developer option to convert to file encryption - final warning -->
|
||||
<string name="confirm_convert_to_fbe_warning">Really wipe user data and convert to file encryption?</string>
|
||||
@@ -9775,11 +9790,6 @@
|
||||
<!-- Summary text for ambient display (device) [CHAR LIMIT=NONE]-->
|
||||
<string name="ambient_display_pickup_summary" product="device">To check time, notifications, and other info, pick up your device.</string>
|
||||
|
||||
<!-- Preference and settings suggestion title text for gesture that shows the lock screen [CHAR LIMIT=60]-->
|
||||
<string name="ambient_display_wake_lock_screen_title">Wake lock screen gesture</string>
|
||||
<!-- Summary text for ambient display [CHAR LIMIT=NONE]-->
|
||||
<string name="ambient_display_wake_lock_screen_summary" product="default"></string>
|
||||
|
||||
<!-- Preference and settings suggestion title text for ambient display tap (phone) [CHAR LIMIT=60]-->
|
||||
<string name="ambient_display_tap_screen_title" product="default">Tap to check phone</string>
|
||||
<!-- Preference and settings suggestion title text for ambient display tap (tablet) [CHAR LIMIT=60]-->
|
||||
@@ -10553,7 +10563,7 @@
|
||||
<!-- Title for the top level Privacy Settings [CHAR LIMIT=30]-->
|
||||
<string name="privacy_dashboard_title">Privacy</string>
|
||||
<!-- Summary for the top level Privacy Settings [CHAR LIMIT=NONE]-->
|
||||
<string name="privacy_dashboard_summary">Permissions, activity controls, data shown on screen</string>
|
||||
<string name="privacy_dashboard_summary">Permissions, web activity, personal data</string>
|
||||
|
||||
<!-- Label for button in contextual card for users to remove the card [CHAR LIMIT=30] -->
|
||||
<string name="contextual_card_dismiss_remove">Remove</string>
|
||||
|
||||
@@ -33,12 +33,6 @@
|
||||
android:fragment="com.android.settings.gestures.WakeScreenGestureSettings"
|
||||
settings:controller="com.android.settings.gestures.WakeScreenGesturePreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="gesture_wake_lock_screen_summary"
|
||||
android:title="@string/ambient_display_wake_lock_screen_title"
|
||||
android:fragment="com.android.settings.gestures.WakeLockScreenGestureSettings"
|
||||
settings:controller="com.android.settings.gestures.WakeLockScreenGesturePreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="gesture_swipe_down_fingerprint_input_summary"
|
||||
android:title="@string/fingerprint_swipe_for_notifications_title"
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2018 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:key="gesture_wake_lock_screen_screen"
|
||||
android:title="@string/ambient_display_wake_lock_screen_title">
|
||||
|
||||
<com.android.settings.widget.VideoPreference
|
||||
android:key="gesture_wake_lock_screen_video"
|
||||
app:animation="@raw/gesture_ambient_wake_lock_screen"
|
||||
app:preview="@drawable/gesture_ambient_wake_lock_screen" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="gesture_wake_lock_screen"
|
||||
android:title="@string/ambient_display_wake_lock_screen_title"
|
||||
android:summary="@string/ambient_display_wake_lock_screen_summary"
|
||||
app:keywords="@string/keywords_gesture"
|
||||
app:controller="com.android.settings.gestures.WakeLockScreenGesturePreferenceController"
|
||||
app:allowDividerAbove="true" />
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -23,6 +23,7 @@ import android.app.Activity;
|
||||
import android.app.QueuedWork;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
@@ -40,6 +41,7 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Telephony;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.CellIdentityCdma;
|
||||
import android.telephony.CellIdentityGsm;
|
||||
@@ -81,11 +83,13 @@ import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AlertDialog.Builder;
|
||||
|
||||
import com.android.ims.ImsConfig;
|
||||
import com.android.ims.ImsException;
|
||||
import com.android.ims.ImsManager;
|
||||
import com.android.internal.telephony.Phone;
|
||||
import com.android.internal.telephony.PhoneConfigurationManager;
|
||||
import com.android.internal.telephony.PhoneFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -93,6 +97,7 @@ import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
// TODO(b/123598192) consider to move this activity to telephony package.
|
||||
public class RadioInfo extends Activity {
|
||||
private static final String TAG = "RadioInfo";
|
||||
|
||||
@@ -214,6 +219,7 @@ public class RadioInfo extends Activity {
|
||||
private Switch imsWfcProvisionedSwitch;
|
||||
private Switch eabProvisionedSwitch;
|
||||
private Switch cbrsDataSwitch;
|
||||
private Switch dsdsSwitch;
|
||||
private Spinner preferredNetworkType;
|
||||
private Spinner cellInfoRefreshRateSpinner;
|
||||
|
||||
@@ -454,6 +460,23 @@ public class RadioInfo extends Activity {
|
||||
cbrsDataSwitch = (Switch) findViewById(R.id.cbrs_data_switch);
|
||||
cbrsDataSwitch.setVisibility(isCbrsSupported() ? View.VISIBLE : View.GONE);
|
||||
|
||||
dsdsSwitch = findViewById(R.id.dsds_switch);
|
||||
if (isDsdsSupported()) {
|
||||
dsdsSwitch.setVisibility(View.VISIBLE);
|
||||
dsdsSwitch.setOnClickListener(v -> {
|
||||
if (mTelephonyManager.isRebootRequiredForModemConfigChange()) {
|
||||
// Undo the click action until user clicks the confirm dialog.
|
||||
dsdsSwitch.toggle();
|
||||
showDsdsChangeDialog();
|
||||
} else {
|
||||
performDsdsSwitch();
|
||||
}
|
||||
});
|
||||
dsdsSwitch.setChecked(isDsdsEnabled());
|
||||
} else {
|
||||
dsdsSwitch.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
|
||||
|
||||
mDownlinkKbps = (TextView) findViewById(R.id.dl_kbps);
|
||||
@@ -1525,5 +1548,38 @@ public class RadioInfo extends Activity {
|
||||
}
|
||||
};
|
||||
|
||||
private void showDsdsChangeDialog() {
|
||||
final AlertDialog confirmDialog = new Builder(RadioInfo.this)
|
||||
.setTitle(R.string.dsds_dialog_title)
|
||||
.setMessage(R.string.dsds_dialog_message)
|
||||
.setPositiveButton(R.string.dsds_dialog_confirm, mOnDsdsDialogConfirmedListener)
|
||||
.setNegativeButton(R.string.dsds_dialog_cancel, mOnDsdsDialogConfirmedListener)
|
||||
.create();
|
||||
confirmDialog.show();
|
||||
}
|
||||
|
||||
private static boolean isDsdsSupported() {
|
||||
return PhoneConfigurationManager.getInstance().getStaticPhoneCapability()
|
||||
.logicalModemList.size() >= 2
|
||||
&& !TelephonyManager.getDefault().isMultisimCarrierRestricted();
|
||||
}
|
||||
|
||||
private static boolean isDsdsEnabled() {
|
||||
return TelephonyManager.getDefault().getPhoneCount() > 1;
|
||||
}
|
||||
|
||||
private void performDsdsSwitch() {
|
||||
mTelephonyManager.switchMultiSimConfig(dsdsSwitch.isChecked() ? 2 : 1);
|
||||
}
|
||||
|
||||
DialogInterface.OnClickListener mOnDsdsDialogConfirmedListener =
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||
dsdsSwitch.toggle();
|
||||
performDsdsSwitch();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -28,4 +28,5 @@ public class FeatureFlags {
|
||||
public static final String NETWORK_INTERNET_V2 = "settings_network_and_internet_v2";
|
||||
public static final String WIFI_SHARING = "settings_wifi_sharing";
|
||||
public static final String SLICE_INJECTION = "settings_slice_injection";
|
||||
public static final String MAINLINE_MODULE = "settings_mainline_module";
|
||||
}
|
||||
|
||||
@@ -19,9 +19,11 @@ package com.android.settings.deviceinfo.firmwareversion;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
@@ -48,6 +50,11 @@ public class ModuleVersionDialogController {
|
||||
* Updates the mainline module version field of the dialog.
|
||||
*/
|
||||
public void initialize() {
|
||||
if (!FeatureFlagUtils.isEnabled(mContext, FeatureFlags.MAINLINE_MODULE)) {
|
||||
mDialog.removeSettingFromScreen(MODULE_VERSION_LABEL_ID);
|
||||
mDialog.removeSettingFromScreen(MODULE_VERSION_VALUE_ID);
|
||||
return;
|
||||
}
|
||||
final String moduleProvider = mContext.getString(
|
||||
com.android.internal.R.string.config_defaultModuleMetadataProvider);
|
||||
if (!TextUtils.isEmpty(moduleProvider)) {
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.gestures;
|
||||
|
||||
import static android.provider.Settings.Secure.DOZE_WAKE_LOCK_SCREEN_GESTURE;
|
||||
|
||||
import android.annotation.UserIdInt;
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
|
||||
public class WakeLockScreenGesturePreferenceController extends GesturePreferenceController {
|
||||
|
||||
private static final int ON = 1;
|
||||
private static final int OFF = 0;
|
||||
|
||||
private static final String PREF_KEY_VIDEO = "gesture_wake_lock_screen_video";
|
||||
private final String mWakeLockScreenPrefKey;
|
||||
|
||||
private AmbientDisplayConfiguration mAmbientConfig;
|
||||
@UserIdInt
|
||||
private final int mUserId;
|
||||
|
||||
public WakeLockScreenGesturePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mUserId = UserHandle.myUserId();
|
||||
mWakeLockScreenPrefKey = key;
|
||||
}
|
||||
|
||||
public WakeLockScreenGesturePreferenceController
|
||||
setConfig(AmbientDisplayConfiguration config) {
|
||||
mAmbientConfig = config;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
// No hardware support for this Gesture
|
||||
if (!getAmbientConfig().wakeScreenGestureAvailable()) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSliceable() {
|
||||
return TextUtils.equals(getPreferenceKey(), "gesture_wake_lock_screen");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getVideoPrefKey() {
|
||||
return PREF_KEY_VIDEO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return getAmbientConfig().wakeLockScreenGestureEnabled(mUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return mWakeLockScreenPrefKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
return Settings.Secure.putInt(mContext.getContentResolver(), DOZE_WAKE_LOCK_SCREEN_GESTURE,
|
||||
isChecked ? ON : OFF);
|
||||
}
|
||||
|
||||
private AmbientDisplayConfiguration getAmbientConfig() {
|
||||
if (mAmbientConfig == null) {
|
||||
mAmbientConfig = new AmbientDisplayConfiguration(mContext);
|
||||
}
|
||||
|
||||
return mAmbientConfig;
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.gestures;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class WakeLockScreenGestureSettings extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "WakeLockScreenGestureSettings";
|
||||
|
||||
public static final String PREF_KEY_SUGGESTION_COMPLETE =
|
||||
"pref_wake_lock_screen_gesture_suggestion_complete";
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
SuggestionFeatureProvider suggestionFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getSuggestionFeatureProvider(context);
|
||||
SharedPreferences prefs = suggestionFeatureProvider.getSharedPrefs(context);
|
||||
prefs.edit().putBoolean(PREF_KEY_SUGGESTION_COMPLETE, true).apply();
|
||||
|
||||
use(WakeLockScreenGesturePreferenceController.class)
|
||||
.setConfig(new AmbientDisplayConfiguration(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.SETTINGS_GESTURE_WAKE_LOCK_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.wake_lock_screen_gesture_settings;
|
||||
}
|
||||
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
||||
Context context, boolean enabled) {
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.wake_lock_screen_gesture_settings;
|
||||
return Arrays.asList(sir);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -26,6 +26,8 @@ import android.text.TextUtils;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.settings.aware.AwareFeatureProvider;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
public class WakeScreenGesturePreferenceController extends GesturePreferenceController {
|
||||
|
||||
@@ -34,6 +36,7 @@ public class WakeScreenGesturePreferenceController extends GesturePreferenceCont
|
||||
|
||||
private static final String PREF_KEY_VIDEO = "gesture_wake_screen_video";
|
||||
|
||||
private final AwareFeatureProvider mFeatureProvider;
|
||||
private AmbientDisplayConfiguration mAmbientConfig;
|
||||
@UserIdInt
|
||||
private final int mUserId;
|
||||
@@ -41,16 +44,16 @@ public class WakeScreenGesturePreferenceController extends GesturePreferenceCont
|
||||
public WakeScreenGesturePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mUserId = UserHandle.myUserId();
|
||||
mFeatureProvider = FeatureFactory.getFactory(context).getAwareFeatureProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
// No hardware support for Wake Screen Gesture
|
||||
if (!getAmbientConfig().wakeScreenGestureAvailable()) {
|
||||
if (!getAmbientConfig().wakeScreenGestureAvailable()
|
||||
|| !mFeatureProvider.isSupported(mContext)) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
return AVAILABLE;
|
||||
return mFeatureProvider.isEnabled(mContext) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.content.Context;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
@@ -62,7 +63,11 @@ public class VibrateWhenRingPreferenceController extends TogglePreferenceControl
|
||||
@Override
|
||||
@AvailabilityStatus
|
||||
public int getAvailabilityStatus() {
|
||||
return Utils.isVoiceCapable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
// If ramping ringer is enabled then this setting will be injected
|
||||
// with additional options.
|
||||
return Utils.isVoiceCapable(mContext) && !isRampingRingerEnabled()
|
||||
? AVAILABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,4 +128,19 @@ public class VibrateWhenRingPreferenceController extends TogglePreferenceControl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isRampingRingerEnabled() {
|
||||
String enableRampingRinger = DeviceConfig.getProperty(
|
||||
DeviceConfig.Telephony.NAMESPACE,
|
||||
DeviceConfig.Telephony.RAMPING_RINGER_ENABLED);
|
||||
if (enableRampingRinger == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return Boolean.valueOf(enableRampingRinger);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ import static org.mockito.Mockito.when;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -52,6 +55,17 @@ public class ModuleVersionDialogControllerTest {
|
||||
when(mDialog.getContext()).thenReturn(mContext);
|
||||
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||
mController = new ModuleVersionDialogController(mDialog);
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.MAINLINE_MODULE, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initialize_featureDisabled_shouldRemoveSettingFromDialog() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.MAINLINE_MODULE, false);
|
||||
|
||||
mController.initialize();
|
||||
|
||||
verify(mDialog).removeSettingFromScreen(mController.MODULE_VERSION_LABEL_ID);
|
||||
verify(mDialog).removeSettingFromScreen(mController.MODULE_VERSION_VALUE_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.gestures;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class WakeLockScreenGesturePreferenceControllerTest {
|
||||
|
||||
private static final String KEY_WAKE_LOCK_SCREEN = "gesture_wake_lock_screen";
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private AmbientDisplayConfiguration mAmbientDisplayConfiguration;
|
||||
|
||||
private WakeLockScreenGesturePreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mController = new WakeLockScreenGesturePreferenceController(mContext, KEY_WAKE_LOCK_SCREEN);
|
||||
mController.setConfig(mAmbientDisplayConfiguration);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChecked_configIsSet_shouldReturnTrue() {
|
||||
// Set the setting to be enabled.
|
||||
when(mAmbientDisplayConfiguration.wakeLockScreenGestureEnabled(anyInt())).thenReturn(true);
|
||||
assertThat(mController.isChecked()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChecked_configIsNotSet_shouldReturnFalse() {
|
||||
// Set the setting to be disabled.
|
||||
when(mAmbientDisplayConfiguration.wakeLockScreenGestureEnabled(anyInt())).thenReturn(false);
|
||||
assertThat(mController.isChecked()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_gestureNotSupported_UNSUPPORTED_ON_DEVICE() {
|
||||
when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(false);
|
||||
final int availabilityStatus = mController.getAvailabilityStatus();
|
||||
|
||||
assertThat(availabilityStatus).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_gestureSupported_AVAILABLE() {
|
||||
when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(true);
|
||||
final int availabilityStatus = mController.getAvailabilityStatus();
|
||||
|
||||
assertThat(availabilityStatus).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSliceableCorrectKey_returnsTrue() {
|
||||
final WakeLockScreenGesturePreferenceController controller =
|
||||
new WakeLockScreenGesturePreferenceController(mContext, KEY_WAKE_LOCK_SCREEN);
|
||||
assertThat(controller.isSliceable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSliceableIncorrectKey_returnsFalse() {
|
||||
final WakeLockScreenGesturePreferenceController controller =
|
||||
new WakeLockScreenGesturePreferenceController(mContext, "bad_key");
|
||||
assertThat(controller.isSliceable()).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.gestures;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class WakeLockScreenGestureSettingsTest {
|
||||
|
||||
private WakeLockScreenGestureSettings mSettings;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mSettings = new WakeLockScreenGestureSettings();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchIndexProvider_shouldIndexResource() {
|
||||
final List<SearchIndexableResource> indexRes =
|
||||
WakeLockScreenGestureSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
|
||||
RuntimeEnvironment.application, true /* enabled */);
|
||||
|
||||
assertThat(indexRes).isNotNull();
|
||||
assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId());
|
||||
}
|
||||
}
|
||||
@@ -21,12 +21,15 @@ import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.settings.aware.AwareFeatureProvider;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -45,12 +48,15 @@ public class WakeScreenGesturePreferenceControllerTest {
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private AmbientDisplayConfiguration mAmbientDisplayConfiguration;
|
||||
|
||||
private WakeScreenGesturePreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
AwareFeatureProvider featureProvider =
|
||||
FakeFeatureFactory.setupForTest().getAwareFeatureProvider();
|
||||
when(featureProvider.isSupported(any())).thenReturn(true);
|
||||
when(featureProvider.isEnabled(any())).thenReturn(true);
|
||||
mController = new WakeScreenGesturePreferenceController(mContext, KEY_WAKE_SCREEN);
|
||||
mController.setConfig(mAmbientDisplayConfiguration);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.preference.SeekBarVolumizer;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
import com.android.settings.testutils.shadow.ShadowAudioHelper;
|
||||
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
|
||||
import com.android.settings.testutils.shadow.ShadowUserManager;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -47,7 +48,7 @@ import java.util.List;
|
||||
public class SoundSettingsTest {
|
||||
|
||||
@Test
|
||||
@Config(shadows = {ShadowUserManager.class, ShadowAudioHelper.class})
|
||||
@Config(shadows = {ShadowUserManager.class, ShadowAudioHelper.class, ShadowDeviceConfig.class})
|
||||
public void getNonIndexableKeys_existInXmlLayout() {
|
||||
final Context context = spy(RuntimeEnvironment.application);
|
||||
AudioManager audioManager = mock(AudioManager.class);
|
||||
|
||||
@@ -29,6 +29,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
@@ -36,17 +37,21 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.TwoStatePreference;
|
||||
|
||||
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.shadow.api.Shadow;
|
||||
import org.robolectric.shadows.ShadowContentResolver;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows={ShadowDeviceConfig.class})
|
||||
public class VibrateWhenRingPreferenceControllerTest {
|
||||
|
||||
private static final String KEY_VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
|
||||
@@ -74,20 +79,42 @@ public class VibrateWhenRingPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void display_voiceCapable_shouldDisplay() {
|
||||
public void display_shouldDisplay() {
|
||||
when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
|
||||
|
||||
DeviceConfig.setProperty("namespace", "key", "false", false);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
assertThat(mPreference.isVisible()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void display_notVoiceCapable_shouldNotDisplay() {
|
||||
public void display_shouldNotDisplay_notVoiceCapable() {
|
||||
when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
|
||||
|
||||
DeviceConfig.setProperty("namespace", "key", "false", false);
|
||||
mController.displayPreference(mScreen);
|
||||
assertThat(mPreference.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void display_shouldNotDisplay_RampingRingerEnabled() {
|
||||
when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
|
||||
DeviceConfig.setProperty("namespace", "key", "true", false);
|
||||
mController.displayPreference(mScreen);
|
||||
assertThat(mPreference.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void display_shouldNotDisplay_VoiceEnabled_RampingRingerEnabled() {
|
||||
when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
|
||||
DeviceConfig.setProperty("namespace", "key", "true", false);
|
||||
mController.displayPreference(mScreen);
|
||||
assertThat(mPreference.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void display_shouldNotDisplay_VoiceDisabled_RampingRingerEnabled() {
|
||||
when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
|
||||
DeviceConfig.setProperty("namespace", "key", "true", false);
|
||||
mController.displayPreference(mScreen);
|
||||
assertThat(mPreference.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@@ -112,14 +139,14 @@ public class VibrateWhenRingPreferenceControllerTest {
|
||||
@Test
|
||||
public void voiceCapable_availabled() {
|
||||
when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
|
||||
|
||||
DeviceConfig.setProperty("namespace", "key", "false", false);
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void voiceCapable_notAvailabled() {
|
||||
when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
|
||||
|
||||
DeviceConfig.setProperty("namespace", "key", "false", false);
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@@ -197,4 +224,5 @@ public class VibrateWhenRingPreferenceControllerTest {
|
||||
new VibrateWhenRingPreferenceController(mContext, "bad_key");
|
||||
assertThat(controller.isSliceable()).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.testutils.shadow;
|
||||
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
|
||||
@Implements(android.provider.DeviceConfig.class)
|
||||
public class ShadowDeviceConfig {
|
||||
|
||||
private static String configValue;
|
||||
|
||||
@Implementation
|
||||
protected static boolean setProperty(
|
||||
String namespace, String name, String value, boolean makeDefault) {
|
||||
configValue = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Implementation
|
||||
protected static String getProperty(String ns, String key) { return configValue; }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user