Snap for 8016676 from e2f4baed0b to tm-release

Change-Id: Ief830a6a45256d5089b1e2ca9e7caef1c394eddd
This commit is contained in:
Android Build Coastguard Worker
2021-12-21 02:09:06 +00:00
21 changed files with 157 additions and 494 deletions

View File

@@ -112,6 +112,7 @@
<uses-permission android:name="android.permission.ALLOW_PLACE_IN_MULTI_PANE_SETTINGS" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_APP_SPECIFIC_LOCALES" />
<uses-permission android:name="android.permission.QUERY_ADMIN_POLICY" />
<application
android:name=".SettingsApplication"
@@ -238,17 +239,14 @@
android:value="true" />
</activity>
<activity android:name=".network.telephony.MobileNetworkActivity"
android:label="@string/network_settings_title"
android:exported="true"
android:taskAffinity="com.android.settings.root"
android:launchMode="singleTask"
android:configChanges="orientation|screenSize|keyboardHidden">
<!-- Note: Since the framework does not support the multiple requests of network scan
from the UI, this singleTask can protect that there is only one
Settings$NetworkSelectActivity which can request the network scan.
If removing the "singleTask" in the future, please also modify the
Settings$NetworkSelectActivity's structure. -->
<activity
android:name=".Settings$MobileNetworkActivity"
android:label="@string/network_settings_title"
android:configChanges="orientation|screenSize|keyboardHidden"
android:launchMode="singleInstance"
android:exported="true">
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.network.telephony.MobileNetworkSettings"/>
<intent-filter android:priority="1">
<!-- Displays the MobileNetworkActivity and opt-in dialog for capability discovery. -->
<action android:name="android.telephony.ims.action.SHOW_CAPABILITY_DISCOVERY_OPT_IN" />
@@ -259,14 +257,6 @@
</intent-filter>
</activity>
<activity
android:name=".Settings$SubscriptionSettingsActivity"
android:label="@string/network_settings_title"
android:exported="false">
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.network.telephony.MobileNetworkSettings"/>
</activity>
<activity android:name=".Settings$MobileNetworkListActivity"
android:exported="true"
android:label="@string/network_settings_title">
@@ -549,7 +539,6 @@
<activity android:name="Settings$ApnSettingsActivity"
android:label="@string/apn_settings"
android:launchMode="singleTask"
android:exported="true"
android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter android:priority="1">

View File

