Merge "Consolidate wake-screen settings page"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8362fd6..6e1d8f8 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2776,13 +2776,17 @@
android:value="com.android.settings.webview.WebViewAppPicker" />
</activity-alias>
- <activity android:name=".backup.BackupSettingsActivity"
+ <provider
+ android:name=".backup.BackupSettingsContentProvider"
+ android:authorities="com.android.settings.backup.BackupSettingsContentProvider"
+ android:exported="true">
+ </provider>
+
+ <activity android:name=".backup.UserBackupSettingsActivity"
android:label="@string/privacy_settings_title"
- android:icon="@drawable/ic_settings_backup"
- android:parentActivityName="Settings">
+ android:icon="@drawable/ic_settings_backup">
<intent-filter android:priority="1">
<action android:name="android.settings.PRIVACY_SETTINGS" />
- <action android:name="android.settings.BACKUP_AND_RESET_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
@@ -2790,10 +2794,16 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.VOICE_LAUNCH" />
</intent-filter>
- <meta-data android:name="com.android.settings.summary"
- android:resource="@string/summary_empty"/>
- <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
- android:value="true" />
+ <!-- Mark the activity as a dynamic setting -->
+ <intent-filter>
+ <action android:name="com.android.settings.action.IA_SETTINGS" />
+ </intent-filter>
+ <!-- Tell Settings app which category it belongs to -->
+ <meta-data android:name="com.android.settings.category"
+ android:value="com.android.settings.category.ia.system" />
+ <meta-data android:name="com.android.settings.summary_uri"
+ android:value="content://com.android.settings.backup.BackupSettingsContentProvider/summary" />
+ <meta-data android:name="com.android.settings.order" android:value="-60"/>
</activity>
<activity
diff --git a/protos/contextual_card_list.proto b/protos/contextual_card_list.proto
index 5645c87..37383ba 100644
--- a/protos/contextual_card_list.proto
+++ b/protos/contextual_card_list.proto
@@ -18,7 +18,7 @@
SUGGESTION = 1;
POSSIBLE = 2;
IMPORTANT = 3;
- EXCLUSIVE = 4;
+ EXCLUSIVE = 4 [deprecated = true];
DEFERRED_SETUP = 5;
}
diff --git a/res/layout/manage_applications_apps.xml b/res/layout/manage_applications_apps.xml
index c2f58c3..021a61e 100644
--- a/res/layout/manage_applications_apps.xml
+++ b/res/layout/manage_applications_apps.xml
@@ -28,9 +28,9 @@
settings:layout_behavior="com.android.settings.widget.FloatingAppBarScrollingViewBehavior">
<FrameLayout
+ android:id="@+id/content_container"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingTop="@dimen/app_bar_height">
+ android:layout_height="match_parent">
<LinearLayout
android:id="@+id/list_container"
diff --git a/res/layout/radio_info.xml b/res/layout/radio_info.xml
index 100521e..fc8cc26 100644
--- a/res/layout/radio_info.xml
+++ b/res/layout/radio_info.xml
@@ -182,6 +182,14 @@
android:layout_height="wrap_content"
android:text="@string/cbrs_data_switch_string" />
+ <!-- Switch between SSSS(single sim single standby) and DSDS(dual sim dual standby). -->
+ <Switch android:id="@+id/dsds_switch"
+ android:textSize="14sp"
+ android:layout_marginTop="8dip"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/dsds_switch_string" />
+
<!-- Horizontal Rule -->
<View
android:layout_width="fill_parent"
diff --git a/res/values/config.xml b/res/values/config.xml
index e6856ac..0e46200 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -41,10 +41,6 @@
<!-- Whether to show Camera laser sensor switch in Developer Options -->
<bool name="config_show_camera_laser_sensor">false</bool>
- <!-- Whether to show Connected MAC Randomization in Developer Options
- as not all devices can support dynamic MAC address change. -->
- <bool name="config_wifi_support_connected_mac_randomization">false</bool>
-
<!-- Fully-qualified class name for the implementation of the FeatureFactory to be instantiated. -->
<string name="config_featureFactory" translatable="false">com.android.settings.overlay.FeatureFactoryImpl</string>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 525a5fb..fdc44c1 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -66,6 +66,21 @@
<!-- Cbrs enable disable flag. Only shown in diagnostic screen, so precise translation is not needed -->
<string name="cbrs_data_switch_string">Cbrs Data</string>
+ <!-- Dsds enable/disable flag. Only shown in diagnostic screen, so precise translation is not needed, [CHAR LIMIT=none] -->
+ <string name="dsds_switch_string">Enable DSDS</string>
+
+ <!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
+ <string name="dsds_dialog_title">Restart Device?</string>
+
+ <!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
+ <string name="dsds_dialog_message">You need to restart your device to change this setting.</string>
+
+ <!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
+ <string name="dsds_dialog_confirm">Restart</string>
+
+ <!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
+ <string name="dsds_dialog_cancel">Cancel</string>
+
<!-- Title for controlling on/off for Mobile phone's radio power. Only shown in diagnostic screen, so precise translation is not needed. -->
<string name="radio_info_radio_power">Mobile Radio Power</string>
@@ -1871,6 +1886,11 @@
<!-- Dialog content for NFC disclaimer: telling user NFC can exchange data when device is nearby other devices (for example: payment terminals, badge reader etc). [CHAR_LIMIT=NONE]-->
<string name="nfc_disclaimer_content">NFC exchanges data between this device and other nearby devices or targets, such as payment terminals, access readers, and interactive ads or tags.</string>
+ <!-- Used in the settings screen to secure NFC [CHAR LIMIT=NONE] -->
+ <string name="nfc_secure_settings_title">Secure NFC</string>
+ <!-- Description of Secure NFC in the 1st level settings screen. [CHAR LIMIT=NONE] -->
+ <string name="nfc_secure_toggle_summary" product="default">Allow NFC Payment and Transit use only when screen is unlocked</string>
+
<!-- Used to enter the Android Beam sharing preferences screen. This phrase is a trademark. [CHAR LIMIT=32] -->
<string name="android_beam_settings_title">Android Beam</string>
<!-- Used to describe the on state of the Android Beam feature [CHAR LIMIT=NONE] -->
@@ -1878,7 +1898,7 @@
<!-- Used to describe the off state of the Android Beam feature [CHAR LIMIT=NONE] -->
<string name="android_beam_off_summary">Off</string>
<!-- Used to describe the enabled state of the Android Beam feature when NFC, which it relies on, is turned off [CHAR LIMIT=NONE] -->
- <string name="android_beam_disabled_summary">Unavailable because NFC is turned off</string>
+ <string name="nfc_disabled_summary">Unavailable because NFC is turned off</string>
<!-- Used in the Android Beam sharing preferences screen. This phrase is a trademark. [CHAR LIMIT=32] -->
<string name="android_beam_label">Android Beam</string>
<!-- Explanation of the Android Beam feature in the Android Beam settings panel. The use of "beam" here is as a verb and not considered trademarked. [CHAR LIMIT=NONE] -->
@@ -7402,12 +7422,6 @@
<!-- Do not disturb: Label for button that will turn off zen mode. [CHAR LIMIT=30] -->
<string name="zen_mode_button_turn_off">Turn off now</string>
- <!-- Setting title for controlling how caption text display in real time [CHAR LIMIT=40]-->
- <string name="live_captions_title">Live Caption</string>
-
- <!-- Setting summary for controlling how caption text display in real time [CHAR LIMIT=NONE]-->
- <string name="live_captions_summary">Auto-convert on-device audio to captions</string>
-
<!-- [CHAR LIMIT=110] Zen mode settings footer: Footer showing end time of DND -->
<string name="zen_mode_settings_dnd_manual_end_time">Do Not Disturb is on until <xliff:g id="formatted_time" example="7:00 AM">%s</xliff:g></string>
@@ -7592,6 +7606,12 @@
<!-- Configure Notifications: Work profile section header [CHAR LIMIT=30] -->
<string name="profile_section_header">Work notifications</string>
+ <!-- Configure Notifications: setting title [CHAR LIMIT=80] -->
+ <string name="hide_silent_icons_title">Hide silent notification status icons</string>
+
+ <!-- Configure Notifications: setting summary [CHAR LIMIT=NONE] -->
+ <string name="hide_silent_icons_summary">Hide icons for silent notifications in the status bar</string>
+
<!-- Configure Notifications: Title for the notification badging option. [CHAR LIMIT=30 BACKUP_MESSAGE_ID=5125022693565388760] -->
<string name="notification_badging_title">Allow notification dots</string>
@@ -10543,7 +10563,7 @@
<!-- Title for the top level Privacy Settings [CHAR LIMIT=30]-->
<string name="privacy_dashboard_title">Privacy</string>
<!-- Summary for the top level Privacy Settings [CHAR LIMIT=NONE]-->
- <string name="privacy_dashboard_summary">Permissions, activity controls, data shown on screen</string>
+ <string name="privacy_dashboard_summary">Permissions, web activity, personal data</string>
<!-- Label for button in contextual card for users to remove the card [CHAR LIMIT=30] -->
<string name="contextual_card_dismiss_remove">Remove</string>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index b3e1704..cc07ce1 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -124,12 +124,6 @@
android:key="audio_and_captions_category"
android:title="@string/audio_and_captions_category_title">
- <Preference
- android:key="live_caption"
- android:title="@string/live_captions_title"
- android:summary="@string/live_captions_summary"
- settings:controller="com.android.settings.accessibility.LiveCaptionPreferenceController"/>
-
<SwitchPreference
android:key="toggle_master_mono"
android:title="@string/accessibility_toggle_master_mono_title"
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index e4d948b..ca82609 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -26,6 +26,12 @@
android:summary="@string/summary_placeholder"
settings:searchable="false"/>
+ <SwitchPreference
+ android:key="hide_silent_icons"
+ android:title="@string/hide_silent_icons_title"
+ android:summary="@string/hide_silent_icons_summary"
+ settings:controller="com.android.settings.notification.SilentStatusBarPreferenceController" />
+
<!-- Notification badging -->
<SwitchPreference
android:key="notification_badging"
diff --git a/res/xml/connected_devices_advanced.xml b/res/xml/connected_devices_advanced.xml
index 28e9fdc..ab8967d 100644
--- a/res/xml/connected_devices_advanced.xml
+++ b/res/xml/connected_devices_advanced.xml
@@ -44,6 +44,14 @@
android:icon="@drawable/ic_android"
android:order="-6"/>
+ <SwitchPreference
+ android:key="nfc_secure_settings"
+ android:title="@string/nfc_secure_settings_title"
+ settings:controller="com.android.settings.nfc.SecureNfcPreferenceController"
+ android:icon="@drawable/ic_nfc"
+ android:summary="@string/nfc_secure_toggle_summary"
+ android:order="-7"/>
+
<com.android.settingslib.RestrictedPreference
android:key="connected_device_printing"
android:title="@string/print_settings"
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 9b43723..d7fcaec 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -222,11 +222,6 @@
android:summary="@string/wifi_verbose_logging_summary" />
<SwitchPreference
- android:key="wifi_connected_mac_randomization"
- android:title="@string/wifi_connected_mac_randomization"
- android:summary="@string/wifi_connected_mac_randomization_summary" />
-
- <SwitchPreference
android:key="mobile_data_always_on"
android:title="@string/mobile_data_always_on"
android:summary="@string/mobile_data_always_on_summary" />
diff --git a/res/xml/system_dashboard_fragment.xml b/res/xml/system_dashboard_fragment.xml
index 1ca86ab..6a753f2 100644
--- a/res/xml/system_dashboard_fragment.xml
+++ b/res/xml/system_dashboard_fragment.xml
@@ -29,17 +29,6 @@
android:fragment="com.android.settings.gestures.GestureSettings"
settings:controller="com.android.settings.gestures.GesturesSettingPreferenceController"/>
- <!-- Backup -->
- <Preference
- android:key="backup_settings"
- android:title="@string/privacy_settings_title"
- android:summary="@string/summary_placeholder"
- android:icon="@drawable/ic_settings_backup"
- android:order="-60"
- settings:controller="com.android.settings.backup.BackupSettingsActivityPreferenceController">
- <intent android:action="android.settings.BACKUP_AND_RESET_SETTINGS" />
- </Preference>
-
<Preference
android:key="reset_dashboard"
android:title="@string/reset_dashboard_title"
diff --git a/src/com/android/settings/RadioInfo.java b/src/com/android/settings/RadioInfo.java
index 251bfbc..db6bd9b 100644
--- a/src/com/android/settings/RadioInfo.java
+++ b/src/com/android/settings/RadioInfo.java
@@ -23,6 +23,7 @@
import android.app.QueuedWork;
import android.content.ComponentName;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
@@ -40,6 +41,7 @@
import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
+import android.provider.Telephony;
import android.telephony.CarrierConfigManager;
import android.telephony.CellIdentityCdma;
import android.telephony.CellIdentityGsm;
@@ -81,11 +83,13 @@
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AlertDialog.Builder;
import com.android.ims.ImsConfig;
import com.android.ims.ImsException;
import com.android.ims.ImsManager;
import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneConfigurationManager;
import com.android.internal.telephony.PhoneFactory;
import java.io.IOException;
@@ -93,6 +97,7 @@
import java.net.URL;
import java.util.List;
+// TODO(b/123598192) consider to move this activity to telephony package.
public class RadioInfo extends Activity {
private static final String TAG = "RadioInfo";
@@ -214,6 +219,7 @@
private Switch imsWfcProvisionedSwitch;
private Switch eabProvisionedSwitch;
private Switch cbrsDataSwitch;
+ private Switch dsdsSwitch;
private Spinner preferredNetworkType;
private Spinner cellInfoRefreshRateSpinner;
@@ -454,6 +460,23 @@
cbrsDataSwitch = (Switch) findViewById(R.id.cbrs_data_switch);
cbrsDataSwitch.setVisibility(isCbrsSupported() ? View.VISIBLE : View.GONE);
+ dsdsSwitch = findViewById(R.id.dsds_switch);
+ if (isDsdsSupported()) {
+ dsdsSwitch.setVisibility(View.VISIBLE);
+ dsdsSwitch.setOnClickListener(v -> {
+ if (mTelephonyManager.isRebootRequiredForModemConfigChange()) {
+ // Undo the click action until user clicks the confirm dialog.
+ dsdsSwitch.toggle();
+ showDsdsChangeDialog();
+ } else {
+ performDsdsSwitch();
+ }
+ });
+ dsdsSwitch.setChecked(isDsdsEnabled());
+ } else {
+ dsdsSwitch.setVisibility(View.GONE);
+ }
+
radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
mDownlinkKbps = (TextView) findViewById(R.id.dl_kbps);
@@ -1525,5 +1548,38 @@
}
};
+ private void showDsdsChangeDialog() {
+ final AlertDialog confirmDialog = new Builder(RadioInfo.this)
+ .setTitle(R.string.dsds_dialog_title)
+ .setMessage(R.string.dsds_dialog_message)
+ .setPositiveButton(R.string.dsds_dialog_confirm, mOnDsdsDialogConfirmedListener)
+ .setNegativeButton(R.string.dsds_dialog_cancel, mOnDsdsDialogConfirmedListener)
+ .create();
+ confirmDialog.show();
+ }
+ private static boolean isDsdsSupported() {
+ return PhoneConfigurationManager.getInstance().getStaticPhoneCapability()
+ .logicalModemList.size() >= 2
+ && !TelephonyManager.getDefault().isMultisimCarrierRestricted();
+ }
+
+ private static boolean isDsdsEnabled() {
+ return TelephonyManager.getDefault().getPhoneCount() > 1;
+ }
+
+ private void performDsdsSwitch() {
+ mTelephonyManager.switchMultiSimConfig(dsdsSwitch.isChecked() ? 2 : 1);
+ }
+
+ DialogInterface.OnClickListener mOnDsdsDialogConfirmedListener =
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == DialogInterface.BUTTON_POSITIVE) {
+ dsdsSwitch.toggle();
+ performDsdsSwitch();
+ }
+ }
+ };
}
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 25ad73d..8bd81ee 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -18,6 +18,7 @@
import android.app.ActionBar;
import android.app.ActivityManager;
+import android.app.settings.SettingsEnums;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -51,7 +52,6 @@
import com.android.internal.util.ArrayUtils;
import com.android.settings.Settings.WifiSettingsActivity;
import com.android.settings.applications.manageapplications.ManageApplications;
-import com.android.settings.backup.BackupSettingsActivity;
import com.android.settings.core.OnActivityResultListener;
import com.android.settings.core.SettingsBaseActivity;
import com.android.settings.core.SubSettingLauncher;
@@ -287,7 +287,7 @@
final Toolbar toolbar = findViewById(R.id.search_action_bar);
setActionBar(toolbar);
FeatureFactory.getFactory(this).getSearchFeatureProvider()
- .initSearchToolbar(this, toolbar);
+ .initSearchToolbar(this, toolbar, SettingsEnums.SETTINGS_HOMEPAGE);
}
ActionBar actionBar = getActionBar();
@@ -651,11 +651,6 @@
showDev, isAdmin)
|| somethingChanged;
- // Enable/disable backup settings depending on whether the user is admin.
- somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
- BackupSettingsActivity.class.getName()), true, isAdmin)
- || somethingChanged;
-
somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
Settings.WifiDisplaySettingsActivity.class.getName()),
WifiDisplaySettings.isAvailable(this), isAdmin)
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 5852757..ee0cb7d 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -92,7 +92,7 @@
private static final String CATEGORY_EXPERIMENTAL = "experimental_category";
private static final String CATEGORY_DOWNLOADED_SERVICES = "user_installed_services_category";
- private static final String[] CATEGORIES = new String[]{
+ private static final String[] CATEGORIES = new String[] {
CATEGORY_SCREEN_READER, CATEGORY_AUDIO_AND_CAPTIONS, CATEGORY_DISPLAY,
CATEGORY_INTERACTION_CONTROL, CATEGORY_EXPERIMENTAL, CATEGORY_DOWNLOADED_SERVICES
};
@@ -133,8 +133,7 @@
"accessibility_content_timeout_preference_fragment";
private static final String ACCESSIBILITY_CONTROL_TIMEOUT_PREFERENCE =
"accessibility_control_timeout_preference_fragment";
- private static final String LIVE_CAPTION_PREFERENCE_KEY =
- "live_caption";
+
// Extras passed to sub-fragments.
static final String EXTRA_PREFERENCE_KEY = "preference_key";
@@ -234,11 +233,9 @@
private Preference mDisplayDaltonizerPreferenceScreen;
private Preference mHearingAidPreference;
private Preference mVibrationPreferenceScreen;
- private Preference mLiveCaptionPreference;
private SwitchPreference mToggleInversionPreference;
private ColorInversionPreferenceController mInversionPreferenceController;
private AccessibilityHearingAidPreferenceController mHearingAidPreferenceController;
- private LiveCaptionPreferenceController mLiveCaptionPreferenceController;
private int mLongPressTimeoutDefault;
@@ -297,9 +294,6 @@
(context, HEARING_AID_PREFERENCE);
mHearingAidPreferenceController.setFragmentManager(getFragmentManager());
getLifecycle().addObserver(mHearingAidPreferenceController);
-
- mLiveCaptionPreferenceController = new LiveCaptionPreferenceController(context,
- LIVE_CAPTION_PREFERENCE_KEY);
}
@Override
@@ -488,10 +482,6 @@
// Captioning.
mCaptioningPreferenceScreen = findPreference(CAPTIONING_PREFERENCE_SCREEN);
- // Live caption
- mLiveCaptionPreference = findPreference(LIVE_CAPTION_PREFERENCE_KEY);
- mLiveCaptionPreferenceController.displayPreference(getPreferenceScreen());
-
// Display magnification.
mDisplayMagnificationPreferenceScreen = findPreference(
DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN);
@@ -727,8 +717,6 @@
mHearingAidPreferenceController.updateState(mHearingAidPreference);
- mLiveCaptionPreferenceController.updateState(mLiveCaptionPreference);
-
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED,
mCaptioningPreferenceScreen);
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
@@ -749,6 +737,7 @@
}
void updateAccessibilityTimeoutSummary(ContentResolver resolver, Preference pref) {
+
String[] timeoutSummarys = getResources().getStringArray(
R.array.accessibility_timeout_summaries);
int[] timeoutValues = getResources().getIntArray(
@@ -817,7 +806,7 @@
pref.setSummary(entries[index]);
}
- @VisibleForTesting
+ @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
void updateVibrationSummary(Preference pref) {
final Context context = getContext();
final Vibrator vibrator = context.getSystemService(Vibrator.class);
diff --git a/src/com/android/settings/accessibility/LiveCaptionPreferenceController.java b/src/com/android/settings/accessibility/LiveCaptionPreferenceController.java
deleted file mode 100644
index 94ee1c0..0000000
--- a/src/com/android/settings/accessibility/LiveCaptionPreferenceController.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2019 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.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.Preference;
-
-import com.android.settings.core.BasePreferenceController;
-
-import java.util.List;
-
-public class LiveCaptionPreferenceController extends BasePreferenceController {
-
- @VisibleForTesting
- static final Intent LIVE_CAPTION_INTENT = new Intent(
- "com.android.settings.action.live_caption");
-
- private final PackageManager mPackageManager;
-
- public LiveCaptionPreferenceController(Context context, String preferenceKey) {
- super(context, preferenceKey);
- mPackageManager = context.getPackageManager();
- }
-
- @Override
- public int getAvailabilityStatus() {
- final List<ResolveInfo> resolved =
- mPackageManager.queryIntentActivities(LIVE_CAPTION_INTENT, 0 /* flags */);
- return resolved != null && !resolved.isEmpty()
- ? AVAILABLE
- : UNSUPPORTED_ON_DEVICE;
- }
-
- @Override
- public void updateState(Preference preference) {
- super.updateState(preference);
- preference.setIntent(LIVE_CAPTION_INTENT);
- }
-}
diff --git a/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceController.java b/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceController.java
index c968d55..c19c367 100644
--- a/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceController.java
@@ -14,27 +14,15 @@
package com.android.settings.applications.appinfo;
+import android.app.role.RoleManager;
import android.content.Context;
-import com.android.settings.applications.defaultapps.DefaultPhonePreferenceController;
-
public class DefaultPhoneShortcutPreferenceController
extends DefaultAppShortcutPreferenceControllerBase {
private static final String KEY = "default_phone_app";
public DefaultPhoneShortcutPreferenceController(Context context, String packageName) {
- super(context, KEY, packageName);
+ super(context, KEY, RoleManager.ROLE_DIALER, packageName);
}
-
- @Override
- protected boolean hasAppCapability() {
- return DefaultPhonePreferenceController.hasPhonePreference(mPackageName, mContext);
- }
-
- @Override
- protected boolean isDefaultApp() {
- return DefaultPhonePreferenceController.isPhoneDefault(mPackageName, mContext);
- }
-
}
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 126cf6d..816b44a 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -185,7 +185,6 @@
private ApplicationsAdapter mApplications;
private View mLoadingContainer;
-
private View mListContainer;
private RecyclerView mRecyclerView;
private SearchView mSearchView;
@@ -216,10 +215,15 @@
LIST_TYPE_MAIN,
LIST_TYPE_STORAGE));
+ @VisibleForTesting
+ View mSpinnerHeader;
+ @VisibleForTesting
+ FilterSpinnerAdapter mFilterAdapter;
+ @VisibleForTesting
+ View mContentContainer;
+
private View mRootView;
- private View mSpinnerHeader;
private Spinner mFilterSpinner;
- private FilterSpinnerAdapter mFilterAdapter;
private IUsageStatsManager mUsageStatsManager;
private UserManager mUserManager;
private NotificationBackend mNotificationBackend;
@@ -326,6 +330,7 @@
Bundle savedInstanceState) {
mRootView = inflater.inflate(R.layout.manage_applications_apps, null);
mLoadingContainer = mRootView.findViewById(R.id.loading_container);
+ mContentContainer = mRootView.findViewById(R.id.content_container);
mListContainer = mRootView.findViewById(R.id.list_container);
if (mListContainer != null) {
// Create adapter and list view here
@@ -794,8 +799,7 @@
}
mFilterOptions.add(filter);
Collections.sort(mFilterOptions);
- mManageApplications.mSpinnerHeader.setVisibility(
- mFilterOptions.size() > 1 ? View.VISIBLE : View.GONE);
+ updateFilterView(mFilterOptions.size() > 1);
notifyDataSetChanged();
if (mFilterOptions.size() == 1) {
if (DEBUG) {
@@ -826,14 +830,13 @@
filter.getTitle()));
}
Collections.sort(mFilterOptions);
- mManageApplications.mSpinnerHeader.setVisibility(
- mFilterOptions.size() > 1 ? View.VISIBLE : View.GONE);
+ updateFilterView(mFilterOptions.size() > 1);
notifyDataSetChanged();
if (mManageApplications.mFilter == filter) {
if (mFilterOptions.size() > 0) {
if (DEBUG) {
Log.d(TAG, "Auto selecting filter " + mFilterOptions.get(0)
- + mContext.getText(mFilterOptions.get(0).getTitle()));
+ + mContext.getText(mFilterOptions.get(0).getTitle()));
}
mManageApplications.mFilterSpinner.setSelection(0);
mManageApplications.onItemSelected(null, null, 0, 0);
@@ -850,6 +853,26 @@
public CharSequence getItem(int position) {
return mContext.getText(mFilterOptions.get(position).getTitle());
}
+
+ @VisibleForTesting
+ void updateFilterView(boolean hasFilter) {
+ // If we need to add a floating filter in this screen, we should have an extra top
+ // padding for putting floating filter view. Otherwise, the content of list will be
+ // overlapped by floating filter.
+ if (hasFilter) {
+ mManageApplications.mSpinnerHeader.setVisibility(View.VISIBLE);
+ mManageApplications.mContentContainer.setPadding(0 /* left */,
+ mContext.getResources().getDimensionPixelSize(
+ R.dimen.app_bar_height) /* top */,
+ 0 /* right */,
+ 0 /* bottom */);
+ } else {
+ mManageApplications.mSpinnerHeader.setVisibility(View.GONE);
+ mManageApplications.mContentContainer.setPadding(0 /* left */, 0 /* top */,
+ 0 /* right */,
+ 0 /* bottom */);
+ }
+ }
}
static class ApplicationsAdapter extends RecyclerView.Adapter<ApplicationViewHolder>
diff --git a/src/com/android/settings/backup/BackupSettingsActivityPreferenceController.java b/src/com/android/settings/backup/BackupSettingsActivityPreferenceController.java
deleted file mode 100644
index 1af80d9..0000000
--- a/src/com/android/settings/backup/BackupSettingsActivityPreferenceController.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.settings.backup;
-
-import android.app.backup.BackupManager;
-import android.content.Context;
-import android.os.UserManager;
-
-import com.android.settings.R;
-import com.android.settings.core.BasePreferenceController;
-
-public class BackupSettingsActivityPreferenceController extends BasePreferenceController {
- private static final String TAG = "BackupSettingActivityPC";
-
-
- private final UserManager mUm;
- private final BackupManager mBackupManager;
-
- public BackupSettingsActivityPreferenceController(Context context, String key) {
- super(context, key);
- mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
- mBackupManager = new BackupManager(context);
- }
-
- @Override
- public int getAvailabilityStatus() {
- return mUm.isAdminUser()
- ? AVAILABLE_UNSEARCHABLE
- : UNSUPPORTED_ON_DEVICE;
- }
-
- @Override
- public CharSequence getSummary() {
- final boolean backupEnabled = mBackupManager.isBackupEnabled();
-
- return backupEnabled
- ? mContext.getText(R.string.backup_summary_state_on)
- : mContext.getText(R.string.backup_summary_state_off);
- }
-}
\ No newline at end of file
diff --git a/src/com/android/settings/backup/BackupSettingsContentProvider.java b/src/com/android/settings/backup/BackupSettingsContentProvider.java
new file mode 100644
index 0000000..5c888ab
--- /dev/null
+++ b/src/com/android/settings/backup/BackupSettingsContentProvider.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2019 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.backup;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.UriMatcher;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+
+import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_SUMMARY;
+
+/** Provider stores and manages user interaction feedback for homepage contextual cards. */
+public class BackupSettingsContentProvider extends ContentProvider {
+ private static final String AUTHORITY =
+ "com.android.settings.backup.BackupSettingsContentProvider";
+ private static final String SUMMARY = "summary";
+ private static final UriMatcher URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH);
+ static {
+ URI_MATCHER.addURI(AUTHORITY, SUMMARY, 1);
+ }
+
+ @Override
+ public Bundle call(String method, String uri, Bundle extras) {
+ if (!SUMMARY.equals(method)) {
+ return null;
+ }
+ Bundle bundle = new Bundle();
+ bundle.putString(META_DATA_PREFERENCE_SUMMARY,
+ new BackupSettingsHelper(getContext()).getSummary());
+ return bundle;
+ }
+
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/src/com/android/settings/backup/BackupSettingsFragment.java b/src/com/android/settings/backup/BackupSettingsFragment.java
index 57c8d00..f08c8e7 100644
--- a/src/com/android/settings/backup/BackupSettingsFragment.java
+++ b/src/com/android/settings/backup/BackupSettingsFragment.java
@@ -68,7 +68,7 @@
return controllers;
}
- // The intention is to index {@link BackupSettingsActivity} instead of the fragments,
+ // The intention is to index {@link UserBackupSettingsActivity} instead of the fragments,
// therefore leaving this index provider empty.
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
diff --git a/src/com/android/settings/backup/BackupSettingsHelper.java b/src/com/android/settings/backup/BackupSettingsHelper.java
index b35d6b2..fa77154 100644
--- a/src/com/android/settings/backup/BackupSettingsHelper.java
+++ b/src/com/android/settings/backup/BackupSettingsHelper.java
@@ -24,6 +24,7 @@
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
+import android.os.UserManager;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -34,7 +35,7 @@
import java.net.URISyntaxException;
/**
- * Helper class for {@link BackupSettingsActivity} that interacts with {@link IBackupManager}.
+ * Helper class for {@link UserBackupSettingsActivity} that interacts with {@link IBackupManager}.
*/
public class BackupSettingsHelper {
private static final String TAG = "BackupSettingsHelper";
@@ -49,6 +50,24 @@
}
/**
+ * If there is only one profile, show whether the backup is on or off.
+ * Otherwise, show nothing.
+ */
+ String getSummary() {
+ UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+ if (userManager.getUserProfiles().size() == 1) {
+ try {
+ int resId = mBackupManager.isBackupEnabled() ? R.string.backup_summary_state_on
+ : R.string.backup_summary_state_off;
+ return mContext.getText(resId).toString();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error getting isBackupEnabled", e);
+ }
+ }
+ return null;
+ }
+
+ /**
* Returns an intent to launch backup settings from backup transport if the intent was provided
* by the transport. Otherwise returns the intent to launch the default backup settings screen.
*
diff --git a/src/com/android/settings/backup/BackupSettingsActivity.java b/src/com/android/settings/backup/UserBackupSettingsActivity.java
similarity index 84%
rename from src/com/android/settings/backup/BackupSettingsActivity.java
rename to src/com/android/settings/backup/UserBackupSettingsActivity.java
index 615dbf3..4a0b80c 100644
--- a/src/com/android/settings/backup/BackupSettingsActivity.java
+++ b/src/com/android/settings/backup/UserBackupSettingsActivity.java
@@ -20,7 +20,6 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
-import android.os.UserHandle;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -40,9 +39,14 @@
/**
* The activity used to launch the configured Backup activity or the preference screen
* if the manufacturer provided their backup settings.
+ * Pre-Q, BackupSettingsActivity was disabled for non-system users. Therefore, for phones which
+ * upgrade to Q, BackupSettingsActivity is disabled for those users. However, we cannot simply
+ * enable it in Q since component enable can only be done by the user itself; which is not
+ * enough in Q we want it to be enabled for all profile users of the user.
+ * Therefore, as a simple workaround, we use a new class which is enabled by default.
*/
@SearchIndexable
-public class BackupSettingsActivity extends FragmentActivity implements Indexable {
+public class UserBackupSettingsActivity extends FragmentActivity implements Indexable {
private static final String TAG = "BackupSettingsActivity";
private FragmentManager mFragmentManager;
@@ -108,29 +112,13 @@
data.screenTitle = context.getString(R.string.settings_label);
data.keywords = context.getString(R.string.keywords_backup);
data.intentTargetPackage = context.getPackageName();
- data.intentTargetClass = BackupSettingsActivity.class.getName();
+ data.intentTargetClass = com.android.settings.backup.UserBackupSettingsActivity.class.getName();
data.intentAction = Intent.ACTION_MAIN;
data.key = BACKUP_SEARCH_INDEX_KEY;
result.add(data);
return result;
}
-
- @Override
- public List<String> getNonIndexableKeys(Context context) {
- final List<String> keys = super.getNonIndexableKeys(context);
-
- // For non-primary user, no backup is available, so don't show it in search
- // TODO: http://b/22388012
- if (UserHandle.myUserId() != UserHandle.USER_SYSTEM) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Not a system user, not indexing the screen");
- }
- keys.add(BACKUP_SEARCH_INDEX_KEY);
- }
-
- return keys;
- }
};
@VisibleForTesting
diff --git a/src/com/android/settings/core/FeatureFlags.java b/src/com/android/settings/core/FeatureFlags.java
index 7f14c0d..d1c2fd5 100644
--- a/src/com/android/settings/core/FeatureFlags.java
+++ b/src/com/android/settings/core/FeatureFlags.java
@@ -28,4 +28,5 @@
public static final String NETWORK_INTERNET_V2 = "settings_network_and_internet_v2";
public static final String WIFI_SHARING = "settings_wifi_sharing";
public static final String SLICE_INJECTION = "settings_slice_injection";
+ public static final String MAINLINE_MODULE = "settings_mainline_module";
}
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 7ba3688..bb292a1 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -49,6 +49,7 @@
import com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetails;
import com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureSettings;
import com.android.settings.applications.specialaccess.vrlistener.VrListenerSettings;
+import com.android.settings.backup.UserBackupSettingsActivity;
import com.android.settings.backup.PrivacySettings;
import com.android.settings.backup.ToggleBackupSettingFragment;
import com.android.settings.biometrics.face.FaceSettings;
@@ -298,5 +299,6 @@
Settings.DateTimeSettingsActivity.class.getName(),
Settings.EnterprisePrivacySettingsActivity.class.getName(),
Settings.MyDeviceInfoActivity.class.getName(),
+ UserBackupSettingsActivity.class.getName(),
};
}
diff --git a/src/com/android/settings/datetime/timezone/TimeZoneSettings.java b/src/com/android/settings/datetime/timezone/TimeZoneSettings.java
index 6f776c9..d557bf9 100644
--- a/src/com/android/settings/datetime/timezone/TimeZoneSettings.java
+++ b/src/com/android/settings/datetime/timezone/TimeZoneSettings.java
@@ -69,6 +69,7 @@
private Locale mLocale;
private boolean mSelectByRegion;
private TimeZoneData mTimeZoneData;
+ private Intent mPendingZonePickerRequestResult;
private String mSelectedTimeZoneId;
private TimeZoneInfo.Formatter mTimeZoneInfoFormatter;
@@ -136,12 +137,10 @@
switch (requestCode) {
case REQUEST_CODE_REGION_PICKER:
case REQUEST_CODE_ZONE_PICKER: {
- String regionId = data.getStringExtra(RegionSearchPicker.EXTRA_RESULT_REGION_ID);
- String tzId = data.getStringExtra(RegionZonePicker.EXTRA_RESULT_TIME_ZONE_ID);
- // Ignore the result if user didn't change the region or time zone.
- if (!Objects.equals(regionId, use(RegionPreferenceController.class).getRegionId())
- || !Objects.equals(tzId, mSelectedTimeZoneId)) {
- onRegionZoneChanged(regionId, tzId);
+ if (mTimeZoneData == null) {
+ mPendingZonePickerRequestResult = data;
+ } else {
+ onZonePickerRequestResult(mTimeZoneData, data);
}
break;
}
@@ -166,8 +165,11 @@
mTimeZoneData = timeZoneData;
setupForCurrentTimeZone();
getActivity().invalidateOptionsMenu();
+ if (mPendingZonePickerRequestResult != null) {
+ onZonePickerRequestResult(timeZoneData, mPendingZonePickerRequestResult);
+ mPendingZonePickerRequestResult = null;
+ }
}
-
}
private void startRegionPicker() {
@@ -226,9 +228,17 @@
updatePreferenceStates();
}
- private void onRegionZoneChanged(String regionId, String tzId) {
+ private void onZonePickerRequestResult(TimeZoneData timeZoneData, Intent data) {
+ String regionId = data.getStringExtra(RegionSearchPicker.EXTRA_RESULT_REGION_ID);
+ String tzId = data.getStringExtra(RegionZonePicker.EXTRA_RESULT_TIME_ZONE_ID);
+ // Ignore the result if user didn't change the region or time zone.
+ if (Objects.equals(regionId, use(RegionPreferenceController.class).getRegionId())
+ && Objects.equals(tzId, mSelectedTimeZoneId)) {
+ return;
+ }
+
FilteredCountryTimeZones countryTimeZones =
- mTimeZoneData.lookupCountryTimeZones(regionId);
+ timeZoneData.lookupCountryTimeZones(regionId);
if (countryTimeZones == null || !countryTimeZones.getTimeZoneIds().contains(tzId)) {
Log.e(TAG, "Unknown time zone id is selected: " + tzId);
return;
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index ed6a19f..5135fbf 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -429,7 +429,6 @@
controllers.add(new CameraLaserSensorPreferenceController(context));
controllers.add(new WifiDisplayCertificationPreferenceController(context));
controllers.add(new WifiVerboseLoggingPreferenceController(context));
- controllers.add(new WifiConnectedMacRandomizationPreferenceController(context));
controllers.add(new MobileDataAlwaysOnPreferenceController(context));
controllers.add(new TetheringHardwareAccelPreferenceController(context));
controllers.add(new BluetoothDeviceNoNamePreferenceController(context));
diff --git a/src/com/android/settings/development/WifiConnectedMacRandomizationPreferenceController.java b/src/com/android/settings/development/WifiConnectedMacRandomizationPreferenceController.java
deleted file mode 100644
index fed07f6..0000000
--- a/src/com/android/settings/development/WifiConnectedMacRandomizationPreferenceController.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.development;
-
-import android.content.Context;
-import android.provider.Settings;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.Preference;
-import androidx.preference.SwitchPreference;
-
-import com.android.settings.R;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.development.DeveloperOptionsPreferenceController;
-
-public class WifiConnectedMacRandomizationPreferenceController extends
- DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
- PreferenceControllerMixin {
-
- private static final String WIFI_CONNECTED_MAC_RANDOMIZATION_KEY =
- "wifi_connected_mac_randomization";
-
- @VisibleForTesting
- static final int SETTING_VALUE_ON = 1;
- @VisibleForTesting
- static final int SETTING_VALUE_OFF = 0;
-
- public WifiConnectedMacRandomizationPreferenceController(Context context) {
- super(context);
- }
-
- @Override
- public boolean isAvailable() {
- return mContext.getResources().getBoolean(
- R.bool.config_wifi_support_connected_mac_randomization);
- }
-
- @Override
- public String getPreferenceKey() {
- return WIFI_CONNECTED_MAC_RANDOMIZATION_KEY;
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- final boolean isEnabled = (Boolean) newValue;
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED,
- isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
- return true;
- }
-
- @Override
- public void updateState(Preference preference) {
- final int enableMode = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, SETTING_VALUE_OFF);
- ((SwitchPreference) mPreference).setChecked(enableMode != SETTING_VALUE_OFF);
- }
-
- @Override
- protected void onDeveloperOptionsSwitchDisabled() {
- super.onDeveloperOptionsSwitchDisabled();
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, SETTING_VALUE_OFF);
- ((SwitchPreference) mPreference).setChecked(false);
- }
-}
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/ModuleVersionDialogController.java b/src/com/android/settings/deviceinfo/firmwareversion/ModuleVersionDialogController.java
index d6fcc38..0dc953d 100644
--- a/src/com/android/settings/deviceinfo/firmwareversion/ModuleVersionDialogController.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/ModuleVersionDialogController.java
@@ -19,9 +19,11 @@
import android.content.Context;
import android.content.pm.PackageManager;
import android.text.TextUtils;
+import android.util.FeatureFlagUtils;
import android.util.Log;
import com.android.settings.R;
+import com.android.settings.core.FeatureFlags;
import androidx.annotation.VisibleForTesting;
@@ -48,6 +50,11 @@
* Updates the mainline module version field of the dialog.
*/
public void initialize() {
+ if (!FeatureFlagUtils.isEnabled(mContext, FeatureFlags.MAINLINE_MODULE)) {
+ mDialog.removeSettingFromScreen(MODULE_VERSION_LABEL_ID);
+ mDialog.removeSettingFromScreen(MODULE_VERSION_VALUE_ID);
+ return;
+ }
final String moduleProvider = mContext.getString(
com.android.internal.R.string.config_defaultModuleMetadataProvider);
if (!TextUtils.isEmpty(moduleProvider)) {
diff --git a/src/com/android/settings/homepage/SettingsHomepageActivity.java b/src/com/android/settings/homepage/SettingsHomepageActivity.java
index ff27ff2..a2e3a9c 100644
--- a/src/com/android/settings/homepage/SettingsHomepageActivity.java
+++ b/src/com/android/settings/homepage/SettingsHomepageActivity.java
@@ -16,6 +16,7 @@
package com.android.settings.homepage;
+import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.os.Bundle;
import android.util.FeatureFlagUtils;
@@ -55,7 +56,7 @@
final Toolbar toolbar = findViewById(R.id.search_action_bar);
FeatureFactory.getFactory(this).getSearchFeatureProvider()
- .initSearchToolbar(this /* activity */, toolbar);
+ .initSearchToolbar(this /* activity */, toolbar, SettingsEnums.SETTINGS_HOMEPAGE);
final ImageView avatarView = findViewById(R.id.account_avatar);
final AvatarViewMixin avatarViewMixin = new AvatarViewMixin(this, avatarView);
diff --git a/src/com/android/settings/nfc/AndroidBeamEnabler.java b/src/com/android/settings/nfc/AndroidBeamEnabler.java
index 4dda2fd..31ef702 100644
--- a/src/com/android/settings/nfc/AndroidBeamEnabler.java
+++ b/src/com/android/settings/nfc/AndroidBeamEnabler.java
@@ -53,7 +53,7 @@
switch (newState) {
case NfcAdapter.STATE_OFF:
mPreference.setEnabled(false);
- mPreference.setSummary(R.string.android_beam_disabled_summary);
+ mPreference.setSummary(R.string.nfc_disabled_summary);
break;
case NfcAdapter.STATE_ON:
if (mBeamDisallowedBySystem) {
diff --git a/src/com/android/settings/nfc/SecureNfcEnabler.java b/src/com/android/settings/nfc/SecureNfcEnabler.java
new file mode 100644
index 0000000..065dc8b
--- /dev/null
+++ b/src/com/android/settings/nfc/SecureNfcEnabler.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2019 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.nfc;
+
+import android.content.Context;
+import android.nfc.NfcAdapter;
+import android.provider.Settings;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.R;
+
+/**
+ * SecureNfcEnabler is a helper to manage the Secure Nfc on/off checkbox preference
+ * It turns on/off Secure NFC and ensures the summary of the preference reflects
+ * the current state.
+ */
+public class SecureNfcEnabler extends BaseNfcEnabler {
+ private final SwitchPreference mPreference;
+
+ public SecureNfcEnabler(Context context, SwitchPreference preference) {
+ super(context);
+ mPreference = preference;
+ }
+
+ @Override
+ protected void handleNfcStateChanged(int newState) {
+ switch (newState) {
+ case NfcAdapter.STATE_OFF:
+ mPreference.setSummary(R.string.nfc_disabled_summary);
+ mPreference.setEnabled(false);
+ break;
+ case NfcAdapter.STATE_ON:
+ mPreference.setChecked(mPreference.isEnabled());
+ mPreference.setEnabled(true);
+ break;
+ case NfcAdapter.STATE_TURNING_ON:
+ mPreference.setEnabled(false);
+ break;
+ case NfcAdapter.STATE_TURNING_OFF:
+ mPreference.setEnabled(false);
+ break;
+ }
+ }
+}
diff --git a/src/com/android/settings/nfc/SecureNfcPreferenceController.java b/src/com/android/settings/nfc/SecureNfcPreferenceController.java
new file mode 100644
index 0000000..2c23672
--- /dev/null
+++ b/src/com/android/settings/nfc/SecureNfcPreferenceController.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2019 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.nfc;
+
+import android.content.Context;
+import android.nfc.NfcAdapter;
+import android.os.SystemProperties;
+
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.core.TogglePreferenceController;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnPause;
+import com.android.settingslib.core.lifecycle.events.OnResume;
+
+public class SecureNfcPreferenceController extends TogglePreferenceController
+ implements LifecycleObserver, OnResume, OnPause {
+
+ public static final String KEY_TOGGLE_NFC = "nfc_secure_setting";
+ private final NfcAdapter mNfcAdapter;
+ private SecureNfcEnabler mSecureNfcEnabler;
+
+ public SecureNfcPreferenceController(Context context, String key) {
+ super(context, key);
+ mNfcAdapter = NfcAdapter.getDefaultAdapter(context);
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ if (!isAvailable()) {
+ mSecureNfcEnabler = null;
+ return;
+ }
+
+ final SwitchPreference switchPreference =
+ (SwitchPreference) screen.findPreference(getPreferenceKey());
+
+ mSecureNfcEnabler = new SecureNfcEnabler(mContext, switchPreference);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return mNfcAdapter.isNfcSecureEnabled();
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ return mNfcAdapter.setNfcSecure(isChecked);
+ }
+
+ @Override
+ @AvailabilityStatus
+ public int getAvailabilityStatus() {
+ if (mNfcAdapter == null) {
+ return UNSUPPORTED_ON_DEVICE;
+ }
+ return mNfcAdapter.deviceSupportsNfcSecure() ? AVAILABLE
+ : UNSUPPORTED_ON_DEVICE;
+ }
+
+ @Override
+ public boolean hasAsyncUpdate() {
+ return true;
+ }
+
+ @Override
+ public boolean isSliceable() {
+ return true;
+ }
+
+ @Override
+ public void onResume() {
+ if (mSecureNfcEnabler != null) {
+ mSecureNfcEnabler.resume();
+ }
+ }
+
+ @Override
+ public void onPause() {
+ if (mSecureNfcEnabler != null) {
+ mSecureNfcEnabler.pause();
+ }
+ }
+}
diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java
index a2be3ea..ec56369 100644
--- a/src/com/android/settings/notification/NotificationBackend.java
+++ b/src/com/android/settings/notification/NotificationBackend.java
@@ -300,6 +300,23 @@
}
}
+ public boolean shouldHideSilentStatusBarIcons(Context context) {
+ try {
+ return sINM.shouldHideSilentStatusIcons(context.getPackageName());
+ } catch (Exception e) {
+ Log.w(TAG, "Error calling NoMan", e);
+ return false;
+ }
+ }
+
+ public void setHideSilentStatusIcons(boolean hide) {
+ try {
+ sINM.setHideSilentStatusIcons(hide);
+ } catch (Exception e) {
+ Log.w(TAG, "Error calling NoMan", e);
+ }
+ }
+
protected void recordAggregatedUsageEvents(Context context, AppRow appRow) {
long now = System.currentTimeMillis();
long startTime = now - (DateUtils.DAY_IN_MILLIS * DAYS_TO_CHECK);
diff --git a/src/com/android/settings/notification/SilentStatusBarPreferenceController.java b/src/com/android/settings/notification/SilentStatusBarPreferenceController.java
new file mode 100644
index 0000000..4721f5c
--- /dev/null
+++ b/src/com/android/settings/notification/SilentStatusBarPreferenceController.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL;
+
+import android.content.Context;
+import android.os.UserHandle;
+import android.provider.Settings;
+
+import com.android.settings.core.TogglePreferenceController;
+
+public class SilentStatusBarPreferenceController extends TogglePreferenceController {
+
+ private static final String KEY = "hide_silent_icons";
+ private static final int MY_USER_ID = UserHandle.myUserId();
+ private final NotificationBackend mBackend;
+
+ public SilentStatusBarPreferenceController(Context context) {
+ super(context, KEY);
+ mBackend = new NotificationBackend();
+ }
+
+ @Override
+ public boolean isChecked() {
+ return mBackend.shouldHideSilentStatusBarIcons(mContext);
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ mBackend.setHideSilentStatusIcons(isChecked);
+ return true;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return Settings.Secure.getInt(
+ mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 1) != 0
+ ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+ }
+
+}
+
+
diff --git a/src/com/android/settings/search/SearchFeatureProvider.java b/src/com/android/settings/search/SearchFeatureProvider.java
index b98936e..dcb4acc 100644
--- a/src/com/android/settings/search/SearchFeatureProvider.java
+++ b/src/com/android/settings/search/SearchFeatureProvider.java
@@ -25,7 +25,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.provider.Settings;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toolbar;
@@ -40,7 +39,6 @@
*/
public interface SearchFeatureProvider {
- Intent SEARCH_UI_INTENT = new Intent(Settings.ACTION_APP_SEARCH_SETTINGS);
int REQUEST_CODE = 0;
/**
@@ -64,7 +62,7 @@
/**
* Initializes the search toolbar.
*/
- default void initSearchToolbar(Activity activity, Toolbar toolbar) {
+ default void initSearchToolbar(Activity activity, Toolbar toolbar, int pageId) {
if (activity == null || toolbar == null) {
return;
}
@@ -87,9 +85,8 @@
navView.setBackground(null);
toolbar.setOnClickListener(tb -> {
- final Intent intent = SEARCH_UI_INTENT;
- intent.setPackage(getSettingsIntelligencePkgName(activity));
final Context context = activity.getApplicationContext();
+ final Intent intent = buildSearchIntent(context, pageId);
if (activity.getPackageManager().queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY).isEmpty()) {
@@ -97,10 +94,12 @@
}
FeatureFactory.getFactory(context).getSlicesFeatureProvider()
- .indexSliceDataAsync(activity.getApplicationContext());
+ .indexSliceDataAsync(context);
FeatureFactory.getFactory(context).getMetricsFeatureProvider()
.action(context, SettingsEnums.ACTION_SEARCH_RESULTS);
activity.startActivityForResult(intent, REQUEST_CODE);
});
}
+
+ Intent buildSearchIntent(Context context, int pageId);
}
diff --git a/src/com/android/settings/search/SearchFeatureProviderImpl.java b/src/com/android/settings/search/SearchFeatureProviderImpl.java
index a5a8777..63bf420 100644
--- a/src/com/android/settings/search/SearchFeatureProviderImpl.java
+++ b/src/com/android/settings/search/SearchFeatureProviderImpl.java
@@ -19,6 +19,9 @@
import android.content.ComponentName;
import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.provider.Settings;
import android.text.TextUtils;
import com.android.settingslib.search.SearchIndexableResources;
@@ -59,7 +62,22 @@
return mSearchIndexableResources;
}
+ @Override
+ public Intent buildSearchIntent(Context context, int pageId) {
+ return new Intent(Settings.ACTION_APP_SEARCH_SETTINGS)
+ .setPackage(getSettingsIntelligencePkgName(context))
+ .putExtra(Intent.EXTRA_REFERRER, buildReferrer(context, pageId));
+ }
+
protected boolean isSignatureWhitelisted(Context context, String callerPackage) {
return false;
}
+
+ private static Uri buildReferrer(Context context, int pageId) {
+ return new Uri.Builder()
+ .scheme("android-app")
+ .authority(context.getPackageName())
+ .path(String.valueOf(pageId))
+ .build();
+ }
}
diff --git a/src/com/android/settings/search/actionbar/SearchMenuController.java b/src/com/android/settings/search/actionbar/SearchMenuController.java
index 2f1c270..af7141e 100644
--- a/src/com/android/settings/search/actionbar/SearchMenuController.java
+++ b/src/com/android/settings/search/actionbar/SearchMenuController.java
@@ -30,11 +30,10 @@
import com.android.settings.R;
import com.android.settings.Utils;
+import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.search.SearchFeatureProvider;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.ObservableFragment;
-import com.android.settingslib.core.lifecycle.ObservablePreferenceFragment;
import com.android.settingslib.core.lifecycle.events.OnCreateOptionsMenu;
public class SearchMenuController implements LifecycleObserver, OnCreateOptionsMenu {
@@ -42,17 +41,21 @@
public static final String NEED_SEARCH_ICON_IN_ACTION_BAR = "need_search_icon_in_action_bar";
private final Fragment mHost;
+ private final int mPageId;
- public static void init(@NonNull ObservablePreferenceFragment host) {
- host.getSettingsLifecycle().addObserver(new SearchMenuController(host));
+ public static void init(@NonNull InstrumentedPreferenceFragment host) {
+ host.getSettingsLifecycle().addObserver(
+ new SearchMenuController(host, host.getMetricsCategory()));
}
- public static void init(@NonNull ObservableFragment host) {
- host.getSettingsLifecycle().addObserver(new SearchMenuController(host));
+ public static void init(@NonNull InstrumentedFragment host) {
+ host.getSettingsLifecycle().addObserver(
+ new SearchMenuController(host, host.getMetricsCategory()));
}
- private SearchMenuController(@NonNull Fragment host) {
+ private SearchMenuController(@NonNull Fragment host, int pageId) {
mHost = host;
+ mPageId = pageId;
}
@Override
@@ -79,8 +82,9 @@
searchItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
searchItem.setOnMenuItemClickListener(target -> {
- final Intent intent = SearchFeatureProvider.SEARCH_UI_INTENT;
- intent.setPackage(SettingsIntelligencePkgName);
+ final Intent intent = FeatureFactory.getFactory(context)
+ .getSearchFeatureProvider()
+ .buildSearchIntent(context, mPageId);
if (context.getPackageManager().queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY).isEmpty()) {
diff --git a/src/com/android/settings/wifi/WifiInfoPreferenceController.java b/src/com/android/settings/wifi/WifiInfoPreferenceController.java
index e847712..2a8c7b5 100644
--- a/src/com/android/settings/wifi/WifiInfoPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiInfoPreferenceController.java
@@ -98,12 +98,11 @@
public void updateWifiInfo() {
if (mWifiMacAddressPref != null) {
final WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
- final int macRandomizationMode = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 0);
+ final boolean macRandomizationSupported = mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported);
final String macAddress = wifiInfo == null ? null : wifiInfo.getMacAddress();
- if (macRandomizationMode == 1
- && WifiInfo.DEFAULT_MAC_ADDRESS.equals(macAddress)) {
+ if (macRandomizationSupported && WifiInfo.DEFAULT_MAC_ADDRESS.equals(macAddress)) {
mWifiMacAddressPref.setSummary(R.string.wifi_status_mac_randomized);
} else if (TextUtils.isEmpty(macAddress)
|| WifiInfo.DEFAULT_MAC_ADDRESS.equals(macAddress)) {
diff --git a/tests/robotests/res/values-mcc999/config.xml b/tests/robotests/res/values-mcc999/config.xml
index da71273..b54781d 100644
--- a/tests/robotests/res/values-mcc999/config.xml
+++ b/tests/robotests/res/values-mcc999/config.xml
@@ -56,7 +56,6 @@
<bool name="config_show_vibrate_input_devices">false</bool>
<bool name="config_show_reset_dashboard">false</bool>
<bool name="config_show_system_update_settings">false</bool>
- <bool name="config_wifi_support_connected_mac_randomization">false</bool>
<bool name="config_show_device_model">false</bool>
<bool name="config_show_top_level_battery">false</bool>
<bool name="config_show_top_level_connected_devices">false</bool>
diff --git a/tests/robotests/res/values/config.xml b/tests/robotests/res/values/config.xml
index 1252ece..15ae899 100644
--- a/tests/robotests/res/values/config.xml
+++ b/tests/robotests/res/values/config.xml
@@ -20,7 +20,6 @@
<bool name="config_show_camera_laser_sensor">true</bool>
<bool name="config_show_connectivity_monitor">true</bool>
<bool name="config_display_recent_apps">true</bool>
- <bool name="config_wifi_support_connected_mac_randomization">true</bool>
<!-- Fake dimen value for restricted icon size - needed to get around Robolectric
issue loading framework hidden resources -->
diff --git a/tests/robotests/src/com/android/settings/accessibility/LiveCaptionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/LiveCaptionPreferenceControllerTest.java
deleted file mode 100644
index f6160b2..0000000
--- a/tests/robotests/src/com/android/settings/accessibility/LiveCaptionPreferenceControllerTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2019 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.android.settings.core.BasePreferenceController.AVAILABLE;
-import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.pm.ResolveInfo;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-import org.robolectric.shadows.ShadowPackageManager;
-
-import java.util.Collections;
-
-@RunWith(RobolectricTestRunner.class)
-public class LiveCaptionPreferenceControllerTest {
-
- private LiveCaptionPreferenceController mController;
-
- @Before
- public void setUp() {
- mController = new LiveCaptionPreferenceController(RuntimeEnvironment.application,
- "test_key");
- }
-
- @Test
- public void getAvailabilityStatus_canResolveIntent_shouldReturnAvailable() {
- final ShadowPackageManager pm = Shadows.shadowOf(
- RuntimeEnvironment.application.getPackageManager());
- pm.addResolveInfoForIntent(LiveCaptionPreferenceController.LIVE_CAPTION_INTENT,
- new ResolveInfo());
-
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
- }
-
- @Test
- public void getAvailabilityStatus_noResolveIntent_shouldReturnUnavailable() {
- final ShadowPackageManager pm = Shadows.shadowOf(
- RuntimeEnvironment.application.getPackageManager());
- pm.setResolveInfosForIntent(LiveCaptionPreferenceController.LIVE_CAPTION_INTENT,
- Collections.emptyList());
-
- assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceControllerTest.java
index bdb7ba3..4e7a800 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceControllerTest.java
@@ -18,13 +18,8 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
import android.content.Context;
-import android.content.pm.PackageManager;
-
-import com.android.settings.applications.defaultapps.DefaultPhonePreferenceController;
+import android.permission.PermissionControllerManager;
import org.junit.Before;
import org.junit.Test;
@@ -33,64 +28,30 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-import org.robolectric.annotation.Implementation;
-import org.robolectric.annotation.Implements;
+import org.robolectric.shadows.ShadowApplication;
@RunWith(RobolectricTestRunner.class)
public class DefaultPhoneShortcutPreferenceControllerTest {
- @Mock
- private PackageManager mPackageManager;
+ private static final String TEST_PACKAGE_NAME = "TestPackage";
+ private static final String PREFERENCE_KEY = "default_phone_app";
- private Context mContext;
+ @Mock
+ private PermissionControllerManager mPermissionControllerManager;
+
private DefaultPhoneShortcutPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mContext = spy(RuntimeEnvironment.application);
- when(mContext.getPackageManager()).thenReturn(mPackageManager);
- mController = new DefaultPhoneShortcutPreferenceController(mContext, "Package1");
+ ShadowApplication.getInstance().setSystemService(Context.PERMISSION_CONTROLLER_SERVICE,
+ mPermissionControllerManager);
+ mController = new DefaultPhoneShortcutPreferenceController(RuntimeEnvironment.application,
+ TEST_PACKAGE_NAME);
}
@Test
public void getPreferenceKey_shouldReturnDefaultPhone() {
- assertThat(mController.getPreferenceKey()).isEqualTo("default_phone_app");
- }
-
- @Test
- @Config(shadows = ShadowDefaultPhonePreferenceController.class)
- public void hasAppCapability_hasPhoneCapability_shouldReturnTrue() {
- assertThat(mController.hasAppCapability()).isTrue();
- }
-
- @Test
- public void hasAppCapability_noPhoneCapability_shouldReturnFalse() {
- assertThat(mController.hasAppCapability()).isFalse();
- }
-
- @Test
- @Config(shadows = ShadowDefaultPhonePreferenceController.class)
- public void isDefaultApp_isDefaultPhone_shouldReturnTrue() {
- assertThat(mController.isDefaultApp()).isTrue();
- }
-
- @Test
- public void isDefaultApp_notDefaultPhone_shouldReturnFalse() {
- assertThat(mController.isDefaultApp()).isFalse();
- }
-
- @Implements(DefaultPhonePreferenceController.class)
- public static class ShadowDefaultPhonePreferenceController {
- @Implementation
- protected static boolean hasPhonePreference(String pkg, Context context) {
- return true;
- }
-
- @Implementation
- protected static boolean isPhoneDefault(String pkg, Context context) {
- return true;
- }
+ assertThat(mController.getPreferenceKey()).isEqualTo(PREFERENCE_KEY);
}
}
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
index 3dc0bc4..27aeccc 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
@@ -91,6 +91,8 @@
private UserManager mUserManager;
@Mock
private PackageManager mPackageManager;
+
+ private Context mContext;
private MenuItem mAppReset;
private MenuItem mSortRecent;
private MenuItem mSortFrequent;
@@ -99,6 +101,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
mAppReset = new RoboMenuItem(R.id.reset_app_preferences);
mSortRecent = new RoboMenuItem(R.id.sort_order_recent_notification);
mSortFrequent = new RoboMenuItem(R.id.sort_order_frequent_notification);
@@ -107,6 +110,7 @@
when(mState.getBackgroundLooper()).thenReturn(Looper.myLooper());
mFragment = spy(new ManageApplications());
+ when(mFragment.getContext()).thenReturn(mContext);
when(mFragment.getActivity()).thenReturn(mActivity);
when(mActivity.getResources()).thenReturn(mResources);
when(mActivity.getSystemService(UserManager.class)).thenReturn(mUserManager);
@@ -460,6 +464,31 @@
assertThat(mFragment.mSortOrder).isEqualTo(mSortFrequent.getItemId());
}
+ @Test
+ public void updateFilterView_hasFilterSet_shouldShowFilterAndHavePaddingTop() {
+ mFragment.mContentContainer = new View(mContext);
+ mFragment.mSpinnerHeader = new View(mContext);
+ mFragment.mFilterAdapter = new ManageApplications.FilterSpinnerAdapter(mFragment);
+
+ mFragment.mFilterAdapter.updateFilterView(true);
+
+ assertThat(mFragment.mSpinnerHeader.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(mFragment.mContentContainer.getPaddingTop()).isEqualTo(
+ mContext.getResources().getDimensionPixelSize(R.dimen.app_bar_height));
+ }
+
+ @Test
+ public void updateFilterView_noFilterSet_shouldHideFilterAndNoPaddingTop() {
+ mFragment.mContentContainer = new View(mContext);
+ mFragment.mSpinnerHeader = new View(mContext);
+ mFragment.mFilterAdapter = new ManageApplications.FilterSpinnerAdapter(mFragment);
+
+ mFragment.mFilterAdapter.updateFilterView(false);
+
+ assertThat(mFragment.mSpinnerHeader.getVisibility()).isEqualTo(View.GONE);
+ assertThat(mFragment.mContentContainer.getPaddingTop()).isEqualTo(0);
+ }
+
private void setUpOptionMenus() {
when(mMenu.findItem(anyInt())).thenAnswer(invocation -> {
final Object[] args = invocation.getArguments();
diff --git a/tests/robotests/src/com/android/settings/backup/BackupSettingsActivityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/backup/BackupSettingsActivityPreferenceControllerTest.java
deleted file mode 100644
index 97ddc4b..0000000
--- a/tests/robotests/src/com/android/settings/backup/BackupSettingsActivityPreferenceControllerTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.settings.backup;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.verify;
-
-import android.app.backup.BackupManager;
-import android.content.Context;
-import android.os.UserManager;
-
-import androidx.preference.Preference;
-
-import com.android.settings.R;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.shadow.api.Shadow;
-import org.robolectric.shadows.ShadowApplication;
-import org.robolectric.shadows.ShadowUserManager;
-
-@RunWith(RobolectricTestRunner.class)
-public class BackupSettingsActivityPreferenceControllerTest {
-
- private static final String KEY_BACKUP_SETTINGS = "backup_settings";
-
- private Context mContext;
- private BackupManager mBackupManager;
- private UserManager mUserManager;
-
- @Mock
- private Preference mBackupPreference;
-
- private BackupSettingsActivityPreferenceController mController;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mContext = RuntimeEnvironment.application;
- mBackupManager = new BackupManager(mContext);
-
- final ShadowApplication shadowApplication = ShadowApplication.getInstance();
- shadowApplication.grantPermissions(android.Manifest.permission.BACKUP);
- shadowApplication.setSystemService(Context.BACKUP_SERVICE, mBackupManager);
-
- mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
-
- mController = new BackupSettingsActivityPreferenceController(mContext, KEY_BACKUP_SETTINGS);
- }
-
- @Test
- public void updateState_backupOn() {
- mBackupManager.setBackupEnabled(true);
-
- mController.updateState(mBackupPreference);
- String summaryString = mContext.getString(R.string.backup_summary_state_on);
- verify(mBackupPreference).setSummary(summaryString);
- }
-
- @Test
- public void updateState_backupOff() {
- mBackupManager.setBackupEnabled(false);
-
- mController.updateState(mBackupPreference);
- String summaryString = mContext.getString(R.string.backup_summary_state_off);
- verify(mBackupPreference).setSummary(summaryString);
- }
-
- @Test
- public void isAvailable_systemUser() {
- final ShadowUserManager sum = Shadow.extract(mUserManager);
- sum.setIsAdminUser(true);
-
- assertThat(mController.isAvailable()).isTrue();
- }
-
- @Test
- public void isAvailable_nonSystemUser() {
- final ShadowUserManager sum = Shadow.extract(mUserManager);
- sum.setIsAdminUser(false);
-
- assertThat(mController.isAvailable()).isFalse();
- }
-
- @Test
- public void getPreferenceKey() {
- assertThat(mController.getPreferenceKey()).isEqualTo(KEY_BACKUP_SETTINGS);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java b/tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java
index 9a809cc..ee8912a 100644
--- a/tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java
+++ b/tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java
@@ -31,12 +31,16 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.os.IBinder;
import android.os.RemoteException;
+import android.os.UserHandle;
+import android.os.UserManager;
import com.android.settings.R;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -47,11 +51,12 @@
import org.robolectric.annotation.Config;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowUserManager;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = BackupSettingsHelperTest.ShadowBackupManagerStub.class)
public class BackupSettingsHelperTest {
-
private static final String DEFAULT_SETTINGS_CLASSNAME =
"com.android.settings.Settings$PrivacySettingsActivity";
@@ -72,12 +77,46 @@
@Mock
private static IBackupManager mBackupManager;
+ private ShadowUserManager mUserManager;
+
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
when(mBackupManager.getCurrentTransport()).thenReturn("test_transport");
mBackupSettingsHelper = new BackupSettingsHelper(mContext);
+ mUserManager = Shadow.extract(mContext.getSystemService(Context.USER_SERVICE));
+ }
+
+ @Test
+ public void testGetSummary_backupEnabledOnlyOneProfile_showsOn() throws Exception {
+ mUserManager.addUserProfile(new UserHandle(0));
+ when(mBackupManager.isBackupEnabled()).thenReturn(true);
+
+ String backupSummary = mBackupSettingsHelper.getSummary();
+
+ assertThat(backupSummary).isEqualTo(mContext.getString(R.string.backup_summary_state_on));
+ }
+
+ @Test
+ public void testGetSummary_backupDisabledOnlyOneProfile_showsOff() throws Exception {
+ mUserManager.addUserProfile(new UserHandle(0));
+ when(mBackupManager.isBackupEnabled()).thenReturn(false);
+
+ String backupSummary = mBackupSettingsHelper.getSummary();
+
+ assertThat(backupSummary).isEqualTo(mContext.getString(R.string.backup_summary_state_off));
+ }
+
+ @Test
+ public void testGetSummary_TwoProfiles_returnsNull() throws Exception {
+ mUserManager.addUserProfile(new UserHandle(0));
+ mUserManager.addUserProfile(new UserHandle(10));
+ when(mBackupManager.isBackupEnabled()).thenReturn(true);
+
+ String backupSummary = mBackupSettingsHelper.getSummary();
+
+ assertThat(backupSummary).isNull();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/backup/BackupSettingsActivityTest.java b/tests/robotests/src/com/android/settings/backup/UserBackupSettingsActivityTest.java
similarity index 82%
rename from tests/robotests/src/com/android/settings/backup/BackupSettingsActivityTest.java
rename to tests/robotests/src/com/android/settings/backup/UserBackupSettingsActivityTest.java
index 931bc1e..19a6051 100644
--- a/tests/robotests/src/com/android/settings/backup/BackupSettingsActivityTest.java
+++ b/tests/robotests/src/com/android/settings/backup/UserBackupSettingsActivityTest.java
@@ -35,8 +35,6 @@
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
-import com.android.settings.search.SearchIndexableRaw;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -54,14 +52,12 @@
import org.robolectric.annotation.Resetter;
import org.robolectric.shadows.ShadowPackageManager;
-import java.util.List;
-
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = {BackupSettingsActivityTest.ShadowBackupSettingsHelper.class,
- BackupSettingsActivityTest.ShadowUserHandle.class})
-public class BackupSettingsActivityTest {
- private ActivityController<BackupSettingsActivity> mActivityController;
- private BackupSettingsActivity mActivity;
+@Config(shadows = {UserBackupSettingsActivityTest.ShadowBackupSettingsHelper.class,
+ UserBackupSettingsActivityTest.ShadowUserHandle.class})
+public class UserBackupSettingsActivityTest {
+ private ActivityController<UserBackupSettingsActivity> mActivityController;
+ private UserBackupSettingsActivity mActivity;
private Application mApplication;
private ShadowPackageManager mPackageManager;
private static boolean mIsBackupProvidedByOEM;
@@ -81,7 +77,7 @@
MockitoAnnotations.initMocks(this);
mApplication = RuntimeEnvironment.application;
- mActivityController = Robolectric.buildActivity(BackupSettingsActivity.class);
+ mActivityController = Robolectric.buildActivity(UserBackupSettingsActivity.class);
mActivity = mActivityController.get();
mPackageManager = Shadows.shadowOf(mApplication.getPackageManager());
when(mIntent.getComponent()).thenReturn(mComponent);
@@ -130,9 +126,9 @@
@Test
public void getNonIndexableKeys_SystemUser() {
- assertThat(BackupSettingsActivity.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(
+ assertThat(UserBackupSettingsActivity.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(
mApplication, true)).isNotEmpty();
- assertThat(BackupSettingsActivity.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
+ assertThat(UserBackupSettingsActivity.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
mApplication)).isEmpty();
}
@@ -140,16 +136,10 @@
public void getNonIndexableKeys_NonSystemUser() {
ShadowUserHandle.setUid(1); // Non-SYSTEM user.
- final List<SearchIndexableRaw> indexableRaws =
- BackupSettingsActivity.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(
- mApplication, true);
- final List<String> nonIndexableKeys =
- BackupSettingsActivity.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
- mApplication);
-
- assertThat(indexableRaws).isNotNull();
- assertThat(indexableRaws).isNotEmpty();
- assertThat(nonIndexableKeys).isNotEmpty();
+ assertThat(UserBackupSettingsActivity.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(
+ mApplication, true)).isNotEmpty();
+ assertThat(UserBackupSettingsActivity.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
+ mApplication)).isEmpty();
}
@Implements(BackupSettingsHelper.class)
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragmentTest.java
index 658a952..2a8aa8e 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragmentTest.java
@@ -16,7 +16,11 @@
package com.android.settings.connecteddevice;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+import android.content.Context;
+import android.nfc.NfcAdapter;
import android.provider.SearchIndexableResource;
import com.android.settings.testutils.shadow.ShadowConnectivityManager;
@@ -26,6 +30,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@@ -40,6 +45,9 @@
private AdvancedConnectedDeviceDashboardFragment mFragment;
+ @Mock
+ private NfcAdapter mNfcAdapter;
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
@@ -69,9 +77,13 @@
@Test
public void testSearchIndexProvider_correctNonIndexables() {
+ Context context = spy(RuntimeEnvironment.application);
+ when(context.getApplicationContext()).thenReturn(context);
+ when(NfcAdapter.getDefaultAdapter(context)).thenReturn(mNfcAdapter);
+ when(mNfcAdapter.deviceSupportsNfcSecure()).thenReturn(true);
final List<String> niks =
AdvancedConnectedDeviceDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
- .getNonIndexableKeys(RuntimeEnvironment.application);
+ .getNonIndexableKeys(context);
assertThat(niks).contains(AdvancedConnectedDeviceDashboardFragment.KEY_BLUETOOTH);
}
diff --git a/tests/robotests/src/com/android/settings/development/WifiConnectedMacRandomizationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/WifiConnectedMacRandomizationPreferenceControllerTest.java
deleted file mode 100644
index 60e7d47..0000000
--- a/tests/robotests/src/com/android/settings/development/WifiConnectedMacRandomizationPreferenceControllerTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.development;
-
-import static com.android.settings.development.WifiConnectedMacRandomizationPreferenceController
- .SETTING_VALUE_OFF;
-import static com.android.settings.development.WifiConnectedMacRandomizationPreferenceController
- .SETTING_VALUE_ON;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.provider.Settings;
-
-import androidx.preference.PreferenceScreen;
-import androidx.preference.SwitchPreference;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-@RunWith(RobolectricTestRunner.class)
-public class WifiConnectedMacRandomizationPreferenceControllerTest {
-
- @Mock
- private PreferenceScreen mPreferenceScreen;
-
- private Context mContext;
- private SwitchPreference mPreference;
- private WifiConnectedMacRandomizationPreferenceController mController;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
- mController = new WifiConnectedMacRandomizationPreferenceController(mContext);
- mPreference = new SwitchPreference(mContext);
- when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
- .thenReturn(mPreference);
- mController.displayPreference(mPreferenceScreen);
- }
-
- @Test
- public void isAvailable_trueSupportFlag_shouldReturnTrue() {
- assertThat(mController.isAvailable()).isTrue();
- }
-
- @Test
- @Config(qualifiers = "mcc999")
- public void isAvailable_falseSupportFlag_shouldReturnFalse() {
- assertThat(mController.isAvailable()).isFalse();
- }
-
- @Test
- public void onPreferenceChange_settingEnabled_shouldEnableConnectedMacRandomization() {
- mController.onPreferenceChange(mPreference, true /* new value */);
-
- final int mode = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, -1 /* default */);
-
- assertThat(mode).isEqualTo(SETTING_VALUE_ON);
- }
-
- @Test
- public void onPreferenceChange_settingDisabled_shouldDisableConnectedMacRandomization() {
- mController.onPreferenceChange(mPreference, false /* new value */);
-
- final int mode = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, -1 /* default */);
-
- assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
- }
-
- @Test
- public void updateState_settingEnabled_shouldEnablePreference() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, SETTING_VALUE_ON);
- mController.updateState(mPreference);
-
- assertThat(mPreference.isChecked()).isTrue();
- }
-
- @Test
- public void updateState_settingDisabled_shouldDisablePreference() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, SETTING_VALUE_OFF);
- mController.updateState(mPreference);
-
- assertThat(mPreference.isChecked()).isFalse();
- }
-
- @Test
- public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
- mController.onDeveloperOptionsSwitchDisabled();
-
- final int mode = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, -1 /* default */);
-
- assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
- assertThat(mPreference.isChecked()).isFalse();
- assertThat(mPreference.isEnabled()).isFalse();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/ModuleVersionDialogControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/ModuleVersionDialogControllerTest.java
index e5958aa..b84ea99 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/ModuleVersionDialogControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/ModuleVersionDialogControllerTest.java
@@ -25,6 +25,9 @@
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
+import android.util.FeatureFlagUtils;
+
+import com.android.settings.core.FeatureFlags;
import org.junit.Before;
import org.junit.Test;
@@ -52,6 +55,17 @@
when(mDialog.getContext()).thenReturn(mContext);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
mController = new ModuleVersionDialogController(mDialog);
+ FeatureFlagUtils.setEnabled(mContext, FeatureFlags.MAINLINE_MODULE, true);
+ }
+
+ @Test
+ public void initialize_featureDisabled_shouldRemoveSettingFromDialog() {
+ FeatureFlagUtils.setEnabled(mContext, FeatureFlags.MAINLINE_MODULE, false);
+
+ mController.initialize();
+
+ verify(mDialog).removeSettingFromScreen(mController.MODULE_VERSION_LABEL_ID);
+ verify(mDialog).removeSettingFromScreen(mController.MODULE_VERSION_VALUE_ID);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/SilentStatusBarPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/SilentStatusBarPreferenceControllerTest.java
new file mode 100644
index 0000000..8a43a1e
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/SilentStatusBarPreferenceControllerTest.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.testutils.FakeFeatureFactory;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+@RunWith(RobolectricTestRunner.class)
+public class SilentStatusBarPreferenceControllerTest {
+
+ @Mock
+ private NotificationBackend mBackend;
+ @Mock
+ private PreferenceScreen mScreen;
+
+ private FakeFeatureFactory mFeatureFactory;
+ private Context mContext;
+ private SilentStatusBarPreferenceController mController;
+ private Preference mPreference;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+ mController = new SilentStatusBarPreferenceController(mContext);
+ mPreference = new Preference(mContext);
+ mPreference.setKey(mController.getPreferenceKey());
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+ }
+
+ @Test
+ public void isAvailable_featureEnabled() {
+ Settings.Secure.putInt(
+ mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 1);
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void isAvailable_featureDisabled() {
+ Settings.Secure.putInt(
+ mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 0);
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void isChecked_settingIsOff_false() {
+ when(mBackend.shouldHideSilentStatusBarIcons(any())).thenReturn(false);
+ assertThat(mController.isChecked()).isFalse();
+ }
+/**
+ @Test
+ public void isChecked_settingIsOn_true() {
+ when(mBackend.shouldHideSilentStatusBarIcons(any())).thenReturn(true);
+ assertThat(mController.isChecked()).isTrue();
+ }
+
+ @Test
+ public void onPreferenceChange_on() {
+ mController.onPreferenceChange(mPreference, true);
+
+ assertThat(mController.isChecked()).isTrue();
+ verify(mBackend).setHideSilentStatusIcons(true);
+ }
+
+ @Test
+ public void onPreferenceChange_off() {
+ mController.onPreferenceChange(mPreference, false);
+
+ assertThat(mController.isChecked()).isFalse();
+ verify(mBackend).setHideSilentStatusIcons(false);
+ }
+ **/
+}
+
diff --git a/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java
index 7f709d6..444a813 100644
--- a/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java
@@ -20,10 +20,12 @@
import static com.google.common.truth.Truth.assertThat;
import android.app.Activity;
+import android.app.settings.SettingsEnums;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ResolveInfo;
+import android.net.Uri;
import android.provider.Settings;
import android.widget.Toolbar;
@@ -60,19 +62,19 @@
@Test
@Config(shadows = ShadowUtils.class)
public void initSearchToolbar_hasResolvedInfo_shouldStartCorrectIntent() {
- final Intent searchIntent = new Intent(SearchFeatureProvider.SEARCH_UI_INTENT)
+ final Intent searchIntent = new Intent(Settings.ACTION_APP_SEARCH_SETTINGS)
.setPackage(mActivity.getString(R.string.config_settingsintelligence_package_name));
final ResolveInfo info = new ResolveInfo();
info.activityInfo = new ActivityInfo();
mPackageManager.addResolveInfoForIntent(searchIntent, info);
// Should not crash.
- mProvider.initSearchToolbar(mActivity, null);
+ mProvider.initSearchToolbar(mActivity, null, SettingsEnums.TESTING);
final Toolbar toolbar = new Toolbar(mActivity);
// This ensures navigationView is created.
toolbar.setNavigationContentDescription("test");
- mProvider.initSearchToolbar(mActivity, toolbar);
+ mProvider.initSearchToolbar(mActivity, toolbar, SettingsEnums.TESTING);
toolbar.performClick();
@@ -87,7 +89,7 @@
final Toolbar toolbar = new Toolbar(mActivity);
// This ensures navigationView is created.
toolbar.setNavigationContentDescription("test");
- mProvider.initSearchToolbar(mActivity, toolbar);
+ mProvider.initSearchToolbar(mActivity, toolbar, SettingsEnums.TESTING);
toolbar.performClick();
@@ -108,6 +110,15 @@
assertThat(Shadows.shadowOf(mActivity).getNextStartedActivity()).isNull();
}
+ @Test
+ public void buildSearchIntent_shouldIncludeReferrer() {
+ final Intent searchIntent = mProvider.buildSearchIntent(mActivity, SettingsEnums.TESTING);
+ final Uri referrer = searchIntent.getParcelableExtra(Intent.EXTRA_REFERRER);
+
+ assertThat(referrer.toSafeString()).isEqualTo(
+ "android-app://" + mActivity.getPackageName() + "/" + SettingsEnums.TESTING);
+ }
+
@Test(expected = IllegalArgumentException.class)
public void verifyLaunchSearchResultPageCaller_nullCaller_shouldCrash() {
mProvider.verifyLaunchSearchResultPageCaller(mActivity, null /* caller */);
diff --git a/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java b/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java
index af1a82d..3063912 100644
--- a/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java
+++ b/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java
@@ -17,11 +17,11 @@
package com.android.settings.search.actionbar;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.Bundle;
import android.provider.Settings.Global;
@@ -29,9 +29,9 @@
import android.view.MenuItem;
import com.android.settings.R;
+import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.testutils.shadow.ShadowUtils;
-import com.android.settingslib.core.lifecycle.ObservableFragment;
-import com.android.settingslib.core.lifecycle.ObservablePreferenceFragment;
import org.junit.Before;
import org.junit.Test;
@@ -49,15 +49,24 @@
@Mock
private Menu mMenu;
private TestPreferenceFragment mPreferenceHost;
- private ObservableFragment mHost;
+ private InstrumentedFragment mHost;
private Context mContext;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
- mHost = spy(new ObservableFragment());
- when(mHost.getContext()).thenReturn(mContext);
+ mHost = new InstrumentedFragment() {
+ @Override
+ public Context getContext() {
+ return mContext;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.TESTING;
+ }
+ };
mPreferenceHost = new TestPreferenceFragment();
Global.putInt(mContext.getContentResolver(), Global.DEVICE_PROVISIONED, 1);
@@ -101,7 +110,7 @@
verifyZeroInteractions(mMenu);
}
- private static class TestPreferenceFragment extends ObservablePreferenceFragment {
+ private static class TestPreferenceFragment extends InstrumentedPreferenceFragment {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
}
@@ -110,5 +119,10 @@
public Context getContext() {
return RuntimeEnvironment.application;
}
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.TESTING;
+ }
}
}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiInfoPreferenceControllerTest.java
index c4a5c78..85d7726 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiInfoPreferenceControllerTest.java
@@ -29,6 +29,7 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.IntentFilter;
+import android.content.res.Resources;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.provider.Settings;
@@ -65,6 +66,8 @@
private Preference mMacPreference;
@Mock
private WifiInfo mWifiInfo;
+ @Mock
+ private Resources mResources;
private Lifecycle mLifecycle;
private LifecycleOwner mLifecycleOwner;
@@ -82,6 +85,7 @@
.thenReturn(mIpPreference);
when(mWifiManager.getConnectionInfo()).thenReturn(mWifiInfo);
when(mWifiManager.getCurrentNetwork()).thenReturn(null);
+ when(mContext.getResources()).thenReturn(mResources);
mController = new WifiInfoPreferenceController(mContext, mLifecycle, mWifiManager);
}
@@ -117,8 +121,9 @@
@Test
public void updateWifiInfo_nullWifiInfoWithMacRandomizationOff_setMacUnavailable() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 0);
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported))
+ .thenReturn(false);
mController.displayPreference(mScreen);
when(mWifiManager.getConnectionInfo()).thenReturn(null);
@@ -129,8 +134,9 @@
@Test
public void updateWifiInfo_nullMacWithMacRandomizationOff_setMacUnavailable() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 0);
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported))
+ .thenReturn(false);
mController.displayPreference(mScreen);
when(mWifiInfo.getMacAddress()).thenReturn(null);
@@ -141,8 +147,9 @@
@Test
public void updateWifiInfo_defaultMacWithMacRandomizationOff_setMacUnavailable() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 0);
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported))
+ .thenReturn(false);
mController.displayPreference(mScreen);
when(mWifiInfo.getMacAddress()).thenReturn(WifiInfo.DEFAULT_MAC_ADDRESS);
@@ -153,8 +160,9 @@
@Test
public void updateWifiInfo_validMacWithMacRandomizationOff_setValidMac() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 0);
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported))
+ .thenReturn(false);
mController.displayPreference(mScreen);
when(mWifiInfo.getMacAddress()).thenReturn(TEST_MAC_ADDRESS);
@@ -165,8 +173,9 @@
@Test
public void updateWifiInfo_nullWifiInfoWithMacRandomizationOn_setMacUnavailable() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 1);
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported))
+ .thenReturn(true);
mController.displayPreference(mScreen);
when(mWifiManager.getConnectionInfo()).thenReturn(null);
@@ -177,8 +186,9 @@
@Test
public void updateWifiInfo_nullMacWithMacRandomizationOn_setMacUnavailable() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 1);
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported))
+ .thenReturn(true);
mController.displayPreference(mScreen);
when(mWifiInfo.getMacAddress()).thenReturn(null);
@@ -189,8 +199,9 @@
@Test
public void updateWifiInfo_defaultMacWithMacRandomizationOn_setMacRandomized() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 1);
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported))
+ .thenReturn(true);
mController.displayPreference(mScreen);
when(mWifiInfo.getMacAddress()).thenReturn(WifiInfo.DEFAULT_MAC_ADDRESS);
@@ -201,8 +212,9 @@
@Test
public void updateWifiInfo_validMacWithMacRandomizationOn_setValidMac() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 1);
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported))
+ .thenReturn(true);
mController.displayPreference(mScreen);
when(mWifiInfo.getMacAddress()).thenReturn(TEST_MAC_ADDRESS);
diff --git a/tests/unit/src/com/android/settings/backup/BackupIntentTest.java b/tests/unit/src/com/android/settings/backup/BackupIntentTest.java
index 18fb17a..0115c56 100644
--- a/tests/unit/src/com/android/settings/backup/BackupIntentTest.java
+++ b/tests/unit/src/com/android/settings/backup/BackupIntentTest.java
@@ -37,12 +37,9 @@
@RunWith(AndroidJUnit4.class)
@SmallTest
public class BackupIntentTest {
-
private static final String INTENT_PRIVACY_SETTINGS = "android.settings.PRIVACY_SETTINGS";
- private static final String INTENT_BACKUP_SETTINGS =
- "android.settings.BACKUP_AND_RESET_SETTINGS";
private static final String BACKUP_SETTINGS_ACTIVITY =
- "com.android.settings.backup.BackupSettingsActivity";
+ "com.android.settings.backup.UserBackupSettingsActivity";
private Context mContext;
@@ -53,17 +50,6 @@
}
@Test
- public void testBackupSettingsIntentResolvesToOnlyOneActivity(){
- PackageManager pm = mContext.getPackageManager();
- Intent intent = new Intent(INTENT_BACKUP_SETTINGS);
- List<ResolveInfo> activities = pm.queryIntentActivities(intent, 0);
- assertThat(activities).isNotNull();
- assertThat(activities.size()).isEqualTo(1);
- assertThat(activities.get(0).activityInfo.getComponentName().getClassName()).
- isEqualTo(BACKUP_SETTINGS_ACTIVITY);
- }
-
- @Test
public void testPrivacySettingsIntentResolvesToOnlyOneActivity(){
PackageManager pm = mContext.getPackageManager();
Intent intent = new Intent(INTENT_PRIVACY_SETTINGS);
@@ -73,5 +59,4 @@
assertThat(activities.get(0).activityInfo.getComponentName().getClassName()).
isEqualTo(BACKUP_SETTINGS_ACTIVITY);
}
-
}