Snap for 7128142 from 92c1b3d5d3 to sc-v2-release
Change-Id: Ic1d573b2e1794a8afc51529f7c37234dd8a9d0c4
This commit is contained in:
@@ -3661,6 +3661,14 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
<receiver
|
||||||
|
android:name=".sim.receivers.SuwFinishReceiver"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="com.google.android.setupwizard.SETUP_WIZARD_FINISHED" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".sim.receivers.SimCompleteBootReceiver"
|
android:name=".sim.receivers.SimCompleteBootReceiver"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
|
|||||||
@@ -17,14 +17,12 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/search_bar_margin"
|
android:layout_marginTop="@dimen/search_bar_margin"
|
||||||
android:layout_marginStart="@dimen/search_bar_margin"
|
android:layout_marginStart="@dimen/search_bar_margin"
|
||||||
android:layout_marginEnd="@dimen/search_bar_margin"
|
android:layout_marginEnd="@dimen/search_bar_margin"
|
||||||
android:layout_marginBottom="@dimen/search_bar_margin_bottom"
|
android:layout_marginBottom="@dimen/search_bar_margin_bottom">
|
||||||
app:layout_scrollFlags="scroll|enterAlways">
|
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:id="@+id/search_bar"
|
android:id="@+id/search_bar"
|
||||||
|
|||||||
@@ -5254,6 +5254,8 @@
|
|||||||
<string name="accessibility_summary_state_stopped">Not working. Tap for info.</string>
|
<string name="accessibility_summary_state_stopped">Not working. Tap for info.</string>
|
||||||
<!-- Accessibility service's description when enabled but not running (like maybe it crashed). -->
|
<!-- Accessibility service's description when enabled but not running (like maybe it crashed). -->
|
||||||
<string name="accessibility_description_state_stopped">This service is malfunctioning.</string>
|
<string name="accessibility_description_state_stopped">This service is malfunctioning.</string>
|
||||||
|
<!-- Title for the accessibility shortcuts settings page. [CHAR LIMIT=50] -->
|
||||||
|
<string name="accessibility_shortcuts_settings_title">Accessibility shortcuts</string>
|
||||||
|
|
||||||
<!-- Title for the preference to show a tile for a particular feature in the Quick Settings pane. [CHAR LIMIT=NONE] -->
|
<!-- Title for the preference to show a tile for a particular feature in the Quick Settings pane. [CHAR LIMIT=NONE] -->
|
||||||
<string name="enable_quick_setting">Show in Quick Settings</string>
|
<string name="enable_quick_setting">Show in Quick Settings</string>
|
||||||
@@ -12142,6 +12144,10 @@
|
|||||||
<string name="switch_to_removable_notification_no_carrier_name">Switched to another carrier</string>
|
<string name="switch_to_removable_notification_no_carrier_name">Switched to another carrier</string>
|
||||||
<!-- Message in a push notification indicating that the user's phone has connected to a different mobile network. [CHAR LIMIT=NONE] -->
|
<!-- Message in a push notification indicating that the user's phone has connected to a different mobile network. [CHAR LIMIT=NONE] -->
|
||||||
<string name="network_changed_notification_text">Your mobile network has changed</string>
|
<string name="network_changed_notification_text">Your mobile network has changed</string>
|
||||||
|
<!-- Title on a push notification indicating that the user's device is capable of DSDS. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="dsds_notification_after_suw_title">Set up your other SIM</string>
|
||||||
|
<!-- Message in a push notification indicating that the user's device is capable of DSDS. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="dsds_notification_after_suw_text">Choose your active SIM or use 2 SIMs at once</string>
|
||||||
|
|
||||||
<!-- Strings for choose SIM activity -->
|
<!-- Strings for choose SIM activity -->
|
||||||
<!-- The title text of choose SIM activity. [CHAR LIMIT=NONE] -->
|
<!-- The title text of choose SIM activity. [CHAR LIMIT=NONE] -->
|
||||||
@@ -12580,8 +12586,10 @@
|
|||||||
<string name="view_airplane_safe_networks">View airplane mode networks</string>
|
<string name="view_airplane_safe_networks">View airplane mode networks</string>
|
||||||
<!-- Text of message for viewing the networks that are available in airplane mode. [CHAR LIMIT=60] -->
|
<!-- Text of message for viewing the networks that are available in airplane mode. [CHAR LIMIT=60] -->
|
||||||
<string name="viewing_airplane_mode_networks">Viewing airplane mode networks</string>
|
<string name="viewing_airplane_mode_networks">Viewing airplane mode networks</string>
|
||||||
<!-- Label text to turn off airplane mode. [CHAR LIMIT=40] -->
|
<!-- Slice title text for turning on networks (e.g. Wi-Fi). [CHAR LIMIT=40] -->
|
||||||
<string name="turn_off_airplane_mode">Turn off airplane mode</string>
|
<string name="turn_on_networks">Turn on networks</string>
|
||||||
|
<!-- Slice title text for turning off networks (e.g. Wi-Fi). [CHAR LIMIT=40] -->
|
||||||
|
<string name="turn_off_networks">Turn off networks</string>
|
||||||
<!-- Title for interrupting the voice call alert. [CHAR_LIMIT=NONE] -->
|
<!-- Title for interrupting the voice call alert. [CHAR_LIMIT=NONE] -->
|
||||||
<string name="reset_your_internet_title">Reset your internet?</string>
|
<string name="reset_your_internet_title">Reset your internet?</string>
|
||||||
<!-- Description for interrupting the voice call alert. [CHAR_LIMIT=NONE] -->
|
<!-- Description for interrupting the voice call alert. [CHAR_LIMIT=NONE] -->
|
||||||
|
|||||||
@@ -221,7 +221,6 @@
|
|||||||
<item name="colorPrimaryDark">@*android:color/primary_dark_device_default_settings_light</item>
|
<item name="colorPrimaryDark">@*android:color/primary_dark_device_default_settings_light</item>
|
||||||
<item name="android:windowLightStatusBar">true</item>
|
<item name="android:windowLightStatusBar">true</item>
|
||||||
<item name="android:navigationBarDividerColor">@*android:color/ripple_material_light</item>
|
<item name="android:navigationBarDividerColor">@*android:color/ripple_material_light</item>
|
||||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Settings.ContextualCard" parent="Theme.Settings.Home">
|
<style name="Theme.Settings.ContextualCard" parent="Theme.Settings.Home">
|
||||||
|
|||||||
@@ -29,15 +29,7 @@
|
|||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="screen_reader_category"
|
android:key="screen_reader_category"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:title="@string/screen_reader_category_title">
|
android:title="@string/screen_reader_category_title"/>
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:fragment="com.android.settings.tts.TextToSpeechSettings"
|
|
||||||
android:key="tts_settings_preference"
|
|
||||||
android:persistent="false"
|
|
||||||
android:title="@string/tts_settings_title"
|
|
||||||
settings:controller="com.android.settings.language.TtsPreferenceController"/>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="display_category"
|
android:key="display_category"
|
||||||
@@ -129,6 +121,25 @@
|
|||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<!-- TODO(b/174829936): Add title for shortcuts settings category. -->
|
||||||
|
<PreferenceCategory android:persistent="false">
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:fragment="com.android.settings.accessibility.ShortcutsSettingsFragment"
|
||||||
|
android:key="accessibility_shortcuts_preference_screen"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/accessibility_shortcuts_settings_title"
|
||||||
|
settings:searchable="true"/>
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:fragment="com.android.settings.tts.TextToSpeechSettings"
|
||||||
|
android:key="tts_settings_preference"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/tts_settings_title"
|
||||||
|
settings:controller="com.android.settings.language.TtsPreferenceController"/>
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="experimental_category"
|
android:key="experimental_category"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
|
|||||||
30
res/xml/accessibility_shortcuts_settings.xml
Normal file
30
res/xml/accessibility_shortcuts_settings.xml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:key="accessibility_shortcuts_settings"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/accessibility_shortcuts_settings_title">
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="accessibility_shortcut_preference"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/accessibility_shortcut_service_on_lock_screen_title"
|
||||||
|
android:summary="@string/accessibility_shortcut_description"
|
||||||
|
settings:controller="com.android.settings.accessibility.AccessibilityShortcutPreferenceController"/>
|
||||||
|
</PreferenceScreen>
|
||||||
@@ -32,7 +32,6 @@
|
|||||||
android:fragment="com.android.settings.fuelgauge.PowerUsageAdvanced"
|
android:fragment="com.android.settings.fuelgauge.PowerUsageAdvanced"
|
||||||
android:key="battery_usage_summary"
|
android:key="battery_usage_summary"
|
||||||
android:title="@string/advanced_battery_preference_title"
|
android:title="@string/advanced_battery_preference_title"
|
||||||
android:icon="@drawable/ic_chevron_right_24dp"
|
|
||||||
settings:searchable="false" />
|
settings:searchable="false" />
|
||||||
|
|
||||||
<com.android.settings.widget.CardPreference
|
<com.android.settings.widget.CardPreference
|
||||||
|
|||||||
@@ -372,6 +372,9 @@ public class AccessibilitySettings extends DashboardFragment {
|
|||||||
} else {
|
} else {
|
||||||
getPreferenceScreen().addPreference(downloadedServicesCategory);
|
getPreferenceScreen().addPreference(downloadedServicesCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hide screen reader category if it is empty.
|
||||||
|
updatePreferenceCategoryVisibility(CATEGORY_SCREEN_READER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<RestrictedPreference> getInstalledAccessibilityList(Context context) {
|
private List<RestrictedPreference> getInstalledAccessibilityList(Context context) {
|
||||||
@@ -452,6 +455,16 @@ public class AccessibilitySettings extends DashboardFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the visibility of a category according to its child preference count.
|
||||||
|
*
|
||||||
|
* @param categoryKey The key of the category which needs to check
|
||||||
|
*/
|
||||||
|
private void updatePreferenceCategoryVisibility(String categoryKey) {
|
||||||
|
final PreferenceCategory category = mCategoryToPrefCategoryMap.get(categoryKey);
|
||||||
|
category.setVisible(category.getPreferenceCount() != 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates preferences related to system configurations.
|
* Updates preferences related to system configurations.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* 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.accessibility;
|
||||||
|
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
|
|
||||||
|
/** Accessibility settings for accessibility shortcuts. */
|
||||||
|
public class ShortcutsSettingsFragment extends DashboardFragment {
|
||||||
|
|
||||||
|
private static final String TAG = "ShortcutsSettingsFragment";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetricsCategory() {
|
||||||
|
return SettingsEnums.ACCESSIBILITY_SHORTCUTS_SETTINGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getPreferenceScreenResId() {
|
||||||
|
return R.xml.accessibility_shortcuts_settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getLogTag() {
|
||||||
|
return TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
|
new BaseSearchIndexProvider(R.xml.accessibility_shortcuts_settings);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -66,7 +66,8 @@ public class UsbDetailsTranscodeMtpController extends UsbDetailsController
|
|||||||
mFragment.getPreferenceScreen().removePreference(mPreferenceCategory);
|
mFragment.getPreferenceScreen().removePreference(mPreferenceCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
mSwitchPreference.setChecked(SystemProperties.getBoolean(TRANSCODE_MTP_SYS_PROP_KEY, true));
|
mSwitchPreference.setChecked(
|
||||||
|
SystemProperties.getBoolean(TRANSCODE_MTP_SYS_PROP_KEY, false));
|
||||||
mPreferenceCategory.setEnabled(
|
mPreferenceCategory.setEnabled(
|
||||||
connected && isDeviceInFileTransferMode(functions, dataRole));
|
connected && isDeviceInFileTransferMode(functions, dataRole));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,11 +46,7 @@ public class SettingsHomepageActivity extends FragmentActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.settings_homepage_container);
|
setContentView(R.layout.settings_homepage_container);
|
||||||
final View root = findViewById(R.id.settings_homepage_container);
|
|
||||||
root.setSystemUiVisibility(
|
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
|
||||||
|
|
||||||
final View appBar = findViewById(R.id.app_bar_container);
|
final View appBar = findViewById(R.id.app_bar_container);
|
||||||
appBar.setMinimumHeight(getSearchBoxHeight());
|
appBar.setMinimumHeight(getSearchBoxHeight());
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -33,6 +34,7 @@ import androidx.slice.Slice;
|
|||||||
import androidx.slice.builders.ListBuilder;
|
import androidx.slice.builders.ListBuilder;
|
||||||
import androidx.slice.builders.ListBuilder.RowBuilder;
|
import androidx.slice.builders.ListBuilder.RowBuilder;
|
||||||
import androidx.slice.builders.SliceAction;
|
import androidx.slice.builders.SliceAction;
|
||||||
|
import androidx.slice.core.SliceHints;
|
||||||
|
|
||||||
import com.android.settings.AirplaneModeEnabler;
|
import com.android.settings.AirplaneModeEnabler;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -41,7 +43,6 @@ import com.android.settings.slices.CustomSliceRegistry;
|
|||||||
import com.android.settings.slices.CustomSliceable;
|
import com.android.settings.slices.CustomSliceable;
|
||||||
import com.android.settings.slices.SliceBackgroundWorker;
|
import com.android.settings.slices.SliceBackgroundWorker;
|
||||||
import com.android.settings.slices.SliceBroadcastReceiver;
|
import com.android.settings.slices.SliceBroadcastReceiver;
|
||||||
import com.android.settingslib.WirelessUtils;
|
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
@@ -49,7 +50,6 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
/**
|
/**
|
||||||
* {@link CustomSliceable} for airplane-safe networks, used by generic clients.
|
* {@link CustomSliceable} for airplane-safe networks, used by generic clients.
|
||||||
*/
|
*/
|
||||||
// TODO(b/173413889): Need to update the slice to Button style.
|
|
||||||
public class AirplaneSafeNetworksSlice implements CustomSliceable,
|
public class AirplaneSafeNetworksSlice implements CustomSliceable,
|
||||||
AirplaneModeEnabler.OnAirplaneModeChangedListener {
|
AirplaneModeEnabler.OnAirplaneModeChangedListener {
|
||||||
|
|
||||||
@@ -60,26 +60,29 @@ public class AirplaneSafeNetworksSlice implements CustomSliceable,
|
|||||||
/**
|
/**
|
||||||
* Annotation for different action of the slice.
|
* Annotation for different action of the slice.
|
||||||
*
|
*
|
||||||
* {@code VIEW_AIRPLANE_SAFE_NETWORKS} for action of turning on Wi-Fi.
|
* {@code TURN_ON_NETWORKS} for action of turning on Wi-Fi networks.
|
||||||
* {@code TURN_OFF_AIRPLANE_MODE} for action of turning off Airplane Mode.
|
* {@code TURN_OFF_NETWORKS} for action of turning off Wi-Fi networks.
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@IntDef(value = {
|
@IntDef(value = {
|
||||||
Action.VIEW_AIRPLANE_SAFE_NETWORKS,
|
Action.TURN_ON_NETWORKS,
|
||||||
Action.TURN_OFF_AIRPLANE_MODE,
|
Action.TURN_OFF_NETWORKS,
|
||||||
})
|
})
|
||||||
public @interface Action {
|
public @interface Action {
|
||||||
int VIEW_AIRPLANE_SAFE_NETWORKS = 1;
|
int TURN_ON_NETWORKS = 1;
|
||||||
int TURN_OFF_AIRPLANE_MODE = 2;
|
int TURN_OFF_NETWORKS = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final AirplaneModeEnabler mAirplaneModeEnabler;
|
private final AirplaneModeEnabler mAirplaneModeEnabler;
|
||||||
private final WifiManager mWifiManager;
|
private final WifiManager mWifiManager;
|
||||||
|
|
||||||
|
private boolean mIsAirplaneModeOn;
|
||||||
|
|
||||||
public AirplaneSafeNetworksSlice(Context context) {
|
public AirplaneSafeNetworksSlice(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mAirplaneModeEnabler = new AirplaneModeEnabler(context, this);
|
mAirplaneModeEnabler = new AirplaneModeEnabler(context, this);
|
||||||
|
mIsAirplaneModeOn = mAirplaneModeEnabler.isAirplaneModeOn();
|
||||||
mWifiManager = mContext.getSystemService(WifiManager.class);
|
mWifiManager = mContext.getSystemService(WifiManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,15 +92,14 @@ public class AirplaneSafeNetworksSlice implements CustomSliceable,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Slice getSlice() {
|
public Slice getSlice() {
|
||||||
if (!WirelessUtils.isAirplaneModeOn(mContext)) {
|
final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY);
|
||||||
return null;
|
if (mIsAirplaneModeOn) {
|
||||||
}
|
listBuilder.addRow(new RowBuilder()
|
||||||
|
|
||||||
return new ListBuilder(mContext, getUri(), ListBuilder.INFINITY)
|
|
||||||
.addRow(new RowBuilder()
|
|
||||||
.setTitle(getTitle())
|
.setTitle(getTitle())
|
||||||
.setPrimaryAction(getSliceAction()))
|
.addEndItem(getEndIcon(), SliceHints.ICON_IMAGE)
|
||||||
.build();
|
.setPrimaryAction(getSliceAction()));
|
||||||
|
}
|
||||||
|
return listBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -108,21 +110,22 @@ public class AirplaneSafeNetworksSlice implements CustomSliceable,
|
|||||||
@Override
|
@Override
|
||||||
public void onNotifyChange(Intent intent) {
|
public void onNotifyChange(Intent intent) {
|
||||||
final int action = intent.getIntExtra(ACTION_INTENT_EXTRA, 0);
|
final int action = intent.getIntExtra(ACTION_INTENT_EXTRA, 0);
|
||||||
if (action == Action.VIEW_AIRPLANE_SAFE_NETWORKS) {
|
if (action == Action.TURN_ON_NETWORKS) {
|
||||||
if (!mWifiManager.isWifiEnabled()) {
|
if (!mWifiManager.isWifiEnabled()) {
|
||||||
logd("Action: turn on WiFi");
|
logd("Action: turn on Wi-Fi networks");
|
||||||
mWifiManager.setWifiEnabled(true);
|
mWifiManager.setWifiEnabled(true);
|
||||||
}
|
}
|
||||||
} else if (action == Action.TURN_OFF_AIRPLANE_MODE) {
|
} else if (action == Action.TURN_OFF_NETWORKS) {
|
||||||
if (WirelessUtils.isAirplaneModeOn(mContext)) {
|
if (mWifiManager.isWifiEnabled()) {
|
||||||
logd("Action: turn off Airplane mode");
|
logd("Action: turn off Wi-Fi networks");
|
||||||
mAirplaneModeEnabler.setAirplaneMode(false);
|
mWifiManager.setWifiEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
|
public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
|
||||||
|
mIsAirplaneModeOn = isAirplaneModeOn;
|
||||||
final AirplaneSafeNetworksWorker worker = SliceBackgroundWorker.getInstance(getUri());
|
final AirplaneSafeNetworksWorker worker = SliceBackgroundWorker.getInstance(getUri());
|
||||||
if (worker != null) {
|
if (worker != null) {
|
||||||
worker.updateSlice();
|
worker.updateSlice();
|
||||||
@@ -140,15 +143,26 @@ public class AirplaneSafeNetworksSlice implements CustomSliceable,
|
|||||||
@Action
|
@Action
|
||||||
private int getAction() {
|
private int getAction() {
|
||||||
return mWifiManager.isWifiEnabled()
|
return mWifiManager.isWifiEnabled()
|
||||||
? Action.TURN_OFF_AIRPLANE_MODE
|
? Action.TURN_OFF_NETWORKS
|
||||||
: Action.VIEW_AIRPLANE_SAFE_NETWORKS;
|
: Action.TURN_ON_NETWORKS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTitle() {
|
private String getTitle() {
|
||||||
return mContext.getText(
|
return mContext.getText(
|
||||||
(getAction() == Action.VIEW_AIRPLANE_SAFE_NETWORKS)
|
(getAction() == Action.TURN_ON_NETWORKS)
|
||||||
? R.string.view_airplane_safe_networks
|
? R.string.turn_on_networks
|
||||||
: R.string.turn_off_airplane_mode).toString();
|
: R.string.turn_off_networks).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private IconCompat getEndIcon() {
|
||||||
|
final Drawable drawable = mContext.getDrawable(
|
||||||
|
(getAction() == Action.TURN_ON_NETWORKS) ? R.drawable.ic_airplane_safe_networks_24dp
|
||||||
|
: R.drawable.ic_airplanemode_active);
|
||||||
|
if (drawable == null) {
|
||||||
|
return Utils.createIconWithDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
|
}
|
||||||
|
drawable.setTintList(Utils.getColorAttr(mContext, android.R.attr.colorAccent));
|
||||||
|
return Utils.createIconWithDrawable(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SliceAction getSliceAction() {
|
private SliceAction getSliceAction() {
|
||||||
@@ -156,8 +170,7 @@ public class AirplaneSafeNetworksSlice implements CustomSliceable,
|
|||||||
0 /* requestCode */, getIntent(),
|
0 /* requestCode */, getIntent(),
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
||||||
final IconCompat icon = Utils.createIconWithDrawable(new ColorDrawable(Color.TRANSPARENT));
|
final IconCompat icon = Utils.createIconWithDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
return SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.ACTION_WITH_LABEL,
|
return SliceAction.create(pendingIntent, icon, ListBuilder.ACTION_WITH_LABEL, getTitle());
|
||||||
getTitle());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -66,12 +66,15 @@ public class SimActivationNotifier {
|
|||||||
value = {
|
value = {
|
||||||
NotificationType.NETWORK_CONFIG,
|
NotificationType.NETWORK_CONFIG,
|
||||||
NotificationType.SWITCH_TO_REMOVABLE_SLOT,
|
NotificationType.SWITCH_TO_REMOVABLE_SLOT,
|
||||||
|
NotificationType.ENABLE_DSDS,
|
||||||
})
|
})
|
||||||
public @interface NotificationType {
|
public @interface NotificationType {
|
||||||
// The notification to remind users to config network Settings.
|
// The notification to remind users to config network Settings.
|
||||||
int NETWORK_CONFIG = 1;
|
int NETWORK_CONFIG = 1;
|
||||||
// The notification to notify users that the device is switched to the removable slot.
|
// The notification to notify users that the device is switched to the removable slot.
|
||||||
int SWITCH_TO_REMOVABLE_SLOT = 2;
|
int SWITCH_TO_REMOVABLE_SLOT = 2;
|
||||||
|
// The notification to notify users that the device is capable of DSDS.
|
||||||
|
int ENABLE_DSDS = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
@@ -120,8 +123,8 @@ public class SimActivationNotifier {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CharSequence displayName = SubscriptionUtil.getUniqueSubscriptionDisplayName(
|
CharSequence displayName =
|
||||||
activeRemovableSub, mContext);
|
SubscriptionUtil.getUniqueSubscriptionDisplayName(activeRemovableSub, mContext);
|
||||||
String carrierName =
|
String carrierName =
|
||||||
TextUtils.isEmpty(displayName)
|
TextUtils.isEmpty(displayName)
|
||||||
? mContext.getString(R.string.sim_card_label)
|
? mContext.getString(R.string.sim_card_label)
|
||||||
@@ -135,7 +138,8 @@ public class SimActivationNotifier {
|
|||||||
TaskStackBuilder.create(mContext).addNextIntent(clickIntent);
|
TaskStackBuilder.create(mContext).addNextIntent(clickIntent);
|
||||||
PendingIntent contentIntent =
|
PendingIntent contentIntent =
|
||||||
stackBuilder.getPendingIntent(
|
stackBuilder.getPendingIntent(
|
||||||
0 /* requestCode */, PendingIntent.FLAG_UPDATE_CURRENT);
|
0 /* requestCode */,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
||||||
|
|
||||||
Notification.Builder builder =
|
Notification.Builder builder =
|
||||||
new Notification.Builder(mContext, SIM_SETUP_CHANNEL_ID)
|
new Notification.Builder(mContext, SIM_SETUP_CHANNEL_ID)
|
||||||
@@ -155,7 +159,8 @@ public class SimActivationNotifier {
|
|||||||
TaskStackBuilder.create(mContext).addNextIntent(clickIntent);
|
TaskStackBuilder.create(mContext).addNextIntent(clickIntent);
|
||||||
PendingIntent contentIntent =
|
PendingIntent contentIntent =
|
||||||
stackBuilder.getPendingIntent(
|
stackBuilder.getPendingIntent(
|
||||||
0 /* requestCode */, PendingIntent.FLAG_UPDATE_CURRENT);
|
0 /* requestCode */,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
||||||
String titleText =
|
String titleText =
|
||||||
TextUtils.isEmpty(carrierName)
|
TextUtils.isEmpty(carrierName)
|
||||||
? mContext.getString(
|
? mContext.getString(
|
||||||
@@ -178,6 +183,33 @@ public class SimActivationNotifier {
|
|||||||
mNotificationManager.notify(SWITCH_TO_REMOVABLE_SLOT_NOTIFICATION_ID, builder.build());
|
mNotificationManager.notify(SWITCH_TO_REMOVABLE_SLOT_NOTIFICATION_ID, builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Sends a push notification for enabling DSDS. */
|
||||||
|
public void sendEnableDsdsNotification() {
|
||||||
|
Intent parentIntent = new Intent(mContext, Settings.MobileNetworkListActivity.class);
|
||||||
|
|
||||||
|
Intent clickIntent = new Intent(mContext, DsdsDialogActivity.class);
|
||||||
|
|
||||||
|
TaskStackBuilder stackBuilder =
|
||||||
|
TaskStackBuilder.create(mContext)
|
||||||
|
.addNextIntentWithParentStack(parentIntent)
|
||||||
|
.addNextIntent(clickIntent);
|
||||||
|
PendingIntent contentIntent =
|
||||||
|
stackBuilder.getPendingIntent(
|
||||||
|
0 /* requestCode */,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
||||||
|
|
||||||
|
Notification.Builder builder =
|
||||||
|
new Notification.Builder(mContext, SIM_SETUP_CHANNEL_ID)
|
||||||
|
.setContentTitle(
|
||||||
|
mContext.getString(R.string.dsds_notification_after_suw_title))
|
||||||
|
.setContentText(
|
||||||
|
mContext.getString(R.string.dsds_notification_after_suw_text))
|
||||||
|
.setContentIntent(contentIntent)
|
||||||
|
.setSmallIcon(R.drawable.ic_sim_alert)
|
||||||
|
.setAutoCancel(true);
|
||||||
|
mNotificationManager.notify(SIM_ACTIVATION_NOTIFICATION_ID, builder.build());
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private SubscriptionInfo getActiveRemovableSub() {
|
private SubscriptionInfo getActiveRemovableSub() {
|
||||||
SubscriptionManager subscriptionManager =
|
SubscriptionManager subscriptionManager =
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ public class SimNotificationService extends JobService {
|
|||||||
case SimActivationNotifier.NotificationType.SWITCH_TO_REMOVABLE_SLOT:
|
case SimActivationNotifier.NotificationType.SWITCH_TO_REMOVABLE_SLOT:
|
||||||
new SimActivationNotifier(this).sendSwitchedToRemovableSlotNotification();
|
new SimActivationNotifier(this).sendSwitchedToRemovableSlotNotification();
|
||||||
break;
|
break;
|
||||||
|
case SimActivationNotifier.NotificationType.ENABLE_DSDS:
|
||||||
|
new SimActivationNotifier(this).sendEnableDsdsNotification();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Log.e(TAG, "Invalid notification type: " + notificationType);
|
Log.e(TAG, "Invalid notification type: " + notificationType);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -50,7 +50,13 @@ public class SimSlotChangeHandler {
|
|||||||
private static final String TAG = "SimSlotChangeHandler";
|
private static final String TAG = "SimSlotChangeHandler";
|
||||||
|
|
||||||
private static final String EUICC_PREFS = "euicc_prefs";
|
private static final String EUICC_PREFS = "euicc_prefs";
|
||||||
|
// Shared preference keys
|
||||||
private static final String KEY_REMOVABLE_SLOT_STATE = "removable_slot_state";
|
private static final String KEY_REMOVABLE_SLOT_STATE = "removable_slot_state";
|
||||||
|
private static final String KEY_SUW_PSIM_ACTION = "suw_psim_action";
|
||||||
|
// User's last removable SIM insertion / removal action during SUW.
|
||||||
|
private static final int LAST_USER_ACTION_IN_SUW_NONE = 0;
|
||||||
|
private static final int LAST_USER_ACTION_IN_SUW_INSERT = 1;
|
||||||
|
private static final int LAST_USER_ACTION_IN_SUW_REMOVE = 2;
|
||||||
|
|
||||||
private static volatile SimSlotChangeHandler sSlotChangeHandler;
|
private static volatile SimSlotChangeHandler sSlotChangeHandler;
|
||||||
|
|
||||||
@@ -107,6 +113,47 @@ public class SimSlotChangeHandler {
|
|||||||
Log.i(TAG, "Do nothing on slot status changes.");
|
Log.i(TAG, "Do nothing on slot status changes.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onSuwFinish(Context context) {
|
||||||
|
init(context);
|
||||||
|
|
||||||
|
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||||
|
throw new IllegalStateException("Cannot be called from main thread.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mTelMgr.getActiveModemCount() > 1) {
|
||||||
|
Log.i(TAG, "The device is already in DSDS mode. Do nothing.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UiccSlotInfo removableSlotInfo = getRemovableUiccSlotInfo();
|
||||||
|
if (removableSlotInfo == null) {
|
||||||
|
Log.e(TAG, "Unable to find the removable slot. Do nothing.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean embeddedSimExist = getGroupedEmbeddedSubscriptions().size() != 0;
|
||||||
|
int removableSlotAction = getSuwRemovableSlotAction(mContext);
|
||||||
|
setSuwRemovableSlotAction(mContext, LAST_USER_ACTION_IN_SUW_NONE);
|
||||||
|
|
||||||
|
if (embeddedSimExist
|
||||||
|
&& removableSlotInfo.getCardStateInfo() == UiccSlotInfo.CARD_STATE_INFO_PRESENT) {
|
||||||
|
if (mTelMgr.isMultiSimSupported() == TelephonyManager.MULTISIM_ALLOWED) {
|
||||||
|
Log.i(TAG, "DSDS condition satisfied. Show notification.");
|
||||||
|
SimNotificationService.scheduleSimNotification(
|
||||||
|
mContext, SimActivationNotifier.NotificationType.ENABLE_DSDS);
|
||||||
|
} else if (removableSlotAction == LAST_USER_ACTION_IN_SUW_INSERT) {
|
||||||
|
Log.i(
|
||||||
|
TAG,
|
||||||
|
"Both removable SIM and eSIM are present. DSDS condition doesn't"
|
||||||
|
+ " satisfied. User inserted pSIM during SUW. Show choose SIM"
|
||||||
|
+ " screen.");
|
||||||
|
startChooseSimActivity(true);
|
||||||
|
}
|
||||||
|
} else if (removableSlotAction == LAST_USER_ACTION_IN_SUW_REMOVE) {
|
||||||
|
handleSimRemove(removableSlotInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void init(Context context) {
|
private void init(Context context) {
|
||||||
mSubMgr =
|
mSubMgr =
|
||||||
(SubscriptionManager)
|
(SubscriptionManager)
|
||||||
@@ -116,11 +163,11 @@ public class SimSlotChangeHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleSimInsert(UiccSlotInfo removableSlotInfo) {
|
private void handleSimInsert(UiccSlotInfo removableSlotInfo) {
|
||||||
Log.i(TAG, "Detect SIM inserted.");
|
Log.i(TAG, "Handle SIM inserted.");
|
||||||
|
|
||||||
if (!isSuwFinished(mContext)) {
|
if (!isSuwFinished(mContext)) {
|
||||||
// TODO(b/170508680): Store the action and handle it after SUW is finished.
|
|
||||||
Log.i(TAG, "Still in SUW. Handle SIM insertion after SUW is finished");
|
Log.i(TAG, "Still in SUW. Handle SIM insertion after SUW is finished");
|
||||||
|
setSuwRemovableSlotAction(mContext, LAST_USER_ACTION_IN_SUW_INSERT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,11 +203,11 @@ public class SimSlotChangeHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleSimRemove(UiccSlotInfo removableSlotInfo) {
|
private void handleSimRemove(UiccSlotInfo removableSlotInfo) {
|
||||||
Log.i(TAG, "Detect SIM removed.");
|
Log.i(TAG, "Handle SIM removed.");
|
||||||
|
|
||||||
if (!isSuwFinished(mContext)) {
|
if (!isSuwFinished(mContext)) {
|
||||||
// TODO(b/170508680): Store the action and handle it after SUW is finished.
|
|
||||||
Log.i(TAG, "Still in SUW. Handle SIM removal after SUW is finished");
|
Log.i(TAG, "Still in SUW. Handle SIM removal after SUW is finished");
|
||||||
|
setSuwRemovableSlotAction(mContext, LAST_USER_ACTION_IN_SUW_REMOVE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,6 +242,16 @@ public class SimSlotChangeHandler {
|
|||||||
prefs.edit().putInt(KEY_REMOVABLE_SLOT_STATE, state).apply();
|
prefs.edit().putInt(KEY_REMOVABLE_SLOT_STATE, state).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getSuwRemovableSlotAction(Context context) {
|
||||||
|
final SharedPreferences prefs = context.getSharedPreferences(EUICC_PREFS, MODE_PRIVATE);
|
||||||
|
return prefs.getInt(KEY_SUW_PSIM_ACTION, LAST_USER_ACTION_IN_SUW_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSuwRemovableSlotAction(Context context, int action) {
|
||||||
|
final SharedPreferences prefs = context.getSharedPreferences(EUICC_PREFS, MODE_PRIVATE);
|
||||||
|
prefs.edit().putInt(KEY_SUW_PSIM_ACTION, action).apply();
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private UiccSlotInfo getRemovableUiccSlotInfo() {
|
private UiccSlotInfo getRemovableUiccSlotInfo() {
|
||||||
UiccSlotInfo[] slotInfos = mTelMgr.getUiccSlotsInfo();
|
UiccSlotInfo[] slotInfos = mTelMgr.getUiccSlotsInfo();
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* 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.sim.receivers;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settingslib.utils.ThreadUtils;
|
||||||
|
|
||||||
|
/** The receiver when SUW is finished. */
|
||||||
|
public class SuwFinishReceiver extends BroadcastReceiver {
|
||||||
|
private static final String TAG = "SuwFinishReceiver";
|
||||||
|
|
||||||
|
private final SimSlotChangeHandler mSlotChangeHandler = SimSlotChangeHandler.get();
|
||||||
|
private final Object mLock = new Object();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (!context.getResources().getBoolean(R.bool.config_handle_sim_slot_change)) {
|
||||||
|
Log.i(TAG, "The flag is off. Ignore SUW finish event.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final BroadcastReceiver.PendingResult pendingResult = goAsync();
|
||||||
|
ThreadUtils.postOnBackgroundThread(
|
||||||
|
() -> {
|
||||||
|
synchronized (mLock) {
|
||||||
|
Log.i(TAG, "Detected SUW finished. Checking slot events.");
|
||||||
|
mSlotChangeHandler.onSuwFinish(context.getApplicationContext());
|
||||||
|
}
|
||||||
|
ThreadUtils.postOnMainThread(pendingResult::finish);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* 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.accessibility;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.testutils.XmlTestUtils;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/** Tests for {@link ShortcutsSettingsFragment}. */
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class ShortcutsSettingsFragmentTest {
|
||||||
|
|
||||||
|
private Context mContext = ApplicationProvider.getApplicationContext();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getNonIndexableKeys_existInXmlLayout() {
|
||||||
|
final List<String> niks = ShortcutsSettingsFragment.SEARCH_INDEX_DATA_PROVIDER
|
||||||
|
.getNonIndexableKeys(mContext);
|
||||||
|
final List<String> keys =
|
||||||
|
XmlTestUtils.getKeysFromPreferenceXml(mContext,
|
||||||
|
R.xml.accessibility_shortcuts_settings);
|
||||||
|
|
||||||
|
assertThat(keys).containsAtLeastElementsIn(niks);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -123,7 +123,7 @@ public class UsbDetailsTranscodeMtpControllerTest {
|
|||||||
mUnderTest.refresh(true /* connected */, UsbManager.FUNCTION_MTP, POWER_ROLE_NONE,
|
mUnderTest.refresh(true /* connected */, UsbManager.FUNCTION_MTP, POWER_ROLE_NONE,
|
||||||
DATA_ROLE_NONE);
|
DATA_ROLE_NONE);
|
||||||
|
|
||||||
assertThat(getSwitchPreference().isChecked()).isTrue();
|
assertThat(getSwitchPreference().isChecked()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -162,7 +162,7 @@ public class UsbDetailsTranscodeMtpControllerTest {
|
|||||||
mUnderTest.displayPreference(mScreen);
|
mUnderTest.displayPreference(mScreen);
|
||||||
getSwitchPreference().performClick();
|
getSwitchPreference().performClick();
|
||||||
getSwitchPreference().performClick();
|
getSwitchPreference().performClick();
|
||||||
assertThat(SystemProperties.getBoolean(TRANSCODE_MTP_SYS_PROP_KEY, false)).isFalse();
|
assertThat(SystemProperties.getBoolean(TRANSCODE_MTP_SYS_PROP_KEY, true)).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import androidx.slice.widget.SliceLiveData;
|
|||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import com.android.settings.testutils.AirplaneModeRule;
|
|
||||||
import com.android.settings.testutils.ResourcesUtils;
|
import com.android.settings.testutils.ResourcesUtils;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -50,8 +49,6 @@ public class AirplaneSafeNetworksSliceTest {
|
|||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public MockitoRule mMocks = MockitoJUnit.rule();
|
public MockitoRule mMocks = MockitoJUnit.rule();
|
||||||
@Rule
|
|
||||||
public AirplaneModeRule mAirplaneModeRule = new AirplaneModeRule();
|
|
||||||
@Mock
|
@Mock
|
||||||
private WifiManager mWifiManager;
|
private WifiManager mWifiManager;
|
||||||
|
|
||||||
@@ -67,18 +64,18 @@ public class AirplaneSafeNetworksSliceTest {
|
|||||||
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
|
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
|
||||||
|
|
||||||
mAirplaneSafeNetworksSlice = new AirplaneSafeNetworksSlice(mContext);
|
mAirplaneSafeNetworksSlice = new AirplaneSafeNetworksSlice(mContext);
|
||||||
|
mAirplaneSafeNetworksSlice.onAirplaneModeChanged(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSlice_airplaneModeOff_shouldBeNull() {
|
public void getSlice_airplaneModeOff_shouldBeNotNull() {
|
||||||
mAirplaneModeRule.setAirplaneMode(false);
|
mAirplaneSafeNetworksSlice.onAirplaneModeChanged(false);
|
||||||
|
|
||||||
assertThat(mAirplaneSafeNetworksSlice.getSlice()).isNull();
|
assertThat(mAirplaneSafeNetworksSlice.getSlice()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSlice_wifiDisabled_shouldShowViewAirplaneSafeNetworks() {
|
public void getSlice_wifiDisabled_shouldShowTurnOnNetworks() {
|
||||||
mAirplaneModeRule.setAirplaneMode(true);
|
|
||||||
when(mWifiManager.isWifiEnabled()).thenReturn(false);
|
when(mWifiManager.isWifiEnabled()).thenReturn(false);
|
||||||
|
|
||||||
final Slice slice = mAirplaneSafeNetworksSlice.getSlice();
|
final Slice slice = mAirplaneSafeNetworksSlice.getSlice();
|
||||||
@@ -87,12 +84,11 @@ public class AirplaneSafeNetworksSliceTest {
|
|||||||
final SliceItem sliceTitle =
|
final SliceItem sliceTitle =
|
||||||
SliceMetadata.from(mContext, slice).getListContent().getHeader().getTitleItem();
|
SliceMetadata.from(mContext, slice).getListContent().getHeader().getTitleItem();
|
||||||
assertThat(sliceTitle.getText()).isEqualTo(
|
assertThat(sliceTitle.getText()).isEqualTo(
|
||||||
ResourcesUtils.getResourcesString(mContext, "view_airplane_safe_networks"));
|
ResourcesUtils.getResourcesString(mContext, "turn_on_networks"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSlice_wifiEnabled_shouldShowTurnOffAirplaneMode() {
|
public void getSlice_wifiEnabled_shouldShowTurnOffNetworks() {
|
||||||
mAirplaneModeRule.setAirplaneMode(true);
|
|
||||||
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
|
|
||||||
final Slice slice = mAirplaneSafeNetworksSlice.getSlice();
|
final Slice slice = mAirplaneSafeNetworksSlice.getSlice();
|
||||||
@@ -101,12 +97,11 @@ public class AirplaneSafeNetworksSliceTest {
|
|||||||
final SliceItem sliceTitle =
|
final SliceItem sliceTitle =
|
||||||
SliceMetadata.from(mContext, slice).getListContent().getHeader().getTitleItem();
|
SliceMetadata.from(mContext, slice).getListContent().getHeader().getTitleItem();
|
||||||
assertThat(sliceTitle.getText()).isEqualTo(
|
assertThat(sliceTitle.getText()).isEqualTo(
|
||||||
ResourcesUtils.getResourcesString(mContext, "turn_off_airplane_mode"));
|
ResourcesUtils.getResourcesString(mContext, "turn_off_networks"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onNotifyChange_viewAirplaneSafeNetworks_shouldSetWifiEnabled() {
|
public void onNotifyChange_turnOnNetworks_shouldSetWifiEnabled() {
|
||||||
mAirplaneModeRule.setAirplaneMode(true);
|
|
||||||
when(mWifiManager.isWifiEnabled()).thenReturn(false);
|
when(mWifiManager.isWifiEnabled()).thenReturn(false);
|
||||||
Intent intent = mAirplaneSafeNetworksSlice.getIntent();
|
Intent intent = mAirplaneSafeNetworksSlice.getIntent();
|
||||||
|
|
||||||
@@ -116,13 +111,12 @@ public class AirplaneSafeNetworksSliceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onNotifyChange_turnOffAirplaneMode_shouldSetAirplaneModeOff() {
|
public void onNotifyChange_turnOffNetworks_shouldSetWifiDisabled() {
|
||||||
mAirplaneModeRule.setAirplaneMode(true);
|
|
||||||
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
Intent intent = mAirplaneSafeNetworksSlice.getIntent();
|
Intent intent = mAirplaneSafeNetworksSlice.getIntent();
|
||||||
|
|
||||||
mAirplaneSafeNetworksSlice.onNotifyChange(intent);
|
mAirplaneSafeNetworksSlice.onNotifyChange(intent);
|
||||||
|
|
||||||
assertThat(mAirplaneModeRule.isAirplaneModeOn()).isFalse();
|
verify(mWifiManager).setWifiEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user