Messaging: Remove compatibility for old android versions
Change-Id: Id9065d60525a509271a0e64c0e349e857cb998e2
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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.messaging.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.Telephony;
|
||||
|
||||
import com.android.messaging.util.ContentType;
|
||||
import com.android.messaging.util.OsUtil;
|
||||
import com.android.messaging.util.PhoneUtils;
|
||||
|
||||
/**
|
||||
* This receiver is used to abort MMS WAP broadcasts pre-KLP when SMS is enabled.
|
||||
*/
|
||||
public class AbortMmsWapPushReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
if (Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION.equals(intent.getAction())
|
||||
&& ContentType.MMS_MESSAGE.equals(intent.getType())) {
|
||||
// If we are enabled, it's our job to stop the broadcast from continuing. This
|
||||
// receiver is not used on KLP but we do an extra check here just to make sure.
|
||||
if (!OsUtil.isAtLeastKLP() && PhoneUtils.getDefault().isSmsEnabled()) {
|
||||
abortBroadcast();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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.messaging.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.android.messaging.util.OsUtil;
|
||||
import com.android.messaging.util.PhoneUtils;
|
||||
|
||||
/**
|
||||
* This receiver is used to abort SMS broadcasts pre-KLP when SMS is enabled.
|
||||
*/
|
||||
public final class AbortSmsReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
// If we are enabled, it's our job to stop the broadcast from continuing. This
|
||||
// receiver is not used on KLP but we do an extra check here just to make sure.
|
||||
if (!OsUtil.isAtLeastKLP() && PhoneUtils.getDefault().isSmsEnabled()) {
|
||||
if (!SmsReceiver.shouldIgnoreMessage(intent)) {
|
||||
abortBroadcast();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
* Copyright (C) 2024 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +22,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.Telephony;
|
||||
|
||||
import com.android.messaging.datamodel.action.ReceiveMmsMessageAction;
|
||||
import com.android.messaging.util.ContentType;
|
||||
import com.android.messaging.util.PhoneUtils;
|
||||
|
||||
@@ -29,15 +31,27 @@ import com.android.messaging.util.PhoneUtils;
|
||||
*/
|
||||
public class MmsWapPushDeliverReceiver extends BroadcastReceiver {
|
||||
|
||||
static final String EXTRA_SUBSCRIPTION = "subscription";
|
||||
static final String EXTRA_DATA = "data";
|
||||
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
if (Telephony.Sms.Intents.WAP_PUSH_DELIVER_ACTION.equals(intent.getAction())
|
||||
&& ContentType.MMS_MESSAGE.equals(intent.getType())) {
|
||||
// Always convert negative subIds into -1
|
||||
int subId = PhoneUtils.getDefault().getEffectiveIncomingSubIdFromSystem(
|
||||
intent, MmsWapPushReceiver.EXTRA_SUBSCRIPTION);
|
||||
byte[] data = intent.getByteArrayExtra(MmsWapPushReceiver.EXTRA_DATA);
|
||||
MmsWapPushReceiver.mmsReceived(subId, data);
|
||||
intent, EXTRA_SUBSCRIPTION);
|
||||
byte[] data = intent.getByteArrayExtra(EXTRA_DATA);
|
||||
mmsReceived(subId, data);
|
||||
}
|
||||
}
|
||||
|
||||
static void mmsReceived(final int subId, final byte[] data) {
|
||||
if (!PhoneUtils.getDefault().isSmsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ReceiveMmsMessageAction action = new ReceiveMmsMessageAction(subId, data);
|
||||
action.start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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.messaging.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.Telephony;
|
||||
|
||||
import com.android.messaging.datamodel.action.ReceiveMmsMessageAction;
|
||||
import com.android.messaging.util.ContentType;
|
||||
import com.android.messaging.util.PhoneUtils;
|
||||
|
||||
/**
|
||||
* Class that handles MMS WAP push intent from telephony on pre-KLP Devices.
|
||||
*/
|
||||
public class MmsWapPushReceiver extends BroadcastReceiver {
|
||||
static final String EXTRA_SUBSCRIPTION = "subscription";
|
||||
static final String EXTRA_DATA = "data";
|
||||
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
if (Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION.equals(intent.getAction())
|
||||
&& ContentType.MMS_MESSAGE.equals(intent.getType())) {
|
||||
if (PhoneUtils.getDefault().isSmsEnabled()) {
|
||||
// Always convert negative subIds into -1
|
||||
final int subId = PhoneUtils.getDefault().getEffectiveIncomingSubIdFromSystem(
|
||||
intent, MmsWapPushReceiver.EXTRA_SUBSCRIPTION);
|
||||
final byte[] data = intent.getByteArrayExtra(MmsWapPushReceiver.EXTRA_DATA);
|
||||
mmsReceived(subId, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void mmsReceived(final int subId, final byte[] data) {
|
||||
if (!PhoneUtils.getDefault().isSmsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ReceiveMmsMessageAction action = new ReceiveMmsMessageAction(subId, data);
|
||||
action.start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,36 +73,12 @@ public final class SmsReceiver extends BroadcastReceiver {
|
||||
* notification.
|
||||
*/
|
||||
public static void updateSmsReceiveHandler(final Context context) {
|
||||
boolean smsReceiverEnabled;
|
||||
boolean mmsWapPushReceiverEnabled;
|
||||
boolean respondViaMessageEnabled;
|
||||
boolean broadcastAbortEnabled;
|
||||
|
||||
if (OsUtil.isAtLeastKLP()) {
|
||||
// When we're running as the secondary user, we don't get the new SMS_DELIVER intent,
|
||||
// only the primary user receives that. As secondary, we need to go old-school and
|
||||
// listen for the SMS_RECEIVED intent. For the secondary user, use this SmsReceiver
|
||||
// for both sms and mms notification. For the primary user on KLP (and above), we don't
|
||||
// use the SmsReceiver.
|
||||
smsReceiverEnabled = OsUtil.isSecondaryUser();
|
||||
// On KLP use the new deliver event for mms
|
||||
mmsWapPushReceiverEnabled = false;
|
||||
// On KLP we need to always enable this handler to show in the list of sms apps
|
||||
respondViaMessageEnabled = true;
|
||||
// On KLP we don't need to abort the broadcast
|
||||
broadcastAbortEnabled = false;
|
||||
} else {
|
||||
// On JB we use the sms receiver for both sms/mms delivery
|
||||
final boolean carrierSmsEnabled = PhoneUtils.getDefault().isSmsEnabled();
|
||||
smsReceiverEnabled = carrierSmsEnabled;
|
||||
|
||||
// On JB we use the mms receiver when sms/mms is enabled
|
||||
mmsWapPushReceiverEnabled = carrierSmsEnabled;
|
||||
// On JB this is dynamic to make sure we don't show in dialer if sms is disabled
|
||||
respondViaMessageEnabled = carrierSmsEnabled;
|
||||
// On JB we need to abort broadcasts if SMS is enabled
|
||||
broadcastAbortEnabled = carrierSmsEnabled;
|
||||
}
|
||||
// When we're running as the secondary user, we don't get the new SMS_DELIVER intent,
|
||||
// only the primary user receives that. As secondary, we need to go old-school and
|
||||
// listen for the SMS_RECEIVED intent. For the secondary user, use this SmsReceiver
|
||||
// for both sms and mms notification. For the primary user on KLP (and above), we don't
|
||||
// use the SmsReceiver.
|
||||
boolean smsReceiverEnabled = OsUtil.isSecondaryUser();
|
||||
|
||||
final PackageManager packageManager = context.getPackageManager();
|
||||
final boolean logv = LogUtil.isLoggable(TAG, LogUtil.VERBOSE);
|
||||
@@ -122,57 +98,13 @@ public final class SmsReceiver extends BroadcastReceiver {
|
||||
new ComponentName(context, SmsReceiver.class),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
if (mmsWapPushReceiverEnabled) {
|
||||
if (logv) {
|
||||
LogUtil.v(TAG, "Enabling MMS message receiving");
|
||||
}
|
||||
packageManager.setComponentEnabledSetting(
|
||||
new ComponentName(context, MmsWapPushReceiver.class),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
} else {
|
||||
if (logv) {
|
||||
LogUtil.v(TAG, "Disabling MMS message receiving");
|
||||
}
|
||||
packageManager.setComponentEnabledSetting(
|
||||
new ComponentName(context, MmsWapPushReceiver.class),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
if (broadcastAbortEnabled) {
|
||||
if (logv) {
|
||||
LogUtil.v(TAG, "Enabling SMS/MMS broadcast abort");
|
||||
}
|
||||
packageManager.setComponentEnabledSetting(
|
||||
new ComponentName(context, AbortSmsReceiver.class),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
packageManager.setComponentEnabledSetting(
|
||||
new ComponentName(context, AbortMmsWapPushReceiver.class),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
} else {
|
||||
if (logv) {
|
||||
LogUtil.v(TAG, "Disabling SMS/MMS broadcast abort");
|
||||
}
|
||||
packageManager.setComponentEnabledSetting(
|
||||
new ComponentName(context, AbortSmsReceiver.class),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
||||
packageManager.setComponentEnabledSetting(
|
||||
new ComponentName(context, AbortMmsWapPushReceiver.class),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
if (respondViaMessageEnabled) {
|
||||
if (logv) {
|
||||
LogUtil.v(TAG, "Enabling respond via message intent");
|
||||
}
|
||||
packageManager.setComponentEnabledSetting(
|
||||
new ComponentName(context, NoConfirmationSmsSendService.class),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
} else {
|
||||
if (logv) {
|
||||
LogUtil.v(TAG, "Disabling respond via message intent");
|
||||
}
|
||||
packageManager.setComponentEnabledSetting(
|
||||
new ComponentName(context, NoConfirmationSmsSendService.class),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
||||
if (logv) {
|
||||
LogUtil.v(TAG, "Enabling respond via message intent");
|
||||
}
|
||||
packageManager.setComponentEnabledSetting(
|
||||
new ComponentName(context, NoConfirmationSmsSendService.class),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
|
||||
}
|
||||
|
||||
private static final String EXTRA_ERROR_CODE = "errorCode";
|
||||
@@ -214,9 +146,7 @@ public final class SmsReceiver extends BroadcastReceiver {
|
||||
// seen for the telephony db.
|
||||
messageValues.put(Sms.Inbox.READ, 0);
|
||||
messageValues.put(Sms.Inbox.SEEN, 0);
|
||||
if (OsUtil.isAtLeastL_MR1()) {
|
||||
messageValues.put(Sms.SUBSCRIPTION_ID, subId);
|
||||
}
|
||||
messageValues.put(Sms.SUBSCRIPTION_ID, subId);
|
||||
|
||||
if (messages[0].getMessageClass() == android.telephony.SmsMessage.MessageClass.CLASS_0 ||
|
||||
DebugUtils.debugClassZeroSmsEnabled()) {
|
||||
@@ -238,8 +168,6 @@ public final class SmsReceiver extends BroadcastReceiver {
|
||||
// TODO: update this with the actual constant from Telephony
|
||||
"android.provider.Telephony.MMS_DOWNLOADED".equals(action))) {
|
||||
postNewMessageSecondaryUserNotification();
|
||||
} else if (!OsUtil.isAtLeastKLP()) {
|
||||
deliverSmsIntent(context, intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user