Account for PhoneMonitor API change

* Needed after:
84a90870aa

Change-Id: Ie6c28388f28b97af273f7c93fc6b5b56b518370a
This commit is contained in:
Chirayu Desai
2019-09-13 03:11:24 +05:30
committed by Bruno Martins
parent b0f5aa9540
commit ec3e5ccaaa
2 changed files with 12 additions and 8 deletions

View File

@@ -50,6 +50,9 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.Looper;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.telephony.PhoneStateListener; import android.telephony.PhoneStateListener;
import android.telephony.ServiceState; import android.telephony.ServiceState;
@@ -102,7 +105,7 @@ public class PhoneMonitor {
private int mSubId = -1; private int mSubId = -1;
public SubscriptionStateTracker(int subId) { public SubscriptionStateTracker(int subId) {
super(subId); super(new HandlerExecutor(new Handler(Looper.myLooper())));
mSubId = subId; mSubId = subId;
} }
@@ -193,7 +196,7 @@ public class PhoneMonitor {
if (mTrackers.indexOfKey(subId) < 0) { if (mTrackers.indexOfKey(subId) < 0) {
SubscriptionStateTracker tracker = new SubscriptionStateTracker(subId); SubscriptionStateTracker tracker = new SubscriptionStateTracker(subId);
mTrackers.put(subId, tracker); mTrackers.put(subId, tracker);
mTelephony.listen(tracker, LISTEN_SERVICE_STATE mTelephony.createForSubscriptionId(subId).listen(tracker, LISTEN_SERVICE_STATE
| LISTEN_SIGNAL_STRENGTHS | LISTEN_SIGNAL_STRENGTHS
| LISTEN_DATA_CONNECTION_STATE); | LISTEN_DATA_CONNECTION_STATE);
} }
@@ -218,11 +221,11 @@ public class PhoneMonitor {
} }
public String getSimOperatorName(int subId) { public String getSimOperatorName(int subId) {
return mTelephony.getSimOperatorName(subId); return mTelephony.createForSubscriptionId(subId).getSimOperatorName();
} }
public String getNetworkOperatorName(int subId) { public String getNetworkOperatorName(int subId) {
return mTelephony.getNetworkOperatorName(subId); return mTelephony.createForSubscriptionId(subId).getNetworkOperatorName();
} }
public ServiceState getServiceStateForSubscriber(int subId) { public ServiceState getServiceStateForSubscriber(int subId) {
@@ -299,7 +302,7 @@ public class PhoneMonitor {
} }
public boolean isGSM(int subId) { public boolean isGSM(int subId) {
return mTelephony.getCurrentPhoneType(subId) == PHONE_TYPE_GSM; return mTelephony.createForSubscriptionId(subId).getCurrentPhoneType() == PHONE_TYPE_GSM;
} }
public boolean isLte(int subId) { public boolean isLte(int subId) {
@@ -307,10 +310,11 @@ public class PhoneMonitor {
} }
public int getLteOnCdmaMode(int subId) { public int getLteOnCdmaMode(int subId) {
if (mTelephony == null || mTelephony.getLteOnCdmaMode(subId) == LTE_ON_CDMA_UNKNOWN) { if (mTelephony == null || mTelephony.createForSubscriptionId(subId).getLteOnCdmaMode()
== LTE_ON_CDMA_UNKNOWN) {
return SystemProperties.getInt("telephony.lteOnCdmaDevice", LTE_ON_CDMA_UNKNOWN); return SystemProperties.getInt("telephony.lteOnCdmaDevice", LTE_ON_CDMA_UNKNOWN);
} }
return mTelephony.getLteOnCdmaMode(subId); return mTelephony.createForSubscriptionId(subId).getLteOnCdmaMode();
} }
private void logPhoneState(String prefix) { private void logPhoneState(String prefix) {

View File

@@ -98,7 +98,7 @@ public class SetupWizardUtils {
android.provider.Settings.Global.putInt(context.getContentResolver(), android.provider.Settings.Global.putInt(context.getContentResolver(),
android.provider.Settings.Global.MOBILE_DATA + phoneId, enabled ? 1 : 0); android.provider.Settings.Global.MOBILE_DATA + phoneId, enabled ? 1 : 0);
int subId = SubscriptionManager.getDefaultDataSubscriptionId(); int subId = SubscriptionManager.getDefaultDataSubscriptionId();
tm.setDataEnabled(subId, enabled); tm.createForSubscriptionId(subId).setDataEnabled(enabled);
} else { } else {
android.provider.Settings.Global.putInt(context.getContentResolver(), android.provider.Settings.Global.putInt(context.getContentResolver(),
android.provider.Settings.Global.MOBILE_DATA, enabled ? 1 : 0); android.provider.Settings.Global.MOBILE_DATA, enabled ? 1 : 0);