Account for PhoneMonitor API change
* Needed after:
84a90870aa
Change-Id: Ie6c28388f28b97af273f7c93fc6b5b56b518370a
This commit is contained in:
committed by
Bruno Martins
parent
b0f5aa9540
commit
ec3e5ccaaa
@@ -50,6 +50,9 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerExecutor;
|
||||
import android.os.Looper;
|
||||
import android.os.SystemProperties;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.ServiceState;
|
||||
@@ -102,7 +105,7 @@ public class PhoneMonitor {
|
||||
private int mSubId = -1;
|
||||
|
||||
public SubscriptionStateTracker(int subId) {
|
||||
super(subId);
|
||||
super(new HandlerExecutor(new Handler(Looper.myLooper())));
|
||||
mSubId = subId;
|
||||
}
|
||||
|
||||
@@ -193,7 +196,7 @@ public class PhoneMonitor {
|
||||
if (mTrackers.indexOfKey(subId) < 0) {
|
||||
SubscriptionStateTracker tracker = new SubscriptionStateTracker(subId);
|
||||
mTrackers.put(subId, tracker);
|
||||
mTelephony.listen(tracker, LISTEN_SERVICE_STATE
|
||||
mTelephony.createForSubscriptionId(subId).listen(tracker, LISTEN_SERVICE_STATE
|
||||
| LISTEN_SIGNAL_STRENGTHS
|
||||
| LISTEN_DATA_CONNECTION_STATE);
|
||||
}
|
||||
@@ -218,11 +221,11 @@ public class PhoneMonitor {
|
||||
}
|
||||
|
||||
public String getSimOperatorName(int subId) {
|
||||
return mTelephony.getSimOperatorName(subId);
|
||||
return mTelephony.createForSubscriptionId(subId).getSimOperatorName();
|
||||
}
|
||||
|
||||
public String getNetworkOperatorName(int subId) {
|
||||
return mTelephony.getNetworkOperatorName(subId);
|
||||
return mTelephony.createForSubscriptionId(subId).getNetworkOperatorName();
|
||||
}
|
||||
|
||||
public ServiceState getServiceStateForSubscriber(int subId) {
|
||||
@@ -299,7 +302,7 @@ public class PhoneMonitor {
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -307,10 +310,11 @@ public class PhoneMonitor {
|
||||
}
|
||||
|
||||
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 mTelephony.getLteOnCdmaMode(subId);
|
||||
return mTelephony.createForSubscriptionId(subId).getLteOnCdmaMode();
|
||||
}
|
||||
|
||||
private void logPhoneState(String prefix) {
|
||||
|
@@ -98,7 +98,7 @@ public class SetupWizardUtils {
|
||||
android.provider.Settings.Global.putInt(context.getContentResolver(),
|
||||
android.provider.Settings.Global.MOBILE_DATA + phoneId, enabled ? 1 : 0);
|
||||
int subId = SubscriptionManager.getDefaultDataSubscriptionId();
|
||||
tm.setDataEnabled(subId, enabled);
|
||||
tm.createForSubscriptionId(subId).setDataEnabled(enabled);
|
||||
} else {
|
||||
android.provider.Settings.Global.putInt(context.getContentResolver(),
|
||||
android.provider.Settings.Global.MOBILE_DATA, enabled ? 1 : 0);
|
||||
|
Reference in New Issue
Block a user