@@ -5553,11 +5553,17 @@
<!-- Description for the seekbar that adjust auto click time. [CHAR_LIMIT=NONE] -->
<string name="accessibility_autoclick_seekbar_desc">Auto click time</string>
<!-- Title for accessibility preference screen for configuring vibrations. -->
<string name="accessibility_vibration_settings_title">Vibration &amp; haptic strength</string>
<!-- Title for accessibility preference for configuring notification vibrations. -->
<string name="accessibility_notification_vibration_title">Notification vibration</string>
<string name="accessibility_vibration_settings_title">Vibration &amp; haptics</string>
<!-- 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>
<!-- Title for the category of preferences to configure device vibrations related to notifications and alarms. [CHAR LIMIT=NONE] -->
<string name="accessibility_notification_alarm_vibration_category_title">Notifications and alarms</string>
<!-- Title for the category of preferences to configure device vibrations triggered by user interaction with the device. [CHAR LIMIT=NONE] -->
<string name="accessibility_interactive_haptics_category_title">Interactive haptics</string>
<!-- Title for accessibility preference for configuring ring vibrations. [CHAR LIMIT=NONE] -->
<string name="accessibility_ring_vibration_title">Ring vibration</string>
<!-- Title for accessibility preference for configuring notification vibrations. -->
<string name="accessibility_notification_vibration_title">Notification vibration</string>
<!-- Title for accessibility preference for configuring touch feedback vibrations. -->
<string name="accessibility_touch_vibration_title">Touch feedback</string>
<!-- Used in the accessibility service settings to control turning on/off the service entirely [CHAR LIMIT=60] -->
@@ -8269,8 +8275,6 @@
<string name="keywords_wifi_notify_open_networks">Wi\u2011Fi notification, wifi notification</string>
<!-- Search keyword for "Wi-fi data usage" settings. [CHAR_LIMIT=NONE]-->
<string name="keywords_wifi_data_usage">data usage</string>
<!-- Search keyword for "Vibrate on touch" settings. [CHAR_LIMIT=NONE]-->
<string name="keywords_vibrate_on_touch">Stop vibration, tap, keyboard</string>
<!-- Search keyword for "Time format" settings. [CHAR_LIMIT=NONE]-->
<string name="keywords_time_format">Use 24-hour format</string>
<!-- Search keyword for "Files" settings under Settings > Storage. [CHAR_LIMIT=NONE]-->
@@ -8406,11 +8410,12 @@
<!-- List of synonyms for touch vibration setting (where you get a haptic response for touching things on the screen), used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_touch_vibration">haptics, vibrate, screen, sensitivity</string>
<!-- List of synonyms for ring vibration setting (changes whether your phone vibrates when it rings), used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_ring_vibration">haptics, vibrate, phone, call, sensitivity, ring</string>
<!-- List of synonyms for notification vibration setting (changes whether your phone vibrates when it shows a notification), used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_notification_vibration">haptics, vibrate, sensitivity</string>
<!-- List of synonyms for vibration and haptics setting, used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_vibration">haptics, vibrate, vibration</string>
<!-- Battery Saver: Search terms for sticky battery saver preference [CHAR_LIMIT=NONE] -->
<string name="keywords_battery_saver_sticky">battery saver, sticky, persist, power saver, battery</string>
<!-- Battery Saver: Search terms for battery saver schedule preference. Feel free to add additional terms when translating if appropriate [CHAR_LIMIT=NONE] -->
@@ -8522,12 +8527,6 @@
<!-- Sound: Other sounds: Title for the option enabling touch sounds. [CHAR LIMIT=30] -->
<string name="touch_sounds_title">Touch sounds</string>
<!-- Sound: Other sounds: Title for the option enabling haptic feedback on touch. [CHAR LIMIT=30] -->
<string name="vibrate_on_touch_title">Touch vibration</string>
<!-- Sound: Other sounds: Preference summary to the option enabling haptic feedback on touch. -->
<string name="vibrate_on_touch_summary">Haptic feedback for tap, keyboard, and more</string>
<!-- Sound: Other sounds: Title for the option enabling dock audio media. [CHAR LIMIT=50] -->
<string name="dock_audio_media_title">Dock speaker plays</string>

View File

@@ -100,7 +100,8 @@
android:icon="@drawable/ic_vibration"
android:persistent="false"
android:title="@string/accessibility_vibration_settings_title"
settings:controller="com.android.settings.accessibility.VibrationPreferenceController"/>
settings:controller="com.android.settings.accessibility.VibrationPreferenceController"
settings:keywords="@string/keywords_vibration"/>
</PreferenceCategory>

View File

