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

Commit 97ac3487 authored by James Chen's avatar James Chen
Browse files

Revert "Switch to Context#sendStickyBroadcastAsUser"

This reverts commit d301e973.

Reason for revert: <b/147332986>

Change-Id: Ib459db846b7626bbc1b84145d91a7e1975b9a404
parent d301e973
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static com.android.internal.telephony.CommandsInterface.SERVICE_CLASS_VOI

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
@@ -775,7 +776,7 @@ public class GsmCdmaPhone extends Phone {
        Intent intent = new Intent(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
        intent.putExtra(PhoneConstants.PHONE_IN_ECM_STATE, isInEcm());
        SubscriptionManager.putPhoneIdAndSubIdExtra(intent, getPhoneId());
        mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
        ActivityManager.broadcastStickyIntent(intent, UserHandle.USER_ALL);
        logi("sendEmergencyCallbackModeChange");
    }

@@ -790,7 +791,7 @@ public class GsmCdmaPhone extends Phone {
            Intent intent = new Intent(TelephonyIntents.ACTION_EMERGENCY_CALL_STATE_CHANGED);
            intent.putExtra(PhoneConstants.PHONE_IN_EMERGENCY_CALL, callActive);
            SubscriptionManager.putPhoneIdAndSubIdExtra(intent, getPhoneId());
            mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
            ActivityManager.broadcastStickyIntent(intent, UserHandle.USER_ALL);
            if (DBG) Rlog.d(LOG_TAG, "sendEmergencyCallStateChange: callActive " + callActive);
        }
    }
@@ -3720,7 +3721,7 @@ public class GsmCdmaPhone extends Phone {
        Intent intent = new Intent(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
        intent.putExtra(PhoneConstants.PHONE_NAME_KEY, getPhoneName());
        SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhoneId);
        mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
        ActivityManager.broadcastStickyIntent(intent, UserHandle.USER_ALL);
    }

    private void switchVoiceRadioTech(int newVoiceRadioTech) {
+4 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.telephony;

import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -55,7 +56,7 @@ public class IntentBroadcaster {
                        logd("Rebroadcasting intent " + i.getAction() + " "
                                + i.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE)
                                + " for slotId " + pair.getKey());
                        context.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
                        ActivityManager.broadcastStickyIntent(i, UserHandle.USER_ALL);
                    }
                }
            }
