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

Commit 4856f85a authored by Hakjun Choi's avatar Hakjun Choi
Browse files

Add subscription Id as parameter when invoke satellite settings activity

When invoking satellite settings activity from system notification when the satellite is connected for the first time, no subscription ID is available, therefore it is unable to check whether the user has eligible mobile plan or not.

Bug: 327540878
Test: manual test on pixel
     1. jump to satellite settings menu when click system notification 	when carrier satellite feature is enabled.
     2. does not show the system notification for the first time satellite connection when carrier satellite feature is disabled.

Change-Id: I65359d71d5959a066f21461808f31b1d5d6d2905
parent cef2c097
Loading
Loading
Loading
Loading
+19 −11
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ import android.telephony.satellite.SatelliteCapabilities;
import android.telephony.satellite.SatelliteDatagram;
import android.telephony.satellite.SatelliteManager;
import android.util.Log;
import android.util.Pair;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.uwb.UwbManager;
@@ -2596,21 +2597,21 @@ public class SatelliteController extends Handler {
    }

    /**
     * @return {@code true} if any subscription on the device is connected to satellite,
     * {@code false} otherwise.
     * @return {@code Pair<true, subscription ID>} if any subscription on the device is connected to
     * satellite, {@code Pair<false, null>} otherwise.
     */
    private boolean isUsingNonTerrestrialNetworkViaCarrier() {
    private Pair<Boolean, Integer> isUsingNonTerrestrialNetworkViaCarrier() {
        if (!mFeatureFlags.carrierEnabledSatelliteFlag()) {
            logd("isUsingNonTerrestrialNetwork: carrierEnabledSatelliteFlag is disabled");
            return false;
            return new Pair<>(false, null);
        }
        for (Phone phone : PhoneFactory.getPhones()) {
            ServiceState serviceState = phone.getServiceState();
            if (serviceState != null && serviceState.isUsingNonTerrestrialNetwork()) {
                return true;
                return new Pair<>(true, phone.getSubId());
            }
        }
        return false;
        return new Pair<>(false, null);
    }

    /**
@@ -2624,7 +2625,7 @@ public class SatelliteController extends Handler {
                    + " is disabled");
            return false;
        }
        if (isUsingNonTerrestrialNetworkViaCarrier()) {
        if (isUsingNonTerrestrialNetworkViaCarrier().first) {
            return true;
        }
        for (Phone phone : PhoneFactory.getPhones()) {
@@ -3995,7 +3996,13 @@ public class SatelliteController extends Handler {
    }

    private void determineSystemNotification() {
        if (isUsingNonTerrestrialNetworkViaCarrier()) {
        if (!mFeatureFlags.carrierEnabledSatelliteFlag()) {
            logd("determineSystemNotification: carrierEnabledSatelliteFlag is disabled");
            return;
        }

        Pair<Boolean, Integer> isNtn = isUsingNonTerrestrialNetworkViaCarrier();
        if (isNtn.first) {
            if (mSharedPreferences == null) {
                try {
                    mSharedPreferences = mContext.getSharedPreferences(SATELLITE_SHARED_PREF,
@@ -4005,18 +4012,18 @@ public class SatelliteController extends Handler {
                }
            }
            if (mSharedPreferences == null) {
                loge("handleEventServiceStateChanged: Cannot get default shared preferences");
                loge("determineSystemNotification: Cannot get default shared preferences");
                return;
            }
            if (!mSharedPreferences.getBoolean(SATELLITE_SYSTEM_NOTIFICATION_DONE_KEY, false)) {
                showSatelliteSystemNotification();
                showSatelliteSystemNotification(isNtn.second);
                mSharedPreferences.edit().putBoolean(SATELLITE_SYSTEM_NOTIFICATION_DONE_KEY,
                        true).apply();
            }
        }
    }

    private void showSatelliteSystemNotification() {
    private void showSatelliteSystemNotification(int subId) {
        logd("showSatelliteSystemNotification");
        final NotificationChannel notificationChannel = new NotificationChannel(
                NOTIFICATION_CHANNEL_ID,
@@ -4054,6 +4061,7 @@ public class SatelliteController extends Handler {

        // Add action to invoke Satellite setting activity in Settings.
        Intent intentSatelliteSetting = new Intent(ACTION_SATELLITE_SETTING);
        intentSatelliteSetting.putExtra("sub_id", subId);
        PendingIntent pendingIntentSatelliteSetting = PendingIntent.getActivity(mContext, 0,
                intentSatelliteSetting, PendingIntent.FLAG_IMMUTABLE);