From 9534a05eeb9b6fd85cd64e6240c1be4469132a88 Mon Sep 17 00:00:00 2001 From: Jakub Rotkiewicz Date: Wed, 21 Aug 2024 09:35:49 +0000 Subject: [PATCH 1/4] bluetooth: remove debug logs guard Bug: 329809288 Flag: EXEMPT - log only Test: mmm packages/apps/Settings Change-Id: Ia1626aa6904c90729de518102aedbab226a25692 --- ...ractBluetoothListPreferenceController.java | 23 +++++------- ...luetoothCodecListPreferenceController.java | 35 ++++++------------- 2 files changed, 19 insertions(+), 39 deletions(-) diff --git a/src/com/android/settings/development/bluetooth/AbstractBluetoothListPreferenceController.java b/src/com/android/settings/development/bluetooth/AbstractBluetoothListPreferenceController.java index 9436e06bee5..362a5cdde99 100644 --- a/src/com/android/settings/development/bluetooth/AbstractBluetoothListPreferenceController.java +++ b/src/com/android/settings/development/bluetooth/AbstractBluetoothListPreferenceController.java @@ -43,7 +43,6 @@ public abstract class AbstractBluetoothListPreferenceController implements Preference.OnPreferenceChangeListener { private static final String TAG = "AbstrBtListPrefCtrl"; - private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); protected static final int DEFAULT_VALUE_INT = 1000; @@ -74,9 +73,7 @@ public abstract class AbstractBluetoothListPreferenceController @Override public boolean onPreferenceChange(@Nullable Preference preference, @NonNull Object newValue) { - if (DEBUG) { - Log.d(TAG, "onPreferenceChange: newValue=" + (String) newValue); - } + Log.d(TAG, "onPreferenceChange: newValue=" + (String) newValue); if (mListPreference == null) { Log.e(TAG, "onPreferenceChange: List preference is null"); return false; @@ -99,9 +96,7 @@ public abstract class AbstractBluetoothListPreferenceController @Override protected void onDeveloperOptionsSwitchDisabled() { super.onDeveloperOptionsSwitchDisabled(); - if (DEBUG) { - Log.d(TAG, "onDeveloperOptionsSwitchDisabled"); - } + Log.d(TAG, "onDeveloperOptionsSwitchDisabled"); if (mListPreference == null) { Log.e(TAG, "onDeveloperOptionsSwitchDisabled: List preference is null"); return; @@ -230,14 +225,12 @@ public abstract class AbstractBluetoothListPreferenceController } private void setupDefaultListPreference() { - if (DEBUG) { - Log.d( - TAG, - "setupDefaultListPreference: mDefaultEntry=" - + mDefaultEntry - + ", mDefaultValue=" - + mDefaultValue); - } + Log.d( + TAG, + "setupDefaultListPreference: mDefaultEntry=" + + mDefaultEntry + + ", mDefaultValue=" + + mDefaultValue); if (mListPreference == null) { Log.e(TAG, "setupListPreference: List preference is null"); return; diff --git a/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceController.java b/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceController.java index 863cd2795c4..9808807b077 100644 --- a/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceController.java +++ b/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceController.java @@ -43,7 +43,6 @@ public class BluetoothCodecListPreferenceController private static final String KEY = "bluetooth_audio_codec_settings_list"; private static final String TAG = "BtExtCodecCtr"; - private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); @Nullable private final Callback mCallback; @@ -59,9 +58,7 @@ public class BluetoothCodecListPreferenceController @Override public boolean isAvailable() { boolean available = Flags.a2dpOffloadCodecExtensibilitySettings(); - if (DEBUG) { - Log.d(TAG, "isAvailable: " + available); - } + Log.d(TAG, "isAvailable: " + available); return available; } @@ -82,9 +79,7 @@ public class BluetoothCodecListPreferenceController return false; } - if (DEBUG) { - Log.d(TAG, "onPreferenceChange: newValue=" + (String) newValue); - } + Log.d(TAG, "onPreferenceChange: newValue=" + (String) newValue); final BluetoothA2dp bluetoothA2dp = mBluetoothA2dp; if (bluetoothA2dp == null) { Log.e(TAG, "onPreferenceChange: bluetoothA2dp is null"); @@ -110,9 +105,7 @@ public class BluetoothCodecListPreferenceController return false; } - if (DEBUG) { - Log.d(TAG, "onPreferenceChange: setCodecConfigPreference: " + codecConfig.toString()); - } + Log.d(TAG, "onPreferenceChange: setCodecConfigPreference: " + codecConfig.toString()); bluetoothA2dp.setCodecConfigPreference(activeDevice, codecConfig); if (mCallback != null) { mCallback.onBluetoothCodecChanged(); @@ -161,14 +154,12 @@ public class BluetoothCodecListPreferenceController && currentCodecConfig.getExtendedCodecType().equals(codecType)) { selectedCodecId = codecIds.get(codecIds.size() - 1); selectedLabel = labels.get(labels.size() - 1); - if (DEBUG) { - Log.d( - TAG, - "updateState: Current config: " - + selectedLabel - + ", id: " - + selectedCodecId); - } + Log.d( + TAG, + "updateState: Current config: " + + selectedLabel + + ", id: " + + selectedCodecId); } } @@ -178,9 +169,7 @@ public class BluetoothCodecListPreferenceController @Override public void onHDAudioEnabled(boolean enabled) { - if (DEBUG) { - Log.d(TAG, "onHDAudioEnabled: enabled=" + enabled); - } + Log.d(TAG, "onHDAudioEnabled: enabled=" + enabled); if (mListPreference == null) { Log.e(TAG, "onHDAudioEnabled: List preference is null"); return; @@ -216,9 +205,7 @@ public class BluetoothCodecListPreferenceController return; } - if (DEBUG) { - Log.d(TAG, "writeConfigurationValues: Selected codec: " + selectedCodecType.toString()); - } + Log.d(TAG, "writeConfigurationValues: Selected codec: " + selectedCodecType.toString()); final BluetoothCodecStatus codecStatus = getBluetoothCodecStatus(); if (codecStatus == null) { Log.e(TAG, "writeConfigurationValues: Bluetooth Codec Status is null"); From 29f56b0b544d3f330656f9df59ecd9606ab8acc6 Mon Sep 17 00:00:00 2001 From: Chaohui Wang Date: Thu, 22 Aug 2024 12:09:32 +0800 Subject: [PATCH 2/4] Clean up EuiccPreferenceController Bug: 356684993 Flag: EXEMPT clean up Test: manual - on mobile settings Change-Id: I44856cf82f97c69d74dd2c8ba6e0c815498a7520 --- .../telephony/EuiccPreferenceController.java | 70 ----------------- .../EuiccPreferenceControllerTest.java | 75 ------------------- 2 files changed, 145 deletions(-) delete mode 100644 src/com/android/settings/network/telephony/EuiccPreferenceController.java delete mode 100644 tests/unit/src/com/android/settings/network/telephony/EuiccPreferenceControllerTest.java diff --git a/src/com/android/settings/network/telephony/EuiccPreferenceController.java b/src/com/android/settings/network/telephony/EuiccPreferenceController.java deleted file mode 100644 index 50523792e6a..00000000000 --- a/src/com/android/settings/network/telephony/EuiccPreferenceController.java +++ /dev/null @@ -1,70 +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 android.content.Context; -import android.content.Intent; -import android.telephony.TelephonyManager; -import android.telephony.euicc.EuiccManager; -import android.text.TextUtils; - -import androidx.preference.Preference; - -import com.android.settings.Utils; - -/** - * Preference controller for "Euicc preference" - */ -public class EuiccPreferenceController extends TelephonyBasePreferenceController { - - private TelephonyManager mTelephonyManager; - - public EuiccPreferenceController(Context context, String key) { - super(context, key); - mTelephonyManager = context.getSystemService(TelephonyManager.class); - } - - @Override - public int getAvailabilityStatus(int subId) { - return MobileNetworkUtils.showEuiccSettings(mContext) - ? AVAILABLE - : CONDITIONALLY_UNAVAILABLE; - } - - @Override - public CharSequence getSummary() { - return mTelephonyManager.getSimOperatorName(); - } - - public void init(int subId) { - mSubId = subId; - mTelephonyManager = mContext.getSystemService(TelephonyManager.class) - .createForSubscriptionId(mSubId); - } - - @Override - public boolean handlePreferenceTreeClick(Preference preference) { - if (TextUtils.equals(preference.getKey(), getPreferenceKey())) { - Intent intent = new Intent(EuiccManager.ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS) - .setPackage(Utils.PHONE_PACKAGE_NAME); - mContext.startActivity(intent); - return true; - } - - return false; - } -} diff --git a/tests/unit/src/com/android/settings/network/telephony/EuiccPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/EuiccPreferenceControllerTest.java deleted file mode 100644 index ccc12e369d9..00000000000 --- a/tests/unit/src/com/android/settings/network/telephony/EuiccPreferenceControllerTest.java +++ /dev/null @@ -1,75 +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.network.telephony; - -import static com.google.common.truth.Truth.assertThat; - -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import android.content.Context; -import android.content.Intent; -import android.telephony.TelephonyManager; -import android.telephony.euicc.EuiccManager; - -import androidx.preference.Preference; -import androidx.test.core.app.ApplicationProvider; -import androidx.test.ext.junit.runners.AndroidJUnit4; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -@RunWith(AndroidJUnit4.class) -public class EuiccPreferenceControllerTest { - private static final int SUB_ID = 2; - - @Mock private TelephonyManager mTelephonyManager; - - private EuiccPreferenceController mController; - private Preference mPreference; - private Context mContext; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - - mContext = spy(ApplicationProvider.getApplicationContext()); - when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager); - when(mTelephonyManager.createForSubscriptionId(SUB_ID)).thenReturn(mTelephonyManager); - - mPreference = new Preference(mContext); - mController = new EuiccPreferenceController(mContext, "euicc"); - mController.init(SUB_ID); - mPreference.setKey(mController.getPreferenceKey()); - } - - @Test - public void handlePreferenceTreeClick_startActivity() { - ArgumentCaptor captor = ArgumentCaptor.forClass(Intent.class); - doNothing().when(mContext).startActivity(captor.capture()); - - mController.handlePreferenceTreeClick(mPreference); - - assertThat(captor.getValue().getAction()).isEqualTo( - EuiccManager.ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS); - } -} From b6be744bc63de09bdd286ffb24dddd37200e3fb2 Mon Sep 17 00:00:00 2001 From: songferngwang Date: Fri, 23 Aug 2024 09:24:21 +0000 Subject: [PATCH 3/4] Modify the preferredSimDialogFragment After the telephony flag resetPrimarySimDefaultValues on, the telephony set the preferred default subscription to remaining sim. Therefore, here can ask whether the user uses [remaining SIM] for mobile data or not Bug: 349783684 Test: remove the sim card, and settings show "use mobile data" dialog Flag: EXEMPT bugfix Change-Id: I5e3399e777bf1e8ef7998074082e55635eb23eb4 --- res/values/strings.xml | 7 +++---- .../sim/PreferredSimDialogFragment.java | 17 ++++++++++++----- .../android/settings/sim/SimDialogActivity.java | 3 +-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 42bbe27d4b7..9de6f9abeda 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -3058,10 +3058,9 @@ Use %1$s - - Update preferred SIM? + - %1$s is the only SIM in your device. Do you want to use this SIM for mobile data, calls, and SMS messages? + %1$s is now your primary SIM Improve mobile data coverage? @@ -7563,7 +7562,7 @@ Select a SIM for SMS Switching data SIM, this may take up to a minute\u2026 - + Use %1$s for mobile data? If you switch to %1$s, %2$s will no longer be used for mobile data. diff --git a/src/com/android/settings/sim/PreferredSimDialogFragment.java b/src/com/android/settings/sim/PreferredSimDialogFragment.java index bb694406a28..96c0eb61a75 100644 --- a/src/com/android/settings/sim/PreferredSimDialogFragment.java +++ b/src/com/android/settings/sim/PreferredSimDialogFragment.java @@ -37,8 +37,8 @@ import com.android.settings.R; import com.android.settings.network.SubscriptionUtil; /** - * Presents a dialog asking the user if they want to update all services to use a given "preferred" - * SIM. Typically this would be used in a case where a device goes from having multiple SIMs down to + * After androidV, presents a dialog asking the user if they want to update the mobile data. + * Typically this would be used in a case where a device goes from having multiple SIMs down to * only one. */ public class PreferredSimDialogFragment extends SimDialogFragment implements @@ -48,7 +48,7 @@ public class PreferredSimDialogFragment extends SimDialogFragment implements public static PreferredSimDialogFragment newInstance() { final PreferredSimDialogFragment fragment = new PreferredSimDialogFragment(); final Bundle args = initArguments(SimDialogActivity.PREFERRED_PICK, - R.string.sim_preferred_title); + R.string.select_specific_sim_for_data_title); fragment.setArguments(args); return fragment; } @@ -57,7 +57,6 @@ public class PreferredSimDialogFragment extends SimDialogFragment implements @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { final AlertDialog dialog = new AlertDialog.Builder(getContext()) - .setTitle(getTitleResId()) .setPositiveButton(R.string.yes, this) .setNegativeButton(R.string.no, null) .create(); @@ -104,10 +103,18 @@ public class PreferredSimDialogFragment extends SimDialogFragment implements dismiss(); return; } + Log.d(TAG, "SubscriptionInfo: " + info); + final CharSequence simName = + SubscriptionUtil.getUniqueSubscriptionDisplayName(info, getContext()); + final String title = + getContext().getString( + getTitleResId(), + simName); final String message = getContext().getString( R.string.sim_preferred_message, - SubscriptionUtil.getUniqueSubscriptionDisplayName(info, getContext())); + simName); + dialog.setTitle(title); dialog.setMessage(message); } diff --git a/src/com/android/settings/sim/SimDialogActivity.java b/src/com/android/settings/sim/SimDialogActivity.java index 2e19641af12..5512117f733 100644 --- a/src/com/android/settings/sim/SimDialogActivity.java +++ b/src/com/android/settings/sim/SimDialogActivity.java @@ -122,6 +122,7 @@ public class SimDialogActivity extends FragmentActivity { private void showOrUpdateDialog() { final int dialogType = getIntent().getIntExtra(DIALOG_TYPE_KEY, INVALID_PICK); + Log.d(TAG, "dialogType:" + dialogType); if (dialogType == PICK_DISMISS) { finishAndRemoveTask(); @@ -379,8 +380,6 @@ public class SimDialogActivity extends FragmentActivity { private void setPreferredSim(final int subId) { setDefaultDataSubId(subId); - setDefaultSmsSubId(subId); - setDefaultCallsSubId(subId); } private PhoneAccountHandle subscriptionIdToPhoneAccountHandle(final int subId) { From a21fbfa6121510798f0fa845853d87298a870f8b Mon Sep 17 00:00:00 2001 From: Weng Su Date: Fri, 23 Aug 2024 17:41:10 +0800 Subject: [PATCH 4/4] Refine WifiDetailsSettingsActivity - Use the parameter's intent to avoid re-creating it in getIntent() Bug: 349180072 Flag: EXEMPT bugfix Test: Manual testing Change-Id: Ia3549eccf22e30c4fd1ae011c51cf7840c76b1e5 --- src/com/android/settings/Settings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java index 8321588fd12..493a27b6f26 100644 --- a/src/com/android/settings/Settings.java +++ b/src/com/android/settings/Settings.java @@ -79,7 +79,7 @@ public class Settings extends SettingsActivity { public static class WifiDetailsSettingsActivity extends SettingsActivity { @Override protected void createUiFromIntent(@Nullable Bundle savedState, Intent intent) { - Bundle bundle = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS); + Bundle bundle = intent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS); if (TextUtils.isEmpty(bundle.getString(WifiUtils.KEY_CHOSEN_WIFIENTRY_KEY))) { Log.e(getLocalClassName(), "The key of WifiEntry is empty!"); finishAndRemoveTask();