Created
September 20, 2016 12:55
-
-
Save luk1337/5b16d367efe870b0f64f4eb7ed3b0968 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 015bb53b5b6c8eab7578db027ddb56e467dbf099 Mon Sep 17 00:00:00 2001 | |
From: Ethan Chen <intervigil@gmail.com> | |
Date: Mon, 23 Nov 2015 17:12:47 -0800 | |
Subject: [PATCH 01/12] Set default subscriptions when single SIM is available | |
* Subscriptions are not updated when SIM cards are swapped. If there is | |
ever a SIM count of 1, direct all defaults to point at that | |
subscription, since there is no other option. | |
Change-Id: Idb84140b65f3355e29cbdebcaff804318d826fe7 | |
--- | |
.../internal/telephony/SubscriptionInfoUpdater.java | 14 +++++++++++--- | |
1 file changed, 11 insertions(+), 3 deletions(-) | |
diff --git a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
index a89f19c..bcaff1d 100644 | |
--- a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
+++ b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
@@ -664,9 +664,17 @@ public class SubscriptionInfoUpdater extends Handler { | |
} | |
} | |
- // Ensure the modems are mapped correctly | |
- mSubscriptionManager.setDefaultDataSubId( | |
- mSubscriptionManager.getDefaultDataSubscriptionId()); | |
+ if (insertedSimCount == 1) { | |
+ SubscriptionInfo sir = subInfos.get(0); | |
+ int subId = sir.getSubscriptionId(); | |
+ mSubscriptionManager.setDefaultDataSubId(subId); | |
+ mSubscriptionManager.setDefaultVoiceSubId(subId); | |
+ mSubscriptionManager.setDefaultSmsSubId(subId); | |
+ } else { | |
+ // Ensure the modems are mapped correctly | |
+ mSubscriptionManager.setDefaultDataSubId( | |
+ mSubscriptionManager.getDefaultDataSubscriptionId()); | |
+ } | |
SubscriptionController.getInstance().notifySubscriptionInfoChanged(); | |
logd("updateSubscriptionInfoByIccId:- SsubscriptionInfo update complete"); | |
-- | |
2.7.4 | |
From cf57913698380e3d52be880145c9999f3a89bc95 Mon Sep 17 00:00:00 2001 | |
From: Christian Morlok <ChristianMorlok@gmail.com> | |
Date: Wed, 20 Jan 2016 08:31:10 +0100 | |
Subject: [PATCH 02/12] telephony: Do not set default subscriptions on shutdown | |
On some devices the SIM slots are not deactivated at the same time | |
when the phone is shut down or rebooted. This means that at some point | |
only one SIM is activated, and all default subscriptions are set to | |
this SIM (a feature introduced in http://review.cyanogenmod.org/#/c/121239/). | |
Change-Id: Ief36004619b75530a21b23efc767e1beb1fb0750 | |
--- | |
.../android/internal/telephony/SubscriptionInfoUpdater.java | 10 +++++++++- | |
1 file changed, 9 insertions(+), 1 deletion(-) | |
diff --git a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
index bcaff1d..80fda48 100644 | |
--- a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
+++ b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
@@ -114,6 +114,7 @@ public class SubscriptionInfoUpdater extends Handler { | |
// The current foreground user ID. | |
private int mCurrentlyActiveUserId; | |
private CarrierServiceBindHelper mCarrierServiceBindHelper; | |
+ private boolean mIsShutdown; | |
public SubscriptionInfoUpdater(Context context, Phone[] phone, CommandsInterface[] ci) { | |
logd("Constructor invoked"); | |
@@ -123,10 +124,12 @@ public class SubscriptionInfoUpdater extends Handler { | |
mSubscriptionManager = SubscriptionManager.from(mContext); | |
mPackageManager = IPackageManager.Stub.asInterface(ServiceManager.getService("package")); | |
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); | |
+ mIsShutdown = false; | |
IntentFilter intentFilter = new IntentFilter(TelephonyIntents.ACTION_SIM_STATE_CHANGED); | |
intentFilter.addAction(IccCardProxy.ACTION_INTERNAL_SIM_STATE_CHANGED); | |
intentFilter.addAction(Intent.ACTION_USER_UNLOCKED); | |
+ intentFilter.addAction(Intent.ACTION_SHUTDOWN); | |
mContext.registerReceiver(sReceiver, intentFilter); | |
mCarrierServiceBindHelper = new CarrierServiceBindHelper(mContext); | |
@@ -199,6 +202,11 @@ public class SubscriptionInfoUpdater extends Handler { | |
return; | |
} | |
+ if (action.equals(Intent.ACTION_SHUTDOWN)) { | |
+ mIsShutdown = true; | |
+ return; | |
+ } | |
+ | |
if (!action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED) && | |
!action.equals(IccCardProxy.ACTION_INTERNAL_SIM_STATE_CHANGED)) { | |
return; | |
@@ -664,7 +672,7 @@ public class SubscriptionInfoUpdater extends Handler { | |
} | |
} | |
- if (insertedSimCount == 1) { | |
+ if (!mIsShutdown && insertedSimCount == 1) { | |
SubscriptionInfo sir = subInfos.get(0); | |
int subId = sir.getSubscriptionId(); | |
mSubscriptionManager.setDefaultDataSubId(subId); | |
-- | |
2.7.4 | |
From 391ed202096950bf5f574aaf437d8895b94f6112 Mon Sep 17 00:00:00 2001 | |
From: LuK1337 <priv.luk@gmail.com> | |
Date: Sun, 4 Sep 2016 00:30:57 +0200 | |
Subject: [PATCH 03/12] Readd setSMSPromptEnabled() | |
Change-Id: I100a73af1c4caf68ea2c7a6a75e1f3b081947316 | |
--- | |
src/java/com/android/internal/telephony/PhoneFactory.java | 8 ++++++++ | |
1 file changed, 8 insertions(+) | |
diff --git a/src/java/com/android/internal/telephony/PhoneFactory.java b/src/java/com/android/internal/telephony/PhoneFactory.java | |
index a7fc025..e9ac447 100644 | |
--- a/src/java/com/android/internal/telephony/PhoneFactory.java | |
+++ b/src/java/com/android/internal/telephony/PhoneFactory.java | |
@@ -366,6 +366,14 @@ public class PhoneFactory { | |
return prompt; | |
} | |
+ /* Sets User SMS Prompt property, enable or not */ | |
+ public static void setSMSPromptEnabled(boolean enabled) { | |
+ int value = (enabled == false) ? 0 : 1; | |
+ Settings.Global.putInt(sContext.getContentResolver(), | |
+ Settings.Global.MULTI_SIM_SMS_PROMPT, value); | |
+ Rlog.d(LOG_TAG, "setSMSPromptOption to " + enabled); | |
+ } | |
+ | |
/** | |
* Makes a {@link ImsPhone} object. | |
* @return the {@code ImsPhone} object or null if the exception occured | |
-- | |
2.7.4 | |
From 1edc907af939c9adb521e4cfeb4dd6916b627cf9 Mon Sep 17 00:00:00 2001 | |
From: Adnan Begovic <adnan@cyngn.com> | |
Date: Wed, 30 Mar 2016 15:16:12 -0700 | |
Subject: [PATCH 04/12] telephony: Workaround default sms sub id not being set. | |
In the scenario where default sms sub id isn't set externally | |
the user can be stuck in an endless loop of prompts if they | |
select "Always Ask". This is bandaid to fix bad UX.. | |
TICKET: CYNGNOS-2185 | |
Change-Id: I70ef343eccc289d0ca58c59646f88b292ca03ca9 | |
--- | |
.../android/internal/telephony/SubscriptionController.java | 13 +++++++++++++ | |
1 file changed, 13 insertions(+) | |
diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java | |
index e9caf94..c5ae0c8 100644 | |
--- a/src/java/com/android/internal/telephony/SubscriptionController.java | |
+++ b/src/java/com/android/internal/telephony/SubscriptionController.java | |
@@ -779,6 +779,19 @@ public class SubscriptionController extends ISub.Stub { | |
setDefaultSmsSubId(subId); | |
setDefaultVoiceSubId(subId); | |
} | |
+ | |
+ // FIXME: Workaround the scenario where default sms subid is not | |
+ // being set externally | |
+ // CYNGNOS-2185 | |
+ int phoneId = SubscriptionController.getInstance().getPhoneId( | |
+ getDefaultSmsSubId()); | |
+ if (phoneId < 0 || phoneId >= TelephonyManager.getDefault() | |
+ .getPhoneCount()) { | |
+ Rlog.i(LOG_TAG, "Subscription is invalid. Set default to " + subId); | |
+ setDefaultSmsSubId(subId); | |
+ PhoneFactory.setSMSPromptEnabled(true); | |
+ } | |
+ | |
} else { | |
if (DBG) { | |
logdl("[addSubInfoRecord] currentSubId != null" | |
-- | |
2.7.4 | |
From c92300ffda552bee937e27fc7d35fc0091bbf243 Mon Sep 17 00:00:00 2001 | |
From: Adnan Begovic <adnan@cyngn.com> | |
Date: Tue, 5 Apr 2016 08:14:29 -0700 | |
Subject: [PATCH 05/12] telephony: Only set prompt enabled if available | |
subscriptions > 1. | |
TICKET: CRACKLING-1026 | |
Change-Id: I8a7555a41a52476af5236c03b4d410dd155db390 | |
--- | |
src/java/com/android/internal/telephony/SubscriptionController.java | 6 +++++- | |
1 file changed, 5 insertions(+), 1 deletion(-) | |
diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java | |
index c5ae0c8..b86a4b5 100644 | |
--- a/src/java/com/android/internal/telephony/SubscriptionController.java | |
+++ b/src/java/com/android/internal/telephony/SubscriptionController.java | |
@@ -789,7 +789,7 @@ public class SubscriptionController extends ISub.Stub { | |
.getPhoneCount()) { | |
Rlog.i(LOG_TAG, "Subscription is invalid. Set default to " + subId); | |
setDefaultSmsSubId(subId); | |
- PhoneFactory.setSMSPromptEnabled(true); | |
+ PhoneFactory.setSMSPromptEnabled(subIdCountMax > 1); | |
} | |
} else { | |
@@ -840,6 +840,10 @@ public class SubscriptionController extends ISub.Stub { | |
if (DBG) logdl("[addSubInfoRecord]- info size=" + sSlotIdxToSubId.size()); | |
+ if (sSlotIdxToSubId.size() <= 1) { | |
+ PhoneFactory.setSMSPromptEnabled(false); | |
+ } | |
+ | |
} finally { | |
Binder.restoreCallingIdentity(identity); | |
} | |
-- | |
2.7.4 | |
From c28a08a6ed2a8c0f85950c7953addc10232b7534 Mon Sep 17 00:00:00 2001 | |
From: Chaitanya Saggurthi <csaggurt@codeaurora.org> | |
Date: Thu, 5 Feb 2015 18:37:59 +0530 | |
Subject: [PATCH 06/12] Add dummy SUB record in CDMA NV mode | |
Add dummy SUB info record when NV is ready in CDMA NV mode. | |
CRs-Fixed: 789989 | |
Change-Id: Ie658087efaa9f93a329773d2d8f0601d083f3701 | |
--- | |
src/java/com/android/internal/telephony/PhoneFactory.java | 4 ++++ | |
1 file changed, 4 insertions(+) | |
diff --git a/src/java/com/android/internal/telephony/PhoneFactory.java b/src/java/com/android/internal/telephony/PhoneFactory.java | |
index e9ac447..5c89d78 100644 | |
--- a/src/java/com/android/internal/telephony/PhoneFactory.java | |
+++ b/src/java/com/android/internal/telephony/PhoneFactory.java | |
@@ -513,4 +513,8 @@ public class PhoneFactory { | |
} | |
pw.decreaseIndent(); | |
} | |
+ | |
+ public static SubscriptionInfoUpdater getSubscriptionInfoUpdater() { | |
+ return sSubInfoRecordUpdater; | |
+ } | |
} | |
-- | |
2.7.4 | |
From 8aacf83ab7f64f0864e24580350e0b3cba5c1487 Mon Sep 17 00:00:00 2001 | |
From: Roman Birg <roman@cyngn.com> | |
Date: Thu, 5 May 2016 16:21:11 -0700 | |
Subject: [PATCH 07/12] SubscriptionController: properly detect when MSIM has 1 | |
SIM | |
We cannot use sSlotIdxToSubId to determine when to turn the SIM dialog | |
off, because when subscription information gets reloaded (on data change | |
for instance), we may add one, then disable SMS prompt, then add the | |
other, which is incorrect. Query the total number of SIMs from the info | |
updater. | |
Ticket: CYNGNOS-2185, CYNGNOS-2570 | |
Change-Id: Iab1225c83b508e055d8a8de55c1e21e2aa153ca5 | |
Signed-off-by: Roman Birg <roman@cyngn.com> | |
--- | |
.../com/android/internal/telephony/SubscriptionController.java | 2 +- | |
.../com/android/internal/telephony/SubscriptionInfoUpdater.java | 7 +++++++ | |
2 files changed, 8 insertions(+), 1 deletion(-) | |
diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java | |
index b86a4b5..8c9c189 100644 | |
--- a/src/java/com/android/internal/telephony/SubscriptionController.java | |
+++ b/src/java/com/android/internal/telephony/SubscriptionController.java | |
@@ -840,7 +840,7 @@ public class SubscriptionController extends ISub.Stub { | |
if (DBG) logdl("[addSubInfoRecord]- info size=" + sSlotIdxToSubId.size()); | |
- if (sSlotIdxToSubId.size() <= 1) { | |
+ if (PhoneFactory.getSubscriptionInfoUpdater().getInsertedSimCount() <= 1) { | |
PhoneFactory.setSMSPromptEnabled(false); | |
} | |
diff --git a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
index 80fda48..7ca8359 100644 | |
--- a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
+++ b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
@@ -115,6 +115,7 @@ public class SubscriptionInfoUpdater extends Handler { | |
private int mCurrentlyActiveUserId; | |
private CarrierServiceBindHelper mCarrierServiceBindHelper; | |
private boolean mIsShutdown; | |
+ private int mCurrentSimCount; | |
public SubscriptionInfoUpdater(Context context, Phone[] phone, CommandsInterface[] ci) { | |
logd("Constructor invoked"); | |
@@ -672,6 +673,8 @@ public class SubscriptionInfoUpdater extends Handler { | |
} | |
} | |
+ mCurrentSimCount = insertedSimCount; | |
+ | |
if (!mIsShutdown && insertedSimCount == 1) { | |
SubscriptionInfo sir = subInfos.get(0); | |
int subId = sir.getSubscriptionId(); | |
@@ -688,6 +691,10 @@ public class SubscriptionInfoUpdater extends Handler { | |
logd("updateSubscriptionInfoByIccId:- SsubscriptionInfo update complete"); | |
} | |
+ protected int getInsertedSimCount() { | |
+ return mCurrentSimCount; | |
+ } | |
+ | |
private boolean isNewSim(String iccId, String[] oldIccId) { | |
boolean newSim = true; | |
for(int i = 0; i < PROJECT_SIM_NUM; i++) { | |
-- | |
2.7.4 | |
From 559006609111d935fa9eaed7bb8a1c31e7399d1f Mon Sep 17 00:00:00 2001 | |
From: Roman Birg <roman@cyngn.com> | |
Date: Mon, 9 May 2016 08:52:42 -0700 | |
Subject: [PATCH 08/12] SubscriptionController: load all subs before setting | |
defaults | |
Switch the whole class to use the new inserted SIM logic added in | |
change id Iab1225c83b508e055d8a8de55c1e21e2aa153ca5. The previous patch | |
fixed scenarios going from two sims to one, but going from one to two | |
(or switching between two sims) is still not working right as the | |
addSubInfoRecord() still used getActiveSubInfoCountMax() to determine | |
the number of SIMS. | |
- Update getActiveSubInfoCountMax() to return the correct number of SIMs. | |
- Furthermore, we need to _only_ update our subscription defaults if we | |
are sure we are not in the middle of an update. | |
- Let the subscription controller set defaults for 1 SIM device after | |
we're done loading | |
Change-Id: I28eefaff61ae7c75732641465ca59eb67cf3e198 | |
Ticket: CYNGNOS-2185, CYNGNOS-2570 | |
--- | |
.../internal/telephony/SubscriptionController.java | 32 +++++++---------- | |
.../telephony/SubscriptionInfoUpdater.java | 41 +++++++++++----------- | |
.../internal/telephony/UiccSmsController.java | 5 +++ | |
3 files changed, 37 insertions(+), 41 deletions(-) | |
diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java | |
index 8c9c189..89dceb0 100644 | |
--- a/src/java/com/android/internal/telephony/SubscriptionController.java | |
+++ b/src/java/com/android/internal/telephony/SubscriptionController.java | |
@@ -186,7 +186,7 @@ public class SubscriptionController extends ISub.Stub { | |
} | |
private boolean isSubInfoReady() { | |
- return sSlotIdxToSubId.size() > 0; | |
+ return sSlotIdxToSubId.size() == getActiveSubInfoCountMax(); | |
} | |
private SubscriptionController(Phone phone) { | |
@@ -665,7 +665,11 @@ public class SubscriptionController extends ISub.Stub { | |
@Override | |
public int getActiveSubInfoCountMax() { | |
// FIXME: This valid now but change to use TelephonyDevController in the future | |
- return mTelephonyManager.getSimCount(); | |
+ if (PhoneFactory.getSubscriptionInfoUpdater() != null) { | |
+ return PhoneFactory.getSubscriptionInfoUpdater().getInsertedSimCount(); | |
+ } else { | |
+ return 0; | |
+ } | |
} | |
/** | |
@@ -765,13 +769,18 @@ public class SubscriptionController extends ISub.Stub { | |
+ " defaultSubId=" + defaultSubId + " simCount=" + subIdCountMax); | |
} | |
+ if (!isSubInfoReady()) { | |
+ continue; | |
+ } | |
+ | |
// Set the default sub if not set or if single sim device | |
if (!SubscriptionManager.isValidSubscriptionId(defaultSubId) | |
|| subIdCountMax == 1 || (!isActiveSubId(defaultSubId))) { | |
setDefaultFallbackSubId(subId); | |
} | |
// If single sim device, set this subscription as the default for everything | |
- if (subIdCountMax == 1) { | |
+ if (subIdCountMax == 1 | |
+ && TelephonyManager.getDefault().getSimCount() == 1) { | |
if (DBG) { | |
logdl("[addSubInfoRecord] one sim set defaults to subId=" + subId); | |
} | |
@@ -779,19 +788,6 @@ public class SubscriptionController extends ISub.Stub { | |
setDefaultSmsSubId(subId); | |
setDefaultVoiceSubId(subId); | |
} | |
- | |
- // FIXME: Workaround the scenario where default sms subid is not | |
- // being set externally | |
- // CYNGNOS-2185 | |
- int phoneId = SubscriptionController.getInstance().getPhoneId( | |
- getDefaultSmsSubId()); | |
- if (phoneId < 0 || phoneId >= TelephonyManager.getDefault() | |
- .getPhoneCount()) { | |
- Rlog.i(LOG_TAG, "Subscription is invalid. Set default to " + subId); | |
- setDefaultSmsSubId(subId); | |
- PhoneFactory.setSMSPromptEnabled(subIdCountMax > 1); | |
- } | |
- | |
} else { | |
if (DBG) { | |
logdl("[addSubInfoRecord] currentSubId != null" | |
@@ -840,10 +836,6 @@ public class SubscriptionController extends ISub.Stub { | |
if (DBG) logdl("[addSubInfoRecord]- info size=" + sSlotIdxToSubId.size()); | |
- if (PhoneFactory.getSubscriptionInfoUpdater().getInsertedSimCount() <= 1) { | |
- PhoneFactory.setSMSPromptEnabled(false); | |
- } | |
- | |
} finally { | |
Binder.restoreCallingIdentity(identity); | |
} | |
diff --git a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
index 7ca8359..f1d95e3 100644 | |
--- a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
+++ b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
@@ -74,6 +74,9 @@ public class SubscriptionInfoUpdater extends Handler { | |
private static final int EVENT_SIM_LOCKED = 5; | |
private static final int EVENT_SIM_IO_ERROR = 6; | |
private static final int EVENT_SIM_UNKNOWN = 7; | |
+ private static final int EVENT_UPDATE_INSERTED_SIM_COUNT = 8; | |
+ | |
+ private static final int DELAY_MILLIS = 500; | |
private static final String ICCID_STRING_FOR_NO_SIM = ""; | |
/** | |
@@ -115,7 +118,7 @@ public class SubscriptionInfoUpdater extends Handler { | |
private int mCurrentlyActiveUserId; | |
private CarrierServiceBindHelper mCarrierServiceBindHelper; | |
private boolean mIsShutdown; | |
- private int mCurrentSimCount; | |
+ private int mCurrentSimCount = 0; | |
public SubscriptionInfoUpdater(Context context, Phone[] phone, CommandsInterface[] ci) { | |
logd("Constructor invoked"); | |
@@ -223,6 +226,9 @@ public class SubscriptionInfoUpdater extends Handler { | |
String simStatus = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE); | |
logd("simStatus: " + simStatus); | |
+ removeMessages(EVENT_UPDATE_INSERTED_SIM_COUNT, slotId); | |
+ sendMessageDelayed(obtainMessage(EVENT_UPDATE_INSERTED_SIM_COUNT, slotId), DELAY_MILLIS); | |
+ | |
if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) { | |
if (IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(simStatus)) { | |
sendMessage(obtainMessage(EVENT_SIM_ABSENT, slotId, -1)); | |
@@ -303,9 +309,6 @@ public class SubscriptionInfoUpdater extends Handler { | |
logd("Query IccId fail: " + ar.exception); | |
} | |
logd("sIccId[" + slotId + "] = " + mIccId[slotId]); | |
- if (isAllIccIdQueryDone()) { | |
- updateSubscriptionInfoByIccId(); | |
- } | |
broadcastSimStateChanged(slotId, IccCardConstants.INTENT_VALUE_ICC_LOCKED, | |
uObj.reason); | |
if (!ICCID_STRING_FOR_NO_SIM.equals(mIccId[slotId])) { | |
@@ -348,6 +351,13 @@ public class SubscriptionInfoUpdater extends Handler { | |
handleSimAbsentOrError(msg.arg1, IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR); | |
break; | |
+ case EVENT_UPDATE_INSERTED_SIM_COUNT: | |
+ if (isAllIccIdQueryDone() && !hasMessages(EVENT_UPDATE_INSERTED_SIM_COUNT)) { | |
+ updateSubscriptionInfoByIccId(); | |
+ logd("update inserted sim count, current sim count: " + mCurrentSimCount); | |
+ } | |
+ break; | |
+ | |
default: | |
logd("Unknown msg:" + msg.what); | |
} | |
@@ -407,10 +417,6 @@ public class SubscriptionInfoUpdater extends Handler { | |
} | |
mIccId[slotId] = records.getIccId(); | |
- if (isAllIccIdQueryDone()) { | |
- updateSubscriptionInfoByIccId(); | |
- } | |
- | |
int subId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID; | |
int[] subIds = SubscriptionController.getInstance().getSubId(slotId); | |
if (subIds != null) { // Why an array? | |
@@ -466,7 +472,7 @@ public class SubscriptionInfoUpdater extends Handler { | |
PreferenceManager.getDefaultSharedPreferences(mContext); | |
int storedSubId = sp.getInt(CURR_SUBID + slotId, -1); | |
- if (storedSubId != subId) { | |
+ if (storedSubId != subId && storedSubId != -1) { | |
int networkType = RILConstants.PREFERRED_NETWORK_MODE; | |
// when known SIM inserted in another slot for which subId already | |
@@ -529,9 +535,6 @@ public class SubscriptionInfoUpdater extends Handler { | |
logd("SIM" + (slotId + 1) + " hot plug out or error"); | |
} | |
mIccId[slotId] = ICCID_STRING_FOR_NO_SIM; | |
- if (isAllIccIdQueryDone()) { | |
- updateSubscriptionInfoByIccId(); | |
- } | |
updateCarrierServices(slotId, simState); | |
} | |
@@ -556,6 +559,7 @@ public class SubscriptionInfoUpdater extends Handler { | |
} | |
} | |
logd("insertedSimCount = " + insertedSimCount); | |
+ mCurrentSimCount = insertedSimCount; | |
int index = 0; | |
for (int i = 0; i < PROJECT_SIM_NUM; i++) { | |
@@ -673,15 +677,7 @@ public class SubscriptionInfoUpdater extends Handler { | |
} | |
} | |
- mCurrentSimCount = insertedSimCount; | |
- | |
- if (!mIsShutdown && insertedSimCount == 1) { | |
- SubscriptionInfo sir = subInfos.get(0); | |
- int subId = sir.getSubscriptionId(); | |
- mSubscriptionManager.setDefaultDataSubId(subId); | |
- mSubscriptionManager.setDefaultVoiceSubId(subId); | |
- mSubscriptionManager.setDefaultSmsSubId(subId); | |
- } else { | |
+ if (!mIsShutdown && insertedSimCount > 1) { | |
// Ensure the modems are mapped correctly | |
mSubscriptionManager.setDefaultDataSubId( | |
mSubscriptionManager.getDefaultDataSubscriptionId()); | |
@@ -692,6 +688,9 @@ public class SubscriptionInfoUpdater extends Handler { | |
} | |
protected int getInsertedSimCount() { | |
+ if (!isAllIccIdQueryDone()) { | |
+ return 0; | |
+ } | |
return mCurrentSimCount; | |
} | |
diff --git a/src/java/com/android/internal/telephony/UiccSmsController.java b/src/java/com/android/internal/telephony/UiccSmsController.java | |
index 1c563eb..08ff4b3 100755 | |
--- a/src/java/com/android/internal/telephony/UiccSmsController.java | |
+++ b/src/java/com/android/internal/telephony/UiccSmsController.java | |
@@ -302,6 +302,11 @@ public class UiccSmsController extends ISms.Stub { | |
Binder.restoreCallingIdentity(identity); | |
} | |
+ if (isSMSPromptEnabled()) { | |
+ // we will make the user pick | |
+ return false; | |
+ } | |
+ | |
if (subInfoList != null) { | |
final int subInfoLength = subInfoList.size(); | |
-- | |
2.7.4 | |
From c072e8681ffb823013e0d2c8f2a6c03d146ece2f Mon Sep 17 00:00:00 2001 | |
From: Roman Birg <roman@cyngn.com> | |
Date: Mon, 16 May 2016 11:15:26 -0700 | |
Subject: [PATCH 09/12] SubscriptionController: fix subscription updating | |
We need to only repost messages on events we have handled, not | |
prematurely posting them for every single eveng incoming. | |
Furthermore, getMaxActive should return the MAX, not the current max. | |
The previous fixed dual sim insertion and removal ONLY if there were two | |
sims, but switching from two to one would break. | |
Ticket: CYNGNOS-2185, CYNGNOS-2570 | |
Change-Id: I5b829662b466f609cd22adfa7d3b754757258463 | |
Signed-off-by: Roman Birg <roman@cyngn.com> | |
--- | |
.../internal/telephony/SubscriptionController.java | 18 ++++++------- | |
.../telephony/SubscriptionInfoUpdater.java | 31 +++++++++++++++------- | |
2 files changed, 30 insertions(+), 19 deletions(-) | |
diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java | |
index 89dceb0..c7c3f80 100644 | |
--- a/src/java/com/android/internal/telephony/SubscriptionController.java | |
+++ b/src/java/com/android/internal/telephony/SubscriptionController.java | |
@@ -186,7 +186,8 @@ public class SubscriptionController extends ISub.Stub { | |
} | |
private boolean isSubInfoReady() { | |
- return sSlotIdxToSubId.size() == getActiveSubInfoCountMax(); | |
+ final SubscriptionInfoUpdater subUpdater = PhoneFactory.getSubscriptionInfoUpdater(); | |
+ return subUpdater != null && sSlotIdxToSubId.size() == subUpdater.getInsertedSimCount(); | |
} | |
private SubscriptionController(Phone phone) { | |
@@ -665,11 +666,7 @@ public class SubscriptionController extends ISub.Stub { | |
@Override | |
public int getActiveSubInfoCountMax() { | |
// FIXME: This valid now but change to use TelephonyDevController in the future | |
- if (PhoneFactory.getSubscriptionInfoUpdater() != null) { | |
- return PhoneFactory.getSubscriptionInfoUpdater().getInsertedSimCount(); | |
- } else { | |
- return 0; | |
- } | |
+ return TelephonyManager.getDefault().getSimCount(); | |
} | |
/** | |
@@ -760,13 +757,14 @@ public class SubscriptionController extends ISub.Stub { | |
// may not be true, for instance with multiple subs per slot. | |
// But is true at the moment. | |
sSlotIdxToSubId.put(slotId, subId); | |
- int subIdCountMax = getActiveSubInfoCountMax(); | |
+ int simCount = PhoneFactory.getSubscriptionInfoUpdater() | |
+ .getInsertedSimCount(); | |
int defaultSubId = getDefaultSubId(); | |
if (DBG) { | |
logdl("[addSubInfoRecord]" | |
+ " sSlotIdxToSubId.size=" + sSlotIdxToSubId.size() | |
+ " slotId=" + slotId + " subId=" + subId | |
- + " defaultSubId=" + defaultSubId + " simCount=" + subIdCountMax); | |
+ + " defaultSubId=" + defaultSubId + " simCount=" + simCount); | |
} | |
if (!isSubInfoReady()) { | |
@@ -775,11 +773,11 @@ public class SubscriptionController extends ISub.Stub { | |
// Set the default sub if not set or if single sim device | |
if (!SubscriptionManager.isValidSubscriptionId(defaultSubId) | |
- || subIdCountMax == 1 || (!isActiveSubId(defaultSubId))) { | |
+ || simCount == 1 || (!isActiveSubId(defaultSubId))) { | |
setDefaultFallbackSubId(subId); | |
} | |
// If single sim device, set this subscription as the default for everything | |
- if (subIdCountMax == 1 | |
+ if (simCount == 1 | |
&& TelephonyManager.getDefault().getSimCount() == 1) { | |
if (DBG) { | |
logdl("[addSubInfoRecord] one sim set defaults to subId=" + subId); | |
diff --git a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
index f1d95e3..ff7975b 100644 | |
--- a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
+++ b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
@@ -226,9 +226,6 @@ public class SubscriptionInfoUpdater extends Handler { | |
String simStatus = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE); | |
logd("simStatus: " + simStatus); | |
- removeMessages(EVENT_UPDATE_INSERTED_SIM_COUNT, slotId); | |
- sendMessageDelayed(obtainMessage(EVENT_UPDATE_INSERTED_SIM_COUNT, slotId), DELAY_MILLIS); | |
- | |
if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) { | |
if (IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(simStatus)) { | |
sendMessage(obtainMessage(EVENT_SIM_ABSENT, slotId, -1)); | |
@@ -309,6 +306,7 @@ public class SubscriptionInfoUpdater extends Handler { | |
logd("Query IccId fail: " + ar.exception); | |
} | |
logd("sIccId[" + slotId + "] = " + mIccId[slotId]); | |
+ update(slotId); | |
broadcastSimStateChanged(slotId, IccCardConstants.INTENT_VALUE_ICC_LOCKED, | |
uObj.reason); | |
if (!ICCID_STRING_FOR_NO_SIM.equals(mIccId[slotId])) { | |
@@ -379,7 +377,6 @@ public class SubscriptionInfoUpdater extends Handler { | |
mIccId[slotId] = null; | |
} | |
- | |
IccFileHandler fileHandler = mPhone[slotId].getIccCard() == null ? null : | |
mPhone[slotId].getIccCard().getIccFileHandler(); | |
@@ -398,6 +395,14 @@ public class SubscriptionInfoUpdater extends Handler { | |
} else { | |
logd("sFh[" + slotId + "] is null, ignore"); | |
} | |
+ update(slotId); | |
+ } | |
+ | |
+ private void update(int slotId) { | |
+ sendMessageDelayed(obtainMessage(EVENT_UPDATE_INSERTED_SIM_COUNT, slotId), DELAY_MILLIS); | |
+ if (isAllIccIdQueryDone()) { | |
+ updateSubscriptionInfoByIccId(); | |
+ } | |
} | |
protected void handleSimLoaded(int slotId) { | |
@@ -416,6 +421,7 @@ public class SubscriptionInfoUpdater extends Handler { | |
return; | |
} | |
mIccId[slotId] = records.getIccId(); | |
+ update(slotId); | |
int subId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID; | |
int[] subIds = SubscriptionController.getInstance().getSubId(slotId); | |
@@ -535,6 +541,7 @@ public class SubscriptionInfoUpdater extends Handler { | |
logd("SIM" + (slotId + 1) + " hot plug out or error"); | |
} | |
mIccId[slotId] = ICCID_STRING_FOR_NO_SIM; | |
+ update(slotId); | |
updateCarrierServices(slotId, simState); | |
} | |
@@ -545,7 +552,11 @@ public class SubscriptionInfoUpdater extends Handler { | |
synchronized protected void updateSubscriptionInfoByIccId() { | |
logd("updateSubscriptionInfoByIccId:+ Start"); | |
- mSubscriptionManager.clearSubscriptionInfo(); | |
+ // only update external state if we have no pending updates pending | |
+ boolean update = !hasMessages(EVENT_UPDATE_INSERTED_SIM_COUNT); | |
+ if (update) { | |
+ mSubscriptionManager.clearSubscriptionInfo(); | |
+ } | |
for (int i = 0; i < PROJECT_SIM_NUM; i++) { | |
mInsertSimState[i] = SIM_NOT_CHANGE; | |
@@ -620,13 +631,13 @@ public class SubscriptionInfoUpdater extends Handler { | |
if (mInsertSimState[i] == SIM_NOT_INSERT) { | |
logd("updateSubscriptionInfoByIccId: No SIM inserted in slot " + i + " this time"); | |
} else { | |
- if (mInsertSimState[i] > 0) { | |
+ if (mInsertSimState[i] > 0 && update) { | |
//some special SIMs may have the same IccIds, add suffix to distinguish them | |
//FIXME: addSubInfoRecord can return an error. | |
mSubscriptionManager.addSubscriptionInfoRecord(mIccId[i] | |
+ Integer.toString(mInsertSimState[i]), i); | |
logd("SUB" + (i + 1) + " has invalid IccId"); | |
- } else /*if (sInsertSimState[i] != SIM_NOT_INSERT)*/ { | |
+ } else if (update)/*if (sInsertSimState[i] != SIM_NOT_INSERT)*/ { | |
mSubscriptionManager.addSubscriptionInfoRecord(mIccId[i], i); | |
} | |
if (isNewSim(mIccId[i], oldIccId)) { | |
@@ -677,13 +688,15 @@ public class SubscriptionInfoUpdater extends Handler { | |
} | |
} | |
- if (!mIsShutdown && insertedSimCount > 1) { | |
+ if (!mIsShutdown && insertedSimCount > 1 && update) { | |
// Ensure the modems are mapped correctly | |
mSubscriptionManager.setDefaultDataSubId( | |
mSubscriptionManager.getDefaultDataSubscriptionId()); | |
} | |
- SubscriptionController.getInstance().notifySubscriptionInfoChanged(); | |
+ if (update) { | |
+ SubscriptionController.getInstance().notifySubscriptionInfoChanged(); | |
+ } | |
logd("updateSubscriptionInfoByIccId:- SsubscriptionInfo update complete"); | |
} | |
-- | |
2.7.4 | |
From b57ae0598446d893a96f5d2e248ad86fb3bcbfff Mon Sep 17 00:00:00 2001 | |
From: Roman Birg <roman@cyngn.com> | |
Date: Tue, 17 May 2016 17:14:44 -0700 | |
Subject: [PATCH 10/12] SubscriptionInfoUpdater: improved sim swap | |
We now keep track of the last number of inserted SIMs updated for. So | |
when the number of SIMs has changed we do the following: | |
1 sim: Clear stale defaults | |
Disable SMS prompt, SMS app will default to current sim | |
Disable data if the SIM left in the tray is not the one chosen | |
m sim: Enable SMS prompt if we don't have a valid default (aka always | |
ask) | |
Furthermore, when we detect the device is an MSIM device and there is | |
only one active sub, return the active sub to the UI layers (so SIM | |
selection screen displays proper, grayed out, current settings). | |
Ticket: CYNGNOS-2185, CYNGNOS-2570 | |
Change-Id: Ib1b4f4d87640e4b20722295304c58dff7dbeecbb | |
Signed-off-by: Roman Birg <roman@cyngn.com> | |
--- | |
.../internal/telephony/SubscriptionController.java | 26 ++++++++- | |
.../telephony/SubscriptionInfoUpdater.java | 68 +++++++++++++++++++--- | |
.../internal/telephony/UiccSmsController.java | 17 ++++-- | |
3 files changed, 96 insertions(+), 15 deletions(-) | |
diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java | |
index c7c3f80..dc66485 100644 | |
--- a/src/java/com/android/internal/telephony/SubscriptionController.java | |
+++ b/src/java/com/android/internal/telephony/SubscriptionController.java | |
@@ -190,6 +190,12 @@ public class SubscriptionController extends ISub.Stub { | |
return subUpdater != null && sSlotIdxToSubId.size() == subUpdater.getInsertedSimCount(); | |
} | |
+ private boolean isSingleSimActiveOnMSIM() { | |
+ final SubscriptionInfoUpdater subUpdater = PhoneFactory.getSubscriptionInfoUpdater(); | |
+ return subUpdater != null && subUpdater.getInsertedSimCount() == 1 | |
+ && getActiveSubInfoCountMax() > 1; | |
+ } | |
+ | |
private SubscriptionController(Phone phone) { | |
mContext = phone.getContext(); | |
mCM = CallManager.getInstance(); | |
@@ -1408,6 +1414,10 @@ public class SubscriptionController extends ISub.Stub { | |
@Override | |
public int getDefaultSmsSubId() { | |
+ if (isSingleSimActiveOnMSIM()) { | |
+ if (VDBG) logd("[getDefaultSmsSubId] overridden to current single active sim"); | |
+ return mDefaultFallbackSubId; | |
+ } | |
int subId = Settings.Global.getInt(mContext.getContentResolver(), | |
Settings.Global.MULTI_SIM_SMS_SUBSCRIPTION, | |
SubscriptionManager.INVALID_SUBSCRIPTION_ID); | |
@@ -1439,6 +1449,10 @@ public class SubscriptionController extends ISub.Stub { | |
@Override | |
public int getDefaultVoiceSubId() { | |
+ if (isSingleSimActiveOnMSIM()) { | |
+ if (VDBG) logd("[getDefaultVoiceSubId] overridden to current single active sim"); | |
+ return mDefaultFallbackSubId; | |
+ } | |
int subId = Settings.Global.getInt(mContext.getContentResolver(), | |
Settings.Global.MULTI_SIM_VOICE_CALL_SUBSCRIPTION, | |
SubscriptionManager.INVALID_SUBSCRIPTION_ID); | |
@@ -1448,6 +1462,10 @@ public class SubscriptionController extends ISub.Stub { | |
@Override | |
public int getDefaultDataSubId() { | |
+ if (isSingleSimActiveOnMSIM()) { | |
+ if (VDBG) logd("[getDefaultDataSubId] overridden to current single active sim"); | |
+ return mDefaultFallbackSubId; | |
+ } | |
int subId = Settings.Global.getInt(mContext.getContentResolver(), | |
Settings.Global.MULTI_SIM_DATA_CALL_SUBSCRIPTION, | |
SubscriptionManager.INVALID_SUBSCRIPTION_ID); | |
@@ -1500,8 +1518,10 @@ public class SubscriptionController extends ISub.Stub { | |
// FIXME is this still needed? | |
updateAllDataConnectionTrackers(); | |
- Settings.Global.putInt(mContext.getContentResolver(), | |
- Settings.Global.MULTI_SIM_DATA_CALL_SUBSCRIPTION, subId); | |
+ if (!isSingleSimActiveOnMSIM()) { | |
+ Settings.Global.putInt(mContext.getContentResolver(), | |
+ Settings.Global.MULTI_SIM_DATA_CALL_SUBSCRIPTION, subId); | |
+ } | |
broadcastDefaultDataSubIdChanged(subId); | |
} | |
@@ -1536,7 +1556,7 @@ public class SubscriptionController extends ISub.Stub { | |
if (SubscriptionManager.isValidSubscriptionId(subId)) { | |
int phoneId = getPhoneId(subId); | |
if (phoneId >= 0 && (phoneId < mTelephonyManager.getPhoneCount() | |
- || mTelephonyManager.getSimCount() == 1)) { | |
+ || isSingleSimActiveOnMSIM())) { | |
if (DBG) logdl("[setDefaultFallbackSubId] set mDefaultFallbackSubId=" + subId); | |
mDefaultFallbackSubId = subId; | |
// Update MCC MNC device configuration information | |
diff --git a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
index ff7975b..8ee2353 100644 | |
--- a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
+++ b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
@@ -52,6 +52,7 @@ import com.android.internal.telephony.uicc.IccUtils; | |
import java.io.FileDescriptor; | |
import java.io.PrintWriter; | |
+import java.util.BitSet; | |
import java.util.HashMap; | |
import java.util.Iterator; | |
import java.util.List; | |
@@ -104,6 +105,8 @@ public class SubscriptionInfoUpdater extends Handler { | |
// Key used to read/write the current IMSI. Updated on SIM_STATE_CHANGED - LOADED. | |
public static final String CURR_SUBID = "curr_subid"; | |
+ // Key used to determine if the number of sims in the device has changed | |
+ private static final String PREF_LAST_SEEN_SIM_COUNT = "previous_update_sim_count"; | |
private static Phone[] mPhone; | |
private static Context mContext = null; | |
@@ -119,6 +122,7 @@ public class SubscriptionInfoUpdater extends Handler { | |
private CarrierServiceBindHelper mCarrierServiceBindHelper; | |
private boolean mIsShutdown; | |
private int mCurrentSimCount = 0; | |
+ private BitSet mLockedSims = new BitSet(PROJECT_SIM_NUM); | |
public SubscriptionInfoUpdater(Context context, Phone[] phone, CommandsInterface[] ci) { | |
logd("Constructor invoked"); | |
@@ -247,6 +251,16 @@ public class SubscriptionInfoUpdater extends Handler { | |
logd("Ignoring simStatus: " + simStatus); | |
} | |
} | |
+ | |
+ if (IccCardConstants.INTENT_VALUE_ICC_LOCKED.equals(simStatus)) { | |
+ mLockedSims.set(slotId); | |
+ update(slotId); | |
+ } else if (IccCardConstants.INTENT_VALUE_ICC_READY.equals(simStatus) | |
+ || IccCardConstants.INTENT_VALUE_ICC_LOADED.equals(simStatus)) { | |
+ mLockedSims.clear(slotId); | |
+ update(slotId); | |
+ } | |
+ | |
logd("[Receiver]-"); | |
} | |
}; | |
@@ -350,6 +364,7 @@ public class SubscriptionInfoUpdater extends Handler { | |
break; | |
case EVENT_UPDATE_INSERTED_SIM_COUNT: | |
+ logd("EVENT_UPDATE_INSERTED_SIM_COUNT: locked sims: " + mLockedSims.cardinality()); | |
if (isAllIccIdQueryDone() && !hasMessages(EVENT_UPDATE_INSERTED_SIM_COUNT)) { | |
updateSubscriptionInfoByIccId(); | |
logd("update inserted sim count, current sim count: " + mCurrentSimCount); | |
@@ -478,7 +493,7 @@ public class SubscriptionInfoUpdater extends Handler { | |
PreferenceManager.getDefaultSharedPreferences(mContext); | |
int storedSubId = sp.getInt(CURR_SUBID + slotId, -1); | |
- if (storedSubId != subId && storedSubId != -1) { | |
+ if (storedSubId != subId) { | |
int networkType = RILConstants.PREFERRED_NETWORK_MODE; | |
// when known SIM inserted in another slot for which subId already | |
@@ -688,18 +703,57 @@ public class SubscriptionInfoUpdater extends Handler { | |
} | |
} | |
- if (!mIsShutdown && insertedSimCount > 1 && update) { | |
+ if (update && !mIsShutdown && mLockedSims.cardinality() == 0) { | |
+ final int previousUpdateSimCount = previousUpdateSimCount(); | |
+ if (previousUpdateSimCount != insertedSimCount) { | |
+ logd("number of sims changed, resetting sms prompt, old sim count: " | |
+ + previousUpdateSimCount); | |
+ if (insertedSimCount == 1 && PROJECT_SIM_NUM > 1) { | |
+ // 1 sim, msim device: clear stale defaults (doesn't clear inactive subs) | |
+ mSubscriptionManager.clearDefaultsForInactiveSubIds(); | |
+ | |
+ // then disable sms prompt (sms app will default to inserted sim) | |
+ PhoneFactory.setSMSPromptEnabled(false); // can't prompt for 1 sim | |
+ | |
+ // finally, disable data if this single sim isn't our our selected data sim previously | |
+ int realStoredDataSub = Settings.Global.getInt(mContext.getContentResolver(), | |
+ Settings.Global.MULTI_SIM_DATA_CALL_SUBSCRIPTION, | |
+ SubscriptionManager.INVALID_SUBSCRIPTION_ID); | |
+ | |
+ if (realStoredDataSub != SubscriptionManager.getDefaultDataSubscriptionId()) { | |
+ PhoneFactory.getDefaultPhone().setDataEnabled(false); | |
+ } | |
+ } else if (insertedSimCount > 1) { | |
+ // we now have multiple sims, maybe enable the SMS prompt if no valid | |
+ // sub is ready to handle SMS | |
+ PhoneFactory.setSMSPromptEnabled(!SubscriptionManager.isValidSubscriptionId( | |
+ SubscriptionManager.getDefaultSmsSubscriptionId())); | |
+ } | |
+ setPreviousUpdateSimCount(insertedSimCount); | |
+ } | |
// Ensure the modems are mapped correctly | |
- mSubscriptionManager.setDefaultDataSubId( | |
- mSubscriptionManager.getDefaultDataSubscriptionId()); | |
- } | |
- | |
- if (update) { | |
+ // will not override MSIM settings with 1 sim in the device. | |
+ mSubscriptionManager.setDefaultDataSubId(SubscriptionManager.getDefaultDataSubscriptionId()); | |
+ SubscriptionController.getInstance().notifySubscriptionInfoChanged(); | |
+ } else if (update && !mIsShutdown) { | |
+ // we have locked sims, need to update so we can unlock them | |
SubscriptionController.getInstance().notifySubscriptionInfoChanged(); | |
} | |
logd("updateSubscriptionInfoByIccId:- SsubscriptionInfo update complete"); | |
} | |
+ private int previousUpdateSimCount() { | |
+ return PreferenceManager.getDefaultSharedPreferences(mContext) | |
+ .getInt(PREF_LAST_SEEN_SIM_COUNT, 0); | |
+ } | |
+ | |
+ private void setPreviousUpdateSimCount(int simCount) { | |
+ PreferenceManager.getDefaultSharedPreferences(mContext) | |
+ .edit() | |
+ .putInt(PREF_LAST_SEEN_SIM_COUNT, simCount) | |
+ .apply(); | |
+ } | |
+ | |
protected int getInsertedSimCount() { | |
if (!isAllIccIdQueryDone()) { | |
return 0; | |
diff --git a/src/java/com/android/internal/telephony/UiccSmsController.java b/src/java/com/android/internal/telephony/UiccSmsController.java | |
index 08ff4b3..caca2f2 100755 | |
--- a/src/java/com/android/internal/telephony/UiccSmsController.java | |
+++ b/src/java/com/android/internal/telephony/UiccSmsController.java | |
@@ -291,6 +291,12 @@ public class UiccSmsController extends ISms.Stub { | |
@Override | |
public boolean isSmsSimPickActivityNeeded(int subId) { | |
+ if (!isSMSPromptEnabled()) { | |
+ Rlog.d(LOG_TAG, "isSmsSimPickActivityNeeded: false, sms prompt disabled."); | |
+ // user knows best | |
+ return false; | |
+ } | |
+ | |
final Context context = ActivityThread.currentApplication().getApplicationContext(); | |
TelephonyManager telephonyManager = | |
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); | |
@@ -302,11 +308,6 @@ public class UiccSmsController extends ISms.Stub { | |
Binder.restoreCallingIdentity(identity); | |
} | |
- if (isSMSPromptEnabled()) { | |
- // we will make the user pick | |
- return false; | |
- } | |
- | |
if (subInfoList != null) { | |
final int subInfoLength = subInfoList.size(); | |
@@ -320,6 +321,12 @@ public class UiccSmsController extends ISms.Stub { | |
// If reached here and multiple SIMs and subs present, sms sim pick activity is needed | |
if (subInfoLength > 0 && telephonyManager.getSimCount() > 1) { | |
+ final SubscriptionInfoUpdater subscriptionInfoUpdater | |
+ = PhoneFactory.getSubscriptionInfoUpdater(); | |
+ if (subscriptionInfoUpdater != null) { | |
+ // use the *real* inserted sim count if we can | |
+ return subscriptionInfoUpdater.getInsertedSimCount() > 1; | |
+ } | |
return true; | |
} | |
} | |
-- | |
2.7.4 | |
From c1ced01578563da0a1d22e0ed5bedbaaa7c90d9d Mon Sep 17 00:00:00 2001 | |
From: Roman Birg <roman@cyngn.com> | |
Date: Mon, 20 Jun 2016 11:13:54 -0700 | |
Subject: [PATCH 11/12] Telephony: handle 3rd party sms apps + 'always ask' | |
3rd party SMS apps may not be able to handle our always ask behavior, so | |
they may get stuck in a bad state. An example of this is Hangouts, which | |
just ends up never sending messages when always ask is selected. | |
TIcket: CYNGNOS-3068 | |
Change-Id: I8a0f1f6bf7a5010438e40eb0be9aa178d2141f3c | |
Signed-off-by: Roman Birg <roman@cyngn.com> | |
--- | |
src/java/com/android/internal/telephony/SmsApplication.java | 12 ++++++++++++ | |
.../com/android/internal/telephony/UiccSmsController.java | 7 ++++--- | |
2 files changed, 16 insertions(+), 3 deletions(-) | |
diff --git a/src/java/com/android/internal/telephony/SmsApplication.java b/src/java/com/android/internal/telephony/SmsApplication.java | |
index 675d943..1f9765f 100644 | |
--- a/src/java/com/android/internal/telephony/SmsApplication.java | |
+++ b/src/java/com/android/internal/telephony/SmsApplication.java | |
@@ -40,6 +40,7 @@ import android.provider.Telephony.Sms.Intents; | |
import android.telephony.Rlog; | |
import android.telephony.SmsManager; | |
import android.telephony.TelephonyManager; | |
+import android.text.TextUtils; | |
import android.util.Log; | |
import com.android.internal.content.PackageMonitor; | |
@@ -61,6 +62,7 @@ public final class SmsApplication { | |
private static final String BLUETOOTH_PACKAGE_NAME = "com.android.bluetooth"; | |
private static final String MMS_SERVICE_PACKAGE_NAME = "com.android.mms.service"; | |
private static final String TELEPHONY_PROVIDER_PACKAGE_NAME = "com.android.providers.telephony"; | |
+ private static final String DEFAULT_SYSTEM_MMS_PACKAGE_NAME = "com.android.messaging"; | |
private static final String SCHEME_SMS = "sms"; | |
private static final String SCHEME_SMSTO = "smsto"; | |
@@ -898,6 +900,16 @@ public final class SmsApplication { | |
return false; | |
} | |
+ /** | |
+ * @hide | |
+ */ | |
+ public static boolean canSmsAppHandleAlwaysAsk(Context context) { | |
+ final ComponentName defaultMmsApplication = SmsApplication.getDefaultMmsApplication(context, | |
+ false); | |
+ return TextUtils.equals(DEFAULT_SYSTEM_MMS_PACKAGE_NAME, | |
+ defaultMmsApplication.getPackageName()); | |
+ } | |
+ | |
private static String getDefaultSmsApplicationPackageName(Context context) { | |
final ComponentName component = getDefaultSmsApplication(context, false); | |
if (component != null) { | |
diff --git a/src/java/com/android/internal/telephony/UiccSmsController.java b/src/java/com/android/internal/telephony/UiccSmsController.java | |
index caca2f2..258571d 100755 | |
--- a/src/java/com/android/internal/telephony/UiccSmsController.java | |
+++ b/src/java/com/android/internal/telephony/UiccSmsController.java | |
@@ -291,13 +291,14 @@ public class UiccSmsController extends ISms.Stub { | |
@Override | |
public boolean isSmsSimPickActivityNeeded(int subId) { | |
- if (!isSMSPromptEnabled()) { | |
+ final Context context = ActivityThread.currentApplication().getApplicationContext(); | |
+ boolean canCurrentAppHandleAlwaysAsk = SmsApplication.canSmsAppHandleAlwaysAsk(context); | |
+ if (!isSMSPromptEnabled() && canCurrentAppHandleAlwaysAsk) { | |
Rlog.d(LOG_TAG, "isSmsSimPickActivityNeeded: false, sms prompt disabled."); | |
// user knows best | |
return false; | |
} | |
- final Context context = ActivityThread.currentApplication().getApplicationContext(); | |
TelephonyManager telephonyManager = | |
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); | |
List<SubscriptionInfo> subInfoList; | |
@@ -331,7 +332,7 @@ public class UiccSmsController extends ISms.Stub { | |
} | |
} | |
- return false; | |
+ return !canCurrentAppHandleAlwaysAsk; | |
} | |
@Override | |
-- | |
2.7.4 | |
From 90ffa115e54cc23857a53adc3ef6107271bd807c Mon Sep 17 00:00:00 2001 | |
From: Roman Birg <roman@cyngn.com> | |
Date: Wed, 22 Jun 2016 15:12:01 -0700 | |
Subject: [PATCH 12/12] Subscription updater: don't turn data off if we've | |
never set a deafult | |
In the case of an MSIM device that has only had 1 SIM and then you swap | |
the sim to another slot, the data will turn off, but it's the same SIM | |
and should not. | |
Change-Id: I77ed8c22663aa10d211e6f4de06b791c1a8f0971 | |
Signed-off-by: Roman Birg <roman@cyngn.com> | |
--- | |
.../com/android/internal/telephony/SubscriptionInfoUpdater.java | 6 +++++- | |
1 file changed, 5 insertions(+), 1 deletion(-) | |
diff --git a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
index 8ee2353..aadb579 100644 | |
--- a/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
+++ b/src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java | |
@@ -720,7 +720,11 @@ public class SubscriptionInfoUpdater extends Handler { | |
Settings.Global.MULTI_SIM_DATA_CALL_SUBSCRIPTION, | |
SubscriptionManager.INVALID_SUBSCRIPTION_ID); | |
- if (realStoredDataSub != SubscriptionManager.getDefaultDataSubscriptionId()) { | |
+ if (realStoredDataSub != SubscriptionManager.INVALID_SUBSCRIPTION_ID && | |
+ realStoredDataSub != SubscriptionManager.getDefaultDataSubscriptionId()) { | |
+ logd("switching data off; real stored sub: " + realStoredDataSub | |
+ + ", and we think the default sub id is now: " | |
+ + SubscriptionManager.getDefaultDataSubscriptionId()); | |
PhoneFactory.getDefaultPhone().setDataEnabled(false); | |
} | |
} else if (insertedSimCount > 1) { | |
-- | |
2.7.4 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 7b88e2e35e783c3509f500bf968f06c76da771a3 Mon Sep 17 00:00:00 2001 | |
From: Sandeep Gutta <sangutta@codeaurora.org> | |
Date: Fri, 12 Sep 2014 01:14:35 +0530 | |
Subject: [PATCH 1/3] MSIM: Phone account related changes | |
- Do not set "always ask" if only one account present | |
- Use voice subId from SIM Settings as default outgoing account | |
Change-Id: I9e7b16f20c357f8d3ceedfba781bc893d11c39ea | |
--- | |
.../server/telecom/PhoneAccountRegistrar.java | 30 ++++++++++++++++++++++ | |
1 file changed, 30 insertions(+) | |
diff --git a/src/com/android/server/telecom/PhoneAccountRegistrar.java b/src/com/android/server/telecom/PhoneAccountRegistrar.java | |
index 7090c21..11efa66 100644 | |
--- a/src/com/android/server/telecom/PhoneAccountRegistrar.java | |
+++ b/src/com/android/server/telecom/PhoneAccountRegistrar.java | |
@@ -232,6 +232,10 @@ public class PhoneAccountRegistrar { | |
DefaultPhoneAccountHandle defaultPhoneAccountHandle = mState.defaultOutgoingAccountHandles | |
.get(userHandle); | |
if (defaultPhoneAccountHandle == null) { | |
+ if (TelephonyManager.getDefault().getPhoneCount() > 1 && | |
+ mSubscriptionManager.getActiveSubscriptionInfoCount() == 1) { | |
+ return getUserSelectedVoicePhoneAccount(); | |
+ } | |
return null; | |
} | |
// Make sure the account is still registered and owned by the user. | |
@@ -244,6 +248,32 @@ public class PhoneAccountRegistrar { | |
return null; | |
} | |
+ PhoneAccountHandle getUserSelectedVoicePhoneAccount() { | |
+ long voiceSubId = SubscriptionManager.getDefaultVoiceSubscriptionId(); | |
+ PhoneAccountHandle prefPhoneAccount = null; | |
+ | |
+ Log.i(this, "getUserSelVoicePhoneAccount, voice subId = " + voiceSubId); | |
+ for (int i = 0; i < mState.accounts.size(); i++) { | |
+ String id = mState.accounts.get(i).getAccountHandle().getId(); | |
+ | |
+ // emergency account present return it | |
+ if (id.equals("E")) { | |
+ Log.i(this, "getUserSelVoicePhoneAccount, emergency account "); | |
+ return mState.accounts.get(i).getAccountHandle(); | |
+ } | |
+ | |
+ long subId = Long.parseLong(id); | |
+ Log.i(this, "getUserSelectedVoicePhoneAccount, voice subId = " | |
+ + voiceSubId + " subId = " + subId + " mId = " + id); | |
+ if (subId == voiceSubId) { | |
+ prefPhoneAccount = mState.accounts.get(i).getAccountHandle(); | |
+ break; | |
+ } | |
+ } | |
+ | |
+ return prefPhoneAccount; | |
+ } | |
+ | |
/** | |
* Sets the phone account with which to place all calls by default. Set by the user | |
* within phone settings. | |
-- | |
2.7.4 | |
From c8ce70158838d45d77c029c5447d87e88a35b633 Mon Sep 17 00:00:00 2001 | |
From: LuK1337 <priv.luk@gmail.com> | |
Date: Wed, 6 Jan 2016 17:25:30 +0100 | |
Subject: [PATCH 2/3] Do not query for default sim when more than 1 calling | |
account is available | |
* Fixes an issue when com.android.phone crashes if user has | |
single SIM inserted and SIP account set up. | |
Change-Id: I8034a13a6b2d55b32e44c5c7761ff02ee36383cf | |
--- | |
src/com/android/server/telecom/PhoneAccountRegistrar.java | 2 +- | |
1 file changed, 1 insertion(+), 1 deletion(-) | |
diff --git a/src/com/android/server/telecom/PhoneAccountRegistrar.java b/src/com/android/server/telecom/PhoneAccountRegistrar.java | |
index 11efa66..505b084 100644 | |
--- a/src/com/android/server/telecom/PhoneAccountRegistrar.java | |
+++ b/src/com/android/server/telecom/PhoneAccountRegistrar.java | |
@@ -233,7 +233,7 @@ public class PhoneAccountRegistrar { | |
.get(userHandle); | |
if (defaultPhoneAccountHandle == null) { | |
if (TelephonyManager.getDefault().getPhoneCount() > 1 && | |
- mSubscriptionManager.getActiveSubscriptionInfoCount() == 1) { | |
+ getAllPhoneAccounts(userHandle).size() == 1) { | |
return getUserSelectedVoicePhoneAccount(); | |
} | |
return null; | |
-- | |
2.7.4 | |
From cf5ceca31b79ae7d3025c54abc6a2f18600b3e93 Mon Sep 17 00:00:00 2001 | |
From: LuK1337 <priv.luk@gmail.com> | |
Date: Thu, 9 Jun 2016 15:43:39 +0200 | |
Subject: [PATCH 3/3] Handle IllegalArgumentException while setting default | |
calling sub | |
* How to reproduce: | |
1. Add new SIP account | |
2. Disable it in "All calling accounts" | |
3. Reboot | |
Change-Id: Iaa2546588464a34871d7da8bba0b366d0ca43ab8 | |
--- | |
.../android/server/telecom/PhoneAccountRegistrar.java | 17 +++++++++++------ | |
1 file changed, 11 insertions(+), 6 deletions(-) | |
diff --git a/src/com/android/server/telecom/PhoneAccountRegistrar.java b/src/com/android/server/telecom/PhoneAccountRegistrar.java | |
index 505b084..11b113c 100644 | |
--- a/src/com/android/server/telecom/PhoneAccountRegistrar.java | |
+++ b/src/com/android/server/telecom/PhoneAccountRegistrar.java | |
@@ -70,6 +70,7 @@ import java.io.InputStream; | |
import java.lang.Integer; | |
import java.lang.SecurityException; | |
import java.lang.String; | |
+import java.lang.IllegalArgumentException; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.Comparator; | |
@@ -262,12 +263,16 @@ public class PhoneAccountRegistrar { | |
return mState.accounts.get(i).getAccountHandle(); | |
} | |
- long subId = Long.parseLong(id); | |
- Log.i(this, "getUserSelectedVoicePhoneAccount, voice subId = " | |
- + voiceSubId + " subId = " + subId + " mId = " + id); | |
- if (subId == voiceSubId) { | |
- prefPhoneAccount = mState.accounts.get(i).getAccountHandle(); | |
- break; | |
+ try { | |
+ long subId = Long.parseLong(id); | |
+ Log.i(this, "getUserSelectedVoicePhoneAccount, voice subId = " | |
+ + voiceSubId + " subId = " + subId + " mId = " + id); | |
+ if (subId == voiceSubId) { | |
+ prefPhoneAccount = mState.accounts.get(i).getAccountHandle(); | |
+ break; | |
+ } | |
+ } catch (IllegalArgumentException e) { | |
+ Log.w(this, "getUserSelectedVoicePhoneAccount, accountHandle ID = " + id); | |
} | |
} | |
-- | |
2.7.4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment