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

Commit b9b14f0b authored by Ta-wei Yen's avatar Ta-wei Yen
Browse files

Calling as system when filtering VVM SMS in CarrierSmsFilterCallback

When the callback is invoked in CarrierSmsFilterCallback, the calling
identity is replaced with the carrier app.

VisualVoicemailSmsFilter need to be called from the system so the
calling identity must be restored before calling.

Change-Id: I03ad92aaefba58c57e76317cb30565a794a1c268
Fixes:28982677
parent 5b561176
Loading
Loading
Loading
Loading
+33 −32
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@

package com.android.internal.telephony;

import static android.telephony.TelephonyManager.PHONE_TYPE_CDMA;
import static android.service.carrier.CarrierMessagingService.RECEIVE_OPTIONS_SKIP_NOTIFY_WHEN_CREDENTIAL_PROTECTED_STORAGE_UNAVAILABLE;
import static android.telephony.TelephonyManager.PHONE_TYPE_CDMA;

import android.app.Activity;
import android.app.ActivityManagerNative;
@@ -58,7 +58,6 @@ import android.service.carrier.CarrierMessagingService;
import android.service.carrier.ICarrierMessagingCallback;
import android.service.carrier.ICarrierMessagingService;
import android.service.carrier.MessagePdu;
import android.service.notification.StatusBarNotification;
import android.telephony.CarrierMessagingServiceManager;
import android.telephony.Rlog;
import android.telephony.SmsManager;
@@ -1372,7 +1371,10 @@ public abstract class InboundSmsHandler extends StateMachine {
        @Override
        public void onFilterComplete(int result) {
            mSmsFilter.disposeConnection(mContext);

            // Calling identity was the CarrierMessagingService in this callback, change it back to
            // ours. This is required for dropSms() and VisualVoicemailSmsFilter.filter().
            long token = Binder.clearCallingIdentity();
            try {
                logv("onFilterComplete: result is " + result);
                if ((result & CarrierMessagingService.RECEIVE_OPTIONS_DROP) == 0) {
                    if (mFilterWithVvm) {
@@ -1400,6 +1402,10 @@ public abstract class InboundSmsHandler extends StateMachine {
                    // Drop this SMS.
                    dropSms(mSmsFilter.mSmsBroadcastReceiver);
                }
            } finally {
                // return back to the CarrierMessagingService, restore the calling identity.
                Binder.restoreCallingIdentity(token);
            }
        }

        @Override
@@ -1424,13 +1430,8 @@ public abstract class InboundSmsHandler extends StateMachine {
    }

    private void dropSms(SmsBroadcastReceiver receiver) {
        final long token = Binder.clearCallingIdentity();
        try {
        // Needs phone package permissions.
        deleteFromRawTable(receiver.mDeleteWhere, receiver.mDeleteWhereArgs, MARK_DELETED);
        } finally {
            Binder.restoreCallingIdentity(token);
        }
        sendMessage(EVENT_BROADCAST_COMPLETE);
    }