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

Commit 2883ea73 authored by Chaitanya Saggurthi's avatar Chaitanya Saggurthi Committed by Steve Kondik
Browse files

Telephony(MSIM): Add support for MultiSim

Make changes to add support for MultiSim.
  -Add TelephonyManager and TelePhonyRegistry for MultiSim
  -Add ITelephony and IPhoneSubinfo aidl files for MultiSim
  -Extend ShutdownThread to close all radio's for MultiSim
  -Add Constants and Utils used for MultiSim

Add prompt support for SMS
 - Add prompt option in SMS multi sim settings.
 - New iterface API to get SMS prompt is enabled or not.
 - Disply prompt while sending SMS, if user selects
   prompt mode in multi sim settings.

Change Default subscription property name.
 - Change default subscription property name from
   persist.default.subscription to persist.radio.default.sub so
   that it can be set by radio group access processes.

Subscription specific for Mobile data, roaming and usage
 - Provide database flags as per subscription for both Mobile
   data and Data roaming options.
 - Add function to provide DDS susbcriber id.

Set priority when send sms
 - Add the priority support in 3gpp2 text message

Add support for emergency calls
 -Populate ecclist by reading ril.ecclist corresponds to
  each subscription.
 -If dialed number is present in consolidated ecclist then
  mark as emergency number.

Define invalid subscription constant
 -Define a new constant for invalid subscription id.

Third Party Intent Handling
 -Remove firing of below intents from TelephonyRegistry when
  Multisim is enabled, as they will be fired from MSimTelephonyReistry
  ACTION_SERVICE_STATE_CHANGED
  ACTION_SIGNAL_STRENGTH_CHANGED
  ACTION_ANY_DATA_CONNECTION_STATE_CHANGED
  ACTION_DATA_CONNECTION_FAILED
 -Remove below intent from both TelephonyRegistry & MSimTelephonyReistry
  as it will be fired in MSimDefaultNotifier.
   ACTION_PHONE_STATE_CHANGED

Change-Id: I6ee5d2a22e44fe7d0d68a41af0481ddbbbe21c3f
(cherry picked from commit 1014515bac8729ecc20493f763e00a3953c738e0)
(cherry picked from commit 021c08f412bc6117f9b139376371f3344d90abfb)
parent 56940543
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -265,9 +265,12 @@ LOCAL_SRC_FILES += \
	media/java/android/media/IRingtonePlayer.aidl \
	telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \
	telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \
	telephony/java/com/android/internal/telephony/msim/IPhoneSubInfoMSim.aidl \
	telephony/java/com/android/internal/telephony/ITelephony.aidl \
	telephony/java/com/android/internal/telephony/msim/ITelephonyMSim.aidl \
	telephony/java/com/android/internal/telephony/ISms.aidl \
	telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl \
	telephony/java/com/android/internal/telephony/ITelephonyRegistryMSim.aidl \
	telephony/java/com/android/internal/telephony/IWapPushManager.aidl \
	wifi/java/android/net/wifi/IWifiManager.aidl \
	wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl \
@@ -402,7 +405,9 @@ aidl_files := \
	frameworks/base/location/java/com/android/internal/location/ProviderRequest.aidl \
	frameworks/base/telephony/java/android/telephony/ServiceState.aidl \
	frameworks/base/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \
	frameworks/base/telephony/java/com/android/internal/telephony/msim/IPhoneSubInfoMSim.aidl \
	frameworks/base/telephony/java/com/android/internal/telephony/ITelephony.aidl \
    frameworks/base/telephony/java/com/android/internal/telephony/msim/ITelephonyMSim.aidl \
	frameworks/base/wifi/java/android/net/wifi/BatchedScanSettings.aidl \
	frameworks/base/wifi/java/android/net/wifi/BatchedScanResult.aidl \

+10 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012-2013 The Linux Foundation. All rights reserved.
 * Not a Contribution.
 * Copyright (C) 2006 The Android Open Source Project
 * This code has been modified.  Portions copyright (C) 2010, T-Mobile USA, Inc.
 *
