Merge "Protect TelecomManager#getPhoneAccount with necessary permissions." into sc-dev am: d62464f4fe

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15053492

Change-Id: I1416946b0ca62ab9ced528e5c8f4bacacaac34f6
This commit is contained in:
TreeHugger Robot
2021-06-22 23:02:10 +00:00
committed by Automerger Merge Worker
2 changed files with 15 additions and 2 deletions

View File

@@ -1018,6 +1018,16 @@ public class TelecomManager {
// this magic number is a bug ID // this magic number is a bug ID
public static final long ENABLE_GET_CALL_STATE_PERMISSION_PROTECTION = 157233955L; public static final long ENABLE_GET_CALL_STATE_PERMISSION_PROTECTION = 157233955L;
/**
* Enable READ_PHONE_NUMBERS or READ_PRIVILEGED_PHONE_STATE protections on
* {@link TelecomManager#getPhoneAccount(PhoneAccountHandle)}.
* @hide
*/
@ChangeId
@EnabledSince(targetSdkVersion = Build.VERSION_CODES.S)
// bug ID
public static final long ENABLE_GET_PHONE_ACCOUNT_PERMISSION_PROTECTION = 183407956L;
private static final String TAG = "TelecomManager"; private static final String TAG = "TelecomManager";
@@ -1351,6 +1361,9 @@ public class TelecomManager {
* Return the {@link PhoneAccount} for a specified {@link PhoneAccountHandle}. Object includes * Return the {@link PhoneAccount} for a specified {@link PhoneAccountHandle}. Object includes
* resources which can be used in a user interface. * resources which can be used in a user interface.
* *
* Requires Permission:
* {@link android.Manifest.permission#READ_PHONE_NUMBERS} for applications targeting API
* level 31+.
* @param account The {@link PhoneAccountHandle}. * @param account The {@link PhoneAccountHandle}.
* @return The {@link PhoneAccount} object. * @return The {@link PhoneAccount} object.
*/ */
@@ -1358,7 +1371,7 @@ public class TelecomManager {
ITelecomService service = getTelecomService(); ITelecomService service = getTelecomService();
if (service != null) { if (service != null) {
try { try {
return service.getPhoneAccount(account); return service.getPhoneAccount(account, mContext.getPackageName());
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error calling ITelecomService#getPhoneAccount", e); Log.e(TAG, "Error calling ITelecomService#getPhoneAccount", e);
} }

View File

@@ -79,7 +79,7 @@ interface ITelecomService {
/** /**
* @see TelecomManager#getPhoneAccount * @see TelecomManager#getPhoneAccount
*/ */
PhoneAccount getPhoneAccount(in PhoneAccountHandle account); PhoneAccount getPhoneAccount(in PhoneAccountHandle account, String callingPackage);
/** /**
* @see TelecomManager#getAllPhoneAccountsCount * @see TelecomManager#getAllPhoneAccountsCount