1d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd/* 2d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Copyright (C) 2015 The Android Open Source Project 3d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * 4d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Licensed under the Apache License, Version 2.0 (the "License"); 5d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * you may not use this file except in compliance with the License. 6d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * You may obtain a copy of the License at 7d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * 8d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * http://www.apache.org/licenses/LICENSE-2.0 9d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * 10d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Unless required by applicable law or agreed to in writing, software 11d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * distributed under the License is distributed on an "AS IS" BASIS, 12d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * See the License for the specific language governing permissions and 14d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * limitations under the License. 15d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd */ 16d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 17d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddpackage com.android.messaging.receiver; 18d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 19d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.content.BroadcastReceiver; 20d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.content.Context; 21d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.content.Intent; 22d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 23d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport com.android.messaging.util.OsUtil; 24d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport com.android.messaging.util.PhoneUtils; 25d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 26d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd/** 27d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * This receiver is used to abort SMS broadcasts pre-KLP when SMS is enabled. 28d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd */ 29d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddpublic final class AbortSmsReceiver extends BroadcastReceiver { 30d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 31d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd @Override 32d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd public void onReceive(final Context context, final Intent intent) { 33d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd // If we are enabled, it's our job to stop the broadcast from continuing. This 34d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd // receiver is not used on KLP but we do an extra check here just to make sure. 35d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd if (!OsUtil.isAtLeastKLP() && PhoneUtils.getDefault().isSmsEnabled()) { 36d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd if (!SmsReceiver.shouldIgnoreMessage(intent)) { 37d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd abortBroadcast(); 38d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 39d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 40d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 41d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd} 42