diff options
16 files changed, 173 insertions, 75 deletions
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index 256d87d..add7af2 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -93,15 +93,20 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM } static boolean sSystemReady = false; + static public void broadcastStickyIntent(Intent intent, String permission, int userId) { + broadcastStickyIntent(intent, permission, AppOpsManager.OP_NONE, userId); + } + /** * Convenience for sending a sticky broadcast. For internal use only. * If you don't care about permission, use null. */ - static public void broadcastStickyIntent(Intent intent, String permission, int userId) { + static public void broadcastStickyIntent(Intent intent, String permission, int appOp, + int userId) { try { getDefault().broadcastIntent( null, intent, null, null, Activity.RESULT_OK, null, null, - null /*permission*/, AppOpsManager.OP_NONE, false, true, userId); + null /*permission*/, appOp, false, true, userId); } catch (RemoteException ex) { } } diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 381c20c..06ece8e 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -16,6 +16,7 @@ package android.app; +import android.Manifest; import android.annotation.SystemApi; import android.app.usage.UsageStatsManager; import android.content.Context; @@ -212,8 +213,10 @@ public class AppOpsManager { public static final int OP_ASSIST_STRUCTURE = 49; /** @hide Received a screenshot from assist. */ public static final int OP_ASSIST_SCREENSHOT = 50; + /** @hide Read the phone state. */ + public static final int OP_READ_PHONE_STATE = 51; /** @hide */ - public static final int _NUM_OP = 51; + public static final int _NUM_OP = 52; /** Access to coarse location information. */ public static final String OPSTR_COARSE_LOCATION = @@ -294,6 +297,7 @@ public class AppOpsManager { OP_WRITE_WALLPAPER, OP_ASSIST_STRUCTURE, OP_ASSIST_SCREENSHOT, + OP_READ_PHONE_STATE }; /** @@ -352,6 +356,7 @@ public class AppOpsManager { null, null, null, + null }; /** @@ -409,7 +414,8 @@ public class AppOpsManager { "ACTIVATE_VPN", "WRITE_WALLPAPER", "ASSIST_STRUCTURE", - "ASSIST_SCREENSHOT" + "ASSIST_SCREENSHOT", + "OP_READ_PHONE_STATE" }; /** @@ -468,6 +474,7 @@ public class AppOpsManager { null, // no permission for supporting wallpaper null, // no permission for receiving assist structure null, // no permission for receiving assist screenshot + Manifest.permission.READ_PHONE_STATE }; /** @@ -527,6 +534,7 @@ public class AppOpsManager { UserManager.DISALLOW_WALLPAPER, // WRITE_WALLPAPER null, // ASSIST_STRUCTURE null, // ASSIST_SCREENSHOT + null // READ_PHONE_STATE }; /** @@ -585,6 +593,7 @@ public class AppOpsManager { false, //WALLPAPER false, //ASSIST_STRUCTURE false, //ASSIST_SCREENSHOT + false, //READ_PHONE_STATE }; /** @@ -642,6 +651,7 @@ public class AppOpsManager { AppOpsManager.MODE_ALLOWED, AppOpsManager.MODE_ALLOWED, AppOpsManager.MODE_ALLOWED, + AppOpsManager.MODE_ALLOWED }; /** @@ -703,6 +713,7 @@ public class AppOpsManager { false, false, false, + false }; private static HashMap<String, Integer> sOpStrToOp = new HashMap<String, Integer>(); diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 4ccd69f..81a78f6 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -860,13 +860,19 @@ class ContextImpl extends Context { @Override public void sendBroadcastAsUser(Intent intent, UserHandle user, String receiverPermission) { + sendBroadcastAsUser(intent, user, receiverPermission, AppOpsManager.OP_NONE); + } + + @Override + public void sendBroadcastAsUser(Intent intent, UserHandle user, + String receiverPermission, int appOp) { String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); try { intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( - mMainThread.getApplicationThread(), intent, resolvedType, null, - Activity.RESULT_OK, null, null, receiverPermission, AppOpsManager.OP_NONE, false, false, - user.getIdentifier()); + mMainThread.getApplicationThread(), intent, resolvedType, null, + Activity.RESULT_OK, null, null, receiverPermission, appOp, false, false, + user.getIdentifier()); } catch (RemoteException e) { } } diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java index e446700..46da025 100644 --- a/core/java/android/app/SystemServiceRegistry.java +++ b/core/java/android/app/SystemServiceRegistry.java @@ -332,10 +332,10 @@ final class SystemServiceRegistry { }}); registerService(Context.NETWORK_POLICY_SERVICE, NetworkPolicyManager.class, - new StaticServiceFetcher<NetworkPolicyManager>() { + new CachedServiceFetcher<NetworkPolicyManager>() { @Override - public NetworkPolicyManager createService() { - return new NetworkPolicyManager(INetworkPolicyManager.Stub.asInterface( + public NetworkPolicyManager createService(ContextImpl ctx) { + return new NetworkPolicyManager(ctx, INetworkPolicyManager.Stub.asInterface( ServiceManager.getService(Context.NETWORK_POLICY_SERVICE))); }}); diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 370f61c..3bf3f85 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -1608,6 +1608,28 @@ public abstract class Context { public abstract void sendBroadcastAsUser(Intent intent, UserHandle user, @Nullable String receiverPermission); + + /** + * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the + * user the broadcast will be sent to. This is not available to applications + * that are not pre-installed on the system image. Using it requires holding + * the INTERACT_ACROSS_USERS permission. + * + * @param intent The Intent to broadcast; all receivers matching this + * Intent will receive the broadcast. + * @param user UserHandle to send the intent to. + * @param receiverPermission (optional) String naming a permission that + * a receiver must hold in order to receive your broadcast. + * If null, no permission is required. + * @param appOp The app op associated with the broadcast. + * + * @see #sendBroadcast(Intent, String) + * + * @hide + */ + public abstract void sendBroadcastAsUser(Intent intent, UserHandle user, + @Nullable String receiverPermission, int appOp); + /** * Version of * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)} diff --git a/core/java/android/content/ContextWrapper.java b/core/java/android/content/ContextWrapper.java index 92f0079..fb9e194 100644 --- a/core/java/android/content/ContextWrapper.java +++ b/core/java/android/content/ContextWrapper.java @@ -444,6 +444,13 @@ public class ContextWrapper extends Context { mBase.sendBroadcastAsUser(intent, user, receiverPermission); } + /** @hide */ + @Override + public void sendBroadcastAsUser(Intent intent, UserHandle user, + String receiverPermission, int appOp) { + mBase.sendBroadcastAsUser(intent, user, receiverPermission, appOp); + } + @Override public void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler, diff --git a/core/java/android/net/INetworkPolicyManager.aidl b/core/java/android/net/INetworkPolicyManager.aidl index 7e92de2..db7c35c 100644 --- a/core/java/android/net/INetworkPolicyManager.aidl +++ b/core/java/android/net/INetworkPolicyManager.aidl @@ -45,7 +45,7 @@ interface INetworkPolicyManager { /** Control network policies atomically. */ void setNetworkPolicies(in NetworkPolicy[] policies); - NetworkPolicy[] getNetworkPolicies(); + NetworkPolicy[] getNetworkPolicies(String callingPackage); /** Snooze limit on policy matching given template. */ void snoozeLimit(in NetworkTemplate template); diff --git a/core/java/android/net/NetworkPolicyManager.java b/core/java/android/net/NetworkPolicyManager.java index a7ffee9..25ad928 100644 --- a/core/java/android/net/NetworkPolicyManager.java +++ b/core/java/android/net/NetworkPolicyManager.java @@ -61,12 +61,14 @@ public class NetworkPolicyManager { */ public static final String EXTRA_NETWORK_TEMPLATE = "android.net.NETWORK_TEMPLATE"; + private final Context mContext; private INetworkPolicyManager mService; - public NetworkPolicyManager(INetworkPolicyManager service) { + public NetworkPolicyManager(Context context, INetworkPolicyManager service) { if (service == null) { throw new IllegalArgumentException("missing INetworkPolicyManager"); } + mContext = context; mService = service; } @@ -158,7 +160,7 @@ public class NetworkPolicyManager { public NetworkPolicy[] getNetworkPolicies() { try { - return mService.getNetworkPolicies(); + return mService.getNetworkPolicies(mContext.getOpPackageName()); } catch (RemoteException e) { return null; } diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 908ee22..4ee6657 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -17,6 +17,7 @@ package com.android.server; import android.app.ActivityManager; +import android.app.AppOpsManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -84,7 +85,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { private static final boolean VDBG = false; // STOPSHIP if true private static class Record { - String pkgForDebug; + String callingPackage; IBinder binder; @@ -109,7 +110,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { @Override public String toString() { - return "{pkgForDebug=" + pkgForDebug + " binder=" + binder + " callback=" + callback + return "{callingPackage=" + callingPackage + " binder=" + binder + + " callback=" + callback + " onSubscriptionsChangedListenererCallback=" + onSubscriptionsChangedListenerCallback + " callerUid=" + callerUid + " subId=" + subId + " phoneId=" + phoneId @@ -125,6 +127,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { private final IBatteryStats mBatteryStats; + private final AppOpsManager mAppOps; + private boolean hasNotifySubscriptionInfoChangedOccurred = false; private int mNumPhones; @@ -327,6 +331,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } } mConnectedApns = new ArrayList<String>(); + + mAppOps = mContext.getSystemService(AppOpsManager.class); } public void systemRunning() { @@ -340,18 +346,24 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } @Override - public void addOnSubscriptionsChangedListener(String pkgForDebug, + public void addOnSubscriptionsChangedListener(String callingPackage, IOnSubscriptionsChangedListener callback) { int callerUid = UserHandle.getCallingUserId(); int myUid = UserHandle.myUserId(); if (VDBG) { - log("listen oscl: E pkg=" + pkgForDebug + " myUid=" + myUid + log("listen oscl: E pkg=" + callingPackage + " myUid=" + myUid + " callerUid=" + callerUid + " callback=" + callback + " callback.asBinder=" + callback.asBinder()); } - /* Checks permission and throws Security exception */ - checkOnSubscriptionsChangedListenerPermission(); + mContext.enforceCallingOrSelfPermission( + android.Manifest.permission.READ_PHONE_STATE, null); + + if (mAppOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, Binder.getCallingUid(), + callingPackage) != AppOpsManager.MODE_ALLOWED) { + return; + } + Record r = null; synchronized (mRecords) { @@ -372,7 +384,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } r.onSubscriptionsChangedListenerCallback = callback; - r.pkgForDebug = pkgForDebug; + r.callingPackage = callingPackage; r.callerUid = callerUid; r.events = 0; if (DBG) { @@ -401,12 +413,6 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { remove(callback.asBinder()); } - private void checkOnSubscriptionsChangedListenerPermission() { - mContext.enforceCallingOrSelfPermission( - SubscriptionManager.OnSubscriptionsChangedListener - .PERMISSION_ON_SUBSCRIPTIONS_CHANGED, null); - } - @Override public void notifySubscriptionInfoChanged() { if (VDBG) log("notifySubscriptionInfoChanged:"); @@ -446,12 +452,12 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { listen(pkgForDebug, callback, events, notifyNow, subId); } - private void listen(String pkgForDebug, IPhoneStateListener callback, int events, + private void listen(String callingPackage, IPhoneStateListener callback, int events, boolean notifyNow, int subId) { int callerUid = UserHandle.getCallingUserId(); int myUid = UserHandle.myUserId(); if (VDBG) { - log("listen: E pkg=" + pkgForDebug + " events=0x" + Integer.toHexString(events) + log("listen: E pkg=" + callingPackage + " events=0x" + Integer.toHexString(events) + " notifyNow=" + notifyNow + " subId=" + subId + " myUid=" + myUid + " callerUid=" + callerUid); } @@ -459,6 +465,14 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { if (events != PhoneStateListener.LISTEN_NONE) { /* Checks permission and throws Security exception */ checkListenerPermission(events); + + if ((events & PHONE_STATE_PERMISSION_MASK) != 0) { + if (mAppOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, Binder.getCallingUid(), + callingPackage) != AppOpsManager.MODE_ALLOWED) { + return; + } + } + synchronized (mRecords) { // register Record r = null; @@ -478,7 +492,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } r.callback = callback; - r.pkgForDebug = pkgForDebug; + r.callingPackage = callingPackage; r.callerUid = callerUid; // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID, // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID @@ -631,7 +645,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { if (mRecords.get(i).binder == binder) { if (DBG) { Record r = mRecords.get(i); - log("remove: binder=" + binder + "r.pkgForDebug" + r.pkgForDebug + log("remove: binder=" + binder + "r.callingPackage" + r.callingPackage + "r.callback" + r.callback); } mRecords.remove(i); @@ -1380,7 +1394,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); mContext.sendBroadcastAsUser(intent, UserHandle.ALL, - android.Manifest.permission.READ_PHONE_STATE); + android.Manifest.permission.READ_PHONE_STATE, + AppOpsManager.OP_READ_PHONE_STATE); } private void broadcastDataConnectionStateChanged(int state, diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java index 5de7d42..4e90f97 100644 --- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java +++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java @@ -74,6 +74,7 @@ import static org.xmlpull.v1.XmlPullParser.START_TAG; import android.Manifest; import android.app.ActivityManager; import android.app.AppGlobals; +import android.app.AppOpsManager; import android.app.IActivityManager; import android.app.INotificationManager; import android.app.IProcessObserver; @@ -136,6 +137,7 @@ import android.util.SparseIntArray; import android.util.TrustedTime; import android.util.Xml; +import com.android.server.AppOpsService; import libcore.io.IoUtils; import com.android.internal.R; @@ -292,6 +294,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { private final AtomicFile mPolicyFile; + private final AppOpsManager mAppOps; + // TODO: keep whitelist of system-critical services that should never have // rules enforced, such as system, phone, and radio UIDs. @@ -326,6 +330,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { mSuppressDefaultPolicy = suppressDefaultPolicy; mPolicyFile = new AtomicFile(new File(systemDir, "netpolicy.xml")); + + mAppOps = context.getSystemService(AppOpsManager.class); } public void bindConnectivityManager(IConnectivityManager connManager) { @@ -1593,16 +1599,21 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } void addNetworkPolicyLocked(NetworkPolicy policy) { - NetworkPolicy[] policies = getNetworkPolicies(); + NetworkPolicy[] policies = getNetworkPolicies(mContext.getOpPackageName()); policies = ArrayUtils.appendElement(NetworkPolicy.class, policies, policy); setNetworkPolicies(policies); } @Override - public NetworkPolicy[] getNetworkPolicies() { + public NetworkPolicy[] getNetworkPolicies(String callingPackage) { mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG); mContext.enforceCallingOrSelfPermission(READ_PHONE_STATE, TAG); + if (mAppOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, Binder.getCallingUid(), + callingPackage) != AppOpsManager.MODE_ALLOWED) { + return new NetworkPolicy[0]; + } + synchronized (mRulesLock) { final int size = mNetworkPolicy.size(); final NetworkPolicy[] policies = new NetworkPolicy[size]; @@ -1614,7 +1625,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } private void normalizePoliciesLocked() { - normalizePoliciesLocked(getNetworkPolicies()); + normalizePoliciesLocked(getNetworkPolicies(mContext.getOpPackageName())); } private void normalizePoliciesLocked(NetworkPolicy[] policies) { diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index 5abbb50..a72172c 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -359,7 +359,8 @@ public class TelecomManager { public PhoneAccountHandle getDefaultOutgoingPhoneAccount(String uriScheme) { try { if (isServiceConnected()) { - return getTelecomService().getDefaultOutgoingPhoneAccount(uriScheme); + return getTelecomService().getDefaultOutgoingPhoneAccount(uriScheme, + mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#getDefaultOutgoingPhoneAccount", e); @@ -443,7 +444,7 @@ public class TelecomManager { public List<PhoneAccountHandle> getSimCallManagers() { try { if (isServiceConnected()) { - return getTelecomService().getSimCallManagers(); + return getTelecomService().getSimCallManagers(mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#getSimCallManagers"); @@ -491,7 +492,8 @@ public class TelecomManager { public List<PhoneAccountHandle> getPhoneAccountsSupportingScheme(String uriScheme) { try { if (isServiceConnected()) { - return getTelecomService().getPhoneAccountsSupportingScheme(uriScheme); + return getTelecomService().getPhoneAccountsSupportingScheme(uriScheme, + mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsSupportingScheme", e); @@ -511,7 +513,7 @@ public class TelecomManager { public List<PhoneAccountHandle> getCallCapablePhoneAccounts() { try { if (isServiceConnected()) { - return getTelecomService().getCallCapablePhoneAccounts(); + return getTelecomService().getCallCapablePhoneAccounts(mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#getCallCapablePhoneAccounts", e); @@ -711,7 +713,8 @@ public class TelecomManager { public boolean isVoiceMailNumber(PhoneAccountHandle accountHandle, String number) { try { if (isServiceConnected()) { - return getTelecomService().isVoiceMailNumber(accountHandle, number); + return getTelecomService().isVoiceMailNumber(accountHandle, number, + mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException calling ITelecomService#isVoiceMailNumber.", e); @@ -729,7 +732,8 @@ public class TelecomManager { public String getVoiceMailNumber(PhoneAccountHandle accountHandle) { try { if (isServiceConnected()) { - return getTelecomService().getVoiceMailNumber(accountHandle); + return getTelecomService().getVoiceMailNumber(accountHandle, + mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException calling ITelecomService#hasVoiceMailNumber.", e); @@ -746,7 +750,8 @@ public class TelecomManager { public String getLine1Number(PhoneAccountHandle accountHandle) { try { if (isServiceConnected()) { - return getTelecomService().getLine1Number(accountHandle); + return getTelecomService().getLine1Number(accountHandle, + mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException calling ITelecomService#getLine1Number.", e); @@ -764,7 +769,7 @@ public class TelecomManager { public boolean isInCall() { try { if (isServiceConnected()) { - return getTelecomService().isInCall(); + return getTelecomService().isInCall(mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException calling isInCall().", e); @@ -806,7 +811,7 @@ public class TelecomManager { public boolean isRinging() { try { if (isServiceConnected()) { - return getTelecomService().isRinging(); + return getTelecomService().isRinging(mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException attempting to get ringing state of phone app.", e); @@ -872,7 +877,7 @@ public class TelecomManager { public boolean isTtySupported() { try { if (isServiceConnected()) { - return getTelecomService().isTtySupported(); + return getTelecomService().isTtySupported(mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException attempting to get TTY supported state.", e); @@ -893,7 +898,7 @@ public class TelecomManager { public int getCurrentTtyMode() { try { if (isServiceConnected()) { - return getTelecomService().getCurrentTtyMode(); + return getTelecomService().getCurrentTtyMode(mContext.getOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException attempting to get the current TTY mode.", e); @@ -1045,7 +1050,7 @@ public class TelecomManager { ITelecomService service = getTelecomService(); if (service != null) { try { - service.showInCallScreen(showDialpad); + service.showInCallScreen(showDialpad, mContext.getOpPackageName()); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#showCallScreen", e); } diff --git a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl index 35db97f..727fd4b 100644 --- a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl +++ b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl @@ -33,12 +33,12 @@ interface ITelecomService { * * @param showDialpad if true, make the dialpad visible initially. */ - void showInCallScreen(boolean showDialpad); + void showInCallScreen(boolean showDialpad, String callingPackage); /** * @see TelecomServiceImpl#getDefaultOutgoingPhoneAccount */ - PhoneAccountHandle getDefaultOutgoingPhoneAccount(in String uriScheme); + PhoneAccountHandle getDefaultOutgoingPhoneAccount(in String uriScheme, String callingPackage); /** * @see TelecomServiceImpl#getUserSelectedOutgoingPhoneAccount @@ -53,12 +53,13 @@ interface ITelecomService { /** * @see TelecomServiceImpl#getCallCapablePhoneAccounts */ - List<PhoneAccountHandle> getCallCapablePhoneAccounts(); + List<PhoneAccountHandle> getCallCapablePhoneAccounts(String callingPackage); /** * @see TelecomManager#getPhoneAccountsSupportingScheme */ - List<PhoneAccountHandle> getPhoneAccountsSupportingScheme(in String uriScheme); + List<PhoneAccountHandle> getPhoneAccountsSupportingScheme(in String uriScheme, + String callingPackage); /** * @see TelecomManager#getPhoneAccountsForPackage @@ -98,7 +99,7 @@ interface ITelecomService { /** * @see TelecomServiceImpl#getSimCallManagers */ - List<PhoneAccountHandle> getSimCallManagers(); + List<PhoneAccountHandle> getSimCallManagers(String callingPackage); /** * @see TelecomServiceImpl#registerPhoneAccount @@ -118,17 +119,18 @@ interface ITelecomService { /** * @see TelecomServiceImpl#isVoiceMailNumber */ - boolean isVoiceMailNumber(in PhoneAccountHandle accountHandle, String number); + boolean isVoiceMailNumber(in PhoneAccountHandle accountHandle, String number, + String callingPackage); /** * @see TelecomServiceImpl#getVoiceMailNumber */ - String getVoiceMailNumber(in PhoneAccountHandle accountHandle); + String getVoiceMailNumber(in PhoneAccountHandle accountHandle, String callingPackage); /** * @see TelecomServiceImpl#getLine1Number */ - String getLine1Number(in PhoneAccountHandle accountHandle); + String getLine1Number(in PhoneAccountHandle accountHandle, String callingPackage); /** * @see TelecomServiceImpl#getDefaultPhoneApp @@ -147,12 +149,12 @@ interface ITelecomService { /** * @see TelecomServiceImpl#isInCall */ - boolean isInCall(); + boolean isInCall(String callingPackage); /** * @see TelecomServiceImpl#isRinging */ - boolean isRinging(); + boolean isRinging(String callingPackage); /** * @see TelecomServiceImpl#getCallState @@ -192,12 +194,12 @@ interface ITelecomService { /** * @see TelecomServiceImpl#isTtySupported */ - boolean isTtySupported(); + boolean isTtySupported(String callingPackage); /** * @see TelecomServiceImpl#getCurrentTtyMode */ - int getCurrentTtyMode(); + int getCurrentTtyMode(String callingPackage); /** * @see TelecomServiceImpl#addNewIncomingCall diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index 08aec08..3ecf5ac 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -272,10 +272,6 @@ public class SubscriptionManager { * for #onSubscriptionsChanged to be invoked. */ public static class OnSubscriptionsChangedListener { - /** @hide */ - public static final String PERMISSION_ON_SUBSCRIPTIONS_CHANGED = - android.Manifest.permission.READ_PHONE_STATE; - private final Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 128f6e3..cd3f636 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -664,7 +664,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony == null) return null; - return telephony.getDeviceId(); + return telephony.getDeviceId(mContext.getOpPackageName()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1975,7 +1975,7 @@ public class TelephonyManager { try { ITelephony telephony = getITelephony(); if (telephony != null) - number = telephony.getLine1NumberForDisplay(subId); + number = telephony.getLine1NumberForDisplay(subId, mContext.getOpPackageName()); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -2096,7 +2096,8 @@ public class TelephonyManager { try { ITelephony telephony = getITelephony(); if (telephony != null) - alphaTag = telephony.getLine1AlphaTagForDisplay(subId); + alphaTag = telephony.getLine1AlphaTagForDisplay(subId, + mContext.getOpPackageName()); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -3342,7 +3343,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony == null) return new String[0]; - return telephony.getPcscfAddress(apnType); + return telephony.getPcscfAddress(apnType, mContext.getOpPackageName()); } catch (RemoteException e) { return new String[0]; } @@ -3759,7 +3760,7 @@ public class TelephonyManager { try { ITelephony telephony = getITelephony(); if (telephony != null) - return telephony.isSimPinEnabled(); + return telephony.isSimPinEnabled(mContext.getOpPackageName()); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isSimPinEnabled", e); } @@ -4026,7 +4027,7 @@ public class TelephonyManager { try { ITelephony telephony = getITelephony(); if (telephony != null) - return telephony.isVideoCallingEnabled(); + return telephony.isVideoCallingEnabled(mContext.getOpPackageName()); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isVideoCallingEnabled", e); } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index a24859b..4fe88c4 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -45,6 +45,7 @@ interface ITelephony { /** * Place a call to the specified number. + * @param callingPackage The package making the call. * @param number the number to be called. */ void call(String callingPackage, String number); @@ -169,8 +170,9 @@ interface ITelephony { /** * Check if the SIM pin lock is enabled. * @return true if the SIM pin lock is enabled. + * @param callingPackage The package making the call. */ - boolean isSimPinEnabled(); + boolean isSimPinEnabled(String callingPackage); /** * Supply a pin to unlock the SIM. Blocks until a result is determined. @@ -644,10 +646,11 @@ interface ITelephony { /* * Get the calculated preferred network type. * Used for device configuration by some CDMA operators. + * @param callingPackage The package making the call. * * @return the calculated preferred network type, defined in RILConstants.java. */ - int getCalculatedPreferredNetworkType(); + int getCalculatedPreferredNetworkType(String callingPackage); /* * Get the preferred network type. @@ -701,8 +704,9 @@ interface ITelephony { /** * Get P-CSCF address from PCO after data connection is established or modified. * @param apnType the apnType, "ims" for IMS APN, "emergency" for EMERGENCY APN + * @param callingPackage The package making the call. */ - String[] getPcscfAddress(String apnType); + String[] getPcscfAddress(String apnType, String callingPackage); /** * Set IMS registration state @@ -768,19 +772,21 @@ interface ITelephony { * {@link #setLine1NumberForDisplay}. Otherwise returns null. * * @param subId whose dialing number for line 1 is returned. + * @param callingPackage The package making the call. * @return the displayed dialing number if set, or null if not set. */ - String getLine1NumberForDisplay(int subId); + String getLine1NumberForDisplay(int subId, String callingPackage); /** * Returns the displayed alphatag of the dialing number if it was set * previously via {@link #setLine1NumberForDisplay}. Otherwise returns null. * * @param subId whose alphatag associated with line 1 is returned. + * @param callingPackage The package making the call. * @return the displayed alphatag of the dialing number if set, or null if * not set. */ - String getLine1AlphaTagForDisplay(int subId); + String getLine1AlphaTagForDisplay(int subId, String callingPackage); String[] getMergedSubscriberIds(); @@ -872,9 +878,10 @@ interface ITelephony { /** * Whether video calling has been enabled by the user. * + * @param callingPackage The package making the call. * @return {@code true} if the user has enabled video calling, {@code false} otherwise. */ - boolean isVideoCallingEnabled(); + boolean isVideoCallingEnabled(String callingPackage); /** * Whether the DTMF tone length can be changed. @@ -925,10 +932,11 @@ interface ITelephony { * Returns the unique device ID of phone, for example, the IMEI for * GSM and the MEID for CDMA phones. Return null if device ID is not available. * + * @param callingPackage The package making the call. * <p>Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ - String getDeviceId(); + String getDeviceId(String callingPackage); /** * Returns the subscription ID associated with the specified PhoneAccount. diff --git a/test-runner/src/android/test/mock/MockContext.java b/test-runner/src/android/test/mock/MockContext.java index b265d47..04ded9d 100644 --- a/test-runner/src/android/test/mock/MockContext.java +++ b/test-runner/src/android/test/mock/MockContext.java @@ -354,6 +354,13 @@ public class MockContext extends Context { throw new UnsupportedOperationException(); } + /** @hide */ + @Override + public void sendBroadcastAsUser(Intent intent, UserHandle user, + String receiverPermission, int appOp) { + throw new UnsupportedOperationException(); + } + @Override public void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler, |