Merge "Consolidated all data allow/disallow logic into one method"

This commit is contained in:
Przemyslaw Szczepaniak
2017-05-18 08:58:26 +00:00
committed by Gerrit Code Review
3 changed files with 11 additions and 22 deletions

View File

@@ -154,10 +154,6 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
private int[] mDataConnectionState; private int[] mDataConnectionState;
private boolean[] mDataConnectionPossible;
private String[] mDataConnectionReason;
private String[] mDataConnectionApn; private String[] mDataConnectionApn;
private ArrayList<String>[] mConnectedApns; private ArrayList<String>[] mConnectedApns;
@@ -307,8 +303,6 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
mDataActivationState = new int[numPhones]; mDataActivationState = new int[numPhones];
mSignalStrength = new SignalStrength[numPhones]; mSignalStrength = new SignalStrength[numPhones];
mMessageWaiting = new boolean[numPhones]; mMessageWaiting = new boolean[numPhones];
mDataConnectionPossible = new boolean[numPhones];
mDataConnectionReason = new String[numPhones];
mDataConnectionApn = new String[numPhones]; mDataConnectionApn = new String[numPhones];
mCallForwarding = new boolean[numPhones]; mCallForwarding = new boolean[numPhones];
mCellLocation = new Bundle[numPhones]; mCellLocation = new Bundle[numPhones];
@@ -326,8 +320,6 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
mSignalStrength[i] = new SignalStrength(); mSignalStrength[i] = new SignalStrength();
mMessageWaiting[i] = false; mMessageWaiting[i] = false;
mCallForwarding[i] = false; mCallForwarding[i] = false;
mDataConnectionPossible[i] = false;
mDataConnectionReason[i] = "";
mDataConnectionApn[i] = ""; mDataConnectionApn[i] = "";
mCellLocation[i] = new Bundle(); mCellLocation[i] = new Bundle();
mCellInfo.add(i, null); mCellInfo.add(i, null);
@@ -1081,16 +1073,16 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
} }
public void notifyDataConnection(int state, boolean isDataConnectivityPossible, public void notifyDataConnection(int state, boolean isDataAllowed,
String reason, String apn, String apnType, LinkProperties linkProperties, String reason, String apn, String apnType, LinkProperties linkProperties,
NetworkCapabilities networkCapabilities, int networkType, boolean roaming) { NetworkCapabilities networkCapabilities, int networkType, boolean roaming) {
notifyDataConnectionForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state, notifyDataConnectionForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state,
isDataConnectivityPossible,reason, apn, apnType, linkProperties, isDataAllowed,reason, apn, apnType, linkProperties,
networkCapabilities, networkType, roaming); networkCapabilities, networkType, roaming);
} }
public void notifyDataConnectionForSubscriber(int subId, int state, public void notifyDataConnectionForSubscriber(int subId, int state,
boolean isDataConnectivityPossible, String reason, String apn, String apnType, boolean isDataAllowed, String reason, String apn, String apnType,
LinkProperties linkProperties, NetworkCapabilities networkCapabilities, LinkProperties linkProperties, NetworkCapabilities networkCapabilities,
int networkType, boolean roaming) { int networkType, boolean roaming) {
if (!checkNotifyPermission("notifyDataConnection()" )) { if (!checkNotifyPermission("notifyDataConnection()" )) {
@@ -1098,7 +1090,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
if (VDBG) { if (VDBG) {
log("notifyDataConnectionForSubscriber: subId=" + subId log("notifyDataConnectionForSubscriber: subId=" + subId
+ " state=" + state + " isDataConnectivityPossible=" + isDataConnectivityPossible + " state=" + state + " isDataAllowed=" + isDataAllowed
+ " reason='" + reason + " reason='" + reason
+ "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType
+ " mRecords.size()=" + mRecords.size()); + " mRecords.size()=" + mRecords.size());
@@ -1126,8 +1118,6 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
} }
} }
mDataConnectionPossible[phoneId] = isDataConnectivityPossible;
mDataConnectionReason[phoneId] = reason;
mDataConnectionLinkProperties[phoneId] = linkProperties; mDataConnectionLinkProperties[phoneId] = linkProperties;
mDataConnectionNetworkCapabilities[phoneId] = networkCapabilities; mDataConnectionNetworkCapabilities[phoneId] = networkCapabilities;
if (mDataConnectionNetworkType[phoneId] != networkType) { if (mDataConnectionNetworkType[phoneId] != networkType) {
@@ -1171,7 +1161,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
handleRemoveListLocked(); handleRemoveListLocked();
} }
broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn, broadcastDataConnectionStateChanged(state, isDataAllowed, reason, apn,
apnType, linkProperties, networkCapabilities, roaming, subId); apnType, linkProperties, networkCapabilities, roaming, subId);
broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, reason, broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, reason,
linkProperties, ""); linkProperties, "");
@@ -1412,8 +1402,6 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
pw.println(" mCallForwarding=" + mCallForwarding[i]); pw.println(" mCallForwarding=" + mCallForwarding[i]);
pw.println(" mDataActivity=" + mDataActivity[i]); pw.println(" mDataActivity=" + mDataActivity[i]);
pw.println(" mDataConnectionState=" + mDataConnectionState[i]); pw.println(" mDataConnectionState=" + mDataConnectionState[i]);
pw.println(" mDataConnectionPossible=" + mDataConnectionPossible[i]);
pw.println(" mDataConnectionReason=" + mDataConnectionReason[i]);
pw.println(" mDataConnectionApn=" + mDataConnectionApn[i]); pw.println(" mDataConnectionApn=" + mDataConnectionApn[i]);
pw.println(" mDataConnectionLinkProperties=" + mDataConnectionLinkProperties[i]); pw.println(" mDataConnectionLinkProperties=" + mDataConnectionLinkProperties[i]);
pw.println(" mDataConnectionNetworkCapabilities=" + pw.println(" mDataConnectionNetworkCapabilities=" +
@@ -1521,7 +1509,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
private void broadcastDataConnectionStateChanged(int state, private void broadcastDataConnectionStateChanged(int state,
boolean isDataConnectivityPossible, boolean isDataAllowed,
String reason, String apn, String apnType, LinkProperties linkProperties, String reason, String apn, String apnType, LinkProperties linkProperties,
NetworkCapabilities networkCapabilities, boolean roaming, int subId) { NetworkCapabilities networkCapabilities, boolean roaming, int subId) {
// Note: not reporting to the battery stats service here, because the // Note: not reporting to the battery stats service here, because the
@@ -1530,7 +1518,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED); Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
intent.putExtra(PhoneConstants.STATE_KEY, intent.putExtra(PhoneConstants.STATE_KEY,
PhoneConstantConversions.convertDataState(state).toString()); PhoneConstantConversions.convertDataState(state).toString());
if (!isDataConnectivityPossible) { if (!isDataAllowed) {
intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true); intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true);
} }
if (reason != null) { if (reason != null) {

View File

@@ -5321,9 +5321,10 @@ public class TelephonyManager {
try { try {
ITelephony telephony = getITelephony(); ITelephony telephony = getITelephony();
if (telephony != null) if (telephony != null)
return telephony.isDataConnectivityPossible(); return telephony.isDataConnectivityPossible(getSubId(SubscriptionManager
.getDefaultDataSubscriptionId()));
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#isDataConnectivityPossible", e); Log.e(TAG, "Error calling ITelephony#isDataAllowed", e);
} }
return false; return false;
} }

View File

@@ -371,7 +371,7 @@ interface ITelephony {
/** /**
* Report whether data connectivity is possible. * Report whether data connectivity is possible.
*/ */
boolean isDataConnectivityPossible(); boolean isDataConnectivityPossible(int subId);
Bundle getCellLocation(String callingPkg); Bundle getCellLocation(String callingPkg);