1/* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.messaging.receiver; 18 19import android.content.BroadcastReceiver; 20import android.content.Context; 21import android.content.Intent; 22import android.provider.Telephony; 23 24import com.android.messaging.datamodel.action.ReceiveMmsMessageAction; 25import com.android.messaging.util.ContentType; 26import com.android.messaging.util.PhoneUtils; 27 28/** 29 * Class that handles MMS WAP push intent from telephony on pre-KLP Devices. 30 */ 31public class MmsWapPushReceiver extends BroadcastReceiver { 32 static final String EXTRA_SUBSCRIPTION = "subscription"; 33 static final String EXTRA_DATA = "data"; 34 35 @Override 36 public void onReceive(final Context context, final Intent intent) { 37 if (Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION.equals(intent.getAction()) 38 && ContentType.MMS_MESSAGE.equals(intent.getType())) { 39 if (PhoneUtils.getDefault().isSmsEnabled()) { 40 // Always convert negative subIds into -1 41 final int subId = PhoneUtils.getDefault().getEffectiveIncomingSubIdFromSystem( 42 intent, MmsWapPushReceiver.EXTRA_SUBSCRIPTION); 43 final byte[] data = intent.getByteArrayExtra(MmsWapPushReceiver.EXTRA_DATA); 44 mmsReceived(subId, data); 45 } 46 } 47 } 48 49 static void mmsReceived(final int subId, final byte[] data) { 50 if (!PhoneUtils.getDefault().isSmsEnabled()) { 51 return; 52 } 53 54 final ReceiveMmsMessageAction action = new ReceiveMmsMessageAction(subId, data); 55 action.start(); 56 } 57} 58 59