Skip to content

Commit 485f209

Browse files
New Author Steven LiuVineetas
authored andcommitted
redirect RIL_UNSOL_OEM_HOOK_RAW to system app
Add LISTEN_OEM_HOOK_RAW_EVENT and onOemHookRawEvent to PhoneStateListener. Bug: 17298769 Change-Id: Iaea054d3cc2925eea1e11f8871faabc7bc9dfb2d
1 parent c2f4985 commit 485f209

4 files changed

Lines changed: 57 additions & 0 deletions

File tree

services/core/java/com/android/server/TelephonyRegistry.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,30 @@ public void notifyVoLteServiceStateChanged(VoLteServiceState lteState) {
10681068
}
10691069
}
10701070

1071+
public void notifyOemHookRawEventForSubscriber(long subId, byte[] rawData) {
1072+
if (!checkNotifyPermission("notifyOemHookRawEventForSubscriber")) {
1073+
return;
1074+
}
1075+
1076+
synchronized (mRecords) {
1077+
for (Record r : mRecords) {
1078+
if (VDBG) {
1079+
log("notifyOemHookRawEventForSubscriber: r=" + r + " subId=" + subId);
1080+
}
1081+
if (((r.events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) &&
1082+
((r.subId == subId) ||
1083+
(r.subId == SubscriptionManager.DEFAULT_SUB_ID))) {
1084+
try {
1085+
r.callback.onOemHookRawEvent(rawData);
1086+
} catch (RemoteException ex) {
1087+
mRemoveList.add(r.binder);
1088+
}
1089+
}
1090+
}
1091+
handleRemoveListLocked();
1092+
}
1093+
}
1094+
10711095
@Override
10721096
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
10731097
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
@@ -1277,6 +1301,11 @@ private void checkListenerPermission(int events) {
12771301
android.Manifest.permission.READ_PRECISE_PHONE_STATE, null);
12781302

12791303
}
1304+
1305+
if ((events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) {
1306+
mContext.enforceCallingOrSelfPermission(
1307+
android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
1308+
}
12801309
}
12811310

12821311
private void handleRemoveListLocked() {

telephony/java/android/telephony/PhoneStateListener.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@ public class PhoneStateListener {
212212
*/
213213
public static final int LISTEN_VOLTE_STATE = 0x00004000;
214214

215+
/**
216+
* Listen for OEM hook raw event
217+
*
218+
* @see #onOemHookRawEvent
219+
* @hide
220+
*/
221+
public static final int LISTEN_OEM_HOOK_RAW_EVENT = 0x00008000;
222+
215223
/*
216224
* Subscription used to listen to the phone state changes
217225
* @hide
@@ -312,6 +320,10 @@ public void handleMessage(Message msg) {
312320
case LISTEN_VOLTE_STATE:
313321
PhoneStateListener.this.onVoLteServiceStateChanged((VoLteServiceState)msg.obj);
314322
break;
323+
case LISTEN_OEM_HOOK_RAW_EVENT:
324+
PhoneStateListener.this.onOemHookRawEvent((byte[])msg.obj);
325+
break;
326+
315327
}
316328
}
317329
};
@@ -479,6 +491,16 @@ public void onDataConnectionRealTimeInfoChanged(
479491
public void onVoLteServiceStateChanged(VoLteServiceState stateInfo) {
480492
}
481493

494+
/**
495+
* Callback invoked when OEM hook raw event is received. Requires
496+
* the READ_PRIVILEGED_PHONE_STATE permission.
497+
* @param rawData is the byte array of the OEM hook raw data.
498+
* @hide
499+
*/
500+
public void onOemHookRawEvent(byte[] rawData) {
501+
// default implementation empty
502+
}
503+
482504
/**
483505
* The callback methods need to be called on the handler thread where
484506
* this object was created. If the binder did that for us it'd be nice.
@@ -551,6 +573,10 @@ public void onDataConnectionRealTimeInfoChanged(
551573
public void onVoLteServiceStateChanged(VoLteServiceState lteState) {
552574
Message.obtain(mHandler, LISTEN_VOLTE_STATE, 0, 0, lteState).sendToTarget();
553575
}
576+
577+
public void onOemHookRawEvent(byte[] rawData) {
578+
Message.obtain(mHandler, LISTEN_OEM_HOOK_RAW_EVENT, 0, 0, rawData).sendToTarget();
579+
}
554580
};
555581

556582
private void log(String s) {

telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ oneway interface IPhoneStateListener {
4343
void onPreciseDataConnectionStateChanged(in PreciseDataConnectionState dataConnectionState);
4444
void onDataConnectionRealTimeInfoChanged(in DataConnectionRealTimeInfo dcRtInfo);
4545
void onVoLteServiceStateChanged(in VoLteServiceState lteState);
46+
void onOemHookRawEvent(in byte[] rawData);
4647
}
4748

telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,5 @@ interface ITelephonyRegistry {
6262
void notifyCellInfoForSubscriber(in long subId, in List<CellInfo> cellInfo);
6363
void notifyDataConnectionRealTimeInfo(in DataConnectionRealTimeInfo dcRtInfo);
6464
void notifyVoLteServiceStateChanged(in VoLteServiceState lteState);
65+
void notifyOemHookRawEventForSubscriber(in long subId, in byte[] rawData);
6566
}

0 commit comments

Comments
 (0)