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

Commit 2020dffd authored by Jack Yu's avatar Jack Yu Committed by android-build-merger
Browse files

Moved SIM_FULL_ACTION into an explicit intent am: b6e1d01e am: 3112399d

am: 714d53da

Change-Id: I4c9d4fe3333bc9251c2d4011974e664cd34e2c19
parents 241c3e70 714d53da
Loading
Loading
Loading
Loading
+75 −19
Original line number Original line Diff line number Diff line
@@ -85,37 +85,42 @@ public final class SmsApplication {
        /**
        /**
         * The class name of the SMS_DELIVER_ACTION receiver in this app.
         * The class name of the SMS_DELIVER_ACTION receiver in this app.
         */
         */
        public String mSmsReceiverClass;
        private String mSmsReceiverClass;


        /**
        /**
         * The class name of the WAP_PUSH_DELIVER_ACTION receiver in this app.
         * The class name of the WAP_PUSH_DELIVER_ACTION receiver in this app.
         */
         */
        public String mMmsReceiverClass;
        private String mMmsReceiverClass;


        /**
        /**
         * The class name of the ACTION_RESPOND_VIA_MESSAGE intent in this app.
         * The class name of the ACTION_RESPOND_VIA_MESSAGE intent in this app.
         */
         */
        public String mRespondViaMessageClass;
        private String mRespondViaMessageClass;


        /**
        /**
         * The class name of the ACTION_SENDTO intent in this app.
         * The class name of the ACTION_SENDTO intent in this app.
         */
         */
        public String mSendToClass;
        private String mSendToClass;


        /**
        /**
         * The class name of the ACTION_DEFAULT_SMS_PACKAGE_CHANGED receiver in this app.
         * The class name of the ACTION_DEFAULT_SMS_PACKAGE_CHANGED receiver in this app.
         */
         */
        public String mSmsAppChangedReceiverClass;
        private String mSmsAppChangedReceiverClass;


        /**
        /**
         * The class name of the ACTION_EXTERNAL_PROVIDER_CHANGE receiver in this app.
         * The class name of the ACTION_EXTERNAL_PROVIDER_CHANGE receiver in this app.
         */
         */
        public String mProviderChangedReceiverClass;
        private String mProviderChangedReceiverClass;

        /**
         * The class name of the SIM_FULL_ACTION receiver in this app.
         */
        private String mSimFullReceiverClass;


        /**
        /**
         * The user-id for this application
         * The user-id for this application
         */
         */
        public int mUid;
        private int mUid;


        /**
        /**
         * Returns true if this SmsApplicationData is complete (all intents handled).
         * Returns true if this SmsApplicationData is complete (all intents handled).
@@ -151,14 +156,15 @@ public final class SmsApplication {


        @Override
        @Override
        public String toString() {
        public String toString() {
            return " mPackageName: " + mPackageName +
            return " mPackageName: " + mPackageName
                    " mSmsReceiverClass: " + mSmsReceiverClass +
                    + " mSmsReceiverClass: " + mSmsReceiverClass
                    " mMmsReceiverClass: " + mMmsReceiverClass +
                    + " mMmsReceiverClass: " + mMmsReceiverClass
                    " mRespondViaMessageClass: " + mRespondViaMessageClass +
                    + " mRespondViaMessageClass: " + mRespondViaMessageClass
                    " mSendToClass: " + mSendToClass +
                    + " mSendToClass: " + mSendToClass
                    " mSmsAppChangedClass: " + mSmsAppChangedReceiverClass +
                    + " mSmsAppChangedClass: " + mSmsAppChangedReceiverClass
                    " mProviderChangedReceiverClass: " + mProviderChangedReceiverClass +
                    + " mProviderChangedReceiverClass: " + mProviderChangedReceiverClass
                    " mUid: " + mUid;
                    + " mSimFullReceiverClass: " + mSimFullReceiverClass
                    + " mUid: " + mUid;
        }
        }
    }
    }


@@ -300,8 +306,8 @@ public final class SmsApplication {


        // Update any existing entries with the default sms changed handler.
        // Update any existing entries with the default sms changed handler.
        intent = new Intent(Telephony.Sms.Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED);
        intent = new Intent(Telephony.Sms.Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED);
        List<ResolveInfo> smsAppChangedReceivers = packageManager.queryBroadcastReceiversAsUser(intent,
        List<ResolveInfo> smsAppChangedReceivers =
                0, userId);
                packageManager.queryBroadcastReceiversAsUser(intent, 0, userId);
        if (DEBUG_MULTIUSER) {
        if (DEBUG_MULTIUSER) {
            Log.i(LOG_TAG, "getApplicationCollectionInternal smsAppChangedActivities=" +
            Log.i(LOG_TAG, "getApplicationCollectionInternal smsAppChangedActivities=" +
                    smsAppChangedReceivers);
                    smsAppChangedReceivers);
@@ -325,8 +331,8 @@ public final class SmsApplication {


        // Update any existing entries with the external provider changed handler.
        // Update any existing entries with the external provider changed handler.
        intent = new Intent(Telephony.Sms.Intents.ACTION_EXTERNAL_PROVIDER_CHANGE);
        intent = new Intent(Telephony.Sms.Intents.ACTION_EXTERNAL_PROVIDER_CHANGE);
        List<ResolveInfo> providerChangedReceivers = packageManager.queryBroadcastReceiversAsUser(intent,
        List<ResolveInfo> providerChangedReceivers =
                0, userId);
                packageManager.queryBroadcastReceiversAsUser(intent, 0, userId);
        if (DEBUG_MULTIUSER) {
        if (DEBUG_MULTIUSER) {
            Log.i(LOG_TAG, "getApplicationCollectionInternal providerChangedActivities=" +
            Log.i(LOG_TAG, "getApplicationCollectionInternal providerChangedActivities=" +
                    providerChangedReceivers);
                    providerChangedReceivers);
@@ -348,6 +354,31 @@ public final class SmsApplication {
            }
            }
        }
        }


        // Update any existing entries with the sim full handler.
        intent = new Intent(Intents.SIM_FULL_ACTION);
        List<ResolveInfo> simFullReceivers =
                packageManager.queryBroadcastReceiversAsUser(intent, 0, userId);
        if (DEBUG_MULTIUSER) {
            Log.i(LOG_TAG, "getApplicationCollectionInternal simFullReceivers="
                    + simFullReceivers);
        }
        for (ResolveInfo resolveInfo : simFullReceivers) {
            final ActivityInfo activityInfo = resolveInfo.activityInfo;
            if (activityInfo == null) {
                continue;
            }
            final String packageName = activityInfo.packageName;
            final SmsApplicationData smsApplicationData = receivers.get(packageName);
            if (DEBUG_MULTIUSER) {
                Log.i(LOG_TAG, "getApplicationCollectionInternal packageName="
                        + packageName + " smsApplicationData: " + smsApplicationData
                        + " activityInfo.name: " + activityInfo.name);
            }
            if (smsApplicationData != null) {
                smsApplicationData.mSimFullReceiverClass = activityInfo.name;
            }
        }

        // Remove any entries for which we did not find all required intents.
        // Remove any entries for which we did not find all required intents.
        for (ResolveInfo resolveInfo : smsReceivers) {
        for (ResolveInfo resolveInfo : smsReceivers) {
            final ActivityInfo activityInfo = resolveInfo.activityInfo;
            final ActivityInfo activityInfo = resolveInfo.activityInfo;
@@ -883,6 +914,31 @@ public final class SmsApplication {
        }
        }
    }
    }


    /**
     * Gets the default application that handles sim full event.
     * @param context context from the calling app
     * @param updateIfNeeded update the default app if there is no valid default app configured.
     * @return component name of the app and class to deliver change intents to
     */
    public static ComponentName getDefaultSimFullApplication(
            Context context, boolean updateIfNeeded) {
        int userId = getIncomingUserId(context);
        final long token = Binder.clearCallingIdentity();
        try {
            ComponentName component = null;
            SmsApplicationData smsApplicationData = getApplication(context, updateIfNeeded,
                    userId);
            if (smsApplicationData != null
                    && smsApplicationData.mSimFullReceiverClass != null) {
                component = new ComponentName(smsApplicationData.mPackageName,
                        smsApplicationData.mSimFullReceiverClass);
            }
            return component;
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }

    /**
    /**
     * Returns whether need to write the SMS message to SMS database for this package.
     * Returns whether need to write the SMS message to SMS database for this package.
     * <p>
     * <p>
+3 −2
Original line number Original line Diff line number Diff line
@@ -137,12 +137,13 @@ public class SmsStorageMonitor extends Handler {
    }
    }


    /**
    /**
     * Called when SIM_FULL message is received from the RIL.  Notifies interested
     * Called when SIM_FULL message is received from the RIL. Notifies the default SMS application
     * parties that SIM storage for SMS messages is full.
     * that SIM storage for SMS messages is full.
     */
     */
    private void handleIccFull() {
    private void handleIccFull() {
        // broadcast SIM_FULL intent
        // broadcast SIM_FULL intent
        Intent intent = new Intent(Intents.SIM_FULL_ACTION);
        Intent intent = new Intent(Intents.SIM_FULL_ACTION);
        intent.setComponent(SmsApplication.getDefaultSimFullApplication(mContext, false));
        mWakeLock.acquire(WAKE_LOCK_TIMEOUT);
        mWakeLock.acquire(WAKE_LOCK_TIMEOUT);
        SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhone.getPhoneId());
        SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhone.getPhoneId());
        mContext.sendBroadcast(intent, android.Manifest.permission.RECEIVE_SMS);
        mContext.sendBroadcast(intent, android.Manifest.permission.RECEIVE_SMS);
+1 −3
Original line number Original line Diff line number Diff line
@@ -43,13 +43,12 @@ import android.os.RegistrantList;
import android.os.ServiceManager;
import android.os.ServiceManager;
import android.provider.BlockedNumberContract;
import android.provider.BlockedNumberContract;
import android.telephony.ServiceState;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.test.mock.MockContentProvider;
import android.test.mock.MockContentProvider;
import android.test.mock.MockContentResolver;
import android.test.mock.MockContentResolver;
import android.util.Log;
import android.util.Log;
import android.util.Singleton;
import android.util.Singleton;
import android.util.SparseArray;


import com.android.ims.ImsCall;
import com.android.ims.ImsCall;
import com.android.ims.ImsCallProfile;
import com.android.ims.ImsCallProfile;
@@ -61,7 +60,6 @@ import com.android.internal.telephony.dataconnection.DcTracker;
import com.android.internal.telephony.imsphone.ImsExternalCallTracker;
import com.android.internal.telephony.imsphone.ImsExternalCallTracker;
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
import com.android.internal.telephony.mocks.TelephonyRegistryMock;
import com.android.internal.telephony.test.SimulatedCommands;
import com.android.internal.telephony.test.SimulatedCommands;
import com.android.internal.telephony.test.SimulatedCommandsVerifier;
import com.android.internal.telephony.test.SimulatedCommandsVerifier;
import com.android.internal.telephony.uicc.IccCardProxy;
import com.android.internal.telephony.uicc.IccCardProxy;
+9 −6
Original line number Original line Diff line number Diff line
@@ -16,6 +16,12 @@


package com.android.internal.telephony.gsm;
package com.android.internal.telephony.gsm;


import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;

import android.content.Intent;
import android.content.Intent;
import android.os.HandlerThread;
import android.os.HandlerThread;
import android.provider.Telephony;
import android.provider.Telephony;
@@ -31,12 +37,6 @@ import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mock;


import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;

public class GsmCellBroadcastHandlerTest extends TelephonyTest {
public class GsmCellBroadcastHandlerTest extends TelephonyTest {
    @Mock
    @Mock
    private SmsStorageMonitor mSmsStorageMonitor;
    private SmsStorageMonitor mSmsStorageMonitor;
@@ -85,6 +85,9 @@ public class GsmCellBroadcastHandlerTest extends TelephonyTest {


    @Test @SmallTest
    @Test @SmallTest
    public void testBroadcastSms() {
    public void testBroadcastSms() {
        mContextFixture.putResource(
                com.android.internal.R.string.config_defaultCellBroadcastReceiverComponent,
                "fake.cellbroadcastreceiver.component");
        mSimulatedCommands.notifyGsmBroadcastSms(new byte[] {
        mSimulatedCommands.notifyGsmBroadcastSms(new byte[] {
                (byte)0xc0, //geographical scope
                (byte)0xc0, //geographical scope
                (byte)0x01, //serial number
                (byte)0x01, //serial number