Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c59761cc authored by Nathan Harold's avatar Nathan Harold
Browse files

Fix a Null retval in SM#getSubscriptionsInGroup

In the event that the SubscriptionService can't be
reached, system callers receive a null return value
instead of receiving the documented NonNull result.

Simple fix to ensure that the return value is an empty
list.

Bug: 296125268
Test: atest FrameworksTelephonyTests
Test: MO/MT voice call, MO/MT sms, data
Change-Id: I21f536e8739c1fb27caeac3266e964eb64c56a3e
parent b8196321
Loading
Loading
Loading
Loading
+11 −18
Original line number Diff line number Diff line
@@ -3396,16 +3396,12 @@ public class SubscriptionManager {
            if (iSub != null) {
                groupUuid = iSub.createSubscriptionGroup(subIdArray, pkgForDebug);
            } else {
                if (!isSystemProcess()) {
                throw new IllegalStateException("telephony service is null.");
            }
            }
        } catch (RemoteException ex) {
            loge("createSubscriptionGroup RemoteException " + ex);
            if (!isSystemProcess()) {
            ex.rethrowAsRuntimeException();
        }
        }

        return groupUuid;
    }
@@ -3446,17 +3442,13 @@ public class SubscriptionManager {
            if (iSub != null) {
                iSub.addSubscriptionsIntoGroup(subIdArray, groupUuid, pkgForDebug);
            } else {
                if (!isSystemProcess()) {
                throw new IllegalStateException("telephony service is null.");
            }
            }
        } catch (RemoteException ex) {
            loge("addSubscriptionsIntoGroup RemoteException " + ex);
            if (!isSystemProcess()) {
            ex.rethrowAsRuntimeException();
        }
    }
    }

    private boolean isSystemProcess() {
        return Process.myUid() == Process.SYSTEM_UID;
@@ -3497,17 +3489,13 @@ public class SubscriptionManager {
            if (iSub != null) {
                iSub.removeSubscriptionsFromGroup(subIdArray, groupUuid, callingPackage);
            } else {
                if (!isSystemProcess()) {
                throw new IllegalStateException("telephony service is null.");
            }
            }
        } catch (RemoteException ex) {
            loge("removeSubscriptionsFromGroup RemoteException " + ex);
            if (!isSystemProcess()) {
            ex.rethrowAsRuntimeException();
        }
    }
    }

    /**
     * Get subscriptionInfo list of subscriptions that are in the same group of given subId.
@@ -3562,6 +3550,11 @@ public class SubscriptionManager {
            }
        }

        // TODO(b/296125268) Really this method should throw, but it's common enough that for
        // system callers it's worth having a little magic for the system process until it's
        // made safer.
        if (result == null) result = Collections.emptyList();

        return result;
    }