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

Commit eb8f55d7 authored by Gary Jian's avatar Gary Jian
Browse files

Check the build type and property when calling setModemService

Only allow to modify the modem service if one of the following conditions met
1. userdebug build
2. persist.radio.allow_mock_modem as true

Bug: 220995034
Test: manual
Change-Id: I8410451623cf7d6814babb2a470dca8363b10dae
parent 18ffcab9
Loading
Loading
Loading
Loading
+26 −16
Original line number Diff line number Diff line
@@ -22,10 +22,12 @@ import static android.telephony.TelephonyManager.EXTRA_ACTIVE_SIM_SUPPORTED_COUN
import android.content.Context;
import android.content.Intent;
import android.os.AsyncResult;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.os.PowerManager;
import android.os.RegistrantList;
import android.os.SystemProperties;
import android.os.storage.StorageManager;
import android.sysprop.TelephonyProperties;
import android.telephony.PhoneCapability;
@@ -70,7 +72,8 @@ public class PhoneConfigurationManager {
    private MockableInterface mMi = new MockableInterface();
    private TelephonyManager mTelephonyManager;
    private static final RegistrantList sMultiSimConfigChangeRegistrants = new RegistrantList();

    private static final String ALLOW_MOCK_MODEM_PROPERTY = "persist.radio.allow_mock_modem";
    private static final boolean DEBUG = !"user".equals(Build.TYPE);
    /**
     * Init method to instantiate the object
     * Should only be called once.
@@ -457,7 +460,10 @@ public class PhoneConfigurationManager {
        log("setModemService: " + serviceName);
        boolean statusRadioConfig = false;
        boolean statusRil = false;
        final boolean isAllowed = SystemProperties.getBoolean(ALLOW_MOCK_MODEM_PROPERTY, false);

        // Check for ALLOW_MOCK_MODEM_PROPERTY on user builds
        if (isAllowed || DEBUG) {
            if (serviceName != null) {
                // Only CTS mock modem service is allowed to swith.
                if (!serviceName.equals(CTS_MOCK_MODEM_SERVICE)) {
@@ -477,6 +483,10 @@ public class PhoneConfigurationManager {
            }

            return statusRadioConfig && statusRil;
        } else {
            loge("setModemService is not allowed");
            return false;
        }
    }

     /**