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

Commit 43f55e59 authored by Sandeep Gutta's avatar Sandeep Gutta Committed by Linux Build Service Account
Browse files

Telephony(MSIM): Add support for MultiSim.

--> Subscription specific for Mobile data, roaming and usage
     - Provide database flags as per subscription for both Mobile
       data and Data roaming options.

--> Add sub based API for getAllCellInfo in TelephonyManager.

--> Use Dds subId to get Sim state, roaming state in NetworkPolicyService.

Change-Id: I6ee5d2a22e44fe7d0d68a41af0481ddbbbe21c3f
parent 364018f2
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;

import java.util.Objects;
@@ -150,11 +151,11 @@ public class NetworkIdentity {
        if (isNetworkTypeMobile(type)) {
            final TelephonyManager telephony = (TelephonyManager) context.getSystemService(
                    Context.TELEPHONY_SERVICE);
            roaming = telephony.isNetworkRoaming();
            roaming = telephony.isNetworkRoaming(SubscriptionManager.getDefaultDataSubId());
            if (state.subscriberId != null) {
                subscriberId = state.subscriberId;
            } else {
                subscriberId = telephony.getSubscriberId();
                subscriberId = telephony.getSubscriberId(SubscriptionManager.getDefaultDataSubId());
            }

        } else if (type == TYPE_WIFI) {
+21 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings.Global;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;

@@ -2495,6 +2496,20 @@ public class DatabaseHelper extends SQLiteOpenHelper {
                            SystemProperties.get("ro.com.android.mobiledata",
                                    "true")) ? 1 : 0);

            int phoneCount = TelephonyManager.getDefault().getPhoneCount();
            // SUB specific flags for Multisim devices
            for (int phoneId = 0; phoneId < phoneCount; phoneId++) {
                // Mobile Data default, based on build
                loadSetting(stmt, Settings.Global.MOBILE_DATA + phoneId,
                        "true".equalsIgnoreCase(
                        SystemProperties.get("ro.com.android.mobiledata", "true")) ? 1 : 0);

                // Data roaming default, based on build
                loadSetting(stmt, Settings.Global.DATA_ROAMING + phoneId,
                        "true".equalsIgnoreCase(
                        SystemProperties.get("ro.com.android.dataroaming", "true")) ? 1 : 0);
            }

            loadBooleanSetting(stmt, Settings.Global.NETSTATS_ENABLED,
                    R.bool.def_netstats_enabled);

@@ -2548,7 +2563,12 @@ public class DatabaseHelper extends SQLiteOpenHelper {
            int type;
            type = SystemProperties.getInt("ro.telephony.default_network",
                        RILConstants.PREFERRED_NETWORK_MODE);
            loadSetting(stmt, Settings.Global.PREFERRED_NETWORK_MODE, type);
            String val = Integer.toString(type);
            for (int phoneId = 1; phoneId < phoneCount; phoneId++) {
                val = val + "," + type;
            }

            loadSetting(stmt, Settings.Global.PREFERRED_NETWORK_MODE, val);

            // Set the preferred cdma subscription source to target desired value or default
            // value defined in CdmaSubscriptionSourceManager
+16 −6
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.format.Formatter;
import android.text.format.Time;
@@ -748,8 +749,10 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
            case MATCH_MOBILE_ALL:
                // mobile templates are relevant when SIM is ready and
                // subscriberId matches.
                if (tele.getSimState() == SIM_STATE_READY) {
                    return Objects.equals(tele.getSubscriberId(), template.getSubscriberId());
                if (isDdsSimStateReady()) {
                    return Objects.equals(tele.getSubscriberId(
                            SubscriptionManager.getDefaultDataSubId()),
                            template.getSubscriberId());
                } else {
                    return false;
                }
@@ -1013,8 +1016,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
            case MATCH_MOBILE_ALL:
                // TODO: offer more granular control over radio states once
                // 4965893 is available.
                if (tele.getSimState() == SIM_STATE_READY
                        && Objects.equals(tele.getSubscriberId(), template.getSubscriberId())) {
                if (isDdsSimStateReady() && Objects.equals(tele.getSubscriberId(
                    SubscriptionManager.getDefaultDataSubId()), template.getSubscriberId())) {
                    setPolicyDataEnable(TYPE_MOBILE, enabled);
                    setPolicyDataEnable(TYPE_WIMAX, enabled);
                }
@@ -1205,9 +1208,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
        final TelephonyManager tele = TelephonyManager.from(mContext);

        // avoid creating policy when SIM isn't ready
        if (tele.getSimState() != SIM_STATE_READY) return;
        if (!isDdsSimStateReady()) return;

        final String subscriberId = tele.getSubscriberId();
        final String subscriberId = tele.getSubscriberId(SubscriptionManager.getDefaultDataSubId());
        final NetworkIdentity probeIdent = new NetworkIdentity(
                TYPE_MOBILE, TelephonyManager.NETWORK_TYPE_UNKNOWN, subscriberId, null, false);

@@ -2259,4 +2262,11 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
        }
        fout.print("]");
    }

    // Return true if SIM state of DDS subscription is in READY state
    private boolean isDdsSimStateReady() {
        final TelephonyManager tm = TelephonyManager.from(mContext);
        int slotId = SubscriptionManager.getSlotId(SubscriptionManager.getDefaultDataSubId());
        return tm.getSimState(slotId) == TelephonyManager.SIM_STATE_READY;
    }
}
+9 −9
Original line number Diff line number Diff line
@@ -1216,7 +1216,7 @@ public class TelephonyManager {
     * @hide
     */
    public int getDataNetworkType() {
        return getDataNetworkType(getDefaultSubscription());
        return getDataNetworkType(SubscriptionManager.getDefaultDataSubId());
    }

    /**
@@ -1388,7 +1388,7 @@ public class TelephonyManager {
            case NETWORK_TYPE_GSM:
                return "GSM";
            case NETWORK_TYPE_TD_SCDMA:
                return "TD_SCDMA";
                return "TD-SCDMA";
            default:
                return "UNKNOWN";
        }
@@ -2367,8 +2367,13 @@ public class TelephonyManager {
     * <p>Requires Permission: {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}
     */
    public List<CellInfo> getAllCellInfo() {
        return getAllCellInfo(getDefaultSubscription());
    }

    /** {@hide} */
    public List<CellInfo> getAllCellInfo(long subId) {
        try {
            return getITelephony().getAllCellInfo();
            return getITelephony().getAllCellInfoUsingSubId(subId);
        } catch (RemoteException ex) {
            return null;
        } catch (NullPointerException ex) {
@@ -2838,12 +2843,7 @@ public class TelephonyManager {

    /** @hide */
    public int getSimCount() {
        if(isMultiSimEnabled()) {
        //TODO Need to get it from Telephony Devcontroller
            return 2;
        } else {
           return 1;
        }
        return getPhoneCount();
    }

    /**
+3 −0
Original line number Diff line number Diff line
@@ -490,6 +490,9 @@ interface ITelephony {
     */
    List<CellInfo> getAllCellInfo();


    List<CellInfo> getAllCellInfoUsingSubId(long subId);

    /**
     * Sets minimum time in milli-seconds between onCellInfoChanged
     */
+1 −1

File changed.

Contains only whitespace changes.

Loading