Add setNtnSmsSupported API in SatelliteManager.
Bug: 378145870
Test: make
Test: Manually tested SMS/MMS/CALLS/DATA
Test: Manually tested using test satellite app
FLAG: com.android.internal.telephony.flags.carrier_roaming_nb_iot_ntn
Change-Id: I985eadf4ee1d653053ad0c4471fd9d11a402a6ac
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 536c88a..85c0b04 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -14727,6 +14727,24 @@
}
}
+
+ /**
+ * Inform whether application supports NTN SMS in satellite mode.
+ *
+ * This method is used by default messaging application to inform framework whether it supports
+ * NTN SMS or not.
+ *
+ * @param ntnSmsSupported {@code true} If application supports NTN SMS, else {@code false}.
+ *
+ * @throws SecurityException if the caller doesn't have required permission.
+ */
+ @Override
+ public void setNtnSmsSupported(boolean ntnSmsSupported) {
+ enforceSatelliteCommunicationPermission("setNtnSmsSupported");
+ enforceSendSmsPermission();
+ mSatelliteController.setNtnSmsSupportedByMessagesApp(ntnSmsSupported);
+ }
+
/**
* This API can be used by only CTS to override the cached value for the device overlay config
* value :
diff --git a/testapps/TestSatelliteApp/AndroidManifest.xml b/testapps/TestSatelliteApp/AndroidManifest.xml
index eaddf95..a1f22fa 100644
--- a/testapps/TestSatelliteApp/AndroidManifest.xml
+++ b/testapps/TestSatelliteApp/AndroidManifest.xml
@@ -20,6 +20,7 @@
<uses-permission android:name="android.permission.BIND_SATELLITE_SERVICE"/>
<uses-permission android:name="android.permission.SATELLITE_COMMUNICATION"/>
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>
+ <uses-permission android:name="android.permission.SEND_SMS"/>
<application android:label="SatelliteTestApp">
<activity android:name=".SatelliteTestApp"
android:label="SatelliteTestApp"
diff --git a/testapps/TestSatelliteApp/res/layout/activity_TestSatelliteWrapper.xml b/testapps/TestSatelliteApp/res/layout/activity_TestSatelliteWrapper.xml
index 9aec52b..d046f03 100644
--- a/testapps/TestSatelliteApp/res/layout/activity_TestSatelliteWrapper.xml
+++ b/testapps/TestSatelliteApp/res/layout/activity_TestSatelliteWrapper.xml
@@ -191,6 +191,19 @@
android:layout_height="wrap_content"
android:paddingRight="4dp"
android:text="@string/deprovisionSatellite"/>
+ <Button
+ android:id="@+id/setNtnSmsSupportedTrue"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/setNtnSmsSupportedTrue"/>
+ <Button
+ android:id="@+id/setNtnSmsSupportedFalse"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/setNtnSmsSupportedFalse"/>
+
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml b/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml
index 54f2722..4b5ea5b 100644
--- a/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml
+++ b/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml
@@ -97,6 +97,9 @@
<string name="requestSatelliteSubscriberProvisionStatus">requestSatelliteSubscriberProvisionStatus</string>
<string name="provisionSatellite">provisionSatellite</string>
<string name="deprovisionSatellite">deprovisionSatellite</string>
+ <string name="setNtnSmsSupportedTrue">setNtnSmsSupportedTrue</string>
+ <string name="setNtnSmsSupportedFalse">setNtnSmsSupportedFalse</string>
+
<string name="Back">Back</string>
<string name="ClearLog">Clear Log</string>
diff --git a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteTestApp.java b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteTestApp.java
index 7c4ae00..cb56e87 100644
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteTestApp.java
+++ b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteTestApp.java
@@ -16,11 +16,13 @@
package com.android.phone.testapps.satellitetestapp;
+import android.Manifest;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.IBinder;
import android.telephony.satellite.stub.SatelliteDatagram;
@@ -42,6 +44,7 @@
private TestSatelliteServiceConnection mSatelliteServiceConn;
private List<SatelliteDatagram> mSentSatelliteDatagrams = new ArrayList<>();
+ private static final int REQUEST_CODE_SEND_SMS = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -105,6 +108,16 @@
});
}
+ @Override
+ protected void onResume() {
+ super.onResume();
+ if (checkSelfPermission(Manifest.permission.SEND_SMS)
+ != PackageManager.PERMISSION_GRANTED) {
+ requestPermissions(new String[]{Manifest.permission.SEND_SMS}, REQUEST_CODE_SEND_SMS);
+ }
+ }
+
+
private final ILocalSatelliteListener mSatelliteListener =
new ILocalSatelliteListener.Stub() {
@Override
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 97cb9c3..7d5e9af 100644
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteWrapper.java
+++ b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteWrapper.java
@@ -127,6 +127,11 @@
.setOnClickListener(this::provisionSatellite);
findViewById(R.id.deprovisionSatelliteWrapper)
.setOnClickListener(this::deprovisionSatellite);
+ findViewById(R.id.setNtnSmsSupportedTrue)
+ .setOnClickListener(this::setNtnSmsSupportedTrue);
+ findViewById(R.id.setNtnSmsSupportedFalse)
+ .setOnClickListener(this::setNtnSmsSupportedFalse);
+
findViewById(R.id.Back).setOnClickListener(new OnClickListener() {
@Override
@@ -799,6 +804,31 @@
}
}
+ private void setNtnSmsSupportedTrue(View view) {
+ setNtnSmsSupported(true);
+ }
+
+ private void setNtnSmsSupportedFalse(View view) {
+ setNtnSmsSupported(false);
+ }
+
+ private void setNtnSmsSupported(boolean ntnSmsSupported) {
+ String msg = "setNtnSmsSupported:" + ntnSmsSupported;
+ addLogMessage(msg);
+ logd(msg);
+
+ try {
+ mSatelliteManagerWrapper.setNtnSmsSupported(ntnSmsSupported);
+ msg = "setNtnSmsSupported=" + ntnSmsSupported + " is successful";
+ logd(msg);
+ addLogMessage(msg);
+ } catch (SecurityException | IllegalStateException ex) {
+ msg = "setNtnSmsSupported=" + ntnSmsSupported + " failed. " + ex.getMessage();
+ logd(msg);
+ addLogMessage(msg);
+ }
+ }
+
private int getActiveSubId() {
int subId;
List<SubscriptionInfo> subscriptionInfoList =