[Settings] Avoid from accessing IMS with invalid subscription id

Check subscription ID before accessing to IMS APIs

Bug: 149190278
Test: make and manual test
Change-Id: I0561529ccaf23c84d7d6dd3e268386ab82f17418
This commit is contained in:
Bonian Chen
2020-03-20 13:31:35 +08:00
parent b33c16cacb
commit 4a49f426fb
4 changed files with 24 additions and 0 deletions

View File

@@ -60,6 +60,9 @@ public class VolteQueryImsState extends ImsQueryController {
*/
@VisibleForTesting
boolean isEnabledByUser(int subId) {
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
return false;
}
return (new ImsQueryEnhanced4gLteModeUserSetting(subId)).query();
}
@@ -75,6 +78,9 @@ public class VolteQueryImsState extends ImsQueryController {
* @return true when VoLTE has been enabled, otherwise false
*/
public boolean isVoLteProvisioned() {
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
return false;
}
if (!isProvisionedOnDevice(mSubId)) {
return false;
}
@@ -92,6 +98,9 @@ public class VolteQueryImsState extends ImsQueryController {
* @return true when VoLTE can be performed, otherwise false
*/
public boolean isReadyToVoLte() {
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
return false;
}
return isVoLteProvisioned()
&& MobileNetworkUtils.isImsServiceStateReady(getImsManager(mSubId));
}