Reflect additional APIs in SatelliteManagerWrapper

Added test buttons for newly added apis

Bug: 322375389
Test: manually test application on pixel
Change-Id: Ibd637e3a2fb9309d7cef04bed1968ef4015af7d0
diff --git a/testapps/TestSatelliteApp/res/layout/activity_TestSatelliteWrapper.xml b/testapps/TestSatelliteApp/res/layout/activity_TestSatelliteWrapper.xml
index c136ce7..7f2f026 100644
--- a/testapps/TestSatelliteApp/res/layout/activity_TestSatelliteWrapper.xml
+++ b/testapps/TestSatelliteApp/res/layout/activity_TestSatelliteWrapper.xml
@@ -14,91 +14,157 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License
   -->
-
-<LinearLayout
+<ScrollView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical"
-    android:gravity="center"
-    android:paddingStart="4dp">
+    android:layout_height="match_parent">
 
-    <TextView
-        android:layout_width="wrap_content"
-        android:layout_height="0dp"
-        android:layout_weight="0"
-        android:textColor="@android:color/holo_blue_dark"
-        android:textSize="20dp"
-        android:text="Satellite Wrapper Test"/>
-    <Button
-        android:id="@+id/requestNtnSignalStrength"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingRight="4dp"
-        android:text="@string/requestNtnSignalStrength"/>
-    <Button
-        android:id="@+id/registerForNtnSignalStrengthChanged"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingRight="4dp"
-        android:text="@string/registerForNtnSignalStrengthChanged"/>
-    <Button
-        android:id="@+id/unregisterForNtnSignalStrengthChanged"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingRight="4dp"
-        android:text="@string/unregisterForNtnSignalStrengthChanged"/>
-    <Button
-        android:id="@+id/isOnlyNonTerrestrialNetworkSubscription"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingRight="4dp"
-        android:text="@string/isOnlyNonTerrestrialNetworkSubscription"/>
-    <Button
-        android:id="@+id/registerForSatelliteCapabilitiesChanged"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingRight="4dp"
-        android:text="@string/registerForSatelliteCapabilitiesChanged"/>
-    <Button
-        android:id="@+id/unregisterForSatelliteCapabilitiesChanged"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingRight="4dp"
-        android:text="@string/unregisterForSatelliteCapabilitiesChanged"/>
     <LinearLayout
+        xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:orientation="horizontal">
-         <Button
-            android:id="@+id/Back"
-            android:onClick="Back"
+        android:orientation="vertical"
+        android:gravity="center"
+        android:paddingStart="4dp">
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="0dp"
+            android:layout_weight="0"
             android:textColor="@android:color/holo_blue_dark"
-            android:layout_marginTop="10dp"
-            android:layout_marginBottom="10dp"
-            android:layout_width="0dp"
-            android:layout_height="wrap_content"
-            android:layout_weight="1"
-            android:paddingRight="4dp"
-            android:text="@string/Back"/>
+            android:textSize="20dp"
+            android:text="Satellite Wrapper Test"/>
         <Button
-            android:id="@+id/ClearLog"
-            android:onClick="ClearLog"
-            android:textColor="@android:color/holo_blue_dark"
-            android:layout_marginTop="10dp"
-            android:layout_marginBottom="10dp"
-            android:layout_width="0dp"
+            android:id="@+id/requestNtnSignalStrength"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_weight="1"
             android:paddingRight="4dp"
