Merge "Clarify notification dots/icons strings"
diff --git a/res/drawable/ic_account_circle_24dp.xml b/res/drawable/ic_account_circle_24dp.xml
new file mode 100644
index 0000000..8445adc
--- /dev/null
+++ b/res/drawable/ic_account_circle_24dp.xml
@@ -0,0 +1,27 @@
+<!--
+ Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="32dp"
+ android:height="32dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#ff4285f4"
+ android:pathData="M12,2C6.48,2 2,6.48 2,12c0,5.52 4.48,10 10,10c5.52,0 10,-4.48 10,-10C22,6.48 17.52,2 12,2zM7.07,18.28c0.43,-0.9 3.05,-1.78 4.93,-1.78s4.51,0.88 4.93,1.78C15.57,19.36 13.86,20 12,20S8.43,19.36 7.07,18.28zM18.36,16.83c-1.43,-1.74 -4.9,-2.33 -6.36,-2.33s-4.93,0.59 -6.36,2.33C4.62,15.49 4,13.82 4,12c0,-4.41 3.59,-8 8,-8c4.41,0 8,3.59 8,8C20,13.82 19.38,15.49 18.36,16.83z"/>
+ <path
+ android:fillColor="#ff4285f4"
+ android:pathData="M12,6c-1.94,0 -3.5,1.56 -3.5,3.5S10.06,13 12,13c1.94,0 3.5,-1.56 3.5,-3.5S13.94,6 12,6zM12,11c-0.83,0 -1.5,-0.67 -1.5,-1.5C10.5,8.67 11.17,8 12,8c0.83,0 1.5,0.67 1.5,1.5C13.5,10.33 12.83,11 12,11z"/>
+</vector>
diff --git a/res/layout/horizontal_divider.xml b/res/layout/horizontal_divider.xml
index e4a277d..a134423 100644
--- a/res/layout/horizontal_divider.xml
+++ b/res/layout/horizontal_divider.xml
@@ -19,5 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/divider"
android:layout_width="match_parent"
- android:layout_height=".75dp"
- android:background="?android:attr/dividerHorizontal" />
\ No newline at end of file
+ android:layout_height="@dimen/horizontal_divider_height"
+ android:layout_marginTop="@dimen/horizontal_divider_margin_top"
+ android:layout_marginBottom="@dimen/horizontal_divider_margin_bottom"
+ android:background="?android:attr/dividerHorizontal"/>
\ No newline at end of file
diff --git a/res/layout/search_bar.xml b/res/layout/search_bar.xml
index 9e64db7..1ba64ad 100644
--- a/res/layout/search_bar.xml
+++ b/res/layout/search_bar.xml
@@ -45,5 +45,12 @@
android:layout_height="wrap_content"
android:text="@string/search_menu"/>
</Toolbar>
+ <ImageView
+ android:id="@+id/account_avatar"
+ android:layout_marginStart="@dimen/search_bar_avatar_start_margin"
+ android:layout_marginEnd="@dimen/search_bar_avatar_end_margin"
+ android:layout_width="@dimen/search_bar_avatar_size"
+ android:layout_height="@dimen/search_bar_avatar_size"
+ android:layout_gravity="end|center_vertical"/>
</androidx.cardview.widget.CardView>
</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/settings_homepage.xml b/res/layout/settings_homepage.xml
index bd54717..0140ced 100644
--- a/res/layout/settings_homepage.xml
+++ b/res/layout/settings_homepage.xml
@@ -27,32 +27,5 @@
android:layout_height="match_parent"
android:layoutAnimation="@anim/layout_animation_fall_down"/>
- <RelativeLayout
- android:id="@+id/suggestion_footer"
- android:layout_width="match_parent"
- android:layout_height="@dimen/condition_header_height"
- android:layout_centerHorizontal="true">
-
- <ImageView
- android:id="@+id/expand_indicator"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_alignParentEnd="true"
- android:paddingTop="4dp"
- android:paddingStart="16dp"
- android:paddingEnd="16dp"/>
-
- <TextView
- android:id="@+id/expand_summary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:layout_toStartOf="@id/expand_indicator"
- android:layout_centerVertical="true"
- android:gravity="end"
- android:textAppearance="@style/TextAppearance.SuggestionTitle"
- android:textColor="?android:attr/colorAccent"/>
-
- </RelativeLayout>
<include layout="@layout/horizontal_divider"/>
</LinearLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 9b33388..e163f7f 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -103,6 +103,9 @@
<dimen name="search_bar_text_size">16dp</dimen>
<dimen name="search_bar_card_elevation">2dp</dimen>
<dimen name="search_bar_content_inset">64dp</dimen>
+ <dimen name="search_bar_avatar_size">32dp</dimen>
+ <dimen name="search_bar_avatar_start_margin">4dp</dimen>
+ <dimen name="search_bar_avatar_end_margin">16dp</dimen>
<!-- Dimensions for Wifi Assistant Card -->
<dimen name="wifi_assistant_padding_top_bottom">16dp</dimen>
@@ -327,11 +330,16 @@
<!-- Homepage cards size and padding -->
<dimen name="homepage_card_corner_radius">8dp</dimen>
<dimen name="homepage_card_elevation">2dp</dimen>
- <dimen name="homepage_card_vertical_margin">6dp</dimen>
- <dimen name="homepage_card_side_margin">16dp</dimen>
+ <dimen name="homepage_card_vertical_margin">4dp</dimen>
+ <dimen name="homepage_card_side_margin">8dp</dimen>
<dimen name="homepage_card_padding_start">16dp</dimen>
<dimen name="homepage_card_padding_end">16dp</dimen>
+ <!-- Horizontal divider size and margin -->
+ <dimen name="horizontal_divider_margin_top">4dp</dimen>
+ <dimen name="horizontal_divider_margin_bottom">8dp</dimen>
+ <dimen name="horizontal_divider_height">.75dp</dimen>
+
<!-- Signal icon in NetworkSelectSetting -->
<dimen name="signal_strength_icon_size">24dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 37d94fe..84a807c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5655,12 +5655,18 @@
<string name="remove_and_uninstall_device_admin">Deactivate & uninstall</string>
<!-- Label for screen showing to select device admin apps -->
<string name="select_device_admin_msg">Device admin apps</string>
+
<!-- Message when there are no available device admin apps to display -->
<string name="no_device_admins">No device admin apps available</string>
<!-- Title for personal device admin apps on the list [CHAR_LIMIT=25] -->
<string name="personal_device_admin_title">Personal</string>
<!-- Title for managed device admin apps on the list [CHAR_LIMIT=25] -->
<string name="managed_device_admin_title">Work</string>
+ <!-- Title for whether to enable SMS access restriction [CHAR LIMIT=50]-->
+ <string name="sms_access_restriction_enabled">Restrict SMS & call log access</string>
+ <!-- Summary for whether to enable SMS access restriction [CHAR LIMIT=NONE]-->
+ <string name="sms_access_restriction_enabled_summary">Only default phone and messaging apps have SMS & call log permissions</string>
+
<!-- Message when there are no available trust agents to display -->
<string name="no_trust_agents">No available trust agents</string>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 3d08cd8..6528cf7 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -513,6 +513,11 @@
<Preference
android:key="reset_shortcut_manager_throttling"
android:title="@string/reset_shortcut_manager_throttling" />
+
+ <SwitchPreference
+ android:key="sms_access_restriction_enabled"
+ android:title="@string/sms_access_restriction_enabled"
+ android:summary="@string/sms_access_restriction_enabled_summary" />
</PreferenceCategory>
<com.android.settings.development.autofill.AutofillPreferenceCategory
diff --git a/res/xml/installed_app_details.xml b/res/xml/installed_app_details.xml
deleted file mode 100644
index 42822c0..0000000
--- a/res/xml/installed_app_details.xml
+++ /dev/null
@@ -1,93 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:key="installed_app_detail_settings_screen"
- app:initialExpandedChildrenCount="6">
-
- <com.android.settings.applications.LayoutPreference
- android:key="header_view"
- android:layout="@layout/settings_entity_header"
- android:selectable="false"
- android:order="-10000"/>
-
- <com.android.settings.applications.LayoutPreference
- android:key="instant_app_buttons"
- android:layout="@layout/instant_app_buttons"
- android:selectable="false"
- android:order="-9999"/>
-
- <com.android.settings.widget.ActionButtonPreference
- android:key="action_buttons"
- android:order="-9998" />
-
- <Preference
- android:key="notification_settings"
- android:title="@string/notifications_label"
- android:selectable="true"/>
-
- <com.android.settings.widget.FixedLineSummaryPreference
- android:key="permission_settings"
- android:title="@string/permissions_label"
- android:summary="@string/summary_placeholder"
- android:selectable="true"
- app:summaryLineCount="1" />
-
- <Preference
- android:key="storage_settings"
- android:title="@string/storage_settings"
- android:summary="@string/summary_placeholder"
- android:selectable="true"/>
-
- <com.android.settings.applications.AppDomainsPreference
- android:key="instant_app_launch_supported_domain_urls"
- android:title="@string/app_launch_supported_domain_urls_title"
- android:selectable="true" />
-
- <Preference
- android:key="data_settings"
- android:title="@string/data_usage_summary_title"
- android:summary="@string/summary_placeholder"
- android:selectable="true"/>
-
- <Preference
- android:key="battery"
- android:title="@string/power_usage_summary_title"
- android:summary="@string/summary_placeholder"
- android:selectable="true"/>
-
- <Preference
- android:key="preferred_settings"
- android:title="@string/launch_by_default"
- android:summary="@string/summary_placeholder"
- android:selectable="true"/>
-
- <Preference
- android:key="memory"
- android:title="@string/memory_settings_title"
- android:summary="@string/summary_placeholder"
- android:enabled="false"
- android:selectable="true"/>
-
- <Preference
- android:key="app_version"
- android:selectable="false"
- android:order="9999"/>
-
-</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/wifi_settings.xml b/res/xml/wifi_settings.xml
index 4ca9284..516ac0a 100644
--- a/res/xml/wifi_settings.xml
+++ b/res/xml/wifi_settings.xml
@@ -20,6 +20,9 @@
android:title="@string/wifi_settings"
settings:keywords="@string/keywords_wifi">
+ <com.android.settings.wifi.LinkablePreference
+ android:key="wifi_status_message"/>
+
<PreferenceCategory
android:key="connected_access_point"
android:layout="@layout/preference_category_no_label"/>
@@ -28,17 +31,14 @@
android:key="access_points"
android:layout="@layout/preference_category_no_label"/>
- <PreferenceCategory
- android:key="additional_settings"
- android:layout="@layout/preference_category_no_label">
- <Preference
- android:key="configure_settings"
- android:title="@string/wifi_configure_settings_preference_title"
- android:fragment="com.android.settings.wifi.ConfigureWifiSettings" />
+ <Preference
+ android:key="configure_settings"
+ android:title="@string/wifi_configure_settings_preference_title"
+ settings:allowDividerAbove="true"
+ android:fragment="com.android.settings.wifi.ConfigureWifiSettings"/>
- <Preference
- android:key="saved_networks"
- android:title="@string/wifi_saved_access_points_label"
- android:fragment="com.android.settings.wifi.savedaccesspoints.SavedAccessPointsWifiSettings" />
- </PreferenceCategory>
+ <Preference
+ android:key="saved_networks"
+ android:title="@string/wifi_saved_access_points_label"
+ android:fragment="com.android.settings.wifi.savedaccesspoints.SavedAccessPointsWifiSettings"/>
</PreferenceScreen>
diff --git a/src/com/android/settings/accounts/AvatarViewMixin.java b/src/com/android/settings/accounts/AvatarViewMixin.java
new file mode 100644
index 0000000..d7f6f8a
--- /dev/null
+++ b/src/com/android/settings/accounts/AvatarViewMixin.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accounts;
+
+import android.accounts.Account;
+import android.content.Context;
+import android.widget.ImageView;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.lifecycle.Lifecycle;
+import androidx.lifecycle.LifecycleObserver;
+import androidx.lifecycle.OnLifecycleEvent;
+
+import com.android.settings.R;
+import com.android.settings.homepage.SettingsHomepageActivity;
+import com.android.settings.overlay.FeatureFactory;
+
+/**
+ * Avatar related work to the onStart method of registered observable classes
+ * in {@link SettingsHomepageActivity}.
+ */
+public class AvatarViewMixin implements LifecycleObserver {
+ private Context mContext;
+ private ImageView mAvatarView;
+
+ public AvatarViewMixin(Context context, ImageView avatarView) {
+ mContext = context.getApplicationContext();
+ mAvatarView = avatarView;
+ }
+
+ @OnLifecycleEvent(Lifecycle.Event.ON_START)
+ public void onStart() {
+ if (hasAccount()) {
+ //TODO(b/117509285): To migrate account icon on search bar
+ } else {
+ mAvatarView.setImageResource(R.drawable.ic_account_circle_24dp);
+ }
+ }
+
+ @VisibleForTesting
+ boolean hasAccount() {
+ final Account accounts[] = FeatureFactory.getFactory(
+ mContext).getAccountFeatureProvider().getAccounts(mContext);
+ return (accounts != null) && (accounts.length > 0);
+ }
+}
diff --git a/src/com/android/settings/applications/appinfo/TimeSpentInAppPreferenceController.java b/src/com/android/settings/applications/appinfo/TimeSpentInAppPreferenceController.java
index a4cfebf..70ffcb3 100644
--- a/src/com/android/settings/applications/appinfo/TimeSpentInAppPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/TimeSpentInAppPreferenceController.java
@@ -21,6 +21,7 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.provider.Settings;
import android.text.TextUtils;
import androidx.annotation.VisibleForTesting;
@@ -34,8 +35,7 @@
public class TimeSpentInAppPreferenceController extends BasePreferenceController {
@VisibleForTesting
- static final Intent SEE_TIME_IN_APP_TEMPLATE =
- new Intent("com.android.settings.action.TIME_SPENT_IN_APP");
+ static final Intent SEE_TIME_IN_APP_TEMPLATE = new Intent(Settings.ACTION_APP_USAGE_SETTINGS);
private final PackageManager mPackageManager;
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index dbcb389..82c9828 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -458,6 +458,7 @@
controllers.add(new AllowAppsOnExternalPreferenceController(context));
controllers.add(new ResizableActivityPreferenceController(context));
controllers.add(new FreeformWindowsPreferenceController(context));
+ controllers.add(new SmsAccessRestrictionPreferenceController(context));
controllers.add(new ShortcutManagerThrottlingPreferenceController(context));
controllers.add(new EnableGnssRawMeasFullTrackingPreferenceController(context));
controllers.add(new CbrsDataSwitchPreferenceController(context));
diff --git a/src/com/android/settings/development/SmsAccessRestrictionPreferenceController.java b/src/com/android/settings/development/SmsAccessRestrictionPreferenceController.java
new file mode 100644
index 0000000..b3f7b23
--- /dev/null
+++ b/src/com/android/settings/development/SmsAccessRestrictionPreferenceController.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+
+// STOPSHIP b/118694572: remove the kill switch once the feature is tested and stable
+public class SmsAccessRestrictionPreferenceController extends DeveloperOptionsPreferenceController
+ implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
+
+ private static final String SMS_ACCESS_RESTRICTION_ENABLED_KEY
+ = "sms_access_restriction_enabled";
+
+ public SmsAccessRestrictionPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return SMS_ACCESS_RESTRICTION_ENABLED_KEY;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ writeSetting((boolean) newValue);
+ return true;
+ }
+
+ private void writeSetting(boolean isEnabled) {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.SMS_ACCESS_RESTRICTION_ENABLED,
+ isEnabled ? 1 : 0);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ final int mode = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.SMS_ACCESS_RESTRICTION_ENABLED, 0);
+ ((SwitchPreference) mPreference).setChecked(mode != 0);
+ }
+
+ @Override
+ protected void onDeveloperOptionsSwitchDisabled() {
+ super.onDeveloperOptionsSwitchDisabled();
+ writeSetting(false);
+ ((SwitchPreference) mPreference).setChecked(false);
+ }
+}
diff --git a/src/com/android/settings/homepage/SettingsHomepageActivity.java b/src/com/android/settings/homepage/SettingsHomepageActivity.java
index c10543d..d3f11a0 100644
--- a/src/com/android/settings/homepage/SettingsHomepageActivity.java
+++ b/src/com/android/settings/homepage/SettingsHomepageActivity.java
@@ -19,6 +19,7 @@
import android.content.Intent;
import android.os.Bundle;
import android.util.FeatureFlagUtils;
+import android.widget.ImageView;
import android.widget.Toolbar;
import androidx.fragment.app.Fragment;
@@ -27,6 +28,7 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
+import com.android.settings.accounts.AvatarViewMixin;
import com.android.settings.core.FeatureFlags;
import com.android.settings.core.SettingsBaseActivity;
import com.android.settings.homepage.contextualcards.ContextualCardsFragment;
@@ -51,6 +53,10 @@
FeatureFactory.getFactory(this).getSearchFeatureProvider()
.initSearchToolbar(this, toolbar);
+ final ImageView avatarView = findViewById(R.id.account_avatar);
+ final AvatarViewMixin avatarViewMixin = new AvatarViewMixin(this, avatarView);
+ getLifecycle().addObserver(avatarViewMixin);
+
showFragment(new ContextualCardsFragment(), R.id.contextual_cards_content);
showFragment(new TopLevelSettings(), R.id.main_content);
}
diff --git a/src/com/android/settings/homepage/contextualcards/CardDatabaseHelper.java b/src/com/android/settings/homepage/contextualcards/CardDatabaseHelper.java
index 11ab8d8..647d718 100644
--- a/src/com/android/settings/homepage/contextualcards/CardDatabaseHelper.java
+++ b/src/com/android/settings/homepage/contextualcards/CardDatabaseHelper.java
@@ -30,7 +30,7 @@
public class CardDatabaseHelper extends SQLiteOpenHelper {
private static final String TAG = "CardDatabaseHelper";
private static final String DATABASE_NAME = "homepage_cards.db";
- private static final int DATABASE_VERSION = 3;
+ private static final int DATABASE_VERSION = 4;
public static final String CARD_TABLE = "cards";
@@ -56,7 +56,7 @@
String SLICE_URI = "slice_uri";
/**
- * Category of the card. The value is between 0 to 3.
+ * Category of the card.
*/
String CATEGORY = "category";
@@ -133,11 +133,7 @@
CardColumns.SLICE_URI +
" TEXT, " +
CardColumns.CATEGORY +
- " INTEGER DEFAULT 0 CHECK (" +
- CardColumns.CATEGORY +
- " >= 0 AND " +
- CardColumns.CATEGORY +
- " <= 3), " +
+ " INTEGER DEFAULT 0, " +
CardColumns.LOCALIZED_TO_LOCALE +
" TEXT, " +
CardColumns.PACKAGE_NAME +
diff --git a/src/com/android/settings/network/telephony/ApnPreferenceController.java b/src/com/android/settings/network/telephony/ApnPreferenceController.java
index e02d9d4..f5cd140 100644
--- a/src/com/android/settings/network/telephony/ApnPreferenceController.java
+++ b/src/com/android/settings/network/telephony/ApnPreferenceController.java
@@ -62,12 +62,13 @@
public int getAvailabilityStatus() {
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
final boolean isCdmaApn = MobileNetworkUtils.isCdmaOptions(mContext, mSubId)
+ && carrierConfig != null
&& carrierConfig.getBoolean(CarrierConfigManager.KEY_SHOW_APN_SETTING_CDMA_BOOL);
final boolean isGsmApn = MobileNetworkUtils.isGsmOptions(mContext, mSubId)
+ && carrierConfig != null
&& carrierConfig.getBoolean(CarrierConfigManager.KEY_APN_EXPAND_BOOL);
- return carrierConfig != null
- && (isCdmaApn || isGsmApn)
+ return isCdmaApn || isGsmApn
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
diff --git a/src/com/android/settings/network/telephony/CdmaOptions.java b/src/com/android/settings/network/telephony/CdmaOptions.java
deleted file mode 100644
index c573128..0000000
--- a/src/com/android/settings/network/telephony/CdmaOptions.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.network.telephony;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceFragmentCompat;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.R;
-
-/**
- * List of Phone-specific settings screens.
- */
-public class CdmaOptions {
- private static final String LOG_TAG = "CdmaOptions";
-
- private static final String BUTTON_CDMA_SYSTEM_SELECT_KEY = "cdma_system_select_key";
- private static final String BUTTON_CDMA_SUBSCRIPTION_KEY = "cdma_subscription_key";
-
- private PreferenceFragmentCompat mPrefFragment;
-
- public CdmaOptions(PreferenceFragmentCompat prefFragment, PreferenceScreen prefScreen,
- int subId) {
- mPrefFragment = prefFragment;
- }
-
- public boolean preferenceTreeClick(Preference preference) {
- //TODO(b/114749736): handle it in preferenceController and remove this file
- if (preference.getKey().equals(BUTTON_CDMA_SYSTEM_SELECT_KEY)) {
- log("preferenceTreeClick: return BUTTON_CDMA_ROAMING_KEY true");
- return true;
- }
- if (preference.getKey().equals(BUTTON_CDMA_SUBSCRIPTION_KEY)) {
- log("preferenceTreeClick: return CDMA_SUBSCRIPTION_KEY true");
- return true;
- }
- return false;
- }
-
- protected void log(String s) {
- android.util.Log.d(LOG_TAG, s);
- }
-}
diff --git a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
index 46773dc..b077dd5 100644
--- a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
@@ -45,7 +45,8 @@
private PersistableBundle mPersistableBundle;
private int mSubId;
private boolean mIsGlobalCdma;
- private boolean mShow4GForLTE;
+ @VisibleForTesting
+ boolean mShow4GForLTE;
public EnabledNetworkModePreferenceController(Context context, String key) {
super(context, key);
@@ -111,12 +112,10 @@
mTelephonyManager.getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE;
mIsGlobalCdma = isLteOnCdma
&& mPersistableBundle.getBoolean(CarrierConfigManager.KEY_SHOW_CDMA_CHOICES_BOOL);
- initShow4GForLTE();
- }
-
- @VisibleForTesting
- void initShow4GForLTE() {
- mShow4GForLTE = MobileNetworkUtils.isShow4GForLTE(mContext);
+ mShow4GForLTE = mPersistableBundle != null
+ ? mPersistableBundle.getBoolean(
+ CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL)
+ : false;
}
private int getPreferredNetworkMode() {
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index e85c917..689799e 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -386,19 +386,6 @@
return false;
}
- public static boolean isShow4GForLTE(Context context) {
- //TODO(b/117882862): move this to framework
- try {
- Context con = context.createPackageContext("com.android.systemui", 0);
- int id = con.getResources().getIdentifier("config_show4GForLTE",
- "bool", "com.android.systemui");
- return con.getResources().getBoolean(id);
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(TAG, "NameNotFoundException for show4GFotLTE");
- return false;
- }
- }
-
/**
* Return {@code true} if Tdscdma is supported in current subscription
*/
diff --git a/src/com/android/settings/notification/ZenAutomaticRuleHeaderPreferenceController.java b/src/com/android/settings/notification/ZenAutomaticRuleHeaderPreferenceController.java
index 18415c7..41eb111 100644
--- a/src/com/android/settings/notification/ZenAutomaticRuleHeaderPreferenceController.java
+++ b/src/com/android/settings/notification/ZenAutomaticRuleHeaderPreferenceController.java
@@ -24,13 +24,10 @@
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.service.notification.ZenModeConfig;
+import android.text.TextUtils;
import android.util.Slog;
import android.view.View;
-import androidx.fragment.app.Fragment;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceFragmentCompat;
-
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.applications.LayoutPreference;
@@ -38,6 +35,10 @@
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.core.lifecycle.Lifecycle;
+import androidx.fragment.app.Fragment;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceFragmentCompat;
+
public class ZenAutomaticRuleHeaderPreferenceController extends AbstractZenModePreferenceController
implements PreferenceControllerMixin {
@@ -128,9 +129,13 @@
@Override
public void onOk(String ruleName, Fragment parent) {
+ if (TextUtils.equals(ruleName, mRule.getName())) {
+ return;
+ }
mMetricsFeatureProvider.action(mContext,
MetricsProto.MetricsEvent.ACTION_ZEN_MODE_RULE_NAME_CHANGE_OK);
mRule.setName(ruleName);
+ mRule.setModified(true);
mBackend.setZenRule(mId, mRule);
}
}
diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java
index 866e5a8..cce871b 100644
--- a/src/com/android/settings/tts/TextToSpeechSettings.java
+++ b/src/com/android/settings/tts/TextToSpeechSettings.java
@@ -251,15 +251,20 @@
mTts.setOnUtteranceProgressListener(new UtteranceProgressListener() {
@Override
public void onStart(String utteranceId) {
+ updateWidgetState(false);
}
@Override
public void onDone(String utteranceId) {
+ updateWidgetState(true);
}
@Override
public void onError(String utteranceId) {
Log.e(TAG, "Error while trying to synthesize sample text");
+ // Re-enable just in case, although there isn't much hope that following synthesis
+ // requests are going to succeed.
+ updateWidgetState(true);
}
});
}
@@ -696,9 +701,11 @@
}
private void updateWidgetState(boolean enable) {
- mActionButtons.setButton1Enabled(enable);
- mDefaultRatePref.setEnabled(enable);
- mDefaultPitchPref.setEnabled(enable);
+ getActivity().runOnUiThread(() -> {
+ mActionButtons.setButton1Enabled(enable);
+ mDefaultRatePref.setEnabled(enable);
+ mDefaultPitchPref.setEnabled(enable);
+ });
}
private void displayNetworkAlert() {
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 4837a88..f097d5b 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -112,9 +112,9 @@
private static final String PREF_KEY_EMPTY_WIFI_LIST = "wifi_empty_list";
private static final String PREF_KEY_CONNECTED_ACCESS_POINTS = "connected_access_point";
private static final String PREF_KEY_ACCESS_POINTS = "access_points";
- private static final String PREF_KEY_ADDITIONAL_SETTINGS = "additional_settings";
private static final String PREF_KEY_CONFIGURE_WIFI_SETTINGS = "configure_settings";
private static final String PREF_KEY_SAVED_NETWORKS = "saved_networks";
+ private static final String PREF_KEY_STATUS_MESSAGE = "wifi_status_message";
private static boolean isVerboseLoggingEnabled() {
return WifiTracker.sVerboseLogging || Log.isLoggable(TAG, Log.VERBOSE);
@@ -167,17 +167,19 @@
private Bundle mAccessPointSavedState;
private Bundle mWifiNfcDialogSavedState;
- private WifiTracker mWifiTracker;
+ @VisibleForTesting
+ WifiTracker mWifiTracker;
private String mOpenSsid;
private AccessPointPreference.UserBadgeCache mUserBadgeCache;
private PreferenceCategory mConnectedAccessPointPreferenceCategory;
private PreferenceCategory mAccessPointsPreferenceCategory;
- private PreferenceCategory mAdditionalSettingsPreferenceCategory;
private Preference mAddPreference;
- private Preference mConfigureWifiSettingsPreference;
- private Preference mSavedNetworksPreference;
+ @VisibleForTesting
+ Preference mConfigureWifiSettingsPreference;
+ @VisibleForTesting
+ Preference mSavedNetworksPreference;
private LinkablePreference mStatusMessagePreference;
// For Search
@@ -229,8 +231,6 @@
(PreferenceCategory) findPreference(PREF_KEY_CONNECTED_ACCESS_POINTS);
mAccessPointsPreferenceCategory =
(PreferenceCategory) findPreference(PREF_KEY_ACCESS_POINTS);
- mAdditionalSettingsPreferenceCategory =
- (PreferenceCategory) findPreference(PREF_KEY_ADDITIONAL_SETTINGS);
mConfigureWifiSettingsPreference = findPreference(PREF_KEY_CONFIGURE_WIFI_SETTINGS);
mSavedNetworksPreference = findPreference(PREF_KEY_SAVED_NETWORKS);
@@ -238,7 +238,7 @@
mAddPreference = new Preference(prefContext);
mAddPreference.setIcon(R.drawable.ic_menu_add);
mAddPreference.setTitle(R.string.wifi_add_network);
- mStatusMessagePreference = new LinkablePreference(prefContext);
+ mStatusMessagePreference = (LinkablePreference) findPreference(PREF_KEY_STATUS_MESSAGE);
mUserBadgeCache = new AccessPointPreference.UserBadgeCache(getPackageManager());
}
@@ -692,14 +692,14 @@
case WifiManager.WIFI_STATE_ENABLING:
removeConnectedAccessPointPreference();
- mAccessPointsPreferenceCategory.removeAll();
+ removeAccessPointPreference();
addMessagePreference(R.string.wifi_starting);
setProgressBarVisible(true);
break;
case WifiManager.WIFI_STATE_DISABLING:
removeConnectedAccessPointPreference();
- mAccessPointsPreferenceCategory.removeAll();
+ removeAccessPointPreference();
addMessagePreference(R.string.wifi_stopping);
break;
@@ -746,7 +746,10 @@
}
boolean hasAvailableAccessPoints = false;
- mAccessPointsPreferenceCategory.removePreference(mStatusMessagePreference);
+ mStatusMessagePreference.setVisible(false);
+ mConnectedAccessPointPreferenceCategory.setVisible(true);
+ mAccessPointsPreferenceCategory.setVisible(true);
+
cacheRemoveAllPrefs(mAccessPointsPreferenceCategory);
int index =
@@ -960,26 +963,28 @@
unregisterCaptivePortalNetworkCallback();
}
- private void setAdditionalSettingsSummaries() {
- mAdditionalSettingsPreferenceCategory.addPreference(mConfigureWifiSettingsPreference);
+ private void removeAccessPointPreference() {
+ mAccessPointsPreferenceCategory.removeAll();
+ mAccessPointsPreferenceCategory.setVisible(false);
+ }
+
+ @VisibleForTesting
+ void setAdditionalSettingsSummaries() {
mConfigureWifiSettingsPreference.setSummary(getString(
isWifiWakeupEnabled()
? R.string.wifi_configure_settings_preference_summary_wakeup_on
: R.string.wifi_configure_settings_preference_summary_wakeup_off));
- int numSavedNetworks = mWifiTracker.getNumSavedNetworks();
- if (numSavedNetworks > 0) {
- mAdditionalSettingsPreferenceCategory.addPreference(mSavedNetworksPreference);
- mSavedNetworksPreference.setSummary(
- getResources().getQuantityString(R.plurals.wifi_saved_access_points_summary,
- numSavedNetworks, numSavedNetworks));
- } else {
- mAdditionalSettingsPreferenceCategory.removePreference(mSavedNetworksPreference);
- }
+ final int numSavedNetworks = mWifiTracker.getNumSavedNetworks();
+ mSavedNetworksPreference.setVisible(numSavedNetworks > 0);
+ mSavedNetworksPreference.setSummary(
+ getResources().getQuantityString(R.plurals.wifi_saved_access_points_summary,
+ numSavedNetworks, numSavedNetworks));
}
private boolean isWifiWakeupEnabled() {
- PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
- ContentResolver contentResolver = getContentResolver();
+ final Context context = getContext();
+ final PowerManager powerManager = context.getSystemService(PowerManager.class);
+ final ContentResolver contentResolver = context.getContentResolver();
return Settings.Global.getInt(contentResolver,
Settings.Global.WIFI_WAKEUP_ENABLED, 0) == 1
&& Settings.Global.getInt(contentResolver,
@@ -1006,15 +1011,14 @@
.launch();
mStatusMessagePreference.setText(title, description, clickListener);
removeConnectedAccessPointPreference();
- mAccessPointsPreferenceCategory.removeAll();
- mAccessPointsPreferenceCategory.addPreference(mStatusMessagePreference);
+ removeAccessPointPreference();
+ mStatusMessagePreference.setVisible(true);
}
private void addMessagePreference(int messageId) {
mStatusMessagePreference.setTitle(messageId);
- removeConnectedAccessPointPreference();
- mAccessPointsPreferenceCategory.removeAll();
- mAccessPointsPreferenceCategory.addPreference(mStatusMessagePreference);
+ mStatusMessagePreference.setVisible(true);
+
}
protected void setProgressBarVisible(boolean visible) {
diff --git a/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java b/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java
new file mode 100644
index 0000000..c72561e
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accounts;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.accounts.Account;
+import android.content.Context;
+import android.widget.ImageView;
+
+import com.android.settings.homepage.SettingsHomepageActivity;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.android.controller.ActivityController;
+import org.robolectric.annotation.Config;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class AvatarViewMixinTest {
+ private static final String DUMMY_ACCOUNT = "test@domain.com";
+ private static final String DUMMY_DOMAIN = "domain.com";
+
+ private Context mContext;
+ private ImageView mImageView;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mImageView = new ImageView(mContext);
+ }
+
+ @Test
+ public void hasAccount_useDefaultAccountData_returnFalse() {
+ final AvatarViewMixin avatarViewMixin = new AvatarViewMixin(mContext, mImageView);
+ assertThat(avatarViewMixin.hasAccount()).isFalse();
+ }
+
+ @Test
+ @Config(shadows = ShadowAccountFeatureProviderImpl.class)
+ public void hasAccount_useShadowAccountData_returnTrue() {
+ final AvatarViewMixin avatarViewMixin = new AvatarViewMixin(mContext, mImageView);
+ assertThat(avatarViewMixin.hasAccount()).isTrue();
+ }
+
+ @Test
+ public void onStart_useMockAvatarViewMixin_shouldBeExecuted() {
+ final AvatarViewMixin mockAvatar = spy(new AvatarViewMixin(mContext, mImageView));
+
+ final ActivityController controller = Robolectric.buildActivity(
+ SettingsHomepageActivity.class).create();
+ final SettingsHomepageActivity settingsHomepageActivity =
+ (SettingsHomepageActivity) controller.get();
+ settingsHomepageActivity.getLifecycle().addObserver(mockAvatar);
+ controller.start();
+
+ verify(mockAvatar).onStart();
+ }
+
+ @Implements(AccountFeatureProviderImpl.class)
+ public static class ShadowAccountFeatureProviderImpl {
+
+ @Implementation
+ public Account[] getAccounts(Context context) {
+ Account[] accounts = {new Account(DUMMY_ACCOUNT, DUMMY_DOMAIN)};
+ return accounts;
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/development/SmsAccessRestrictionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/SmsAccessRestrictionPreferenceControllerTest.java
new file mode 100644
index 0000000..7a0dd68
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/SmsAccessRestrictionPreferenceControllerTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.google.common.truth.Truth.assertThat;
+
+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.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class SmsAccessRestrictionPreferenceControllerTest {
+
+ @Mock
+ private SwitchPreference mPreference;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+
+ private Context mContext;
+ private SmsAccessRestrictionPreferenceController mController;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new SmsAccessRestrictionPreferenceController(mContext);
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
+ .thenReturn(mPreference);
+ mController.displayPreference(mPreferenceScreen);
+ }
+
+ @Test
+ public void onPreferenceChange_settingEnabled_enableSmsRestrictionShouldBeOn() {
+ mController.onPreferenceChange(mPreference, true /* new value */);
+
+ final int mode = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.SMS_ACCESS_RESTRICTION_ENABLED, -1 /* default */);
+
+ assertThat(mode).isEqualTo(1);
+ }
+
+ @Test
+ public void onPreferenceChange_settingDisabled_enableSmsRestrictionShouldBeOff() {
+ mController.onPreferenceChange(mPreference, false /* new value */);
+
+ final int mode = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.SMS_ACCESS_RESTRICTION_ENABLED, -1 /* default */);
+
+ assertThat(mode).isEqualTo(0);
+ }
+
+ @Test
+ public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.SMS_ACCESS_RESTRICTION_ENABLED, 0);
+ mController.updateState(mPreference);
+
+ verify(mPreference).setChecked(false);
+ }
+
+ @Test
+ public void updateState_settingEnabled_preferenceShouldBeChecked() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.SMS_ACCESS_RESTRICTION_ENABLED, 1);
+ mController.updateState(mPreference);
+
+ verify(mPreference).setChecked(true);
+ }
+
+ @Test
+ public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
+ mController.onDeveloperOptionsSwitchDisabled();
+
+ final int mode = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.SMS_ACCESS_RESTRICTION_ENABLED, -1 /* default */);
+
+ assertThat(mode).isEqualTo(0);
+ verify(mPreference).setChecked(false);
+ verify(mPreference).setEnabled(false);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/ApnPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/ApnPreferenceControllerTest.java
index dc277d2..9664428 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/ApnPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/ApnPreferenceControllerTest.java
@@ -24,6 +24,7 @@
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import android.app.Activity;
import android.content.Context;
@@ -115,6 +116,14 @@
}
@Test
+ public void getAvailabilityStatus_carrierConfigNull_returnUnavailable() {
+ doReturn(PhoneConstants.PHONE_TYPE_GSM).when(mTelephonyManager).getPhoneType();
+ when(mCarrierConfigManager.getConfigForSubId(SUB_ID)).thenReturn(null);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+ }
+
+ @Test
public void handPreferenceTreeClick_fireIntent() {
ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceControllerTest.java
index 71df401..02710fb 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceControllerTest.java
@@ -23,7 +23,6 @@
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
@@ -80,8 +79,7 @@
mPreference = new ListPreference(mContext);
mPreference.setEntries(R.array.enabled_networks_choices);
mPreference.setEntryValues(R.array.enabled_networks_values);
- mController = spy(new EnabledNetworkModePreferenceController(mContext, "enabled_network"));
- doNothing().when(mController).initShow4GForLTE();
+ mController = new EnabledNetworkModePreferenceController(mContext, "enabled_network");
mController.init(SUB_ID);
mPreference.setKey(mController.getPreferenceKey());
}
@@ -104,6 +102,16 @@
}
@Test
+ public void init_initShow4GForLTE() {
+ mPersistableBundle.putBoolean(CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL,
+ true);
+
+ mController.init(SUB_ID);
+
+ assertThat(mController.mShow4GForLTE).isTrue();
+ }
+
+ @Test
public void updateState_updateByNetworkMode() {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
index e9daec3..c9e6c1e 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
@@ -20,20 +20,31 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import android.app.Activity;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
+import android.os.PowerManager;
+import android.provider.Settings;
+import androidx.preference.Preference;
+
+import com.android.settings.R;
import com.android.settings.search.SearchIndexableRaw;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.wifi.WifiTracker;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@@ -42,18 +53,33 @@
@RunWith(SettingsRobolectricTestRunner.class)
public class WifiSettingsTest {
+ private static final int NUM_NETWORKS = 4;
+
+ @Mock
+ private WifiTracker mWifiTracker;
+ @Mock
+ private PowerManager mPowerManager;
private Context mContext;
+ private WifiSettings mWifiSettings;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
+
+ mWifiSettings = spy(new WifiSettings());
+ doReturn(mContext).when(mWifiSettings).getContext();
+ doReturn(mPowerManager).when(mContext).getSystemService(PowerManager.class);
+ mWifiSettings.mSavedNetworksPreference = new Preference(mContext);
+ mWifiSettings.mConfigureWifiSettingsPreference = new Preference(mContext);
+ mWifiSettings.mWifiTracker = mWifiTracker;
}
@Test
public void testSearchIndexProvider_shouldIndexFragmentTitle() {
final List<SearchIndexableRaw> indexRes =
- WifiSettings.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext, true /* enabled */);
+ WifiSettings.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext,
+ true /* enabled */);
assertThat(indexRes).isNotNull();
assertThat(indexRes.get(0).key).isEqualTo(WifiSettings.DATA_KEY_REFERENCE);
@@ -63,7 +89,8 @@
@Config(qualifiers = "mcc999")
public void testSearchIndexProvider_ifWifiSettingsNotVisible_shouldNotIndexFragmentTitle() {
final List<SearchIndexableRaw> indexRes =
- WifiSettings.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext, true /* enabled */);
+ WifiSettings.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext,
+ true /* enabled */);
assertThat(indexRes).isEmpty();
}
@@ -78,4 +105,51 @@
verify(wifiSettings).handleAddNetworkRequest(anyInt(), any(Intent.class));
}
+
+ @Test
+ public void setAdditionalSettingsSummaries_hasSavedNetwork_preferenceVisible() {
+ when(mWifiTracker.getNumSavedNetworks()).thenReturn(NUM_NETWORKS);
+
+ mWifiSettings.setAdditionalSettingsSummaries();
+
+ assertThat(mWifiSettings.mSavedNetworksPreference.isVisible()).isTrue();
+ assertThat(mWifiSettings.mSavedNetworksPreference.getSummary()).isEqualTo(
+ mContext.getResources().getQuantityString(
+ R.plurals.wifi_saved_access_points_summary,
+ NUM_NETWORKS, NUM_NETWORKS));
+ }
+
+ @Test
+ public void setAdditionalSettingsSummaries_noSavedNetwork_preferenceInvisible() {
+ when(mWifiTracker.getNumSavedNetworks()).thenReturn(0);
+
+ mWifiSettings.setAdditionalSettingsSummaries();
+
+ assertThat(mWifiSettings.mSavedNetworksPreference.isVisible()).isFalse();
+ }
+
+ @Test
+ public void setAdditionalSettingsSummaries_wifiWakeupEnabled_displayOn() {
+ final ContentResolver contentResolver = mContext.getContentResolver();
+ Settings.Global.putInt(contentResolver, Settings.Global.WIFI_WAKEUP_ENABLED, 1);
+ Settings.Global.putInt(contentResolver, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 1);
+ Settings.Global.putInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0);
+ when(mPowerManager.isPowerSaveMode()).thenReturn(false);
+
+ mWifiSettings.setAdditionalSettingsSummaries();
+
+ assertThat(mWifiSettings.mConfigureWifiSettingsPreference.getSummary()).isEqualTo(
+ mContext.getString(R.string.wifi_configure_settings_preference_summary_wakeup_on));
+ }
+
+ @Test
+ public void setAdditionalSettingsSummaries_wifiWakeupDisabled_displayOff() {
+ final ContentResolver contentResolver = mContext.getContentResolver();
+ Settings.Global.putInt(contentResolver, Settings.Global.WIFI_WAKEUP_ENABLED, 0);
+
+ mWifiSettings.setAdditionalSettingsSummaries();
+
+ assertThat(mWifiSettings.mConfigureWifiSettingsPreference.getSummary()).isEqualTo(
+ mContext.getString(R.string.wifi_configure_settings_preference_summary_wakeup_off));
+ }
}
\ No newline at end of file