@@ -20,24 +20,49 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/accessibility_vibration_settings_title">
<Preference
android:fragment="com.android.settings.accessibility.RingVibrationPreferenceFragment"
android:key="ring_vibration_preference_screen"
android:title="@string/accessibility_ring_vibration_title"
settings:keywords="@string/keywords_ring_vibration"
app:controller="com.android.settings.accessibility.RingVibrationIntensityPreferenceController" />
<PreferenceCategory
android:key="accessibility_call_vibration_category"
android:title="@string/accessibility_call_vibration_category_title">
<Preference
android:fragment="com.android.settings.accessibility.NotificationVibrationPreferenceFragment"
android:key="notification_vibration_preference_screen"
android:title="@string/accessibility_notification_vibration_title"
settings:keywords="@string/keywords_notification_vibration"
app:controller="com.android.settings.accessibility.NotificationVibrationIntensityPreferenceController" />
<Preference
android:fragment="com.android.settings.accessibility.RingVibrationPreferenceFragment"
android:key="ring_vibration_preference_screen"
android:title="@string/accessibility_ring_vibration_title"
settings:keywords="@string/keywords_ring_vibration"
app:controller="com.android.settings.accessibility.RingVibrationIntensityPreferenceController" />
<Preference
android:fragment="com.android.settings.sound.VibrateForCallsPreferenceFragment"
android:key="vibrate_for_calls"
android:title="@string/vibrate_when_ringing_title"
settings:controller="com.android.settings.sound.VibrateForCallsPreferenceController"/>
</PreferenceCategory>
<PreferenceCategory
android:key="accessibility_notification_alarm_vibration_category"
android:title="@string/accessibility_notification_alarm_vibration_category_title">
<Preference
android:fragment="com.android.settings.accessibility.NotificationVibrationPreferenceFragment"
android:key="notification_vibration_preference_screen"
android:title="@string/accessibility_notification_vibration_title"
settings:keywords="@string/keywords_notification_vibration"
app:controller="com.android.settings.accessibility.NotificationVibrationIntensityPreferenceController" />
</PreferenceCategory>
<PreferenceCategory
android:key="accessibility_interactive_haptics_category"
android:title="@string/accessibility_interactive_haptics_category_title">
<Preference
android:fragment="com.android.settings.accessibility.TouchVibrationPreferenceFragment"
android:key="touch_vibration_preference_screen"
android:title="@string/accessibility_touch_vibration_title"
settings:keywords="@string/keywords_touch_vibration"
app:controller="com.android.settings.accessibility.HapticFeedbackIntensityPreferenceController" />
</PreferenceCategory>
<Preference
android:fragment="com.android.settings.accessibility.TouchVibrationPreferenceFragment"
android:key="touch_vibration_preference_screen"
android:title="@string/accessibility_touch_vibration_title"
settings:keywords="@string/keywords_touch_vibration"
app:controller="com.android.settings.accessibility.HapticFeedbackIntensityPreferenceController" />
</PreferenceScreen>

View File

@@ -44,12 +44,6 @@
android:key="touch_sounds"
android:title="@string/touch_sounds_title" />
<!-- Vibrate on touch -->
<SwitchPreference
android:key="vibrate_on_touch"
android:title="@string/vibrate_on_touch_title"
android:summary="@string/vibrate_on_touch_summary" />
<!-- Dock speaker plays -->
<DropDownPreference
android:key="dock_audio_media"

View File

@@ -119,14 +119,14 @@
settings:controller="com.android.settings.sound.MediaControlsParentPreferenceController"
settings:keywords="@string/keywords_media_controls"/>
<!-- Also vibrate for calls -->
<!-- Also vibration -->
<Preference
android:fragment="com.android.settings.sound.VibrateForCallsPreferenceFragment"
android:key="vibrate_for_calls"
android:title="@string/vibrate_when_ringing_title"
android:fragment="com.android.settings.accessibility.VibrationSettings"
android:key="vibration_and_haptics"
android:title="@string/accessibility_vibration_settings_title"
android:order="-90"
settings:controller="com.android.settings.sound.VibrateForCallsPreferenceController"
settings:keywords="@string/keywords_vibrate_for_calls"/>
settings:controller="com.android.settings.accessibility.VibrationPreferenceController"
settings:keywords="@string/keywords_vibration"/>
<com.android.settingslib.PrimarySwitchPreference
android:key="gesture_prevent_ringing_sound"
@@ -191,14 +191,6 @@
android:title="@string/touch_sounds_title"
android:order="-30"/>
<!-- Vibrate on touch -->
<SwitchPreference
android:key="vibrate_on_touch"
android:title="@string/vibrate_on_touch_title"
android:summary="@string/vibrate_on_touch_summary"
settings:keywords="@string/keywords_vibrate_on_touch"
android:order="-25"/>
<!-- Dock speaker plays -->
<DropDownPreference
android:key="dock_audio_media"

View File

