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

Commit 4fa1ab70 authored by Ecco Park's avatar Ecco Park
Browse files

CarrierConfig: add persist_lpp_mode_bool



Removing carrier specific function from
GnssLocationProvider.java

This property is used for persisting the current
lpp_mode of carrier even after sim is removed

Instead, we will use the property of carrier config

Bug: 32250938

Change-Id: Ibc69883723392cb0fbfcd8dbf3e866860db9dd5d
Signed-off-by: default avatarEcco Park <eccopark@google.com>
parent fa4c3114
Loading
Loading
Loading
Loading
+17 −31
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import android.os.AsyncTask;
import android.os.BatteryStats;
import android.os.Binder;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -75,6 +76,7 @@ import android.telephony.SmsMessage;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.TelephonyManager;
import android.telephony.CarrierConfigManager;
import android.telephony.gsm.GsmCellLocation;
import android.text.TextUtils;
import android.util.Log;
@@ -396,10 +398,6 @@ public class GnssLocationProvider implements LocationProviderInterface {
    // Persist property for LPP_PROFILE
    private final static String LPP_PROFILE = "persist.sys.gps.lpp";

    // VZW PLMN info
    private static final String[] VzwMccMncList = {"311480", "310004", "20404"};
    // corresponding GID1 value, empty string means ignore gid1 match.
    private static final String[] VzwGid1List = {"", "", "BAE0000000000000"};


    private final PowerManager mPowerManager;
@@ -520,41 +518,29 @@ public class GnssLocationProvider implements LocationProviderInterface {
        }
    };

    private final boolean isVerizon(String mccMnc, String imsi, String groupId) {
        if (DEBUG) Log.d(TAG, "simOperator: " + mccMnc);
        if (!TextUtils.isEmpty(mccMnc) || !TextUtils.isEmpty(imsi)) {
            for (int i = 0; i < VzwMccMncList.length; i++) {
                if ((!TextUtils.isEmpty(mccMnc) && mccMnc.equals(VzwMccMncList[i])) ||
                        (!TextUtils.isEmpty(imsi) && imsi.startsWith(VzwMccMncList[i]))) {
                    // check gid too if needed
                    if (TextUtils.isEmpty(VzwGid1List[i]) || VzwGid1List[i].equals(groupId)) {
                        if (DEBUG) Log.d(TAG, "Verizon UICC");
                        return true;
                    }
                }
            }
        }
        return false;
    }

    private void subscriptionOrSimChanged(Context context) {
        if (DEBUG) Log.d(TAG, "received SIM related action: ");
        TelephonyManager phone = (TelephonyManager)
                mContext.getSystemService(Context.TELEPHONY_SERVICE);
        CarrierConfigManager configManager = (CarrierConfigManager)
                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        String mccMnc = phone.getSimOperator();
        String imsi = phone.getSubscriberId();
        String groupId = phone.getGroupIdLevel1();
        boolean isKeepLppProfile = false;
        if (!TextUtils.isEmpty(mccMnc)) {
            if (DEBUG) Log.d(TAG, "SIM MCC/MNC is available: " + mccMnc);
            synchronized (mLock) {
                if (isVerizon(mccMnc, imsi, groupId)) {
                        // load current properties for carrier VZW
                if (configManager != null) {
                    PersistableBundle b = configManager.getConfig();
                    isKeepLppProfile = b.getBoolean(CarrierConfigManager.KEY_PERSIST_LPP_MODE_BOOL);
                }
                if (isKeepLppProfile) {
                    // load current properties for the carrier
                    loadPropertiesFromResource(context, mProperties);
                    String lpp_profile = mProperties.getProperty("LPP_PROFILE");
                        // set the persist property LPP_PROFILE for VZW
                    // set the persist property LPP_PROFILE for the value
                    SystemProperties.set(LPP_PROFILE, lpp_profile);
                } else {
                        // reset the persist property for Non VZW
                    // reset the persist property
                    SystemProperties.set(LPP_PROFILE, "");
                }
                reloadGpsProperties(context, mProperties);
+13 −0
Original line number Diff line number Diff line
@@ -1072,6 +1072,18 @@ public class CarrierConfigManager {
    public static final String KEY_EDITABLE_WFC_ROAMING_MODE_BOOL =
            "editable_wfc_roaming_mode_bool";

   /**
     * Determine whether current lpp_mode used for E-911 needs to be kept persistently.
     * {@code false} - not keeping the lpp_mode means using default configuration of gps.conf
     *                 when sim is not presented.
     * {@code true}  - current lpp_profile of carrier will be kepted persistently
     *                 even after sim is removed.
     *
     * @hide
     */
    public static final String KEY_PERSIST_LPP_MODE_BOOL = "persist_lpp_mode_bool";


    /** The default value for every variable. */
    private final static PersistableBundle sDefaults;

@@ -1266,6 +1278,7 @@ public class CarrierConfigManager {
        sDefaults.putStringArray(FILTERED_CNAP_NAMES_STRING_ARRAY, null);
        sDefaults.putBoolean(KEY_EDITABLE_WFC_ROAMING_MODE_BOOL, false);
        sDefaults.putBoolean(KEY_STK_DISABLE_LAUNCH_BROWSER_BOOL, false);
        sDefaults.putBoolean(KEY_PERSIST_LPP_MODE_BOOL, false);
    }

    /**