From 4cf561d2c320ba5ce73297ab952d6a8671cb84ce Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Fri, 31 Jul 2020 15:27:20 -0400 Subject: [PATCH 1/3] Fix pending intent links Test: manual Fixes: 154795795 Change-Id: Ia870bd0bfd90be852121b542100806cac5bac881 (cherry picked from commit 97894bcfb70ec0a90693d7634f2a49fc91bf2562) --- .../notification/history/NotificationSbnViewHolder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/settings/notification/history/NotificationSbnViewHolder.java b/src/com/android/settings/notification/history/NotificationSbnViewHolder.java index de128472727..ac39f88def9 100644 --- a/src/com/android/settings/notification/history/NotificationSbnViewHolder.java +++ b/src/com/android/settings/notification/history/NotificationSbnViewHolder.java @@ -108,7 +108,7 @@ public class NotificationSbnViewHolder extends RecyclerView.ViewHolder { : NotificationHistoryActivity.NotificationHistoryEvent .NOTIFICATION_HISTORY_RECENT_ITEM_CLICK, uid, pkg, instanceId, position); - if (pi != null) { + if (pi != null && isPendingIntentValid) { try { pi.send(); } catch (PendingIntent.CanceledException e) { From e4ba98cebeccbabdb5c34b7e9bf12ac821bd3f21 Mon Sep 17 00:00:00 2001 From: Arc Wang Date: Mon, 17 Aug 2020 14:02:48 +0800 Subject: [PATCH 2/3] Add 'Adaptive connectivity' UI 'Adaptive connectivity' toggle button controls whether network connection is automatically managed. Bug: 162871294 Test: make RunSettingsRoboTests manual Switch the toggle button and reboot device, observe if the state is retained. Change-Id: I4499a3639abab356e8faa6316bfa45541efd63ac Merged-In: I4499a3639abab356e8faa6316bfa45541efd63ac --- .../ic_illustration_adaptive_connectivity.xml | 99 +++++++++++++++++++ res/layout/adaptive_connectivity_header.xml | 30 ++++++ res/values/config.xml | 3 + res/values/strings.xml | 5 + res/xml/adaptive_connectivity_settings.xml | 38 +++++++ res/xml/network_and_internet.xml | 7 ++ ...ptiveConnectivityPreferenceController.java | 54 ++++++++++ .../network/AdaptiveConnectivitySettings.java | 52 ++++++++++ ...onnectivityTogglePreferenceController.java | 58 +++++++++++ ...eConnectivityPreferenceControllerTest.java | 88 +++++++++++++++++ ...ctivityTogglePreferenceControllerTest.java | 77 +++++++++++++++ 11 files changed, 511 insertions(+) create mode 100644 res/drawable/ic_illustration_adaptive_connectivity.xml create mode 100644 res/layout/adaptive_connectivity_header.xml create mode 100644 res/xml/adaptive_connectivity_settings.xml create mode 100644 src/com/android/settings/network/AdaptiveConnectivityPreferenceController.java create mode 100644 src/com/android/settings/network/AdaptiveConnectivitySettings.java create mode 100644 src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceController.java create mode 100644 tests/robotests/src/com/android/settings/network/AdaptiveConnectivityPreferenceControllerTest.java create mode 100644 tests/robotests/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceControllerTest.java diff --git a/res/drawable/ic_illustration_adaptive_connectivity.xml b/res/drawable/ic_illustration_adaptive_connectivity.xml new file mode 100644 index 00000000000..748dd66d0e9 --- /dev/null +++ b/res/drawable/ic_illustration_adaptive_connectivity.xml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/layout/adaptive_connectivity_header.xml b/res/layout/adaptive_connectivity_header.xml new file mode 100644 index 00000000000..4c5fb0c380b --- /dev/null +++ b/res/layout/adaptive_connectivity_header.xml @@ -0,0 +1,30 @@ + + + + + + + + diff --git a/res/values/config.xml b/res/values/config.xml index fa4bc93d456..de0dcfbcb6c 100755 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -459,4 +459,7 @@ false + + + false diff --git a/res/values/strings.xml b/res/values/strings.xml index 2ad35e0b77d..23714226f20 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -6192,6 +6192,11 @@ VPN + + Adaptive connectivity + + Extends battery life and improves device performance by automatically managing your network connections + Credential storage diff --git a/res/xml/adaptive_connectivity_settings.xml b/res/xml/adaptive_connectivity_settings.xml new file mode 100644 index 00000000000..ff9bdb0443e --- /dev/null +++ b/res/xml/adaptive_connectivity_settings.xml @@ -0,0 +1,38 @@ + + + + + + + + + + diff --git a/res/xml/network_and_internet.xml b/res/xml/network_and_internet.xml index eaa78083358..6bf6dbaccf7 100644 --- a/res/xml/network_and_internet.xml +++ b/res/xml/network_and_internet.xml @@ -118,4 +118,11 @@ android:positiveButtonText="@string/save" android:negativeButtonText="@android:string/cancel" /> + diff --git a/src/com/android/settings/network/AdaptiveConnectivityPreferenceController.java b/src/com/android/settings/network/AdaptiveConnectivityPreferenceController.java new file mode 100644 index 00000000000..33d1d5b66cd --- /dev/null +++ b/src/com/android/settings/network/AdaptiveConnectivityPreferenceController.java @@ -0,0 +1,54 @@ +/* + * 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.network; + +import android.content.Context; +import android.provider.Settings; + +import androidx.preference.PreferenceScreen; + +import com.android.settings.R; +import com.android.settings.core.BasePreferenceController; + +/** + * {@link BasePreferenceController} that shows Adaptive connectivity on/off state. + */ +public class AdaptiveConnectivityPreferenceController extends BasePreferenceController { + + public AdaptiveConnectivityPreferenceController(Context context, String preferenceKey) { + super(context, preferenceKey); + } + + @Override + public void displayPreference(PreferenceScreen screen) { + super.displayPreference(screen); + } + + @Override + public int getAvailabilityStatus() { + return mContext.getResources().getBoolean(R.bool.config_show_adaptive_connectivity) + ? AVAILABLE : UNSUPPORTED_ON_DEVICE; + } + + @Override + public CharSequence getSummary() { + return Settings.Secure.getInt(mContext.getContentResolver(), + Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED, 1) == 1 + ? mContext.getString(R.string.switch_on_text) + : mContext.getString(R.string.switch_off_text); + } +} diff --git a/src/com/android/settings/network/AdaptiveConnectivitySettings.java b/src/com/android/settings/network/AdaptiveConnectivitySettings.java new file mode 100644 index 00000000000..5e1dc124f3b --- /dev/null +++ b/src/com/android/settings/network/AdaptiveConnectivitySettings.java @@ -0,0 +1,52 @@ +/* + * 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.network; + +import android.app.settings.SettingsEnums; + +import com.android.settings.R; +import com.android.settings.dashboard.DashboardFragment; +import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settingslib.search.SearchIndexable; + +/** + * Adaptive connectivity is a feature which automatically manages network connections. + */ +@SearchIndexable +public class AdaptiveConnectivitySettings extends DashboardFragment { + + private static final String TAG = "AdaptiveConnectivitySettings"; + + private static final String KEY_ADAPTIVE_CONNECTIVITY_PREFERENCE = "adaptive_connectivity"; + + @Override + public int getMetricsCategory() { + return SettingsEnums.ADAPTIVE_CONNECTIVITY_CATEGORY; + } + + @Override + protected String getLogTag() { + return TAG; + } + + @Override + protected int getPreferenceScreenResId() { + return R.xml.adaptive_connectivity_settings; + } + + public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new BaseSearchIndexProvider(R.xml.adaptive_connectivity_settings); +} diff --git a/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceController.java b/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceController.java new file mode 100644 index 00000000000..e072b5c4e38 --- /dev/null +++ b/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceController.java @@ -0,0 +1,58 @@ +/* + * 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.network; + +import android.content.Context; +import android.provider.Settings; + +import androidx.preference.PreferenceScreen; + +import com.android.settings.core.TogglePreferenceController; + +/** + * {@link TogglePreferenceController} that controls whether Adaptive connectivity option is enabled. + */ +public class AdaptiveConnectivityTogglePreferenceController extends TogglePreferenceController { + + public AdaptiveConnectivityTogglePreferenceController(Context context, String preferenceKey) { + super(context, preferenceKey); + } + + @Override + public void displayPreference(PreferenceScreen screen) { + super.displayPreference(screen); + } + + @Override + public int getAvailabilityStatus() { + return AVAILABLE; + } + + @Override + public boolean isChecked() { + return Settings.Secure.getInt(mContext.getContentResolver(), + Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED, 1) == 1; + } + + @Override + public boolean setChecked(boolean isChecked) { + Settings.Secure.putInt(mContext.getContentResolver(), + Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED, + isChecked ? 1 : 0); + return true; + } +} diff --git a/tests/robotests/src/com/android/settings/network/AdaptiveConnectivityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/AdaptiveConnectivityPreferenceControllerTest.java new file mode 100644 index 00000000000..9ba62385756 --- /dev/null +++ b/tests/robotests/src/com/android/settings/network/AdaptiveConnectivityPreferenceControllerTest.java @@ -0,0 +1,88 @@ +/* + * 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.network; + +import static com.google.common.truth.Truth.assertThat; + +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + +import android.content.Context; +import android.content.res.Resources; +import android.provider.Settings; + +import com.android.settings.R; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; + +@RunWith(RobolectricTestRunner.class) +public class AdaptiveConnectivityPreferenceControllerTest { + + private static final String PREF_KEY = "adaptive_connectivity"; + + private Context mContext; + @Mock private Resources mResources; + private AdaptiveConnectivityPreferenceController mController; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + mContext = spy(RuntimeEnvironment.application); + doReturn(mResources).when(mContext).getResources(); + mController = new AdaptiveConnectivityPreferenceController(mContext, PREF_KEY); + } + + @Test + public void isAvailable_supportAdaptiveConnectivity_shouldReturnTrue() { + when(mResources.getBoolean(R.bool.config_show_adaptive_connectivity)) + .thenReturn(true); + + assertThat(mController.isAvailable()).isTrue(); + } + + @Test + public void isAvailable_notSupportAdaptiveConnectivity_shouldReturnFalse() { + when(mResources.getBoolean(R.bool.config_show_adaptive_connectivity)) + .thenReturn(false); + + assertThat(mController.isAvailable()).isFalse(); + } + + @Test + public void getSummary_adaptiveConnectivityEnabled_shouldShowOn() { + Settings.Secure.putInt(mContext.getContentResolver(), + Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED, 1); + + assertThat(mController.getSummary()).isEqualTo(mContext.getString(R.string.switch_on_text)); + } + + @Test + public void getSummary_adaptiveConnectivityEnabled_shouldShowOff() { + Settings.Secure.putInt(mContext.getContentResolver(), + Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED, 0); + + assertThat(mController.getSummary()) + .isEqualTo(mContext.getString(R.string.switch_off_text)); + } +} diff --git a/tests/robotests/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceControllerTest.java new file mode 100644 index 00000000000..dfb9a8f2136 --- /dev/null +++ b/tests/robotests/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceControllerTest.java @@ -0,0 +1,77 @@ +/* + * 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.network; + +import static com.google.common.truth.Truth.assertThat; + +import static org.mockito.Answers.RETURNS_DEEP_STUBS; + +import android.content.Context; +import android.provider.Settings; + +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; + +@RunWith(RobolectricTestRunner.class) +public class AdaptiveConnectivityTogglePreferenceControllerTest { + + private static final String PREF_KEY = "adaptive_connectivity"; + + @Mock(answer = RETURNS_DEEP_STUBS) + private Context mContext; + + private AdaptiveConnectivityTogglePreferenceController mController; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + mController = new AdaptiveConnectivityTogglePreferenceController(mContext, PREF_KEY); + } + + @Test + public void isAvailable_shouldReturnTrue() { + assertThat(mController.isAvailable()).isTrue(); + } + + @Test + public void setChecked_withTrue_shouldUpdateSetting() { + Settings.Secure.putInt(mContext.getContentResolver(), + Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED, 0); + + mController.setChecked(true); + + assertThat(Settings.Secure.getInt(mContext.getContentResolver(), + Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED, 1)) + .isEqualTo(1); + } + + @Test + public void setChecked_withFalse_shouldUpdateSetting() { + Settings.Secure.putInt(mContext.getContentResolver(), + Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED, 1); + + mController.setChecked(false); + + assertThat(Settings.Secure.getInt(mContext.getContentResolver(), + Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED, 1)) + .isEqualTo(0); + } +} From 6de20ba7d3f4521118e7b1379979a2dec17fcc92 Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Mon, 24 Aug 2020 07:55:38 -0700 Subject: [PATCH 3/3] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: I7c05495dd402909c7be8dff05bf3dcfa989046b0 --- res/values-az/strings.xml | 2 +- res/values-bg/strings.xml | 2 +- res/values-bs/strings.xml | 2 +- res/values-es/strings.xml | 2 +- res/values-eu/strings.xml | 2 +- res/values-fa/strings.xml | 4 ++-- res/values-hy/strings.xml | 2 +- res/values-nl/strings.xml | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/res/values-az/strings.xml b/res/values-az/strings.xml index de0ad0f9979..851be80a7ef 100644 --- a/res/values-az/strings.xml +++ b/res/values-az/strings.xml @@ -2502,7 +2502,7 @@ "Cihaz batareya istifadəsini normal idarə edə bilmir, çünki tətbiqdən istifadə etmədiyiniz zaman %1$s məkanı təklif etməyə davam edir.\n\n Bu problemi həll etmək üçün tətbiq məkanını deaktiv edə bilərsiniz." "Deaktiv edin" "Ekran" - "İşartı" + "Fənər" "Kamera" "Wi-Fi" "Bluetooth" diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml index 6f7a7fa8b50..1cc04bb4c42 100644 --- a/res/values-bg/strings.xml +++ b/res/values-bg/strings.xml @@ -2276,7 +2276,7 @@ "За звъненето и известията е зададено „Силно“" "Изключено" "Слабо" - "средно" + "Средно" "Силно" "Настройки" "Вкл." diff --git a/res/values-bs/strings.xml b/res/values-bs/strings.xml index 503b7559dc7..4c8a23fc93b 100644 --- a/res/values-bs/strings.xml +++ b/res/values-bs/strings.xml @@ -2206,7 +2206,7 @@ "Dugme uklj./isklj. prekida poziv" "Veliki pokazivač miša" "Ukloni animacije" - "Mono audio" + "Mono zvuk" "Kombiniranje kanala prilikom reprodukcije zvuka" "Balans zvuka" "Lijevo" diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 3d621d3c4f1..f5e1d455638 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -254,7 +254,7 @@ "Fecha y hora" "Establecer fecha y hora" "Establecer fecha, hora, zona horaria y formatos" - "Usar hora de la red" + "Usar la hora proporcionada por la red" "Usar la zona horaria proporcionada por la red" "Usar la configuración regional predeterminada" "Formato de 24 horas" diff --git a/res/values-eu/strings.xml b/res/values-eu/strings.xml index f704b61cedc..87c65e419f9 100644 --- a/res/values-eu/strings.xml +++ b/res/values-eu/strings.xml @@ -823,7 +823,7 @@ "Kokapenaren zehaztasuna hobetzeko, aplikazioek eta zerbitzuek wifi-sareak bilatzen jarraituko dute, baita wifi-konexioa desaktibatuta dagoenean ere. Besteak beste, kokapenean oinarritutako eginbideak eta zerbitzuak hobetzeko erabil daiteke. Aukera hori aldatzeko, joan LINK_BEGINbilatzeko ezarpenetaraLINK_END." "Kokapenaren zehaztasuna hobetzeko, aktibatu Wifi-sareen bilaketa LINK_BEGINbilatzeko ezarpenetanLINK_END." "Ez erakutsi berriro" - "Izan Wi-Fia aktibatuta egoera inaktiboan" + "Eduki Wi-Fia aktibatuta egoera inaktiboan" "Wi‑Fi aktibatuta inaktibo moduan" "Arazo bat izan da ezarpena aldatzean" "Egin eraginkorrago" diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index fd92c9c80f1..8f2bafe09b1 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -2616,7 +2616,7 @@ "پس‌زمینه" "پیش‌زمینه" "در حافظه پنهان" - "‏سیستم عامل Android" + "‏سیستم‌عامل Android" "داخلی" "مرکزی" "Z-Ram" @@ -4930,7 +4930,7 @@ "نمایش کنترل‌های دستگاه" "نمایش کارت‌ها و مجوزها" "برای دسترسی به کنترل‌های دستگاه‌های متصل، دکمه روشن/خاموش را نگه دارید" - "برای دسترسی به مواردی مانند روش‌های پرداخت و کارت پرواز، دکمه «روشن/خاموش» را فشار دهید و نگه‌دارید." + "برای دسترسی به مواردی مانند روش‌های پرداخت و کارت پرواز، دکمه روشن/خاموش را فشار دهید و نگه‌دارید." diff --git a/res/values-hy/strings.xml b/res/values-hy/strings.xml index 6d390486f77..82f2f017faa 100644 --- a/res/values-hy/strings.xml +++ b/res/values-hy/strings.xml @@ -3273,7 +3273,7 @@ "մատնահետք, ավելացնել մատնահետք" "խամրեցված էկրան, հպէկրան, մարտկոց, խելացի պայծառություն, դինամիկ պայծառություն, ավտոմատ պայծառություն" "խամրած էկրան, քնի ռեժիմ, մարտկոց, ժամանակի սպառում, ուշադրություն, էկրան, ցուցադրել, անգործուն ռեժիմ" - "պտտել, շրջել, պտույտ, ուղղահայաց, հորիզոնական, դիրք, դիմանկար, բնանկար" + "պտտել, շրջել, պտույտ, ուղղաձիգ, հորիզոնական, դիրք, դիմանկար, բնանկար" "թարմացնել, Android" "չանհանգստացնել, ժամանակացույց, ծանուցումներ, արգելափակել, անձայն ռեժիմ, թրթռալ, քուն, աշխատանք, կենտրոնացում, ձայն, անջատել ձայնը, օր, աշխատանքային օր, հանգստյան օր, աշխատանքային օրվա երեկո, միջոցառում" "էկրան, կողպման ժամանակը, անջատում, կողպէկրան" diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index 04db69bcca3..63a8e44ef94 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -3822,7 +3822,7 @@ %s mogen onderbreken %s mag onderbreken - "en nog %d" + "nog %d" "Apps" "Alle meldingen" "Bepaalde meldingen"