@@ -85,12 +86,12 @@ public class IntentBroadcaster {
     * Wrapper for ActivityManager.broadcastStickyIntent() that also stores intent to be rebroadcast
     * on USER_UNLOCKED
     */
    public void broadcastStickyIntent(Context context, Intent intent, int phoneId) {
    public void broadcastStickyIntent(Intent intent, int phoneId) {
        logd("Broadcasting and adding intent for rebroadcast: " + intent.getAction() + " "
                + intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE)
                + " for phoneId " + phoneId);
        synchronized (mRebroadcastIntents) {
            context.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
            ActivityManager.broadcastStickyIntent(intent, UserHandle.USER_ALL);
            mRebroadcastIntents.put(phoneId, intent);
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -1092,7 +1092,7 @@ public class SubscriptionInfoUpdater extends Handler {
        SubscriptionManager.putPhoneIdAndSubIdExtra(i, phoneId);
        logd("Broadcasting intent ACTION_SIM_STATE_CHANGED " + state + " reason " + reason +
                " for phone: " + phoneId);
        IntentBroadcaster.getInstance().broadcastStickyIntent(sContext, i, phoneId);
        IntentBroadcaster.getInstance().broadcastStickyIntent(i, phoneId);
    }

    private void broadcastSimCardStateChanged(int phoneId, int state) {
+2 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import static com.android.internal.telephony.CommandsInterface.SERVICE_CLASS_NON
import static com.android.internal.telephony.CommandsInterface.SERVICE_CLASS_VOICE;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
@@ -1697,7 +1698,7 @@ public class ImsPhone extends ImsPhoneBase {
        Intent intent = new Intent(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
        intent.putExtra(PhoneConstants.PHONE_IN_ECM_STATE, isInEcm());
        SubscriptionManager.putPhoneIdAndSubIdExtra(intent, getPhoneId());
        mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
        ActivityManager.broadcastStickyIntent(intent, UserHandle.USER_ALL);
        if (DBG) logd("sendEmergencyCallbackModeChange: isInEcm=" + isInEcm());
    }

+56 −8
Original line number Diff line number Diff line
@@ -41,9 +41,13 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import android.app.Activity;
import android.app.IApplicationThread;
import android.content.IIntentReceiver;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncResult;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Process;
@@ -876,8 +880,19 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        // verify ACTION_EMERGENCY_CALLBACK_MODE_CHANGED
        ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
        try {
            verify(mContext, atLeast(1)).sendStickyBroadcastAsUser(intentArgumentCaptor.capture(),
                    any());
            verify(mIActivityManager, atLeast(1)).broadcastIntent(eq((IApplicationThread) null),
                    intentArgumentCaptor.capture(),
                    eq((String) null),
                    eq((IIntentReceiver) null),
                    eq(Activity.RESULT_OK),
                    eq((String) null),
                    eq((Bundle) null),
                    eq((String[]) null),
                    anyInt(),
                    eq((Bundle) null),
                    eq(false),
                    eq(true),
                    anyInt());
        } catch(Exception e) {
            fail("Unexpected exception: " + e.getStackTrace());
        }
@@ -899,8 +914,19 @@ public class GsmCdmaPhoneTest extends TelephonyTest {

        // verify ACTION_EMERGENCY_CALLBACK_MODE_CHANGED
        try {
            verify(mContext, atLeast(2)).sendStickyBroadcastAsUser(intentArgumentCaptor.capture(),
                    any());
            verify(mIActivityManager, atLeast(2)).broadcastIntent(eq((IApplicationThread) null),
                    intentArgumentCaptor.capture(),
                    eq((String) null),
                    eq((IIntentReceiver) null),
                    eq(Activity.RESULT_OK),
                    eq((String) null),
                    eq((Bundle) null),
                    eq((String[]) null),
                    anyInt(),
                    eq((Bundle) null),
                    eq(false),
                    eq(true),
                    anyInt());
        } catch(Exception e) {
            fail("Unexpected exception: " + e.getStackTrace());
        }
@@ -942,8 +968,19 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        // verify ACTION_EMERGENCY_CALLBACK_MODE_CHANGED
        ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
        try {
            verify(mContext, atLeast(1)).sendStickyBroadcastAsUser(intentArgumentCaptor.capture(),
                    any());
            verify(mIActivityManager, atLeast(1)).broadcastIntent(eq((IApplicationThread) null),
                    intentArgumentCaptor.capture(),
                    eq((String) null),
                    eq((IIntentReceiver) null),
                    eq(Activity.RESULT_OK),
                    eq((String) null),
                    eq((Bundle) null),
                    eq((String[]) null),
                    anyInt(),
                    eq((Bundle) null),
                    eq(false),
                    eq(true),
                    anyInt());
        } catch (Exception e) {
            fail("Unexpected exception: " + e.getStackTrace());
        }
@@ -965,8 +1002,19 @@ public class GsmCdmaPhoneTest extends TelephonyTest {

        // verify ACTION_EMERGENCY_CALLBACK_MODE_CHANGED
        try {
            verify(mContext, atLeast(2)).sendStickyBroadcastAsUser(intentArgumentCaptor.capture(),
                    any());
            verify(mIActivityManager, atLeast(2)).broadcastIntent(eq((IApplicationThread) null),
                    intentArgumentCaptor.capture(),
                    eq((String) null),
                    eq((IIntentReceiver) null),
                    eq(Activity.RESULT_OK),
                    eq((String) null),
                    eq((Bundle) null),
                    eq((String[]) null),
                    anyInt(),
                    eq((Bundle) null),
                    eq(false),
                    eq(true),
                    anyInt());
        } catch (Exception e) {
            fail("Unexpected exception: " + e.getStackTrace());
        }