Merge "Connect button should have correct icon"
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index eb2e730..efbb2c6 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -169,6 +169,22 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="homepage_accessibility_background">#783BE5</color>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values-night/colors.xml"
+ line="22"
+ column="3"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" <color name="material_empty_color_light">#FFCED7DB</color>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
@@ -185,6 +201,22 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="homepage_support_background">#3F5FBD</color>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values-night/colors.xml"
+ line="23"
+ column="3"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" <color name="bluetooth_dialog_text_color">#8a000000</color>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
@@ -1145,7 +1177,7 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" <color name="homepage_accessibility_background">#783BE5</color>"
+ errorLine1=" <color name="homepage_accessibility_background">#5011C1</color>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
@@ -1177,7 +1209,7 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" <color name="homepage_support_background">#3F5FBD</color>"
+ errorLine1=" <color name="homepage_support_background">#26459C</color>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
@@ -1785,6 +1817,22 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" android:color="@color/homepage_accessibility_background" />"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/drawable/ic_homepage_accessibility.xml"
+ line="23"
+ column="17"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" android:color="@color/homepage_accounts_background" />"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
@@ -1993,6 +2041,22 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" android:color="@color/homepage_support_background" />"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/drawable/ic_homepage_support.xml"
+ line="23"
+ column="17"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" android:color="@color/homepage_system_background" />"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
@@ -2605,7 +2669,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/strings.xml"
- line="5806"
+ line="5907"
column="36"/>
</issue>
@@ -2637,7 +2701,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="419"
+ line="427"
column="44"/>
</issue>
@@ -2653,7 +2717,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="425"
+ line="433"
column="44"/>
</issue>
@@ -2669,7 +2733,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="426"
+ line="434"
column="44"/>
</issue>
diff --git a/res/layout/zen_onboarding.xml b/res/layout/zen_onboarding.xml
index 33cdbdd..35b992d 100644
--- a/res/layout/zen_onboarding.xml
+++ b/res/layout/zen_onboarding.xml
@@ -47,7 +47,8 @@
android:id="@+id/zen_onboarding_new_setting_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:paddingHorizontal="8dp" />
+ android:paddingHorizontal="8dp"
+ android:minHeight="48dp"/>
<LinearLayout
android:layout_width="match_parent"
@@ -83,7 +84,8 @@
android:id="@+id/zen_onboarding_current_setting_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:paddingHorizontal="8dp" />
+ android:paddingHorizontal="8dp"
+ android:minHeight="48dp"/>
<LinearLayout
android:layout_width="match_parent"
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index 595f429..bc06f47 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -19,5 +19,7 @@
<color name="switch_bar_background">#dadce0</color>
<color name="switchbar_switch_track_tint">#82000000</color>
<color name="switchbar_switch_thumb_tint">@android:color/black</color>
+ <color name="homepage_accessibility_background">#783BE5</color>
+ <color name="homepage_support_background">#3F5FBD</color>
</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index e477277..6a6a2b3 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -116,9 +116,9 @@
<color name="homepage_storage_background">#C14CE6</color>
<color name="homepage_security_background">#0F9D58</color>
<color name="homepage_accounts_background">#F15B8D</color>
- <color name="homepage_accessibility_background">#783BE5</color>
+ <color name="homepage_accessibility_background">#5011C1</color>
<color name="homepage_system_background">#9E9E9E</color>
- <color name="homepage_support_background">#3F5FBD</color>
+ <color name="homepage_support_background">#26459C</color>
<color name="homepage_generic_icon_background">#1A73E8</color>
<color name="homepage_location_background">#2EC7DC</color>
<color name="homepage_about_background">#9FA8DA</color>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a95eb3d..5b6321a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -9889,6 +9889,11 @@
<!-- UI debug setting: preference summary - describes the behavior of forcing full raw GNSS satellite measurements [CHAR LIMIT=NONE] -->
<string name="enable_gnss_raw_meas_full_tracking_summary">Track all GNSS constellations and frequencies with no duty cycling</string>
+ <!-- UI debug setting: preference title - allow background activity starts [CHAR LIMIT=60] -->
+ <string name="allow_background_activity_starts">Allow background activity starts</string>
+ <!-- UI debug setting: preference summary - describes the behavior of allowing background activity starts [CHAR LIMIT=NONE] -->
+ <string name="allow_background_activity_starts_summary">Allows all background activity starts</string>
+
<!-- UI debug setting: preference title - show all crash dialogs [CHAR LIMIT=60] -->
<string name="show_first_crash_dialog">Always show crash dialog</string>
<!-- UI debug setting: preference summary - describes the behavior of showing a dialog every time an app crashes [CHAR LIMIT=NONE] -->
@@ -10254,4 +10259,4 @@
<string name="contextual_card_feedback_send">Send feedback</string>
<!-- String for contextual card feedback dialog [CHAR LIMIT=NONE] -->
<string name="contextual_card_feedback_confirm_message">Would you like to give us feedback on this suggestion?</string>
-</resources>
\ No newline at end of file
+</resources>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index cc724b8..a0f019d 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -485,6 +485,11 @@
android:title="@string/background_check_pref" />
<SwitchPreference
+ android:key="allow_background_activity_starts"
+ android:title="@string/allow_background_activity_starts"
+ android:summary="@string/allow_background_activity_starts_summary" />
+
+ <SwitchPreference
android:key="show_first_crash_dialog"
android:title="@string/show_first_crash_dialog"
android:summary="@string/show_first_crash_dialog_summary" />
diff --git a/res/xml/wifi_network_details_fragment.xml b/res/xml/wifi_network_details_fragment.xml
index b33cb75..8b027e2 100644
--- a/res/xml/wifi_network_details_fragment.xml
+++ b/res/xml/wifi_network_details_fragment.xml
@@ -34,18 +34,18 @@
<!-- General Details Category -->
<PreferenceCategory
android:key="general_details_category" >
- <com.android.settings.wifi.WifiDetailPreference
+ <Preference
android:key="signal_strength"
android:title="@string/wifi_signal"
android:selectable="false"/>
- <com.android.settings.wifi.WifiDetailPreference
+ <Preference
android:key="frequency"
android:icon="@drawable/ic_frequency_antenna"
android:title="@string/wifi_frequency"
android:selectable="false"/>
- <com.android.settings.wifi.WifiDetailPreference
+ <Preference
android:key="security"
android:icon="@drawable/ic_security_lock_24dp"
android:title="@string/wifi_security"
@@ -69,30 +69,36 @@
<PreferenceCategory
android:key="ip_details_category"
android:title="@string/wifi_setup_detail">
- <com.android.settings.wifi.WifiDetailPreference
- android:key="mac_address"
- android:title="@string/wifi_advanced_mac_address_title"
- android:selectable="false"/>
- <com.android.settings.wifi.WifiDetailPreference
+ <Preference
+ android:key="mac_address"
+ android:title="@string/wifi_advanced_mac_address_title"
+ android:selectable="false"
+ settings:enableCopying="true"/>
+ <Preference
android:key="ip_address"
android:title="@string/wifi_ip_address"
- android:selectable="false"/>
- <com.android.settings.wifi.WifiDetailPreference
+ android:selectable="false"
+ settings:enableCopying="true"/>
+ <Preference
android:key="gateway"
android:title="@string/wifi_gateway"
- android:selectable="false"/>
- <com.android.settings.wifi.WifiDetailPreference
+ android:selectable="false"
+ settings:enableCopying="true"/>
+ <Preference
android:key="subnet_mask"
android:title="@string/wifi_details_subnet_mask"
- android:selectable="false"/>
- <com.android.settings.wifi.WifiDetailPreference
+ android:selectable="false"
+ settings:enableCopying="true"/>
+ <Preference
android:key="dns"
android:title="@string/wifi_details_dns"
- android:selectable="false"/>
- <com.android.settings.wifi.WifiDetailPreference
+ android:selectable="false"
+ settings:enableCopying="true"/>
+ <Preference
android:key="link_speed"
android:title="@string/wifi_speed"
- android:selectable="false"/>
+ android:selectable="false"
+ settings:enableCopying="true"/>
</PreferenceCategory>
<!-- IPv6 Details -->
diff --git a/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceController.java b/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceController.java
new file mode 100644
index 0000000..ea47f35
--- /dev/null
+++ b/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceController.java
@@ -0,0 +1,68 @@
+/*
+ * 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;
+
+public class AllowBackgroundActivityStartsPreferenceController
+ extends DeveloperOptionsPreferenceController
+ implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
+
+ private static final String BACKGROUND_ACTIVITY_STARTS_ENABLED_KEY
+ = "allow_background_activity_starts";
+
+ public AllowBackgroundActivityStartsPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return BACKGROUND_ACTIVITY_STARTS_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.BACKGROUND_ACTIVITY_STARTS_ENABLED, isEnabled ? 1 : 0);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ final int mode = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.BACKGROUND_ACTIVITY_STARTS_ENABLED, 1);
+ ((SwitchPreference) mPreference).setChecked(mode != 0);
+ }
+
+ @Override
+ protected void onDeveloperOptionsSwitchDisabled() {
+ super.onDeveloperOptionsSwitchDisabled();
+ writeSetting(false);
+ ((SwitchPreference) mPreference).setChecked(false);
+ }
+}
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index 932c0c7..762686a 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -454,6 +454,7 @@
controllers.add(new ProfileGpuRenderingPreferenceController(context));
controllers.add(new KeepActivitiesPreferenceController(context));
controllers.add(new BackgroundProcessLimitPreferenceController(context));
+ controllers.add(new AllowBackgroundActivityStartsPreferenceController(context));
controllers.add(new ShowFirstCrashDialogPreferenceController(context));
controllers.add(new AppsNotRespondingPreferenceController(context));
controllers.add(new NotificationChannelWarningsPreferenceController(context));
diff --git a/src/com/android/settings/wifi/WifiDetailPreference.java b/src/com/android/settings/wifi/WifiDetailPreference.java
deleted file mode 100644
index 2567a42..0000000
--- a/src/com/android/settings/wifi/WifiDetailPreference.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2009 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.wifi;
-
-import android.content.Context;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.widget.TextView;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceViewHolder;
-
-import com.android.settings.R;
-
-/**
- * A Preference to be used with the Wifi Network Detail Fragment that allows a summary text to be
- * set inside the widget resource
- */
-public class WifiDetailPreference extends Preference {
- private String mDetailText;
-
- public WifiDetailPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- setWidgetLayoutResource(R.layout.preference_widget_summary);
- }
-
- public void setDetailText(String text) {
- if (TextUtils.equals(mDetailText, text)) return;
- mDetailText = text;
- notifyChanged();
- }
-
- @Override
- public void onBindViewHolder(PreferenceViewHolder view) {
- super.onBindViewHolder(view);
- TextView textView = ((TextView) view.findViewById(R.id.widget_summary));
- textView.setText(mDetailText);
- textView.setPadding(0, 0, 10, 0);
- }
-}
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index 9a3398a..48446c9 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -57,7 +57,6 @@
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.widget.ActionButtonPreference;
import com.android.settings.widget.EntityHeaderController;
-import com.android.settings.wifi.WifiDetailPreference;
import com.android.settings.wifi.WifiDialog;
import com.android.settings.wifi.WifiDialog.WifiDialogListener;
import com.android.settings.wifi.WifiUtils;
@@ -133,15 +132,15 @@
// UI elements - in order of appearance
private ActionButtonPreference mButtonsPref;
private EntityHeaderController mEntityHeaderController;
- private WifiDetailPreference mSignalStrengthPref;
- private WifiDetailPreference mLinkSpeedPref;
- private WifiDetailPreference mFrequencyPref;
- private WifiDetailPreference mSecurityPref;
- private WifiDetailPreference mMacAddressPref;
- private WifiDetailPreference mIpAddressPref;
- private WifiDetailPreference mGatewayPref;
- private WifiDetailPreference mSubnetPref;
- private WifiDetailPreference mDnsPref;
+ private Preference mSignalStrengthPref;
+ private Preference mLinkSpeedPref;
+ private Preference mFrequencyPref;
+ private Preference mSecurityPref;
+ private Preference mMacAddressPref;
+ private Preference mIpAddressPref;
+ private Preference mGatewayPref;
+ private Preference mSubnetPref;
+ private Preference mDnsPref;
private PreferenceCategory mIpv6Category;
private Preference mIpv6AddressPref;
@@ -283,22 +282,21 @@
.setButton2Text(R.string.wifi_sign_in_button_text)
.setButton2OnClickListener(view -> signIntoNetwork());
- mSignalStrengthPref =
- (WifiDetailPreference) screen.findPreference(KEY_SIGNAL_STRENGTH_PREF);
- mLinkSpeedPref = (WifiDetailPreference) screen.findPreference(KEY_LINK_SPEED);
- mFrequencyPref = (WifiDetailPreference) screen.findPreference(KEY_FREQUENCY_PREF);
- mSecurityPref = (WifiDetailPreference) screen.findPreference(KEY_SECURITY_PREF);
+ mSignalStrengthPref = screen.findPreference(KEY_SIGNAL_STRENGTH_PREF);
+ mLinkSpeedPref = screen.findPreference(KEY_LINK_SPEED);
+ mFrequencyPref = screen.findPreference(KEY_FREQUENCY_PREF);
+ mSecurityPref = screen.findPreference(KEY_SECURITY_PREF);
- mMacAddressPref = (WifiDetailPreference) screen.findPreference(KEY_MAC_ADDRESS_PREF);
- mIpAddressPref = (WifiDetailPreference) screen.findPreference(KEY_IP_ADDRESS_PREF);
- mGatewayPref = (WifiDetailPreference) screen.findPreference(KEY_GATEWAY_PREF);
- mSubnetPref = (WifiDetailPreference) screen.findPreference(KEY_SUBNET_MASK_PREF);
- mDnsPref = (WifiDetailPreference) screen.findPreference(KEY_DNS_PREF);
+ mMacAddressPref = screen.findPreference(KEY_MAC_ADDRESS_PREF);
+ mIpAddressPref = screen.findPreference(KEY_IP_ADDRESS_PREF);
+ mGatewayPref = screen.findPreference(KEY_GATEWAY_PREF);
+ mSubnetPref = screen.findPreference(KEY_SUBNET_MASK_PREF);
+ mDnsPref = screen.findPreference(KEY_DNS_PREF);
mIpv6Category = (PreferenceCategory) screen.findPreference(KEY_IPV6_CATEGORY);
mIpv6AddressPref = screen.findPreference(KEY_IPV6_ADDRESSES_PREF);
- mSecurityPref.setDetailText(mAccessPoint.getSecurityString(false /* concise */));
+ mSecurityPref.setSummary(mAccessPoint.getSecurityString(false /* concise */));
}
private void setupEntityHeader(PreferenceScreen screen) {
@@ -359,12 +357,12 @@
refreshRssiViews();
// MAC Address Pref
- mMacAddressPref.setDetailText(mWifiInfo.getMacAddress());
+ mMacAddressPref.setSummary(mWifiInfo.getMacAddress());
// Link Speed Pref
int linkSpeedMbps = mWifiInfo.getLinkSpeed();
mLinkSpeedPref.setVisible(linkSpeedMbps >= 0);
- mLinkSpeedPref.setDetailText(mContext.getString(
+ mLinkSpeedPref.setSummary(mContext.getString(
R.string.link_speed, mWifiInfo.getLinkSpeed()));
// Frequency Pref
@@ -379,7 +377,7 @@
} else {
Log.e(TAG, "Unexpected frequency " + frequency);
}
- mFrequencyPref.setDetailText(band);
+ mFrequencyPref.setSummary(band);
updateIpLayerInfo();
}
@@ -414,12 +412,12 @@
R.color.wifi_details_icon_color, mContext.getTheme()));
mSignalStrengthPref.setIcon(wifiIconDark);
- mSignalStrengthPref.setDetailText(mSignalStr[mRssiSignalLevel]);
+ mSignalStrengthPref.setSummary(mSignalStr[mRssiSignalLevel]);
}
- private void updatePreference(WifiDetailPreference pref, String detailText) {
+ private void updatePreference(Preference pref, String detailText) {
if (!TextUtils.isEmpty(detailText)) {
- pref.setDetailText(detailText);
+ pref.setSummary(detailText);
pref.setVisible(true);
} else {
pref.setVisible(false);
diff --git a/tests/robotests/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceControllerTest.java
new file mode 100644
index 0000000..8b9b14f
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceControllerTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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 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 AllowBackgroundActivityStartsPreferenceControllerTest {
+
+ @Mock
+ private SwitchPreference mPreference;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+
+ private Context mContext;
+ private AllowBackgroundActivityStartsPreferenceController mController;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new AllowBackgroundActivityStartsPreferenceController(mContext);
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
+ .thenReturn(mPreference);
+ mController.displayPreference(mPreferenceScreen);
+ }
+
+ @Test
+ public void onPreferenceChange_settingEnabled_allowBackgroundActivityStartsShouldBeOn() {
+ mController.onPreferenceChange(mPreference, true /* new value */);
+
+ final int mode = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.BACKGROUND_ACTIVITY_STARTS_ENABLED, 1 /* default */);
+
+ assertThat(mode).isEqualTo(1);
+ }
+
+ @Test
+ public void onPreferenceChange_settingDisabled_allowBackgroundActivityStartsShouldBeOff() {
+ mController.onPreferenceChange(mPreference, false /* new value */);
+
+ final int mode = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.BACKGROUND_ACTIVITY_STARTS_ENABLED, 1 /* default */);
+
+ assertThat(mode).isEqualTo(0);
+ }
+
+ @Test
+ public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.BACKGROUND_ACTIVITY_STARTS_ENABLED, 0);
+ mController.updateState(mPreference);
+
+ verify(mPreference).setChecked(false);
+ }
+
+ @Test
+ public void updateState_settingEnabled_preferenceShouldBeChecked() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.BACKGROUND_ACTIVITY_STARTS_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.BACKGROUND_ACTIVITY_STARTS_ENABLED, 1 /* default */);
+
+ assertThat(mode).isEqualTo(0);
+ verify(mPreference).setChecked(false);
+ verify(mPreference).setEnabled(false);
+ }
+}
+
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
index 4a0988a..d39b55f 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
@@ -57,6 +57,7 @@
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.LifecycleOwner;
+import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
@@ -69,7 +70,6 @@
import com.android.settings.widget.ActionButtonPreference;
import com.android.settings.widget.ActionButtonPreferenceTest;
import com.android.settings.widget.EntityHeaderController;
-import com.android.settings.wifi.WifiDetailPreference;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.widget.LayoutPreference;
@@ -144,27 +144,27 @@
@Mock
private ActionButtonPreference mockButtonsPref;
@Mock
- private WifiDetailPreference mockSignalStrengthPref;
+ private Preference mockSignalStrengthPref;
@Mock
- private WifiDetailPreference mockLinkSpeedPref;
+ private Preference mockLinkSpeedPref;
@Mock
- private WifiDetailPreference mockFrequencyPref;
+ private Preference mockFrequencyPref;
@Mock
- private WifiDetailPreference mockSecurityPref;
+ private Preference mockSecurityPref;
@Mock
- private WifiDetailPreference mockMacAddressPref;
+ private Preference mockMacAddressPref;
@Mock
- private WifiDetailPreference mockIpAddressPref;
+ private Preference mockIpAddressPref;
@Mock
- private WifiDetailPreference mockGatewayPref;
+ private Preference mockGatewayPref;
@Mock
- private WifiDetailPreference mockSubnetPref;
+ private Preference mockSubnetPref;
@Mock
- private WifiDetailPreference mockDnsPref;
+ private Preference mockDnsPref;
@Mock
private PreferenceCategory mockIpv6Category;
@Mock
- private WifiDetailPreference mockIpv6AddressesPref;
+ private Preference mockIpv6AddressesPref;
@Mock
private PackageManager mockPackageManager;
@@ -336,7 +336,7 @@
public void securityPreference_stringShouldBeSet() {
displayAndResume();
- verify(mockSecurityPref).setDetailText(SECURITY);
+ verify(mockSecurityPref).setSummary(SECURITY);
}
@Test
@@ -413,7 +413,7 @@
displayAndResume();
- verify(mockSignalStrengthPref).setDetailText(expectedStrength);
+ verify(mockSignalStrengthPref).setSummary(expectedStrength);
}
@Test
@@ -422,7 +422,7 @@
displayAndResume();
- verify(mockLinkSpeedPref).setDetailText(expectedLinkSpeed);
+ verify(mockLinkSpeedPref).setSummary(expectedLinkSpeed);
}
@Test
@@ -438,7 +438,7 @@
public void macAddressPref_shouldHaveDetailTextSet() {
displayAndResume();
- verify(mockMacAddressPref).setDetailText(MAC_ADDRESS);
+ verify(mockMacAddressPref).setSummary(MAC_ADDRESS);
}
@Test
@@ -447,7 +447,7 @@
displayAndResume();
- verify(mockIpAddressPref).setDetailText(Constants.IPV4_ADDR.getAddress().getHostAddress());
+ verify(mockIpAddressPref).setSummary(Constants.IPV4_ADDR.getAddress().getHostAddress());
}
@Test
@@ -458,8 +458,8 @@
displayAndResume();
- verify(mockSubnetPref).setDetailText("255.255.255.128");
- verify(mockGatewayPref).setDetailText("192.0.2.127");
+ verify(mockSubnetPref).setSummary("255.255.255.128");
+ verify(mockGatewayPref).setSummary("192.0.2.127");
}
@Test
@@ -470,7 +470,7 @@
displayAndResume();
- verify(mockDnsPref).setDetailText(
+ verify(mockDnsPref).setSummary(
"8.8.4.4\n" +
"8.8.8.8\n" +
Constants.IPV6_DNS.getHostAddress());
@@ -551,15 +551,15 @@
lp.addRoute(Constants.IPV4_DEFAULT);
updateLinkProperties(lp);
- inOrder.verify(mockGatewayPref).setDetailText(Constants.IPV4_GATEWAY.getHostAddress());
+ inOrder.verify(mockGatewayPref).setSummary(Constants.IPV4_GATEWAY.getHostAddress());
inOrder.verify(mockGatewayPref).setVisible(true);
lp.addLinkAddress(Constants.IPV4_ADDR);
lp.addRoute(Constants.IPV4_SUBNET);
updateLinkProperties(lp);
- inOrder.verify(mockIpAddressPref).setDetailText(asString(Constants.IPV4_ADDR));
+ inOrder.verify(mockIpAddressPref).setSummary(asString(Constants.IPV4_ADDR));
inOrder.verify(mockIpAddressPref).setVisible(true);
- inOrder.verify(mockSubnetPref).setDetailText("255.255.255.128");
+ inOrder.verify(mockSubnetPref).setSummary("255.255.255.128");
inOrder.verify(mockSubnetPref).setVisible(true);
lp.addLinkAddress(Constants.IPV6_GLOBAL1);
@@ -578,13 +578,13 @@
lp.addDnsServer(Constants.IPV6_DNS);
updateLinkProperties(lp);
- inOrder.verify(mockDnsPref).setDetailText(Constants.IPV6_DNS.getHostAddress());
+ inOrder.verify(mockDnsPref).setSummary(Constants.IPV6_DNS.getHostAddress());
inOrder.verify(mockDnsPref).setVisible(true);
lp.addDnsServer(Constants.IPV4_DNS1);
lp.addDnsServer(Constants.IPV4_DNS2);
updateLinkProperties(lp);
- inOrder.verify(mockDnsPref).setDetailText(
+ inOrder.verify(mockDnsPref).setSummary(
Constants.IPV6_DNS.getHostAddress() + "\n" +
Constants.IPV4_DNS1.getHostAddress() + "\n" +
Constants.IPV4_DNS2.getHostAddress());