Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88c5cb4c authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6610691 from e51ecf74 to rvc-release

Change-Id: I81aa771c028cb7d5d9e60daa093cad1a7bdf7715
parents f1503c2d e51ecf74
Loading
Loading
Loading
Loading
+17 −33
Original line number Diff line number Diff line
@@ -24,11 +24,8 @@ import android.Manifest;
import android.app.AppOpsManager;
import android.app.PendingIntent;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteException;
@@ -40,11 +37,9 @@ import android.os.Looper;
import android.os.Message;
import android.os.UserManager;
import android.provider.Telephony;
import android.telephony.CarrierConfigManager;
import android.telephony.SmsCbMessage;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
import android.telephony.SubscriptionManager;
import android.telephony.emergency.EmergencyNumber;
import android.util.LocalLog;
import android.util.Log;
@@ -190,24 +185,6 @@ public class IccSmsInterfaceManager {
        mAppOps = appOps;
        mDispatchersController = dispatchersController;
        mSmsPermissions = new SmsPermissions(phone, context, appOps);

        mContext.registerReceiver(
                new BroadcastReceiver() {
                    @Override
                    public void onReceive(Context context, Intent intent) {
                        if (CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED
                                .equals(intent.getAction())) {
                            if (mPhone.getPhoneId() == intent.getIntExtra(
                                    CarrierConfigManager.EXTRA_SLOT_INDEX,
                                    SubscriptionManager.INVALID_SIM_SLOT_INDEX)) {
                                new Thread(() -> {
                                    log("Carrier config changed. Update ranges.");
                                    mCellBroadcastRangeManager.updateRanges();
                                }).start();
                            }
                        }
                    }
                }, new IntentFilter(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
    }

    private void enforceNotOnHandlerThread(String methodName) {
@@ -957,7 +934,7 @@ public class IccSmsInterfaceManager {
    }

    public boolean enableCellBroadcastRange(int startMessageId, int endMessageId, int ranType) {
        mContext.enforceCallingPermission("android.permission.RECEIVE_EMERGENCY_BROADCAST",
        mContext.enforceCallingPermission(android.Manifest.permission.RECEIVE_EMERGENCY_BROADCAST,
                "enabling cell broadcast range [" + startMessageId + "-" + endMessageId + "]. "
                        + "ranType=" + ranType);
        if (ranType == SmsCbMessage.MESSAGE_FORMAT_3GPP) {
@@ -970,7 +947,7 @@ public class IccSmsInterfaceManager {
    }

    public boolean disableCellBroadcastRange(int startMessageId, int endMessageId, int ranType) {
        mContext.enforceCallingPermission("android.permission.RECEIVE_EMERGENCY_BROADCAST",
        mContext.enforceCallingPermission(android.Manifest.permission.RECEIVE_EMERGENCY_BROADCAST,
                "disabling cell broadcast range [" + startMessageId + "-" + endMessageId
                        + "]. ranType=" + ranType);
        if (ranType == SmsCbMessage.MESSAGE_FORMAT_3GPP) {
@@ -985,8 +962,7 @@ public class IccSmsInterfaceManager {
    @UnsupportedAppUsage
    synchronized public boolean enableGsmBroadcastRange(int startMessageId, int endMessageId) {

        mContext.enforceCallingPermission(
                "android.permission.RECEIVE_SMS",
        mContext.enforceCallingPermission(android.Manifest.permission.RECEIVE_EMERGENCY_BROADCAST,
                "Enabling cell broadcast SMS");

        String client = mContext.getPackageManager().getNameForUid(
@@ -1016,8 +992,7 @@ public class IccSmsInterfaceManager {
    @UnsupportedAppUsage
    synchronized public boolean disableGsmBroadcastRange(int startMessageId, int endMessageId) {

        mContext.enforceCallingPermission(
                "android.permission.RECEIVE_SMS",
        mContext.enforceCallingPermission(android.Manifest.permission.RECEIVE_EMERGENCY_BROADCAST,
                "Disabling cell broadcast SMS");

        String client = mContext.getPackageManager().getNameForUid(
@@ -1047,8 +1022,7 @@ public class IccSmsInterfaceManager {
    @UnsupportedAppUsage
    synchronized public boolean enableCdmaBroadcastRange(int startMessageId, int endMessageId) {

        mContext.enforceCallingPermission(
                "android.permission.RECEIVE_SMS",
        mContext.enforceCallingPermission(android.Manifest.permission.RECEIVE_EMERGENCY_BROADCAST,
                "Enabling cdma broadcast SMS");

        String client = mContext.getPackageManager().getNameForUid(
@@ -1077,8 +1051,7 @@ public class IccSmsInterfaceManager {
    @UnsupportedAppUsage
    synchronized public boolean disableCdmaBroadcastRange(int startMessageId, int endMessageId) {

        mContext.enforceCallingPermission(
                "android.permission.RECEIVE_SMS",
        mContext.enforceCallingPermission(android.Manifest.permission.RECEIVE_EMERGENCY_BROADCAST,
                "Disabling cell broadcast SMS");

        String client = mContext.getPackageManager().getNameForUid(
@@ -1104,6 +1077,17 @@ public class IccSmsInterfaceManager {
        return true;
    }

    /**
     * Reset all cell broadcast ranges. Previously enabled ranges will become invalid after this.
     */
    public void resetAllCellBroadcastRanges() {
        mContext.enforceCallingPermission(android.Manifest.permission.RECEIVE_EMERGENCY_BROADCAST,
                "resetAllCellBroadcastRanges");
        mCdmaBroadcastRangeManager.clearRanges();
        mCellBroadcastRangeManager.clearRanges();
        log("Cell broadcast ranges reset.");
    }

    class CellBroadcastRangeManager extends IntRangeManager {
        private ArrayList<SmsBroadcastConfigInfo> mConfigList =
                new ArrayList<SmsBroadcastConfigInfo>();
+7 −0
Original line number Diff line number Diff line
@@ -188,6 +188,13 @@ public abstract class IntRangeManager {

    protected IntRangeManager() {}

    /**
     * Clear all the ranges.
     */
    public synchronized void clearRanges() {
        mRanges.clear();
    }

    /**
     * Enable a range for the specified client and update ranges
     * if necessary. If {@link #finishUpdate} returns failure,
+18 −0
Original line number Diff line number Diff line
@@ -822,4 +822,22 @@ public class SmsController extends ISmsImplBase {
            return 0;
        }
    }

    /**
     * Reset all cell broadcast ranges. Previously enabled ranges will become invalid after this.
     *
     * @param subId Subscription index
     * @return {@code true} if succeeded, otherwise {@code false}.
     */
    @Override
    public boolean resetAllCellBroadcastRanges(int subId) {
        IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId);
        if (iccSmsIntMgr != null) {
            iccSmsIntMgr.resetAllCellBroadcastRanges();
            return true;
        } else {
            Rlog.e(LOG_TAG, "iccSmsIntMgr is null for " + " subId: " + subId);
            return false;
        }
    }
}