Fix security vulnerability of TelecomManager#getPhoneAccountsForPackage am: f3f2d7c2dc am: 21bc22a06e am: 0b9f87a4e3 am: 094c156982 am: 1aadaf8e1a am: a6a9176d19
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/services/Telecomm/+/12141784
Change-Id: Ifcb2327a43a526cb80148e6906a28ae09979522b
diff --git a/src/com/android/server/telecom/TelecomServiceImpl.java b/src/com/android/server/telecom/TelecomServiceImpl.java
index 62e0f3f..9ccae9a 100644
--- a/src/com/android/server/telecom/TelecomServiceImpl.java
+++ b/src/com/android/server/telecom/TelecomServiceImpl.java
@@ -279,6 +279,23 @@
@Override
public List<PhoneAccountHandle> getPhoneAccountsForPackage(String packageName) {
+ //TODO: Deprecate this in S
+ try {
+ enforceCallingPackage(packageName);
+ } catch (SecurityException se1) {
+ EventLog.writeEvent(0x534e4554, "153995334", Binder.getCallingUid(),
+ "getPhoneAccountsForPackage: invalid calling package");
+ throw se1;
+ }
+
+ try {
+ enforcePermission(READ_PRIVILEGED_PHONE_STATE);
+ } catch (SecurityException se2) {
+ EventLog.writeEvent(0x534e4554, "153995334", Binder.getCallingUid(),
+ "getPhoneAccountsForPackage: no permission");
+ throw se2;
+ }
+
synchronized (mLock) {
final UserHandle callingUserHandle = Binder.getCallingUserHandle();
long token = Binder.clearCallingIdentity();