Loading services/core/java/com/android/server/MmsServiceBroker.java +15 −4 Original line number Original line Diff line number Diff line Loading @@ -16,8 +16,6 @@ package com.android.server; package com.android.server; import com.android.internal.telephony.IMms; import android.Manifest; import android.Manifest; import android.app.AppOpsManager; import android.app.AppOpsManager; import android.app.PendingIntent; import android.app.PendingIntent; Loading @@ -38,6 +36,8 @@ import android.os.SystemClock; import android.telephony.TelephonyManager; import android.telephony.TelephonyManager; import android.util.Slog; import android.util.Slog; import com.android.internal.telephony.IMms; /** /** * This class is a proxy for MmsService APIs. We need this because MmsService runs * This class is a proxy for MmsService APIs. We need this because MmsService runs * in phone process and may crash anytime. This manages a connection to the actual * in phone process and may crash anytime. This manages a connection to the actual Loading Loading @@ -118,7 +118,7 @@ public class MmsServiceBroker extends SystemService { } } public void systemRunning() { public void systemRunning() { tryConnecting(); Slog.i(TAG, "Delay connecting to MmsService until an API is called"); } } private void tryConnecting() { private void tryConnecting() { Loading Loading @@ -206,7 +206,7 @@ public class MmsServiceBroker extends SystemService { * Throws a security exception unless the caller has carrier privilege. * Throws a security exception unless the caller has carrier privilege. */ */ private void enforceCarrierPrivilege() { private void enforceCarrierPrivilege() { String[] packages = getPackageManager().getPackagesForUid(Binder.getCallingUid()); final String[] packages = getPackageManager().getPackagesForUid(Binder.getCallingUid()); for (String pkg : packages) { for (String pkg : packages) { if (getTelephonyManager().checkCarrierPrivilegesForPackage(pkg) == if (getTelephonyManager().checkCarrierPrivilegesForPackage(pkg) == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) { TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) { Loading @@ -216,12 +216,21 @@ public class MmsServiceBroker extends SystemService { throw new SecurityException("No carrier privilege"); throw new SecurityException("No carrier privilege"); } } private String getCallingPackageName() { final String[] packages = getPackageManager().getPackagesForUid(Binder.getCallingUid()); if (packages != null && packages.length > 0) { return packages[0]; } return "unknown"; } // Service API calls implementation, proxied to the real MmsService in "com.android.mms.service" // Service API calls implementation, proxied to the real MmsService in "com.android.mms.service" private final class BinderService extends IMms.Stub { private final class BinderService extends IMms.Stub { @Override @Override public void sendMessage(int subId, String callingPkg, Uri contentUri, public void sendMessage(int subId, String callingPkg, Uri contentUri, String locationUrl, Bundle configOverrides, PendingIntent sentIntent) String locationUrl, Bundle configOverrides, PendingIntent sentIntent) throws RemoteException { throws RemoteException { Slog.d(TAG, "sendMessage() by " + callingPkg); mContext.enforceCallingPermission(Manifest.permission.SEND_SMS, "Send MMS message"); mContext.enforceCallingPermission(Manifest.permission.SEND_SMS, "Send MMS message"); if (getAppOpsManager().noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(), if (getAppOpsManager().noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(), callingPkg) != AppOpsManager.MODE_ALLOWED) { callingPkg) != AppOpsManager.MODE_ALLOWED) { Loading @@ -235,6 +244,7 @@ public class MmsServiceBroker extends SystemService { public void downloadMessage(int subId, String callingPkg, String locationUrl, public void downloadMessage(int subId, String callingPkg, String locationUrl, Uri contentUri, Bundle configOverrides, Uri contentUri, Bundle configOverrides, PendingIntent downloadedIntent) throws RemoteException { PendingIntent downloadedIntent) throws RemoteException { Slog.d(TAG, "downloadMessage() by " + callingPkg); mContext.enforceCallingPermission(Manifest.permission.RECEIVE_MMS, mContext.enforceCallingPermission(Manifest.permission.RECEIVE_MMS, "Download MMS message"); "Download MMS message"); if (getAppOpsManager().noteOp(AppOpsManager.OP_RECEIVE_MMS, Binder.getCallingUid(), if (getAppOpsManager().noteOp(AppOpsManager.OP_RECEIVE_MMS, Binder.getCallingUid(), Loading @@ -260,6 +270,7 @@ public class MmsServiceBroker extends SystemService { @Override @Override public Bundle getCarrierConfigValues(int subId) throws RemoteException { public Bundle getCarrierConfigValues(int subId) throws RemoteException { Slog.d(TAG, "getCarrierConfigValues() by " + getCallingPackageName()); return getServiceGuarded().getCarrierConfigValues(subId); return getServiceGuarded().getCarrierConfigValues(subId); } } Loading Loading
services/core/java/com/android/server/MmsServiceBroker.java +15 −4 Original line number Original line Diff line number Diff line Loading @@ -16,8 +16,6 @@ package com.android.server; package com.android.server; import com.android.internal.telephony.IMms; import android.Manifest; import android.Manifest; import android.app.AppOpsManager; import android.app.AppOpsManager; import android.app.PendingIntent; import android.app.PendingIntent; Loading @@ -38,6 +36,8 @@ import android.os.SystemClock; import android.telephony.TelephonyManager; import android.telephony.TelephonyManager; import android.util.Slog; import android.util.Slog; import com.android.internal.telephony.IMms; /** /** * This class is a proxy for MmsService APIs. We need this because MmsService runs * This class is a proxy for MmsService APIs. We need this because MmsService runs * in phone process and may crash anytime. This manages a connection to the actual * in phone process and may crash anytime. This manages a connection to the actual Loading Loading @@ -118,7 +118,7 @@ public class MmsServiceBroker extends SystemService { } } public void systemRunning() { public void systemRunning() { tryConnecting(); Slog.i(TAG, "Delay connecting to MmsService until an API is called"); } } private void tryConnecting() { private void tryConnecting() { Loading Loading @@ -206,7 +206,7 @@ public class MmsServiceBroker extends SystemService { * Throws a security exception unless the caller has carrier privilege. * Throws a security exception unless the caller has carrier privilege. */ */ private void enforceCarrierPrivilege() { private void enforceCarrierPrivilege() { String[] packages = getPackageManager().getPackagesForUid(Binder.getCallingUid()); final String[] packages = getPackageManager().getPackagesForUid(Binder.getCallingUid()); for (String pkg : packages) { for (String pkg : packages) { if (getTelephonyManager().checkCarrierPrivilegesForPackage(pkg) == if (getTelephonyManager().checkCarrierPrivilegesForPackage(pkg) == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) { TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) { Loading @@ -216,12 +216,21 @@ public class MmsServiceBroker extends SystemService { throw new SecurityException("No carrier privilege"); throw new SecurityException("No carrier privilege"); } } private String getCallingPackageName() { final String[] packages = getPackageManager().getPackagesForUid(Binder.getCallingUid()); if (packages != null && packages.length > 0) { return packages[0]; } return "unknown"; } // Service API calls implementation, proxied to the real MmsService in "com.android.mms.service" // Service API calls implementation, proxied to the real MmsService in "com.android.mms.service" private final class BinderService extends IMms.Stub { private final class BinderService extends IMms.Stub { @Override @Override public void sendMessage(int subId, String callingPkg, Uri contentUri, public void sendMessage(int subId, String callingPkg, Uri contentUri, String locationUrl, Bundle configOverrides, PendingIntent sentIntent) String locationUrl, Bundle configOverrides, PendingIntent sentIntent) throws RemoteException { throws RemoteException { Slog.d(TAG, "sendMessage() by " + callingPkg); mContext.enforceCallingPermission(Manifest.permission.SEND_SMS, "Send MMS message"); mContext.enforceCallingPermission(Manifest.permission.SEND_SMS, "Send MMS message"); if (getAppOpsManager().noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(), if (getAppOpsManager().noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(), callingPkg) != AppOpsManager.MODE_ALLOWED) { callingPkg) != AppOpsManager.MODE_ALLOWED) { Loading @@ -235,6 +244,7 @@ public class MmsServiceBroker extends SystemService { public void downloadMessage(int subId, String callingPkg, String locationUrl, public void downloadMessage(int subId, String callingPkg, String locationUrl, Uri contentUri, Bundle configOverrides, Uri contentUri, Bundle configOverrides, PendingIntent downloadedIntent) throws RemoteException { PendingIntent downloadedIntent) throws RemoteException { Slog.d(TAG, "downloadMessage() by " + callingPkg); mContext.enforceCallingPermission(Manifest.permission.RECEIVE_MMS, mContext.enforceCallingPermission(Manifest.permission.RECEIVE_MMS, "Download MMS message"); "Download MMS message"); if (getAppOpsManager().noteOp(AppOpsManager.OP_RECEIVE_MMS, Binder.getCallingUid(), if (getAppOpsManager().noteOp(AppOpsManager.OP_RECEIVE_MMS, Binder.getCallingUid(), Loading @@ -260,6 +270,7 @@ public class MmsServiceBroker extends SystemService { @Override @Override public Bundle getCarrierConfigValues(int subId) throws RemoteException { public Bundle getCarrierConfigValues(int subId) throws RemoteException { Slog.d(TAG, "getCarrierConfigValues() by " + getCallingPackageName()); return getServiceGuarded().getCarrierConfigValues(subId); return getServiceGuarded().getCarrierConfigValues(subId); } } Loading