From 203b5203d97f348a5b060979bc226ad7eebc4f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thi=C3=A9baud=20Weksteen?= Date: Wed, 17 Feb 2021 15:38:58 +0100 Subject: [PATCH 01/10] Add onPreferenceChange_update tests Bug: 180688212 Test: atest -c Enable2gPreferenceControllerTest Change-Id: Ie7bc7a49f2ce4d5e8b8d75914fa46b613569566f --- .../Enable2gPreferenceControllerTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/unit/src/com/android/settings/network/telephony/Enable2gPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/Enable2gPreferenceControllerTest.java index 9b9bb1131d3..293a19dad09 100644 --- a/tests/unit/src/com/android/settings/network/telephony/Enable2gPreferenceControllerTest.java +++ b/tests/unit/src/com/android/settings/network/telephony/Enable2gPreferenceControllerTest.java @@ -22,6 +22,8 @@ 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.times; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; @@ -117,4 +119,27 @@ public final class Enable2gPreferenceControllerTest { assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); } + + @Test + public void onPreferenceChange_update() { + // Set "Enable 2G" flag to "on" + when(mTelephonyManager.getAllowedNetworkTypesForReason( + TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G)).thenReturn( + (long) (TelephonyManager.NETWORK_TYPE_BITMASK_GSM + | TelephonyManager.NETWORK_TYPE_BITMASK_LTE)); + + // Setup state to allow disabling + doReturn(true).when(mTelephonyManager).isRadioInterfaceCapabilitySupported( + mTelephonyManager.CAPABILITY_ALLOWED_NETWORK_TYPES_USED); + mPersistableBundle.putBoolean(CarrierConfigManager.KEY_HIDE_ENABLE_2G, + false); + + // Disable 2G + boolean changed = mController.setChecked(false); + assertThat(changed).isEqualTo(true); + + verify(mTelephonyManager, times(1)).setAllowedNetworkTypesForReason( + TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G, + TelephonyManager.NETWORK_TYPE_BITMASK_LTE); + } } From 51513522b3eee3ee5931a1f7bea131cec091109c Mon Sep 17 00:00:00 2001 From: Mill Chen Date: Sat, 20 Feb 2021 00:35:05 +0800 Subject: [PATCH 02/10] Tweak UI for make profile pattern visible Removing the summary placeholder from Make profile pattern visible preference, since this preference has nothing to show in its summary. Bug: 180573775 Test: visual verified 1) Create a work profile through TestDPC 2) Settings -> Security -> disable Use one lock 3) Setting pattern for Work profile lock 4) Observe Make profile pattern visible and check if it's central aligned Change-Id: I66b828aa6f719cdefc6b81efcc3c2c9e54cdcaf1 --- res/xml/security_dashboard_settings.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/res/xml/security_dashboard_settings.xml b/res/xml/security_dashboard_settings.xml index b5dcebf6d99..1b7b02654c2 100644 --- a/res/xml/security_dashboard_settings.xml +++ b/res/xml/security_dashboard_settings.xml @@ -78,7 +78,6 @@ From 38567b98d43380025d5a0c13a063e5f86deba4b7 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Fri, 19 Feb 2021 18:02:57 +0000 Subject: [PATCH 03/10] Correctly select peak refresh rate. Currently we will get an arbitrary value that is greater than the default depending on the order returned by the Display. Bug: 180723012 Test: make RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.display.PeakRefreshRatePreferenceControllerTest" Change-Id: Id2c99f2bea9c6b2814d82a9db3a417e4a93ee06d --- ...ForcePeakRefreshRatePreferenceController.java | 2 +- .../PeakRefreshRatePreferenceController.java | 5 +++-- .../PeakRefreshRatePreferenceControllerTest.java | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/development/ForcePeakRefreshRatePreferenceController.java b/src/com/android/settings/development/ForcePeakRefreshRatePreferenceController.java index 78352d33cd1..d5d40254fa8 100644 --- a/src/com/android/settings/development/ForcePeakRefreshRatePreferenceController.java +++ b/src/com/android/settings/development/ForcePeakRefreshRatePreferenceController.java @@ -122,7 +122,7 @@ public class ForcePeakRefreshRatePreferenceController extends DeveloperOptionsPr private float findPeakRefreshRate(Display.Mode[] modes) { float peakRefreshRate = DEFAULT_REFRESH_RATE; for (Display.Mode mode : modes) { - if (Math.round(mode.getRefreshRate()) > DEFAULT_REFRESH_RATE) { + if (Math.round(mode.getRefreshRate()) > peakRefreshRate) { peakRefreshRate = mode.getRefreshRate(); } } diff --git a/src/com/android/settings/display/PeakRefreshRatePreferenceController.java b/src/com/android/settings/display/PeakRefreshRatePreferenceController.java index 10cab1c9e27..36e085a068f 100644 --- a/src/com/android/settings/display/PeakRefreshRatePreferenceController.java +++ b/src/com/android/settings/display/PeakRefreshRatePreferenceController.java @@ -129,10 +129,11 @@ public class PeakRefreshRatePreferenceController extends TogglePreferenceControl mDeviceConfigDisplaySettings.stopListening(); } - private float findPeakRefreshRate(Display.Mode[] modes) { + @VisibleForTesting + float findPeakRefreshRate(Display.Mode[] modes) { float peakRefreshRate = DEFAULT_REFRESH_RATE; for (Display.Mode mode : modes) { - if (Math.round(mode.getRefreshRate()) > DEFAULT_REFRESH_RATE) { + if (Math.round(mode.getRefreshRate()) > peakRefreshRate) { peakRefreshRate = mode.getRefreshRate(); } } diff --git a/tests/robotests/src/com/android/settings/display/PeakRefreshRatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/PeakRefreshRatePreferenceControllerTest.java index cae7d896916..aaeeea4f368 100644 --- a/tests/robotests/src/com/android/settings/display/PeakRefreshRatePreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/display/PeakRefreshRatePreferenceControllerTest.java @@ -24,6 +24,7 @@ import static com.google.common.truth.Truth.assertThat; import android.content.Context; import android.provider.Settings; +import android.view.Display; import androidx.preference.SwitchPreference; @@ -102,6 +103,21 @@ public class PeakRefreshRatePreferenceControllerTest { assertThat(mController.isChecked()).isFalse(); } + @Test + public void findPeakRefreshRate_moreThanOneHigherThanDefault() { + Display.Mode lower = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE - 1); + Display.Mode def = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE); + Display.Mode higher = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE + 1); + Display.Mode higher1 = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE + 2); + + assertThat(mController.findPeakRefreshRate( + new Display.Mode[] {lower, def, higher, higher1})) + .isEqualTo(DEFAULT_REFRESH_RATE + 2); + assertThat(mController.findPeakRefreshRate( + new Display.Mode[] {lower, def, higher1, higher})) + .isEqualTo(DEFAULT_REFRESH_RATE + 2); + } + private void enableSmoothDisplayPreference() { mController.mPeakRefreshRate = 88f; From 00798a5902e0042629a2f19c0ec7bc017d1ea658 Mon Sep 17 00:00:00 2001 From: tom hsu Date: Fri, 5 Feb 2021 22:42:58 +0800 Subject: [PATCH 04/10] [Provider model] Show a string on internet picker when mobile data off - https://screenshot.googleplex.com/6JE9ma6UZmGCNFQ Bug: 178680922 Test: Manual test passed Test: atest passed Change-Id: Id276e3f97b4380f648eb9e35ca7780a0ba32bdb2 --- .../SubscriptionsPreferenceController.java | 8 +++- ...SubscriptionsPreferenceControllerTest.java | 47 +++++++++++++++---- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java index d028c5835e2..392ccc6aba5 100644 --- a/src/com/android/settings/network/SubscriptionsPreferenceController.java +++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java @@ -35,6 +35,7 @@ import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; +import android.text.Html; import android.util.ArraySet; import androidx.annotation.VisibleForTesting; @@ -255,14 +256,17 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl mUpdateListener.onChildrenUpdated(); } - private String getMobilePreferenceSummary(int subId) { + private CharSequence getMobilePreferenceSummary(int subId) { String result = mSubsPrefCtrlInjector.getNetworkType( mContext, mConfig, mTelephonyDisplayInfo, subId); + if (!mTelephonyManager.isDataEnabled()) { + return mContext.getString(R.string.mobile_data_off_summary); + } if (!result.isEmpty() && mSubsPrefCtrlInjector.isActiveCellularNetwork(mContext)) { result = mContext.getString(R.string.preference_summary_default_combination, mContext.getString(R.string.mobile_data_connection_active), result); } - return result; + return Html.fromHtml(result, Html.FROM_HTML_MODE_LEGACY); } private Drawable getIcon(int subId) { diff --git a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java index ef3f130911f..6b31342d31e 100644 --- a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java +++ b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java @@ -16,7 +16,6 @@ package com.android.settings.network; -import static android.telephony.SignalStrength.NUM_SIGNAL_STRENGTH_BINS; import static android.telephony.SignalStrength.SIGNAL_STRENGTH_GOOD; import static android.telephony.SignalStrength.SIGNAL_STRENGTH_GREAT; import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; @@ -24,6 +23,7 @@ import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq;; import static org.mockito.Mockito.doReturn; @@ -47,6 +47,7 @@ import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; +import android.text.Html; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.LifecycleRegistry; @@ -371,14 +372,14 @@ public class SubscriptionsPreferenceControllerTest { final Preference pref = new Preference(mContext); final Drawable greatDrawWithoutCutOff = mock(Drawable.class); doReturn(greatDrawWithoutCutOff).when(sInjector) - .getIcon(mContext, 4, NUM_SIGNAL_STRENGTH_BINS, true); + .getIcon(any(), anyInt(), anyInt(), anyBoolean()); mController.setIcon(pref, 1, true /* isDefaultForData */); assertThat(pref.getIcon()).isEqualTo(greatDrawWithoutCutOff); final Drawable greatDrawWithCutOff = mock(Drawable.class); doReturn(greatDrawWithCutOff).when(sInjector) - .getIcon(mContext, 4, NUM_SIGNAL_STRENGTH_BINS, true); + .getIcon(any(), anyInt(), anyInt(), anyBoolean()); mController.setIcon(pref, 2, false /* isDefaultForData */); assertThat(pref.getIcon()).isEqualTo(greatDrawWithCutOff); } @@ -416,7 +417,8 @@ public class SubscriptionsPreferenceControllerTest { @Test @UiThreadTest public void displayPreference_providerAndHasMultiSimAndActive_connectedAndRat() { - final String expectedSummary = "Connected / 5G"; + final CharSequence expectedSummary = + Html.fromHtml("Connected / 5G", Html.FROM_HTML_MODE_LEGACY); final String networkType = "5G"; final List sub = setupMockSubscriptions(2); doReturn(true).when(sInjector).isProviderModelEnabled(mContext); @@ -426,6 +428,7 @@ public class SubscriptionsPreferenceControllerTest { doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext); doReturn(networkType) .when(sInjector).getNetworkType(any(), any(), any(), anyInt()); + when(mTelephonyManager.isDataEnabled()).thenReturn(true); mController.onResume(); mController.displayPreference(mPreferenceScreen); @@ -435,8 +438,11 @@ public class SubscriptionsPreferenceControllerTest { @Test @UiThreadTest - public void displayPreference_providerAndHasMultiSimAndNotActive_showRatOnly() { - final String expectedSummary = "5G"; + public void displayPreference_providerAndHasMultiSimButMobileDataOff_notAutoConnect() { + final String dataOffSummary = + ResourcesUtils.getResourcesString(mContext, "mobile_data_off_summary"); + final CharSequence expectedSummary = + Html.fromHtml(dataOffSummary, Html.FROM_HTML_MODE_LEGACY); final String networkType = "5G"; final List sub = setupMockSubscriptions(2); doReturn(true).when(sInjector).isProviderModelEnabled(mContext); @@ -449,6 +455,27 @@ public class SubscriptionsPreferenceControllerTest { mController.onResume(); mController.displayPreference(mPreferenceScreen); + assertThat(mPreferenceCategory.getPreference(0).getSummary()) + .isEqualTo(expectedSummary.toString()); + } + + @Test + @UiThreadTest + public void displayPreference_providerAndHasMultiSimAndNotActive_showRatOnly() { + final CharSequence expectedSummary = Html.fromHtml("5G", Html.FROM_HTML_MODE_LEGACY); + final String networkType = "5G"; + final List sub = setupMockSubscriptions(2); + doReturn(true).when(sInjector).isProviderModelEnabled(mContext); + doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo(); + setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true, + TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE); + doReturn(networkType) + .when(sInjector).getNetworkType(any(), any(), any(), anyInt()); + when(mTelephonyManager.isDataEnabled()).thenReturn(true); + + mController.onResume(); + mController.displayPreference(mPreferenceScreen); + assertThat(mPreferenceCategory.getPreference(0).getSummary()).isEqualTo(expectedSummary); } @@ -467,7 +494,8 @@ public class SubscriptionsPreferenceControllerTest { @Test @UiThreadTest public void onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndActive_connectedAndRat() { - final String expectedSummary = "Connected / LTE"; + final CharSequence expectedSummary = + Html.fromHtml("Connected / LTE", Html.FROM_HTML_MODE_LEGACY); final String networkType = "LTE"; final List sub = setupMockSubscriptions(2); final TelephonyDisplayInfo telephonyDisplayInfo = @@ -480,6 +508,7 @@ public class SubscriptionsPreferenceControllerTest { doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext); doReturn(networkType) .when(sInjector).getNetworkType(any(), any(), any(), anyInt()); + when(mTelephonyManager.isDataEnabled()).thenReturn(true); mController.onResume(); mController.displayPreference(mPreferenceScreen); @@ -491,7 +520,8 @@ public class SubscriptionsPreferenceControllerTest { @Test @UiThreadTest public void onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndNotActive_showRat() { - final String expectedSummary = "LTE"; + final CharSequence expectedSummary = + Html.fromHtml("LTE", Html.FROM_HTML_MODE_LEGACY); final String networkType = "LTE"; final List sub = setupMockSubscriptions(2); final TelephonyDisplayInfo telephonyDisplayInfo = @@ -504,6 +534,7 @@ public class SubscriptionsPreferenceControllerTest { doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext); doReturn(networkType) .when(sInjector).getNetworkType(any(), any(), any(), anyInt()); + when(mTelephonyManager.isDataEnabled()).thenReturn(true); mController.onResume(); mController.displayPreference(mPreferenceScreen); From 2ad549e13afc916a0a204968278c2ce9a30e8c0a Mon Sep 17 00:00:00 2001 From: Mill Chen Date: Sat, 20 Feb 2021 16:56:04 +0800 Subject: [PATCH 05/10] Update FingerprintEnrollEnrolling for UDFPS The BC theme didn't work in the fingerprint enrollment page since this page was using a customized layout and wasn't following the SUD template. Also the fingerprint sensor icon has been moved to SysUI so it's unnecessary to have the customized layout. This CL is trying to merge two layouts together and make BC theme apply to the fingerprint enrollment page. Bug: 177026664 Test: visual verified Change-Id: Ia22ea14244cd4b508a1fa6341aa15bd741c195f4 --- res/layout/udfps_enroll_enrolling.xml | 42 +++++++++- res/layout/udfps_enroll_layout.xml | 77 ------------------- .../FingerprintEnrollEnrolling.java | 5 -- .../fingerprint/UdfpsEnrollLayout.java | 42 ---------- 4 files changed, 41 insertions(+), 125 deletions(-) delete mode 100644 res/layout/udfps_enroll_layout.xml delete mode 100644 src/com/android/settings/biometrics/fingerprint/UdfpsEnrollLayout.java diff --git a/res/layout/udfps_enroll_enrolling.xml b/res/layout/udfps_enroll_enrolling.xml index 03b6528b32e..6b3382cb606 100644 --- a/res/layout/udfps_enroll_enrolling.xml +++ b/res/layout/udfps_enroll_enrolling.xml @@ -20,7 +20,47 @@ android:id="@+id/setup_wizard_layout" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout="@layout/sud_glif_blank_template" style="?attr/fingerprint_layout_theme"> + + + + + + + + + + + + + diff --git a/res/layout/udfps_enroll_layout.xml b/res/layout/udfps_enroll_layout.xml deleted file mode 100644 index 833858911d2..00000000000 --- a/res/layout/udfps_enroll_layout.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java index 78abb58bd80..1b2a6a5f071 100644 --- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java +++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java @@ -144,12 +144,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling { mCanAssumeUdfps = props.size() == 1 && props.get(0).isAnyUdfpsType(); if (mCanAssumeUdfps) { - // Use a custom layout since animations, etc must be based off of the sensor's physical - // location. setContentView(R.layout.udfps_enroll_enrolling); - final UdfpsEnrollLayout udfpsEnrollLayout = (UdfpsEnrollLayout) getLayoutInflater() - .inflate(R.layout.udfps_enroll_layout, null /* root */); - getLayout().addView(udfpsEnrollLayout); } else { setContentView(R.layout.fingerprint_enroll_enrolling); } diff --git a/src/com/android/settings/biometrics/fingerprint/UdfpsEnrollLayout.java b/src/com/android/settings/biometrics/fingerprint/UdfpsEnrollLayout.java deleted file mode 100644 index 7923d27a01d..00000000000 --- a/src/com/android/settings/biometrics/fingerprint/UdfpsEnrollLayout.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.biometrics.fingerprint; - -import android.content.Context; -import android.hardware.fingerprint.FingerprintManager; -import android.hardware.fingerprint.FingerprintSensorPropertiesInternal; -import android.util.AttributeSet; -import android.view.View; -import android.view.WindowInsets; -import android.view.WindowManager; -import android.widget.LinearLayout; - -import com.android.settings.R; - -public class UdfpsEnrollLayout extends LinearLayout { - - private static final String TAG = "UdfpsEnrollLayout"; - - public UdfpsEnrollLayout(Context context, AttributeSet attrs) { - super(context, attrs); - } - - @Override - public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } -} From 5fea7c9a46d5ec817d1e5b9f2823a53414fccda6 Mon Sep 17 00:00:00 2001 From: Mill Chen Date: Sat, 20 Feb 2021 17:30:59 +0800 Subject: [PATCH 06/10] Remove enroll animation from touch sensor page During the setup flow, the enrolling animation will be shown in the touch sensor page. This was caused by using the old layout during the setup flow. Removing the overrided method getContentView to fix this issue. Fixes: 179447737 Test: visual verified 1) adb shell am start -n com.google.android.setupwizard/.SetupWizardTestActivity 2) Follow the setup flow and check if the touch sensor page has an animation Change-Id: I249535d6c0e8a5f12d86aeeac5308489e469bf71 --- .../fingerprint/SetupFingerprintEnrollFindSensor.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java index 8097adc701f..394b6733786 100644 --- a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java +++ b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java @@ -36,11 +36,6 @@ import com.android.settings.password.ChooseLockSettingsHelper; public class SetupFingerprintEnrollFindSensor extends FingerprintEnrollFindSensor { - @Override - protected int getContentView() { - return R.layout.fingerprint_enroll_find_sensor; - } - @Override protected Intent getFingerprintEnrollingIntent() { Intent intent = new Intent(this, SetupFingerprintEnrollEnrolling.class); From cbbe9da1adb5d1437ed4802aa1b85f0660cb0e95 Mon Sep 17 00:00:00 2001 From: Manish Singh Date: Thu, 11 Feb 2021 22:03:44 +0000 Subject: [PATCH 07/10] Introduce controller for transcode notifications This is to provider users with control over whether to show transcoding notifications or not. By default we show the notifications. The controller resides within the Media transcoding settings under Developer Options. BUG: 170973510 Test: manual. unit test added. Change-Id: I7172f583ce4c1a53e5d5ccc07625f201852db43a --- res/xml/transcode_settings.xml | 5 ++ ...scodeNotificationPreferenceController.java | 53 +++++++++++++ ...eNotificationPreferenceControllerTest.java | 76 +++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 src/com/android/settings/development/transcode/TranscodeNotificationPreferenceController.java create mode 100644 tests/unit/src/com/android/settings/development/transcode/TranscodeNotificationPreferenceControllerTest.java diff --git a/res/xml/transcode_settings.xml b/res/xml/transcode_settings.xml index b142d318392..c5a9763e4b5 100644 --- a/res/xml/transcode_settings.xml +++ b/res/xml/transcode_settings.xml @@ -35,4 +35,9 @@ android:key="transcode_default" android:title="@string/transcode_default" settings:controller="com.android.settings.development.transcode.TranscodeDefaultOptionPreferenceController" /> + + diff --git a/src/com/android/settings/development/transcode/TranscodeNotificationPreferenceController.java b/src/com/android/settings/development/transcode/TranscodeNotificationPreferenceController.java new file mode 100644 index 00000000000..e51f8ad5b63 --- /dev/null +++ b/src/com/android/settings/development/transcode/TranscodeNotificationPreferenceController.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2021 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.transcode; + +import android.content.Context; +import android.os.SystemProperties; + +import com.android.internal.annotations.VisibleForTesting; +import com.android.settings.core.TogglePreferenceController; + +/** + * The controller (in the Media transcoding settings) indicating the user's preference to show + * or hide the transcoding notifications. + */ +public class TranscodeNotificationPreferenceController extends TogglePreferenceController { + @VisibleForTesting + static final String TRANSCODE_NOTIFICATION_SYS_PROP_KEY = + "persist.sys.fuse.transcode_notification"; + + public TranscodeNotificationPreferenceController(Context context, String preferenceKey) { + super(context, preferenceKey); + } + + @Override + public boolean isChecked() { + return SystemProperties.getBoolean(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, true); + } + + @Override + public boolean setChecked(boolean isChecked) { + SystemProperties.set(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, String.valueOf(isChecked)); + return true; + } + + @Override + public int getAvailabilityStatus() { + return AVAILABLE; + } +} diff --git a/tests/unit/src/com/android/settings/development/transcode/TranscodeNotificationPreferenceControllerTest.java b/tests/unit/src/com/android/settings/development/transcode/TranscodeNotificationPreferenceControllerTest.java new file mode 100644 index 00000000000..0903c72a099 --- /dev/null +++ b/tests/unit/src/com/android/settings/development/transcode/TranscodeNotificationPreferenceControllerTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2021 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.transcode; + +import static com.android.settings.development.transcode.TranscodeNotificationPreferenceController.TRANSCODE_NOTIFICATION_SYS_PROP_KEY; + +import static com.google.common.truth.Truth.assertThat; + +import android.content.Context; +import android.os.SystemProperties; + +import androidx.test.core.app.ApplicationProvider; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import com.android.settings.core.BasePreferenceController; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(AndroidJUnit4.class) +public class TranscodeNotificationPreferenceControllerTest { + private TranscodeNotificationPreferenceController mUnderTest; + + @Before + public void setUp() { + Context context = ApplicationProvider.getApplicationContext(); + mUnderTest = new TranscodeNotificationPreferenceController(context, "notification_key"); + } + + @Test + public void isChecked_whenSysPropSet_shouldReturnTrue() { + SystemProperties.set(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, "true"); + assertThat(mUnderTest.isChecked()).isTrue(); + } + + @Test + public void isChecked_whenSysPropUnset_shouldReturnFalse() { + SystemProperties.set(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, "false"); + assertThat(mUnderTest.isChecked()).isFalse(); + } + + @Test + public void setChecked_withTrue_shouldSetSysProp() { + mUnderTest.setChecked(true); + assertThat( + SystemProperties.getBoolean(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, false)).isTrue(); + } + + @Test + public void setChecked_withFalse_shouldUnsetSysProp() { + mUnderTest.setChecked(false); + assertThat( + SystemProperties.getBoolean(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, true)).isFalse(); + } + + @Test + public void getAvailabilityStatus_shouldReturn_isAvailable() { + assertThat(mUnderTest.getAvailabilityStatus()).isEqualTo( + BasePreferenceController.AVAILABLE); + } +} From 2fb3390ce6166ffca9f12dfaf693fd5ed87ffb7b Mon Sep 17 00:00:00 2001 From: "Wesley.CW Wang" Date: Mon, 22 Feb 2021 14:19:49 +0800 Subject: [PATCH 08/10] Update battery saver switch string Bug: 180749420 Test: Test: make RunSettingsRoboTests -j40 Change-Id: Ibd65573a50a9c4f4ab2a055e7bdff6800cf1d873 --- .../batterysaver/BatterySaverButtonPreferenceController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java index 257810c595d..122e13ab05b 100644 --- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java +++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java @@ -88,8 +88,8 @@ public class BatterySaverButtonPreferenceController extends @Override public void displayPreference(PreferenceScreen screen) { super.displayPreference(screen); - mPreference = (MainSwitchPreference) screen.findPreference(getPreferenceKey()); - mPreference.setTitle(mContext.getString(R.string.battery_saver_main_switch_title)); + mPreference = screen.findPreference(getPreferenceKey()); + mPreference.setTitle(mContext.getString(R.string.battery_saver_master_switch_title)); mPreference.addOnSwitchChangeListener(this); mPreference.updateStatus(isChecked()); } From f3b21931a5e4329ecd1475e30df930ebbdabfa8d Mon Sep 17 00:00:00 2001 From: SongFerngWang Date: Fri, 19 Feb 2021 20:57:30 +0800 Subject: [PATCH 09/10] EnabledNetworkModePreferenceController redo Init after sim activate Failed to get RadioAccessFamily information from TelephonyManager.getSupportedRadioAccessFamily due to SIM inactivated Bug: 180360457 Test: atest EnabledNetworkModePreferenceControllerTest Change-Id: Icfce6c319e9a84318c9496125718cd60dda6afbb --- ...nabledNetworkModePreferenceController.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java index 9e7a3a8b2a5..5680bf60140 100644 --- a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java +++ b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java @@ -35,6 +35,7 @@ import androidx.preference.PreferenceScreen; import com.android.settings.R; import com.android.settings.network.AllowedNetworkTypesListener; +import com.android.settings.network.SubscriptionsChangeListener; import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants; import java.util.ArrayList; @@ -47,7 +48,8 @@ import java.util.stream.Stream; */ public class EnabledNetworkModePreferenceController extends TelephonyBasePreferenceController implements - ListPreference.OnPreferenceChangeListener, LifecycleObserver { + ListPreference.OnPreferenceChangeListener, LifecycleObserver, + SubscriptionsChangeListener.SubscriptionsChangeListenerClient { private static final String LOG_TAG = "EnabledNetworkMode"; private AllowedNetworkTypesListener mAllowedNetworkTypesListener; @@ -56,9 +58,11 @@ public class EnabledNetworkModePreferenceController extends private TelephonyManager mTelephonyManager; private CarrierConfigManager mCarrierConfigManager; private PreferenceEntriesBuilder mBuilder; + private SubscriptionsChangeListener mSubscriptionsListener; public EnabledNetworkModePreferenceController(Context context, String key) { super(context, key); + mSubscriptionsListener = new SubscriptionsChangeListener(context, this); } @Override @@ -85,6 +89,7 @@ public class EnabledNetworkModePreferenceController extends @OnLifecycleEvent(ON_START) public void onStart() { + mSubscriptionsListener.start(); if (mAllowedNetworkTypesListener == null) { return; } @@ -93,6 +98,7 @@ public class EnabledNetworkModePreferenceController extends @OnLifecycleEvent(ON_STOP) public void onStop() { + mSubscriptionsListener.stop(); if (mAllowedNetworkTypesListener == null) { return; } @@ -196,11 +202,14 @@ public class EnabledNetworkModePreferenceController extends PreferenceEntriesBuilder(Context context, int subId) { this.mContext = context; this.mSubId = subId; - mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class); mTelephonyManager = mContext.getSystemService(TelephonyManager.class) .createForSubscriptionId(mSubId); + updateConfig(); + } + public void updateConfig() { + mTelephonyManager = mTelephonyManager.createForSubscriptionId(mSubId); final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId); mAllowed5gNetworkType = checkSupportedRadioBitmask( mTelephonyManager.getAllowedNetworkTypesForReason( @@ -214,6 +223,11 @@ public class EnabledNetworkModePreferenceController extends && carrierConfig.getBoolean(CarrierConfigManager.KEY_SHOW_CDMA_CHOICES_BOOL); mShow4gForLTE = carrierConfig != null && carrierConfig.getBoolean( CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL); + Log.d(LOG_TAG, "PreferenceEntriesBuilder: subId" + mSubId + + ",Supported5gRadioAccessFamily :" + mSupported5gRadioAccessFamily + + ",mAllowed5gNetworkType :" + mAllowed5gNetworkType + + ",IsGlobalCdma :" + mIsGlobalCdma + + ",Show4gForLTE :" + mShow4gForLTE); } void setPreferenceEntries() { @@ -818,4 +832,13 @@ public class EnabledNetworkModePreferenceController extends } } + + @Override + public void onAirplaneModeChanged(boolean airplaneModeEnabled) { + } + + @Override + public void onSubscriptionsChanged() { + mBuilder.updateConfig(); + } } From ef851e84ed8e0c13545573a6e6700f598e0af3d5 Mon Sep 17 00:00:00 2001 From: Yi Jiang Date: Mon, 22 Feb 2021 00:59:11 -0800 Subject: [PATCH 10/10] Promotes screen timeout setting. This change puts the screen timeout setting before the 'advanced' tab in Settings->Display. Test: manual Bug: 180759324 Change-Id: I32081fa289be5b9c2bb1cc5089161ad70386ed39 --- res/xml/display_settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml index 8df5696a0c4..27bf0ba206f 100644 --- a/res/xml/display_settings.xml +++ b/res/xml/display_settings.xml @@ -20,7 +20,7 @@ android:key="display_settings_screen" android:title="@string/display_settings" settings:keywords="@string/keywords_display" - settings:initialExpandedChildrenCount="5"> + settings:initialExpandedChildrenCount="6">