@@ -19,12 +19,17 @@ package com.android.settings;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.ims.ImsRcsManager;
import android.text.TextUtils;
import android.util.FeatureFlagUtils;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.core.FeatureFlags;
import com.android.settings.enterprise.EnterprisePrivacySettings;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.security.SecuritySettingsFeatureProvider;
@@ -304,7 +309,51 @@ public class Settings extends SettingsActivity {
public static class WifiCallingDisclaimerActivity extends SettingsActivity { /* empty */ }
public static class MobileNetworkListActivity extends SettingsActivity {}
public static class PowerMenuSettingsActivity extends SettingsActivity {}
public static class SubscriptionSettingsActivity extends SettingsActivity { /* empty */ }
public static class MobileNetworkActivity extends SettingsActivity {
public static final String EXTRA_MMS_MESSAGE = "mms_message";
public static final String EXTRA_SHOW_CAPABILITY_DISCOVERY_OPT_IN =
"show_capability_discovery_opt_in";
@Override
public Intent getIntent() {
final Intent intent = new Intent(super.getIntent());
int subId = intent.getIntExtra(android.provider.Settings.EXTRA_SUB_ID,
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
SubscriptionInfo subInfo = SubscriptionUtil.getSubscriptionOrDefault(
getApplicationContext(), subId);
CharSequence title = SubscriptionUtil.getUniqueSubscriptionDisplayName(
subInfo, getApplicationContext());
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE, title);
intent.putExtra(android.provider.Settings.EXTRA_SUB_ID, subId);
if (android.provider.Settings.ACTION_MMS_MESSAGE_SETTING.equals(intent.getAction())) {
// highlight "mms_message" preference.
intent.putExtra(EXTRA_FRAGMENT_ARG_KEY, EXTRA_MMS_MESSAGE);
}
if (doesIntentContainOptInAction(intent)) {
intent.putExtra(EXTRA_SHOW_CAPABILITY_DISCOVERY_OPT_IN,
maybeShowContactDiscoveryDialog(subId));
}
return intent;
}
private boolean maybeShowContactDiscoveryDialog(int subId) {
// If this activity was launched using ACTION_SHOW_CAPABILITY_DISCOVERY_OPT_IN, show the
// associated dialog only if the opt-in has not been granted yet.
return MobileNetworkUtils.isContactDiscoveryVisible(getApplicationContext(), subId)
// has the user already enabled this configuration?
&& !MobileNetworkUtils.isContactDiscoveryEnabled(
getApplicationContext(), subId);
}
public static boolean doesIntentContainOptInAction(Intent intent) {
String intentAction = (intent != null ? intent.getAction() : null);
return TextUtils.equals(intentAction,
ImsRcsManager.ACTION_SHOW_CAPABILITY_DISCOVERY_OPT_IN);
}
}
/**
* Activity for BugReportHandlerPicker.

View File

@@ -16,6 +16,8 @@
package com.android.settings.network;
import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
import static androidx.lifecycle.Lifecycle.Event.ON_PAUSE;
import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
@@ -34,7 +36,6 @@ import androidx.preference.PreferenceScreen;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.network.telephony.MobileNetworkActivity;
import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -137,7 +138,8 @@ public class MobileNetworkListController extends AbstractPreferenceController im
&& !SubscriptionUtil.showToggleForPhysicalSim(mSubscriptionManager)) {
SubscriptionUtil.startToggleSubscriptionDialogActivity(mContext, subId, true);
} else {
final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
final Intent intent = new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS);
intent.setPackage(SETTINGS_PACKAGE_NAME);
intent.putExtra(Settings.EXTRA_SUB_ID, info.getSubscriptionId());
mContext.startActivity(intent);
}

View File

@@ -18,6 +18,8 @@ package com.android.settings.network;
import static android.os.UserHandle.myUserId;
import static android.os.UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS;
import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
import static androidx.lifecycle.Lifecycle.Event;
import android.content.BroadcastReceiver;
@@ -38,7 +40,6 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.network.telephony.MobileNetworkActivity;
import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.RestrictedPreference;
@@ -146,7 +147,8 @@ public class MobileNetworkPreferenceController extends AbstractPreferenceControl
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (KEY_MOBILE_NETWORK_SETTINGS.equals(preference.getKey())) {
final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
final Intent intent = new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS);
intent.setPackage(SETTINGS_PACKAGE_NAME);
mContext.startActivity(intent);
return true;
}

View File

@@ -18,6 +18,8 @@ package com.android.settings.network.telephony;
import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
import android.annotation.ColorInt;
import android.app.PendingIntent;
import android.content.Context;
@@ -27,6 +29,7 @@ import android.database.ContentObserver;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -142,7 +145,8 @@ public class MobileDataSlice implements CustomSliceable {
@Override
public Intent getIntent() {
return new Intent(mContext, MobileNetworkActivity.class);
return new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS).setPackage(
SETTINGS_PACKAGE_NAME);
}
@Override

View File

@@ -1,121 +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.network.telephony;
import static com.android.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY;
import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.os.Bundle;
import android.os.UserManager;
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.ims.ImsRcsManager;
import android.text.TextUtils;
import android.util.Log;
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
import com.android.settings.network.SubscriptionUtil;
/**
* Activity for displaying MobileNetworkSettings.
*
* @Deprecated The MobileNetworkActivity should be removed in Android U. Instead of using the
* singleTask activity which will cause an additional window transition when users launch the SIMs
* page, using the {@link com.android.settings.Settings.SubscriptionSettingsActivity} which can be
* managed by {@link SettingsActivity} and be migrated into the Settings architecture.
*/
@Deprecated
public class MobileNetworkActivity extends Activity {
private static final String TAG = "MobileNetworkActivity";
public static final String SHOW_CAPABILITY_DISCOVERY_OPT_IN =
"show_capability_discovery_opt_in";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final UserManager userManager = this.getSystemService(UserManager.class);
if (!userManager.isAdminUser()) {
this.finish();
return;
}
// TODO: Move these intent's extra into SubscriptionSettingsActivity if the
// MobileNetworkActivity is removed in Android U.
Intent intent = getIntent();
if (intent == null) {
Log.d(TAG, "onCreate(), intent = null");
this.finish();
return;
}
Intent trampolineIntent;
final Intent subscriptionSettingsIntent = new Intent(this,
com.android.settings.Settings.SubscriptionSettingsActivity.class);
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this) || !isTaskRoot()) {
trampolineIntent = subscriptionSettingsIntent;
} else {
trampolineIntent = new Intent(Settings.ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY)
.setPackage(Utils.SETTINGS_PACKAGE_NAME);
trampolineIntent.putExtra(
android.provider.Settings.EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI,
subscriptionSettingsIntent.toUri(Intent.URI_INTENT_SCHEME));
}
int subId = intent.getIntExtra(Settings.EXTRA_SUB_ID,
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
SubscriptionInfo subInfo = SubscriptionUtil.getSubscriptionOrDefault(this, subId);
CharSequence title = SubscriptionUtil.getUniqueSubscriptionDisplayName(subInfo, this);
trampolineIntent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE, title);
trampolineIntent.putExtra(Settings.EXTRA_SUB_ID, subId);
if (Settings.ACTION_MMS_MESSAGE_SETTING.equals(intent.getAction())) {
// highlight "mms_message" preference.
trampolineIntent.putExtra(EXTRA_FRAGMENT_ARG_KEY, "mms_message");
}
if (doesIntentContainOptInAction(intent)) {
trampolineIntent.putExtra(SHOW_CAPABILITY_DISCOVERY_OPT_IN,
maybeShowContactDiscoveryDialog(subId));
}
startActivity(trampolineIntent);
if (isTaskRoot()) {
finishAndRemoveTask();
} else {
finish();
}
}
private boolean maybeShowContactDiscoveryDialog(int subId) {
// If this activity was launched using ACTION_SHOW_CAPABILITY_DISCOVERY_OPT_IN, show the
// associated dialog only if the opt-in has not been granted yet.
return MobileNetworkUtils.isContactDiscoveryVisible(this, subId)
// has the user already enabled this configuration?
&& !MobileNetworkUtils.isContactDiscoveryEnabled(this, subId);
}
public static boolean doesIntentContainOptInAction(Intent intent) {
String intentAction = (intent != null ? intent.getAction() : null);
return TextUtils.equals(intentAction,
ImsRcsManager.ACTION_SHOW_CAPABILITY_DISCOVERY_OPT_IN);
}
}

