Merge "checkCarrierPrivilegesForPackage by subId rather than default" into qt-dev

This commit is contained in:
Chen Xu
2019-05-14 01:06:05 +00:00
committed by Android (Google) Code Review
3 changed files with 27 additions and 6 deletions

View File

@@ -1356,7 +1356,7 @@ public class AppStandbyController {
private void fetchCarrierPrivilegedAppsLocked() { private void fetchCarrierPrivilegedAppsLocked() {
TelephonyManager telephonyManager = TelephonyManager telephonyManager =
mContext.getSystemService(TelephonyManager.class); mContext.getSystemService(TelephonyManager.class);
mCarrierPrivilegedApps = telephonyManager.getPackagesWithCarrierPrivileges(); mCarrierPrivilegedApps = telephonyManager.getPackagesWithCarrierPrivilegesForAllPhones();
mHaveCarrierPrivilegedApps = true; mHaveCarrierPrivilegedApps = true;
if (DEBUG) { if (DEBUG) {
Slog.d(TAG, "apps with carrier privilege " + mCarrierPrivilegedApps); Slog.d(TAG, "apps with carrier privilege " + mCarrierPrivilegedApps);

View File

@@ -7475,7 +7475,7 @@ public class TelephonyManager {
try { try {
ITelephony telephony = getITelephony(); ITelephony telephony = getITelephony();
if (telephony != null) if (telephony != null)
return telephony.checkCarrierPrivilegesForPackage(pkgName); return telephony.checkCarrierPrivilegesForPackage(getSubId(), pkgName);
} catch (RemoteException ex) { } catch (RemoteException ex) {
Rlog.e(TAG, "checkCarrierPrivilegesForPackage RemoteException", ex); Rlog.e(TAG, "checkCarrierPrivilegesForPackage RemoteException", ex);
} catch (NullPointerException ex) { } catch (NullPointerException ex) {
@@ -7526,7 +7526,7 @@ public class TelephonyManager {
try { try {
ITelephony telephony = getITelephony(); ITelephony telephony = getITelephony();
if (telephony != null) { if (telephony != null) {
return telephony.getPackagesWithCarrierPrivileges(); return telephony.getPackagesWithCarrierPrivileges(getPhoneId());
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
Rlog.e(TAG, "getPackagesWithCarrierPrivileges RemoteException", ex); Rlog.e(TAG, "getPackagesWithCarrierPrivileges RemoteException", ex);
@@ -7536,6 +7536,22 @@ public class TelephonyManager {
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }
/** @hide */
public List<String> getPackagesWithCarrierPrivilegesForAllPhones() {
try {
ITelephony telephony = getITelephony();
if (telephony != null) {
return telephony.getPackagesWithCarrierPrivilegesForAllPhones();
}
} catch (RemoteException ex) {
Rlog.e(TAG, "getPackagesWithCarrierPrivilegesForAllPhones RemoteException", ex);
} catch (NullPointerException ex) {
Rlog.e(TAG, "getPackagesWithCarrierPrivilegesForAllPhones NPE", ex);
}
return Collections.EMPTY_LIST;
}
/** @hide */ /** @hide */
@SystemApi @SystemApi
@SuppressLint("Doclava125") @SuppressLint("Doclava125")

View File

@@ -1000,7 +1000,7 @@ interface ITelephony {
/** /**
* Similar to above, but check for the package whose name is pkgName. * Similar to above, but check for the package whose name is pkgName.
*/ */
int checkCarrierPrivilegesForPackage(String pkgName); int checkCarrierPrivilegesForPackage(int subId, String pkgName);
/** /**
* Similar to above, but check across all phones. * Similar to above, but check across all phones.
@@ -1356,10 +1356,15 @@ interface ITelephony {
void setVoicemailVibrationEnabled(String callingPackage, void setVoicemailVibrationEnabled(String callingPackage,
in PhoneAccountHandle phoneAccountHandle, boolean enabled); in PhoneAccountHandle phoneAccountHandle, boolean enabled);
/**
* Returns a list of packages that have carrier privileges for the specific phone.
*/
List<String> getPackagesWithCarrierPrivileges(int phoneId);
/** /**
* Returns a list of packages that have carrier privileges. * Returns a list of packages that have carrier privileges.
*/ */
List<String> getPackagesWithCarrierPrivileges(); List<String> getPackagesWithCarrierPrivilegesForAllPhones();
/** /**
* Return the application ID for the app type. * Return the application ID for the app type.