diff --git a/src/java/com/android/internal/telephony/Phone.java b/src/java/com/android/internal/telephony/Phone.java index 6b7e95c5ee..addb51807f 100755 --- a/src/java/com/android/internal/telephony/Phone.java +++ b/src/java/com/android/internal/telephony/Phone.java @@ -272,7 +272,7 @@ private static class NetworkSelectMessage { private boolean mImsServiceReady = false; protected Phone mImsPhone = null; - private final AtomicReference mRadioCapability = + protected final AtomicReference mRadioCapability = new AtomicReference(); private static final int DEFAULT_REPORT_INTERVAL_MS = 200; diff --git a/src/java/com/android/internal/telephony/PhoneFactory.java b/src/java/com/android/internal/telephony/PhoneFactory.java index b4cf18a7bc..0ba9d4f05b 100644 --- a/src/java/com/android/internal/telephony/PhoneFactory.java +++ b/src/java/com/android/internal/telephony/PhoneFactory.java @@ -132,6 +132,8 @@ public static void makeDefaultPhone(Context context) { } sPhoneNotifier = new DefaultPhoneNotifier(); + TelephonyComponentFactory telephonyComponentFactory + = TelephonyComponentFactory.getInstance(); int cdmaSubscription = CdmaSubscriptionSourceManager.getDefault(context); Rlog.i(LOG_TAG, "Cdma Subscription set to " + cdmaSubscription); @@ -162,8 +164,8 @@ where as in single SIM mode only instance. isMultiSimEnabled() function checks cdmaSubscription, i); } Rlog.i(LOG_TAG, "Creating SubscriptionController"); - SubscriptionController.init(context, sCommandsInterfaces); - + telephonyComponentFactory.initSubscriptionController( + context, sCommandsInterfaces); // Instantiate UiccController so that all other classes can just // call getInstance() sUiccController = UiccController.make(context, sCommandsInterfaces); @@ -172,15 +174,15 @@ where as in single SIM mode only instance. isMultiSimEnabled() function checks Phone phone = null; int phoneType = TelephonyManager.getPhoneType(networkModes[i]); if (phoneType == PhoneConstants.PHONE_TYPE_GSM) { - phone = new GsmCdmaPhone(context, + phone = telephonyComponentFactory.makePhone(context, sCommandsInterfaces[i], sPhoneNotifier, i, PhoneConstants.PHONE_TYPE_GSM, - TelephonyComponentFactory.getInstance()); + telephonyComponentFactory); } else if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) { - phone = new GsmCdmaPhone(context, + phone = telephonyComponentFactory.makePhone(context, sCommandsInterfaces[i], sPhoneNotifier, i, PhoneConstants.PHONE_TYPE_CDMA_LTE, - TelephonyComponentFactory.getInstance()); + telephonyComponentFactory); } Rlog.i(LOG_TAG, "Creating Phone with type = " + phoneType + " sub = " + i); @@ -209,8 +211,8 @@ where as in single SIM mode only instance. isMultiSimEnabled() function checks sMadeDefaults = true; Rlog.i(LOG_TAG, "Creating SubInfoRecordUpdater "); - sSubInfoRecordUpdater = new SubscriptionInfoUpdater(context, - sPhones, sCommandsInterfaces); + sSubInfoRecordUpdater = telephonyComponentFactory.makeSubscriptionInfoUpdater( + context, sPhones, sCommandsInterfaces); SubscriptionController.getInstance().updatePhonesAvailability(sPhones); // Start monitoring after defaults have been made. @@ -227,7 +229,8 @@ where as in single SIM mode only instance. isMultiSimEnabled() function checks sSubscriptionMonitor = new SubscriptionMonitor(tr, sContext, sc, numPhones); - sPhoneSwitcher = new PhoneSwitcher(MAX_ACTIVE_PHONES, numPhones, + sPhoneSwitcher = telephonyComponentFactory. + makePhoneSwitcher(MAX_ACTIVE_PHONES, numPhones, sContext, sc, Looper.myLooper(), tr, sCommandsInterfaces, sPhones); @@ -242,6 +245,9 @@ where as in single SIM mode only instance. isMultiSimEnabled() function checks sPhoneSwitcher, sc, sSubscriptionMonitor, Looper.myLooper(), sContext, i, sPhones[i].mDcTracker); } + + telephonyComponentFactory.makeExtTelephonyClasses( + context, sPhones, sCommandsInterfaces); } } } diff --git a/src/java/com/android/internal/telephony/PhoneSwitcher.java b/src/java/com/android/internal/telephony/PhoneSwitcher.java index 15dc842a08..67e4d2b809 100644 --- a/src/java/com/android/internal/telephony/PhoneSwitcher.java +++ b/src/java/com/android/internal/telephony/PhoneSwitcher.java @@ -57,29 +57,34 @@ * the active phones. Note we don't wait for data attach (which may not happen anyway). */ public class PhoneSwitcher extends Handler { - private final static String LOG_TAG = "PhoneSwitcher"; - private final static boolean VDBG = false; - - private final int mMaxActivePhones; - private final List mPrioritizedDcRequests = new ArrayList(); - private final RegistrantList[] mActivePhoneRegistrants; - private final SubscriptionController mSubscriptionController; - private final int[] mPhoneSubscriptions; - private final CommandsInterface[] mCommandsInterfaces; - private final Context mContext; - private final PhoneState[] mPhoneStates; - private final int mNumPhones; - private final Phone[] mPhones; + protected final static String LOG_TAG = "PhoneSwitcher"; + protected final static boolean VDBG = false; + + protected int mMaxActivePhones; + protected final List mPrioritizedDcRequests = new ArrayList(); + protected final RegistrantList[] mActivePhoneRegistrants; + protected final SubscriptionController mSubscriptionController; + protected final int[] mPhoneSubscriptions; + protected final CommandsInterface[] mCommandsInterfaces; + protected final Context mContext; + protected final PhoneState[] mPhoneStates; + protected final int mNumPhones; + protected final Phone[] mPhones; private final LocalLog mLocalLog; - private int mDefaultDataSubscription; + protected int mDefaultDataSubscription; - private final static int EVENT_DEFAULT_SUBSCRIPTION_CHANGED = 101; - private final static int EVENT_SUBSCRIPTION_CHANGED = 102; - private final static int EVENT_REQUEST_NETWORK = 103; + protected final static int EVENT_DEFAULT_SUBSCRIPTION_CHANGED = 101; + protected final static int EVENT_SUBSCRIPTION_CHANGED = 102; + protected final static int EVENT_REQUEST_NETWORK = 103; private final static int EVENT_RELEASE_NETWORK = 104; private final static int EVENT_EMERGENCY_TOGGLE = 105; private final static int EVENT_RESEND_DATA_ALLOWED = 106; + protected final static int EVENT_ALLOW_DATA_RESPONSE = 107; + protected final static int EVENT_VOICE_CALL_ENDED = 108; + protected final static int EVENT_DATA_RAT_CHANGED = 109; + protected static final int EVENT_UNSOL_MAX_DATA_ALLOWED_CHANGED = 110; + protected static final int EVENT_OEM_HOOK_SERVICE_READY = 111; private final static int MAX_LOCAL_LOG_LINES = 30; @@ -203,7 +208,7 @@ public void handleMessage(Message msg) { } } - private boolean isEmergency() { + protected boolean isEmergency() { for (Phone p : mPhones) { if (p == null) continue; if (p.isInEcm() || p.isInEmergencyCall()) return true; @@ -254,7 +259,7 @@ private void onReleaseNetwork(NetworkRequest networkRequest) { } private static final boolean REQUESTS_CHANGED = true; - private static final boolean REQUESTS_UNCHANGED = false; + protected static final boolean REQUESTS_UNCHANGED = false; /** * Re-evaluate things. * Do nothing if nothing's changed. @@ -264,7 +269,7 @@ private void onReleaseNetwork(NetworkRequest networkRequest) { * phones that aren't in the active phone list. Finally, activate all * phones in the active phone list. */ - private void onEvaluate(boolean requestsChanged, String reason) { + protected void onEvaluate(boolean requestsChanged, String reason) { StringBuilder sb = new StringBuilder(reason); if (isEmergency()) { log("onEvalute aborted due to Emergency"); @@ -325,12 +330,12 @@ private void onEvaluate(boolean requestsChanged, String reason) { } } - private static class PhoneState { + protected static class PhoneState { public volatile boolean active = false; public long lastRequested = 0; } - private void deactivate(int phoneId) { + protected void deactivate(int phoneId) { PhoneState state = mPhoneStates[phoneId]; if (state.active == false) return; state.active = false; @@ -340,7 +345,7 @@ private void deactivate(int phoneId) { mActivePhoneRegistrants[phoneId].notifyRegistrants(); } - private void activate(int phoneId) { + protected void activate(int phoneId) { PhoneState state = mPhoneStates[phoneId]; if (state.active == true) return; state.active = true; @@ -359,12 +364,12 @@ public void resendDataAllowed(int phoneId) { msg.sendToTarget(); } - private void onResendDataAllowed(Message msg) { + protected void onResendDataAllowed(Message msg) { final int phoneId = msg.arg1; mCommandsInterfaces[phoneId].setDataAllowed(mPhoneStates[phoneId].active, null); } - private int phoneIdForRequest(NetworkRequest netRequest) { + protected int phoneIdForRequest(NetworkRequest netRequest) { NetworkSpecifier specifier = netRequest.networkCapabilities.getNetworkSpecifier(); int subId; @@ -417,7 +422,7 @@ private void validatePhoneId(int phoneId) { } } - private void log(String l) { + protected void log(String l) { Rlog.d(LOG_TAG, l); mLocalLog.log(l); } diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java index 187f1cfba4..10bb90bd68 100644 --- a/src/java/com/android/internal/telephony/SubscriptionController.java +++ b/src/java/com/android/internal/telephony/SubscriptionController.java @@ -74,8 +74,8 @@ */ public class SubscriptionController extends ISub.Stub { static final String LOG_TAG = "SubscriptionController"; - static final boolean DBG = true; - static final boolean VDBG = false; + protected static final boolean DBG = true; + protected static final boolean VDBG = false; static final int MAX_LOCAL_LOG_LINES = 500; // TODO: Reduce to 100 when 17678050 is fixed private ScLocalLog mLocalLog = new ScLocalLog(MAX_LOCAL_LOG_LINES); @@ -120,7 +120,7 @@ public synchronized void dump(FileDescriptor fd, PrintWriter pw, String[] args) protected final Object mLock = new Object(); /** The singleton instance. */ - private static SubscriptionController sInstance = null; + protected static SubscriptionController sInstance = null; protected static Phone[] sPhones; protected Context mContext; protected TelephonyManager mTelephonyManager; @@ -131,8 +131,8 @@ public synchronized void dump(FileDescriptor fd, PrintWriter pw, String[] args) // FIXME: Does not allow for multiple subs in a slot and change to SparseArray private static Map sSlotIndexToSubId = new ConcurrentHashMap(); - private static int mDefaultFallbackSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; - private static int mDefaultPhoneId = SubscriptionManager.DEFAULT_PHONE_INDEX; + protected static int mDefaultFallbackSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; + protected static int mDefaultPhoneId = SubscriptionManager.DEFAULT_PHONE_INDEX; private int[] colorArr; @@ -227,7 +227,7 @@ private boolean canReadPhoneState(String callingPackage, String message) { callingPackage) == AppOpsManager.MODE_ALLOWED; } - private void enforceModifyPhoneState(String message) { + protected void enforceModifyPhoneState(String message) { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.MODIFY_PHONE_STATE, message); } @@ -1231,7 +1231,7 @@ public int getPhoneId(int subId) { } - private int[] getDummySubIds(int slotIndex) { + protected int[] getDummySubIds(int slotIndex) { // FIXME: Remove notion of Dummy SUBSCRIPTION_ID. // I tested this returning null as no one appears to care, // but no connection came up on sprout with two sims. @@ -1277,21 +1277,21 @@ public int clearSubInfo() { } } - private void logvl(String msg) { + protected void logvl(String msg) { logv(msg); mLocalLog.log(msg); } - private void logv(String msg) { + protected void logv(String msg) { Rlog.v(LOG_TAG, msg); } - private void logdl(String msg) { + protected void logdl(String msg) { logd(msg); mLocalLog.log(msg); } - private static void slogd(String msg) { + protected static void slogd(String msg) { Rlog.d(LOG_TAG, msg); } @@ -1299,7 +1299,7 @@ private void logd(String msg) { Rlog.d(LOG_TAG, msg); } - private void logel(String msg) { + protected void logel(String msg) { loge(msg); mLocalLog.log(msg); } @@ -1472,7 +1472,7 @@ protected void broadcastDefaultDataSubIdChanged(int subId) { * sub is set as default subId. If two or more sub's are active * the first sub is set as default subscription */ - private void setDefaultFallbackSubId(int subId) { + protected void setDefaultFallbackSubId(int subId) { if (subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) { throw new RuntimeException("setDefaultSubId called with DEFAULT_SUB_ID"); } @@ -1533,7 +1533,7 @@ public void clearDefaultsForInactiveSubIds() { } } - private boolean shouldDefaultBeCleared(List records, int subId) { + protected boolean shouldDefaultBeCleared(List records, int subId) { if (DBG) logdl("[shouldDefaultBeCleared: subId] " + subId); if (records == null) { if (DBG) logdl("[shouldDefaultBeCleared] return true no records subId=" + subId); @@ -1792,7 +1792,7 @@ public String getSubscriptionProperty(int subId, String propKey, String callingP return resultValue; } - private static void printStackTrace(String msg) { + protected static void printStackTrace(String msg) { RuntimeException re = new RuntimeException(); slogd("StackTrace - " + msg); StackTraceElement[] st = re.getStackTrace(); diff --git a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java index e33fc8cd60..234b5457ae 100644 --- a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +++ b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java @@ -102,7 +102,7 @@ public class SubscriptionInfoUpdater extends Handler { private static Phone[] mPhone; private static Context mContext = null; - private static String mIccId[] = new String[PROJECT_SIM_NUM]; + protected static String mIccId[] = new String[PROJECT_SIM_NUM]; private static int[] mInsertSimState = new int[PROJECT_SIM_NUM]; private SubscriptionManager mSubscriptionManager = null; private IPackageManager mPackageManager; @@ -231,7 +231,7 @@ public void onReceive(Context context, Intent intent) { } }; - private boolean isAllIccIdQueryDone() { + protected boolean isAllIccIdQueryDone() { for (int i = 0; i < PROJECT_SIM_NUM; i++) { if (mIccId[i] == null) { logd("Wait for SIM" + (i + 1) + " IccId"); @@ -506,7 +506,7 @@ private void updateCarrierServices(int slotId, String simState) { mCarrierServiceBindHelper.updateForPhoneId(slotId, simState); } - private void handleSimAbsent(int slotId) { + protected void handleSimAbsent(int slotId) { if (mIccId[slotId] != null && !mIccId[slotId].equals(ICCID_STRING_FOR_NO_SIM)) { logd("SIM" + (slotId + 1) + " hot plug out"); } @@ -532,7 +532,7 @@ private void handleSimError(int slotId) { * TODO: Simplify more, as no one is interested in what happened * only what the current list contains. */ - synchronized private void updateSubscriptionInfoByIccId() { + synchronized protected void updateSubscriptionInfoByIccId() { logd("updateSubscriptionInfoByIccId:+ Start"); mSubscriptionManager.clearSubscriptionInfo(); diff --git a/src/java/com/android/internal/telephony/TelephonyComponentFactory.java b/src/java/com/android/internal/telephony/TelephonyComponentFactory.java index 193d29e152..f0dea13354 100644 --- a/src/java/com/android/internal/telephony/TelephonyComponentFactory.java +++ b/src/java/com/android/internal/telephony/TelephonyComponentFactory.java @@ -20,7 +20,9 @@ import android.database.Cursor; import android.os.Handler; import android.os.IDeviceIdleController; +import android.os.Looper; import android.os.ServiceManager; +import android.telephony.Rlog; import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager; import com.android.internal.telephony.cdma.EriManager; @@ -28,36 +30,76 @@ import com.android.internal.telephony.imsphone.ImsExternalCallTracker; import com.android.internal.telephony.imsphone.ImsPhone; import com.android.internal.telephony.imsphone.ImsPhoneCallTracker; +import com.android.internal.telephony.PhoneConstants; +import com.android.internal.telephony.SubscriptionController; import com.android.internal.telephony.uicc.IccCardProxy; +import dalvik.system.PathClassLoader; + +import java.lang.reflect.Method; +import java.lang.reflect.Constructor; +import java.io.File; + /** * This class has one-line methods to instantiate objects only. The purpose is to make code * unit-test friendly and use this class as a way to do dependency injection. Instantiating objects * this way makes it easier to mock them in tests. */ public class TelephonyComponentFactory { + protected static String LOG_TAG = "TelephonyComponentFactory"; + private static TelephonyComponentFactory sInstance; public static TelephonyComponentFactory getInstance() { if (sInstance == null) { - sInstance = new TelephonyComponentFactory(); + String fullClsName = "com.qualcomm.qti.internal.telephony.QtiTelephonyComponentFactory"; + String libPath = "/system/framework/qti-telephony-common.jar"; + + PathClassLoader classLoader = new PathClassLoader(libPath, + ClassLoader.getSystemClassLoader()); + Rlog.d(LOG_TAG, "classLoader = " + classLoader); + + if (fullClsName == null || fullClsName.length() == 0) { + Rlog.d(LOG_TAG, "no customized TelephonyPlugin available, fallback to default"); + fullClsName = "com.android.internal.telephony.TelephonyComponentFactory"; + } + Class cls = null; + try { + cls = Class.forName(fullClsName, false, classLoader); + Rlog.d(LOG_TAG, "cls = " + cls); + Constructor custMethod = cls.getConstructor(); + Rlog.d(LOG_TAG, "constructor method = " + custMethod); + sInstance = (TelephonyComponentFactory) custMethod.newInstance(); + } catch (NoClassDefFoundError e) { + e.printStackTrace(); + Rlog.e(LOG_TAG, "error loading TelephonyComponentFactory"); + sInstance = new TelephonyComponentFactory(); + } catch (Exception e) { + e.printStackTrace(); + Rlog.e(LOG_TAG, "Error loading TelephonyComponentFactory"); + sInstance = new TelephonyComponentFactory(); + } } return sInstance; } public GsmCdmaCallTracker makeGsmCdmaCallTracker(GsmCdmaPhone phone) { + Rlog.d(LOG_TAG, "makeGsmCdmaCallTracker"); return new GsmCdmaCallTracker(phone); } public SmsStorageMonitor makeSmsStorageMonitor(Phone phone) { + Rlog.d(LOG_TAG, "makeSmsStorageMonitor"); return new SmsStorageMonitor(phone); } public SmsUsageMonitor makeSmsUsageMonitor(Context context) { + Rlog.d(LOG_TAG, "makeSmsUsageMonitor"); return new SmsUsageMonitor(context); } public ServiceStateTracker makeServiceStateTracker(GsmCdmaPhone phone, CommandsInterface ci) { + Rlog.d(LOG_TAG, "makeServiceStateTracker"); return new ServiceStateTracker(phone, ci); } @@ -66,6 +108,7 @@ public SimActivationTracker makeSimActivationTracker(Phone phone) { } public DcTracker makeDcTracker(Phone phone) { + Rlog.d(LOG_TAG, "makeDcTracker"); return new DcTracker(phone); } @@ -78,22 +121,27 @@ public CarrierActionAgent makeCarrierActionAgent(Phone phone) { } public IccPhoneBookInterfaceManager makeIccPhoneBookInterfaceManager(Phone phone) { + Rlog.d(LOG_TAG, "makeIccPhoneBookInterfaceManager"); return new IccPhoneBookInterfaceManager(phone); } public IccSmsInterfaceManager makeIccSmsInterfaceManager(Phone phone) { + Rlog.d(LOG_TAG, "makeIccSmsInterfaceManager"); return new IccSmsInterfaceManager(phone); } public IccCardProxy makeIccCardProxy(Context context, CommandsInterface ci, int phoneId) { + Rlog.d(LOG_TAG, "makeIccCardProxy"); return new IccCardProxy(context, ci, phoneId); } public EriManager makeEriManager(Phone phone, Context context, int eriFileSource) { + Rlog.d(LOG_TAG, "makeEriManager"); return new EriManager(phone, context, eriFileSource); } public WspTypeDecoder makeWspTypeDecoder(byte[] pdu) { + Rlog.d(LOG_TAG, "makeWspTypeDecoder"); return new WspTypeDecoder(pdu); } @@ -103,6 +151,7 @@ public WspTypeDecoder makeWspTypeDecoder(byte[] pdu) { public InboundSmsTracker makeInboundSmsTracker(byte[] pdu, long timestamp, int destPort, boolean is3gpp2, boolean is3gpp2WapPdu, String address, String displayAddr, String messageBody) { + Rlog.d(LOG_TAG, "makeInboundSmsTracker"); return new InboundSmsTracker(pdu, timestamp, destPort, is3gpp2, is3gpp2WapPdu, address, displayAddr, messageBody); } @@ -113,6 +162,7 @@ public InboundSmsTracker makeInboundSmsTracker(byte[] pdu, long timestamp, int d public InboundSmsTracker makeInboundSmsTracker(byte[] pdu, long timestamp, int destPort, boolean is3gpp2, String address, String displayAddr, int referenceNumber, int sequenceNumber, int messageCount, boolean is3gpp2WapPdu, String messageBody) { + Rlog.d(LOG_TAG, "makeInboundSmsTracker"); return new InboundSmsTracker(pdu, timestamp, destPort, is3gpp2, address, displayAddr, referenceNumber, sequenceNumber, messageCount, is3gpp2WapPdu, messageBody); } @@ -125,6 +175,7 @@ public InboundSmsTracker makeInboundSmsTracker(Cursor cursor, boolean isCurrentF } public ImsPhoneCallTracker makeImsPhoneCallTracker(ImsPhone imsPhone) { + Rlog.d(LOG_TAG, "makeImsPhoneCallTracker"); return new ImsPhoneCallTracker(imsPhone); } @@ -147,11 +198,57 @@ public DeviceStateMonitor makeDeviceStateMonitor(Phone phone) { public CdmaSubscriptionSourceManager getCdmaSubscriptionSourceManagerInstance(Context context, CommandsInterface ci, Handler h, int what, Object obj) { + Rlog.d(LOG_TAG, "getCdmaSubscriptionSourceManagerInstance"); return CdmaSubscriptionSourceManager.getInstance(context, ci, h, what, obj); } public IDeviceIdleController getIDeviceIdleController() { + Rlog.d(LOG_TAG, "getIDeviceIdleController"); return IDeviceIdleController.Stub.asInterface( ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER)); } + + public Phone makePhone(Context context, CommandsInterface ci, PhoneNotifier notifier, + int phoneId, int precisePhoneType, + TelephonyComponentFactory telephonyComponentFactory) { + Rlog.d(LOG_TAG, "makePhone"); + Phone phone = null; + if (precisePhoneType == PhoneConstants.PHONE_TYPE_GSM) { + phone = new GsmCdmaPhone(context, + ci, notifier, phoneId, + PhoneConstants.PHONE_TYPE_GSM, + telephonyComponentFactory); + } else if (precisePhoneType == PhoneConstants.PHONE_TYPE_CDMA) { + phone = new GsmCdmaPhone(context, + ci, notifier, phoneId, + PhoneConstants.PHONE_TYPE_CDMA_LTE, + telephonyComponentFactory); + } + return phone; + } + + public SubscriptionController initSubscriptionController(Context c, CommandsInterface[] ci) { + Rlog.d(LOG_TAG, "initSubscriptionController"); + return SubscriptionController.init(c, ci); + } + + public SubscriptionInfoUpdater makeSubscriptionInfoUpdater(Context context, Phone[] phones, + CommandsInterface[] ci) { + Rlog.d(LOG_TAG, "makeSubscriptionInfoUpdater"); + return new SubscriptionInfoUpdater(context, phones, ci); + } + + public void makeExtTelephonyClasses(Context context, + Phone[] phones, CommandsInterface[] commandsInterfaces) { + Rlog.d(LOG_TAG, "makeExtTelephonyClasses"); + } + + public PhoneSwitcher makePhoneSwitcher(int maxActivePhones, int numPhones, Context context, + SubscriptionController subscriptionController, Looper looper, ITelephonyRegistry tr, + CommandsInterface[] cis, Phone[] phones) { + Rlog.d(LOG_TAG, "makePhoneSwitcher"); + return new PhoneSwitcher(maxActivePhones,numPhones, + context, subscriptionController, looper, tr, cis, + phones); + } } diff --git a/tests/telephonytests/src/com/android/internal/telephony/TelephonyComponentFactoryTest.java b/tests/telephonytests/src/com/android/internal/telephony/TelephonyComponentFactoryTest.java new file mode 100644 index 0000000000..5b833d9a68 --- /dev/null +++ b/tests/telephonytests/src/com/android/internal/telephony/TelephonyComponentFactoryTest.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2016, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +package com.android.internal.telephony; + +import android.app.AlarmManager; +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.database.Cursor; +import android.database.MatrixCursor; +import android.net.LinkProperties; +import android.net.Uri; +import android.os.HandlerThread; +import android.os.IBinder; +import android.os.Message; +import android.os.ServiceManager; +import android.provider.Telephony; +import android.telephony.ServiceState; +import android.test.mock.MockContentProvider; +import android.test.mock.MockContentResolver; +import android.test.suitebuilder.annotation.MediumTest; + +import com.android.internal.telephony.dataconnection.DataCallResponse; +import com.android.internal.telephony.dataconnection.DcTracker; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Mock; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static com.android.internal.telephony.TelephonyTestUtils.waitForMs; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyLong; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +public class TelephonyComponentFactoryTest extends TelephonyTest { + + @Before + public void setUp() throws Exception { + super.setUp(getClass().getSimpleName()); + } + + @Override + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + @Test + public void testMakeDcTracker() { + TelephonyComponentFactory telephonyComponentFactory + = TelephonyComponentFactory.getInstance(); + DcTracker dcTracker = telephonyComponentFactory.makeDcTracker(mPhone); + + //FIXME: Uncomment below once QtiDcTracker is available. + //assertFalse(dcTracker instanceof DcTracker); + assertTrue(dcTracker instanceof DcTracker); + } + + //TODO: Add test for all factory methods of TelephonyComponentFactory +}