diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-11-03 18:08:28 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-11-03 18:08:28 +0000 |
commit | 325f77fdfcd67dfc3154083f6d5614240137f135 (patch) | |
tree | 8c2372a067645cb9231a4979682601b7c54db703 | |
parent | 1a720d4dffda99e2ffb2b6048d0917717de5dfe0 (diff) | |
parent | cf77b59c08706912ff6c18f9bc26420e4feadf17 (diff) | |
download | sl4a-325f77fdfcd67dfc3154083f6d5614240137f135.tar.gz |
Snap for 6948038 from cf77b59c08706912ff6c18f9bc26420e4feadf17 to rvc-platform-releaseandroid-platform-11.0.0_r9android-platform-11.0.0_r8android-platform-11.0.0_r7android-platform-11.0.0_r6android-platform-11.0.0_r5android-platform-11.0.0_r40android-platform-11.0.0_r4android-platform-11.0.0_r39android-platform-11.0.0_r38android-platform-11.0.0_r37android-platform-11.0.0_r36android-platform-11.0.0_r35android-platform-11.0.0_r34android-platform-11.0.0_r33android-platform-11.0.0_r32android-platform-11.0.0_r31android-platform-11.0.0_r30android-platform-11.0.0_r3android-platform-11.0.0_r29android-platform-11.0.0_r28android-platform-11.0.0_r27android-platform-11.0.0_r26android-platform-11.0.0_r25android-platform-11.0.0_r24android-platform-11.0.0_r23android-platform-11.0.0_r22android-platform-11.0.0_r21android-platform-11.0.0_r20android-platform-11.0.0_r19android-platform-11.0.0_r18android-platform-11.0.0_r17android-platform-11.0.0_r16android-platform-11.0.0_r15android-platform-11.0.0_r14android-platform-11.0.0_r13android-platform-11.0.0_r12android-platform-11.0.0_r11android-platform-11.0.0_r10android11-platform-release
Change-Id: I76e0425ae79e846ac148fd63206e7ddcb17e5b9b
5 files changed, 231 insertions, 0 deletions
diff --git a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyConstants.java b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyConstants.java index ecbec0dd..1c83e273 100644 --- a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyConstants.java +++ b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyConstants.java @@ -228,6 +228,15 @@ public class TelephonyConstants { public static final String DATA_STATE_UNKNOWN = "UNKNOWN"; /** + * Constant for Override Network Type + * **/ + public static final String OVERRIDE_NETWORK_TYPE_NONE = "NONE"; + public static final String OVERRIDE_NETWORK_TYPE_LTE_CA = "LTE_CA"; + public static final String OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO = "LTE_ADVANCED_PRO"; + public static final String OVERRIDE_NETWORK_TYPE_NR_NSA = "NR_NSA"; + public static final String OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE = "NR_MMWAVE"; + + /** * Constant for Telephony Manager Call State * **/ public static final String TELEPHONY_STATE_RINGING = "RINGING"; @@ -317,6 +326,17 @@ public class TelephonyConstants { public static final String NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA = "NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA"; public static final String NETWORK_MODE_TDSCDMA_CDMA_EVDO_GSM_WCDMA = "NETWORK_MODE_TDSCDMA_CDMA_EVDO_GSM_WCDMA"; public static final String NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA = "NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA"; + public static final String NETWORK_MODE_NR_LTE_GSM_WCDMA = "NETWORK_MODE_NR_LTE_GSM_WCDMA"; + public static final String NETWORK_MODE_NR_ONLY = "NETWORK_MODE_NR_ONLY"; + public static final String NETWORK_MODE_NR_LTE = "NETWORK_MODE_NR_LTE"; + public static final String NETWORK_MODE_NR_LTE_CDMA_EVDO = "NETWORK_MODE_NR_LTE_CDMA_EVDO"; + public static final String NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA = "NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA"; + public static final String NETWORK_MODE_NR_LTE_WCDMA = "NETWORK_MODE_NR_LTE_WCDMA"; + public static final String NETWORK_MODE_NR_LTE_TDSCDMA = "NETWORK_MODE_NR_LTE_TDSCDMA"; + public static final String NETWORK_MODE_NR_LTE_TDSCDMA_GSM = "NETWORK_MODE_NR_LTE_TDSCDMA_GSM"; + public static final String NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA = "NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA"; + public static final String NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA = "NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA"; + public static final String NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA = "NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA"; public static final String NETWORK_MODE_INVALID = "INVALID"; /** @@ -373,6 +393,7 @@ public class TelephonyConstants { public static final String EventPreciseStateChanged = "PreciseStateChanged"; public static final String EventDataConnectionRealTimeInfoChanged = "DataConnectionRealTimeInfoChanged"; public static final String EventDataConnectionStateChanged = "DataConnectionStateChanged"; + public static final String EventDisplayInfoChanged = "DisplayInfoChanged"; public static final String EventActiveDataSubIdChanged = "ActiveDataSubIdChanged"; public static final String EventServiceStateChanged = "ServiceStateChanged"; public static final String EventSignalStrengthChanged = "SignalStrengthChanged"; @@ -438,6 +459,13 @@ public class TelephonyConstants { public static final String DATA_CONNECTION_STATE = "dataConnectionState"; } + public static class DisplayInfoContainer { + public static final String TIME = "time"; + public static final String NETWORK = "network"; + public static final String OVERRIDE = "override"; + public static final String SUBSCRIPTION_ID = "subscriptionId"; + } + public static class ServiceStateContainer { public static final String VOICE_REG_STATE = "voiceRegState"; public static final String VOICE_NETWORK_TYPE = "voiceNetworkType"; diff --git a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyEvents.java b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyEvents.java index 7021475a..04f80418 100644 --- a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyEvents.java +++ b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyEvents.java @@ -20,6 +20,7 @@ import android.telephony.DataConnectionRealTimeInfo; import android.telephony.PhysicalChannelConfig; import android.telephony.PreciseCallState; import android.telephony.ServiceState; +import android.telephony.TelephonyDisplayInfo; import com.googlecode.android_scripting.jsonrpc.JsonSerializable; @@ -267,6 +268,52 @@ public class TelephonyEvents { } } + public static class DisplayInfoChangedEvent implements JsonSerializable { + private TelephonyDisplayInfo mDisplayInfoString; + private int mSubscriptionId; + private String mOverrideDataNetworkType; + private String mDataNetworkType; + + DisplayInfoChangedEvent(TelephonyDisplayInfo DisplayInfoString, int subscriptionId) { + mDisplayInfoString = DisplayInfoString; + mSubscriptionId = subscriptionId; + mOverrideDataNetworkType = TelephonyUtils.getDisplayInfoString( + DisplayInfoString.getOverrideNetworkType()); + mDataNetworkType = TelephonyUtils.getNetworkTypeString( + DisplayInfoString.getNetworkType()); + } + + public String getOverrideDataNetworkType() { + return mOverrideDataNetworkType; + } + + public int getSubscriptionId() { + return mSubscriptionId; + } + + public String getDataNetworkType() { + return mDataNetworkType; + } + + public JSONObject toJSON() throws JSONException { + JSONObject displayInfoState = new JSONObject(); + + displayInfoState.put( + TelephonyConstants.DisplayInfoContainer.OVERRIDE, + mOverrideDataNetworkType); + + displayInfoState.put( + TelephonyConstants.DisplayInfoContainer.NETWORK, + mDataNetworkType); + + displayInfoState.put( + TelephonyConstants.DisplayInfoContainer.SUBSCRIPTION_ID, + mSubscriptionId); + + return displayInfoState; + } + } + public static class PhysicalChannelConfigChangedEvent implements JsonSerializable { private final List<PhysicalChannelConfig> mConfigs; diff --git a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java index a338402b..a7988aa0 100644 --- a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java +++ b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java @@ -55,6 +55,8 @@ import com.googlecode.android_scripting.facade.telephony.TelephonyStateListeners import com.googlecode.android_scripting.facade.telephony.TelephonyStateListeners .DataConnectionStateChangeListener; import com.googlecode.android_scripting.facade.telephony.TelephonyStateListeners + .DisplayInfoStateChangeListener; +import com.googlecode.android_scripting.facade.telephony.TelephonyStateListeners .ServiceStateChangeListener; import com.googlecode.android_scripting.facade.telephony.TelephonyStateListeners .SignalStrengthChangeListener; @@ -303,6 +305,28 @@ public class TelephonyManagerFacade extends RpcReceiver { return true; } + @Rpc(description = "Starts tracking display info change" + + "for default subscription ID.") + public Boolean telephonyStartTrackingDisplayInfoChange() { + return telephonyStartTrackingDisplayInfoChangeForSubscription( + SubscriptionManager.DEFAULT_SUBSCRIPTION_ID); + } + + @Rpc(description = "Starts tracking display info change" + + "for specified subscription ID.") + public Boolean telephonyStartTrackingDisplayInfoChangeForSubscription( + @RpcParameter(name = "subId") Integer subId) { + StateChangeListener listener = getStateChangeListenerForSubscription(subId, true); + if(listener == null) { + Log.e("Invalid subscription ID"); + return false; + } + mTelephonyManager.createForSubscriptionId(subId).listen( + listener.mDisplayInfoStateChangeListener, + PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED); + return true; + } + @Rpc(description = "Turn on/off precise listening on fore/background or" + " ringing calls for default voice subscription ID.") public Boolean telephonyAdjustPreciseCallStateListenLevel( @@ -381,6 +405,28 @@ public class TelephonyManagerFacade extends RpcReceiver { return true; } + @Rpc(description = "Stops tracking display info change " + + "for default subscription ID.") + public Boolean telephonyStopTrackingDisplayInfoChange() { + return telephonyStopTrackingDisplayInfoChangeForSubscription( + SubscriptionManager.DEFAULT_SUBSCRIPTION_ID); + } + + @Rpc(description = "Stops tracking display info change " + + "for specified subscription ID.") + public Boolean telephonyStopTrackingDisplayInfoChangeForSubscription( + @RpcParameter(name = "subId") Integer subId) { + StateChangeListener listener = getStateChangeListenerForSubscription(subId, false); + if(listener == null) { + Log.e("Invalid subscription ID"); + return false; + } + mTelephonyManager.createForSubscriptionId(subId).listen( + listener.mDisplayInfoStateChangeListener, + PhoneStateListener.LISTEN_NONE); + return true; + } + @Rpc(description = "Stops tracking call state change " + "for default voice subscription ID.") public Boolean telephonyStopTrackingCallStateChange() { @@ -1506,6 +1552,7 @@ public class TelephonyManagerFacade extends RpcReceiver { public CellInfoChangeListener mCellInfoChangeListener; public DataConnectionStateChangeListener mDataConnectionStateChangeListener; public ActiveDataSubIdChangeListener mActiveDataSubIdChangeListener; + public DisplayInfoStateChangeListener mDisplayInfoStateChangeListener; public DataConnectionRealTimeInfoChangeListener mDataConnectionRTInfoChangeListener; public VoiceMailStateChangeListener mVoiceMailStateChangeListener; @@ -1520,6 +1567,9 @@ public class TelephonyManagerFacade extends RpcReceiver { mActiveDataSubIdChangeListener = new ActiveDataSubIdChangeListener( mEventFacade, mTelephonyManager, subId, mService.getMainLooper()); + mDisplayInfoStateChangeListener = + new DisplayInfoStateChangeListener( + mEventFacade, mTelephonyManager, subId, mService.getMainLooper()); mCallStateChangeListener = new CallStateChangeListener(mEventFacade, subId, mService.getMainLooper()); mCellInfoChangeListener = @@ -1545,6 +1595,9 @@ public class TelephonyManagerFacade extends RpcReceiver { mActiveDataSubIdChangeListener, PhoneStateListener.LISTEN_NONE); mTelephonyManager.listen( + mDisplayInfoStateChangeListener, + PhoneStateListener.LISTEN_NONE); + mTelephonyManager.listen( mCellInfoChangeListener, PhoneStateListener.LISTEN_NONE); mTelephonyManager.listen( diff --git a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyStateListeners.java b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyStateListeners.java index e06af17a..b13b66cd 100644 --- a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyStateListeners.java +++ b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyStateListeners.java @@ -24,6 +24,7 @@ import android.telephony.PreciseCallState; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.SubscriptionManager; +import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import com.googlecode.android_scripting.facade.EventFacade; @@ -217,6 +218,45 @@ public class TelephonyStateListeners { } } + public static class DisplayInfoStateChangeListener extends PhoneStateListener { + + private final EventFacade mEventFacade; + private final TelephonyManager mTelephonyManager; + public static final int sListeningStates = + PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED; + public int subscriptionId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; + + public DisplayInfoStateChangeListener(EventFacade ef, TelephonyManager tm) { + super(); + mEventFacade = ef; + mTelephonyManager = tm; + subscriptionId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID; + } + + public DisplayInfoStateChangeListener(EventFacade ef, TelephonyManager tm, int subId) { + super(); + mEventFacade = ef; + mTelephonyManager = tm; + subscriptionId = subId; + } + + public DisplayInfoStateChangeListener( + EventFacade ef, TelephonyManager tm, int subId, Looper looper) { + super(looper); + mEventFacade = ef; + mTelephonyManager = tm; + subscriptionId = subId; + } + + @Override + public void onDisplayInfoChanged(TelephonyDisplayInfo mTelephonyDisplayInfo) { + mEventFacade.postEvent( + TelephonyConstants.EventDisplayInfoChanged, + new TelephonyEvents.DisplayInfoChangedEvent( + mTelephonyDisplayInfo, subscriptionId)); + } + } + public static class ServiceStateChangeListener extends PhoneStateListener { private final EventFacade mEventFacade; diff --git a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyUtils.java b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyUtils.java index 3b0b4364..c1556ccb 100644 --- a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyUtils.java +++ b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyUtils.java @@ -18,10 +18,12 @@ package com.googlecode.android_scripting.facade.telephony; import com.android.ims.ImsConfig; import com.android.internal.telephony.RILConstants; import com.googlecode.android_scripting.Log; + import android.telecom.TelecomManager; import android.telephony.DataConnectionRealTimeInfo; import android.telephony.PreciseCallState; import android.telephony.ServiceState; +import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.telephony.VoLteServiceState; @@ -189,6 +191,23 @@ public class TelephonyUtils { return TelephonyConstants.DATA_STATE_UNKNOWN; } + public static String getDisplayInfoString(int state) { + switch (state) { + case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE: + return TelephonyConstants.OVERRIDE_NETWORK_TYPE_NONE; + case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA: + return TelephonyConstants.OVERRIDE_NETWORK_TYPE_LTE_CA; + case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO: + return TelephonyConstants.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO; + case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA: + return TelephonyConstants.OVERRIDE_NETWORK_TYPE_NR_NSA; + case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE: + return TelephonyConstants.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE; + } + Log.d("getDisplayInfoStateString error. int: " + state); + return TelephonyConstants.OVERRIDE_NETWORK_TYPE_NONE; + } + public static int getNetworkModeIntfromString(String networkMode) { switch (networkMode) { case TelephonyConstants.NETWORK_MODE_WCDMA_PREF: @@ -237,6 +256,28 @@ public class TelephonyUtils { return RILConstants.NETWORK_MODE_TDSCDMA_CDMA_EVDO_GSM_WCDMA; case TelephonyConstants.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA: return RILConstants.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA; + case TelephonyConstants.NETWORK_MODE_NR_LTE_GSM_WCDMA: + return RILConstants.NETWORK_MODE_NR_LTE_GSM_WCDMA; + case TelephonyConstants.NETWORK_MODE_NR_ONLY: + return RILConstants.NETWORK_MODE_NR_ONLY; + case TelephonyConstants.NETWORK_MODE_NR_LTE: + return RILConstants.NETWORK_MODE_NR_LTE; + case TelephonyConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO: + return RILConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO; + case TelephonyConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA: + return RILConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA; + case TelephonyConstants.NETWORK_MODE_NR_LTE_WCDMA: + return RILConstants.NETWORK_MODE_NR_LTE_WCDMA; + case TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA: + return RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA; + case TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM: + return RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM; + case TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA: + return RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA; + case TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA: + return RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA; + case TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA: + return RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA; } Log.d("getNetworkModeIntfromString error. String: " + networkMode); return RILConstants.RIL_ERRNO_INVALID_RESPONSE; @@ -290,6 +331,28 @@ public class TelephonyUtils { return TelephonyConstants.NETWORK_MODE_TDSCDMA_CDMA_EVDO_GSM_WCDMA; case RILConstants.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA: return TelephonyConstants.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA; + case RILConstants.NETWORK_MODE_NR_LTE_GSM_WCDMA: + return TelephonyConstants.NETWORK_MODE_NR_LTE_GSM_WCDMA; + case RILConstants.NETWORK_MODE_NR_ONLY: + return TelephonyConstants.NETWORK_MODE_NR_ONLY; + case RILConstants.NETWORK_MODE_NR_LTE: + return TelephonyConstants.NETWORK_MODE_NR_LTE; + case RILConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO: + return TelephonyConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO; + case RILConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA: + return TelephonyConstants.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA; + case RILConstants.NETWORK_MODE_NR_LTE_WCDMA: + return TelephonyConstants.NETWORK_MODE_NR_LTE_WCDMA; + case RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA: + return TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA; + case RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM: + return TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM; + case RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA: + return TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA; + case RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA: + return TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA; + case RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA: + return TelephonyConstants.NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA; } Log.d("getNetworkModeStringfromInt error. Int: " + networkMode); return TelephonyConstants.NETWORK_MODE_INVALID; |