use of android.telephony.SubscriptionInfo in project android_frameworks_base by AOSPA.
the class SimSwitchController method updateSubscriptions.
private void updateSubscriptions() {
int voicePrefSlot = -1;
IExtTelephony extTelephony = IExtTelephony.Stub.asInterface(ServiceManager.getService("extphone"));
mSubInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
if (mSubInfoList != null) {
for (SubscriptionInfo subInfo : mSubInfoList) {
int slotId = subInfo.getSimSlotIndex();
if (SubscriptionManager.isValidSlotId(slotId)) {
try {
mUiccProvisionStatus[slotId] = extTelephony.getCurrentUiccCardProvisioningStatus(slotId);
} catch (RemoteException ex) {
logd("Activate sub failed phoneId " + subInfo.getSimSlotIndex());
} catch (NullPointerException ex) {
logd("Failed to activate sub Exception: " + ex);
}
}
}
voicePrefSlot = getVoicePrefSlot();
}
updateViews(voicePrefSlot);
}
use of android.telephony.SubscriptionInfo in project android_frameworks_base by AOSPA.
the class NetworkControllerImpl method dispatchDemoCommand.
@Override
public void dispatchDemoCommand(String command, Bundle args) {
if (!mDemoMode && command.equals(COMMAND_ENTER)) {
if (DEBUG)
Log.d(TAG, "Entering demo mode");
unregisterListeners();
mDemoMode = true;
mDemoInetCondition = mInetCondition;
mDemoWifiState = mWifiSignalController.getState();
} else if (mDemoMode && command.equals(COMMAND_EXIT)) {
if (DEBUG)
Log.d(TAG, "Exiting demo mode");
mDemoMode = false;
// Update what MobileSignalControllers, because they may change
// to set the number of sim slots.
updateMobileControllers();
for (MobileSignalController controller : mMobileSignalControllers.values()) {
controller.resetLastState();
}
mWifiSignalController.resetLastState();
mReceiverHandler.post(mRegisterListeners);
notifyAllListeners();
} else if (mDemoMode && command.equals(COMMAND_NETWORK)) {
String airplane = args.getString("airplane");
if (airplane != null) {
boolean show = airplane.equals("show");
mCallbackHandler.setIsAirplaneMode(new IconState(show, TelephonyIcons.FLIGHT_MODE_ICON, R.string.accessibility_airplane_mode, mContext));
}
String fully = args.getString("fully");
if (fully != null) {
mDemoInetCondition = Boolean.parseBoolean(fully);
BitSet connected = new BitSet();
if (mDemoInetCondition) {
connected.set(mWifiSignalController.mTransportType);
}
mWifiSignalController.updateConnectivity(connected, connected);
for (MobileSignalController controller : mMobileSignalControllers.values()) {
if (mDemoInetCondition) {
connected.set(controller.mTransportType);
}
controller.updateConnectivity(connected, connected);
}
}
String wifi = args.getString("wifi");
if (wifi != null) {
boolean show = wifi.equals("show");
String level = args.getString("level");
if (level != null) {
mDemoWifiState.level = level.equals("null") ? -1 : Math.min(Integer.parseInt(level), WifiIcons.WIFI_LEVEL_COUNT - 1);
mDemoWifiState.connected = mDemoWifiState.level >= 0;
}
mDemoWifiState.enabled = show;
mWifiSignalController.notifyListeners();
}
String sims = args.getString("sims");
if (sims != null) {
int num = MathUtils.constrain(Integer.parseInt(sims), 1, 8);
List<SubscriptionInfo> subs = new ArrayList<>();
if (num != mMobileSignalControllers.size()) {
mMobileSignalControllers.clear();
int start = mSubscriptionManager.getActiveSubscriptionInfoCountMax();
for (int i = start; /* get out of normal index range */
i < start + num; i++) {
subs.add(addSignalController(i, i));
}
mCallbackHandler.setSubs(subs);
}
}
String nosim = args.getString("nosim");
if (nosim != null) {
mHasNoSims = nosim.equals("show");
mCallbackHandler.setNoSims(mHasNoSims);
}
String mobile = args.getString("mobile");
if (mobile != null) {
boolean show = mobile.equals("show");
String datatype = args.getString("datatype");
String slotString = args.getString("slot");
int slot = TextUtils.isEmpty(slotString) ? 0 : Integer.parseInt(slotString);
slot = MathUtils.constrain(slot, 0, 8);
// Ensure we have enough sim slots
List<SubscriptionInfo> subs = new ArrayList<>();
while (mMobileSignalControllers.size() <= slot) {
int nextSlot = mMobileSignalControllers.size();
subs.add(addSignalController(nextSlot, nextSlot));
}
if (!subs.isEmpty()) {
mCallbackHandler.setSubs(subs);
}
// Hack to index linearly for easy use.
MobileSignalController controller = mMobileSignalControllers.values().toArray(new MobileSignalController[0])[slot];
controller.getState().dataSim = datatype != null;
if (datatype != null) {
controller.getState().iconGroup = datatype.equals("1x") ? TelephonyIcons.ONE_X : datatype.equals("3g") ? TelephonyIcons.THREE_G : datatype.equals("4g") ? TelephonyIcons.FOUR_G : datatype.equals("4g+") ? TelephonyIcons.FOUR_G_PLUS : datatype.equals("e") ? TelephonyIcons.E : datatype.equals("g") ? TelephonyIcons.G : datatype.equals("h") ? TelephonyIcons.H : datatype.equals("lte") ? TelephonyIcons.LTE : datatype.equals("lte+") ? TelephonyIcons.LTE_PLUS : TelephonyIcons.UNKNOWN;
}
if (args.containsKey("roam")) {
controller.getState().roaming = "show".equals(args.getString("roam"));
}
int[][] icons = TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH;
String level = args.getString("level");
if (level != null) {
controller.getState().level = level.equals("null") ? -1 : Math.min(Integer.parseInt(level), icons[0].length - 1);
controller.getState().connected = controller.getState().level >= 0;
}
String activity = args.getString("activity");
if (activity != null) {
controller.setActivity(Integer.parseInt(activity));
}
controller.getState().enabled = show;
controller.notifyListeners();
}
String carrierNetworkChange = args.getString("carriernetworkchange");
if (carrierNetworkChange != null) {
boolean show = carrierNetworkChange.equals("show");
for (MobileSignalController controller : mMobileSignalControllers.values()) {
controller.setCarrierNetworkChangeMode(show);
}
}
}
}
use of android.telephony.SubscriptionInfo in project android_frameworks_base by AOSPA.
the class NetworkControllerBaseTest method setSubscriptions.
protected void setSubscriptions(int... subIds) {
List<SubscriptionInfo> subs = new ArrayList<SubscriptionInfo>();
for (int subId : subIds) {
SubscriptionInfo subscription = mock(SubscriptionInfo.class);
when(subscription.getSubscriptionId()).thenReturn(subId);
subs.add(subscription);
}
when(mMockSm.getActiveSubscriptionInfoList()).thenReturn(subs);
mNetworkController.doUpdateMobileControllers();
}
use of android.telephony.SubscriptionInfo in project android_frameworks_base by AOSPA.
the class NetworkControllerSignalTest method testHasCorrectMobileControllers.
// Some tests of actual NetworkController code, just internals not display stuff
// TODO: Put this somewhere else, maybe in its own file.
public void testHasCorrectMobileControllers() {
int[] testSubscriptions = new int[] { 1, 5, 3 };
int notTestSubscription = 0;
MobileSignalController mobileSignalController = Mockito.mock(MobileSignalController.class);
mNetworkController.mMobileSignalControllers.clear();
List<SubscriptionInfo> subscriptions = new ArrayList<>();
for (int i = 0; i < testSubscriptions.length; i++) {
// Force the test controllers into NetworkController.
mNetworkController.mMobileSignalControllers.put(testSubscriptions[i], mobileSignalController);
// Generate a list of subscriptions we will tell the NetworkController to use.
SubscriptionInfo mockSubInfo = Mockito.mock(SubscriptionInfo.class);
Mockito.when(mockSubInfo.getSubscriptionId()).thenReturn(testSubscriptions[i]);
subscriptions.add(mockSubInfo);
}
assertTrue(mNetworkController.hasCorrectMobileControllers(subscriptions));
// Add a subscription that the NetworkController doesn't know about.
SubscriptionInfo mockSubInfo = Mockito.mock(SubscriptionInfo.class);
Mockito.when(mockSubInfo.getSubscriptionId()).thenReturn(notTestSubscription);
subscriptions.add(mockSubInfo);
assertFalse(mNetworkController.hasCorrectMobileControllers(subscriptions));
}
use of android.telephony.SubscriptionInfo in project android_frameworks_base by AOSPA.
the class NetworkControllerSignalTest method testSetCurrentSubscriptions.
public void testSetCurrentSubscriptions() {
// We will not add one controller to make sure it gets created.
int indexToSkipController = 0;
// We will not add one subscription to make sure it's controller gets removed.
int indexToSkipSubscription = 1;
int[] testSubscriptions = new int[] { 1, 5, 3 };
MobileSignalController[] mobileSignalControllers = new MobileSignalController[] { Mockito.mock(MobileSignalController.class), Mockito.mock(MobileSignalController.class), Mockito.mock(MobileSignalController.class) };
mNetworkController.mMobileSignalControllers.clear();
List<SubscriptionInfo> subscriptions = new ArrayList<>();
for (int i = 0; i < testSubscriptions.length; i++) {
if (i != indexToSkipController) {
// Force the test controllers into NetworkController.
mNetworkController.mMobileSignalControllers.put(testSubscriptions[i], mobileSignalControllers[i]);
}
if (i != indexToSkipSubscription) {
// Generate a list of subscriptions we will tell the NetworkController to use.
SubscriptionInfo mockSubInfo = Mockito.mock(SubscriptionInfo.class);
Mockito.when(mockSubInfo.getSubscriptionId()).thenReturn(testSubscriptions[i]);
Mockito.when(mockSubInfo.getSimSlotIndex()).thenReturn(testSubscriptions[i]);
subscriptions.add(mockSubInfo);
}
}
// We can only test whether unregister gets called if it thinks its in a listening
// state.
mNetworkController.mListening = true;
mNetworkController.setCurrentSubscriptions(subscriptions);
for (int i = 0; i < testSubscriptions.length; i++) {
if (i == indexToSkipController) {
// Make sure a controller was created despite us not adding one.
assertTrue(mNetworkController.mMobileSignalControllers.containsKey(testSubscriptions[i]));
} else if (i == indexToSkipSubscription) {
// Make sure the controller that did exist was removed
assertFalse(mNetworkController.mMobileSignalControllers.containsKey(testSubscriptions[i]));
} else {
// If a MobileSignalController is around it needs to not be unregistered.
Mockito.verify(mobileSignalControllers[i], Mockito.never()).unregisterListener();
}
}
}
Aggregations