-            android:text="@string/ClearLog"/>
+            android:text="@string/requestNtnSignalStrength"/>
+        <Button
+            android:id="@+id/registerForNtnSignalStrengthChanged"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingRight="4dp"
+            android:text="@string/registerForNtnSignalStrengthChanged"/>
+        <Button
+            android:id="@+id/unregisterForNtnSignalStrengthChanged"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingRight="4dp"
+            android:text="@string/unregisterForNtnSignalStrengthChanged"/>
+        <Button
+            android:id="@+id/isOnlyNonTerrestrialNetworkSubscription"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingRight="4dp"
+            android:text="@string/isOnlyNonTerrestrialNetworkSubscription"/>
+        <Button
+            android:id="@+id/registerForSatelliteCapabilitiesChanged"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingRight="4dp"
+            android:text="@string/registerForSatelliteCapabilitiesChanged"/>
+        <Button
+            android:id="@+id/unregisterForSatelliteCapabilitiesChanged"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingRight="4dp"
+            android:text="@string/unregisterForSatelliteCapabilitiesChanged"/>
+        <Button
+            android:id="@+id/isNonTerrestrialNetwork"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingRight="4dp"
+            android:text="@string/isNonTerrestrialNetwork"/>
+        <Button
+            android:id="@+id/getAvailableServices"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingRight="4dp"
+            android:text="@string/getAvailableServices"/>
+        <Button
+            android:id="@+id/isUsingNonTerrestrialNetwork"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingRight="4dp"
+            android:text="@string/isUsingNonTerrestrialNetwork"/>
+        <Button
+            android:id="@+id/requestAttachEnabledForCarrier_enable"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingRight="4dp"
+            android:text="@string/requestAttachEnabledForCarrier_enable"/>
+        <Button
+            android:id="@+id/requestAttachEnabledForCarrier_disable"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingRight="4dp"
+            android:text="@string/requestAttachEnabledForCarrier_disable"/>
+        <Button
+            android:id="@+id/requestIsAttachEnabledForCarrier"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingRight="4dp"
+            android:text="@string/requestIsAttachEnabledForCarrier"/>
+        <Button
+            android:id="@+id/addAttachRestrictionForCarrier"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingRight="4dp"
+            android:text="@string/addAttachRestrictionForCarrier"/>
+        <Button
+            android:id="@+id/removeAttachRestrictionForCarrier"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingRight="4dp"
+            android:text="@string/removeAttachRestrictionForCarrier"/>
+        <Button
+            android:id="@+id/getAttachRestrictionReasonsForCarrier"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingRight="4dp"
+            android:text="@string/getAttachRestrictionReasonsForCarrier"/>
+        <Button
+            android:id="@+id/getSatellitePlmnsForCarrier"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingRight="4dp"
+            android:text="@string/getSatellitePlmnsForCarrier"/>
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal">
+             <Button
+                android:id="@+id/Back"
+                android:onClick="Back"
+                android:textColor="@android:color/holo_blue_dark"
+                android:layout_marginTop="10dp"
+                android:layout_marginBottom="10dp"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:paddingRight="4dp"
+                android:text="@string/Back"/>
+            <Button
+                android:id="@+id/ClearLog"
+                android:onClick="ClearLog"
+                android:textColor="@android:color/holo_blue_dark"
+                android:layout_marginTop="10dp"
+                android:layout_marginBottom="10dp"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:paddingRight="4dp"
+                android:text="@string/ClearLog"/>
+        </LinearLayout>
+        <ListView
+            android:id="@+id/logListView"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:capitalize="characters"
+            android:textColor="@android:color/holo_blue_light"
+            android:layout_centerVertical="true"
+            android:textSize="8dp" />
     </LinearLayout>
-    <ListView
-        android:id="@+id/logListView"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:capitalize="characters"
-        android:textColor="@android:color/holo_blue_light"
-        android:layout_centerVertical="true"
-        android:textSize="8dp" />
-</LinearLayout>
+
+</ScrollView>
\ No newline at end of file
diff --git a/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml b/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml
index 8ebe5f3..ecbe5df 100644
--- a/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml
+++ b/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml
@@ -64,6 +64,16 @@
     <string name="isOnlyNonTerrestrialNetworkSubscription">isOnlyNonTerrestrialNetworkSubscription</string>
     <string name="registerForSatelliteCapabilitiesChanged">registerForSatelliteCapabilitiesChanged</string>
     <string name="unregisterForSatelliteCapabilitiesChanged">unregisterForSatelliteCapabilitiesChanged</string>
