Merge "Adds read/modify permission checks to ImsService"
This commit is contained in:
@@ -41,6 +41,9 @@ import com.android.ims.internal.IImsServiceFeatureListener;
|
|||||||
import com.android.ims.internal.IImsUt;
|
import com.android.ims.internal.IImsUt;
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
|
|
||||||
|
import static android.Manifest.permission.MODIFY_PHONE_STATE;
|
||||||
|
import static android.Manifest.permission.READ_PHONE_STATE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main ImsService implementation, which binds via the Telephony ImsResolver. Services that extend
|
* Main ImsService implementation, which binds via the Telephony ImsResolver. Services that extend
|
||||||
* ImsService must register the service in their AndroidManifest to be detected by the framework.
|
* ImsService must register the service in their AndroidManifest to be detected by the framework.
|
||||||
@@ -94,6 +97,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
public void createImsFeature(int slotId, int feature, IImsFeatureStatusCallback c)
|
public void createImsFeature(int slotId, int feature, IImsFeatureStatusCallback c)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
|
enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "createImsFeature");
|
||||||
onCreateImsFeatureInternal(slotId, feature, c);
|
onCreateImsFeatureInternal(slotId, feature, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,6 +105,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
@Override
|
@Override
|
||||||
public void removeImsFeature(int slotId, int feature) throws RemoteException {
|
public void removeImsFeature(int slotId, int feature) throws RemoteException {
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
|
enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "removeImsFeature");
|
||||||
onRemoveImsFeatureInternal(slotId, feature);
|
onRemoveImsFeatureInternal(slotId, feature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,6 +113,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
@Override
|
@Override
|
||||||
public int startSession(int slotId, int featureType, PendingIntent incomingCallIntent,
|
public int startSession(int slotId, int featureType, PendingIntent incomingCallIntent,
|
||||||
IImsRegistrationListener listener) throws RemoteException {
|
IImsRegistrationListener listener) throws RemoteException {
|
||||||
|
enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "startSession");
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
@@ -120,6 +126,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
@Override
|
@Override
|
||||||
public void endSession(int slotId, int featureType, int sessionId) throws RemoteException {
|
public void endSession(int slotId, int featureType, int sessionId) throws RemoteException {
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
|
enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "endSession");
|
||||||
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
feature.endSession(sessionId);
|
feature.endSession(sessionId);
|
||||||
@@ -130,6 +137,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isConnected(int slotId, int featureType, int callSessionType, int callType)
|
public boolean isConnected(int slotId, int featureType, int callSessionType, int callType)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
enforceCallingOrSelfPermission(READ_PHONE_STATE, "isConnected");
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
@@ -141,6 +149,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOpened(int slotId, int featureType) throws RemoteException {
|
public boolean isOpened(int slotId, int featureType) throws RemoteException {
|
||||||
|
enforceCallingOrSelfPermission(READ_PHONE_STATE, "isOpened");
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
@@ -152,6 +161,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFeatureStatus(int slotId, int featureType) throws RemoteException {
|
public int getFeatureStatus(int slotId, int featureType) throws RemoteException {
|
||||||
|
enforceCallingOrSelfPermission(READ_PHONE_STATE, "getFeatureStatus");
|
||||||
int status = ImsFeature.STATE_NOT_AVAILABLE;
|
int status = ImsFeature.STATE_NOT_AVAILABLE;
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
SparseArray<ImsFeature> featureMap = mFeatures.get(slotId);
|
SparseArray<ImsFeature> featureMap = mFeatures.get(slotId);
|
||||||
@@ -168,6 +178,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
@Override
|
@Override
|
||||||
public void addRegistrationListener(int slotId, int featureType,
|
public void addRegistrationListener(int slotId, int featureType,
|
||||||
IImsRegistrationListener listener) throws RemoteException {
|
IImsRegistrationListener listener) throws RemoteException {
|
||||||
|
enforceCallingOrSelfPermission(READ_PHONE_STATE, "addRegistrationListener");
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
@@ -179,6 +190,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
@Override
|
@Override
|
||||||
public void removeRegistrationListener(int slotId, int featureType,
|
public void removeRegistrationListener(int slotId, int featureType,
|
||||||
IImsRegistrationListener listener) throws RemoteException {
|
IImsRegistrationListener listener) throws RemoteException {
|
||||||
|
enforceCallingOrSelfPermission(READ_PHONE_STATE, "removeRegistrationListener");
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
@@ -190,6 +202,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
@Override
|
@Override
|
||||||
public ImsCallProfile createCallProfile(int slotId, int featureType, int sessionId,
|
public ImsCallProfile createCallProfile(int slotId, int featureType, int sessionId,
|
||||||
int callSessionType, int callType) throws RemoteException {
|
int callSessionType, int callType) throws RemoteException {
|
||||||
|
enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "createCallProfile");
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
@@ -202,6 +215,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
@Override
|
@Override
|
||||||
public IImsCallSession createCallSession(int slotId, int featureType, int sessionId,
|
public IImsCallSession createCallSession(int slotId, int featureType, int sessionId,
|
||||||
ImsCallProfile profile, IImsCallSessionListener listener) throws RemoteException {
|
ImsCallProfile profile, IImsCallSessionListener listener) throws RemoteException {
|
||||||
|
enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "createCallSession");
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
@@ -214,6 +228,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
@Override
|
@Override
|
||||||
public IImsCallSession getPendingCallSession(int slotId, int featureType, int sessionId,
|
public IImsCallSession getPendingCallSession(int slotId, int featureType, int sessionId,
|
||||||
String callId) throws RemoteException {
|
String callId) throws RemoteException {
|
||||||
|
enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "getPendingCallSession");
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
@@ -226,6 +241,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
@Override
|
@Override
|
||||||
public IImsUt getUtInterface(int slotId, int featureType)
|
public IImsUt getUtInterface(int slotId, int featureType)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "getUtInterface");
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
@@ -238,6 +254,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
@Override
|
@Override
|
||||||
public IImsConfig getConfigInterface(int slotId, int featureType)
|
public IImsConfig getConfigInterface(int slotId, int featureType)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "getConfigInterface");
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
@@ -249,6 +266,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void turnOnIms(int slotId, int featureType) throws RemoteException {
|
public void turnOnIms(int slotId, int featureType) throws RemoteException {
|
||||||
|
enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "turnOnIms");
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
@@ -259,6 +277,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void turnOffIms(int slotId, int featureType) throws RemoteException {
|
public void turnOffIms(int slotId, int featureType) throws RemoteException {
|
||||||
|
enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "turnOffIms");
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
@@ -270,6 +289,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
@Override
|
@Override
|
||||||
public IImsEcbm getEcbmInterface(int slotId, int featureType)
|
public IImsEcbm getEcbmInterface(int slotId, int featureType)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "getEcbmInterface");
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
@@ -282,6 +302,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
@Override
|
@Override
|
||||||
public void setUiTTYMode(int slotId, int featureType, int uiTtyMode, Message onComplete)
|
public void setUiTTYMode(int slotId, int featureType, int uiTtyMode, Message onComplete)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "setUiTTYMode");
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
@@ -293,6 +314,7 @@ public abstract class ImsService extends ImsServiceBase {
|
|||||||
@Override
|
@Override
|
||||||
public IImsMultiEndpoint getMultiEndpointInterface(int slotId, int featureType)
|
public IImsMultiEndpoint getMultiEndpointInterface(int slotId, int featureType)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, "getMultiEndpointInterface");
|
||||||
synchronized (mFeatures) {
|
synchronized (mFeatures) {
|
||||||
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
MMTelFeature feature = resolveMMTelFeature(slotId, featureType);
|
||||||
if (feature != null) {
|
if (feature != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user