Loading core/java/android/os/Build.java +1 −1 Original line number Diff line number Diff line Loading @@ -161,7 +161,7 @@ public class Build { try { Application application = ActivityThread.currentApplication(); String callingPackage = application != null ? application.getPackageName() : null; return service.getSerialForPackage(callingPackage); return service.getSerialForPackage(callingPackage, null); } catch (RemoteException e) { e.rethrowFromSystemServer(); } Loading core/java/android/os/IDeviceIdentifiersPolicyService.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -21,5 +21,5 @@ package android.os; */ interface IDeviceIdentifiersPolicyService { String getSerial(); String getSerialForPackage(in String callingPackage); String getSerialForPackage(in String callingPackage, String callingFeatureId); } core/java/android/telephony/TelephonyRegistryManager.java +3 −2 Original line number Diff line number Diff line Loading @@ -118,7 +118,8 @@ public class TelephonyRegistryManager { }; mSubscriptionChangedListenerMap.put(listener, callback); try { sRegistry.addOnSubscriptionsChangedListener(mContext.getOpPackageName(), callback); sRegistry.addOnSubscriptionsChangedListener(mContext.getOpPackageName(), null, callback); } catch (RemoteException ex) { // system server crash } Loading Loading @@ -177,7 +178,7 @@ public class TelephonyRegistryManager { mOpportunisticSubscriptionChangedListenerMap.put(listener, callback); try { sRegistry.addOnOpportunisticSubscriptionsChangedListener(mContext.getOpPackageName(), callback); null, callback); } catch (RemoteException ex) { // system server crash } Loading core/java/com/android/internal/telephony/ITelephonyRegistry.aidl +9 −3 Original line number Diff line number Diff line Loading @@ -33,16 +33,22 @@ import com.android.internal.telephony.IPhoneStateListener; import com.android.internal.telephony.IOnSubscriptionsChangedListener; interface ITelephonyRegistry { void addOnSubscriptionsChangedListener(String pkg, void addOnSubscriptionsChangedListener(String pkg, String featureId, IOnSubscriptionsChangedListener callback); void addOnOpportunisticSubscriptionsChangedListener(String pkg, void addOnOpportunisticSubscriptionsChangedListener(String pkg, String featureId, IOnSubscriptionsChangedListener callback); void removeOnSubscriptionsChangedListener(String pkg, IOnSubscriptionsChangedListener callback); /** * @deprecated Use {@link #listenWithFeature(String, String, IPhoneStateListener, int, * boolean) instead */ @UnsupportedAppUsage void listen(String pkg, IPhoneStateListener callback, int events, boolean notifyNow); void listenForSubscriber(in int subId, String pkg, IPhoneStateListener callback, int events, void listenWithFeature(String pkg, String featureId, IPhoneStateListener callback, int events, boolean notifyNow); void listenForSubscriber(in int subId, String pkg, String featureId, IPhoneStateListener callback, int events, boolean notifyNow); @UnsupportedAppUsage void notifyCallStateForAllSubs(int state, String incomingNumber); void notifyCallState(in int phoneId, in int subId, int state, String incomingNumber); Loading services/core/java/com/android/server/TelephonyRegistry.java +28 −15 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static android.telephony.TelephonyRegistryManager.SIM_ACTIVATION_TYPE_VOI import static java.util.Arrays.copyOf; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.AppOpsManager; import android.content.BroadcastReceiver; Loading Loading @@ -114,6 +115,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { Context context; String callingPackage; String callingFeatureId; IBinder binder; Loading Loading @@ -147,7 +149,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { boolean canReadCallLog() { try { return TelephonyPermissions.checkReadCallLog( context, subId, callerPid, callerUid, callingPackage); context, subId, callerPid, callerUid, callingPackage, callingFeatureId); } catch (SecurityException e) { return false; } Loading Loading @@ -570,7 +572,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { } @Override public void addOnSubscriptionsChangedListener(String callingPackage, public void addOnSubscriptionsChangedListener(String callingPackage, String callingFeatureId, IOnSubscriptionsChangedListener callback) { int callerUserId = UserHandle.getCallingUserId(); mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); Loading @@ -592,6 +594,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { r.context = mContext; r.onSubscriptionsChangedListenerCallback = callback; r.callingPackage = callingPackage; r.callingFeatureId = callingFeatureId; r.callerUid = Binder.getCallingUid(); r.callerPid = Binder.getCallingPid(); r.events = 0; Loading Loading @@ -624,7 +627,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { @Override public void addOnOpportunisticSubscriptionsChangedListener(String callingPackage, IOnSubscriptionsChangedListener callback) { String callingFeatureId, IOnSubscriptionsChangedListener callback) { int callerUserId = UserHandle.getCallingUserId(); mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); if (VDBG) { Loading @@ -645,6 +648,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { r.context = mContext; r.onOpportunisticSubscriptionsChangedListenerCallback = callback; r.callingPackage = callingPackage; r.callingFeatureId = callingFeatureId; r.callerUid = Binder.getCallingUid(); r.callerPid = Binder.getCallingPid(); r.events = 0; Loading Loading @@ -720,21 +724,28 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { } } @Deprecated @Override public void listen(String pkgForDebug, IPhoneStateListener callback, int events, public void listen(String callingPackage, IPhoneStateListener callback, int events, boolean notifyNow) { listenForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, pkgForDebug, callback, events, notifyNow); listenWithFeature(callingPackage, null, callback, events, notifyNow); } @Override public void listenWithFeature(String callingPackage, String callingFeatureId, IPhoneStateListener callback, int events, boolean notifyNow) { listenForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, callingPackage, callingFeatureId, callback, events, notifyNow); } @Override public void listenForSubscriber(int subId, String pkgForDebug, IPhoneStateListener callback, int events, boolean notifyNow) { listen(pkgForDebug, callback, events, notifyNow, subId); public void listenForSubscriber(int subId, String callingPackage, String callingFeatureId, IPhoneStateListener callback, int events, boolean notifyNow) { listen(callingPackage, callingFeatureId, callback, events, notifyNow, subId); } private void listen(String callingPackage, IPhoneStateListener callback, int events, boolean notifyNow, int subId) { private void listen(String callingPackage, @Nullable String callingFeatureId, IPhoneStateListener callback, int events, boolean notifyNow, int subId) { int callerUserId = UserHandle.getCallingUserId(); mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); String str = "listen: E pkg=" + callingPackage + " events=0x" + Integer.toHexString(events) Loading @@ -749,7 +760,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { // Checks permission and throws SecurityException for disallowed operations. For pre-M // apps whose runtime permission has been revoked, we return immediately to skip sending // events to the app without crashing it. if (!checkListenerPermission(events, subId, callingPackage, "listen")) { if (!checkListenerPermission(events, subId, callingPackage, callingFeatureId, "listen")) { return; } Loading @@ -766,6 +778,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { r.context = mContext; r.callback = callback; r.callingPackage = callingPackage; r.callingFeatureId = callingFeatureId; r.callerUid = Binder.getCallingUid(); r.callerPid = Binder.getCallingPid(); // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID, Loading Loading @@ -2286,8 +2299,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { == PackageManager.PERMISSION_GRANTED; } private boolean checkListenerPermission( int events, int subId, String callingPackage, String message) { private boolean checkListenerPermission(int events, int subId, String callingPackage, @Nullable String callingFeatureId, String message) { LocationAccessPolicy.LocationPermissionQuery.Builder locationQueryBuilder = new LocationAccessPolicy.LocationPermissionQuery.Builder() .setCallingPackage(callingPackage) Loading Loading @@ -2322,7 +2335,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { if ((events & ENFORCE_PHONE_STATE_PERMISSION_MASK) != 0) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, subId, callingPackage, message)) { mContext, subId, callingPackage, callingFeatureId, message)) { return false; } } Loading Loading
core/java/android/os/Build.java +1 −1 Original line number Diff line number Diff line Loading @@ -161,7 +161,7 @@ public class Build { try { Application application = ActivityThread.currentApplication(); String callingPackage = application != null ? application.getPackageName() : null; return service.getSerialForPackage(callingPackage); return service.getSerialForPackage(callingPackage, null); } catch (RemoteException e) { e.rethrowFromSystemServer(); } Loading
core/java/android/os/IDeviceIdentifiersPolicyService.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -21,5 +21,5 @@ package android.os; */ interface IDeviceIdentifiersPolicyService { String getSerial(); String getSerialForPackage(in String callingPackage); String getSerialForPackage(in String callingPackage, String callingFeatureId); }
core/java/android/telephony/TelephonyRegistryManager.java +3 −2 Original line number Diff line number Diff line Loading @@ -118,7 +118,8 @@ public class TelephonyRegistryManager { }; mSubscriptionChangedListenerMap.put(listener, callback); try { sRegistry.addOnSubscriptionsChangedListener(mContext.getOpPackageName(), callback); sRegistry.addOnSubscriptionsChangedListener(mContext.getOpPackageName(), null, callback); } catch (RemoteException ex) { // system server crash } Loading Loading @@ -177,7 +178,7 @@ public class TelephonyRegistryManager { mOpportunisticSubscriptionChangedListenerMap.put(listener, callback); try { sRegistry.addOnOpportunisticSubscriptionsChangedListener(mContext.getOpPackageName(), callback); null, callback); } catch (RemoteException ex) { // system server crash } Loading
core/java/com/android/internal/telephony/ITelephonyRegistry.aidl +9 −3 Original line number Diff line number Diff line Loading @@ -33,16 +33,22 @@ import com.android.internal.telephony.IPhoneStateListener; import com.android.internal.telephony.IOnSubscriptionsChangedListener; interface ITelephonyRegistry { void addOnSubscriptionsChangedListener(String pkg, void addOnSubscriptionsChangedListener(String pkg, String featureId, IOnSubscriptionsChangedListener callback); void addOnOpportunisticSubscriptionsChangedListener(String pkg, void addOnOpportunisticSubscriptionsChangedListener(String pkg, String featureId, IOnSubscriptionsChangedListener callback); void removeOnSubscriptionsChangedListener(String pkg, IOnSubscriptionsChangedListener callback); /** * @deprecated Use {@link #listenWithFeature(String, String, IPhoneStateListener, int, * boolean) instead */ @UnsupportedAppUsage void listen(String pkg, IPhoneStateListener callback, int events, boolean notifyNow); void listenForSubscriber(in int subId, String pkg, IPhoneStateListener callback, int events, void listenWithFeature(String pkg, String featureId, IPhoneStateListener callback, int events, boolean notifyNow); void listenForSubscriber(in int subId, String pkg, String featureId, IPhoneStateListener callback, int events, boolean notifyNow); @UnsupportedAppUsage void notifyCallStateForAllSubs(int state, String incomingNumber); void notifyCallState(in int phoneId, in int subId, int state, String incomingNumber); Loading
services/core/java/com/android/server/TelephonyRegistry.java +28 −15 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static android.telephony.TelephonyRegistryManager.SIM_ACTIVATION_TYPE_VOI import static java.util.Arrays.copyOf; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.AppOpsManager; import android.content.BroadcastReceiver; Loading Loading @@ -114,6 +115,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { Context context; String callingPackage; String callingFeatureId; IBinder binder; Loading Loading @@ -147,7 +149,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { boolean canReadCallLog() { try { return TelephonyPermissions.checkReadCallLog( context, subId, callerPid, callerUid, callingPackage); context, subId, callerPid, callerUid, callingPackage, callingFeatureId); } catch (SecurityException e) { return false; } Loading Loading @@ -570,7 +572,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { } @Override public void addOnSubscriptionsChangedListener(String callingPackage, public void addOnSubscriptionsChangedListener(String callingPackage, String callingFeatureId, IOnSubscriptionsChangedListener callback) { int callerUserId = UserHandle.getCallingUserId(); mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); Loading @@ -592,6 +594,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { r.context = mContext; r.onSubscriptionsChangedListenerCallback = callback; r.callingPackage = callingPackage; r.callingFeatureId = callingFeatureId; r.callerUid = Binder.getCallingUid(); r.callerPid = Binder.getCallingPid(); r.events = 0; Loading Loading @@ -624,7 +627,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { @Override public void addOnOpportunisticSubscriptionsChangedListener(String callingPackage, IOnSubscriptionsChangedListener callback) { String callingFeatureId, IOnSubscriptionsChangedListener callback) { int callerUserId = UserHandle.getCallingUserId(); mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); if (VDBG) { Loading @@ -645,6 +648,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { r.context = mContext; r.onOpportunisticSubscriptionsChangedListenerCallback = callback; r.callingPackage = callingPackage; r.callingFeatureId = callingFeatureId; r.callerUid = Binder.getCallingUid(); r.callerPid = Binder.getCallingPid(); r.events = 0; Loading Loading @@ -720,21 +724,28 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { } } @Deprecated @Override public void listen(String pkgForDebug, IPhoneStateListener callback, int events, public void listen(String callingPackage, IPhoneStateListener callback, int events, boolean notifyNow) { listenForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, pkgForDebug, callback, events, notifyNow); listenWithFeature(callingPackage, null, callback, events, notifyNow); } @Override public void listenWithFeature(String callingPackage, String callingFeatureId, IPhoneStateListener callback, int events, boolean notifyNow) { listenForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, callingPackage, callingFeatureId, callback, events, notifyNow); } @Override public void listenForSubscriber(int subId, String pkgForDebug, IPhoneStateListener callback, int events, boolean notifyNow) { listen(pkgForDebug, callback, events, notifyNow, subId); public void listenForSubscriber(int subId, String callingPackage, String callingFeatureId, IPhoneStateListener callback, int events, boolean notifyNow) { listen(callingPackage, callingFeatureId, callback, events, notifyNow, subId); } private void listen(String callingPackage, IPhoneStateListener callback, int events, boolean notifyNow, int subId) { private void listen(String callingPackage, @Nullable String callingFeatureId, IPhoneStateListener callback, int events, boolean notifyNow, int subId) { int callerUserId = UserHandle.getCallingUserId(); mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); String str = "listen: E pkg=" + callingPackage + " events=0x" + Integer.toHexString(events) Loading @@ -749,7 +760,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { // Checks permission and throws SecurityException for disallowed operations. For pre-M // apps whose runtime permission has been revoked, we return immediately to skip sending // events to the app without crashing it. if (!checkListenerPermission(events, subId, callingPackage, "listen")) { if (!checkListenerPermission(events, subId, callingPackage, callingFeatureId, "listen")) { return; } Loading @@ -766,6 +778,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { r.context = mContext; r.callback = callback; r.callingPackage = callingPackage; r.callingFeatureId = callingFeatureId; r.callerUid = Binder.getCallingUid(); r.callerPid = Binder.getCallingPid(); // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID, Loading Loading @@ -2286,8 +2299,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { == PackageManager.PERMISSION_GRANTED; } private boolean checkListenerPermission( int events, int subId, String callingPackage, String message) { private boolean checkListenerPermission(int events, int subId, String callingPackage, @Nullable String callingFeatureId, String message) { LocationAccessPolicy.LocationPermissionQuery.Builder locationQueryBuilder = new LocationAccessPolicy.LocationPermissionQuery.Builder() .setCallingPackage(callingPackage) Loading Loading @@ -2322,7 +2335,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { if ((events & ENFORCE_PHONE_STATE_PERMISSION_MASK) != 0) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, subId, callingPackage, message)) { mContext, subId, callingPackage, callingFeatureId, message)) { return false; } } Loading