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

Commit 3848da04 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update notifySmsSent() feature flag dependency" into main

parents 938fcf74 faa0419d
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -1060,16 +1060,17 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    }

    /**
     * Notify the phone that an SMS has been sent. This will be used determine if the SMS was sent
     * to an emergency address.
     * Notify the phone that an SMS has been sent. This will be used to determine if the SMS was
     * sent to an emergency address.
     *
     * @param destinationAddress the address that the SMS was sent to.
     */
    public void notifySmsSent(String destinationAddress) {
        TelephonyManager m = (TelephonyManager) getContext().getSystemService(
                Context.TELEPHONY_SERVICE);
        TelephonyManager m =
                (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
        if (mContext.getPackageManager() != null
                && mContext.getPackageManager().hasSystemFeature(
                        PackageManager.FEATURE_TELEPHONY_CALLING)) {
                && mContext.getPackageManager()
                                .hasSystemFeature(PackageManager.FEATURE_TELEPHONY_MESSAGING)) {
            if (m != null && m.isEmergencyNumber(destinationAddress)) {
                mLocalLog.log("Emergency SMS detected, recording time.");
                mTimeLastEmergencySmsSentMs = SystemClock.elapsedRealtime();
+4 −4
Original line number Diff line number Diff line
@@ -640,16 +640,16 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        doReturn(true).when(mTelephonyManager).isEmergencyNumber(emergencyNumber);

        // Feature flag enabled
        // Device does not have FEATURE_TELEPHONY_CALLING
        // Device does not have FEATURE_TELEPHONY_MESSAGING
        doReturn(false).when(mPackageManager).hasSystemFeature(
                eq(PackageManager.FEATURE_TELEPHONY_CALLING));
                eq(PackageManager.FEATURE_TELEPHONY_MESSAGING));
        mPhoneUT.notifySmsSent(emergencyNumber);
        processAllMessages();
        assertFalse(mPhoneUT.isInEmergencySmsMode());

        // Device has FEATURE_TELEPHONY_CALLING
        // Device has FEATURE_TELEPHONY_MESSAGING
        doReturn(true).when(mPackageManager).hasSystemFeature(
                eq(PackageManager.FEATURE_TELEPHONY_CALLING));
                eq(PackageManager.FEATURE_TELEPHONY_MESSAGING));
        mPhoneUT.notifySmsSent(emergencyNumber);
        processAllMessages();
        assertTrue(mPhoneUT.isInEmergencySmsMode());