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

Commit d2c00121 authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Revert "Fix issue where redial connection change is notified on wrong phone."

This reverts commit 0a74874a.

Reason for revert: ImsPhone is a valid recipient of TelephonyConnection callbacks

Bug: 193805172
Change-Id: I4ada4e7a224dc666cea2199f12bc71f3d2d99590
parent be447bc8
Loading
Loading
Loading
Loading
+11 −25
Original line number Diff line number Diff line
@@ -200,8 +200,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    // Single Radio Voice Call Continuity
    @VisibleForTesting
    protected static final int EVENT_SRVCC_STATE_CHANGED             = 31;
    @VisibleForTesting
    public static final int EVENT_INITIATE_SILENT_REDIAL           = 32;
    private static final int EVENT_INITIATE_SILENT_REDIAL           = 32;
    private static final int EVENT_RADIO_NOT_AVAILABLE              = 33;
    private static final int EVENT_UNSOL_OEM_HOOK_RAW               = 34;
    protected static final int EVENT_GET_RADIO_CAPABILITY           = 35;
@@ -357,11 +356,6 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    private static final boolean LCE_PULL_MODE = true;
    private int mLceStatus = RILConstants.LCE_NOT_AVAILABLE;
    protected TelephonyComponentFactory mTelephonyComponentFactory;
    /**
     * Should ALWAYS be {@code true} in production code.  This is used only used in tests so that we
     * can disable the read checks which interfer with unit testing.
     */
    private boolean mAreThreadChecksEnabled = true;

    //IMS
    /**
@@ -743,7 +737,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
                break;

            case EVENT_INITIATE_SILENT_REDIAL:
                Rlog.i(LOG_TAG, "Event EVENT_INITIATE_SILENT_REDIAL Received");
                Rlog.d(LOG_TAG, "Event EVENT_INITIATE_SILENT_REDIAL Received");
                ar = (AsyncResult) msg.obj;
                if ((ar.exception == null) && (ar.result != null)) {
                    SilentRedialParam result = (SilentRedialParam) ar.result;
@@ -753,12 +747,16 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
                    if (TextUtils.isEmpty(dialString)) return;
                    try {
                        Connection cn = dialInternal(dialString, dialArgs);
                        Rlog.i(LOG_TAG, "Notify redial connection changed cn: " + cn);
                        notifyRedialConnectionChanged(cn);
                        Rlog.d(LOG_TAG, "Notify redial connection changed cn: " + cn);
                        if (mImsPhone != null) {
                            // Don't care it is null or not.
                            mImsPhone.notifyRedialConnectionChanged(cn);
                        }
                    } catch (CallStateException e) {
                        Rlog.e(LOG_TAG, "Notify redial connection changed - silent redial failed: "
                                + e);
                        notifyRedialConnectionChanged(null);
                        Rlog.e(LOG_TAG, "silent redial failed: " + e);
                        if (mImsPhone != null) {
                            mImsPhone.notifyRedialConnectionChanged(null);
                        }
                    }
                }
                break;
@@ -1764,9 +1762,6 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
     * the thread that originally obtained this Phone instance.
     */
    private void checkCorrectThread(Handler h) {
        if (!mAreThreadChecksEnabled) {
            return;
        }
        if (h.getLooper() != mLooper) {
            throw new RuntimeException(
                    "com.android.internal.telephony.Phone must be used from within one thread");
@@ -5036,13 +5031,4 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    private static String pii(String s) {
        return Rlog.pii(LOG_TAG, s);
    }

    /**
     * Used in unit tests to disable the thread checks.  Should not be used otherwise.
     * @param enabled {@code true} if thread checks are enabled, {@code false} otherwise.
     */
    @VisibleForTesting
    public void setAreThreadChecksEnabled(boolean enabled) {
        mAreThreadChecksEnabled = enabled;
    }
}
+0 −26
Original line number Diff line number Diff line
@@ -112,7 +112,6 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
    private static final int EVENT_EMERGENCY_CALLBACK_MODE_EXIT = 1;
    private static final int EVENT_EMERGENCY_CALL_TOGGLE = 2;
    private static final int EVENT_SET_ICC_LOCK_ENABLED = 3;
    private static final int EVENT_SILENT_REDIAL_CONNECTION_CHANGED = 4;

    private void switchToGsm() {
        mSimulatedCommands.setVoiceRadioTech(ServiceState.RIL_RADIO_TECHNOLOGY_GSM);
@@ -640,31 +639,6 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        assertFalse(mPhoneUT.handlePinMmi("1234567890"));
    }

    /**
     * Verifies that silent redial connection changes are raised on the phone itself, not on the
     * ImsPhone.
     */
    @Test
    @SmallTest
    public void testSilentRedialNotify() {
        mPhoneUT.setAreThreadChecksEnabled(false);
        mPhoneUT.registerForRedialConnectionChanged(mTestHandler,
                EVENT_SILENT_REDIAL_CONNECTION_CHANGED, null);

        // Raise a silent redial on the GsmCdmaPhone.
        Phone.SilentRedialParam params = new Phone.SilentRedialParam("6505551212", 0, null);
        AsyncResult result = new AsyncResult(null, params, null);
        Message.obtain(mPhoneUT, Phone.EVENT_INITIATE_SILENT_REDIAL, result).sendToTarget();
        processAllMessages();

        // We expect our test handler to have the registered redial connection changed event
        // raised on it.
        ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
        verify(mTestHandler).sendMessageDelayed(messageCaptor.capture(), anyLong());
        assertEquals(1, messageCaptor.getAllValues().size());
        assertEquals(EVENT_SILENT_REDIAL_CONNECTION_CHANGED, messageCaptor.getValue().what);
    }

    @Test
    @SmallTest
    public void testEmergencySmsMode() {
+0 −3
Original line number Diff line number Diff line
@@ -471,9 +471,6 @@ public abstract class TelephonyTest {
                BlockedNumberContract.AUTHORITY, mFakeBlockedNumberContentProvider);
        mPhone.mCi = mSimulatedCommands;
        mCT.mCi = mSimulatedCommands;
        mCT.mForegroundCall = new GsmCdmaCall(mCT);
        mCT.mBackgroundCall = new GsmCdmaCall(mCT);
        mCT.mRingingCall = new GsmCdmaCall(mCT);
        doReturn(mUiccCard).when(mPhone).getUiccCard();
        doReturn(mUiccProfile).when(mUiccCard).getUiccProfile();