I am trying to understand the native Android Code Base. I would like to know the part of the code where permissions are checked. For eg if I want to send an SMS, I need the function : public void sendDataMessage (String destinationAddress, String scAddress, short destinationPort, byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent) Together with this I need to declare the permission SEND_SMS in the Android Manifest. If I dont declare the permission, I get a security Exception. But I didn't find this part in the code in the SmsManager.java. This is the function:
public void sendDataMessage(
String destinationAddress, String scAddress, short destinationPort,
byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent) {
if (TextUtils.isEmpty(destinationAddress)) {
throw new IllegalArgumentException("Invalid destinationAddress");
}
if (data == null || data.length == 0) {
throw new IllegalArgumentException("Invalid message data");
}
try {
ISms iccISms = getISmsServiceOrThrow();
iccISms.sendDataForSubscriber(getSubscriptionId(), ActivityThread.currentPackageName(),
destinationAddress, scAddress, destinationPort & 0xFFFF,
data, sentIntent, deliveryIntent);
} catch (RemoteException ex) {
// ignore it
}
}
So where exactly are the permissions checked. I am looking for the part of the code where before sending the SMS, Android checks for the SEND_SMS permission. I was expecting a call to various permission Check functions in the PackageManager but it is not the case. I found a few similar questions here where they talk about how the packages are linked to linux users. But I would like to go through the code where it is precisely checked.