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

Commit faa0419d authored by Madhav's avatar Madhav
Browse files

Update notifySmsSent() feature flag dependency

Given that  notifySmsSent() functionality is utilized by both calling
and messaging modules, and messaging can be enabled without calling,
the function's access control should be based on either
FEATURE_TELEPHONY_CALLING or
FEATURE_TELEPHONY_MESSAGING.

Bug: 395178686
Flag: EXEMPT bug fix
Test: atest CtsTelephonyTestCases --no-bazel-mode
Change-Id: I183097a4fb872a82295f9a738b95656d66fa9823
parent b58bf9cd
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -1059,16 +1059,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
@@ -748,16 +748,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());