From 6213c3dbd25436dbbff7ac2acfb69732d7b9f04a Mon Sep 17 00:00:00 2001 From: Meng Wang Date: Fri, 6 Dec 2019 10:37:58 -0800 Subject: Remove hidden APIs for callState and dataState. Bug: 140908357 Test: make Merged-In: I008f47447f15ac556c8a88297a8706543e25b3e8 Change-Id: I008f47447f15ac556c8a88297a8706543e25b3e8 --- .../java/com/android/server/TelephonyRegistry.java | 25 +++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index fc34434b57b2..cda5dcaf2bd5 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -70,7 +70,6 @@ import com.android.internal.app.IBatteryStats; import com.android.internal.telephony.IOnSubscriptionsChangedListener; import com.android.internal.telephony.IPhoneStateListener; import com.android.internal.telephony.ITelephonyRegistry; -import com.android.internal.telephony.PhoneConstantConversions; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.TelephonyIntents; import com.android.internal.telephony.TelephonyPermissions; @@ -2252,8 +2251,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { } Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED); - intent.putExtra(PhoneConstants.STATE_KEY, - PhoneConstantConversions.convertCallState(state).toString()); + intent.putExtra(TelephonyManager.EXTRA_STATE, callStateToString(state)); // If a valid subId was specified, we should fire off a subId-specific state // change intent and include the subId. @@ -2286,6 +2284,18 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { android.Manifest.permission.READ_CALL_LOG}); } + /** Converts TelephonyManager#CALL_STATE_* to TelephonyManager#EXTRA_STATE_*. */ + private static String callStateToString(int callState) { + switch (callState) { + case TelephonyManager.CALL_STATE_RINGING: + return TelephonyManager.EXTRA_STATE_RINGING; + case TelephonyManager.CALL_STATE_OFFHOOK: + return TelephonyManager.EXTRA_STATE_OFFHOOK; + default: + return TelephonyManager.EXTRA_STATE_IDLE; + } + } + private void broadcastDataConnectionStateChanged(int state, boolean isDataAllowed, String apn, String apnType, LinkProperties linkProperties, NetworkCapabilities networkCapabilities, @@ -2294,8 +2304,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { // status bar takes care of that after taking into account all of the // required info. Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED); - intent.putExtra(PhoneConstants.STATE_KEY, - PhoneConstantConversions.convertDataState(state).toString()); + intent.putExtra(TelephonyManager.EXTRA_STATE, dataStateToString(state)); if (!isDataAllowed) { intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true); } @@ -2338,7 +2347,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { String apnType, String apn, LinkProperties linkProperties, @DataFailureCause int failCause) { Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED); - intent.putExtra(PhoneConstants.STATE_KEY, state); + intent.putExtra(TelephonyManager.EXTRA_STATE, state); intent.putExtra(PhoneConstants.DATA_NETWORK_TYPE_KEY, networkType); if (apnType != null) intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType); if (apn != null) intent.putExtra(PhoneConstants.DATA_APN_KEY, apn); @@ -2679,11 +2688,11 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { } /** - * Convert data state to string + * Convert TelephonyManager.DATA_* to string. * * @return The data state in string format. */ - private String dataStateToString(@TelephonyManager.DataState int state) { + private static String dataStateToString(int state) { switch (state) { case TelephonyManager.DATA_DISCONNECTED: return "DISCONNECTED"; case TelephonyManager.DATA_CONNECTING: return "CONNECTING"; -- cgit v1.2.3-59-g8ed1b