Snap for 7205268 from 45a3450d6f to sc-v2-release

Change-Id: I9a47d41427e55fc7ec4f5a94195d7c0a742350de
This commit is contained in:
android-build-team Robot
2021-03-13 02:08:37 +00:00
33 changed files with 640 additions and 700 deletions

View File

@@ -2820,8 +2820,13 @@
</activity>
<!-- Show channel-level notification settings (channel passed in as extras) -->
<activity android:name="Settings$ChannelNotificationSettingsActivity"
<activity android:name=".notification.app.ChannelPanelActivity"
android:label="@string/notification_channel_title"
android:theme="@style/Theme.Panel"
android:launchMode="singleInstance"
android:excludeFromRecents="true"
android:noHistory="true"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true">
<intent-filter android:priority="1">
<action android:name="android.settings.CHANNEL_NOTIFICATION_SETTINGS" />
@@ -2902,6 +2907,12 @@
android:grantUriPermissions="true"
android:exported="false"/>
<provider
android:name=".emergency.EmergencyActionContentProvider"
android:authorities="com.android.settings.emergency"
android:permission="android.permission.CALL_PRIVILEGED"
android:exported="true"/>
<activity
android:name=".wifi.RequestToggleWiFiActivity"
android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert"

View File

@@ -22,7 +22,6 @@
android:orientation="vertical">
<TextView
android:id="@+id/airplane_mode_text"
android:text="@string/condition_airplane_title"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
@@ -30,17 +29,6 @@
android:layout_gravity="center_horizontal"
android:layout_marginStart="@dimen/content_margin_left"
android:layout_marginEnd="@dimen/content_margin_left"
android:layout_marginTop="@dimen/view_airplane_mode_networks_button_margin_vertical"
android:layout_marginBottom="@dimen/view_airplane_mode_networks_button_margin_vertical"/>
<Button
android:id="@+id/view_airplane_mode_networks_button"
android:text="@string/view_airplane_safe_networks"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginStart="@dimen/content_margin_left"
android:layout_marginEnd="@dimen/content_margin_left"
android:layout_marginBottom="@dimen/view_airplane_mode_networks_button_margin_vertical"
style="@style/ActionPrimaryButton"/>
android:layout_marginTop="@dimen/airplane_mode_message_margin_vertical"
android:layout_marginBottom="@dimen/airplane_mode_message_margin_vertical"/>
</LinearLayout>

View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 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.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_content"
android:layout_height="@dimen/output_switcher_slice_max_height"
android:background="@drawable/settings_panel_background"
android:orientation="vertical"
android:layout_width="match_parent">
<FrameLayout
android:id="@android:id/list_container"
android:layout_height="0px"
android:layout_weight="1"
android:layout_width="match_parent"/>
<View
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/footer_divider"
android:layout_width="match_parent"
android:layout_height="@dimen/horizontal_divider_height"
android:background="?android:attr/dividerHorizontal"/>
<LinearLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<Button
android:id="@+id/see_more"
style="@android:style/Widget.DeviceDefault.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_marginStart="12dp"
android:text="@string/see_more"/>
<Space
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent" />
<Button
android:id="@+id/done"
style="@android:style/Widget.DeviceDefault.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_marginEnd="12dp"
android:text="@string/done"/>
</LinearLayout>
</LinearLayout>

View File

@@ -213,7 +213,7 @@
<dimen name="wifi_detail_page_header_image_size">32dp</dimen>
<!-- Internet Preferences -->
<dimen name="view_airplane_mode_networks_button_margin_vertical">24dp</dimen>
<dimen name="airplane_mode_message_margin_vertical">24dp</dimen>
<dimen name="reset_internet_ring_progress_right_margin">4dp</dimen>
<!-- Color picker -->

View File

@@ -12727,12 +12727,10 @@
<string name="resetting_internet_text">Resetting your internet\u2026</string>
<!-- Menu option for data connectivity recovery for all requested technologies. [CHAR_LIMIT=NONE] -->
<string name="fix_connectivity">Fix connectivity</string>
<!-- Summary for airplane mode networks available. [CHAR LIMIT=60] -->
<string name="airplane_mode_network_available">Airplane mode networks available</string>
<!-- Summary for warning to disconnect ethernet first then switch to other networks. [CHAR LIMIT=60] -->
<string name="to_switch_networks_disconnect_ethernet">To switch networks, disconnect ethernet</string>
<!-- Title for airplane mode network panel. [CHAR LIMIT=60] -->
<string name="airplane_mode_network_panel_title">Airplane mode networks</string>
<!-- Panel subtitle for Wi-Fi turned on. [CHAR LIMIT=60] -->
<string name="wifi_is_turned_on_subtitle">Wi\u2011Fi is turned on</string>
<!-- Summary text separator for preferences including a short description
(eg. "Connected / 5G"). [CHAR LIMIT=50] -->
@@ -12782,13 +12780,15 @@
<string name="category_name_others">Others</string>
<!-- General category name [CHAR LIMIT=none] -->
<string name="category_name_general">General</string>
<!-- Title for Dark theme main switch preferences. [CHAR LIMIT=50] -->
<string name="dark_theme_main_switch_title">Use Dark theme</string>
<!-- Title for bluetooth main switch. [CHAR LIMIT=50] -->
<string name="bluetooth_main_switch_title">Use Bluetooth</string>
<!-- Do not translate. Title for prevent ringing main switch. [CHAR LIMIT=50] -->
<string name="prevent_ringing_main_switch_title" translatable="false">Use prevent ringing</string>
<!-- Do not translate. Title for use wifi hotspot main switch [CHAR LIMIT=50]-->
<string name="use_wifi_hotsopt_main_switch_title" translatable="false">Use Wi\u2011Fi hotspot</string>
<!-- Do not translate. Title for bluetooth main switch. [CHAR LIMIT=50] -->
<string name="bluetooth_main_switch_title" translatable="false">Use bluetooth</string>
<!-- Do not translate. Title for app pinning main switch. [CHAR LIMIT=50] -->
<string name="app_pinning_main_switch_title" translatable="false">Use app pinning</string>
<!-- Do not translate. Title for developer options main switch. [CHAR LIMIT=50] -->
@@ -12805,8 +12805,6 @@
<string name="battery_saver_main_switch_title" translatable="false">Use battery saver</string>
<!-- Do not translate. Title for Do Not Disturb main switch preferences. [CHAR LIMIT=50] -->
<string name="do_not_disturb_main_switch_title" translatable="false">Use Do Not Disturb</string>
<!-- Do not translate. Title for Dark theme main switch preferences. [CHAR LIMIT=50] -->
<string name="dark_theme_main_switch_title" translatable="false">Use Dark Theme</string>
<!-- Do not translate. Title for Night Light main switch preferences. [CHAR LIMIT=50] -->
<string name="night_light_main_switch_title" translatable="false">Use Night Light</string>
<!-- Do not translate. Title for NFC main switch preferences. [CHAR LIMIT=50] -->

View File

@@ -65,56 +65,56 @@
android:summary="@string/promote_conversation_summary"
settings:allowDividerAbove="true"/>
<!-- Default ringtone -->
<com.android.settings.notification.app.NotificationSoundPreference
android:key="ringtone"
android:title="@string/notification_channel_sound_title"
android:dialogTitle="@string/notification_channel_sound_title"
android:order="11"
android:showSilent="true"
android:showDefault="true"/>
<!-- Default ringtone -->
<com.android.settings.notification.app.NotificationSoundPreference
android:key="ringtone"
android:title="@string/notification_channel_sound_title"
android:dialogTitle="@string/notification_channel_sound_title"
android:order="11"
android:showSilent="true"
android:showDefault="true"/>
<!-- Vibration -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="vibrate"
android:order="12"
android:title="@string/notification_vibrate_title"
settings:useAdditionalSummary="true" />
<!-- Vibration -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="vibrate"
android:order="12"
android:title="@string/notification_vibrate_title"
settings:useAdditionalSummary="true" />
<!-- Visibility Override -->
<com.android.settings.RestrictedListPreference
android:key="visibility_override"
android:order="13"
android:title="@string/app_notification_visibility_override_title"/>
<!-- Visibility Override -->
<com.android.settings.RestrictedListPreference
android:key="visibility_override"
android:order="13"
android:title="@string/app_notification_visibility_override_title"/>
<!-- Lights -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="lights"
android:order="14"
android:title="@string/notification_show_lights_title"
settings:useAdditionalSummary="true"/>
<!-- Lights -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="lights"
android:order="14"
android:title="@string/notification_show_lights_title"
settings:useAdditionalSummary="true"/>
<!-- Show badge -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="badge"
android:order="15"
android:title="@string/notification_channel_badge_title"
settings:useAdditionalSummary="true"
settings:restrictedSwitchSummary="@string/enabled_by_admin"/>
<!-- Show badge -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="badge"
android:order="15"
android:title="@string/notification_channel_badge_title"
settings:useAdditionalSummary="true"
settings:restrictedSwitchSummary="@string/enabled_by_admin"/>
<!-- Bypass DND -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="bypass_dnd"
android:order="17"
android:title="@string/app_notification_override_dnd_title"
android:summary="@string/app_notification_override_dnd_summary"
settings:useAdditionalSummary="true"/>
<!-- Bypass DND -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="bypass_dnd"
android:order="17"
android:title="@string/app_notification_override_dnd_title"
android:summary="@string/app_notification_override_dnd_summary"
settings:useAdditionalSummary="true"/>
<Preference
android:key="app_link"
android:order="18"
android:title="@string/app_settings_link"
settings:allowDividerAbove="true"/>
<Preference
android:key="app_link"
android:order="18"
android:title="@string/app_settings_link"
settings:allowDividerAbove="true"/>
<com.android.settings.notification.app.NotificationFooterPreference
android:key="desc"

