Merge "Add new apis for satellite service" into main
diff --git a/src/java/com/android/internal/telephony/subscription/SubscriptionDatabaseManager.java b/src/java/com/android/internal/telephony/subscription/SubscriptionDatabaseManager.java
index 3fcbdb8..2e2b147 100644
--- a/src/java/com/android/internal/telephony/subscription/SubscriptionDatabaseManager.java
+++ b/src/java/com/android/internal/telephony/subscription/SubscriptionDatabaseManager.java
@@ -48,6 +48,7 @@
 
 import com.android.internal.annotations.GuardedBy;
 import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.telephony.flags.FeatureFlags;
 import com.android.internal.telephony.uicc.UiccController;
 import com.android.internal.util.function.TriConsumer;
 import com.android.telephony.Rlog;
@@ -277,8 +278,10 @@
                     SubscriptionInfoInternal::getSatelliteEnabled),
             new AbstractMap.SimpleImmutableEntry<>(
                     SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
-                    SubscriptionInfoInternal::getSatelliteAttachEnabledForCarrier)
-
+                    SubscriptionInfoInternal::getSatelliteAttachEnabledForCarrier),
+            new AbstractMap.SimpleImmutableEntry<>(
+                    SimInfo.COLUMN_IS_NTN,
+                    SubscriptionInfoInternal::getNtn)
     );
 
     /**
@@ -406,7 +409,10 @@
                     SubscriptionDatabaseManager::setSatelliteEnabled),
             new AbstractMap.SimpleImmutableEntry<>(
                     SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
-                    SubscriptionDatabaseManager::setSatelliteAttachEnabledForCarrier)
+                    SubscriptionDatabaseManager::setSatelliteAttachEnabledForCarrier),
+            new AbstractMap.SimpleImmutableEntry<>(
+                    SimInfo.COLUMN_IS_NTN,
+                    SubscriptionDatabaseManager::setNtn)
     );
 
     /**
@@ -538,6 +544,10 @@
     @NonNull
     private final Context mContext;
 
+    /** The feature flags */
+    @NonNull
+    private final FeatureFlags mFeatureFlags;
+
     /** The callback used for passing events back to {@link SubscriptionManagerService}. */
     @NonNull
     private final SubscriptionDatabaseManagerCallback mCallback;
@@ -628,9 +638,11 @@
      *
      * @param context The context.
      * @param looper Looper for the handler.
+     * @param featureFlags The feature flags.
      * @param callback Subscription database callback.
      */
     public SubscriptionDatabaseManager(@NonNull Context context, @NonNull Looper looper,
+            @NonNull FeatureFlags featureFlags,
             @NonNull SubscriptionDatabaseManagerCallback callback) {
         super(looper);
         log("Created SubscriptionDatabaseManager.");
@@ -639,6 +651,7 @@
         mUiccController = UiccController.getInstance();
         mAsyncMode = mContext.getResources().getBoolean(
                 com.android.internal.R.bool.config_subscription_database_async_update);
+        mFeatureFlags = featureFlags;
         initializeDatabase();
     }
 
@@ -2014,6 +2027,23 @@
     }
 
     /**
+     * Set whether the subscription is exclusively used for non-terrestrial networks or not.
+     *
+     * @param subId Subscription ID.
+     * @param isNtn {@code 1} if it is a non-terrestrial network subscription.
+     * {@code 0} otherwise.
+     *
+     * @throws IllegalArgumentException if the subscription does not exist.
+     */
+    public void setNtn(int subId, int isNtn) {
+        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
+            return;
+        }
+        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_IS_NTN, isNtn,
+                SubscriptionInfoInternal.Builder::setNtn);
+    }
+
+    /**
      * Set whether group of the subscription is disabled. This is only useful if it's a grouped
      * opportunistic subscription. In this case, if all primary (non-opportunistic)
      * subscriptions in the group are deactivated (unplugged pSIM or deactivated eSIM profile),
@@ -2272,7 +2302,11 @@
                         SimInfo.COLUMN_SATELLITE_ENABLED)))
                 .setSatelliteAttachEnabledForCarrier(cursor.getInt(
                         cursor.getColumnIndexOrThrow(
-                        SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER)));
+                                SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER)));
+        if (mFeatureFlags.oemEnabledSatelliteFlag()) {
+            builder.setNtn(cursor.getInt(cursor.getColumnIndexOrThrow(
+                    SimInfo.COLUMN_IS_NTN)));
+        }
         return builder.build();
     }
 
diff --git a/src/java/com/android/internal/telephony/subscription/SubscriptionInfoInternal.java b/src/java/com/android/internal/telephony/subscription/SubscriptionInfoInternal.java
index 4eda949..942e9ce 100644
--- a/src/java/com/android/internal/telephony/subscription/SubscriptionInfoInternal.java
+++ b/src/java/com/android/internal/telephony/subscription/SubscriptionInfoInternal.java
@@ -448,6 +448,12 @@
      */
     private final int mIsSatelliteAttachEnabledForCarrier;
 