@@ -102,6 +104,7 @@ import android.os.storage.IMountService;
import android.os.storage.StorageManager;
import android.print.IPrintManager;
import android.print.PrintManager;
import android.telephony.MSimTelephonyManager;
import android.telephony.TelephonyManager;
import android.content.ClipboardManager;
import android.util.AndroidRuntimeException;
@@ -508,6 +511,13 @@ class ContextImpl extends Context {
                    return new TelephonyManager(ctx.getOuterContext());
                }});

        if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
            registerService(MSIM_TELEPHONY_SERVICE, new ServiceFetcher() {
                    public Object createService(ContextImpl ctx) {
                        return new MSimTelephonyManager(ctx.getOuterContext());
                    }});
        }

        registerService(UI_MODE_SERVICE, new ServiceFetcher() {
                public Object createService(ContextImpl ctx) {
                    return new UiModeManager();
+14 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012-2013 The Linux Foundation. All rights reserved.
 * Not a Contribution.
 * Copyright (C) 2006 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -2273,6 +2275,17 @@ public abstract class Context {
     */
    public static final String TELEPHONY_SERVICE = "phone";

    /**
     * Use with {@link #getSystemService} to retrieve a
     * {android.telephony.MSimTelephonyManager} for handling the management
     * of the telephony features of the multi sim device.
     *
     * @see #getSystemService
     * @see android.telephony.MSimTelephonyManager
     * @hide
     */
    public static final String MSIM_TELEPHONY_SERVICE = "phone_msim";

    /**
     * Use with {@link #getSystemService} to retrieve a
     * {@link android.text.ClipboardManager} for accessing and modifying
+66 −19
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012-2013 The Linux Foundation. All rights reserved.
 * Not a Contribution.
 * Copyright (C) 2008 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,6 +30,7 @@ import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.telephony.MSimTelephonyManager;
import android.telephony.PhoneStateListener;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
@@ -36,6 +39,7 @@ import android.util.Slog;

import com.android.internal.telephony.DctConstants;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.msim.ITelephonyMSim;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.util.AsyncChannel;
@@ -59,6 +63,7 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker {

    private PhoneConstants.DataState mMobileDataState;
    private ITelephony mPhoneService;
    private ITelephonyMSim mMSimPhoneService;

    private String mApnType;
    private NetworkInfo mNetworkInfo;
@@ -370,6 +375,13 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker {
    }

    private void getPhoneService(boolean forceRefresh) {
        if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
            if (mMSimPhoneService == null || forceRefresh) {
                mMSimPhoneService = ITelephonyMSim.Stub.asInterface(
                        ServiceManager.getService("phone_msim"));
            }
            return;
        }
        if ((mPhoneService == null) || forceRefresh) {
            mPhoneService = ITelephony.Stub.asInterface(ServiceManager.getService("phone"));
        }
@@ -551,6 +563,23 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker {
         * RemoteException and need to re-reference the service.
         */
        for (int retry = 0; retry < 2; retry++) {
            if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
                if (mMSimPhoneService == null) {
                    loge("Ignoring mobile radio request because "
                            + "could not acquire MSim Phone Service");
                    break;
                }

                try {
                    boolean result = true;
                    for (int i = 0; i < MSimTelephonyManager.getDefault().getPhoneCount(); i++) {
                        result = result && mMSimPhoneService.setRadio(turnOn, i);
                    }
                    return result;
                } catch (RemoteException e) {
                    if (retry == 0) getPhoneService(true);
                }
            } else {
                if (mPhoneService == null) {
                    loge("Ignoring mobile radio request because could not acquire PhoneService");
                    break;
@@ -562,6 +591,7 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker {
                    if (retry == 0) getPhoneService(true);
                }
            }
        }

        loge("Could not set radio power to " + (turnOn ? "on" : "off"));
        return false;
@@ -690,6 +720,22 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker {
         * RemoteException and need to re-reference the service.
         */
        for (int retry = 0; retry < 2; retry++) {
            if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
                if (mMSimPhoneService == null) {
                    loge("Ignoring feature request because could not acquire MSim Phone Service");
                    break;
                }

                try {
                    if (enable) {
                        return mMSimPhoneService.enableApnType(apnType);
                    } else {
                        return mMSimPhoneService.disableApnType(apnType);
                    }
                } catch (RemoteException e) {
                    if (retry == 0) getPhoneService(true);
                }
            } else {
                if (mPhoneService == null) {
                    loge("Ignoring feature request because could not acquire PhoneService");
                    break;
@@ -705,6 +751,7 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker {
                    if (retry == 0) getPhoneService(true);
                }
            }
        }

        loge("Could not " + (enable ? "enable" : "disable") + " APN type \"" + apnType + "\"");
        return PhoneConstants.APN_REQUEST_FAILED;
+37 −5
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
 * Not a Contribution.
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,8 +26,8 @@ import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.telephony.MSimTelephonyManager;
import android.telephony.TelephonyManager;

import com.android.internal.util.Objects;

/**
@@ -148,13 +150,12 @@ public class NetworkIdentity {
        boolean roaming = false;

        if (isNetworkTypeMobile(type)) {
            final TelephonyManager telephony = (TelephonyManager) context.getSystemService(
                    Context.TELEPHONY_SERVICE);
            roaming = telephony.isNetworkRoaming();
            roaming = isDdsRoaming();
            if (state.subscriberId != null) {
                subscriberId = state.subscriberId;
            } else {
                subscriberId = telephony.getSubscriberId();
                //used for dual sim data traffic statistics
                subscriberId = getDdsSubscriberId();
            }

        } else if (type == TYPE_WIFI) {
@@ -170,4 +171,35 @@ public class NetworkIdentity {

        return new NetworkIdentity(type, subType, subscriberId, networkId, roaming);
    }

    private static boolean isDdsRoaming() {
        MSimTelephonyManager mtm = MSimTelephonyManager.getDefault();
        TelephonyManager tm = TelephonyManager.getDefault();
        if (mtm.isMultiSimEnabled()) {
            return mtm.isNetworkRoaming(mtm.getPreferredDataSubscription());
        } else {
            return tm.isNetworkRoaming();
        }
    }

    public static String getDdsSubscriberId() {
        MSimTelephonyManager mtm = MSimTelephonyManager.getDefault();
        TelephonyManager tm = TelephonyManager.getDefault();
        if (mtm.isMultiSimEnabled()) {
            return mtm.getSubscriberId(mtm.getPreferredDataSubscription());
        } else {
            return tm.getSubscriberId();
        }
    }

    public static boolean isDdsReady() {
        MSimTelephonyManager mtm = MSimTelephonyManager.getDefault();
        TelephonyManager tm = TelephonyManager.getDefault();
        if (mtm.isMultiSimEnabled()) {
            return mtm.getSimState(mtm.getPreferredDataSubscription())
                    == TelephonyManager.SIM_STATE_READY;
        } else {
            return tm.getSimState() == TelephonyManager.SIM_STATE_READY;
        }
    }
}
Loading