Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/java/com/android/internal/telephony/Phone.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private static class NetworkSelectMessage {
private boolean mImsServiceReady = false;
protected Phone mImsPhone = null;

private final AtomicReference<RadioCapability> mRadioCapability =
protected final AtomicReference<RadioCapability> mRadioCapability =
new AtomicReference<RadioCapability>();

private static final int DEFAULT_REPORT_INTERVAL_MS = 200;
Expand Down
24 changes: 15 additions & 9 deletions src/java/com/android/internal/telephony/PhoneFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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.
Expand All @@ -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);

Expand All @@ -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);
}
}
}
Expand Down
57 changes: 31 additions & 26 deletions src/java/com/android/internal/telephony/PhoneSwitcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<DcRequest> mPrioritizedDcRequests = new ArrayList<DcRequest>();
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<DcRequest> mPrioritizedDcRequests = new ArrayList<DcRequest>();
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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand All @@ -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");
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down
30 changes: 15 additions & 15 deletions src/java/com/android/internal/telephony/SubscriptionController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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<Integer, Integer> sSlotIndexToSubId =
new ConcurrentHashMap<Integer, Integer>();
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;

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -1277,29 +1277,29 @@ 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);
}

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);
}
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -1533,7 +1533,7 @@ public void clearDefaultsForInactiveSubIds() {
}
}

private boolean shouldDefaultBeCleared(List<SubscriptionInfo> records, int subId) {
protected boolean shouldDefaultBeCleared(List<SubscriptionInfo> records, int subId) {
if (DBG) logdl("[shouldDefaultBeCleared: subId] " + subId);
if (records == null) {
if (DBG) logdl("[shouldDefaultBeCleared] return true no records subId=" + subId);
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
}
Expand All @@ -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();
Expand Down
Loading