+    /**
+     * Whether this subscription is used for communicating with non-terrestrial networks.
+     * By default, its disabled. It is intended to use integer to fit the database format.
+     */
+    private final int mIsNtn;
+
     // Below are the fields that do not exist in the SimInfo table.
     /**
      * The card ID of the SIM card. This maps uniquely to {@link #mCardString}.
@@ -532,6 +538,7 @@
         this.mIsSatelliteEnabled = builder.mIsSatelliteEnabled;
         this.mIsSatelliteAttachEnabledForCarrier =
                 builder.mIsSatelliteAttachEnabledForCarrier;
+        this.mIsNtn = builder.mIsNtn;
 
         // Below are the fields that do not exist in the SimInfo table.
         this.mCardId = builder.mCardId;
@@ -1143,6 +1150,15 @@
         return mIsSatelliteAttachEnabledForCarrier;
     }
 
+    /**
+     * An NTN subscription connects to non-terrestrial networks.
+     *
+     * @return {@code 1} if the subscription is for non-terrestrial networks. {@code 0} otherwise.
+     */
+    public int getNtn() {
+        return mIsNtn;
+    }
+
     // Below are the fields that do not exist in SimInfo table.
     /**
      * @return The card ID of the SIM card which contains the subscription.
@@ -1212,6 +1228,7 @@
                 .setUiccApplicationsEnabled(mAreUiccApplicationsEnabled != 0)
                 .setPortIndex(mPortIndex)
                 .setUsageSetting(mUsageSetting)
+                .setNtn(mIsNtn == 1)
                 .build();
     }
 
@@ -1269,6 +1286,7 @@
                 + " userId=" + mUserId
                 + " isSatelliteEnabled=" + mIsSatelliteEnabled
                 + " satellite_attach_enabled_for_carrier=" + mIsSatelliteAttachEnabledForCarrier
+                + " getNtn=" + mIsNtn
                 + " isGroupDisabled=" + mIsGroupDisabled
                 + "]";
     }
@@ -1325,7 +1343,8 @@
                 that.mAllowedNetworkTypesForReasons) && mDeviceToDeviceStatusSharingContacts.equals(
                 that.mDeviceToDeviceStatusSharingContacts) && mNumberFromCarrier.equals(
                 that.mNumberFromCarrier) && mNumberFromIms.equals(that.mNumberFromIms)
-                && mIsSatelliteAttachEnabledForCarrier == that.mIsSatelliteAttachEnabledForCarrier;
+                && mIsSatelliteAttachEnabledForCarrier == that.mIsSatelliteAttachEnabledForCarrier
+                && mIsNtn == that.mIsNtn;
     }
 
     @Override
@@ -1347,7 +1366,7 @@
                 mNumberFromCarrier,
                 mNumberFromIms, mPortIndex, mUsageSetting, mLastUsedTPMessageReference, mUserId,
                 mIsSatelliteEnabled, mCardId, mIsGroupDisabled,
-                mIsSatelliteAttachEnabledForCarrier);
+                mIsSatelliteAttachEnabledForCarrier, mIsNtn);
         result = 31 * result + Arrays.hashCode(mNativeAccessRules);
         result = 31 * result + Arrays.hashCode(mCarrierConfigAccessRules);
         result = 31 * result + Arrays.hashCode(mRcsConfig);
@@ -1708,12 +1727,17 @@
         /**
          * Whether satellite is enabled or not.
          */
-        private int mIsSatelliteEnabled = -1;
+        private int mIsSatelliteEnabled = 0;
 
         /**
          * Whether satellite attach for carrier is enabled by user.
          */
