Merge "Revert "access system resources with android.R package"" into rvc-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d01f8be..2fd7e45 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2742,7 +2742,7 @@
<!-- Display settings screen, display white balance settings summary [CHAR LIMIT=NONE] -->
<string name="display_white_balance_summary"></string>
<!-- Display settings screen, setting option name to enable adaptive sleep [CHAR LIMIT=30] -->
- <string name="adaptive_sleep_title">Turn on screen attention</string>
+ <string name="adaptive_sleep_title">Screen attention</string>
<!-- Setting option summary when adaptive sleep is on [CHAR LIMIT=NONE] -->
<string name="adaptive_sleep_summary_on">On / Screen won\u2019t turn off if you\u2019re looking at it</string>
<!-- Setting option summary when adaptive sleep is off [CHAR LIMIT=NONE] -->
@@ -2755,6 +2755,8 @@
<string name="adaptive_sleep_description">Prevents your screen from turning off if you\u2019re looking at it</string>
<!-- Description feature's privacy sensitive details to make sure users understand what feature users, what it saves/sends etc [CHAR LIMIT=NONE]-->
<string name="adaptive_sleep_privacy">Screen attention uses the front camera to see if someone is looking at the screen. It works on device, and images are never stored or sent to Google.</string>
+ <!-- Title of the contextual adaptive sleep card [CHAR LIMIT=NONE]-->
+ <string name="adaptive_sleep_contextual_slice_title">Turn on screen attention</string>
<!-- Description about the contextual adaptive sleep card [CHAR LIMIT=NONE]-->
<string name="adaptive_sleep_contextual_slice_summary">Keep screen on when looking at it</string>
@@ -7194,6 +7196,9 @@
<string name="help_url_double_tap_screen" translatable="false"></string>
<string name="help_url_account_detail" translatable="false"></string>
<string name="help_url_icc_lock" translatable="false"></string>
+ <!-- Help URI, ManageSubscription [DO NOT TRANSLATE] -->
+ <string name="help_url_manage_wifi_subscription" translatable="false"></string>
+
<string name="help_uri_process_stats_summary" translatable="false"></string>
<string name="help_uri_process_stats_apps" translatable="false"></string>
<string name="help_uri_private_dns" translatable="false"></string>
@@ -7265,7 +7270,7 @@
<string name="contact_discovery_opt_in_dialog_title">Enable contact discovery?</string>
<!-- Text displayed in the dialog shown when the user tries to enable Contact Discovery.
[CHAR LIMIT=NONE]-->
- <string name="contact_discovery_opt_in_dialog_message">Enabling this feature will allow your carrier access to phone numbers in your contacts in order to discover which calling features they support.</string>
+ <string name="contact_discovery_opt_in_dialog_message">All of the phone numbers in your contacts will be periodically sent to your carrier in order to discover which calling features are supported.</string>
<!-- Preferred network type title. [CHAR LIMIT=50] -->
<string name="preferred_network_type_title">Preferred network type</string>
<!-- Preferred network type summary. [CHAR LIMIT=100] -->
@@ -8187,6 +8192,24 @@
<!-- Button to cancel out of the dialog shown when the user has disabled bubbles at the feature level but tries to enable it for an app. [CHAR LIMIT=60] -->
<string name="bubbles_feature_disabled_button_cancel">Cancel</string>
+ <!-- Bubble feature settings: Description for toggle when bubbles are turned on in notification settings [CHAR LIMIT=100] -->
+ <string name="notifications_bubble_setting_on_summary">On / Conversations can appear as floating icons</string>
+ <!-- Bubble feature settings: Title of the toggle to turn bubbles on and off [CHAR LIMIT=100] -->
+ <string name="notifications_bubble_setting_title">Allow apps to show bubbles</string>
+ <!-- Bubble feature settings: Description shown with the toggle to turn bubbles on and off [CHAR LIMIT=NONE]-->
+ <string name="notifications_bubble_setting_description">Some conversations will appear as floating icons on top of other apps</string>
+
+ <!-- Bubble app settings: option allowing all conversations from an app to bubble if the app sends bubbles [CHAR LIMIT=60]-->
+ <string name="bubble_app_setting_all">All conversations can bubble</string>
+ <!-- Bubble app settings: option allowing only user selected conversations from an app to bubble if the app sends bubbles [CHAR LIMIT=60] -->
+ <string name="bubble_app_setting_selected">Selected conversations can bubble</string>
+ <!-- Bubble app settings: option allowing no bubbles from the app [CHAR LIMIT=60] -->
+ <string name="bubble_app_setting_none">Nothing can bubble</string>
+ <!-- Bubble app settings: Title above a list of conversations that have been selected to bubble [CHAR LIMIT=60]-->
+ <string name="bubble_app_setting_selected_conversation_title">Conversations</string>
+ <!-- Bubble app settings: Title above a list of conversations that have been excluded from bubbling [CHAR LIMIT=60] -->
+ <string name="bubble_app_setting_excluded_conversation_title">Excluded</string>
+
<!-- Configure notifications: title for swipe direction [CHAR LIMIT=60] -->
<string name="swipe_direction_title">Swipe actions</string>
@@ -8552,58 +8575,98 @@
<!-- Apps > App Details > Picture-in-picture > Description. [CHAR LIMIT=NONE] -->
<string name="picture_in_picture_app_detail_summary">Allow this app to create a picture-in-picture window while the app is open or after you leave it (for example, to continue watching a video). This window displays on top of other apps you\'re using.</string>
- <!-- Special access > Title for managing the settings where users opt-in to connect a work app
- to its personal equivalent, allowing cross-profile communication. [CHAR LIMIT=50] -->
- <string name="interact_across_profiles_title" translatable="false">Connected personal and work apps</string>
+ <!-- Settings label. This setting shows a user's connected work and personal apps.
+ When a user connects select work and personal apps, they can access work and personal data together. [CHAR LIMIT=50] -->
+ <string name="interact_across_profiles_title">Connected work & personal apps</string>
- <!-- Special access > Connected personal and work apps > Text to display when the list is empty. [CHAR LIMIT=NONE] -->
- <string name="interact_across_profiles_empty_text" translatable="false">No connected apps</string>
+ <!-- Settings subtext. This text is shown when a user doesn't have any connected apps. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_empty_text">No connected apps</string>
- <!-- Special access > Connected personal and work apps > Additional keywords to search for. [CHAR LIMIT=NONE] -->
- <string name="interact_across_profiles_keywords" translatable="false">cross profile connected app apps work and personal</string>
+ <!-- Search keywords. If a user is searching for the "Connected work & personal apps" feature in Settings,
+ these keywords will surface that feature. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_keywords">cross profile connected app apps work and personal</string>
- <!-- Apps > App Details > Advanced section string title. [CHAR LIMIT=NONE] -->
- <string name="interact_across_profiles_app_detail_title" translatable="false">Connected personal and work apps</string>
+ <!-- Settings header. This setting shows a user's connected work and personal apps.
+ When a user connects select work and personal apps, they can access work and personal data together. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_app_detail_title">Connected work & personal apps</string>
- <!-- Apps > App Details > Connected personal and work apps > Switch title. [CHAR LIMIT=NONE] -->
- <string name="interact_across_profiles_switch_enabled" translatable="false">Connected</string>
+ <!-- Toggle label. This text is shown when a user's work and personal apps are connected. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_switch_enabled">Connected</string>
- <!-- Apps > App Details > Connected personal and work apps > Switch title. [CHAR LIMIT=NONE] -->
- <string name="interact_across_profiles_switch_disabled" translatable="false">Connect these apps</string>
+ <!-- Toggle label. This text is shown when a user can connect specific work and personal apps.
+ The apps they can connect are shown above this toggle. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_switch_disabled">Connect these apps</string>
- <!-- Apps > App Details > Connected personal and work apps > Description. [CHAR LIMIT=NONE] -->
- <string name="interact_across_profiles_summary_1" translatable="false">Connected apps share permissions and can access each other\u2019s data.</string>
+ <!-- Settings text. This text lets a user know that if they connect work and personal apps,
+ they will share permissions and can access each other's data. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_summary_1">Connected apps share permissions and can access each other\u2019s data.</string>
- <!-- Apps > App Details > Connected personal and work apps > Description. [CHAR LIMIT=NONE] -->
- <string name="interact_across_profiles_summary_2" translatable="false">Only connect apps that you trust with your personal data. Work apps may expose your data to your IT admin.</string>
+ <!-- Settings text. This text lets a user know that they should only connect work and personal apps
+ if they trust the work app with their personal data. The work app could potentially show that data
+ to the user's IT admin. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_summary_2">Only connect apps that you trust with your personal data. Work apps may expose your data to your IT admin.</string>
- <!-- Apps > App Details > Connected personal and work apps > Consent dialog title. [CHAR LIMIT=NONE] -->
- <string name="interact_across_profiles_consent_dialog_title" translatable="false">Trust work %1$s with your personal data?</string>
+ <!-- Dialog title. This dialog is shown when a user tries to connect a work app to a personal
+ app (e.g. their work Calendar to their personal Calendar), and it's confirming that they should
+ connect the apps only if they trust the work app with their personal data. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_consent_dialog_title">Trust work <xliff:g id="name" example="Calendar">%1$s</xliff:g> with your personal data?</string>
- <!-- Apps > App Details > Connected personal and work apps > Consent dialog description. [CHAR LIMIT=NONE] -->
- <string name="interact_across_profiles_consent_dialog_summary" translatable="false">%1$s may expose your personal data to your IT admin.</string>
+ <!-- Dialog text. This dialog is shown when a user tries to connect a work app to a personal
+ app (e.g. their work Calendar to their personal Calendar), and it's confirming that they should
+ connect the apps only if they trust the work app with their personal data.
+ The placeholder is the app name. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_consent_dialog_summary"><xliff:g id="name" example="Calendar">%1$s</xliff:g> may expose your personal data to your IT admin.</string>
- <!-- Apps > App Details > Connected personal and work apps > Consent dialog App data title. [CHAR LIMIT=NONE] -->
- <string name="interact_across_profiles_consent_dialog_app_data_title" translatable="false">App data</string>
+ <!-- Title of a section in a dialog. This section shows the app data that will be
+ accessible when work and personal apps are connected. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_consent_dialog_app_data_title">App data</string>
- <!-- Apps > App Details > Connected personal and work apps > Consent dialog App data description. [CHAR LIMIT=NONE] -->
- <string name="interact_across_profiles_consent_dialog_app_data_summary" translatable="false">It can access data in your personal %1$s app.</string>
+ <!-- Dialog text. This text lets the user know that their work app (e.g. Calendar) will be
+ able to access data in their personal app. The placeholder is the app name. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_consent_dialog_app_data_summary">This app can access data in your personal <xliff:g id="name" example="Calendar">%1$s</xliff:g> app.</string>
- <!-- Apps > App Details > Connected personal and work apps > Consent dialog Permissions title. [CHAR LIMIT=NONE] -->
- <string name="interact_across_profiles_consent_dialog_permissions_title" translatable="false">Permissions</string>
+ <!-- Title of a section in a dialog. This section shows the permissions that will be accessible
+ when work and personal apps are connected. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_consent_dialog_permissions_title">Permissions</string>
- <!-- Apps > App Details > Connected personal and work apps > Consent dialog Permissions description. [CHAR LIMIT=NONE] -->
- <string name="interact_across_profiles_consent_dialog_permissions_summary" translatable="false">It can use your personal %1$s app\u2019s permissions, like access to location, storage, or contacts.</string>
+ <!-- Dialog text. This text lets the user know that their work app (e.g. Calendar) will be able
+ to use permissions in their personal app. The placeholder is the app name. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_consent_dialog_permissions_summary">This app can use your personal <xliff:g id="name" example="Calendar">%1$s</xliff:g> app\u2019s permissions, like access to location, storage, or contacts.</string>
- <!-- Summary of preference to manage connected personal and work apps, informing the user that currently no apps are connected -->
- <string name="interact_across_profiles_number_of_connected_apps_none" translatable="false">No apps connected</string>
+ <!-- Summary of preference to manage connected work and personal apps, informing the user that
+ currently no apps are connected [CHAR LIMIT=NONE]-->
+ <string name="interact_across_profiles_number_of_connected_apps_none">No apps connected</string>
- <!-- Summary of preference to manage connected personal and work apps, informing the user how many apps are connected -->
- <plurals name="interact_across_profiles_number_of_connected_apps" translatable="false">
+ <!-- Summary of preference to manage connected work and personal apps, informing the user how many apps are connected -->
+ <plurals name="interact_across_profiles_number_of_connected_apps">
<item quantity="one"><xliff:g id="count">%d</xliff:g> app connected</item>
<item quantity="other"><xliff:g id="count">%d</xliff:g> apps connected</item>
</plurals>
+ <!-- Banner title. This banner lets a user know that they need to install an app in their
+ work profile in order to connect it to the corresponding personal app.
+ The placeholder would be the app name (e.g. Calendar). [CHAR LIMIT=50]-->
+ <string name="interact_across_profiles_install_work_app_title">Install <xliff:g id="name" example="Calendar">%1$s</xliff:g> in your work profile</string>
+
+ <!-- Banner text. This banner lets a user know that they need to install an app in their
+ work profile in order to connect it to the corresponding personal app.
+ The placeholder would be the app name (e.g. Calendar). [CHAR LIMIT=NONE]-->
+ <string name="interact_across_profiles_install_work_app_summary">To connect these apps, install the <xliff:g id="name" example="Calendar">%1$s</xliff:g> app in your work profile</string>
+
+ <!-- Banner title. This banner lets a user know that they need to install an app in their
+ personal profile in order to connect it to the corresponding work app.
+ The placeholder would be the app name (e.g. Calendar). [CHAR LIMIT=50]-->
+ <string name="interact_across_profiles_install_personal_app_title">Install <xliff:g id="name" example="Calendar">%1$s</xliff:g> in your personal profile</string>
+
+ <!-- Banner text. This banner lets a user know that they need to install an app in their
+ personal profile in order to connect it to the corresponding work app.
+ The placeholder would be the app name (e.g. Calendar). [CHAR LIMIT=NONE]-->
+ <string name="interact_across_profiles_install_personal_app_summary">To connect these apps, install the <xliff:g id="name" example="Calendar">%1$s</xliff:g> app in your personal profile</string>
+
+ <!-- Button text. This button takes a user to the app store so they can download and
+ install the app they need. [CHAR LIMIT=50]-->
+ <string name="interact_across_profiles_install_app_action">Get the app</string>
+
<!-- Sound & notification > Advanced section: Title for managing Do Not Disturb access option. [CHAR LIMIT=40] -->
<string name="manage_zen_access_title">Do Not Disturb access</string>
@@ -10491,6 +10554,11 @@
<!-- [CHAR LIMIT=60] Name of dev option to enable extra quick settings tiles -->
<string name="quick_settings_developer_tiles">Quick settings developer tiles</string>
+ <!-- [CHAR LIMIT=50] Setting title to disable the adb authorization timeout feature. -->
+ <string name="adb_authorization_timeout_title">Disable adb authorization timeout</string>
+ <!-- [CHAR LIMIT=NONE] Setting summary explaining the disablement of the automatic adb authorization timeout. -->
+ <string name="adb_authorization_timeout_summary">Disable automatic revocation of adb authorizations for systems that have not reconnected within the default (7 days) or user-configured (minimum 1 day) amount of time.</string>
+
<!-- [CHAR LIMIT=25] Title of developer tile to toggle winscope trace -->
<string name="winscope_trace_quick_settings_title">Winscope Trace</string>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index b4d0bba..48a0850 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -149,6 +149,11 @@
settings:keywords="@string/keywords_adb_wireless" />
<SwitchPreference
+ android:key="adb_authorization_timeout"
+ android:title="@string/adb_authorization_timeout_title"
+ android:summary="@string/adb_authorization_timeout_summary" />
+
+ <SwitchPreference
android:key="enable_terminal"
android:title="@string/enable_terminal_title"
android:summary="@string/enable_terminal_summary" />
diff --git a/src/com/android/settings/development/AdbAuthorizationTimeoutPreferenceController.java b/src/com/android/settings/development/AdbAuthorizationTimeoutPreferenceController.java
new file mode 100644
index 0000000..79aa8e6
--- /dev/null
+++ b/src/com/android/settings/development/AdbAuthorizationTimeoutPreferenceController.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2020 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.preference.Preference;
+import androidx.preference.SwitchPreference;
+
+import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+
+/**
+ * Preference controller for the developer option to disable the automatic revocation of adb
+ * authorizations.
+ */
+public class AdbAuthorizationTimeoutPreferenceController extends
+ DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener {
+ private static final String ADB_AUTHORIZATION_TIMEOUT_KEY = "adb_authorization_timeout";
+
+ private final Context mContext;
+
+ public AdbAuthorizationTimeoutPreferenceController(Context context) {
+ super(context);
+ mContext = context;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return ADB_AUTHORIZATION_TIMEOUT_KEY;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ final long authTimeout = Settings.Global.getLong(mContext.getContentResolver(),
+ Settings.Global.ADB_ALLOWED_CONNECTION_TIME,
+ Settings.Global.DEFAULT_ADB_ALLOWED_CONNECTION_TIME);
+ // An authTimeout of 0 indicates this preference is enabled and adb authorizations will not
+ // be automatically revoked.
+ ((SwitchPreference) mPreference).setChecked(authTimeout == 0);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ writeSetting((boolean) newValue);
+ return true;
+ }
+
+ @Override
+ public void onDeveloperOptionsSwitchDisabled() {
+ super.onDeveloperOptionsSwitchDisabled();
+ writeSetting(false);
+ ((SwitchPreference) mPreference).setChecked(false);
+ }
+
+ private void writeSetting(boolean isEnabled) {
+ long authTimeout = 0;
+ if (!isEnabled) {
+ authTimeout = Settings.Global.DEFAULT_ADB_ALLOWED_CONNECTION_TIME;
+ }
+ Settings.Global.putLong(mContext.getContentResolver(),
+ Settings.Global.ADB_ALLOWED_CONNECTION_TIME,
+ authTimeout);
+ }
+}
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index 8c79f2a..c349de9 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -444,6 +444,7 @@
controllers.add(new AdbPreferenceController(context, fragment));
controllers.add(new ClearAdbKeysPreferenceController(context, fragment));
controllers.add(new WirelessDebuggingPreferenceController(context, lifecycle));
+ controllers.add(new AdbAuthorizationTimeoutPreferenceController(context));
controllers.add(new LocalTerminalPreferenceController(context));
controllers.add(new BugReportInPowerPreferenceController(context));
controllers.add(new AutomaticSystemServerHeapDumpPreferenceController(context));
diff --git a/src/com/android/settings/homepage/contextualcards/slices/ContextualAdaptiveSleepSlice.java b/src/com/android/settings/homepage/contextualcards/slices/ContextualAdaptiveSleepSlice.java
index c94469a..b9cc202 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/ContextualAdaptiveSleepSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/ContextualAdaptiveSleepSlice.java
@@ -81,7 +81,8 @@
if (isSettingsAvailable() && !isUserInteracted() && !isRecentlySetup() && !isTurnedOn()) {
final IconCompat icon = IconCompat.createWithResource(mContext,
R.drawable.ic_settings_adaptive_sleep);
- final CharSequence title = mContext.getText(R.string.adaptive_sleep_title);
+ final CharSequence title =
+ mContext.getText(R.string.adaptive_sleep_contextual_slice_title);
final CharSequence subtitle = mContext.getText(
R.string.adaptive_sleep_contextual_slice_summary);
diff --git a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
index 5ac407d..2716e4c 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
@@ -467,7 +467,7 @@
return true;
}
- return channel.isBlockableSystem()
+ return channel.isBlockable()
|| channel.getImportance() == IMPORTANCE_NONE;
}
diff --git a/src/com/android/settings/notification/app/NotificationPreferenceController.java b/src/com/android/settings/notification/app/NotificationPreferenceController.java
index be1ce1b..ecba95b 100644
--- a/src/com/android/settings/notification/app/NotificationPreferenceController.java
+++ b/src/com/android/settings/notification/app/NotificationPreferenceController.java
@@ -134,7 +134,7 @@
return channel.getImportance() == IMPORTANCE_NONE;
}
- return channel.isBlockableSystem() || !mAppRow.systemApp
+ return channel.isBlockable() || !mAppRow.systemApp
|| channel.getImportance() == IMPORTANCE_NONE;
}
return false;
diff --git a/src/com/android/settings/wifi/UseOpenWifiPreferenceController.java b/src/com/android/settings/wifi/UseOpenWifiPreferenceController.java
index 27cf1e2..44114e5 100644
--- a/src/com/android/settings/wifi/UseOpenWifiPreferenceController.java
+++ b/src/com/android/settings/wifi/UseOpenWifiPreferenceController.java
@@ -100,6 +100,10 @@
@Override
public int getAvailabilityStatus() {
+ // It is possible that mEnableUseWifiComponentName is no longer enabled by
+ // USE_OPEN_WIFI_PACKAGE. So update this component to reflect correct availability.
+ updateEnableUseWifiComponentName();
+ checkForFeatureSupportedScorers();
return mDoFeatureSupportedScorersExist ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
diff --git a/src/com/android/settings/wifi/WifiSettings2.java b/src/com/android/settings/wifi/WifiSettings2.java
index 5152569..b94994e 100644
--- a/src/com/android/settings/wifi/WifiSettings2.java
+++ b/src/com/android/settings/wifi/WifiSettings2.java
@@ -22,6 +22,7 @@
import android.app.Activity;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
+import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
@@ -69,6 +70,7 @@
import com.android.settings.widget.SwitchBarController;
import com.android.settings.wifi.details2.WifiNetworkDetailsFragment2;
import com.android.settings.wifi.dpp.WifiDppUtils;
+import com.android.settingslib.HelpUtils;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.search.Indexable;
@@ -109,6 +111,7 @@
@VisibleForTesting
static final int ADD_NETWORK_REQUEST = 2;
static final int CONFIG_NETWORK_REQUEST = 3;
+ static final int MANAGE_SUBSCRIPTION = 4;
private static final String PREF_KEY_EMPTY_WIFI_LIST = "wifi_empty_list";
// TODO(b/70983952): Rename these to use WifiEntry instead of AccessPoint.
@@ -428,6 +431,9 @@
}
}
return;
+ } else if (requestCode == MANAGE_SUBSCRIPTION) {
+ //Do nothing
+ return;
}
final boolean formerlyRestricted = mIsRestricted;
@@ -750,6 +756,12 @@
pref.setKey(wifiEntry.getKey());
pref.setOrder(index++);
pref.refresh();
+
+ if (wifiEntry.canManageSubscription()) {
+ pref.setOnButtonClickListener(preference -> {
+ openSubscriptionHelpPage();
+ });
+ }
mWifiEntryPreferenceCategory.addPreference(pref);
}
removeCachedPrefs(mWifiEntryPreferenceCategory);
@@ -1061,4 +1073,24 @@
int reason = networkStatus.getNetworkSelectionDisableReason();
return WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD == reason;
}
+
+ @VisibleForTesting
+ void openSubscriptionHelpPage() {
+ final Intent intent = getHelpIntent(getContext());
+ if (intent != null) {
+ try {
+ startActivityForResult(intent, MANAGE_SUBSCRIPTION);
+ } catch (ActivityNotFoundException e) {
+ Log.e(TAG, "Activity was not found for intent, " + intent.toString());
+ }
+ }
+ }
+
+ @VisibleForTesting
+ Intent getHelpIntent(Context context) {
+ return HelpUtils.getHelpIntent(
+ context,
+ context.getString(R.string.help_url_manage_wifi_subscription),
+ context.getClass().getName());
+ }
}
diff --git a/tests/robotests/src/com/android/settings/development/AdbAuthorizationTimeoutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/AdbAuthorizationTimeoutPreferenceControllerTest.java
new file mode 100644
index 0000000..bc3544d
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/AdbAuthorizationTimeoutPreferenceControllerTest.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2020 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 junit.framework.Assert.assertEquals;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class AdbAuthorizationTimeoutPreferenceControllerTest {
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ @Mock
+ private DevelopmentSettingsDashboardFragment mFragment;
+
+ private Context mContext;
+ private ContentResolver mContentResolver;
+ private SwitchPreference mPreference;
+ private AdbAuthorizationTimeoutPreferenceController mPreferenceController;
+ private long mInitialAuthTimeout;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mContentResolver = mContext.getContentResolver();
+
+ mPreferenceController = new AdbAuthorizationTimeoutPreferenceController(mContext);
+ mPreference = spy(new SwitchPreference(mContext));
+ when(mPreferenceScreen.findPreference(mPreferenceController.getPreferenceKey())).thenReturn(
+ mPreference);
+ mPreferenceController.displayPreference(mPreferenceScreen);
+
+ mInitialAuthTimeout = Settings.Global.getLong(mContext.getContentResolver(),
+ Settings.Global.ADB_ALLOWED_CONNECTION_TIME,
+ Settings.Global.DEFAULT_ADB_ALLOWED_CONNECTION_TIME);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ Settings.Global.putLong(mContext.getContentResolver(),
+ Settings.Global.ADB_ALLOWED_CONNECTION_TIME, mInitialAuthTimeout);
+ }
+
+ @Test
+ public void onPreferenceChange_enableSetting_timeoutSetToZero() throws Exception {
+ // This developer option disables the automatic adb authorization revocation by setting
+ // the timeout value to 0 when enabled.
+ mPreferenceController.onPreferenceChange(mPreference, true);
+ long authTimeout = Settings.Global.getLong(mContentResolver,
+ Settings.Global.ADB_ALLOWED_CONNECTION_TIME);
+
+ assertEquals(0, authTimeout);
+ }
+
+ @Test
+ public void onPreferenceChange_enableAndDisableSetting_timeoutSetToDefault()
+ throws Exception {
+ // A non-default setting value is not saved when this developer option is enabled and the
+ // setting value is set to 0. If the user subsequently disables the option the setting
+ // value is restored to the default value.
+ Settings.Global.putLong(mContentResolver, Settings.Global.ADB_ALLOWED_CONNECTION_TIME, 1);
+
+ mPreferenceController.onPreferenceChange(mPreference, true);
+ mPreferenceController.onPreferenceChange(mPreference, false);
+ long authTimeout = Settings.Global.getLong(mContentResolver,
+ Settings.Global.ADB_ALLOWED_CONNECTION_TIME);
+
+ assertEquals(Settings.Global.DEFAULT_ADB_ALLOWED_CONNECTION_TIME, authTimeout);
+ }
+
+ @Test
+ public void updateState_timeoutSetToZero_preferenceDisplayedEnabled() throws Exception {
+ Settings.Global.putLong(mContentResolver, Settings.Global.ADB_ALLOWED_CONNECTION_TIME, 0);
+
+ mPreferenceController.updateState(mPreference);
+
+ verify(mPreference).setChecked(true);
+ }
+
+ @Test
+ public void updateState_timeoutSetToDefault_preferenceDisplayedDisabled() throws Exception {
+ Settings.Global.putLong(mContentResolver, Settings.Global.ADB_ALLOWED_CONNECTION_TIME,
+ Settings.Global.DEFAULT_ADB_ALLOWED_CONNECTION_TIME);
+
+ mPreferenceController.updateState(mPreference);
+
+ verify(mPreference).setChecked(false);
+ }
+
+ @Test
+ public void onDeveloperOptionsSwitchDisabled_preferenceAndTimeoutDisabled() throws Exception {
+ mPreferenceController.onDeveloperOptionsSwitchDisabled();
+
+ long authTimeout = Settings.Global.getLong(mContentResolver,
+ Settings.Global.ADB_ALLOWED_CONNECTION_TIME);
+
+ assertEquals(Settings.Global.DEFAULT_ADB_ALLOWED_CONNECTION_TIME, authTimeout);
+ verify(mPreference).setChecked(false);
+ }
+}
+
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/ContextualAdaptiveSleepSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/ContextualAdaptiveSleepSliceTest.java
index 0a88d64..3261902 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/ContextualAdaptiveSleepSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/ContextualAdaptiveSleepSliceTest.java
@@ -66,7 +66,7 @@
mContext = spy(RuntimeEnvironment.application);
mContextualAdaptiveSleepSlice = spy(new ContextualAdaptiveSleepSlice(mContext));
- Settings.System.putInt(mContext.getContentResolver(), Settings.System.ADAPTIVE_SLEEP, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.ADAPTIVE_SLEEP, 0);
doReturn(mPackageManager).when(mContext).getPackageManager();
doReturn(mSharedPreferences).when(mContext).getSharedPreferences(eq(PREF), anyInt());
doReturn(true).when(mContextualAdaptiveSleepSlice).isSettingsAvailable();
@@ -124,7 +124,7 @@
@Test
public void getSlice_DoNotShowIFTurnedOn() {
- Settings.System.putInt(mContext.getContentResolver(), Settings.System.ADAPTIVE_SLEEP, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.ADAPTIVE_SLEEP, 1);
final Slice slice = mContextualAdaptiveSleepSlice.getSlice();
diff --git a/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java
index b83ab77..d203c47 100644
--- a/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java
@@ -200,7 +200,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- channel.setBlockableSystem(true);
+ channel.setBlockable(true);
mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
assertTrue(mSwitch.isEnabled());
diff --git a/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java
index 170a5e0..259f40e 100644
--- a/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java
@@ -236,7 +236,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = false;
NotificationChannel channel = mock(NotificationChannel.class);
- when(channel.isBlockableSystem()).thenReturn(false);
+ when(channel.isBlockable()).thenReturn(false);
mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isChannelBlockable());
@@ -247,7 +247,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
NotificationChannel channel = mock(NotificationChannel.class);
- when(channel.isBlockableSystem()).thenReturn(false);
+ when(channel.isBlockable()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
mController.onResume(appRow, channel, null, null, null, null);
@@ -259,7 +259,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
NotificationChannel channel = mock(NotificationChannel.class);
- when(channel.isBlockableSystem()).thenReturn(true);
+ when(channel.isBlockable()).thenReturn(true);
mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isChannelBlockable());
@@ -270,7 +270,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
NotificationChannel channel = mock(NotificationChannel.class);
- when(channel.isBlockableSystem()).thenReturn(false);
+ when(channel.isBlockable()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
mController.onResume(appRow, channel, null, null, null, null);
diff --git a/tests/robotests/src/com/android/settings/wifi/UseOpenWifiPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/UseOpenWifiPreferenceControllerTest.java
index beaa1a6..ca636a4 100644
--- a/tests/robotests/src/com/android/settings/wifi/UseOpenWifiPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/UseOpenWifiPreferenceControllerTest.java
@@ -39,7 +39,6 @@
import android.provider.Settings;
import androidx.fragment.app.Fragment;
-import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import com.android.settings.R;
@@ -144,6 +143,19 @@
}
@Test
+ public void isAvailable_disableUseOpenWifiComponentBetweenCalls_returnsTrueThenReturnsFalse() {
+ setupScorers(Lists.newArrayList(sAppData));
+ createController();
+
+ assertThat(mController.isAvailable()).isTrue();
+
+ // Update NetworkScorerAppData so that it no longer has openWifiActivity.
+ setupScorers(Lists.newArrayList(sAppDataNoActivity));
+
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
public void setChecked_withTrue_enableShouldStartEnableActivity() {
setupScorers(Lists.newArrayList(sAppData, sAppDataNoActivity));
createController();
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
index 2af87fe..c85ea49 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
@@ -25,6 +25,7 @@
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -98,13 +99,14 @@
@Test
public void addNetworkFragmentSendResult_onActivityResult_shouldHandleEvent() {
- final WifiSettings wifiSettings = spy(new WifiSettings());
+ final WifiSettings2 wifiSettings2 = spy(new WifiSettings2());
final Intent intent = new Intent();
- doNothing().when(wifiSettings).handleAddNetworkRequest(anyInt(), any(Intent.class));
+ doNothing().when(wifiSettings2).handleAddNetworkRequest(anyInt(), any(Intent.class));
- wifiSettings.onActivityResult(WifiSettings.ADD_NETWORK_REQUEST, Activity.RESULT_OK, intent);
+ wifiSettings2.onActivityResult(WifiSettings2.ADD_NETWORK_REQUEST, Activity.RESULT_OK,
+ intent);
- verify(wifiSettings).handleAddNetworkRequest(anyInt(), any(Intent.class));
+ verify(wifiSettings2).handleAddNetworkRequest(anyInt(), any(Intent.class));
}
@Test
@@ -163,7 +165,7 @@
public void setAdditionalSettingsSummaries_wifiWakeupEnabled_displayOn() {
final ContentResolver contentResolver = mContext.getContentResolver();
when(mWifiManager.isAutoWakeupEnabled()).thenReturn(true);
- when(mWifiManager.isScanAlwaysAvailable()).thenReturn(false);
+ when(mWifiManager.isScanAlwaysAvailable()).thenReturn(true);
Settings.Global.putInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0);
when(mPowerManager.isPowerSaveMode()).thenReturn(false);
@@ -200,7 +202,7 @@
when(activity.getSystemService(Context.USER_SERVICE))
.thenReturn(userManager);
- when(mWifiSettings2.findPreference(WifiSettings.PREF_KEY_DATA_USAGE))
+ when(mWifiSettings2.findPreference(WifiSettings2.PREF_KEY_DATA_USAGE))
.thenReturn(mDataUsagePreference);
}
@@ -268,4 +270,14 @@
verify(mWifiSettings2).changeNextButtonState(anyBoolean());
}
+
+ @Test
+ public void openSubscriptionHelpPage_shouldCallStartActivityForResult() {
+ doReturn(new Intent()).when(mWifiSettings2).getHelpIntent(mContext);
+ doNothing().when(mWifiSettings2).startActivityForResult(any(Intent.class), anyInt());
+
+ mWifiSettings2.openSubscriptionHelpPage();
+
+ verify(mWifiSettings2, times(1)).startActivityForResult(any(), anyInt());
+ }
}