View File

@@ -26,7 +26,6 @@ import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsRcsManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
@@ -37,6 +36,7 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.Settings.MobileNetworkActivity;
import com.android.settings.datausage.BillingCyclePreferenceController;
import com.android.settings.datausage.DataUsageSummaryPreferenceController;
import com.android.settings.network.ActiveSubscriptionsListener;

View File

@@ -256,8 +256,6 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult
new DockingSoundPreferenceController(context, fragment, lifecycle);
final TouchSoundPreferenceController touchSoundPreferenceController =
new TouchSoundPreferenceController(context, fragment, lifecycle);
final VibrateOnTouchPreferenceController vibrateOnTouchPreferenceController =
new VibrateOnTouchPreferenceController(context, fragment, lifecycle);
final DockAudioMediaPreferenceController dockAudioMediaPreferenceController =
new DockAudioMediaPreferenceController(context, fragment, lifecycle);
final BootSoundPreferenceController bootSoundPreferenceController =
@@ -270,7 +268,6 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult
controllers.add(chargingSoundPreferenceController);
controllers.add(dockingSoundPreferenceController);
controllers.add(touchSoundPreferenceController);
controllers.add(vibrateOnTouchPreferenceController);
controllers.add(dockAudioMediaPreferenceController);
controllers.add(bootSoundPreferenceController);
controllers.add(emergencyTonePreferenceController);
@@ -281,7 +278,6 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult
chargingSoundPreferenceController,
dockingSoundPreferenceController,
touchSoundPreferenceController,
vibrateOnTouchPreferenceController,
dockAudioMediaPreferenceController,
bootSoundPreferenceController,
emergencyTonePreferenceController)));