-        private int mIsSatelliteAttachEnabledForCarrier = -1;
+        private int mIsSatelliteAttachEnabledForCarrier = 0;
+
+        /**
+         * Whether this subscription is used for communicating with non-terrestrial network or not.
+         */
+        private int mIsNtn = 0;
 
         // The following fields do not exist in the SimInfo table.
         /**
@@ -1803,6 +1827,7 @@
             mUserId = info.mUserId;
             mIsSatelliteEnabled = info.mIsSatelliteEnabled;
             mIsSatelliteAttachEnabledForCarrier = info.mIsSatelliteAttachEnabledForCarrier;
+            mIsNtn = info.mIsNtn;
             // Below are the fields that do not exist in the SimInfo table.
             mCardId = info.mCardId;
             mIsGroupDisabled = info.mIsGroupDisabled;
@@ -2686,6 +2711,18 @@
             return this;
         }
 
+        /**
+         * Set whether the subscription is for NTN or not.
+         *
+         * @param isNtn {@code 1} if the subscription is for NTN, {@code 0} otherwise.
+         * @return The builder.
+         */
+        @NonNull
+        public Builder setNtn(int isNtn) {
+            mIsNtn = isNtn;
+            return this;
+        }
+
         // Below are the fields that do not exist in the SimInfo table.
         /**
          * Set the card ID of the SIM card which contains the subscription.
diff --git a/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java b/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java
index 3b03a62..83048d8 100644
--- a/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java
+++ b/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java
@@ -175,7 +175,8 @@
             SimInfo.COLUMN_D2D_STATUS_SHARING_SELECTED_CONTACTS,
             SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED,
             SimInfo.COLUMN_SATELLITE_ENABLED,
-            SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER
+            SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
+            SimInfo.COLUMN_IS_NTN
     );
 
     /**
@@ -488,7 +489,8 @@
         HandlerThread handlerThread = new HandlerThread(LOG_TAG);
         handlerThread.start();
         mSubscriptionDatabaseManager = new SubscriptionDatabaseManager(context,
-                handlerThread.getLooper(), new SubscriptionDatabaseManagerCallback(mHandler::post) {
+                handlerThread.getLooper(), mFeatureFlags,
+                new SubscriptionDatabaseManagerCallback(mHandler::post) {
                     /**
                      * Called when database has been loaded into the cache.
                      */
