Loading src/com/android/server/telecom/TelecomServiceImpl.java +100 −33 Original line number Diff line number Diff line Loading @@ -204,10 +204,16 @@ public class TelecomServiceImpl { String callingPackage) { try { Log.startSession("TSI.gPASS"); synchronized (mLock) { if (!canReadPhoneState(callingPackage, "getPhoneAccountsSupportingScheme")) { try { enforceModifyPermission( "getPhoneAccountsSupportingScheme requires MODIFY_PHONE_STATE"); } catch (SecurityException e) { EventLog.writeEvent(0x534e4554, "62347125", Binder.getCallingUid(), "getPhoneAccountsSupportingScheme: " + callingPackage); return Collections.emptyList(); } synchronized (mLock) { final UserHandle callingUserHandle = Binder.getCallingUserHandle(); long token = Binder.clearCallingIdentity(); try { Loading Loading @@ -270,33 +276,57 @@ public class TelecomServiceImpl { @Override public int getAllPhoneAccountsCount() { synchronized (mLock) { try { Log.startSession("TSI.gAPAC"); try { enforceModifyPermission( "getAllPhoneAccountsCount requires MODIFY_PHONE_STATE permission."); } catch (SecurityException e) { EventLog.writeEvent(0x534e4554, "62347125", Binder.getCallingUid(), "getAllPhoneAccountsCount"); throw e; } synchronized (mLock) { try { // This list is pre-filtered for the calling user. return getAllPhoneAccounts().size(); } catch (Exception e) { Log.e(this, e, "getAllPhoneAccountsCount"); throw e; } } } finally { Log.endSession(); } } } @Override public List<PhoneAccount> getAllPhoneAccounts() { synchronized (mLock) { try { Log.startSession("TSI.gAPA"); try { enforceModifyPermission( "getAllPhoneAccounts requires MODIFY_PHONE_STATE permission."); } catch (SecurityException e) { EventLog.writeEvent(0x534e4554, "62347125", Binder.getCallingUid(), "getAllPhoneAccounts"); throw e; } final UserHandle callingUserHandle = Binder.getCallingUserHandle(); long token = Binder.clearCallingIdentity(); try { Log.startSession("TSI.gAPA"); return mPhoneAccountRegistrar.getAllPhoneAccounts(callingUserHandle); } catch (Exception e) { Log.e(this, e, "getAllPhoneAccounts"); throw e; } finally { Binder.restoreCallingIdentity(token); } } finally { Log.endSession(); } } Loading @@ -304,20 +334,32 @@ public class TelecomServiceImpl { @Override public List<PhoneAccountHandle> getAllPhoneAccountHandles() { try { Log.startSession("TSI.gAPAH"); try { enforceModifyPermission( "getAllPhoneAccountHandles requires MODIFY_PHONE_STATE permission."); } catch (SecurityException e) { EventLog.writeEvent(0x534e4554, "62347125", Binder.getCallingUid(), "getAllPhoneAccountHandles"); throw e; } synchronized (mLock) { final UserHandle callingUserHandle = Binder.getCallingUserHandle(); long token = Binder.clearCallingIdentity(); try { Log.startSession("TSI.gAPAH"); return mPhoneAccountRegistrar.getAllPhoneAccountHandles(callingUserHandle); } catch (Exception e) { Log.e(this, e, "getAllPhoneAccounts"); throw e; } finally { Binder.restoreCallingIdentity(token); Log.endSession(); } } } finally { Log.endSession(); } } @Override Loading Loading @@ -682,8 +724,14 @@ public class TelecomServiceImpl { public boolean isRinging(String callingPackage) { try { Log.startSession("TSI.iR"); if (!canReadPhoneState(callingPackage, "isRinging")) { return false; if (!isPrivilegedDialerCalling(callingPackage)) { try { enforceModifyPermission( "isRinging requires MODIFY_PHONE_STATE permission."); } catch (SecurityException e) { EventLog.writeEvent(0x534e4554, "62347125", "isRinging: " + callingPackage); throw e; } } synchronized (mLock) { Loading Loading @@ -932,9 +980,15 @@ public class TelecomServiceImpl { public boolean isTtySupported(String callingPackage) { try { Log.startSession("TSI.iTS"); if (!canReadPhoneState(callingPackage, "isTtySupported")) { throw new SecurityException("Only default dialer or an app with" + "READ_PRIVILEGED_PHONE_STATE or READ_PHONE_STATE can call this api"); if (!isPrivilegedDialerCalling(callingPackage)) { try { enforceModifyPermission( "isTtySupported requires MODIFY_PHONE_STATE permission."); } catch (SecurityException e) { EventLog.writeEvent(0x534e4554, "62347125", "isTtySupported: " + callingPackage); throw e; } } synchronized (mLock) { Loading Loading @@ -1034,6 +1088,15 @@ public class TelecomServiceImpl { public void addNewUnknownCall(PhoneAccountHandle phoneAccountHandle, Bundle extras) { try { Log.startSession("TSI.aNUC"); try { enforceModifyPermission( "addNewUnknownCall requires MODIFY_PHONE_STATE permission."); } catch (SecurityException e) { EventLog.writeEvent(0x534e4554, "62347125", Binder.getCallingUid(), "addNewUnknownCall"); throw e; } synchronized (mLock) { if (phoneAccountHandle != null && phoneAccountHandle.getComponentName() != null) { Loading Loading @@ -1517,6 +1580,10 @@ public class TelecomServiceImpl { enforcePermission(MODIFY_PHONE_STATE); } private void enforceModifyPermission(String message) { mContext.enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, message); } private void enforcePermission(String permission) { mContext.enforceCallingOrSelfPermission(permission, null); } Loading Loading
src/com/android/server/telecom/TelecomServiceImpl.java +100 −33 Original line number Diff line number Diff line Loading @@ -204,10 +204,16 @@ public class TelecomServiceImpl { String callingPackage) { try { Log.startSession("TSI.gPASS"); synchronized (mLock) { if (!canReadPhoneState(callingPackage, "getPhoneAccountsSupportingScheme")) { try { enforceModifyPermission( "getPhoneAccountsSupportingScheme requires MODIFY_PHONE_STATE"); } catch (SecurityException e) { EventLog.writeEvent(0x534e4554, "62347125", Binder.getCallingUid(), "getPhoneAccountsSupportingScheme: " + callingPackage); return Collections.emptyList(); } synchronized (mLock) { final UserHandle callingUserHandle = Binder.getCallingUserHandle(); long token = Binder.clearCallingIdentity(); try { Loading Loading @@ -270,33 +276,57 @@ public class TelecomServiceImpl { @Override public int getAllPhoneAccountsCount() { synchronized (mLock) { try { Log.startSession("TSI.gAPAC"); try { enforceModifyPermission( "getAllPhoneAccountsCount requires MODIFY_PHONE_STATE permission."); } catch (SecurityException e) { EventLog.writeEvent(0x534e4554, "62347125", Binder.getCallingUid(), "getAllPhoneAccountsCount"); throw e; } synchronized (mLock) { try { // This list is pre-filtered for the calling user. return getAllPhoneAccounts().size(); } catch (Exception e) { Log.e(this, e, "getAllPhoneAccountsCount"); throw e; } } } finally { Log.endSession(); } } } @Override public List<PhoneAccount> getAllPhoneAccounts() { synchronized (mLock) { try { Log.startSession("TSI.gAPA"); try { enforceModifyPermission( "getAllPhoneAccounts requires MODIFY_PHONE_STATE permission."); } catch (SecurityException e) { EventLog.writeEvent(0x534e4554, "62347125", Binder.getCallingUid(), "getAllPhoneAccounts"); throw e; } final UserHandle callingUserHandle = Binder.getCallingUserHandle(); long token = Binder.clearCallingIdentity(); try { Log.startSession("TSI.gAPA"); return mPhoneAccountRegistrar.getAllPhoneAccounts(callingUserHandle); } catch (Exception e) { Log.e(this, e, "getAllPhoneAccounts"); throw e; } finally { Binder.restoreCallingIdentity(token); } } finally { Log.endSession(); } } Loading @@ -304,20 +334,32 @@ public class TelecomServiceImpl { @Override public List<PhoneAccountHandle> getAllPhoneAccountHandles() { try { Log.startSession("TSI.gAPAH"); try { enforceModifyPermission( "getAllPhoneAccountHandles requires MODIFY_PHONE_STATE permission."); } catch (SecurityException e) { EventLog.writeEvent(0x534e4554, "62347125", Binder.getCallingUid(), "getAllPhoneAccountHandles"); throw e; } synchronized (mLock) { final UserHandle callingUserHandle = Binder.getCallingUserHandle(); long token = Binder.clearCallingIdentity(); try { Log.startSession("TSI.gAPAH"); return mPhoneAccountRegistrar.getAllPhoneAccountHandles(callingUserHandle); } catch (Exception e) { Log.e(this, e, "getAllPhoneAccounts"); throw e; } finally { Binder.restoreCallingIdentity(token); Log.endSession(); } } } finally { Log.endSession(); } } @Override Loading Loading @@ -682,8 +724,14 @@ public class TelecomServiceImpl { public boolean isRinging(String callingPackage) { try { Log.startSession("TSI.iR"); if (!canReadPhoneState(callingPackage, "isRinging")) { return false; if (!isPrivilegedDialerCalling(callingPackage)) { try { enforceModifyPermission( "isRinging requires MODIFY_PHONE_STATE permission."); } catch (SecurityException e) { EventLog.writeEvent(0x534e4554, "62347125", "isRinging: " + callingPackage); throw e; } } synchronized (mLock) { Loading Loading @@ -932,9 +980,15 @@ public class TelecomServiceImpl { public boolean isTtySupported(String callingPackage) { try { Log.startSession("TSI.iTS"); if (!canReadPhoneState(callingPackage, "isTtySupported")) { throw new SecurityException("Only default dialer or an app with" + "READ_PRIVILEGED_PHONE_STATE or READ_PHONE_STATE can call this api"); if (!isPrivilegedDialerCalling(callingPackage)) { try { enforceModifyPermission( "isTtySupported requires MODIFY_PHONE_STATE permission."); } catch (SecurityException e) { EventLog.writeEvent(0x534e4554, "62347125", "isTtySupported: " + callingPackage); throw e; } } synchronized (mLock) { Loading Loading @@ -1034,6 +1088,15 @@ public class TelecomServiceImpl { public void addNewUnknownCall(PhoneAccountHandle phoneAccountHandle, Bundle extras) { try { Log.startSession("TSI.aNUC"); try { enforceModifyPermission( "addNewUnknownCall requires MODIFY_PHONE_STATE permission."); } catch (SecurityException e) { EventLog.writeEvent(0x534e4554, "62347125", Binder.getCallingUid(), "addNewUnknownCall"); throw e; } synchronized (mLock) { if (phoneAccountHandle != null && phoneAccountHandle.getComponentName() != null) { Loading Loading @@ -1517,6 +1580,10 @@ public class TelecomServiceImpl { enforcePermission(MODIFY_PHONE_STATE); } private void enforceModifyPermission(String message) { mContext.enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, message); } private void enforcePermission(String permission) { mContext.enforceCallingOrSelfPermission(permission, null); } Loading