Loading src/java/com/android/internal/telephony/BtSmsInterfaceManager.java 0 → 100644 +121 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.telephony; import android.app.ActivityThread; import android.app.PendingIntent; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothMapClient; import android.bluetooth.BluetoothProfile; import android.net.Uri; import android.telecom.PhoneAccount; import android.telephony.SmsManager; import android.telephony.SubscriptionInfo; import android.util.Log; /** * BtSmsInterfaceManager to provide a mechanism for sending SMS over Bluetooth */ public class BtSmsInterfaceManager { private static final String LOG_TAG = "BtSmsInterfaceManager"; /** * Sends text through connected Bluetooth device */ public void sendText(String destAddr, String text, PendingIntent sentIntent, PendingIntent deliveryIntent, SubscriptionInfo info) { BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); if (btAdapter == null) { // No bluetooth service on this platform? sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_NO_SERVICE); return; } BluetoothDevice device = btAdapter.getRemoteDevice(info.getIccId()); if (device == null) { Log.d(LOG_TAG, "Bluetooth device addr invalid: " + info.getIccId()); sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_NO_SERVICE); return; } btAdapter.getProfileProxy(ActivityThread.currentApplication().getApplicationContext(), new MapMessageSender(destAddr, text, device, sentIntent, deliveryIntent), BluetoothProfile.MAP_CLIENT); } private void sendErrorInPendingIntent(PendingIntent intent, int errorCode) { if (intent == null) { return; } try { intent.send(errorCode); } catch (PendingIntent.CanceledException e) { // PendingIntent is cancelled. ignore sending this error code back to // caller. Log.d(LOG_TAG, "PendingIntent.CanceledException: " + e.getMessage()); } } private class MapMessageSender implements BluetoothProfile.ServiceListener { final Uri[] mDestAddr; private String mMessage; final BluetoothDevice mDevice; final PendingIntent mSentIntent; final PendingIntent mDeliveryIntent; MapMessageSender(final String destAddr, final String message, final BluetoothDevice device, final PendingIntent sentIntent, final PendingIntent deliveryIntent) { super(); mDestAddr = new Uri[]{new Uri.Builder() .appendPath(destAddr) .scheme(PhoneAccount.SCHEME_TEL) .build()}; mMessage = message; mDevice = device; mSentIntent = sentIntent; mDeliveryIntent = deliveryIntent; } @Override public void onServiceConnected(int profile, BluetoothProfile proxy) { Log.d(LOG_TAG, "Service connected"); if (profile != BluetoothProfile.MAP_CLIENT) { return; } BluetoothMapClient mapProfile = (BluetoothMapClient) proxy; if (mMessage != null) { Log.d(LOG_TAG, "Sending message thru bluetooth"); mapProfile.sendMessage(mDevice, mDestAddr, mMessage, mSentIntent, mDeliveryIntent); mMessage = null; } BluetoothAdapter.getDefaultAdapter() .closeProfileProxy(BluetoothProfile.MAP_CLIENT, mapProfile); } @Override public void onServiceDisconnected(int profile) { if (mMessage != null) { Log.d(LOG_TAG, "Bluetooth disconnected before sending the message"); sendErrorInPendingIntent(mSentIntent, SmsManager.RESULT_ERROR_NO_SERVICE); mMessage = null; } } } } src/java/com/android/internal/telephony/CellularNetworkService.java +6 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.telephony; import android.hardware.radio.V1_0.CellInfoType; import android.hardware.radio.V1_0.RegState; import android.hardware.radio.V1_4.DataRegStateResult.VopsInfo.hidl_discriminator; import android.os.AsyncResult; import android.os.Handler; import android.os.HandlerThread; Loading Loading @@ -317,7 +318,11 @@ public class CellularNetworkService extends NetworkService { CellIdentity cellIdentity = convertHalCellIdentityToCellIdentity(dataRegState.base.cellIdentity); android.hardware.radio.V1_4.NrIndicators nrIndicators = dataRegState.nrIndicators; if (AccessNetworkType.EUTRAN == accessNetworkTechnology) { // Check for lteVopsInfo only if its initialized and RAT is EUTRAN if (dataRegState.vopsInfo.getDiscriminator() == hidl_discriminator.lteVopsInfo && ServiceState.rilRadioTechnologyToAccessNetworkType(dataRegState.base.rat) == AccessNetworkType.EUTRAN) { android.hardware.radio.V1_4.LteVopsInfo vopsSupport = dataRegState.vopsInfo.lteVopsInfo(); lteVopsSupportInfo = convertHalLteVopsSupportInfo(vopsSupport.isVopsSupported, Loading src/java/com/android/internal/telephony/GsmCdmaPhone.java +1 −46 Original line number Diff line number Diff line Loading @@ -78,7 +78,6 @@ import com.android.ims.ImsManager; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.cdma.CdmaMmiCode; import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager; import com.android.internal.telephony.cdma.EriManager; import com.android.internal.telephony.dataconnection.DataEnabledSettings; import com.android.internal.telephony.dataconnection.DcTracker; import com.android.internal.telephony.dataconnection.TransportManager; Loading Loading @@ -142,11 +141,7 @@ public class GsmCdmaPhone extends Phone { public static final int CANCEL_ECM_TIMER = 1; // cancel Ecm timer private CdmaSubscriptionSourceManager mCdmaSSM; public int mCdmaSubscriptionSource = CdmaSubscriptionSourceManager.SUBSCRIPTION_SOURCE_UNKNOWN; @UnsupportedAppUsage public EriManager mEriManager; private PowerManager.WakeLock mWakeLock; // mEriFileLoadedRegistrants are informed after the ERI text has been loaded private final RegistrantList mEriFileLoadedRegistrants = new RegistrantList(); // mEcmExitRespRegistrant is informed after the phone has been exited @UnsupportedAppUsage private Registrant mEcmExitRespRegistrant; Loading Loading @@ -333,8 +328,6 @@ public class GsmCdmaPhone extends Phone { mCdmaSSM = mTelephonyComponentFactory.inject(CdmaSubscriptionSourceManager.class.getName()) .getCdmaSubscriptionSourceManagerInstance(mContext, mCi, this, EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED, null); mEriManager = mTelephonyComponentFactory.inject(EriManager.class.getName()) .makeEriManager(this, mContext, EriManager.ERI_FROM_XML); mCi.setEmergencyCallbackMode(this, EVENT_EMERGENCY_CALLBACK_MODE_ENTER, null); mCi.registerForExitEmergencyCallbackMode(this, EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE, null); Loading Loading @@ -2542,11 +2535,6 @@ public class GsmCdmaPhone extends Phone { } else { loge("didn't get the cdma_roaming_mode changes from the carrier config."); } // Load the ERI based on carrier config. Carrier might have their specific ERI. prepareEri(); mSST.pollState(); break; case EVENT_SET_ROAMING_PREFERENCE_DONE: Loading Loading @@ -2958,38 +2946,6 @@ public class GsmCdmaPhone extends Phone { return mIccPhoneBookIntManager; } //CDMA public void registerForEriFileLoaded(Handler h, int what, Object obj) { Registrant r = new Registrant (h, what, obj); mEriFileLoadedRegistrants.add(r); } //CDMA public void unregisterForEriFileLoaded(Handler h) { mEriFileLoadedRegistrants.remove(h); } //CDMA public void prepareEri() { if (mEriManager == null) { Rlog.e(LOG_TAG, "PrepareEri: Trying to access stale objects"); return; } mEriManager.loadEriFile(); if(mEriManager.isEriFileLoaded()) { // when the ERI file is loaded logd("ERI read, notify registrants"); mEriFileLoadedRegistrants.notifyRegistrants(); } } //CDMA @UnsupportedAppUsage public boolean isEriFileLoaded() { return mEriManager.isEriFileLoaded(); } /** * Activate or deactivate cell broadcast SMS. * Loading Loading @@ -3466,7 +3422,7 @@ public class GsmCdmaPhone extends Phone { } else { int roamInd = getServiceState().getCdmaRoamingIndicator(); int defRoamInd = getServiceState().getCdmaDefaultRoamingIndicator(); return mEriManager.getCdmaEriText(roamInd, defRoamInd); return mSST.getCdmaEriText(roamInd, defRoamInd); } } Loading Loading @@ -3675,7 +3631,6 @@ public class GsmCdmaPhone extends Phone { if (VDBG) pw.println(" mVmNumber=" + mVmNumber); pw.println(" mCdmaSSM=" + mCdmaSSM); pw.println(" mCdmaSubscriptionSource=" + mCdmaSubscriptionSource); pw.println(" mEriManager=" + mEriManager); pw.println(" mWakeLock=" + mWakeLock); pw.println(" isInEcm()=" + isInEcm()); if (VDBG) pw.println(" mEsn=" + mEsn); Loading src/java/com/android/internal/telephony/IccSmsInterfaceManager.java +13 −98 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.app.AppOpsManager; import android.app.PendingIntent; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.database.Cursor; import android.database.sqlite.SQLiteException; Loading @@ -37,7 +36,6 @@ import android.os.Handler; import android.os.Message; import android.os.UserManager; import android.provider.Telephony; import android.service.carrier.CarrierMessagingService; import android.telephony.Rlog; import android.telephony.SmsManager; import android.telephony.SmsMessage; Loading Loading @@ -96,6 +94,7 @@ public class IccSmsInterfaceManager { final protected AppOpsManager mAppOps; @VisibleForTesting public SmsDispatchersController mDispatchersController; private SmsPermissions mSmsPermissions; private final LocalLog mCellBroadcastLocalLog = new LocalLog(100); Loading Loading @@ -157,6 +156,7 @@ public class IccSmsInterfaceManager { mContext = context; mAppOps = appOps; mDispatchersController = dispatchersController; mSmsPermissions = new SmsPermissions(phone, context, appOps); } protected void markMessagesAsRead(ArrayList<byte[]> messages) { Loading Loading @@ -344,7 +344,7 @@ public class IccSmsInterfaceManager { */ public void sendDataWithSelfPermissions(String callingPackage, String destAddr, String scAddr, int destPort, byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent) { if (!checkCallingOrSelfSendSmsPermission(callingPackage, "Sending SMS message")) { if (!mSmsPermissions.checkCallingOrSelfCanSendSms(callingPackage, "Sending SMS message")) { returnUnspecifiedFailure(sentIntent); return; } Loading @@ -359,7 +359,7 @@ public class IccSmsInterfaceManager { @UnsupportedAppUsage public void sendData(String callingPackage, String destAddr, String scAddr, int destPort, byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent) { if (!checkCallingSendSmsPermission(callingPackage, "Sending SMS message")) { if (!mSmsPermissions.checkCallingCanSendSms(callingPackage, "Sending SMS message")) { returnUnspecifiedFailure(sentIntent); return; } Loading Loading @@ -409,15 +409,11 @@ public class IccSmsInterfaceManager { /** * A permissions check before passing to {@link IccSmsInterfaceManager#sendTextInternal}. * This method checks only if the calling package has the permission to send the sms. * Note: SEND_SMS permission should be checked by the caller of this method */ public void sendText(String callingPackage, String destAddr, String scAddr, String text, PendingIntent sentIntent, PendingIntent deliveryIntent, boolean persistMessageForNonDefaultSmsApp) { if (!checkCallingSendTextPermissions( persistMessageForNonDefaultSmsApp, callingPackage, "Sending SMS message")) { returnUnspecifiedFailure(sentIntent); return; } sendTextInternal(callingPackage, destAddr, scAddr, text, sentIntent, deliveryIntent, persistMessageForNonDefaultSmsApp, SMS_MESSAGE_PRIORITY_NOT_SPECIFIED, false /* expectMore */, SMS_MESSAGE_PERIOD_NOT_SPECIFIED); Loading @@ -430,7 +426,7 @@ public class IccSmsInterfaceManager { public void sendTextWithSelfPermissions(String callingPackage, String destAddr, String scAddr, String text, PendingIntent sentIntent, PendingIntent deliveryIntent, boolean persistMessage) { if (!checkCallingOrSelfSendSmsPermission(callingPackage, "Sending SMS message")) { if (!mSmsPermissions.checkCallingOrSelfCanSendSms(callingPackage, "Sending SMS message")) { returnUnspecifiedFailure(sentIntent); return; } Loading Loading @@ -552,7 +548,7 @@ public class IccSmsInterfaceManager { String text, PendingIntent sentIntent, PendingIntent deliveryIntent, boolean persistMessageForNonDefaultSmsApp, int priority, boolean expectMore, int validityPeriod) { if (!checkCallingOrSelfSendSmsPermission(callingPackage, "Sending SMS message")) { if (!mSmsPermissions.checkCallingOrSelfCanSendSms(callingPackage, "Sending SMS message")) { returnUnspecifiedFailure(sentIntent); return; } Loading @@ -574,7 +570,7 @@ public class IccSmsInterfaceManager { public void injectSmsPdu(byte[] pdu, String format, PendingIntent receivedIntent) { if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { enforceCallerIsImsAppOrCarrierApp("injectSmsPdu"); mSmsPermissions.enforceCallerIsImsAppOrCarrierApp("injectSmsPdu"); } if (Rlog.isLoggable("SMS", Log.VERBOSE)) { Loading Loading @@ -681,7 +677,7 @@ public class IccSmsInterfaceManager { String scAddr, List<String> parts, List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents, boolean persistMessageForNonDefaultSmsApp, int priority, boolean expectMore, int validityPeriod) { if (!checkCallingSendTextPermissions( if (!mSmsPermissions.checkCallingCanSendText( persistMessageForNonDefaultSmsApp, callingPackage, "Sending SMS message")) { returnUnspecifiedFailure(sentIntents); return; Loading Loading @@ -1134,7 +1130,7 @@ public class IccSmsInterfaceManager { @UnsupportedAppUsage public void sendStoredText(String callingPkg, Uri messageUri, String scAddress, PendingIntent sentIntent, PendingIntent deliveryIntent) { if (!checkCallingSendSmsPermission(callingPkg, "Sending SMS message")) { if (!mSmsPermissions.checkCallingCanSendSms(callingPkg, "Sending SMS message")) { returnUnspecifiedFailure(sentIntent); return; } Loading Loading @@ -1164,7 +1160,7 @@ public class IccSmsInterfaceManager { @UnsupportedAppUsage public void sendStoredMultipartText(String callingPkg, Uri messageUri, String scAddress, List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents) { if (!checkCallingSendSmsPermission(callingPkg, "Sending SMS message")) { if (!mSmsPermissions.checkCallingCanSendSms(callingPkg, "Sending SMS message")) { returnUnspecifiedFailure(sentIntents); return; } Loading Loading @@ -1318,87 +1314,6 @@ public class IccSmsInterfaceManager { } } /** * Check that the caller can send text messages. * * For persisted messages, the caller just needs the SEND_SMS permission. For unpersisted * messages, the caller must either be the IMS app or a carrier-privileged app, or they must * have both the MODIFY_PHONE_STATE and SEND_SMS permissions. * * @throws SecurityException if the caller is missing all necessary permission declaration or * has had a necessary runtime permission revoked. * @return true unless the caller has all necessary permissions but has a revoked AppOps bit. */ @VisibleForTesting public boolean checkCallingSendTextPermissions( boolean persistMessageForNonDefaultSmsApp, String callingPackage, String message) { // TODO(b/75978989): Should we allow IMS/carrier apps for persisted messages as well? if (!persistMessageForNonDefaultSmsApp) { try { enforceCallerIsImsAppOrCarrierApp(message); // No need to also check SEND_SMS. return true; } catch (SecurityException e) { mContext.enforceCallingPermission( android.Manifest.permission.MODIFY_PHONE_STATE, message); } } return checkCallingSendSmsPermission(callingPackage, message); } /** * Check that the caller (or self, if this is not an IPC) has SEND_SMS permissions. * * @throws SecurityException if the caller is missing the permission declaration or has had the * permission revoked at runtime. * @return whether the caller has the OP_SEND_SMS AppOps bit. */ private boolean checkCallingOrSelfSendSmsPermission(String callingPackage, String message) { mContext.enforceCallingOrSelfPermission(Manifest.permission.SEND_SMS, message); return mAppOps.noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(), callingPackage) == AppOpsManager.MODE_ALLOWED; } /** * Check that the caller has SEND_SMS permissions. Can only be called during an IPC. * * @throws SecurityException if the caller is missing the permission declaration or has had the * permission revoked at runtime. * @return whether the caller has the OP_SEND_SMS AppOps bit. */ private boolean checkCallingSendSmsPermission(String callingPackage, String message) { mContext.enforceCallingPermission(Manifest.permission.SEND_SMS, message); return mAppOps.noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(), callingPackage) == AppOpsManager.MODE_ALLOWED; } /** * Enforces that the caller is one of the following apps: * <ul> * <li> IMS App * <li> Carrier App * </ul> */ @VisibleForTesting public void enforceCallerIsImsAppOrCarrierApp(String message) { int callingUid = Binder.getCallingUid(); String carrierImsPackage = CarrierSmsUtils.getCarrierImsPackageForIntent(mContext, mPhone, new Intent(CarrierMessagingService.SERVICE_INTERFACE)); try { if (carrierImsPackage != null && callingUid == mContext.getPackageManager().getPackageUid( carrierImsPackage, 0)) { return; } } catch (PackageManager.NameNotFoundException e) { if (Rlog.isLoggable("SMS", Log.DEBUG)) { log("Cannot find configured carrier ims package"); } } TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege(mPhone.getSubId(), message); } @UnsupportedAppUsage private String filterDestAddress(String destAddr) { String result = null; Loading src/java/com/android/internal/telephony/Phone.java +1 −1 Original line number Diff line number Diff line Loading @@ -2570,7 +2570,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { // that both of these two actions will be broadcast. Intent secrectCodeIntent = new Intent(TelephonyManager.ACTION_SECRET_CODE, Uri.parse("android_secret_code://" + code)); intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); secrectCodeIntent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); mContext.sendBroadcast(secrectCodeIntent, null, options.toBundle()); } } Loading Loading
src/java/com/android/internal/telephony/BtSmsInterfaceManager.java 0 → 100644 +121 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.telephony; import android.app.ActivityThread; import android.app.PendingIntent; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothMapClient; import android.bluetooth.BluetoothProfile; import android.net.Uri; import android.telecom.PhoneAccount; import android.telephony.SmsManager; import android.telephony.SubscriptionInfo; import android.util.Log; /** * BtSmsInterfaceManager to provide a mechanism for sending SMS over Bluetooth */ public class BtSmsInterfaceManager { private static final String LOG_TAG = "BtSmsInterfaceManager"; /** * Sends text through connected Bluetooth device */ public void sendText(String destAddr, String text, PendingIntent sentIntent, PendingIntent deliveryIntent, SubscriptionInfo info) { BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); if (btAdapter == null) { // No bluetooth service on this platform? sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_NO_SERVICE); return; } BluetoothDevice device = btAdapter.getRemoteDevice(info.getIccId()); if (device == null) { Log.d(LOG_TAG, "Bluetooth device addr invalid: " + info.getIccId()); sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_NO_SERVICE); return; } btAdapter.getProfileProxy(ActivityThread.currentApplication().getApplicationContext(), new MapMessageSender(destAddr, text, device, sentIntent, deliveryIntent), BluetoothProfile.MAP_CLIENT); } private void sendErrorInPendingIntent(PendingIntent intent, int errorCode) { if (intent == null) { return; } try { intent.send(errorCode); } catch (PendingIntent.CanceledException e) { // PendingIntent is cancelled. ignore sending this error code back to // caller. Log.d(LOG_TAG, "PendingIntent.CanceledException: " + e.getMessage()); } } private class MapMessageSender implements BluetoothProfile.ServiceListener { final Uri[] mDestAddr; private String mMessage; final BluetoothDevice mDevice; final PendingIntent mSentIntent; final PendingIntent mDeliveryIntent; MapMessageSender(final String destAddr, final String message, final BluetoothDevice device, final PendingIntent sentIntent, final PendingIntent deliveryIntent) { super(); mDestAddr = new Uri[]{new Uri.Builder() .appendPath(destAddr) .scheme(PhoneAccount.SCHEME_TEL) .build()}; mMessage = message; mDevice = device; mSentIntent = sentIntent; mDeliveryIntent = deliveryIntent; } @Override public void onServiceConnected(int profile, BluetoothProfile proxy) { Log.d(LOG_TAG, "Service connected"); if (profile != BluetoothProfile.MAP_CLIENT) { return; } BluetoothMapClient mapProfile = (BluetoothMapClient) proxy; if (mMessage != null) { Log.d(LOG_TAG, "Sending message thru bluetooth"); mapProfile.sendMessage(mDevice, mDestAddr, mMessage, mSentIntent, mDeliveryIntent); mMessage = null; } BluetoothAdapter.getDefaultAdapter() .closeProfileProxy(BluetoothProfile.MAP_CLIENT, mapProfile); } @Override public void onServiceDisconnected(int profile) { if (mMessage != null) { Log.d(LOG_TAG, "Bluetooth disconnected before sending the message"); sendErrorInPendingIntent(mSentIntent, SmsManager.RESULT_ERROR_NO_SERVICE); mMessage = null; } } } }
src/java/com/android/internal/telephony/CellularNetworkService.java +6 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.telephony; import android.hardware.radio.V1_0.CellInfoType; import android.hardware.radio.V1_0.RegState; import android.hardware.radio.V1_4.DataRegStateResult.VopsInfo.hidl_discriminator; import android.os.AsyncResult; import android.os.Handler; import android.os.HandlerThread; Loading Loading @@ -317,7 +318,11 @@ public class CellularNetworkService extends NetworkService { CellIdentity cellIdentity = convertHalCellIdentityToCellIdentity(dataRegState.base.cellIdentity); android.hardware.radio.V1_4.NrIndicators nrIndicators = dataRegState.nrIndicators; if (AccessNetworkType.EUTRAN == accessNetworkTechnology) { // Check for lteVopsInfo only if its initialized and RAT is EUTRAN if (dataRegState.vopsInfo.getDiscriminator() == hidl_discriminator.lteVopsInfo && ServiceState.rilRadioTechnologyToAccessNetworkType(dataRegState.base.rat) == AccessNetworkType.EUTRAN) { android.hardware.radio.V1_4.LteVopsInfo vopsSupport = dataRegState.vopsInfo.lteVopsInfo(); lteVopsSupportInfo = convertHalLteVopsSupportInfo(vopsSupport.isVopsSupported, Loading
src/java/com/android/internal/telephony/GsmCdmaPhone.java +1 −46 Original line number Diff line number Diff line Loading @@ -78,7 +78,6 @@ import com.android.ims.ImsManager; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.cdma.CdmaMmiCode; import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager; import com.android.internal.telephony.cdma.EriManager; import com.android.internal.telephony.dataconnection.DataEnabledSettings; import com.android.internal.telephony.dataconnection.DcTracker; import com.android.internal.telephony.dataconnection.TransportManager; Loading Loading @@ -142,11 +141,7 @@ public class GsmCdmaPhone extends Phone { public static final int CANCEL_ECM_TIMER = 1; // cancel Ecm timer private CdmaSubscriptionSourceManager mCdmaSSM; public int mCdmaSubscriptionSource = CdmaSubscriptionSourceManager.SUBSCRIPTION_SOURCE_UNKNOWN; @UnsupportedAppUsage public EriManager mEriManager; private PowerManager.WakeLock mWakeLock; // mEriFileLoadedRegistrants are informed after the ERI text has been loaded private final RegistrantList mEriFileLoadedRegistrants = new RegistrantList(); // mEcmExitRespRegistrant is informed after the phone has been exited @UnsupportedAppUsage private Registrant mEcmExitRespRegistrant; Loading Loading @@ -333,8 +328,6 @@ public class GsmCdmaPhone extends Phone { mCdmaSSM = mTelephonyComponentFactory.inject(CdmaSubscriptionSourceManager.class.getName()) .getCdmaSubscriptionSourceManagerInstance(mContext, mCi, this, EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED, null); mEriManager = mTelephonyComponentFactory.inject(EriManager.class.getName()) .makeEriManager(this, mContext, EriManager.ERI_FROM_XML); mCi.setEmergencyCallbackMode(this, EVENT_EMERGENCY_CALLBACK_MODE_ENTER, null); mCi.registerForExitEmergencyCallbackMode(this, EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE, null); Loading Loading @@ -2542,11 +2535,6 @@ public class GsmCdmaPhone extends Phone { } else { loge("didn't get the cdma_roaming_mode changes from the carrier config."); } // Load the ERI based on carrier config. Carrier might have their specific ERI. prepareEri(); mSST.pollState(); break; case EVENT_SET_ROAMING_PREFERENCE_DONE: Loading Loading @@ -2958,38 +2946,6 @@ public class GsmCdmaPhone extends Phone { return mIccPhoneBookIntManager; } //CDMA public void registerForEriFileLoaded(Handler h, int what, Object obj) { Registrant r = new Registrant (h, what, obj); mEriFileLoadedRegistrants.add(r); } //CDMA public void unregisterForEriFileLoaded(Handler h) { mEriFileLoadedRegistrants.remove(h); } //CDMA public void prepareEri() { if (mEriManager == null) { Rlog.e(LOG_TAG, "PrepareEri: Trying to access stale objects"); return; } mEriManager.loadEriFile(); if(mEriManager.isEriFileLoaded()) { // when the ERI file is loaded logd("ERI read, notify registrants"); mEriFileLoadedRegistrants.notifyRegistrants(); } } //CDMA @UnsupportedAppUsage public boolean isEriFileLoaded() { return mEriManager.isEriFileLoaded(); } /** * Activate or deactivate cell broadcast SMS. * Loading Loading @@ -3466,7 +3422,7 @@ public class GsmCdmaPhone extends Phone { } else { int roamInd = getServiceState().getCdmaRoamingIndicator(); int defRoamInd = getServiceState().getCdmaDefaultRoamingIndicator(); return mEriManager.getCdmaEriText(roamInd, defRoamInd); return mSST.getCdmaEriText(roamInd, defRoamInd); } } Loading Loading @@ -3675,7 +3631,6 @@ public class GsmCdmaPhone extends Phone { if (VDBG) pw.println(" mVmNumber=" + mVmNumber); pw.println(" mCdmaSSM=" + mCdmaSSM); pw.println(" mCdmaSubscriptionSource=" + mCdmaSubscriptionSource); pw.println(" mEriManager=" + mEriManager); pw.println(" mWakeLock=" + mWakeLock); pw.println(" isInEcm()=" + isInEcm()); if (VDBG) pw.println(" mEsn=" + mEsn); Loading
src/java/com/android/internal/telephony/IccSmsInterfaceManager.java +13 −98 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.app.AppOpsManager; import android.app.PendingIntent; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.database.Cursor; import android.database.sqlite.SQLiteException; Loading @@ -37,7 +36,6 @@ import android.os.Handler; import android.os.Message; import android.os.UserManager; import android.provider.Telephony; import android.service.carrier.CarrierMessagingService; import android.telephony.Rlog; import android.telephony.SmsManager; import android.telephony.SmsMessage; Loading Loading @@ -96,6 +94,7 @@ public class IccSmsInterfaceManager { final protected AppOpsManager mAppOps; @VisibleForTesting public SmsDispatchersController mDispatchersController; private SmsPermissions mSmsPermissions; private final LocalLog mCellBroadcastLocalLog = new LocalLog(100); Loading Loading @@ -157,6 +156,7 @@ public class IccSmsInterfaceManager { mContext = context; mAppOps = appOps; mDispatchersController = dispatchersController; mSmsPermissions = new SmsPermissions(phone, context, appOps); } protected void markMessagesAsRead(ArrayList<byte[]> messages) { Loading Loading @@ -344,7 +344,7 @@ public class IccSmsInterfaceManager { */ public void sendDataWithSelfPermissions(String callingPackage, String destAddr, String scAddr, int destPort, byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent) { if (!checkCallingOrSelfSendSmsPermission(callingPackage, "Sending SMS message")) { if (!mSmsPermissions.checkCallingOrSelfCanSendSms(callingPackage, "Sending SMS message")) { returnUnspecifiedFailure(sentIntent); return; } Loading @@ -359,7 +359,7 @@ public class IccSmsInterfaceManager { @UnsupportedAppUsage public void sendData(String callingPackage, String destAddr, String scAddr, int destPort, byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent) { if (!checkCallingSendSmsPermission(callingPackage, "Sending SMS message")) { if (!mSmsPermissions.checkCallingCanSendSms(callingPackage, "Sending SMS message")) { returnUnspecifiedFailure(sentIntent); return; } Loading Loading @@ -409,15 +409,11 @@ public class IccSmsInterfaceManager { /** * A permissions check before passing to {@link IccSmsInterfaceManager#sendTextInternal}. * This method checks only if the calling package has the permission to send the sms. * Note: SEND_SMS permission should be checked by the caller of this method */ public void sendText(String callingPackage, String destAddr, String scAddr, String text, PendingIntent sentIntent, PendingIntent deliveryIntent, boolean persistMessageForNonDefaultSmsApp) { if (!checkCallingSendTextPermissions( persistMessageForNonDefaultSmsApp, callingPackage, "Sending SMS message")) { returnUnspecifiedFailure(sentIntent); return; } sendTextInternal(callingPackage, destAddr, scAddr, text, sentIntent, deliveryIntent, persistMessageForNonDefaultSmsApp, SMS_MESSAGE_PRIORITY_NOT_SPECIFIED, false /* expectMore */, SMS_MESSAGE_PERIOD_NOT_SPECIFIED); Loading @@ -430,7 +426,7 @@ public class IccSmsInterfaceManager { public void sendTextWithSelfPermissions(String callingPackage, String destAddr, String scAddr, String text, PendingIntent sentIntent, PendingIntent deliveryIntent, boolean persistMessage) { if (!checkCallingOrSelfSendSmsPermission(callingPackage, "Sending SMS message")) { if (!mSmsPermissions.checkCallingOrSelfCanSendSms(callingPackage, "Sending SMS message")) { returnUnspecifiedFailure(sentIntent); return; } Loading Loading @@ -552,7 +548,7 @@ public class IccSmsInterfaceManager { String text, PendingIntent sentIntent, PendingIntent deliveryIntent, boolean persistMessageForNonDefaultSmsApp, int priority, boolean expectMore, int validityPeriod) { if (!checkCallingOrSelfSendSmsPermission(callingPackage, "Sending SMS message")) { if (!mSmsPermissions.checkCallingOrSelfCanSendSms(callingPackage, "Sending SMS message")) { returnUnspecifiedFailure(sentIntent); return; } Loading @@ -574,7 +570,7 @@ public class IccSmsInterfaceManager { public void injectSmsPdu(byte[] pdu, String format, PendingIntent receivedIntent) { if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { enforceCallerIsImsAppOrCarrierApp("injectSmsPdu"); mSmsPermissions.enforceCallerIsImsAppOrCarrierApp("injectSmsPdu"); } if (Rlog.isLoggable("SMS", Log.VERBOSE)) { Loading Loading @@ -681,7 +677,7 @@ public class IccSmsInterfaceManager { String scAddr, List<String> parts, List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents, boolean persistMessageForNonDefaultSmsApp, int priority, boolean expectMore, int validityPeriod) { if (!checkCallingSendTextPermissions( if (!mSmsPermissions.checkCallingCanSendText( persistMessageForNonDefaultSmsApp, callingPackage, "Sending SMS message")) { returnUnspecifiedFailure(sentIntents); return; Loading Loading @@ -1134,7 +1130,7 @@ public class IccSmsInterfaceManager { @UnsupportedAppUsage public void sendStoredText(String callingPkg, Uri messageUri, String scAddress, PendingIntent sentIntent, PendingIntent deliveryIntent) { if (!checkCallingSendSmsPermission(callingPkg, "Sending SMS message")) { if (!mSmsPermissions.checkCallingCanSendSms(callingPkg, "Sending SMS message")) { returnUnspecifiedFailure(sentIntent); return; } Loading Loading @@ -1164,7 +1160,7 @@ public class IccSmsInterfaceManager { @UnsupportedAppUsage public void sendStoredMultipartText(String callingPkg, Uri messageUri, String scAddress, List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents) { if (!checkCallingSendSmsPermission(callingPkg, "Sending SMS message")) { if (!mSmsPermissions.checkCallingCanSendSms(callingPkg, "Sending SMS message")) { returnUnspecifiedFailure(sentIntents); return; } Loading Loading @@ -1318,87 +1314,6 @@ public class IccSmsInterfaceManager { } } /** * Check that the caller can send text messages. * * For persisted messages, the caller just needs the SEND_SMS permission. For unpersisted * messages, the caller must either be the IMS app or a carrier-privileged app, or they must * have both the MODIFY_PHONE_STATE and SEND_SMS permissions. * * @throws SecurityException if the caller is missing all necessary permission declaration or * has had a necessary runtime permission revoked. * @return true unless the caller has all necessary permissions but has a revoked AppOps bit. */ @VisibleForTesting public boolean checkCallingSendTextPermissions( boolean persistMessageForNonDefaultSmsApp, String callingPackage, String message) { // TODO(b/75978989): Should we allow IMS/carrier apps for persisted messages as well? if (!persistMessageForNonDefaultSmsApp) { try { enforceCallerIsImsAppOrCarrierApp(message); // No need to also check SEND_SMS. return true; } catch (SecurityException e) { mContext.enforceCallingPermission( android.Manifest.permission.MODIFY_PHONE_STATE, message); } } return checkCallingSendSmsPermission(callingPackage, message); } /** * Check that the caller (or self, if this is not an IPC) has SEND_SMS permissions. * * @throws SecurityException if the caller is missing the permission declaration or has had the * permission revoked at runtime. * @return whether the caller has the OP_SEND_SMS AppOps bit. */ private boolean checkCallingOrSelfSendSmsPermission(String callingPackage, String message) { mContext.enforceCallingOrSelfPermission(Manifest.permission.SEND_SMS, message); return mAppOps.noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(), callingPackage) == AppOpsManager.MODE_ALLOWED; } /** * Check that the caller has SEND_SMS permissions. Can only be called during an IPC. * * @throws SecurityException if the caller is missing the permission declaration or has had the * permission revoked at runtime. * @return whether the caller has the OP_SEND_SMS AppOps bit. */ private boolean checkCallingSendSmsPermission(String callingPackage, String message) { mContext.enforceCallingPermission(Manifest.permission.SEND_SMS, message); return mAppOps.noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(), callingPackage) == AppOpsManager.MODE_ALLOWED; } /** * Enforces that the caller is one of the following apps: * <ul> * <li> IMS App * <li> Carrier App * </ul> */ @VisibleForTesting public void enforceCallerIsImsAppOrCarrierApp(String message) { int callingUid = Binder.getCallingUid(); String carrierImsPackage = CarrierSmsUtils.getCarrierImsPackageForIntent(mContext, mPhone, new Intent(CarrierMessagingService.SERVICE_INTERFACE)); try { if (carrierImsPackage != null && callingUid == mContext.getPackageManager().getPackageUid( carrierImsPackage, 0)) { return; } } catch (PackageManager.NameNotFoundException e) { if (Rlog.isLoggable("SMS", Log.DEBUG)) { log("Cannot find configured carrier ims package"); } } TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege(mPhone.getSubId(), message); } @UnsupportedAppUsage private String filterDestAddress(String destAddr) { String result = null; Loading
src/java/com/android/internal/telephony/Phone.java +1 −1 Original line number Diff line number Diff line Loading @@ -2570,7 +2570,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { // that both of these two actions will be broadcast. Intent secrectCodeIntent = new Intent(TelephonyManager.ACTION_SECRET_CODE, Uri.parse("android_secret_code://" + code)); intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); secrectCodeIntent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); mContext.sendBroadcast(secrectCodeIntent, null, options.toBundle()); } } Loading