View File

@@ -1,50 +0,0 @@
/*
* Copyright (C) 2017 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.notification;
import static com.android.settings.notification.SettingPref.TYPE_SYSTEM;
import android.content.Context;
import android.os.Vibrator;
import android.provider.Settings.System;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settingslib.core.lifecycle.Lifecycle;
public class VibrateOnTouchPreferenceController extends SettingPrefController {
private static final String KEY_VIBRATE_ON_TOUCH = "vibrate_on_touch";
public VibrateOnTouchPreferenceController(Context context, SettingsPreferenceFragment parent,
Lifecycle lifecycle) {
super(context, parent, lifecycle);
mPreference = new SettingPref(
TYPE_SYSTEM, KEY_VIBRATE_ON_TOUCH, System.HAPTIC_FEEDBACK_ENABLED, 0) {
@Override
public boolean isApplicable(Context context) {
return hasHaptic(context);
}
};
}
private static boolean hasHaptic(Context context) {
final Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
return vibrator != null && vibrator.hasVibrator();
}
}

View File

@@ -53,7 +53,6 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.HelpTrampoline;
import com.android.settings.R;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.telephony.MobileNetworkActivity;
public class SimSelectNotification extends BroadcastReceiver {
private static final String TAG = "SimSelectNotification";
@@ -261,7 +260,7 @@ public class SimSelectNotification extends BroadcastReceiver {
// Create the pending intent that will lead to the subscription setting page.
Intent resultIntent = new Intent(Settings.ACTION_MMS_MESSAGE_SETTING);
resultIntent.setClass(context, MobileNetworkActivity.class);
resultIntent.setPackage(SETTINGS_PACKAGE_NAME);
resultIntent.putExtra(Settings.EXTRA_SUB_ID, subId);
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);

View File

@@ -37,6 +37,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry;
import com.android.settings.Settings;
import com.android.settings.testutils.CommonUtils;
import com.android.settings.testutils.UiUtils;
@@ -68,7 +69,7 @@ public class MobileDataPreferenceControllerComponentTest {
Context.TELECOM_SERVICE);
@Rule
public ActivityScenarioRule<com.android.settings.network.telephony.MobileNetworkActivity>
public ActivityScenarioRule<Settings.MobileNetworkActivity>
rule = new ActivityScenarioRule<>(
new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));

View File

@@ -250,4 +250,22 @@ public class SavedBluetoothDeviceUpdaterTest {
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice,
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
}
@Test
public void forceUpdate_deviceIsSubDevice_doesNothing() {
final List<BluetoothDevice> bluetoothDevices = new ArrayList<>();
bluetoothDevices.add(mBluetoothDevice);
when(mBluetoothAdapter.isEnabled()).thenReturn(true);
when(mBluetoothAdapter.getMostRecentlyConnectedDevices()).thenReturn(bluetoothDevices);
when(mBluetoothManager.getCachedDeviceManager()).thenReturn(mDeviceManager);
when(mDeviceManager.findDevice(mBluetoothDevice)).thenReturn(mCachedBluetoothDevice);
when(mDeviceManager.isSubDevice(mBluetoothDevice)).thenReturn(true);
mBluetoothDeviceUpdater.forceUpdate();
verify(mBluetoothDeviceUpdater, never()).removePreference(mCachedBluetoothDevice);
verify(mBluetoothDeviceUpdater, never()).addPreference(mCachedBluetoothDevice,
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
}
}

View File

@@ -44,7 +44,7 @@ import android.util.FeatureFlagUtils;
import androidx.lifecycle.Lifecycle;
import androidx.preference.PreferenceScreen;
import com.android.settings.network.telephony.MobileNetworkActivity;
import com.android.settings.Settings.MobileNetworkActivity;
import com.android.settings.widget.AddPreference;
import com.android.settingslib.RestrictedLockUtils;

View File

@@ -1,108 +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.network.telephony;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.robolectric.Shadows.shadowOf;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.UserManager;
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import androidx.test.core.app.ActivityScenario;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.settings.SettingsActivity;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.shadows.ShadowContextImpl;
import org.robolectric.shadows.ShadowSubscriptionManager;
import org.robolectric.shadows.ShadowSubscriptionManager.SubscriptionInfoBuilder;
@RunWith(AndroidJUnit4.class)
public class MobileNetworkActivityTest {
private static final int SUB_ID = 1;
private static final String DISPLAY_NAME = "SUB_ID";
private Context mContext;
private ShadowContextImpl mShadowContextImpl;
private Intent mTestIntent;
@Mock
private UserManager mUserManager;
private ShadowSubscriptionManager mSubscriptionManager;
private SubscriptionInfo mSubscriptionInfo;
private ActivityScenario<MobileNetworkActivity> mMobileNetworkActivity;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = ApplicationProvider.getApplicationContext();
mShadowContextImpl = Shadow.extract(RuntimeEnvironment.application.getBaseContext());
mSubscriptionManager = shadowOf(mContext.getSystemService(SubscriptionManager.class));
mShadowContextImpl.setSystemService(Context.USER_SERVICE, mUserManager);
doReturn(true).when(mUserManager).isAdminUser();
mTestIntent = new Intent(mContext, MobileNetworkActivity.class);
mSubscriptionInfo = SubscriptionInfoBuilder.newBuilder()
.setId(SUB_ID).setDisplayName(DISPLAY_NAME).buildSubscriptionInfo();
mTestIntent.putExtra(Settings.EXTRA_SUB_ID, SUB_ID);
mTestIntent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE,
mSubscriptionInfo.getDisplayName());
}
@After
public void cleanUp() {
if (mMobileNetworkActivity != null) {
mMobileNetworkActivity.close();
}
}
private ActivityScenario<MobileNetworkActivity> createTargetActivity(Intent activityIntent) {
return ActivityScenario.launch(activityIntent);
}
@Test
public void onCreate_getExtraFromIntent() {
mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo);
mMobileNetworkActivity = createTargetActivity(mTestIntent);
mMobileNetworkActivity.onActivity(activity -> {
final Bundle bundle = new Bundle();
activity.onCreate(bundle);
assertThat(bundle.getInt(Settings.EXTRA_SUB_ID)).isEqualTo(SUB_ID);
assertThat(bundle.getString(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE)).isEqualTo(
DISPLAY_NAME);
});
}
}

View File

@@ -1,121 +0,0 @@
/*
* Copyright (C) 2017 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.notification;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
import android.content.ContentResolver;
import android.content.Context;
import android.os.Vibrator;
import android.provider.Settings.System;
import androidx.fragment.app.FragmentActivity;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class VibrateOnTouchPreferenceControllerTest {
@Mock
private PreferenceScreen mScreen;
@Mock
private FragmentActivity mActivity;
@Mock
private ContentResolver mContentResolver;
@Mock
private SoundSettings mSetting;
@Mock
private Context mContext;
@Mock
private Vibrator mVibrator;
private VibrateOnTouchPreferenceController mController;
private SwitchPreference mPreference;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mActivity.getSystemService(Context.VIBRATOR_SERVICE)).thenReturn(mVibrator);
when(mContext.getSystemService(Context.VIBRATOR_SERVICE)).thenReturn(mVibrator);
when(mVibrator.hasVibrator()).thenReturn(true);
when(mSetting.getActivity()).thenReturn(mActivity);
when(mActivity.getContentResolver()).thenReturn(mContentResolver);
mPreference = new SwitchPreference(RuntimeEnvironment.application);
mController = new VibrateOnTouchPreferenceController(mContext, mSetting, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
doReturn(mScreen).when(mSetting).getPreferenceScreen();
}
@Test
public void isAvailable_hasHaptic_shouldReturnTrue() {
assertThat(mController.isAvailable()).isTrue();
}
@Test
public void isAvailable_noHaptic_shouldReturnFalse() {
when(mVibrator.hasVibrator()).thenReturn(false);
assertThat(mController.isAvailable()).isFalse();
}
@Test
public void displayPreference_hapticEnabled_shouldCheckedPreference() {
System.putInt(mContentResolver, System.HAPTIC_FEEDBACK_ENABLED, 1);
mController.displayPreference(mScreen);
assertThat(mPreference.isChecked()).isTrue();
}
@Test
public void displayPreference_hapticDisabled_shouldUncheckedPreference() {
System.putInt(mContentResolver, System.HAPTIC_FEEDBACK_ENABLED, 0);
mController.displayPreference(mScreen);
assertThat(mPreference.isChecked()).isFalse();
}
@Test
public void onPreferenceChanged_preferenceChecked_shouldEnabledHaptic() {
mController.displayPreference(mScreen);
mPreference.getOnPreferenceChangeListener().onPreferenceChange(mPreference, true);
assertThat(System.getInt(mContentResolver, System.HAPTIC_FEEDBACK_ENABLED, 1)).isEqualTo(1);
}
@Test
public void onPreferenceChanged_preferenceUnchecked_shouldDisabledHaptic() {
mController.displayPreference(mScreen);
mPreference.getOnPreferenceChangeListener().onPreferenceChange(mPreference, false);
assertThat(System.getInt(mContentResolver, System.HAPTIC_FEEDBACK_ENABLED, 1)).isEqualTo(0);
}
}

View File

@@ -153,14 +153,6 @@ public class SoundSettingsTest extends InstrumentationTestCase {
"Touch sounds", Settings.System.SOUND_EFFECTS_ENABLED));
}
@MediumTest
public void testOtherSoundsVibrateOnTap() throws Exception {
loadOtherSoundsPage();
assertTrue("Vibrate on tap not toggled",
mHelper.verifyToggleSetting(SettingsType.SYSTEM, PAGE,
"Vibrate on tap", Settings.System.HAPTIC_FEEDBACK_ENABLED));
}
private void loadOtherSoundsPage() throws Exception {
launchSoundSettings();
mHelper.scrollVert(false);