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

Commit 6bfad803 authored by Jack Yu's avatar Jack Yu
Browse files

Fixed failed unit tests

Test: runtest --path frameworks/opt/telephony/tests/telephonytests/
bug: 29579544

Merged-In: Ib53a4e7fee5dee1f305303bfbd914e31cdd2ab71
Change-Id: Ib53a4e7fee5dee1f305303bfbd914e31cdd2ab71
parent fe88f5e6
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -99,12 +99,16 @@ public class CellBroadcastHandler extends WakeLockStateMachine {
        SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhone.getPhoneId());

        if (Build.IS_DEBUGGABLE) {
            // Send additional broadcast intent to the specified package. This is only for sl4a
            // automation tests.
            final String additionalPackage = Settings.Secure.getString(
                    mContext.getContentResolver(), CMAS_ADDITIONAL_BROADCAST_PKG);
            if (additionalPackage != null) {
                intent.setPackage(additionalPackage);
                mContext.sendOrderedBroadcastAsUser(intent, UserHandle.ALL, receiverPermission,
                        appOp, null, getHandler(), Activity.RESULT_OK, null, null);
                Intent additionalIntent = new Intent(intent);
                additionalIntent.setPackage(additionalPackage);
                mContext.sendOrderedBroadcastAsUser(additionalIntent, UserHandle.ALL,
                        receiverPermission, appOp, null, getHandler(), Activity.RESULT_OK, null,
                        null);
            }
        }

+3 −1
Original line number Diff line number Diff line
@@ -502,8 +502,10 @@ public abstract class Connection {
    }

    protected final void clearPostDialListeners() {
        if (mPostDialListeners != null) {
            mPostDialListeners.clear();
        }
    }

    protected final void notifyPostDialListeners() {
        if (getPostDialState() == PostDialState.WAIT) {
+29 −27
Original line number Diff line number Diff line
@@ -225,8 +225,7 @@ public class GsmCdmaConnection extends Connection {
        releaseAllWakeLocks();
    }

    static boolean
    equalsHandlesNulls (Object a, Object b) {
    static boolean equalsHandlesNulls(Object a, Object b) {
        return (a == null) ? (b == null) : a.equals (b);
    }

@@ -806,13 +805,13 @@ public class GsmCdmaConnection extends Connection {
    protected void finalize()
    {
        /**
         * It is understood that This finializer is not guaranteed
         * It is understood that This finalizer is not guaranteed
         * to be called and the release lock call is here just in
         * case there is some path that doesn't call onDisconnect
         * and or onConnectedInOrOut.
         */
        if (mPartialWakeLock.isHeld()) {
            Rlog.e(LOG_TAG, "[GsmCdmaConn] UNEXPECTED; mPartialWakeLock is held when finalizing.");
        if (mPartialWakeLock != null && mPartialWakeLock.isHeld()) {
            Rlog.e(LOG_TAG, "UNEXPECTED; mPartialWakeLock is held when finalizing.");
        }
        clearPostDialListeners();
        releaseWakeLock();
@@ -937,20 +936,22 @@ public class GsmCdmaConnection extends Connection {
        notifyPostDialListeners();
    }

    private void
    createWakeLock(Context context) {
    private void createWakeLock(Context context) {
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        mPartialWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, LOG_TAG);
    }

    private void
    acquireWakeLock() {
    private void acquireWakeLock() {
        if (mPartialWakeLock != null) {
            synchronized (mPartialWakeLock) {
                log("acquireWakeLock");
                mPartialWakeLock.acquire();
            }
        }
    }

    private void
    releaseWakeLock() {
    private void releaseWakeLock() {
        if (mPartialWakeLock != null) {
            synchronized (mPartialWakeLock) {
                if (mPartialWakeLock.isHeld()) {
                    log("releaseWakeLock");
@@ -958,15 +959,17 @@ public class GsmCdmaConnection extends Connection {
                }
            }
        }
    }

    private void
    releaseAllWakeLocks() {
    private void releaseAllWakeLocks() {
        if (mPartialWakeLock != null) {
            synchronized (mPartialWakeLock) {
                while (mPartialWakeLock.isHeld()) {
                    mPartialWakeLock.release();
                }
            }
        }
    }

    private static boolean isPause(char c) {
        return c == PhoneNumberUtils.PAUSE;
@@ -984,8 +987,7 @@ public class GsmCdmaConnection extends Connection {
    // This function is to find the next PAUSE character index if
    // multiple pauses in a row. Otherwise it finds the next non PAUSE or
    // non WAIT character index.
    private static int
    findNextPCharOrNonPOrNonWCharIndex(String phoneNumber, int currIndex) {
    private static int findNextPCharOrNonPOrNonWCharIndex(String phoneNumber, int currIndex) {
        boolean wMatched = isWait(phoneNumber.charAt(currIndex));
        int index = currIndex + 1;
        int length = phoneNumber.length();
@@ -1016,8 +1018,8 @@ public class GsmCdmaConnection extends Connection {
    // This function returns either PAUSE or WAIT character to append.
    // It is based on the next non PAUSE/WAIT character in the phoneNumber and the
    // index for the current PAUSE/WAIT character
    private static char
    findPOrWCharToAppend(String phoneNumber, int currPwIndex, int nextNonPwCharIndex) {
    private static char findPOrWCharToAppend(String phoneNumber, int currPwIndex,
                                             int nextNonPwCharIndex) {
        char c = phoneNumber.charAt(currPwIndex);
        char ret;

+5 −6
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static android.hardware.radio.V1_0.DeviceStateType.LOW_DATA_EXPECTED;

import static com.android.internal.telephony.TelephonyTestUtils.waitForMs;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.nullable;
import static org.mockito.Mockito.times;
@@ -97,10 +96,10 @@ public class DeviceStateMonitorTest extends TelephonyTest {
        waitForMs(100);

        verify(mSimulatedCommandsVerifier, times(1)).setUnsolResponseFilter(eq(0),
                any(Message.class));
                nullable(Message.class));

        verify(mSimulatedCommandsVerifier, times(1)).sendDeviceState(eq(LOW_DATA_EXPECTED),
                eq(true), any(Message.class));
                eq(true), nullable(Message.class));
    }

    @FlakyTest
@@ -121,12 +120,12 @@ public class DeviceStateMonitorTest extends TelephonyTest {
        waitForMs(100);

        verify(mSimulatedCommandsVerifier, times(1)).setUnsolResponseFilter(eq(0),
                any(Message.class));
                nullable(Message.class));

        verify(mSimulatedCommandsVerifier, times(1)).sendDeviceState(eq(LOW_DATA_EXPECTED),
                eq(true), any(Message.class));
                eq(true), nullable(Message.class));

        verify(mSimulatedCommandsVerifier, times(1)).sendDeviceState(eq(CHARGING_STATE),
                eq(false), any(Message.class));
                eq(false), nullable(Message.class));
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -858,7 +858,8 @@ public class ServiceStateTrackerTest extends TelephonyTest {

        // verify if registered handler has message posted to it
        messageArgumentCaptor = ArgumentCaptor.forClass(Message.class);
        verify(mTestHandler).sendMessageAtTime(messageArgumentCaptor.capture(), anyLong());
        verify(mTestHandler, times(2)).sendMessageAtTime(messageArgumentCaptor.capture(),
                anyLong());
        assertEquals(EVENT_REGISTERED_TO_NETWORK, messageArgumentCaptor.getValue().what);
    }

Loading