Have proper permission check in getConfigForSubId

In CarrierConfigManager, add pass context in constructor, so that
when calling CarrierConfigLoader#getConfigForSubId, it can pass
callingPackage.

Bug: 73136824
Test: regression
Change-Id: I4bbff4ea30e2d5473c14d24d6833bf3ca3c595ec
Merged-In: I4bbff4ea30e2d5473c14d24d6833bf3ca3c595ec
This commit is contained in:
Malcolm Chen
2018-02-28 15:20:45 -08:00
committed by Xiangyu/Malcolm Chen
parent 36ce625ccf
commit 6cc64f7244
6 changed files with 15 additions and 9 deletions

View File

@@ -7809,7 +7809,7 @@ Lcom/android/internal/telephony/GsmAlphabet;->sLanguageTables:[Ljava/lang/String
Lcom/android/internal/telephony/GsmAlphabet;->stringToGsm7BitPacked(Ljava/lang/String;IZII)[B
Lcom/android/internal/telephony/GsmAlphabet;->stringToGsm7BitPackedWithHeader(Ljava/lang/String;[BII)[B
Lcom/android/internal/telephony/GsmAlphabet;->stringToGsm8BitPacked(Ljava/lang/String;)[B
Lcom/android/internal/telephony/ICarrierConfigLoader;->getConfigForSubId(I)Landroid/os/PersistableBundle;
Lcom/android/internal/telephony/ICarrierConfigLoader;->getConfigForSubId(ILjava/lang/String;)Landroid/os/PersistableBundle;
Lcom/android/internal/telephony/IMms$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/telephony/IMms;
Lcom/android/internal/telephony/IPhoneStateListener$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/telephony/IPhoneStateListener;
Lcom/android/internal/telephony/IPhoneStateListener;->onCallForwardingIndicatorChanged(Z)V

View File

@@ -490,7 +490,7 @@ final class SystemServiceRegistry {
new CachedServiceFetcher<CarrierConfigManager>() {
@Override
public CarrierConfigManager createService(ContextImpl ctx) {
return new CarrierConfigManager();
return new CarrierConfigManager(ctx.getOuterContext());
}});
registerService(Context.TELECOM_SERVICE, TelecomManager.class,

View File

@@ -51,10 +51,13 @@ public class CarrierConfigManager {
public static final String EXTRA_SUBSCRIPTION_INDEX =
SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX;
private final Context mContext;
/**
* @hide
*/
public CarrierConfigManager() {
public CarrierConfigManager(Context context) {
mContext = context;
}
/**
@@ -2271,7 +2274,7 @@ public class CarrierConfigManager {
+ " ICarrierConfigLoader is null");
return null;
}
return loader.getConfigForSubId(subId);
return loader.getConfigForSubId(subId, mContext.getOpPackageName());
} catch (RemoteException ex) {
Rlog.e(TAG, "Error getting config for subId " + subId + ": "
+ ex.toString());

View File

@@ -6554,7 +6554,7 @@ public class TelephonyManager {
try {
ITelephony telephony = getITelephony();
if (telephony != null) {
return telephony.canChangeDtmfToneLength();
return telephony.canChangeDtmfToneLength(mSubId, getOpPackageName());
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#canChangeDtmfToneLength", e);
@@ -6573,7 +6573,7 @@ public class TelephonyManager {
try {
ITelephony telephony = getITelephony();
if (telephony != null) {
return telephony.isWorldPhone();
return telephony.isWorldPhone(mSubId, getOpPackageName());
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#isWorldPhone", e);

View File

@@ -23,7 +23,7 @@ import android.os.PersistableBundle;
*/
interface ICarrierConfigLoader {
PersistableBundle getConfigForSubId(int subId);
PersistableBundle getConfigForSubId(int subId, String callingPackage);
void notifyConfigChangedForSubId(int subId);

View File

@@ -1123,16 +1123,19 @@ interface ITelephony {
/**
* Whether the DTMF tone length can be changed.
*
* @param subId The subscription to use.
* @param callingPackage The package making the call.
* @return {@code true} if the DTMF tone length can be changed.
*/
boolean canChangeDtmfToneLength();
boolean canChangeDtmfToneLength(int subId, String callingPackage);
/**
* Whether the device is a world phone.
*
* @param callingPackage The package making the call.
* @return {@code true} if the devices is a world phone.
*/
boolean isWorldPhone();
boolean isWorldPhone(int subId, String callingPackage);
/**
* Whether the phone supports TTY mode.