View File

@@ -62,10 +62,6 @@
android:key="block_desc"
settings:allowDividerAbove="false"/>
<PreferenceCategory
android:key="channel_advanced"
android:order="50"
settings:initialExpandedChildrenCount="0">
<!-- peeking -->
<com.android.settingslib.RestrictedSwitchPreference
@@ -107,6 +103,5 @@
android:icon="@drawable/ic_volume_ringer_vibrate"
android:title="@string/notification_vibrate_title"
settings:useAdditionalSummary="true" />
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -28,12 +28,12 @@
android:layout="@layout/resetting_internet"
settings:allowDividerBelow="true"/>
<!-- View airplane mode networks button -->
<!-- Airplane mode message -->
<com.android.settingslib.widget.LayoutPreference
android:key="view_airplane_mode_netwokrs_button"
android:key="airplane_mode_message"
android:title="@string/condition_airplane_title"
android:selectable="false"
android:layout="@layout/view_airplane_mode_networks_button"
android:layout="@layout/airplane_mode_message_preference"
settings:allowDividerBelow="true"/>
<Preference

View File

@@ -24,7 +24,6 @@ import android.content.pm.PackageManager;
import android.provider.Settings;
import android.text.TextUtils;
import com.android.internal.app.AssistUtils;
import com.android.settings.R;
import com.android.settings.applications.defaultapps.DefaultAppPickerFragment;
import com.android.settingslib.applications.DefaultAppInfo;
@@ -35,8 +34,6 @@ import java.util.List;
public class DefaultVoiceInputPicker extends DefaultAppPickerFragment {
private VoiceInputHelper mHelper;
private AssistUtils mAssistUtils;
private String mAssistRestrict;
@Override
public int getMetricsCategory() {
@@ -46,13 +43,8 @@ public class DefaultVoiceInputPicker extends DefaultAppPickerFragment {
@Override
public void onAttach(Context context) {
super.onAttach(context);
mAssistUtils = new AssistUtils(context);
mHelper = new VoiceInputHelper(context);
mHelper.buildUi();
final ComponentName assist = getCurrentAssist();
if (isCurrentAssistVoiceService(assist, getCurrentService(mHelper))) {
mAssistRestrict = assist.flattenToShortString();
}
}
@Override
@@ -64,16 +56,9 @@ public class DefaultVoiceInputPicker extends DefaultAppPickerFragment {
protected List<VoiceInputDefaultAppInfo> getCandidates() {
final List<VoiceInputDefaultAppInfo> candidates = new ArrayList<>();
final Context context = getContext();
boolean hasEnabled = true;
for (VoiceInputHelper.InteractionInfo info : mHelper.mAvailableInteractionInfos) {
final boolean enabled = TextUtils.equals(info.key, mAssistRestrict);
hasEnabled |= enabled;
candidates.add(new VoiceInputDefaultAppInfo(context, mPm, mUserId, info, enabled));
}
final boolean assistIsService = !hasEnabled;
for (VoiceInputHelper.RecognizerInfo info : mHelper.mAvailableRecognizerInfos) {
final boolean enabled = !assistIsService;
final boolean enabled = true;
candidates.add(new VoiceInputDefaultAppInfo(context, mPm, mUserId, info, enabled));
}
return candidates;
@@ -90,23 +75,8 @@ public class DefaultVoiceInputPicker extends DefaultAppPickerFragment {
@Override
protected boolean setDefaultKey(String value) {
for (VoiceInputHelper.InteractionInfo info : mHelper.mAvailableInteractionInfos) {
if (TextUtils.equals(value, info.key)) {
Settings.Secure.putString(getContext().getContentResolver(),
Settings.Secure.VOICE_INTERACTION_SERVICE, value);
Settings.Secure.putString(getContext().getContentResolver(),
Settings.Secure.VOICE_RECOGNITION_SERVICE,
new ComponentName(info.service.packageName,
info.serviceInfo.getRecognitionService())
.flattenToShortString());
return true;
}
}
for (VoiceInputHelper.RecognizerInfo info : mHelper.mAvailableRecognizerInfos) {
if (TextUtils.equals(value, info.key)) {
Settings.Secure.putString(getContext().getContentResolver(),
Settings.Secure.VOICE_INTERACTION_SERVICE, "");
Settings.Secure.putString(getContext().getContentResolver(),
Settings.Secure.VOICE_RECOGNITION_SERVICE, value);
return true;
@@ -116,23 +86,7 @@ public class DefaultVoiceInputPicker extends DefaultAppPickerFragment {
}
public static ComponentName getCurrentService(VoiceInputHelper helper) {
if (helper.mCurrentVoiceInteraction != null) {
return helper.mCurrentVoiceInteraction;
} else if (helper.mCurrentRecognizer != null) {
return helper.mCurrentRecognizer;
} else {
return null;
}
}
private ComponentName getCurrentAssist() {
return mAssistUtils.getAssistComponentForUser(mUserId);
}
public static boolean isCurrentAssistVoiceService(ComponentName currentAssist,
ComponentName currentVoiceService) {
return currentAssist == null && currentVoiceService == null ||
currentAssist != null && currentAssist.equals(currentVoiceService);
return helper.mCurrentRecognizer;
}
public static class VoiceInputDefaultAppInfo extends DefaultAppInfo {
@@ -152,11 +106,7 @@ public class DefaultVoiceInputPicker extends DefaultAppPickerFragment {
@Override
public CharSequence loadLabel() {
if (mInfo instanceof VoiceInputHelper.InteractionInfo) {
return mInfo.appLabel;
} else {
return mInfo.label;
}
return mInfo.label;
}
public Intent getSettingIntent() {

View File

@@ -26,7 +26,6 @@ import android.text.TextUtils;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.internal.app.AssistUtils;
import com.android.settings.applications.defaultapps.DefaultAppPreferenceController;
import com.android.settingslib.applications.DefaultAppInfo;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -42,17 +41,13 @@ public class DefaultVoiceInputPreferenceController extends DefaultAppPreferenceC
private static final String KEY_VOICE_INPUT = "voice_input_settings";
private VoiceInputHelper mHelper;
private AssistUtils mAssistUtils;
private PreferenceScreen mScreen;
private Preference mPreference;
private SettingObserver mSettingObserver;
private Context mContext;
public DefaultVoiceInputPreferenceController(Context context, Lifecycle lifecycle) {
super(context);
mContext = context;
mSettingObserver = new SettingObserver();
mAssistUtils = new AssistUtils(context);
mHelper = new VoiceInputHelper(context);
mHelper.buildUi();
if (lifecycle != null) {
@@ -80,7 +75,6 @@ public class DefaultVoiceInputPreferenceController extends DefaultAppPreferenceC
@Override
public void onResume() {
mSettingObserver.register(mContext.getContentResolver(), true);
updatePreference();
}
@@ -91,9 +85,7 @@ public class DefaultVoiceInputPreferenceController extends DefaultAppPreferenceC
}
@Override
public void onPause() {
mSettingObserver.register(mContext.getContentResolver(), false);
}
public void onPause() {}
@Override
protected DefaultAppInfo getDefaultAppInfo() {
@@ -101,12 +93,6 @@ public class DefaultVoiceInputPreferenceController extends DefaultAppPreferenceC
if (defaultKey == null) {
return null;
}
for (VoiceInputHelper.InteractionInfo info : mHelper.mAvailableInteractionInfos) {
if (TextUtils.equals(defaultKey, info.key)) {
return new DefaultVoiceInputPicker.VoiceInputDefaultAppInfo(mContext,
mPackageManager, mUserId, info, true /* enabled */);
}
}
for (VoiceInputHelper.RecognizerInfo info : mHelper.mAvailableRecognizerInfos) {
if (TextUtils.equals(defaultKey, info.key)) {
@@ -149,16 +135,4 @@ public class DefaultVoiceInputPreferenceController extends DefaultAppPreferenceC
}
return currentService.flattenToShortString();
}
class SettingObserver extends AssistSettingObserver {
@Override
protected List<Uri> getSettingUris() {
return null;
}
@Override
public void onSettingChange() {
updatePreference();
}
}
}

View File

@@ -26,10 +26,7 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.provider.Settings;
import android.service.voice.VoiceInteractionService;
import android.service.voice.VoiceInteractionServiceInfo;
import android.speech.RecognitionService;
import android.util.ArraySet;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;
@@ -46,9 +43,9 @@ public final class VoiceInputHelper {
static final String TAG = "VoiceInputHelper";
final Context mContext;
final List<ResolveInfo> mAvailableVoiceInteractions;
final List<ResolveInfo> mAvailableRecognition;
// TODO: Remove this superclass as we only have 1 class now (RecognizerInfo).
static public class BaseInfo implements Comparable {
public final ServiceInfo service;
public final ComponentName componentName;
@@ -75,15 +72,6 @@ public final class VoiceInputHelper {
}
}
static public class InteractionInfo extends BaseInfo {
public final VoiceInteractionServiceInfo serviceInfo;
public InteractionInfo(PackageManager pm, VoiceInteractionServiceInfo _service) {
super(pm, _service.getServiceInfo(), _service.getSettingsActivity());
serviceInfo = _service;
}
}
static public class RecognizerInfo extends BaseInfo {
public final boolean mSelectableAsDefault;
@@ -96,56 +84,21 @@ public final class VoiceInputHelper {
}
}
final ArrayList<InteractionInfo> mAvailableInteractionInfos = new ArrayList<>();
final ArrayList<RecognizerInfo> mAvailableRecognizerInfos = new ArrayList<>();
ComponentName mCurrentVoiceInteraction;
ComponentName mCurrentRecognizer;
public VoiceInputHelper(Context context) {
mContext = context;
mAvailableVoiceInteractions = mContext.getPackageManager().queryIntentServices(
new Intent(VoiceInteractionService.SERVICE_INTERFACE),
PackageManager.GET_META_DATA);
mAvailableRecognition = mContext.getPackageManager().queryIntentServices(
new Intent(RecognitionService.SERVICE_INTERFACE),
PackageManager.GET_META_DATA);
}
public void buildUi() {
// Get the currently selected interactor from the secure setting.
String currentSetting = Settings.Secure.getString(
mContext.getContentResolver(), Settings.Secure.VOICE_INTERACTION_SERVICE);
if (currentSetting != null && !currentSetting.isEmpty()) {
mCurrentVoiceInteraction = ComponentName.unflattenFromString(currentSetting);
} else {
mCurrentVoiceInteraction = null;
}
ArraySet<ComponentName> interactorRecognizers = new ArraySet<>();
// Iterate through all the available interactors and load up their info to show
// in the preference.
int size = mAvailableVoiceInteractions.size();
for (int i = 0; i < size; i++) {
ResolveInfo resolveInfo = mAvailableVoiceInteractions.get(i);
VoiceInteractionServiceInfo info = new VoiceInteractionServiceInfo(
mContext.getPackageManager(), resolveInfo.serviceInfo);
if (info.getParseError() != null) {
Log.w("VoiceInteractionService", "Error in VoiceInteractionService "
+ resolveInfo.serviceInfo.packageName + "/"
+ resolveInfo.serviceInfo.name + ": " + info.getParseError());
continue;
}
mAvailableInteractionInfos.add(new InteractionInfo(mContext.getPackageManager(), info));
interactorRecognizers.add(new ComponentName(resolveInfo.serviceInfo.packageName,
info.getRecognitionService()));
}
Collections.sort(mAvailableInteractionInfos);
// Get the currently selected recognizer from the secure setting.
currentSetting = Settings.Secure.getString(
String currentSetting = Settings.Secure.getString(
mContext.getContentResolver(), Settings.Secure.VOICE_RECOGNITION_SERVICE);
if (currentSetting != null && !currentSetting.isEmpty()) {
mCurrentRecognizer = ComponentName.unflattenFromString(currentSetting);
@@ -155,14 +108,11 @@ public final class VoiceInputHelper {
// Iterate through all the available recognizers and load up their info to show
// in the preference.
size = mAvailableRecognition.size();
int size = mAvailableRecognition.size();
for (int i = 0; i < size; i++) {
ResolveInfo resolveInfo = mAvailableRecognition.get(i);
ComponentName comp = new ComponentName(resolveInfo.serviceInfo.packageName,
resolveInfo.serviceInfo.name);
if (interactorRecognizers.contains(comp)) {
//continue;
}
ServiceInfo si = resolveInfo.serviceInfo;
String settingsActivity = null;
// Always show in voice input settings unless specifically set to False.

View File

@@ -0,0 +1,112 @@
/*
* Copyright (C) 2021 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.emergency;
import static android.telecom.TelecomManager.EXTRA_CALL_SOURCE;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.Context;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
import android.telecom.PhoneAccount;
import android.telecom.TelecomManager;
import android.text.TextUtils;
import android.util.Log;
import com.android.settings.R;
import com.android.settingslib.emergencynumber.EmergencyNumberUtils;
/**
* ContentProvider to delegate emergency action work
*/
public class EmergencyActionContentProvider extends ContentProvider {
private static final String TAG = "EmergencyActionContentP";
private static final String ACTION_START_EMERGENCY_CALL =
"com.android.settings.emergency.MAKE_EMERGENCY_CALL";
@Override
public Bundle call(String authority, String method, String arg, Bundle extras) {
int uid = Binder.getCallingUid();
Log.d(TAG, "calling pid/uid" + Binder.getCallingPid() + "/" + uid);
if (!isEmergencyInfo(getContext())) {
throw new SecurityException("Uid is not allowed: " + uid);
}
if (!TextUtils.equals(method, ACTION_START_EMERGENCY_CALL)) {
throw new IllegalArgumentException("Unsupported operation");
}
placeEmergencyCall(getContext());
return new Bundle();
}
@Override
public boolean onCreate() {
return true;
}
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder) {
return null;
}
@Override
public String getType(Uri uri) {
return null;
}
@Override
public Uri insert(Uri uri, ContentValues values) {
return null;
}
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
return 0;
}
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
return 0;
}
private static boolean isEmergencyInfo(Context context) {
final int callingUid = Binder.getCallingUid();
final String callingPackage = context.getPackageManager().getPackagesForUid(callingUid)[0];
return TextUtils.equals(callingPackage,
context.getString(R.string.config_aosp_emergency_package_name));
}
private static void placeEmergencyCall(Context context) {
if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
Log.i(TAG, "Telephony is not supported, skipping.");
return;
}
Bundle extras = new Bundle();
extras.putBoolean(TelecomManager.EXTRA_IS_USER_INTENT_EMERGENCY_CALL, true);
extras.putInt(EXTRA_CALL_SOURCE, TelecomManager.CALL_SOURCE_EMERGENCY_SHORTCUT);
TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
EmergencyNumberUtils emergencyNumberUtils = new EmergencyNumberUtils(context);
telecomManager.placeCall(
Uri.fromParts(PhoneAccount.SCHEME_TEL, emergencyNumberUtils.getPoliceNumber(),
/* fragment= */ null), extras);
}
}

View File

@@ -49,11 +49,11 @@ public class EmergencyGestureEntrypointPreferenceController extends BasePreferen
final String emergencyGestureSettingsPackageName = context.getResources().getString(
R.string.emergency_gesture_settings_package);
if (!TextUtils.isEmpty(emergencyGestureSettingsPackageName)) {
mUseCustomIntent = true;
// Use custom intent if it's configured and system can resolve it.
final Intent intent = new Intent(ACTION_EMERGENCY_GESTURE_SETTINGS)
.setPackage(emergencyGestureSettingsPackageName);
if (canResolveIntent(intent)) {
// Use custom intent if it's configured and system can resolve it.
mUseCustomIntent = true;
mIntent = intent;
}
}

View File

@@ -360,6 +360,11 @@ public class FakeUid extends Uid {
return 0;
}
@Override
public long getCpuMeasuredBatteryConsumptionUC() {
return 0;
}
@Override
public long[] getCustomConsumerMeasuredBatteryConsumptionUC() {
return null;

View File

@@ -24,7 +24,6 @@ import android.util.Log;
import androidx.annotation.VisibleForTesting;
import java.util.Map;
import java.util.concurrent.Executor;
@@ -72,9 +71,10 @@ public class AllowedNetworkTypesListener extends TelephonyCallback implements
}
@Override
public void onAllowedNetworkTypesChanged(Map<Integer, Long> allowedNetworkTypesList) {
long newAllowedNetworkType = allowedNetworkTypesList.get(
TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER);
public void onAllowedNetworkTypesChanged(int reason, long newAllowedNetworkType) {
if (reason != TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER) {
return;
}
if (mListener != null && mAllowedNetworkType != newAllowedNetworkType) {
mListener.onAllowedNetworkTypesChanged();
Log.d(LOG_TAG, "onAllowedNetworkChanged: " + mAllowedNetworkType);

View File

@@ -124,12 +124,6 @@ public class InternetPreferenceController extends AbstractPreferenceController i
return;
}
if (mInternetType == INTERNET_NETWORKS_AVAILABLE
&& mInternetUpdater.isApmNetworksAvailable()) {
mPreference.setSummary(R.string.airplane_mode_network_available);
return;
}
final @IdRes int summary = sSummaryMap.get(mInternetType);
if (summary != 0) {
mPreference.setSummary(summary);

View File

@@ -73,9 +73,9 @@ public class InternetUpdater implements AirplaneModeEnabler.OnAirplaneModeChange
default void onAirplaneModeChanged(boolean isAirplaneModeOn) {};
/**
* Called when airplane mode networks state is changed.
* Called when Wi-Fi enabled is changed.
*/
default void onAirplaneModeNetworksChanged(boolean available) {};
default void onWifiEnabledChanged(boolean enabled) {};
}
/**
@@ -157,9 +157,8 @@ public class InternetUpdater implements AirplaneModeEnabler.OnAirplaneModeChange
@Override
public void onReceive(Context context, Intent intent) {
fetchActiveNetwork();
if (mListener != null && mAirplaneModeEnabler.isAirplaneModeOn()) {
mListener.onAirplaneModeNetworksChanged(
mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED);
if (mListener != null) {
mListener.onWifiEnabledChanged(mWifiManager.isWifiEnabled());
}
}
};
@@ -272,10 +271,9 @@ public class InternetUpdater implements AirplaneModeEnabler.OnAirplaneModeChange
}
/**
* Return ture when the APM networks is available.
* Return ture when the Wi-Fi is enabled.
*/
public boolean isApmNetworksAvailable() {
return mAirplaneModeEnabler.isAirplaneModeOn()
&& (mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED);
public boolean isWifiEnabled() {
return mWifiManager.isWifiEnabled();
}
}

View File

@@ -55,6 +55,7 @@ import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.AirplaneModeEnabler;
import com.android.settings.R;
import com.android.settings.RestrictedSettingsFragment;
import com.android.settings.core.FeatureFlags;
@@ -98,7 +99,8 @@ import java.util.Optional;
public class NetworkProviderSettings extends RestrictedSettingsFragment
implements Indexable, WifiPickerTracker.WifiPickerTrackerCallback,
WifiDialog2.WifiDialog2Listener, DialogInterface.OnDismissListener,
ConnectivitySubsystemsRecoveryManager.RecoveryStatusCallback {
ConnectivitySubsystemsRecoveryManager.RecoveryStatusCallback,
AirplaneModeEnabler.OnAirplaneModeChangedListener {
public static final String ACTION_NETWORK_PROVIDER_SETTINGS =
"android.settings.NETWORK_PROVIDER_SETTINGS";
@@ -118,6 +120,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
static final int CONFIG_NETWORK_REQUEST = 3;
static final int MANAGE_SUBSCRIPTION = 4;
private static final String PREF_KEY_AIRPLANE_MODE_MSG = "airplane_mode_message";
private static final String PREF_KEY_EMPTY_WIFI_LIST = "wifi_empty_list";
// TODO(b/70983952): Rename these to use WifiEntry instead of AccessPoint.
private static final String PREF_KEY_CONNECTED_ACCESS_POINTS = "connected_access_point";
@@ -184,6 +187,8 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
*/
private boolean mIsRestricted;
@VisibleForTesting
AirplaneModeEnabler mAirplaneModeEnabler;
@VisibleForTesting
WifiPickerTracker mWifiPickerTracker;
private WifiPickerTrackerHelper mWifiPickerTrackerHelper;
@@ -204,8 +209,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
@VisibleForTesting
DataUsagePreference mDataUsagePreference;
@VisibleForTesting
ViewAirplaneModeNetworksLayoutPreferenceController
mViewAirplaneModeNetworksButtonPreference;
Preference mAirplaneModeMsgPreference;
@VisibleForTesting
LayoutPreference mResetInternetPreference;
@VisibleForTesting
@@ -241,6 +245,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mAirplaneModeEnabler = new AirplaneModeEnabler(getContext(), this);
// TODO(b/37429702): Add animations and preference comparator back after initial screen is
// loaded (ODR).
@@ -254,6 +259,8 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
private void addPreferences() {
addPreferencesFromResource(R.xml.network_provider_settings);
mAirplaneModeMsgPreference = findPreference(PREF_KEY_AIRPLANE_MODE_MSG);
updateAirplaneModeMsgPreference(mAirplaneModeEnabler.isAirplaneModeOn() /* visible */);
mConnectedWifiEntryPreferenceCategory = findPreference(PREF_KEY_CONNECTED_ACCESS_POINTS);
mWifiEntryPreferenceCategory = findPreference(PREF_KEY_ACCESS_POINTS);
mConfigureWifiSettingsPreference = findPreference(PREF_KEY_CONFIGURE_WIFI_SETTINGS);
@@ -269,11 +276,16 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
mResetInternetPreference.setVisible(false);
}
addNetworkMobileProviderController();
addViewAirplaneModeNetworksButtonController();
addConnectedEthernetNetworkController();
addWifiSwitchPreferenceController();
}
private void updateAirplaneModeMsgPreference(boolean visible) {
if (mAirplaneModeMsgPreference != null) {
mAirplaneModeMsgPreference.setVisible(visible);
}
}
private void addNetworkMobileProviderController() {
if (mNetworkMobileProviderController == null) {
mNetworkMobileProviderController = new NetworkMobileProviderController(
@@ -283,15 +295,6 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
mNetworkMobileProviderController.displayPreference(getPreferenceScreen());
}
private void addViewAirplaneModeNetworksButtonController() {
if (mViewAirplaneModeNetworksButtonPreference == null) {
mViewAirplaneModeNetworksButtonPreference =
new ViewAirplaneModeNetworksLayoutPreferenceController(
getContext(), getSettingsLifecycle());
}
mViewAirplaneModeNetworksButtonPreference.displayPreference(getPreferenceScreen());
}
private void addConnectedEthernetNetworkController() {
if (mConnectedEthernetNetworkController == null) {
mConnectedEthernetNetworkController =
@@ -386,10 +389,11 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
@Override
public void onStart() {
super.onStart();
if (mIsRestricted) {
restrictUi();
return;
}
mAirplaneModeEnabler.start();
}
private void restrictUi() {
@@ -419,6 +423,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
public void onStop() {
getView().removeCallbacks(mUpdateWifiEntryPreferencesRunnable);
getView().removeCallbacks(mHideProgressBarRunnable);
mAirplaneModeEnabler.stop();
super.onStop();
}
@@ -1188,9 +1193,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
if (mResetInternetPreference != null) {
mResetInternetPreference.setVisible(true);
}
if (mViewAirplaneModeNetworksButtonPreference != null) {
mViewAirplaneModeNetworksButtonPreference.setVisible(false);
}
updateAirplaneModeMsgPreference(false /* visible */);
}
/**
@@ -1200,9 +1203,18 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
if (mResetInternetPreference != null) {
mResetInternetPreference.setVisible(false);
}
if (mViewAirplaneModeNetworksButtonPreference != null
&& mViewAirplaneModeNetworksButtonPreference.isAvailable()) {
mViewAirplaneModeNetworksButtonPreference.setVisible(true);
if (mAirplaneModeEnabler.isAirplaneModeOn()) {
updateAirplaneModeMsgPreference(true /* visible */);
}
}
/**
* Called when airplane mode status is changed.
*
* @param isAirplaneModeOn The airplane mode is on
*/
@Override
public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
updateAirplaneModeMsgPreference(isAirplaneModeOn /* visible */);
}
}

View File

@@ -1,168 +0,0 @@
/*
* Copyright (C) 2021 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;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.wifi.WifiManager;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
import androidx.preference.PreferenceScreen;
import com.android.settings.AirplaneModeEnabler;
import com.android.settings.R;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.widget.LayoutPreference;
/**
* This controls the airplane mode message and click button of the "View airplane mode networks"
* item on the Network & internet page.
*/
public class ViewAirplaneModeNetworksLayoutPreferenceController extends AbstractPreferenceController
implements LifecycleObserver, AirplaneModeEnabler.OnAirplaneModeChangedListener,
View.OnClickListener {
public static final String KEY = "view_airplane_mode_netwokrs_button";
private LayoutPreference mPreference;
@VisibleForTesting
TextView mTextView;
@VisibleForTesting
Button mButton;
private AirplaneModeEnabler mAirplaneModeEnabler;
private final WifiManager mWifiManager;
private final IntentFilter mIntentFilter;
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
refreshLayout();
}
}
};
public ViewAirplaneModeNetworksLayoutPreferenceController(Context context,
Lifecycle lifecycle) {
super(context);
if (lifecycle == null) {
throw new IllegalArgumentException("Lifecycle must be set");
}
mAirplaneModeEnabler = new AirplaneModeEnabler(context, this);
mWifiManager = context.getSystemService(WifiManager.class);
mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
lifecycle.addObserver(this);
}
@Override
public boolean isAvailable() {
return mAirplaneModeEnabler.isAirplaneModeOn();
}
@Override
public String getPreferenceKey() {
return KEY;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
generateLayout();
}
/** Lifecycle.Event.ON_START */
@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onStart() {
mAirplaneModeEnabler.start();
}
/** Lifecycle.Event.ON_STOP */
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
public void onStop() {
mAirplaneModeEnabler.stop();
}
/** Lifecycle.Event.ON_RESUME */
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
public void onResume() {
mContext.registerReceiver(mBroadcastReceiver, mIntentFilter);
}
/** Lifecycle.Event.ON_PAUSE */
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
public void onPause() {
mContext.unregisterReceiver(mBroadcastReceiver);
}
@Override
public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
if (mPreference != null) {
mPreference.setVisible(isAirplaneModeOn);
}
}
@Override
public void onClick(View v) {
mWifiManager.setWifiEnabled(true);
}
private void generateLayout() {
if (mPreference == null) {
return;
}
if (mTextView == null) {
mTextView = mPreference.findViewById(R.id.airplane_mode_text);
}
if (mButton == null) {
mButton = mPreference.findViewById(R.id.view_airplane_mode_networks_button);
}
if (mButton != null) {
mButton.setOnClickListener(this);
}
refreshLayout();
}
@VisibleForTesting
void refreshLayout() {
boolean isWifiEnabled = mWifiManager.isWifiEnabled();
if (mTextView != null) {
mTextView.setText(isWifiEnabled ? R.string.viewing_airplane_mode_networks
: R.string.condition_airplane_title);
}
if (mButton != null) {
mButton.setVisibility(isWifiEnabled ? View.GONE : View.VISIBLE);
}
}
/**
* Sets the visibility of the preference.
*/
public void setVisible(boolean visible) {
if (mPreference != null) {
mPreference.setVisible(visible);
}
}
}

View File

@@ -106,7 +106,7 @@ public class BackupCallingPreferenceController extends TelephonyTogglePreference
return false;
}
try {
return imsMmTelMgr.isCrossSimCallingEnabledByUser();
return imsMmTelMgr.isCrossSimCallingEnabled();
} catch (ImsException exception) {
Log.w(LOG_TAG, "fail to get cross SIM calling configuration", exception);
}

View File

@@ -217,7 +217,12 @@ public class NetworkProviderWifiCallingGroup extends
pref.setEnabled(getTelephonyManagerForSubscriptionId(subId).getCallState()
== TelephonyManager.CALL_STATE_IDLE);
pref.setOrder(order++);
pref.setSummary(R.string.calls_sms_wfc_summary);
int resId = com.android.internal.R.string.wifi_calling_off_summary;
if (queryImsState(subId).isEnabledByUser()) {
resId = R.string.calls_sms_wfc_summary;
}
pref.setSummary(resId);
mWifiCallingForSubPreferences.put(subId, pref);
}

View File

@@ -68,12 +68,16 @@ public class ChannelNotificationSettings extends NotificationSettings {
if (mChannel != null && !TextUtils.isEmpty(mChannel.getConversationId())
&& !mChannel.isDemoted()) {
startActivity(new SubSettingLauncher(mContext)
Intent intent = new SubSettingLauncher(mContext)
.setDestination(ConversationNotificationSettings.class.getName())
.setArguments(getArguments())
.setExtras(getIntent() != null ? getIntent().getExtras(): null)
.setSourceMetricsCategory(SettingsEnums.NOTIFICATION_TOPIC_NOTIFICATION)
.toIntent());
.toIntent();
if (mPreferenceFilter != null) {
intent.setClass(mContext, ChannelPanelActivity.class);
}
startActivity(intent);
finish();
return;
}
@@ -84,6 +88,7 @@ public class ChannelNotificationSettings extends NotificationSettings {
controller.displayPreference(getPreferenceScreen());
}
updatePreferenceStates();
animatePanel();
}
@Override

View File

@@ -0,0 +1,111 @@
/*
* Copyright (C) 2021 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.app;
import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.core.HideNonSystemOverlayMixin;
import com.android.settings.core.SubSettingLauncher;
/**
* Dialog Activity to host channel settings
*/
public class ChannelPanelActivity extends FragmentActivity {
private static final String TAG = "ChannelPanelActivity";
final Bundle mBundle = new Bundle();
NotificationSettings mPanelFragment;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!getIntent().hasExtra(Settings.EXTRA_CHANNEL_FILTER_LIST)) {
launchFullSettings();
}
getApplicationContext().getTheme().rebase();
createOrUpdatePanel();
getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
createOrUpdatePanel();
}
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
private void launchFullSettings() {
Bundle extras = getIntent().getExtras();
extras.remove(Settings.EXTRA_CHANNEL_FILTER_LIST);
startActivity(new SubSettingLauncher(this)
.setDestination(ChannelNotificationSettings.class.getName())
.setExtras(extras)
.setSourceMetricsCategory(SettingsEnums.NOTIFICATION_TOPIC_NOTIFICATION)
.toIntent());
finish();
}
private void createOrUpdatePanel() {
final Intent callingIntent = getIntent();
if (callingIntent == null) {
Log.e(TAG, "Null intent, closing Panel Activity");
finish();
return;
}
final FragmentManager fragmentManager = getSupportFragmentManager();
setContentView(R.layout.notification_channel_panel);
// Move the window to the bottom of screen, and make it take up the entire screen width.
final Window window = getWindow();
window.setGravity(Gravity.BOTTOM);
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT);
findViewById(R.id.done).setOnClickListener(v -> finish());
findViewById(R.id.see_more).setOnClickListener(v -> launchFullSettings());
mPanelFragment = callingIntent.hasExtra(Settings.EXTRA_CONVERSATION_ID)
? new ConversationNotificationSettings()
: new ChannelNotificationSettings();
mPanelFragment.setArguments(new Bundle(mBundle));
fragmentManager.beginTransaction().replace(
android.R.id.list_container, mPanelFragment).commit();
}
}

View File

@@ -93,6 +93,7 @@ public class ConversationHeaderPreferenceController extends NotificationPreferen
.done(activity, mContext);
pref.findViewById(R.id.entity_header).setVisibility(View.VISIBLE);
pref.findViewById(R.id.entity_header).setBackground(null);
}
}

View File

@@ -49,10 +49,11 @@ public class ConversationNotificationSettings extends NotificationSettings {
for (NotificationPreferenceController controller : mControllers) {
controller.onResume(mAppRow, mChannel, mChannelGroup, mConversationDrawable,
mConversationInfo, mSuspendedAppsAdmin, null);
mConversationInfo, mSuspendedAppsAdmin, mPreferenceFilter);
controller.displayPreference(getPreferenceScreen());
}
updatePreferenceStates();
animatePanel();
}
@Override

View File

@@ -92,6 +92,7 @@ public class HeaderPreferenceController extends NotificationPreferenceController
.setRecyclerView(mFragment.getListView(), mFragment.getSettingsLifecycle())
.done(activity, mContext);
pref.findViewById(R.id.entity_header).setVisibility(View.VISIBLE);
pref.findViewById(R.id.entity_header).setBackground(null);
}
}

View File

@@ -18,6 +18,9 @@ package com.android.settings.notification.app;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
@@ -39,8 +42,13 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.animation.DecelerateInterpolator;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
@@ -85,6 +93,20 @@ abstract public class NotificationSettings extends DashboardFragment {
protected Intent mIntent;
protected Bundle mArgs;
private ViewGroup mLayoutView;
private static final int DURATION_ANIMATE_PANEL_EXPAND_MS = 250;
private final ViewTreeObserver.OnGlobalLayoutListener mOnGlobalLayoutListener =
new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
animateIn();
if (mLayoutView != null) {
mLayoutView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
}
};
@Override
public void onAttach(Context context) {
super.onAttach(context);
@@ -187,6 +209,50 @@ abstract public class NotificationSettings extends DashboardFragment {
collectConfigActivities();
}
protected void animatePanel() {
if (mPreferenceFilter != null) {
mLayoutView = getActivity().findViewById(R.id.main_content);
mLayoutView.getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener);
}
}
/**
* Animate a Panel onto the screen.
* <p>
* Takes the entire panel and animates in from behind the navigation bar.
* <p>
* Relies on the Panel being having a fixed height to begin the animation.
*/
private void animateIn() {
final AnimatorSet animatorSet = buildAnimatorSet(mLayoutView,
mLayoutView.getHeight() /* startY */, 0.0f /* endY */,
0.0f /* startAlpha */, 1.0f /* endAlpha */,
DURATION_ANIMATE_PANEL_EXPAND_MS);
final ValueAnimator animator = new ValueAnimator();
animator.setFloatValues(0.0f, 1.0f);
animatorSet.play(animator);
animatorSet.start();
}
/**
* Build an {@link AnimatorSet} to animate the Panel, {@param parentView} in or out of the
* screen, based on the positional parameters {@param startY}, {@param endY}, the parameters
* for alpha changes {@param startAlpha}, {@param endAlpha}, and the {@param duration} in
* milliseconds.
*/
@NonNull
private static AnimatorSet buildAnimatorSet(@NonNull View targetView,
float startY, float endY,
float startAlpha, float endAlpha, int duration) {
final AnimatorSet animatorSet = new AnimatorSet();
animatorSet.setDuration(duration);
animatorSet.setInterpolator(new DecelerateInterpolator());
animatorSet.playTogether(
ObjectAnimator.ofFloat(targetView, View.TRANSLATION_Y, startY, endY),
ObjectAnimator.ofFloat(targetView, View.ALPHA, startAlpha, endAlpha));
return animatorSet;
}
private void loadPreferencesFilter() {
Intent intent = getActivity().getIntent();
mPreferenceFilter = intent != null

View File

@@ -50,9 +50,8 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
@VisibleForTesting
boolean mIsProviderModelEnabled;
private PanelContentCallback mCallback;
private InternetUpdater mInternetUpdater;
private boolean mIsAirplaneModeOn;
private boolean mIsApmNetworksAvailable;
@VisibleForTesting
InternetUpdater mInternetUpdater;
public static InternetConnectivityPanel create(Context context) {
return new InternetConnectivityPanel(context);
@@ -62,8 +61,6 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
mContext = context.getApplicationContext();
mIsProviderModelEnabled = Utils.isProviderModelEnabled(mContext);
mInternetUpdater = new InternetUpdater(context, null /* Lifecycle */, this);
mIsAirplaneModeOn = mInternetUpdater.isAirplaneModeOn();
mIsApmNetworksAvailable = mInternetUpdater.isApmNetworksAvailable();
}
/** @OnLifecycleEvent(ON_RESUME) */
@@ -90,9 +87,8 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
@Override
public CharSequence getTitle() {
if (mIsProviderModelEnabled) {
return mContext.getText(mIsApmNetworksAvailable
? R.string.airplane_mode_network_panel_title
: R.string.provider_internet_settings);
return mContext.getText(mInternetUpdater.isAirplaneModeOn()
? R.string.airplane_mode : R.string.provider_internet_settings);
}
return mContext.getText(R.string.internet_connectivity_panel_title);
}
@@ -102,8 +98,9 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
*/
@Override
public CharSequence getSubTitle() {
if (mIsProviderModelEnabled && mIsAirplaneModeOn && !mIsApmNetworksAvailable) {
return mContext.getText(R.string.condition_airplane_title);
if (mIsProviderModelEnabled && mInternetUpdater.isAirplaneModeOn()
&& mInternetUpdater.isWifiEnabled()) {
return mContext.getText(R.string.wifi_is_turned_on_subtitle);
}
return null;
}
@@ -136,7 +133,7 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
@Override
public CharSequence getCustomizedButtonTitle() {
if (mIsAirplaneModeOn && !mIsApmNetworksAvailable) {
if (mInternetUpdater.isAirplaneModeOn() && !mInternetUpdater.isWifiEnabled()) {
return null;
}
return mContext.getText(R.string.settings_button);
@@ -162,19 +159,14 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
*/
@Override
public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
if (!isAirplaneModeOn) {
mIsApmNetworksAvailable = false;
}
mIsAirplaneModeOn = isAirplaneModeOn;
updatePanelTitle();
}
/**
* Called when airplane mode networks state is changed.
* Called when Wi-Fi enabled is changed.
*/
@Override
public void onAirplaneModeNetworksChanged(boolean available) {
mIsApmNetworksAvailable = available;
public void onWifiEnabledChanged(boolean enabled) {
updatePanelTitle();
}
@@ -183,16 +175,14 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
return;
}
if (mIsAirplaneModeOn && !mIsApmNetworksAvailable) {
// When the airplane mode is on.
// Title: Internet
// Sub-Title: Airplane mode is on
// Settings button: Hide
if (mInternetUpdater.isAirplaneModeOn() && mInternetUpdater.isWifiEnabled()) {
// When the airplane mode is on and Wi-Fi is enabled.
// Title: Airplane mode
// Sub-Title: Wi-Fi is turned on
mCallback.onHeaderChanged();
} else {
// Except for airplane mode on.
// Title: Airplane mode networks / Internet
// Settings button: Show
// Other situations.
// Title: Airplane mode / Internet
mCallback.onTitleChanged();
}
mCallback.onCustomizedButtonStateChanged();

View File

@@ -105,7 +105,7 @@ public class EmergencyGestureEntrypointPreferenceControllerTest {
}
@Test
public void getAvailabilityStatus_noSuitableIntent_shouldReturnUnsupported() {
public void getAvailabilityStatus_noSuitableIntent_shouldReturnAvailable() {
SettingsShadowResources.overrideResource(
R.bool.config_show_emergency_gesture_settings,
Boolean.TRUE);
@@ -117,7 +117,8 @@ public class EmergencyGestureEntrypointPreferenceControllerTest {
EmergencyGestureEntrypointPreferenceController controller =
new EmergencyGestureEntrypointPreferenceController(mContext, PREF_KEY);
assertThat(controller.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
assertThat(controller.mIntent).isNull();
}
private void prepareCustomIntent() {

View File

@@ -54,6 +54,7 @@ import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.AirplaneModeEnabler;
import com.android.settings.R;
import com.android.settings.datausage.DataUsagePreference;
import com.android.settings.testutils.shadow.ShadowDataUsageUtils;
@@ -90,6 +91,8 @@ public class NetworkProviderSettingsTest {
@Mock
private UserManager mUserManager;
@Mock
private AirplaneModeEnabler mAirplaneModeEnabler;
@Mock
private DataUsagePreference mDataUsagePreference;
private Context mContext;
private NetworkProviderSettings mNetworkProviderSettings;
@@ -100,8 +103,7 @@ public class NetworkProviderSettingsTest {
@Mock
private ConnectivitySubsystemsRecoveryManager mConnectivitySubsystemsRecoveryManager;
@Mock
private ViewAirplaneModeNetworksLayoutPreferenceController
mViewAirplaneModeNetworksButtonPreference;
private Preference mAirplaneModeMsgPreference;
@Mock
private LayoutPreference mResetInternetPreference;
@Mock
@@ -126,6 +128,9 @@ public class NetworkProviderSettingsTest {
new Preference(mContext);
mNetworkProviderSettings.mWifiPickerTracker = mMockWifiPickerTracker;
mNetworkProviderSettings.mWifiManager = mWifiManager;
mNetworkProviderSettings.mResetInternetPreference = mResetInternetPreference;
mNetworkProviderSettings.mAirplaneModeMsgPreference = mAirplaneModeMsgPreference;
mNetworkProviderSettings.mAirplaneModeEnabler = mAirplaneModeEnabler;
}
@Test
@@ -421,27 +426,35 @@ public class NetworkProviderSettingsTest {
}
@Test
public void onSubsystemRestartOperationBegin_showResetInternetHideApmNetworks() {
mNetworkProviderSettings.mResetInternetPreference = mResetInternetPreference;
mNetworkProviderSettings.mViewAirplaneModeNetworksButtonPreference =
mViewAirplaneModeNetworksButtonPreference;
public void onSubsystemRestartOperationBegin_showResetInternetHideApmMsg() {
mNetworkProviderSettings.onSubsystemRestartOperationBegin();
verify(mResetInternetPreference).setVisible(true);
verify(mViewAirplaneModeNetworksButtonPreference).setVisible(false);
verify(mAirplaneModeMsgPreference).setVisible(false);
}
@Test
public void onSubsystemRestartOperationEnd_showApmNetworksHideResetInternet() {
mNetworkProviderSettings.mResetInternetPreference = mResetInternetPreference;
mNetworkProviderSettings.mViewAirplaneModeNetworksButtonPreference =
mViewAirplaneModeNetworksButtonPreference;
doReturn(true).when(mViewAirplaneModeNetworksButtonPreference).isAvailable();
public void onSubsystemRestartOperationEnd_showApmMsgHideResetInternet() {
doReturn(true).when(mAirplaneModeEnabler).isAirplaneModeOn();
mNetworkProviderSettings.onSubsystemRestartOperationEnd();
verify(mResetInternetPreference).setVisible(false);
verify(mViewAirplaneModeNetworksButtonPreference).setVisible(true);
verify(mAirplaneModeMsgPreference).setVisible(true);
}
@Test
public void onAirplaneModeChanged_apmIsOn_showApmMsg() {
mNetworkProviderSettings.onAirplaneModeChanged(true);
verify(mAirplaneModeMsgPreference).setVisible(true);
}
@Test
public void onAirplaneModeChanged_apmIsOff_hideApmMsg() {
mNetworkProviderSettings.onAirplaneModeChanged(false);
verify(mAirplaneModeMsgPreference).setVisible(false);
}
}

View File

@@ -40,9 +40,6 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.HashMap;
import java.util.Map;
@RunWith(AndroidJUnit4.class)
public class AllowedNetworkTypesListenerTest {
@@ -73,12 +70,11 @@ public class AllowedNetworkTypesListenerTest {
@Test
public void onChange_shouldCallListener() {
mAllowedNetworkTypesListener.mListener = mListener;
Map<Integer, Long> allowedNetworkTypesList = new HashMap<>();
long networkType = (long) RadioAccessFamily.getRafFromNetworkType(
TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO);
allowedNetworkTypesList.put(TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER,
networkType);
mAllowedNetworkTypesListener.onAllowedNetworkTypesChanged(allowedNetworkTypesList);
mAllowedNetworkTypesListener.onAllowedNetworkTypesChanged(
TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER, networkType);
verify(mListener).onAllowedNetworkTypesChanged();
}

View File

@@ -1,171 +0,0 @@
/*
* Copyright (C) 2021 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;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import android.content.Context;
import android.net.wifi.WifiManager;
import android.os.Looper;
import android.view.View;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.settings.testutils.AirplaneModeRule;
import com.android.settings.testutils.ResourcesUtils;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.widget.LayoutPreference;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
@RunWith(AndroidJUnit4.class)
public class ViewAirplaneModeNetworksLayoutPreferenceControllerTest {
private static final String KEY = ViewAirplaneModeNetworksLayoutPreferenceController.KEY;
private static final String RES_ID_AIRPLANE_MODE_IS_ON = "condition_airplane_title";
private static final String RES_ID_VIEWING_AIRPLANE_MODE_NETWORKS =
"viewing_airplane_mode_networks";
@Rule
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
@Rule
public AirplaneModeRule mAirplaneModeRule = new AirplaneModeRule();
@Mock
private WifiManager mWifiManager;
private Context mContext;
private PreferenceScreen mScreen;
private LayoutPreference mPreference;
private ViewAirplaneModeNetworksLayoutPreferenceController mController;
@Before
public void setUp() {
mContext = spy(ApplicationProvider.getApplicationContext());
doReturn(mWifiManager).when(mContext).getSystemService(Context.WIFI_SERVICE);
mController = new ViewAirplaneModeNetworksLayoutPreferenceController(mContext,
mock(Lifecycle.class));
if (Looper.myLooper() == null) {
Looper.prepare();
}
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
mScreen = preferenceManager.createPreferenceScreen(mContext);
mPreference = new LayoutPreference(mContext,
ResourcesUtils.getResourcesId(
mContext, "layout", "view_airplane_mode_networks_button"));
mPreference.setKey(KEY);
mScreen.addPreference(mPreference);
}
@Test
public void isAvailable_airplaneModeOff_returnFalse() {
mAirplaneModeRule.setAirplaneMode(false);
assertThat(mController.isAvailable()).isFalse();
}
@Test
public void isAvailable_airplaneModeOn_returnTrue() {
mAirplaneModeRule.setAirplaneMode(true);
assertThat(mController.isAvailable()).isTrue();
}
@Test
public void displayPreference_wifiDisabled_showAirplaneModeIsOnButtonVisible() {
mAirplaneModeRule.setAirplaneMode(true);
doReturn(false).when(mWifiManager).isWifiEnabled();
mController.displayPreference(mScreen);
assertThat(mController.mTextView.getText())
.isEqualTo(ResourcesUtils.getResourcesString(mContext, RES_ID_AIRPLANE_MODE_IS_ON));
assertThat(mController.mButton.getVisibility()).isEqualTo(View.VISIBLE);
}
@Test
public void displayPreference_wifiEnabled_showViewingAirplaneModeNetworksButtonGone() {
mAirplaneModeRule.setAirplaneMode(true);
doReturn(true).when(mWifiManager).isWifiEnabled();
mController.displayPreference(mScreen);
assertThat(mController.mTextView.getText()).isEqualTo(
ResourcesUtils.getResourcesString(mContext, RES_ID_VIEWING_AIRPLANE_MODE_NETWORKS));
assertThat(mController.mButton.getVisibility()).isEqualTo(View.GONE);
}
@Test
public void refreshLayout_wifiEnabledThenDisabled_showAirplaneModeIsOnButtonVisible() {
mAirplaneModeRule.setAirplaneMode(true);
// Wi-Fi enabled
doReturn(true).when(mWifiManager).isWifiEnabled();
// Display preference
mController.displayPreference(mScreen);
// Then Wi-Fi disabled
doReturn(false).when(mWifiManager).isWifiEnabled();
// Refresh layout
mController.refreshLayout();
assertThat(mController.mTextView.getText())
.isEqualTo(ResourcesUtils.getResourcesString(mContext, RES_ID_AIRPLANE_MODE_IS_ON));
assertThat(mController.mButton.getVisibility()).isEqualTo(View.VISIBLE);
}
@Test
public void refreshLayout_wifiDisabledThenEnabled_showViewingAirplaneModeNetworksButtonGone() {
mAirplaneModeRule.setAirplaneMode(true);
// Wi-Fi disabled
doReturn(false).when(mWifiManager).isWifiEnabled();
// Display preference
mController.displayPreference(mScreen);
// Then Wi-Fi enabled
doReturn(true).when(mWifiManager).isWifiEnabled();
// Refresh layout
mController.refreshLayout();
assertThat(mController.mTextView.getText()).isEqualTo(
ResourcesUtils.getResourcesString(mContext, RES_ID_VIEWING_AIRPLANE_MODE_NETWORKS));
assertThat(mController.mButton.getVisibility()).isEqualTo(View.GONE);
}
@Test
public void onClick_shouldSetWifiEnabled() {
mAirplaneModeRule.setAirplaneMode(true);
doReturn(false).when(mWifiManager).isWifiEnabled();
mController.onClick(mock(View.class));
verify(mWifiManager).setWifiEnabled(true);
}
}

View File

@@ -19,6 +19,7 @@ package com.android.settings.panel;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -29,6 +30,7 @@ import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.settings.network.AirplaneModePreferenceController;
import com.android.settings.network.InternetUpdater;
import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.testutils.ResourcesUtils;
@@ -47,10 +49,10 @@ public class InternetConnectivityPanelTest {
public static final String TITLE_INTERNET = ResourcesUtils.getResourcesString(
ApplicationProvider.getApplicationContext(), "provider_internet_settings");
public static final String TITLE_APM_NETWORKS = ResourcesUtils.getResourcesString(
ApplicationProvider.getApplicationContext(), "airplane_mode_network_panel_title");
public static final String SUBTITLE_APM_IS_ON = ResourcesUtils.getResourcesString(
ApplicationProvider.getApplicationContext(), "condition_airplane_title");
public static final String TITLE_APM = ResourcesUtils.getResourcesString(
ApplicationProvider.getApplicationContext(), "airplane_mode");
public static final String SUBTITLE_WIFI_IS_TURNED_ON = ResourcesUtils.getResourcesString(
ApplicationProvider.getApplicationContext(), "wifi_is_turned_on_subtitle");
public static final String BUTTON_SETTINGS = ResourcesUtils.getResourcesString(
ApplicationProvider.getApplicationContext(), "settings_button");
@@ -58,6 +60,8 @@ public class InternetConnectivityPanelTest {
public final MockitoRule mMocks = MockitoJUnit.rule();
@Mock
PanelContentCallback mPanelContentCallback;
@Mock
InternetUpdater mInternetUpdater;
private Context mContext;
private InternetConnectivityPanel mPanel;
@@ -69,73 +73,65 @@ public class InternetConnectivityPanelTest {
mPanel = InternetConnectivityPanel.create(mContext);
mPanel.registerCallback(mPanelContentCallback);
mPanel.mIsProviderModelEnabled = true;
mPanel.mInternetUpdater = mInternetUpdater;
}
@Test
public void getTitle_apmOnApmNetworksOff_shouldBeInternet() {
mPanel.onAirplaneModeChanged(true);
mPanel.onAirplaneModeNetworksChanged(false);
public void getTitle_apmOff_shouldBeInternet() {
doReturn(false).when(mInternetUpdater).isAirplaneModeOn();
assertThat(mPanel.getTitle()).isEqualTo(TITLE_INTERNET);
}
@Test
public void getTitle_apmOnApmNetworksOn_shouldBeApmNetworks() {
mPanel.onAirplaneModeChanged(true);
mPanel.onAirplaneModeNetworksChanged(true);
public void getTitle_apmOn_shouldBeApm() {
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
assertThat(mPanel.getTitle()).isEqualTo(TITLE_APM_NETWORKS);
}
@Test
public void getTitle_notInternetApmNetworks_shouldBeInternet() {
mPanel.onAirplaneModeNetworksChanged(false);
assertThat(mPanel.getTitle()).isEqualTo(TITLE_INTERNET);
}
@Test
public void getSubTitle_apmOnApmNetworksOff_shouldBeApmIsOn() {
mPanel.onAirplaneModeChanged(true);
mPanel.onAirplaneModeNetworksChanged(false);
assertThat(mPanel.getSubTitle()).isEqualTo(SUBTITLE_APM_IS_ON);
}
@Test
public void getSubTitle_apmOnApmNetworksOn_shouldBeNull() {
mPanel.onAirplaneModeChanged(true);
mPanel.onAirplaneModeNetworksChanged(true);
assertThat(mPanel.getSubTitle()).isNull();
assertThat(mPanel.getTitle()).isEqualTo(TITLE_APM);
}
@Test
public void getSubTitle_apmOff_shouldBeNull() {
mPanel.onAirplaneModeChanged(false);
doReturn(false).when(mInternetUpdater).isAirplaneModeOn();
assertThat(mPanel.getSubTitle()).isNull();
}
@Test
public void getCustomizedButtonTitle_apmOnApmNetworksOff_shouldBeNull() {
mPanel.onAirplaneModeChanged(true);
mPanel.onAirplaneModeNetworksChanged(false);
public void getSubTitle_apmOnWifiOff_shouldBeNull() {
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
doReturn(false).when(mInternetUpdater).isWifiEnabled();
assertThat(mPanel.getCustomizedButtonTitle()).isNull();
assertThat(mPanel.getSubTitle()).isNull();
}
@Test
public void getCustomizedButtonTitle_apmOnApmNetworksOn_shouldBeSettings() {
mPanel.onAirplaneModeChanged(true);
mPanel.onAirplaneModeNetworksChanged(true);
public void getSubTitle_apmOnWifiOn_shouldWifiIsTurnedOn() {
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
doReturn(true).when(mInternetUpdater).isWifiEnabled();
assertThat(mPanel.getSubTitle()).isEqualTo(SUBTITLE_WIFI_IS_TURNED_ON);
}
@Test
public void getCustomizedButtonTitle_apmOff_shouldBeSettings() {
doReturn(false).when(mInternetUpdater).isAirplaneModeOn();
assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_SETTINGS);
}
@Test
public void getCustomizedButtonTitle_apmOff_shouldBeSettings() {
mPanel.onAirplaneModeChanged(false);
public void getCustomizedButtonTitle_apmOnWifiOff_shouldBeNull() {
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
doReturn(false).when(mInternetUpdater).isWifiEnabled();
assertThat(mPanel.getCustomizedButtonTitle()).isNull();
}
@Test
public void getCustomizedButtonTitle_apmOnWifiOn_shouldBeSettings() {
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
doReturn(true).when(mInternetUpdater).isWifiEnabled();
assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_SETTINGS);
}
@@ -166,46 +162,86 @@ public class InternetConnectivityPanelTest {
}
@Test
public void onAirplaneModeOn_apmNetworksOff_changeHeaderAndHideSettings() {
mPanel.onAirplaneModeNetworksChanged(false);
public void onAirplaneModeOn_apmOff_onTitleChanged() {
doReturn(false).when(mInternetUpdater).isAirplaneModeOn();
clearInvocations(mPanelContentCallback);
mPanel.onAirplaneModeChanged(false);
verify(mPanelContentCallback).onTitleChanged();
}
@Test
public void onAirplaneModeOn_apmOnWifiOff_onTitleChanged() {
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
doReturn(false).when(mInternetUpdater).isWifiEnabled();
clearInvocations(mPanelContentCallback);
mPanel.onAirplaneModeChanged(true);
verify(mPanelContentCallback).onTitleChanged();
}
@Test
public void onAirplaneModeOn_apmOnWifiOn_onHeaderChanged() {
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
doReturn(true).when(mInternetUpdater).isWifiEnabled();
clearInvocations(mPanelContentCallback);
mPanel.onAirplaneModeChanged(true);
verify(mPanelContentCallback).onHeaderChanged();
verify(mPanelContentCallback).onCustomizedButtonStateChanged();
}
@Test
public void onAirplaneModeOn_apmNetworksOn_changeTitleAndShowSettings() {
mPanel.onAirplaneModeNetworksChanged(true);
public void onAirplaneModeOn_onCustomizedButtonStateChanged() {
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
clearInvocations(mPanelContentCallback);
mPanel.onAirplaneModeChanged(true);
verify(mPanelContentCallback).onTitleChanged();
verify(mPanelContentCallback).onCustomizedButtonStateChanged();
}
@Test
public void onAirplaneModeNetworksOn_apmOff_changeTitleAndShowSettings() {
mPanel.onAirplaneModeChanged(false);
public void onWifiEnabledChanged_apmOff_onTitleChanged() {
doReturn(false).when(mInternetUpdater).isAirplaneModeOn();
clearInvocations(mPanelContentCallback);
mPanel.onAirplaneModeNetworksChanged(true);
mPanel.onWifiEnabledChanged(false);
verify(mPanelContentCallback).onTitleChanged();
verify(mPanelContentCallback).onCustomizedButtonStateChanged();
}
@Test
public void onAirplaneModeNetworksOff_apmOff_changeTitleAndShowSettings() {
mPanel.onAirplaneModeChanged(false);
public void onWifiEnabledChanged_apmOnWifiOff_onTitleChanged() {
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
doReturn(false).when(mInternetUpdater).isWifiEnabled();
clearInvocations(mPanelContentCallback);
mPanel.onAirplaneModeNetworksChanged(false);
mPanel.onWifiEnabledChanged(true);
verify(mPanelContentCallback).onTitleChanged();
}
@Test
public void onWifiEnabledChanged_apmOnWifiOn_onHeaderChanged() {
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
doReturn(true).when(mInternetUpdater).isWifiEnabled();
clearInvocations(mPanelContentCallback);
mPanel.onWifiEnabledChanged(true);
verify(mPanelContentCallback).onHeaderChanged();
}
@Test
public void onWifiEnabledChanged_onCustomizedButtonStateChanged() {
doReturn(true).when(mInternetUpdater).isWifiEnabled();
clearInvocations(mPanelContentCallback);
mPanel.onWifiEnabledChanged(true);
verify(mPanelContentCallback).onCustomizedButtonStateChanged();
}
}