@@ -826,6 +828,26 @@
     }
 
     /**
+     * Set whether the subscription ID supports oem satellite or not.
+     *
+     * @param subId The subscription ID.
+     * @param isNtn {@code true} Requested subscription ID supports oem satellite service,
+     * {@code false} otherwise.
+     */
+    public void setNtn(int subId, boolean isNtn) {
+        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
+            return;
+        }
+
+        // This can throw IllegalArgumentException if the subscription does not exist.
+        try {
+            mSubscriptionDatabaseManager.setNtn(subId, (isNtn ? 1 : 0));
+        } catch (IllegalArgumentException e) {
+            loge("setNtn: invalid subId=" + subId);
+        }
+    }
+
+    /**
      * Set ISO country code by subscription id.
      *
      * @param iso ISO country code associated with the subscription.
@@ -1120,6 +1142,9 @@
                         String mnc = cid.getMnc();
                         builder.setMcc(mcc);
                         builder.setMnc(mnc);
+                        if (mFeatureFlags.oemEnabledSatelliteFlag()) {
+                            builder.setNtn(isSatellitePlmn(mcc + mnc) ? 1 : 0);
+                        }
                     }
                     // If cardId = unsupported or un-initialized, we have no reason to update DB.
                     // Additionally, if the device does not support cardId for default eUICC, the
@@ -1391,6 +1416,7 @@
                             MccTable.updateMccMncConfiguration(mContext, mccMnc);
                         }
                         setMccMnc(subId, mccMnc);
+                        setNtn(subId, isSatellitePlmn(mccMnc));
                     } else {
                         loge("updateSubscription: mcc/mnc is empty");
                     }
@@ -3959,6 +3985,30 @@
     }
 
     /**
+     * @param mccMnc MccMnc value to check whether it supports non-terrestrial network or not.
+     * @return {@code true} if MCC/MNC is matched with in the device overlay key
+     * "config_satellite_esim_identifier", {@code false} otherwise.
+     */
+    private boolean isSatellitePlmn(@NonNull String mccMnc) {
+        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
+            return false;
+        }
+
+        final int id = R.string.config_satellite_esim_identifier;
+        String overlayMccMnc = null;
+        try {
+            overlayMccMnc = mContext.getResources().getString(id);
+        } catch (Resources.NotFoundException ex) {
+            loge("isSatellitePlmn: id= " + id + ", ex=" + ex);
+        }
+        if (overlayMccMnc == null) {
+            return false;
+        } else {
+            return mccMnc.equals(overlayMccMnc);
+        }
+    }
+
+    /**
      * Log debug messages.
      *
      * @param s debug messages
diff --git a/tests/telephonytests/src/com/android/internal/telephony/FakeTelephonyProvider.java b/tests/telephonytests/src/com/android/internal/telephony/FakeTelephonyProvider.java
index 47e315d..2692057 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/FakeTelephonyProvider.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/FakeTelephonyProvider.java
@@ -128,9 +128,10 @@
                     + "  INTEGER DEFAULT -1,"
                     + Telephony.SimInfo.COLUMN_USER_HANDLE + " INTEGER DEFAULT "
                     + UserHandle.USER_NULL + ","
-                    + Telephony.SimInfo.COLUMN_SATELLITE_ENABLED + " INTEGER DEFAULT -1,"
+                    + Telephony.SimInfo.COLUMN_SATELLITE_ENABLED + " INTEGER DEFAULT 0,"
                     + Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER
-                    + " INTEGER DEFAULT -1"
+                    + " INTEGER DEFAULT 0, "
+                    + Telephony.SimInfo.COLUMN_IS_NTN + " INTEGER DEFAULT 0"
                     + ");";
         }
 
diff --git a/tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoTest.java b/tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoTest.java
index 3bafe4d..20ad1a2 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoTest.java
@@ -21,6 +21,8 @@
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
 
+import com.android.internal.telephony.flags.Flags;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -52,6 +54,7 @@
                 .setEhplmns(EHPLMNS)
                 .setHplmns(HPLMNS)
                 .setCountryIso("us")
+                .setNtn(true)
                 .build();
     }
 
@@ -71,6 +74,9 @@
         assertThat(mSubscriptionInfoUT.getSubscriptionId()).isEqualTo(1);
         assertThat(mSubscriptionInfoUT.getSimSlotIndex()).isEqualTo(0);
         assertThat(mSubscriptionInfoUT.getIccId()).isEqualTo("890126042XXXXXXXXXXX");
+        if (Flags.oemEnabledSatelliteFlag()) {
+            assertThat(mSubscriptionInfoUT.isNtn()).isTrue();
+        }
     }
 
     @Test
diff --git a/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionDatabaseManagerTest.java b/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionDatabaseManagerTest.java
index 59dfec6..ce77f14 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionDatabaseManagerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionDatabaseManagerTest.java
@@ -26,8 +26,10 @@
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import android.annotation.NonNull;
 import android.annotation.Nullable;
@@ -49,6 +51,7 @@
 import android.testing.TestableLooper;
 
 import com.android.internal.telephony.TelephonyTest;
+import com.android.internal.telephony.flags.FeatureFlags;
 import com.android.internal.telephony.subscription.SubscriptionDatabaseManager.SubscriptionDatabaseManagerCallback;
 
 import org.junit.After;
@@ -119,10 +122,14 @@
     static final int FAKE_USER_ID2 = 11;
     static final int FAKE_SATELLITE_ATTACH_FOR_CARRIER_ENABLED = 1;
     static final int FAKE_SATELLITE_ATTACH_FOR_CARRIER_DISABLED = 0;
+    static final int FAKE_SATELLITE_IS_NTN_ENABLED = 1;
+    static final int FAKE_SATELLITE_IS_NTN_DISABLED = 0;
 
     static final String FAKE_MAC_ADDRESS1 = "DC:E5:5B:38:7D:40";
     static final String FAKE_MAC_ADDRESS2 = "DC:B5:4F:47:F3:4C";
 
+    private FeatureFlags mFeatureFlags;
+
     static final SubscriptionInfoInternal FAKE_SUBSCRIPTION_INFO1 =
             new SubscriptionInfoInternal.Builder()
                     .setId(1)
@@ -190,6 +197,7 @@
                     .setSatelliteEnabled(0)
                     .setSatelliteAttachEnabledForCarrier(
                             FAKE_SATELLITE_ATTACH_FOR_CARRIER_DISABLED)
+                    .setNtn(FAKE_SATELLITE_IS_NTN_DISABLED)
                     .setGroupDisabled(false)
                     .build();
 
@@ -260,6 +268,7 @@
                     .setSatelliteEnabled(1)
                     .setSatelliteAttachEnabledForCarrier(
                             FAKE_SATELLITE_ATTACH_FOR_CARRIER_ENABLED)
+                    .setNtn(FAKE_SATELLITE_IS_NTN_ENABLED)
                     .setGroupDisabled(false)
                     .build();
 
@@ -412,14 +421,16 @@
             ((Runnable) invocation.getArguments()[0]).run();
             return null;
         }).when(mSubscriptionDatabaseManagerCallback).invokeFromExecutor(any(Runnable.class));
+        mFeatureFlags = Mockito.mock(FeatureFlags.class);
 
         ((MockContentResolver) mContext.getContentResolver()).addProvider(
                 Telephony.Carriers.CONTENT_URI.getAuthority(), mSubscriptionProvider);
 
         doReturn(1).when(mUiccController).convertToPublicCardId(eq(FAKE_ICCID1));
         doReturn(2).when(mUiccController).convertToPublicCardId(eq(FAKE_ICCID2));
+        when(mFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(true);
         mDatabaseManagerUT = new SubscriptionDatabaseManager(mContext, Looper.myLooper(),
-                mSubscriptionDatabaseManagerCallback);
+                mFeatureFlags, mSubscriptionDatabaseManagerCallback);
         logd("SubscriptionDatabaseManagerTest -Setup!");
     }
 
@@ -524,7 +535,7 @@
         mContextFixture.putBooleanResource(com.android.internal.R.bool
                 .config_subscription_database_async_update, false);
         mDatabaseManagerUT = new SubscriptionDatabaseManager(mContext, Looper.myLooper(),
-                mSubscriptionDatabaseManagerCallback);
+                mFeatureFlags, mSubscriptionDatabaseManagerCallback);
 
         assertThat(insertSubscriptionAndVerify(FAKE_SUBSCRIPTION_INFO1).getSubscriptionId())
                 .isEqualTo(1);
@@ -1971,6 +1982,80 @@
     }
 
     @Test
+    public void testUpdateSatelliteNtn() throws Exception {
+        // exception is expected if there is nothing in the database.
+        assertThrows(IllegalArgumentException.class,
+                () -> mDatabaseManagerUT.setNtn(FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
+                        FAKE_SATELLITE_IS_NTN_ENABLED));
+
+        SubscriptionInfoInternal subInfo = insertSubscriptionAndVerify(FAKE_SUBSCRIPTION_INFO1);
+        mDatabaseManagerUT.setNtn(FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
+                FAKE_SATELLITE_IS_NTN_ENABLED);
+        processAllMessages();
+
+        subInfo = new SubscriptionInfoInternal.Builder(subInfo)
+                .setNtn(FAKE_SATELLITE_IS_NTN_ENABLED)
+                .build();
+        verifySubscription(subInfo);
+        verify(mSubscriptionDatabaseManagerCallback, times(2)).onSubscriptionChanged(eq(1));
+
+        assertThat(mDatabaseManagerUT.getSubscriptionProperty(
+                FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
+                SimInfo.COLUMN_IS_NTN)).isEqualTo(FAKE_SATELLITE_IS_NTN_ENABLED);
+
+        mDatabaseManagerUT.setSubscriptionProperty(FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
+                SimInfo.COLUMN_IS_NTN, FAKE_SATELLITE_IS_NTN_DISABLED);
+        assertThat(mDatabaseManagerUT.getSubscriptionInfoInternal(
+                        FAKE_SUBSCRIPTION_INFO1.getSubscriptionId()).getNtn())
+                .isEqualTo(FAKE_SATELLITE_IS_NTN_DISABLED);
+    }
+
+    @Test
+    public void testUpdateSatelliteNtnWithFeatureDisabled() throws Exception {
+        assertThrows(IllegalArgumentException.class,
+                () -> mDatabaseManagerUT.setSatelliteAttachEnabledForCarrier(
+                        FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
+                        FAKE_SATELLITE_ATTACH_FOR_CARRIER_ENABLED));
+
+        SubscriptionInfoInternal subInfo = insertSubscriptionAndVerify(FAKE_SUBSCRIPTION_INFO1);
+        mDatabaseManagerUT.setSatelliteAttachEnabledForCarrier(
+                FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
+                FAKE_SATELLITE_IS_NTN_DISABLED);
+        processAllMessages();
+
+        when(mFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(false);
+        reset(mSubscriptionDatabaseManagerCallback);
+        subInfo = new SubscriptionInfoInternal.Builder(subInfo)
+                .setNtn(FAKE_SATELLITE_IS_NTN_ENABLED)
+                .build();
+
+        int subId = subInfo.getSubscriptionId();
+        // Verify the cache value is not same as the inserted one.
+        assertWithMessage("Subscription info cache value is not different.")
+                .that(mDatabaseManagerUT.getSubscriptionInfoInternal(subId)).isNotEqualTo(subInfo);
+
+        // Load subscription info from the database.
+        mDatabaseManagerUT.reloadDatabaseSync();
+        processAllMessages();
+
+        // Verify the database value is not same as the inserted one.
+        assertWithMessage("Subscription info database value is not different.")
+                .that(mDatabaseManagerUT.getSubscriptionInfoInternal(subId)).isNotEqualTo(subInfo);
+
+        verify(mSubscriptionDatabaseManagerCallback, never()).onSubscriptionChanged(eq(1));
+
+        assertThat(mDatabaseManagerUT.getSubscriptionProperty(
+                FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
+                SimInfo.COLUMN_IS_NTN)).isNotEqualTo(FAKE_SATELLITE_IS_NTN_ENABLED);
+
+        mDatabaseManagerUT.setSubscriptionProperty(FAKE_SUBSCRIPTION_INFO1.getSubscriptionId(),
+                SimInfo.COLUMN_IS_NTN, FAKE_SATELLITE_IS_NTN_ENABLED);
+        assertThat(mDatabaseManagerUT.getSubscriptionInfoInternal(
+                FAKE_SUBSCRIPTION_INFO1.getSubscriptionId()).getNtn())
+                .isNotEqualTo(FAKE_SATELLITE_IS_NTN_ENABLED);
+    }
+
+    @Test
     public void testUpdateSubscriptionsInGroup() throws Exception {
         insertSubscriptionAndVerify(FAKE_SUBSCRIPTION_INFO1);
         insertSubscriptionAndVerify(FAKE_SUBSCRIPTION_INFO2);
@@ -2074,7 +2159,8 @@
                     }
                 };
         assertThat(callback.getExecutor()).isEqualTo(executor);
-        mDatabaseManagerUT = new SubscriptionDatabaseManager(mContext, Looper.myLooper(), callback);
+        mDatabaseManagerUT = new SubscriptionDatabaseManager(mContext, Looper.myLooper(),
+                mFeatureFlags, callback);
         processAllMessages();
 
         assertThat(latch.getCount()).isEqualTo(1);
diff --git a/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionInfoInternalTest.java b/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionInfoInternalTest.java
index d1e3bb5..94bcca7 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionInfoInternalTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionInfoInternalTest.java
@@ -104,7 +104,9 @@
                     .setSatelliteAttachEnabledForCarrier(
                             SubscriptionDatabaseManagerTest
                                     .FAKE_SATELLITE_ATTACH_FOR_CARRIER_ENABLED)
+                    .setNtn(SubscriptionDatabaseManagerTest.FAKE_SATELLITE_IS_NTN_ENABLED)
                     .setGroupDisabled(false)
+                    .setNtn(1)
                     .build();
 
     private final SubscriptionInfoInternal mSubInfoNull =
@@ -217,7 +219,10 @@
         assertThat(mSubInfo.getSatelliteAttachEnabledForCarrier())
                 .isEqualTo(SubscriptionDatabaseManagerTest
                         .FAKE_SATELLITE_ATTACH_FOR_CARRIER_ENABLED);
+        assertThat(mSubInfo.getNtn()).isEqualTo(
+                SubscriptionDatabaseManagerTest.FAKE_SATELLITE_IS_NTN_ENABLED);
         assertThat(mSubInfo.isGroupDisabled()).isFalse();
+        assertThat(mSubInfo.getNtn()).isEqualTo(1);
     }
 
     @Test
@@ -280,6 +285,7 @@
         assertThat(subInfo.getPortIndex()).isEqualTo(
                 SubscriptionManager.USAGE_SETTING_DEFAULT);
         assertThat(subInfo.isGroupDisabled()).isFalse();
+        assertThat(subInfo.isNtn()).isTrue();
     }
 
     @Test