Loading src/com/android/server/telecom/PhoneAccountRegistrar.java +19 −0 Original line number Diff line number Diff line Loading @@ -752,6 +752,25 @@ public class PhoneAccountRegistrar { return getPhoneAccountHandles(0, null, packageName, false, userHandle); } /** * Retrieves a list of all {@link PhoneAccount#CAPABILITY_SELF_MANAGED} phone accounts * registered by a specified package. * * @param packageName The name of the package that registered the phone accounts. * @return The self-managed phone account handles for the given package. */ public List<PhoneAccountHandle> getSelfManagedPhoneAccountsForPackage(String packageName, UserHandle userHandle) { List<PhoneAccountHandle> phoneAccountsHandles = new ArrayList<>(); for (PhoneAccountHandle pah : getPhoneAccountsForPackage(packageName, userHandle)) { if (isSelfManagedPhoneAccount(pah)) { phoneAccountsHandles.add(pah); } } return phoneAccountsHandles; } /** * Determines if a {@link PhoneAccountHandle} is for a self-managed {@link ConnectionService}. * @param handle The handle. Loading src/com/android/server/telecom/TelecomServiceImpl.java +54 −15 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE; import static android.Manifest.permission.READ_SMS; import static android.Manifest.permission.REGISTER_SIM_SUBSCRIPTION; import static android.Manifest.permission.WRITE_SECURE_SETTINGS; import static android.Manifest.permission.MANAGE_OWN_CALLS; import android.Manifest; import android.app.ActivityManager; Loading Loading @@ -227,11 +228,11 @@ public class TelecomServiceImpl { public List<PhoneAccountHandle> getSelfManagedPhoneAccounts(String callingPackage, String callingFeatureId) { try { Log.startSession("TSI.gSMPA", Log.getPackageAbbreviation(callingPackage)); if (!canReadPhoneState(callingPackage, callingFeatureId, Log.startSession("TSI.gSMPA", Log.getPackageAbbreviation(callingPackage)); try { if (canReadPhoneState(callingPackage, callingFeatureId, "Requires READ_PHONE_STATE permission.")) { throw new SecurityException("Requires READ_PHONE_STATE permission."); } synchronized (mLock) { final UserHandle callingUserHandle = Binder.getCallingUserHandle(); long token = Binder.clearCallingIdentity(); Loading @@ -245,11 +246,49 @@ public class TelecomServiceImpl { Binder.restoreCallingIdentity(token); } } } } catch (SecurityException e) { // SecurityException thrown from canReadPhoneState(...) due to READ_PHONE_STATE // permission. check MANAGE_OWN_CALLS permission next. } if (canReadMangeOwnCalls("Requires MANAGE_OWN_CALLS permission")) { synchronized (mLock) { final UserHandle callingUserHandle = Binder.getCallingUserHandle(); long token = Binder.clearCallingIdentity(); try { return mPhoneAccountRegistrar.getSelfManagedPhoneAccountsForPackage( callingPackage, callingUserHandle); } catch (Exception e) { Log.e(this, e, "getSelfManagedPhoneAccountsForPackage"); throw e; } finally { Binder.restoreCallingIdentity(token); } } } else { throw new SecurityException( "Requires caller to be the default dialer app or at least one of the " + "following permissions READ_PRIVILEGED_PHONE_STATE, " + "READ_PHONE_STATE, or MANAGE_OWN_CALLS for the calling " + "package: " + callingPackage); } } finally { Log.endSession(); } } private boolean canReadMangeOwnCalls(String message) { try { mContext.enforceCallingOrSelfPermission(MANAGE_OWN_CALLS, message); return true; } catch (SecurityException e) { return false; } } @Override public List<PhoneAccountHandle> getPhoneAccountsSupportingScheme(String uriScheme, String callingPackage) { Loading Loading
src/com/android/server/telecom/PhoneAccountRegistrar.java +19 −0 Original line number Diff line number Diff line Loading @@ -752,6 +752,25 @@ public class PhoneAccountRegistrar { return getPhoneAccountHandles(0, null, packageName, false, userHandle); } /** * Retrieves a list of all {@link PhoneAccount#CAPABILITY_SELF_MANAGED} phone accounts * registered by a specified package. * * @param packageName The name of the package that registered the phone accounts. * @return The self-managed phone account handles for the given package. */ public List<PhoneAccountHandle> getSelfManagedPhoneAccountsForPackage(String packageName, UserHandle userHandle) { List<PhoneAccountHandle> phoneAccountsHandles = new ArrayList<>(); for (PhoneAccountHandle pah : getPhoneAccountsForPackage(packageName, userHandle)) { if (isSelfManagedPhoneAccount(pah)) { phoneAccountsHandles.add(pah); } } return phoneAccountsHandles; } /** * Determines if a {@link PhoneAccountHandle} is for a self-managed {@link ConnectionService}. * @param handle The handle. Loading
src/com/android/server/telecom/TelecomServiceImpl.java +54 −15 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE; import static android.Manifest.permission.READ_SMS; import static android.Manifest.permission.REGISTER_SIM_SUBSCRIPTION; import static android.Manifest.permission.WRITE_SECURE_SETTINGS; import static android.Manifest.permission.MANAGE_OWN_CALLS; import android.Manifest; import android.app.ActivityManager; Loading Loading @@ -227,11 +228,11 @@ public class TelecomServiceImpl { public List<PhoneAccountHandle> getSelfManagedPhoneAccounts(String callingPackage, String callingFeatureId) { try { Log.startSession("TSI.gSMPA", Log.getPackageAbbreviation(callingPackage)); if (!canReadPhoneState(callingPackage, callingFeatureId, Log.startSession("TSI.gSMPA", Log.getPackageAbbreviation(callingPackage)); try { if (canReadPhoneState(callingPackage, callingFeatureId, "Requires READ_PHONE_STATE permission.")) { throw new SecurityException("Requires READ_PHONE_STATE permission."); } synchronized (mLock) { final UserHandle callingUserHandle = Binder.getCallingUserHandle(); long token = Binder.clearCallingIdentity(); Loading @@ -245,11 +246,49 @@ public class TelecomServiceImpl { Binder.restoreCallingIdentity(token); } } } } catch (SecurityException e) { // SecurityException thrown from canReadPhoneState(...) due to READ_PHONE_STATE // permission. check MANAGE_OWN_CALLS permission next. } if (canReadMangeOwnCalls("Requires MANAGE_OWN_CALLS permission")) { synchronized (mLock) { final UserHandle callingUserHandle = Binder.getCallingUserHandle(); long token = Binder.clearCallingIdentity(); try { return mPhoneAccountRegistrar.getSelfManagedPhoneAccountsForPackage( callingPackage, callingUserHandle); } catch (Exception e) { Log.e(this, e, "getSelfManagedPhoneAccountsForPackage"); throw e; } finally { Binder.restoreCallingIdentity(token); } } } else { throw new SecurityException( "Requires caller to be the default dialer app or at least one of the " + "following permissions READ_PRIVILEGED_PHONE_STATE, " + "READ_PHONE_STATE, or MANAGE_OWN_CALLS for the calling " + "package: " + callingPackage); } } finally { Log.endSession(); } } private boolean canReadMangeOwnCalls(String message) { try { mContext.enforceCallingOrSelfPermission(MANAGE_OWN_CALLS, message); return true; } catch (SecurityException e) { return false; } } @Override public List<PhoneAccountHandle> getPhoneAccountsSupportingScheme(String uriScheme, String callingPackage) { Loading