+    <string name="isNonTerrestrialNetwork">isNonTerrestrialNetwork</string>
+    <string name="getAvailableServices">getAvailableServices</string>
+    <string name="isUsingNonTerrestrialNetwork">isUsingNonTerrestrialNetwork</string>
+    <string name="requestAttachEnabledForCarrier_enable">requestAttachEnabledForCarrier_enable</string>
+    <string name="requestAttachEnabledForCarrier_disable">requestAttachEnabledForCarrier_disable</string>
+    <string name="requestIsAttachEnabledForCarrier">requestIsAttachEnabledForCarrier</string>
+    <string name="addAttachRestrictionForCarrier">addAttachRestrictionForCarrier</string>
+    <string name="removeAttachRestrictionForCarrier">removeAttachRestrictionForCarrier</string>
+    <string name="getAttachRestrictionReasonsForCarrier">getAttachRestrictionReasonsForCarrier</string>
+    <string name="getSatellitePlmnsForCarrier">getSatellitePlmnsForCarrier</string>
 
     <string name="Back">Back</string>
     <string name="ClearLog">Clear Log</string>
diff --git a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteWrapper.java b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteWrapper.java
index e4c2005..4f0679d 100644
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteWrapper.java
+++ b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteWrapper.java
@@ -36,8 +36,10 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.function.Consumer;
 import java.util.stream.Collectors;
 
 /**
@@ -53,6 +55,7 @@
     private NtnSignalStrengthCallback mNtnSignalStrengthCallback = null;
     private SatelliteCapabilitiesCallbackWrapper mSatelliteCapabilitiesCallback;
     private SubscriptionManager mSubscriptionManager;
+    private int mSubId;
 
     private ListView mLogListView;
 
@@ -61,6 +64,7 @@
         super.onCreate(savedInstanceState);
         mSatelliteManagerWrapper = SatelliteManagerWrapper.getInstance(this);
         mSubscriptionManager = getSystemService(SubscriptionManager.class);
+        mSubId = getActiveSubId();
 
         setContentView(R.layout.activity_TestSatelliteWrapper);
         findViewById(R.id.requestNtnSignalStrength)
@@ -75,6 +79,26 @@
                 .setOnClickListener(this::registerForCapabilitiesChanged);
         findViewById(R.id.unregisterForSatelliteCapabilitiesChanged)
                 .setOnClickListener(this::unregisterForCapabilitiesChanged);
+        findViewById(R.id.isNonTerrestrialNetwork)
+                .setOnClickListener(this::isNonTerrestrialNetwork);
+        findViewById(R.id.getAvailableServices)
+                .setOnClickListener(this::getAvailableServices);
+        findViewById(R.id.isUsingNonTerrestrialNetwork)
+                .setOnClickListener(this::isUsingNonTerrestrialNetwork);
+        findViewById(R.id.requestAttachEnabledForCarrier_enable)
+                .setOnClickListener(this::requestAttachEnabledForCarrier_enable);
+        findViewById(R.id.requestAttachEnabledForCarrier_disable)
+                .setOnClickListener(this::requestAttachEnabledForCarrier_disable);
+        findViewById(R.id.requestIsAttachEnabledForCarrier)
+                .setOnClickListener(this::requestIsAttachEnabledForCarrier);
+        findViewById(R.id.addAttachRestrictionForCarrier)
+                .setOnClickListener(this::addAttachRestrictionForCarrier);
+        findViewById(R.id.removeAttachRestrictionForCarrier)
+                .setOnClickListener(this::removeAttachRestrictionForCarrier);
+        findViewById(R.id.getAttachRestrictionReasonsForCarrier)
+                .setOnClickListener(this::getAttachRestrictionReasonsForCarrier);
+        findViewById(R.id.getSatellitePlmnsForCarrier)
+                .setOnClickListener(this::getSatellitePlmnsForCarrier);
         findViewById(R.id.Back).setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View view) {
@@ -107,21 +131,24 @@
 
         if (mSatelliteManagerWrapper != null) {
             if (mNtnSignalStrengthCallback != null) {
-                Log.d(TAG, "unregisterForNtnSignalStrengthChanged()");
+                logd("unregisterForNtnSignalStrengthChanged()");
                 mSatelliteManagerWrapper.unregisterForNtnSignalStrengthChanged(
                         mNtnSignalStrengthCallback);
             }
             if (mSatelliteCapabilitiesCallback != null) {
-                Log.d(TAG, "unregisterForCapabilitiesChanged()");
+                logd("unregisterForCapabilitiesChanged()");
                 mSatelliteManagerWrapper.unregisterForCapabilitiesChanged(
                         mSatelliteCapabilitiesCallback);
             }
         }
+        mSubscriptionManager = null;
+        mSatelliteManagerWrapper = null;
+        mExecutor.shutdown();
     }
 
     private void requestNtnSignalStrength(View view) {
         addLogMessage("requestNtnSignalStrength");
-        Log.d(TAG, "requestNtnSignalStrength");
+        logd("requestNtnSignalStrength");
         OutcomeReceiver<NtnSignalStrengthWrapper,
                 SatelliteManagerWrapper.SatelliteExceptionWrapper> receiver =
                 new OutcomeReceiver<>() {
@@ -138,7 +165,7 @@
                         if (exception != null) {
                             String onError = "requestNtnSignalStrength exception: "
                                     + translateResultCodeToString(exception.getErrorCode());
-                            Log.d(TAG, onError);
+                            logd(onError);
                             addLogMessage(onError);
                         }
                     }
@@ -148,16 +175,16 @@
             mSatelliteManagerWrapper.requestNtnSignalStrength(mExecutor, receiver);
         } catch (SecurityException ex) {
             String errorMessage = "requestNtnSignalStrength: " + ex.getMessage();
-            Log.d(TAG, errorMessage);
+            logd(errorMessage);
             addLogMessage(errorMessage);
         }
     }
 
     private void registerForNtnSignalStrengthChanged(View view) {
         addLogMessage("registerForNtnSignalStrengthChanged");
-        Log.d(TAG, "registerForNtnSignalStrengthChanged()");
+        logd("registerForNtnSignalStrengthChanged()");
         if (mNtnSignalStrengthCallback == null) {
-            Log.d(TAG, "create new NtnSignalStrengthCallback instance.");
+            logd("create new NtnSignalStrengthCallback instance.");
             mNtnSignalStrengthCallback = new NtnSignalStrengthCallback();
         }
 
@@ -166,7 +193,7 @@
                     mNtnSignalStrengthCallback);
         } catch (Exception ex) {
             String errorMessage = "registerForNtnSignalStrengthChanged: " + ex.getMessage();
-            Log.d(TAG, errorMessage);
+            logd(errorMessage);
             addLogMessage(errorMessage);
             mNtnSignalStrengthCallback = null;
         }
@@ -174,7 +201,7 @@
 
     private void unregisterForNtnSignalStrengthChanged(View view) {
         addLogMessage("unregisterForNtnSignalStrengthChanged");
-        Log.d(TAG, "unregisterForNtnSignalStrengthChanged()");
+        logd("unregisterForNtnSignalStrengthChanged()");
         if (mNtnSignalStrengthCallback != null) {
             mSatelliteManagerWrapper.unregisterForNtnSignalStrengthChanged(
                     mNtnSignalStrengthCallback);
@@ -187,7 +214,7 @@
 
     private void isOnlyNonTerrestrialNetworkSubscription(View view) {
         addLogMessage("isOnlyNonTerrestrialNetworkSubscription");
-        Log.d(TAG, "isOnlyNonTerrestrialNetworkSubscription()");
+        logd("isOnlyNonTerrestrialNetworkSubscription()");
         List<SubscriptionInfo> infoList = mSubscriptionManager.getAvailableSubscriptionInfoList();
         List<Integer> subIdList = infoList.stream()
                 .map(SubscriptionInfo::getSubscriptionId)
@@ -214,13 +241,13 @@
 
     private void registerForCapabilitiesChanged(View view) {
         addLogMessage("registerForCapabilitiesChanged");
-        Log.d(TAG, "registerForCapabilitiesChanged()");
+        logd("registerForCapabilitiesChanged()");
         if (mSatelliteCapabilitiesCallback == null) {
             mSatelliteCapabilitiesCallback =
                     SatelliteCapabilities -> {
                         String message = "Received SatelliteCapabillities : "
                                 + SatelliteCapabilities;
-                        Log.d(TAG, message);
+                        logd(message);
                         runOnUiThread(() -> addLogMessage(message));
                     };
         }
@@ -229,7 +256,7 @@
                 mSatelliteCapabilitiesCallback);
         if (result != SatelliteManagerWrapper.SATELLITE_RESULT_SUCCESS) {
             String onError = translateResultCodeToString(result);
-            Log.d(TAG, onError);
+            logd(onError);
             addLogMessage(onError);
             mSatelliteCapabilitiesCallback = null;
         }
@@ -237,7 +264,7 @@
 
     private void unregisterForCapabilitiesChanged(View view) {
         addLogMessage("unregisterForCapabilitiesChanged");
-        Log.d(TAG, "unregisterForCapabilitiesChanged()");
+        logd("unregisterForCapabilitiesChanged()");
         if (mSatelliteCapabilitiesCallback != null) {
             mSatelliteManagerWrapper.unregisterForCapabilitiesChanged(
                     mSatelliteCapabilitiesCallback);
@@ -253,11 +280,238 @@
         public void onNtnSignalStrengthChanged(
                 @NonNull NtnSignalStrengthWrapper ntnSignalStrength) {
             String message = "Received NTN SignalStrength : " + ntnSignalStrength.getLevel();
-            Log.d(TAG, message);
+            logd(message);
             runOnUiThread(() -> addLogMessage(message));
         }
     }
 
+    private void isNonTerrestrialNetwork(View view) {
+        boolean isNonTerrestrialNetwork = mSatelliteManagerWrapper.isNonTerrestrialNetwork(mSubId);
+        addLogMessage("isNonTerrestrialNetwork=" + isNonTerrestrialNetwork);
+        logd("isNonTerrestrialNetwork=" + isNonTerrestrialNetwork);
+    }
+
+    private void getAvailableServices(View view) {
+        List<Integer> as = mSatelliteManagerWrapper.getAvailableServices(mSubId);
+        String availableServices = as.stream().map(Object::toString).collect(
+                Collectors.joining(", "));
+        addLogMessage("getAvailableServices=" + availableServices);
+        logd("getAvailableServices=" + availableServices);
+    }
+
+    private void isUsingNonTerrestrialNetwork(View view) {
+        boolean isUsingNonTerrestrialNetwork =
+                mSatelliteManagerWrapper.isUsingNonTerrestrialNetwork(mSubId);
+        addLogMessage("isUsingNonTerrestrialNetwork=" + isUsingNonTerrestrialNetwork);
+        logd("isUsingNonTerrestrialNetwork=" + isUsingNonTerrestrialNetwork);
+    }
+
+    private void requestAttachEnabledForCarrier_enable(View view) {
+        addLogMessage("requestAttachEnabledForCarrier");
+        logd("requestAttachEnabledForCarrier");
+
+        if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+            addLogMessage("requestAttachEnabledForCarrier: Subscription ID is invalid");
+            logd("requestAttachEnabledForCarrier: Subscription ID is invalid");
+            return;
+        }
+
+        Consumer<Integer> callback = result -> {
+            runOnUiThread(() -> addLogMessage("requestAttachEnabledForCarrier result: " + result));
+            logd("requestAttachEnabledForCarrier result: " + result);
+        };
+
+        try {
+            mSatelliteManagerWrapper.requestAttachEnabledForCarrier(mSubId, true, mExecutor,
+                    callback);
+        } catch (SecurityException | IllegalArgumentException ex) {
+            String errorMessage = "requestAttachEnabledForCarrier: " + ex.getMessage();
+            logd(errorMessage);
+            addLogMessage(errorMessage);
+        }
+    }
+
+    private void requestAttachEnabledForCarrier_disable(View view) {
+        addLogMessage("requestAttachEnabledForCarrier");
+        logd("requestAttachEnabledForCarrier");
+
+        if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+            addLogMessage("requestAttachEnabledForCarrier: Subscription ID is invalid");
+            logd("requestAttachEnabledForCarrier: Subscription ID is invalid");
+            return;
+        }
+
+        Consumer<Integer> callback = result -> {
+            runOnUiThread(() -> addLogMessage("requestAttachEnabledForCarrier result: " + result));
+            logd("requestAttachEnabledForCarrier result: " + result);
+        };
+
+        try {
+            mSatelliteManagerWrapper.requestAttachEnabledForCarrier(mSubId, false, mExecutor,
+                    callback);
+        } catch (SecurityException | IllegalArgumentException ex) {
+            String errorMessage = "requestAttachEnabledForCarrier: " + ex.getMessage();
+            logd(errorMessage);
+            addLogMessage(errorMessage);
+        }
+    }
+
+    private void requestIsAttachEnabledForCarrier(View view) {
+        logd("requestIsAttachEnabledForCarrier");
+        addLogMessage("requestIsAttachEnabledForCarrier");
+
+        if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+            addLogMessage("requestIsAttachEnabledForCarrier: Subscription ID is invalid");
+            logd("requestIsAttachEnabledForCarrier: Subscription ID is invalid");
+            return;
+        }
+
+        OutcomeReceiver<Boolean,
+                SatelliteManagerWrapper.SatelliteExceptionWrapper> receiver =
+                new OutcomeReceiver<>() {
+                    @Override
+                    public void onResult(Boolean result) {
+                        logd("requestIsAttachEnabledForCarrier: onResult=" + result);
+                        addLogMessage("requestIsAttachEnabledForCarrier: onResult=" + result);
+                    }
+
+                    @Override
+                    public void onError(
+                            SatelliteManagerWrapper.SatelliteExceptionWrapper exception) {
+                        if (exception != null) {
+                            String onError = "requestIsAttachEnabledForCarrier exception: "
+                                    + translateResultCodeToString(exception.getErrorCode());
+                            logd(onError);
+                            addLogMessage(onError);
+                        }
+                    }
+                };
+
+        try {
+            mSatelliteManagerWrapper.requestIsAttachEnabledForCarrier(mSubId, mExecutor, receiver);
+        } catch (SecurityException | IllegalStateException | IllegalArgumentException ex) {
+            String errorMessage = "requestIsAttachEnabledForCarrier: " + ex.getMessage();
+            logd(errorMessage);
+            addLogMessage(errorMessage);
+        }
+    }
+
+    private void addAttachRestrictionForCarrier(View view) {
+        addLogMessage("addAttachRestrictionForCarrier");
+        logd("addAttachRestrictionForCarrier");
+
+        if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+            addLogMessage("addAttachRestrictionForCarrier: Subscription ID is invalid");
+            logd("addAttachRestrictionForCarrier: Subscription ID is invalid");
+            return;
+        }
+
+        int reason = SatelliteManagerWrapper.SATELLITE_COMMUNICATION_RESTRICTION_REASON_USER;
+
+        Consumer<Integer> callback = result -> {
+            runOnUiThread(() -> addLogMessage("addAttachRestrictionForCarrier result: " + result));
+            logd("addAttachRestrictionForCarrier result: " + result);
+        };
+
+        try {
+            mSatelliteManagerWrapper.addAttachRestrictionForCarrier(mSubId, reason, mExecutor,
+                    callback);
+        } catch (SecurityException | IllegalArgumentException ex) {
+            String errorMessage = "addAttachRestrictionForCarrier: " + ex.getMessage();
+            logd(errorMessage);
+            addLogMessage(errorMessage);
+        }
+    }
+
+    private void removeAttachRestrictionForCarrier(View view) {
+        addLogMessage("removeAttachRestrictionForCarrier");
+        logd("removeAttachRestrictionForCarrier");
+
+        if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+            addLogMessage("removeAttachRestrictionForCarrier: Subscription ID is invalid");
+            logd("removeAttachRestrictionForCarrier: Subscription ID is invalid");
+            return;
+        }
+
+        int reason = SatelliteManagerWrapper.SATELLITE_COMMUNICATION_RESTRICTION_REASON_USER;
+
+        Consumer<Integer> callback = result -> {
+            runOnUiThread(
+                    () -> addLogMessage("removeAttachRestrictionForCarrier result: " + result));
+            logd("removeAttachRestrictionForCarrier result: " + result);
+        };
+
+        try {
+            mSatelliteManagerWrapper.removeAttachRestrictionForCarrier(mSubId, reason, mExecutor,
+                    callback);
+        } catch (SecurityException | IllegalArgumentException ex) {
+            String errorMessage = "removeAttachRestrictionForCarrier: " + ex.getMessage();
+            logd(errorMessage);
+            addLogMessage(errorMessage);
+        }
+    }
+
+    private void getAttachRestrictionReasonsForCarrier(View view) {
+        addLogMessage("getAttachRestrictionReasonsForCarrier");
+        logd("getAttachRestrictionReasonsForCarrier");
+
+        if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+            addLogMessage("getAttachRestrictionReasonsForCarrier: Subscription ID is invalid");
+            logd("getAttachRestrictionReasonsForCarrier: Subscription ID is invalid");
+            return;
+        }
+
+        try {
+            Set<Integer> reasons = mSatelliteManagerWrapper.getAttachRestrictionReasonsForCarrier(
+                    mSubId);
+            String stringReasons = reasons.stream().map(Object::toString).collect(
+                    Collectors.joining(", "));
+            logd("getAttachRestrictionReasonsForCarrier=" + stringReasons);
+            addLogMessage("getAttachRestrictionReasonsForCarrier=" + stringReasons);
+        } catch (SecurityException | IllegalArgumentException ex) {
+            String errorMessage = "getAttachRestrictionReasonsForCarrier: " + ex.getMessage();
+            logd(errorMessage);
+            addLogMessage(errorMessage);
+        }
+    }
+
+    private void getSatellitePlmnsForCarrier(View view) {
+        addLogMessage("getSatellitePlmnsForCarrier");
+        logd("getSatellitePlmnsForCarrier");
+
+        if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+            addLogMessage("getSatellitePlmnsForCarrier: Subscription ID is invalid");
+            logd("getSatellitePlmnsForCarrier: Subscription ID is invalid");
+            return;
+        }
+
+        try {
+            List<String> reasons = mSatelliteManagerWrapper.getSatellitePlmnsForCarrier(
+                    mSubId);
+            String stringReasons = reasons.stream().collect(Collectors.joining(", "));
+            logd("getSatellitePlmnsForCarrier=" + stringReasons);
+            addLogMessage("getSatellitePlmnsForCarrier=" + stringReasons);
+        } catch (SecurityException | IllegalArgumentException ex) {
+            String errorMessage = "getSatellitePlmnsForCarrier: " + ex.getMessage();
+            logd(errorMessage);
+            addLogMessage(errorMessage);
+        }
+    }
+
+    private int getActiveSubId() {
+        int subId;
+        List<SubscriptionInfo> subscriptionInfoList =
+                mSubscriptionManager.getActiveSubscriptionInfoList();
+
+        if (subscriptionInfoList != null && subscriptionInfoList.size() > 0) {
+            subId = subscriptionInfoList.get(0).getSubscriptionId();
+        } else {
+            subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+        }
+        logd("getActiveSubId() returns " + subId);
+        return subId;
+    }
+
     private String translateResultCodeToString(
             @SatelliteManagerWrapper.SatelliteResult int result) {
         switch (result) {
@@ -319,4 +573,10 @@
         mAdapter.notifyDataSetChanged();
         mLogListView.setSelection(mAdapter.getCount() - 1);
     }
+
+    private static void logd(String message) {
+        if (message != null) {
+            Log.d(TAG, message);
+        }
+    }
 }