diff options
| author | 2018-04-25 21:02:35 +0000 | |
|---|---|---|
| committer | 2018-04-25 23:34:50 +0000 | |
| commit | 066e8652983b1b46103c545ef73c0f7f07687670 (patch) | |
| tree | 8a97665a6ca44ec29f003bbd35b1ead38330cb4d | |
| parent | cbfa614f6074040eef2a2368855521c17af1bac0 (diff) | |
Restore the OEM hook implementation and usage
The current plan is to keep the OEM hook implementation in the
framework, this is for legacy device and old device upgrading
(per b/78098059).
For P launching device, the OEM hook service is removed in hal,
so the OEM hook api in framework should return something dummy, and
prevent infinite loop to get service, but these parts should be done
in seperate CLs after this restore CL is merged.
This reverts commit cbfa614f6074040eef2a2368855521c17af1bac0.
Bug: 34344851
Test: pass Treehugger tests; pass cuttlefish test RilE2eTests
Change-Id: I1f2117331a7f846b192c5f956f3841d58cb8154b
6 files changed, 93 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 83fe97697194..60d11d7e6f4b 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -1426,6 +1426,31 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } } + public void notifyOemHookRawEventForSubscriber(int subId, byte[] rawData) { + if (!checkNotifyPermission("notifyOemHookRawEventForSubscriber")) { + return; + } + + synchronized (mRecords) { + for (Record r : mRecords) { + if (VDBG) { + log("notifyOemHookRawEventForSubscriber: r=" + r + " subId=" + subId); + } + if ((r.matchPhoneStateListenerEvent( + PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT)) && + ((r.subId == subId) || + (r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID))) { + try { + r.callback.onOemHookRawEvent(rawData); + } catch (RemoteException ex) { + mRemoveList.add(r.binder); + } + } + } + handleRemoveListLocked(); + } + } + @Override public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " "); @@ -1693,6 +1718,11 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { android.Manifest.permission.READ_PRECISE_PHONE_STATE, null); } + if ((events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) { + mContext.enforceCallingOrSelfPermission( + android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null); + } + return true; } diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java index 0ff29825bfb3..c16701ba0f35 100644 --- a/telephony/java/android/telephony/PhoneStateListener.java +++ b/telephony/java/android/telephony/PhoneStateListener.java @@ -204,6 +204,16 @@ public class PhoneStateListener { public static final int LISTEN_VOLTE_STATE = 0x00004000; /** + * Listen for OEM hook raw event + * + * @see #onOemHookRawEvent + * @hide + * @deprecated OEM needs a vendor-extension hal and their apps should use that instead + */ + @Deprecated + public static final int LISTEN_OEM_HOOK_RAW_EVENT = 0x00008000; + + /** * Listen for carrier network changes indicated by a carrier app. * * @see #onCarrierNetworkRequest @@ -367,6 +377,9 @@ public class PhoneStateListener { case LISTEN_USER_MOBILE_DATA_STATE: PhoneStateListener.this.onUserMobileDataStateChanged((boolean)msg.obj); break; + case LISTEN_OEM_HOOK_RAW_EVENT: + PhoneStateListener.this.onOemHookRawEvent((byte[])msg.obj); + break; case LISTEN_CARRIER_NETWORK_CHANGE: PhoneStateListener.this.onCarrierNetworkChange((boolean)msg.obj); break; @@ -583,6 +596,16 @@ public class PhoneStateListener { } /** + * Callback invoked when OEM hook raw event is received. Requires + * the READ_PRIVILEGED_PHONE_STATE permission. + * @param rawData is the byte array of the OEM hook raw data. + * @hide + */ + public void onOemHookRawEvent(byte[] rawData) { + // default implementation empty + } + + /** * Callback invoked when telephony has received notice from a carrier * app that a network action that could result in connectivity loss * has been requested by an app using @@ -698,6 +721,10 @@ public class PhoneStateListener { send(LISTEN_USER_MOBILE_DATA_STATE, 0, 0, enabled); } + public void onOemHookRawEvent(byte[] rawData) { + send(LISTEN_OEM_HOOK_RAW_EVENT, 0, 0, rawData); + } + public void onCarrierNetworkChange(boolean active) { send(LISTEN_CARRIER_NETWORK_CHANGE, 0, 0, active); } diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index ca8c6d69cfc3..ba39ffd93d73 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -6445,6 +6445,29 @@ public class TelephonyManager { return retVal; } + /** + * Returns the result and response from RIL for oem request + * + * @param oemReq the data is sent to ril. + * @param oemResp the respose data from RIL. + * @return negative value request was not handled or get error + * 0 request was handled succesfully, but no response data + * positive value success, data length of response + * @hide + * @deprecated OEM needs a vendor-extension hal and their apps should use that instead + */ + @Deprecated + public int invokeOemRilRequestRaw(byte[] oemReq, byte[] oemResp) { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.invokeOemRilRequestRaw(oemReq, oemResp); + } catch (RemoteException ex) { + } catch (NullPointerException ex) { + } + return -1; + } + /** @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) diff --git a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl index 1cfe8c2442bd..0d315e5e563e 100644 --- a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl +++ b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl @@ -47,6 +47,7 @@ oneway interface IPhoneStateListener { void onVoLteServiceStateChanged(in VoLteServiceState lteState); void onVoiceActivationStateChanged(int activationState); void onDataActivationStateChanged(int activationState); + void onOemHookRawEvent(in byte[] rawData); void onCarrierNetworkChange(in boolean active); void onUserMobileDataStateChanged(in boolean enabled); } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 7e8b2de4bc2a..73cd498123fd 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1071,6 +1071,17 @@ interface ITelephony { in List<String> cdmaNonRoamingList); /** + * Returns the result and response from RIL for oem request + * + * @param oemReq the data is sent to ril. + * @param oemResp the respose data from RIL. + * @return negative value request was not handled or get error + * 0 request was handled succesfully, but no response data + * positive value success, data length of response + */ + int invokeOemRilRequestRaw(in byte[] oemReq, out byte[] oemResp); + + /** * Check if any mobile Radios need to be shutdown. * * @return true is any mobile radio needs to be shutdown diff --git a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl index 06dc13e53bf7..0127db97963e 100644 --- a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl @@ -70,6 +70,7 @@ interface ITelephonyRegistry { void notifyVoLteServiceStateChanged(in VoLteServiceState lteState); void notifySimActivationStateChangedForPhoneId(in int phoneId, in int subId, int activationState, int activationType); + void notifyOemHookRawEventForSubscriber(in int subId, in byte[] rawData); void notifySubscriptionInfoChanged(); void notifyCarrierNetworkChange(in boolean active); void notifyUserMobileDataStateChangedForPhoneId(in int phoneId, in int subId, in boolean state); |