@@ -1248,7 +1248,41 @@ public void notifyPreciseCallState(int ringingCallState, int foregroundCallState
12481248 }
12491249 broadcastPreciseCallStateChanged (ringingCallState , foregroundCallState , backgroundCallState ,
12501250 DisconnectCause .NOT_VALID ,
1251- PreciseDisconnectCause .NOT_VALID );
1251+ PreciseDisconnectCause .NOT_VALID , SubscriptionManager .INVALID_SUBSCRIPTION_ID );
1252+ }
1253+
1254+ public void notifyPreciseCallStateForSubscriber (int subId , int ringingCallState ,
1255+ int foregroundCallState , int backgroundCallState ) {
1256+ if (!checkNotifyPermission ("notifyPreciseCallStateForSubscriber()" )) {
1257+ return ;
1258+ }
1259+ synchronized (mRecords ) {
1260+ int phoneId = SubscriptionManager .getPhoneId (subId );
1261+ if (validatePhoneId (phoneId )) {
1262+ mRingingCallState = ringingCallState ;
1263+ mForegroundCallState = foregroundCallState ;
1264+ mBackgroundCallState = backgroundCallState ;
1265+ mPreciseCallState = new PreciseCallState (ringingCallState , foregroundCallState ,
1266+ backgroundCallState ,
1267+ DisconnectCause .NOT_VALID ,
1268+ PreciseDisconnectCause .NOT_VALID );
1269+ for (Record r : mRecords ) {
1270+ if (r .matchPhoneStateListenerEvent (PhoneStateListener .LISTEN_PRECISE_CALL_STATE )
1271+ && ((r .subId == subId ) ||
1272+ (r .subId == SubscriptionManager .DEFAULT_SUBSCRIPTION_ID ))) {
1273+ try {
1274+ r .callback .onPreciseCallStateChanged (mPreciseCallState );
1275+ } catch (RemoteException ex ) {
1276+ mRemoveList .add (r .binder );
1277+ }
1278+ }
1279+ }
1280+ }
1281+ handleRemoveListLocked ();
1282+ }
1283+ broadcastPreciseCallStateChanged (ringingCallState , foregroundCallState , backgroundCallState ,
1284+ DisconnectCause .NOT_VALID ,
1285+ PreciseDisconnectCause .NOT_VALID , subId );
12521286 }
12531287
12541288 public void notifyDisconnectCause (int disconnectCause , int preciseDisconnectCause ) {
@@ -1270,7 +1304,8 @@ public void notifyDisconnectCause(int disconnectCause, int preciseDisconnectCaus
12701304 handleRemoveListLocked ();
12711305 }
12721306 broadcastPreciseCallStateChanged (mRingingCallState , mForegroundCallState ,
1273- mBackgroundCallState , disconnectCause , preciseDisconnectCause );
1307+ mBackgroundCallState , disconnectCause , preciseDisconnectCause ,
1308+ SubscriptionManager .INVALID_SUBSCRIPTION_ID );
12741309 }
12751310
12761311 public void notifyPreciseDataConnectionFailed (String reason , String apnType ,
@@ -1510,13 +1545,16 @@ private void broadcastDataConnectionFailed(String reason, String apnType,
15101545 }
15111546
15121547 private void broadcastPreciseCallStateChanged (int ringingCallState , int foregroundCallState ,
1513- int backgroundCallState , int disconnectCause , int preciseDisconnectCause ) {
1548+ int backgroundCallState , int disconnectCause , int preciseDisconnectCause , int subId ) {
15141549 Intent intent = new Intent (TelephonyManager .ACTION_PRECISE_CALL_STATE_CHANGED );
15151550 intent .putExtra (TelephonyManager .EXTRA_RINGING_CALL_STATE , ringingCallState );
15161551 intent .putExtra (TelephonyManager .EXTRA_FOREGROUND_CALL_STATE , foregroundCallState );
15171552 intent .putExtra (TelephonyManager .EXTRA_BACKGROUND_CALL_STATE , backgroundCallState );
15181553 intent .putExtra (TelephonyManager .EXTRA_DISCONNECT_CAUSE , disconnectCause );
15191554 intent .putExtra (TelephonyManager .EXTRA_PRECISE_DISCONNECT_CAUSE , preciseDisconnectCause );
1555+ if (subId != SubscriptionManager .INVALID_SUBSCRIPTION_ID ) {
1556+ intent .putExtra (PhoneConstants .SUBSCRIPTION_KEY , subId );
1557+ }
15201558 mContext .sendBroadcastAsUser (intent , UserHandle .ALL ,
15211559 android .Manifest .permission .READ_PRECISE_PHONE_STATE );
15221560 }
0 commit comments