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

Commit ba544c41 authored by Jack Yu's avatar Jack Yu
Browse files

Moved implicit intents into explicit intents

Moved two intents SMS_EMERGENCY_CB_RECEIVED_ACTION and
SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION are
now sent to the default cell broadcast receiver only.

The default cell broadcast receiver can be changed through
the resource overlay. Otherwise it is default to
com.android.cellbroadcastreceiver

bug: 33783447
Test: manual
Change-Id: I4e2bcd2b2f79f7a4a6a9b275c09684f204e201f4
Merged-In: I4e2bcd2b2f79f7a4a6a9b275c09684f204e201f4
parent b1e4633f
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -19,13 +19,14 @@ package com.android.internal.telephony;
import android.Manifest;
import android.app.Activity;
import android.app.AppOpsManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Message;
import android.os.UserHandle;
import android.provider.Telephony;
import android.telephony.SubscriptionManager;
import android.telephony.SmsCbMessage;
import android.telephony.SubscriptionManager;

/**
 * Dispatch new Cell Broadcasts to receivers. Acquires a private wakelock until the broadcast
@@ -90,9 +91,22 @@ public class CellBroadcastHandler extends WakeLockStateMachine {
            receiverPermission = Manifest.permission.RECEIVE_SMS;
            appOp = AppOpsManager.OP_RECEIVE_SMS;
        }
        // explicitly send it to the default cell broadcast receiver only.
        intent.setComponent(getDefaultCellBroadcastReceiverApp(mContext));
        intent.putExtra("message", message);
        SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhone.getPhoneId());
        mContext.sendOrderedBroadcastAsUser(intent, UserHandle.ALL, receiverPermission, appOp,
                mReceiver, getHandler(), Activity.RESULT_OK, null, null);
    }

    /**
     * Get the default cell broadcast receiver component name.
     * @param context Device context
     * @return Component name of the default cell broadcast receiver
     */
    public static ComponentName getDefaultCellBroadcastReceiverApp(Context context) {
        String defaultCellBroadcastReceiver = context.getResources().getString(
                com.android.internal.R.string.config_defaultCellBroadcastReceiverComponent);
        return ComponentName.unflattenFromString(defaultCellBroadcastReceiver);
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -30,8 +30,8 @@ import android.telephony.SubscriptionManager;
import android.telephony.cdma.CdmaSmsCbProgramData;
import android.telephony.cdma.CdmaSmsCbProgramResults;

import com.android.internal.telephony.CellBroadcastHandler;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.WakeLockStateMachine;
import com.android.internal.telephony.cdma.sms.BearerData;
import com.android.internal.telephony.cdma.sms.CdmaSmsAddress;
@@ -103,6 +103,7 @@ public final class CdmaServiceCategoryProgramHandler extends WakeLockStateMachin
        }

        Intent intent = new Intent(Intents.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION);
        intent.setComponent(CellBroadcastHandler.getDefaultCellBroadcastReceiverApp(mContext));
        intent.putExtra("sender", sms.getOriginatingAddress());
        intent.putParcelableArrayListExtra("program_data", programDataList);
        SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhone.getPhoneId());