From daea8be9abd408f39a8b7451bc171cb60f8e6274 Mon Sep 17 00:00:00 2001 From: Nathan Harold Date: Tue, 5 Jun 2018 14:02:35 -0700 Subject: [PATCH] [RadioInfo] Save PreferredNetworkMode to Settings Historically, the debug menu intentionally did not save the preferred network mode once chosen. This causes problems because some settings cause a phone switch which overrides the preferred network mode, which can cause another phone switch and again override the preferred network mode, completely obliterating the requested debug setting. This change will now save the debug menu setting to the system settings, which will prevent the circular changes and loss of setting due to phone switching. However, caching the debug setting to prevent the phone switch logic from overriding the setting has a side effect, which is why it wasn't done historically. If a debug setting of the preferred network mode is set, it will cause the UX of the non-debug network preference screen to change. Thus, someone who uses the debug menu to make changes must be careful to re-set the setting to return to the correct UX of the publicly displayed menu. Bug: 95133265 Test: -manually set preferred network mode using the RadioInfo menu and observed that there is no phone switch when setting CDMA. -confirmed that changing the network mode in RadioInfo will cause UX changes to the public network preference menu. Change-Id: I91f669956a6d02515530855c4617cd0a767d73fa --- src/com/android/settings/RadioInfo.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/com/android/settings/RadioInfo.java b/src/com/android/settings/RadioInfo.java index 170db1695b..5d3afa5ff5 100644 --- a/src/com/android/settings/RadioInfo.java +++ b/src/com/android/settings/RadioInfo.java @@ -17,6 +17,7 @@ package com.android.settings; import static android.net.ConnectivityManager.NetworkCallback; +import static android.provider.Settings.Global.PREFERRED_NETWORK_MODE; import android.app.Activity; import android.app.AlertDialog; @@ -39,6 +40,7 @@ import android.os.AsyncResult; import android.os.Bundle; import android.os.Handler; import android.os.Message; +import android.provider.Settings; import android.telephony.CarrierConfigManager; import android.telephony.CellInfo; import android.telephony.CellInfoCdma; @@ -1489,6 +1491,19 @@ public class RadioInfo extends Activity { if (mPreferredNetworkTypeResult != pos && pos >= 0 && pos <= mPreferredNetworkLabels.length - 2) { mPreferredNetworkTypeResult = pos; + + // TODO: Possibly migrate this to TelephonyManager.setPreferredNetworkType() + // which today still has some issues (mostly that the "set" is conditional + // on a successful modem call, which is not what we want). Instead we always + // want this setting to be set, so that if the radio hiccups and this setting + // is for some reason unsuccessful, future calls to the radio will reflect + // the users's preference which is set here. + final int subId = phone.getSubId(); + if (SubscriptionManager.isUsableSubIdValue(subId)) { + Settings.Global.putInt(phone.getContext().getContentResolver(), + PREFERRED_NETWORK_MODE + subId, mPreferredNetworkTypeResult); + } + log("Calling setPreferredNetworkType(" + mPreferredNetworkTypeResult + ")"); Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE); phone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg); } -- 2.11.0