Show various states for Satellite TestApp
UI to check the current corresponding states for modem and provision.
Bug: 287566047
Test: mm
Change-Id: I14dd1cab78c06a435ad78e1215e648576a351d0e
diff --git a/testapps/TestSatelliteApp/AndroidManifest.xml b/testapps/TestSatelliteApp/AndroidManifest.xml
index 278d102..40954b4 100644
--- a/testapps/TestSatelliteApp/AndroidManifest.xml
+++ b/testapps/TestSatelliteApp/AndroidManifest.xml
@@ -41,9 +41,8 @@
</service>
<activity android:name=".SatelliteControl" />
- <activity android:name=".SatelliteTransmissionUpdates" />
<activity android:name=".Datagram" />
<activity android:name=".Provisioning" />
- <activity android:name=".SatelliteModemState" />
+ <activity android:name=".MultipleSendReceive" />
</application>
</manifest>
diff --git a/testapps/TestSatelliteApp/res/layout/activity_Datagram.xml b/testapps/TestSatelliteApp/res/layout/activity_Datagram.xml
index 5cfe7d9..cf1265d 100644
--- a/testapps/TestSatelliteApp/res/layout/activity_Datagram.xml
+++ b/testapps/TestSatelliteApp/res/layout/activity_Datagram.xml
@@ -27,44 +27,38 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
-
<TextView
android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:layout_weight="0"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
android:textColor="@android:color/holo_blue_dark"
android:textSize="20dp"
android:text="Datagram APIs"/>
<Button
+ android:id="@+id/startSatelliteTransmissionUpdates"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/startSatelliteTransmissionUpdates"/>
+ <Button
+ android:id="@+id/stopSatelliteTransmissionUpdates"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/stopSatelliteTransmissionUpdates"/>
+ <Button
android:id="@+id/pollPendingSatelliteDatagrams"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingRight="4dp"
android:text="@string/pollPendingSatelliteDatagrams"/>
<Button
- android:id="@+id/multiplePollPendingSatelliteDatagrams"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingRight="4dp"
- android:text="@string/multiplePollPendingSatelliteDatagrams"/>
- <Button
android:id="@+id/sendSatelliteDatagram"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingRight="4dp"
android:text="@string/sendSatelliteDatagram"/>
<Button
- android:id="@+id/multipleSendSatelliteDatagram"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingRight="4dp"
- android:text="@string/multipleSendSatelliteDatagram"/>
- <Button
- android:id="@+id/multipleSendReceiveSatelliteDatagram"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingRight="4dp"
- android:text="@string/multipleSendReceiveSatelliteDatagram"/>
- <Button
android:id="@+id/registerForSatelliteDatagram"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -77,6 +71,36 @@
android:paddingRight="4dp"
android:text="@string/unregisterForSatelliteDatagram"/>
<Button
+ android:id="@+id/showDatagramSendStateTransition"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/showDatagramSendStateTransition"/>
+ <Button
+ android:id="@+id/showDatagramReceiveStateTransition"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/showDatagramReceiveStateTransition"/>
+ <Button
+ android:id="@+id/registerForSatelliteModemStateChanged"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/registerForSatelliteModemStateChanged"/>
+ <Button
+ android:id="@+id/unregisterForSatelliteModemStateChanged"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/unregisterForSatelliteModemStateChanged"/>
+ <Button
+ android:id="@+id/showSatelliteModemStateTransition"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/showSatelliteModemStateTransition"/>
+ <Button
android:id="@+id/Back"
android:onClick="Back"
android:textColor="@android:color/holo_blue_dark"
@@ -88,11 +112,10 @@
android:text="@string/Back"/>
<TextView
android:id="@+id/text_id"
- android:layout_width="300dp"
- android:layout_height="200dp"
+ android:layout_width="400dp"
+ android:layout_height="50dp"
android:capitalize="characters"
android:textColor="@android:color/holo_blue_light"
- android:layout_centerVertical="true"
android:textSize="15dp" />
</LinearLayout>
</LinearLayout>
diff --git a/testapps/TestSatelliteApp/res/layout/activity_MultipleSendReceive.xml b/testapps/TestSatelliteApp/res/layout/activity_MultipleSendReceive.xml
new file mode 100644
index 0000000..3632ecb
--- /dev/null
+++ b/testapps/TestSatelliteApp/res/layout/activity_MultipleSendReceive.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<LinearLayout
+ 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:paddingLeft="4dp">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
+ android:textColor="@android:color/holo_blue_dark"
+ android:textSize="20dp"
+ android:text="Multiple Send and Receive APIs"/>
+ <Button
+ android:id="@+id/multiplePollPendingSatelliteDatagrams"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/multiplePollPendingSatelliteDatagrams"/>
+ <Button
+ android:id="@+id/multipleSendSatelliteDatagram"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/multipleSendSatelliteDatagram"/>
+ <Button
+ android:id="@+id/multipleSendReceiveSatelliteDatagram"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/multipleSendReceiveSatelliteDatagram"/>
+ <Button
+ android:id="@+id/Back"
+ android:onClick="Back"
+ android:textColor="@android:color/holo_blue_dark"
+ android:layout_marginTop="100dp"
+ android:layout_gravity="center"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/Back"/>
+ <TextView
+ android:id="@+id/text_id"
+ android:layout_width="400dp"
+ android:layout_height="50dp"
+ android:capitalize="characters"
+ android:textColor="@android:color/holo_blue_light"
+ android:textSize="15dp" />
+ <TextView
+ android:id="@+id/text_id1"
+ android:layout_width="400dp"
+ android:layout_height="65dp"
+ android:capitalize="characters"
+ android:textColor="@android:color/holo_blue_light"
+ android:layout_centerVertical="true"
+ android:textSize="15dp" />
+ <TextView
+ android:id="@+id/text_id2"
+ android:layout_width="400dp"
+ android:layout_height="65dp"
+ android:capitalize="characters"
+ android:textColor="@android:color/holo_blue_light"
+ android:layout_centerVertical="true"
+ android:textSize="15dp" />
+ <TextView
+ android:id="@+id/text_id3"
+ android:layout_width="400dp"
+ android:layout_height="65dp"
+ android:capitalize="characters"
+ android:textColor="@android:color/holo_blue_light"
+ android:layout_centerVertical="true"
+ android:textSize="15dp" />
+ </LinearLayout>
+</LinearLayout>
diff --git a/testapps/TestSatelliteApp/res/layout/activity_Provisioning.xml b/testapps/TestSatelliteApp/res/layout/activity_Provisioning.xml
index c62aebf..da5105d 100644
--- a/testapps/TestSatelliteApp/res/layout/activity_Provisioning.xml
+++ b/testapps/TestSatelliteApp/res/layout/activity_Provisioning.xml
@@ -30,7 +30,8 @@
<TextView
android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:layout_weight="0"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
android:textColor="@android:color/holo_blue_dark"
android:textSize="20dp"
android:text="Provisioning APIs"/>
@@ -65,6 +66,12 @@
android:paddingRight="4dp"
android:text="@string/unregisterForSatelliteProvisionStateChanged"/>
<Button
+ android:id="@+id/showCurrentSatelliteProvisionState"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/showCurrentSatelliteProvisionState"/>
+ <Button
android:id="@+id/Back"
android:onClick="Back"
android:textColor="@android:color/holo_blue_dark"
diff --git a/testapps/TestSatelliteApp/res/layout/activity_SatelliteControl.xml b/testapps/TestSatelliteApp/res/layout/activity_SatelliteControl.xml
index 1484ba7..40e3c69 100644
--- a/testapps/TestSatelliteApp/res/layout/activity_SatelliteControl.xml
+++ b/testapps/TestSatelliteApp/res/layout/activity_SatelliteControl.xml
@@ -30,16 +30,23 @@
<TextView
android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:layout_weight="0"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
android:textColor="@android:color/holo_blue_dark"
android:textSize="20dp"
android:text="Satellite Control APIs"/>
<Button
- android:id="@+id/requestSatelliteEnabled"
+ android:id="@+id/enableSatellite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingRight="4dp"
- android:text="@string/requestSatelliteEnabled"/>
+ android:text="@string/enableSatellite"/>
+ <Button
+ android:id="@+id/disableSatellite"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/disableSatellite"/>
<Button
android:id="@+id/requestIsSatelliteEnabled"
android:layout_width="match_parent"
diff --git a/testapps/TestSatelliteApp/res/layout/activity_SatelliteModemState.xml b/testapps/TestSatelliteApp/res/layout/activity_SatelliteModemState.xml
deleted file mode 100644
index 5e70ef3..0000000
--- a/testapps/TestSatelliteApp/res/layout/activity_SatelliteModemState.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2023 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-
-<LinearLayout
- 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:paddingLeft="4dp">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:layout_weight="0"
- android:textColor="@android:color/holo_blue_dark"
- android:textSize="20dp"
- android:text="SatelliteModemState APIs"/>
- <Button
- android:id="@+id/registerForSatelliteModemStateChanged"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingRight="4dp"
- android:text="@string/registerForSatelliteModemStateChanged"/>
- <Button
- android:id="@+id/unregisterForSatelliteModemStateChanged"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingRight="4dp"
- android:text="@string/unregisterForSatelliteModemStateChanged"/>
- <Button
- android:id="@+id/Back"
- android:onClick="Back"
- android:textColor="@android:color/holo_blue_dark"
- android:layout_marginTop="100dp"
- android:layout_gravity="center"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingRight="4dp"
- android:text="@string/Back"/>
- <TextView
- android:id="@+id/text_id"
- android:layout_width="300dp"
- android:layout_height="200dp"
- android:capitalize="characters"
- android:textColor="@android:color/holo_blue_light"
- android:layout_centerVertical="true"
- android:textSize="15dp" />
- </LinearLayout>
-</LinearLayout>
-
diff --git a/testapps/TestSatelliteApp/res/layout/activity_SatelliteTestApp.xml b/testapps/TestSatelliteApp/res/layout/activity_SatelliteTestApp.xml
index f9a0809..2ed4a24 100644
--- a/testapps/TestSatelliteApp/res/layout/activity_SatelliteTestApp.xml
+++ b/testapps/TestSatelliteApp/res/layout/activity_SatelliteTestApp.xml
@@ -29,7 +29,8 @@
<TextView
android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:layout_weight="0"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
android:textColor="@android:color/holo_blue_dark"
android:textSize="20dp"
android:text="Available Satellite APIs"/>
@@ -40,12 +41,6 @@
android:paddingRight="4dp"
android:text="@string/SatelliteControl"/>
<Button
- android:id="@+id/SatelliteTransmissionUpdates"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingRight="4dp"
- android:text="@string/SatelliteTransmissionUpdates"/>
- <Button
android:id="@+id/Datagram"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -58,7 +53,7 @@
android:paddingRight="4dp"
android:text="@string/Provisioning"/>
<Button
- android:id="@+id/SatelliteModemState"
+ android:id="@+id/MultipleSendReceive"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingRight="4dp"
diff --git a/testapps/TestSatelliteApp/res/layout/activity_SatelliteTransmissionUpdates.xml b/testapps/TestSatelliteApp/res/layout/activity_SatelliteTransmissionUpdates.xml
deleted file mode 100644
index 4eb3851..0000000
--- a/testapps/TestSatelliteApp/res/layout/activity_SatelliteTransmissionUpdates.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2023 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-
-<LinearLayout
- 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:paddingLeft="4dp">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:layout_weight="0"
- android:textColor="@android:color/holo_blue_dark"
- android:textSize="20dp"
- android:text="SatelliteTransmissionUpdates APIs"/>
- <Button
- android:id="@+id/startSatelliteTransmissionUpdates"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingRight="4dp"
- android:text="@string/startSatelliteTransmissionUpdates"/>
- <Button
- android:id="@+id/stopSatelliteTransmissionUpdates"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingRight="4dp"
- android:text="@string/stopSatelliteTransmissionUpdates"/>
- <Button
- android:id="@+id/Back"
- android:onClick="Back"
- android:textColor="@android:color/holo_blue_dark"
- android:layout_marginTop="100dp"
- android:layout_gravity="center"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingRight="4dp"
- android:text="@string/Back"/>
- <TextView
- android:id="@+id/text_id"
- android:layout_width="300dp"
- android:layout_height="200dp"
- android:capitalize="characters"
- android:textColor="@android:color/holo_blue_light"
- android:layout_centerVertical="true"
- android:textSize="15dp" />
- </LinearLayout>
-</LinearLayout>
diff --git a/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml b/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml
index bd6f389..8585102 100644
--- a/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml
+++ b/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml
@@ -17,12 +17,12 @@
<resources>
<string name="SatelliteControl">SatelliteControl APIs</string>
- <string name="SatelliteTransmissionUpdates">SatelliteTransmissionUpdates APIs</string>
<string name="Datagram">Datagram APIs</string>
<string name="Provisioning">Provisioning APIs</string>
<string name="SatelliteModemState">SatelliteModemState APIs</string>
- <string name="requestSatelliteEnabled">requestSatelliteEnabled</string>
+ <string name="enableSatellite">enableSatellite</string>
+ <string name="disableSatellite">disableSatellite</string>
<string name="requestIsSatelliteEnabled">requestIsSatelliteEnabled</string>
<string name="requestIsDemoModeEnabled">requestIsDemoModeEnabled</string>
<string name="requestIsSatelliteSupported">requestIsSatelliteSupported</string>
@@ -30,25 +30,28 @@
<string name="requestIsSatelliteCommunicationAllowedForCurrentLocation">requestIsSatelliteCommunicationAllowedForCurrentLocation</string>
<string name="requestTimeForNextSatelliteVisibility">requestTimeForNextSatelliteVisibility</string>
- <string name="startSatelliteTransmissionUpdates">startSatelliteTransmissionUpdates</string>
- <string name="stopSatelliteTransmissionUpdates">stopSatelliteTransmissionUpdates</string>
-
<string name="pollPendingSatelliteDatagrams">pollPendingSatelliteDatagrams</string>
- <string name="multiplePollPendingSatelliteDatagrams">multiplePollPendingSatelliteDatagrams</string>
<string name="sendSatelliteDatagram">sendSatelliteDatagram</string>
- <string name="multipleSendSatelliteDatagram">multipleSendSatelliteDatagram</string>
- <string name="multipleSendReceiveSatelliteDatagram">multipleSendReceiveSatelliteDatagram</string>
<string name="registerForSatelliteDatagram">registerForSatelliteDatagram</string>
<string name="unregisterForSatelliteDatagram">unregisterForSatelliteDatagram</string>
+ <string name="registerForSatelliteModemStateChanged">registerForSatelliteModemStateChanged</string>
+ <string name="unregisterForSatelliteModemStateChanged">unregisterForSatelliteModemStateChanged</string>
+ <string name="showSatelliteModemStateTransition">showSatelliteModemStateTransition</string>
+ <string name="startSatelliteTransmissionUpdates">startSatelliteTransmissionUpdates</string>
+ <string name="stopSatelliteTransmissionUpdates">stopSatelliteTransmissionUpdates</string>
+ <string name="showDatagramSendStateTransition">showDatagramSendStateTransition</string>
+ <string name="showDatagramReceiveStateTransition">showDatagramReceiveStateTransition</string>
<string name="provisionSatelliteService">provisionSatelliteService</string>
<string name="deprovisionSatelliteService">deprovisionSatelliteService</string>
<string name="requestIsSatelliteProvisioned">requestIsSatelliteProvisioned</string>
<string name="registerForSatelliteProvisionStateChanged">registerForSatelliteProvisionStateChanged</string>
<string name="unregisterForSatelliteProvisionStateChanged">unregisterForSatelliteProvisionStateChanged</string>
+ <string name="showCurrentSatelliteProvisionState">showCurrentSatelliteProvisionState</string>
- <string name="registerForSatelliteModemStateChanged">registerForSatelliteModemStateChanged</string>
- <string name="unregisterForSatelliteModemStateChanged">unregisterForSatelliteModemStateChanged</string>
+ <string name="multiplePollPendingSatelliteDatagrams">multiplePollPendingSatelliteDatagrams</string>
+ <string name="multipleSendSatelliteDatagram">multipleSendSatelliteDatagram</string>
+ <string name="multipleSendReceiveSatelliteDatagram">multipleSendReceiveSatelliteDatagram</string>
<string name="Back">Back</string>
</resources>
diff --git a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/Datagram.java b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/Datagram.java
index 5da5efc..dfa15f3 100644
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/Datagram.java
+++ b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/Datagram.java
@@ -16,17 +16,30 @@
package com.android.phone.testapps.satellitetestapp;
+import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE;
+import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVE_FAILED;
+import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVE_NONE;
+import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVE_SUCCESS;
+import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVING;
+import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_SENDING;
+import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_SEND_FAILED;
+import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_SEND_SUCCESS;
+
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
+import android.telephony.satellite.PointingInfo;
import android.telephony.satellite.SatelliteDatagram;
import android.telephony.satellite.SatelliteDatagramCallback;
import android.telephony.satellite.SatelliteManager;
+import android.telephony.satellite.SatelliteStateCallback;
+import android.telephony.satellite.SatelliteTransmissionUpdateCallback;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
+import java.util.LinkedList;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
@@ -36,35 +49,54 @@
*/
public class Datagram extends Activity {
- private static final String TAG = "Datagram";
+ private static final String TAG = "DatagramSaloni";
+ private static final int MAX_NUMBER_OF_STORED_STATES = 3;
+ private int mTransferState;
+ private int mModemState;
+ LinkedList<Integer> mModemStateQueue = new LinkedList<>();
+ LinkedList<Integer> mSendQueue = new LinkedList<>();
+ LinkedList<Integer> mReceiveQueue = new LinkedList<>();
private SatelliteManager mSatelliteManager;
- private SatelliteDatagramCallbackTestApp mCallback;
+ private SatelliteDatagramCallbackTestApp mDatagramCallback;
+ private SatelliteStateCallbackTestApp mStateCallback;
+ private SatelliteTransmissionUpdateCallbackTestApp mCallback;
private android.telephony.satellite.stub.SatelliteDatagram mReceivedDatagram;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mSatelliteManager = getSystemService(SatelliteManager.class);
- mCallback = new SatelliteDatagramCallbackTestApp();
+ mDatagramCallback = new SatelliteDatagramCallbackTestApp();
+ mStateCallback = new SatelliteStateCallbackTestApp();
+ mCallback = new SatelliteTransmissionUpdateCallbackTestApp();
mReceivedDatagram = new android.telephony.satellite.stub.SatelliteDatagram();
setContentView(R.layout.activity_Datagram);
+ findViewById(R.id.startSatelliteTransmissionUpdates)
+ .setOnClickListener(this::startSatelliteTransmissionUpdatesApp);
+ findViewById(R.id.stopSatelliteTransmissionUpdates)
+ .setOnClickListener(this::stopSatelliteTransmissionUpdatesApp);
findViewById(R.id.pollPendingSatelliteDatagrams)
.setOnClickListener(this::pollPendingSatelliteDatagramsApp);
- findViewById(R.id.multiplePollPendingSatelliteDatagrams)
- .setOnClickListener(this::multiplePollPendingSatelliteDatagramsApp);
findViewById(R.id.sendSatelliteDatagram)
.setOnClickListener(this::sendSatelliteDatagramApp);
- findViewById(R.id.multipleSendSatelliteDatagram)
- .setOnClickListener(this::multipleSendSatelliteDatagramApp);
- findViewById(R.id.multipleSendReceiveSatelliteDatagram)
- .setOnClickListener(this::multipleSendReceiveSatelliteDatagramApp);
findViewById(R.id.registerForSatelliteDatagram)
.setOnClickListener(this::registerForSatelliteDatagramApp);
findViewById(R.id.unregisterForSatelliteDatagram)
.setOnClickListener(this::unregisterForSatelliteDatagramApp);
+ findViewById(R.id.showDatagramSendStateTransition)
+ .setOnClickListener(this::showDatagramSendStateTransitionApp);
+ findViewById(R.id.showDatagramReceiveStateTransition)
+ .setOnClickListener(this::showDatagramReceiveStateTransitionApp);
+ findViewById(R.id.registerForSatelliteModemStateChanged)
+ .setOnClickListener(this::registerForSatelliteModemStateChangedApp);
+ findViewById(R.id.unregisterForSatelliteModemStateChanged)
+ .setOnClickListener(this::unregisterForSatelliteModemStateChangedApp);
+ findViewById(R.id.showSatelliteModemStateTransition)
+ .setOnClickListener(this::showSatelliteModemStateTransitionApp);
+
findViewById(R.id.Back).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
@@ -73,20 +105,96 @@
});
}
- protected static class SatelliteDatagramCallbackTestApp implements SatelliteDatagramCallback {
+ protected class SatelliteDatagramCallbackTestApp implements SatelliteDatagramCallback {
@Override
public void onSatelliteDatagramReceived(long datagramId, SatelliteDatagram datagram,
int pendingCount, Consumer<Void> callback) {
- Log.d(TAG, "onSatelliteDatagramReceived in SatelliteTestApp: datagramId =" + datagramId
+ Log.d(TAG, "onSatelliteDatagramReceived in TestApp: datagramId =" + datagramId
+ ", datagram =" + datagram + ", pendingCount=" + pendingCount);
}
}
+ protected class SatelliteStateCallbackTestApp implements SatelliteStateCallback {
+ @Override
+ public void onSatelliteModemStateChanged(int state) {
+ mModemState = state;
+ mModemStateQueue.addLast(state);
+ if (mModemStateQueue.size() > MAX_NUMBER_OF_STORED_STATES) {
+ mModemStateQueue.removeFirst();
+ }
+ Log.d(TAG, "onSatelliteModemStateChanged in TestApp: state=" + mModemState);
+ }
+ }
+ protected class SatelliteTransmissionUpdateCallbackTestApp implements
+ SatelliteTransmissionUpdateCallback {
+ @Override
+ public void onSatellitePositionChanged(PointingInfo pointingInfo) {
+ Log.d(TAG, "onSatellitePositionChanged in TestApp: pointingInfo =" + pointingInfo);
+ }
+
+ @Override
+ public void onSendDatagramStateChanged(int state, int sendPendingCount, int errorCode) {
+ mTransferState = state;
+ mSendQueue.addLast(state);
+ if (mSendQueue.size() > MAX_NUMBER_OF_STORED_STATES) {
+ mSendQueue.removeFirst();
+ }
+ Log.d(TAG, "onSendDatagramStateChanged in TestApp: state =" + mTransferState
+ + ", sendPendingCount =" + sendPendingCount + ", errorCode=" + errorCode);
+ }
+
+ @Override
+ public void onReceiveDatagramStateChanged(
+ int state, int receivePendingCount, int errorCode) {
+ mTransferState = state;
+ mReceiveQueue.addLast(state);
+ if (mReceiveQueue.size() > MAX_NUMBER_OF_STORED_STATES) {
+ mReceiveQueue.removeFirst();
+ }
+ Log.d(TAG, "onReceiveDatagramStateChanged in TestApp: state=" + mTransferState
+ + ", receivePendingCount=" + receivePendingCount + ", errorCode=" + errorCode);
+ }
+ }
+
+ private void startSatelliteTransmissionUpdatesApp(View view) {
+ LinkedBlockingQueue<Integer> error = new LinkedBlockingQueue<>(1);
+ mSatelliteManager.requestSatelliteEnabled(true, true, Runnable::run, error::offer);
+ mSatelliteManager.startSatelliteTransmissionUpdates(Runnable::run, error::offer, mCallback);
+ try {
+ Integer value = error.poll(1000, TimeUnit.MILLISECONDS);
+ TextView textView = findViewById(R.id.text_id);
+ if (value == 0) {
+ textView.setText("startSatelliteTransmissionUpdates is Successful");
+ } else {
+ textView.setText("Status for startSatelliteTransmissionUpdates : "
+ + SatelliteErrorUtils.mapError(value));
+ }
+ } catch (InterruptedException e) {
+ Log.e(TAG, "exception caught =" + e);
+ }
+ }
+
+ private void stopSatelliteTransmissionUpdatesApp(View view) {
+ LinkedBlockingQueue<Integer> error = new LinkedBlockingQueue<>(1);
+ mSatelliteManager.stopSatelliteTransmissionUpdates(mCallback, Runnable::run, error::offer);
+ try {
+ Integer value = error.poll(1000, TimeUnit.MILLISECONDS);
+ TextView textView = findViewById(R.id.text_id);
+ if (value == 0) {
+ textView.setText("stopSatelliteTransmissionUpdates is Successful");
+ } else {
+ textView.setText("Status for stopSatelliteTransmissionUpdates : "
+ + SatelliteErrorUtils.mapError(value));
+ }
+ } catch (InterruptedException e) {
+ Log.e(TAG, "exception caught =" + e);
+ }
+ }
private void pollPendingSatelliteDatagramsApp(View view) {
mSatelliteManager.onDeviceAlignedWithSatellite(true);
SatelliteTestApp.getTestSatelliteService().sendOnPendingDatagrams();
- SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
- mReceivedDatagram, 0);
+ /*SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
+ mReceivedDatagram, 0);*/
LinkedBlockingQueue<Integer> resultListener = new LinkedBlockingQueue<>(1);
mSatelliteManager.requestSatelliteEnabled(true, true, Runnable::run, resultListener::offer);
mSatelliteManager.pollPendingSatelliteDatagrams(Runnable::run, resultListener::offer);
@@ -104,40 +212,6 @@
}
}
- private void multiplePollPendingSatelliteDatagramsApp(View view) {
- mSatelliteManager.onDeviceAlignedWithSatellite(true);
- SatelliteTestApp.getTestSatelliteService().sendOnPendingDatagrams();
- SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
- mReceivedDatagram, 4);
- LinkedBlockingQueue<Integer> resultListener = new LinkedBlockingQueue<>(1);
- mSatelliteManager.requestSatelliteEnabled(true, true, Runnable::run, resultListener::offer);
- mSatelliteManager.pollPendingSatelliteDatagrams(Runnable::run, resultListener::offer);
- SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
- mReceivedDatagram, 3);
- mSatelliteManager.pollPendingSatelliteDatagrams(Runnable::run, resultListener::offer);
- SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
- mReceivedDatagram, 2);
- mSatelliteManager.pollPendingSatelliteDatagrams(Runnable::run, resultListener::offer);
- SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
- mReceivedDatagram, 1);
- mSatelliteManager.pollPendingSatelliteDatagrams(Runnable::run, resultListener::offer);
- SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
- mReceivedDatagram, 0);
- mSatelliteManager.pollPendingSatelliteDatagrams(Runnable::run, resultListener::offer);
- try {
- Integer value = resultListener.poll(1000, TimeUnit.MILLISECONDS);
- TextView textView = findViewById(R.id.text_id);
- if (value == 0) {
- textView.setText("multiplePollPendingSatelliteDatagrams is Successful");
- } else {
- textView.setText("Status for multiplePollPendingSatelliteDatagrams : "
- + SatelliteErrorUtils.mapError(value));
- }
- } catch (InterruptedException e) {
- Log.e(TAG, "exception caught =" + e);
- }
- }
-
private void sendSatelliteDatagramApp(View view) {
mSatelliteManager.onDeviceAlignedWithSatellite(true);
LinkedBlockingQueue<Integer> resultListener = new LinkedBlockingQueue<>(1);
@@ -159,78 +233,9 @@
}
}
- private void multipleSendSatelliteDatagramApp(View view) {
- mSatelliteManager.onDeviceAlignedWithSatellite(true);
- LinkedBlockingQueue<Integer> resultListener = new LinkedBlockingQueue<>(1);
- String mText = "This is a test datagram message";
- SatelliteDatagram datagram = new SatelliteDatagram(mText.getBytes());
- mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
- datagram, true, Runnable::run, resultListener::offer);
- mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
- datagram, true, Runnable::run, resultListener::offer);
- mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
- datagram, true, Runnable::run, resultListener::offer);
- mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
- datagram, true, Runnable::run, resultListener::offer);
- mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
- datagram, true, Runnable::run, resultListener::offer);
- try {
- Integer value = resultListener.poll(1000, TimeUnit.MILLISECONDS);
- TextView textView = findViewById(R.id.text_id);
- if (value == 0) {
- textView.setText("multipleSendSatelliteDatagram is Successful");
- } else {
- textView.setText("Status for multipleSendSatelliteDatagram : "
- + SatelliteErrorUtils.mapError(value));
- }
- } catch (InterruptedException e) {
- Log.e(TAG, "exception caught =" + e);
- }
- }
-
- private void multipleSendReceiveSatelliteDatagramApp(View view) {
- mSatelliteManager.onDeviceAlignedWithSatellite(true);
- LinkedBlockingQueue<Integer> resultListener = new LinkedBlockingQueue<>(1);
- mSatelliteManager.requestSatelliteEnabled(true, true, Runnable::run, resultListener::offer);
- String mText = "This is a test datagram message";
- SatelliteDatagram datagram = new SatelliteDatagram(mText.getBytes());
- mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
- datagram, true, Runnable::run, resultListener::offer);
- SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
- mReceivedDatagram, 4);
- mSatelliteManager.pollPendingSatelliteDatagrams(Runnable::run, resultListener::offer);
- mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
- datagram, true, Runnable::run, resultListener::offer);
- SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
- mReceivedDatagram, 3);
- mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
- datagram, true, Runnable::run, resultListener::offer);
- SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
- mReceivedDatagram, 2);
- mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
- datagram, true, Runnable::run, resultListener::offer);
- SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
- mReceivedDatagram, 1);
- mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
- datagram, true, Runnable::run, resultListener::offer);
- SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
- mReceivedDatagram, 0);
- try {
- Integer value = resultListener.poll(1000, TimeUnit.MILLISECONDS);
- TextView textView = findViewById(R.id.text_id);
- if (value == 0) {
- textView.setText("multipleSendReceiveSatelliteDatagram is Successful");
- } else {
- textView.setText("Status for multipleSendReceiveSatelliteDatagram : "
- + SatelliteErrorUtils.mapError(value));
- }
- } catch (InterruptedException e) {
- Log.e(TAG, "exception caught =" + e);
- }
- }
-
private void registerForSatelliteDatagramApp(View view) {
- int result = mSatelliteManager.registerForSatelliteDatagram(Runnable::run, mCallback);
+ int result = mSatelliteManager.registerForSatelliteDatagram(Runnable::run,
+ mDatagramCallback);
TextView textView = findViewById(R.id.text_id);
if (result == 0) {
textView.setText("registerForSatelliteDatagram is successful");
@@ -241,8 +246,101 @@
}
private void unregisterForSatelliteDatagramApp(View view) {
- mSatelliteManager.unregisterForSatelliteDatagram(mCallback);
+ mSatelliteManager.unregisterForSatelliteDatagram(mDatagramCallback);
TextView textView = findViewById(R.id.text_id);
textView.setText("unregisterForSatelliteDatagram is successful");
}
+
+ private void showDatagramSendStateTransitionApp(View view) {
+ TextView textView = findViewById(R.id.text_id);
+ textView.setText("Last datagram send state transition is : "
+ + getTransferStateTransition(mSendQueue));
+ }
+
+ private void showDatagramReceiveStateTransitionApp(View view) {
+ TextView textView = findViewById(R.id.text_id);
+ textView.setText("Last datagram receive state transition is : "
+ + getTransferStateTransition(mReceiveQueue));
+ }
+
+ private void registerForSatelliteModemStateChangedApp(View view) {
+ int result = mSatelliteManager.registerForSatelliteModemStateChanged(Runnable::run,
+ mStateCallback);
+ TextView textView = findViewById(R.id.text_id);
+ if (result == 0) {
+ textView.setText("registerForSatelliteModemStateChanged is successful");
+ } else {
+ textView.setText("Status for registerForSatelliteModemStateChanged : "
+ + SatelliteErrorUtils.mapError(result));
+ }
+ }
+
+ private void unregisterForSatelliteModemStateChangedApp(View view) {
+ mSatelliteManager.unregisterForSatelliteModemStateChanged(mStateCallback);
+ TextView textView = findViewById(R.id.text_id);
+ textView.setText("unregisterForSatelliteModemStateChanged is successful");
+ }
+
+ private void showSatelliteModemStateTransitionApp(View view) {
+ TextView textView = findViewById(R.id.text_id);
+ textView.setText("Last modem transition state is: "
+ + getSatelliteModemStateTransition(mModemStateQueue));
+ }
+
+ private String getSatelliteModemStateName(@SatelliteManager.SatelliteModemState int state) {
+ switch (state) {
+ case SatelliteManager.SATELLITE_MODEM_STATE_IDLE:
+ return "IDLE";
+ case SatelliteManager.SATELLITE_MODEM_STATE_LISTENING:
+ return "LISTENING";
+ case SatelliteManager.SATELLITE_MODEM_STATE_DATAGRAM_TRANSFERRING:
+ return "DATAGRAM_TRANSFERRING";
+ case SatelliteManager.SATELLITE_MODEM_STATE_DATAGRAM_RETRYING:
+ return "DATAGRAM_RETRYING";
+ case SatelliteManager.SATELLITE_MODEM_STATE_OFF:
+ return "OFF";
+ case SatelliteManager.SATELLITE_MODEM_STATE_UNAVAILABLE:
+ return "UNAVAILABLE";
+ default: return "UNKNOWN";
+ }
+ }
+
+ private String getSatelliteModemStateTransition(LinkedList<Integer> states) {
+ StringBuilder sb = new StringBuilder();
+ for (int state : states) {
+ sb.append(getSatelliteModemStateName(state));
+ sb.append("=>");
+ }
+ if (!sb.isEmpty()) {
+ sb.delete(sb.length() - 2, sb.length());
+ }
+ return sb.toString();
+ }
+
+ private String getDatagramTransferStateName(
+ @SatelliteManager.SatelliteDatagramTransferState int state) {
+ switch (state) {
+ case SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE: return "IDLE";
+ case SATELLITE_DATAGRAM_TRANSFER_STATE_SENDING: return "SENDING";
+ case SATELLITE_DATAGRAM_TRANSFER_STATE_SEND_SUCCESS: return "SEND_SUCCESS";
+ case SATELLITE_DATAGRAM_TRANSFER_STATE_SEND_FAILED: return "SEND_FAILED";
+ case SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVING: return "RECEIVING";
+ case SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVE_SUCCESS: return "RECEIVE_SUCCESS";
+ case SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVE_NONE: return "RECEIVE_NONE";
+ case SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVE_FAILED: return "RECEIVE_FAILED";
+ default: return "UNKNOWN";
+ }
+ }
+
+ private String getTransferStateTransition(LinkedList<Integer> states) {
+ StringBuilder sb = new StringBuilder();
+ for (int state : states) {
+ sb.append(getDatagramTransferStateName(state));
+ sb.append("=>");
+ }
+ if (!sb.isEmpty()) {
+ sb.delete(sb.length() - 2, sb.length());
+ }
+ return sb.toString();
+ }
}
diff --git a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/MultipleSendReceive.java b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/MultipleSendReceive.java
new file mode 100644
index 0000000..b9cfc35
--- /dev/null
+++ b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/MultipleSendReceive.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.phone.testapps.satellitetestapp;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.telephony.satellite.SatelliteDatagram;
+import android.telephony.satellite.SatelliteManager;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.TextView;
+
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Activity related to Send and Receiving of message APIs for satellite.
+ */
+public class MultipleSendReceive extends Activity {
+
+ private static final String TAG = "MultipleSendReceive";
+
+ private SatelliteManager mSatelliteManager;
+ private android.telephony.satellite.stub.SatelliteDatagram mReceivedDatagram;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mSatelliteManager = getSystemService(SatelliteManager.class);
+ mReceivedDatagram = new android.telephony.satellite.stub.SatelliteDatagram();
+
+ setContentView(R.layout.activity_MultipleSendReceive);
+ findViewById(R.id.multiplePollPendingSatelliteDatagrams)
+ .setOnClickListener(this::multiplePollPendingSatelliteDatagramsApp);
+ findViewById(R.id.multipleSendSatelliteDatagram)
+ .setOnClickListener(this::multipleSendSatelliteDatagramApp);
+ findViewById(R.id.multipleSendReceiveSatelliteDatagram)
+ .setOnClickListener(this::multipleSendReceiveSatelliteDatagramApp);
+ findViewById(R.id.Back).setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ startActivity(new Intent(MultipleSendReceive.this, SatelliteTestApp.class));
+ }
+ });
+ }
+
+ private void multiplePollPendingSatelliteDatagramsApp(View view) {
+ mSatelliteManager.onDeviceAlignedWithSatellite(true);
+ SatelliteTestApp.getTestSatelliteService().sendOnPendingDatagrams();
+ SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
+ mReceivedDatagram, 4);
+ LinkedBlockingQueue<Integer> resultListener = new LinkedBlockingQueue<>(1);
+ mSatelliteManager.requestSatelliteEnabled(true, true, Runnable::run, resultListener::offer);
+ mSatelliteManager.pollPendingSatelliteDatagrams(Runnable::run, resultListener::offer);
+ SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
+ mReceivedDatagram, 3);
+ mSatelliteManager.pollPendingSatelliteDatagrams(Runnable::run, resultListener::offer);
+ SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
+ mReceivedDatagram, 2);
+ mSatelliteManager.pollPendingSatelliteDatagrams(Runnable::run, resultListener::offer);
+ SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
+ mReceivedDatagram, 1);
+ mSatelliteManager.pollPendingSatelliteDatagrams(Runnable::run, resultListener::offer);
+ SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
+ mReceivedDatagram, 0);
+ mSatelliteManager.pollPendingSatelliteDatagrams(Runnable::run, resultListener::offer);
+ try {
+ Integer value = resultListener.poll(1000, TimeUnit.MILLISECONDS);
+ TextView textView = findViewById(R.id.text_id);
+ if (value == 0) {
+ textView.setText("multiplePollPendingSatelliteDatagrams is Successful");
+ } else {
+ textView.setText("Status for multiplePollPendingSatelliteDatagrams : "
+ + SatelliteErrorUtils.mapError(value));
+ }
+ } catch (InterruptedException e) {
+ Log.e(TAG, "exception caught =" + e);
+ }
+ }
+
+
+ private void multipleSendSatelliteDatagramApp(View view) {
+ mSatelliteManager.onDeviceAlignedWithSatellite(true);
+ LinkedBlockingQueue<Integer> resultListener = new LinkedBlockingQueue<>(1);
+ String mText = "This is a test datagram message";
+ SatelliteDatagram datagram = new SatelliteDatagram(mText.getBytes());
+ mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
+ datagram, true, Runnable::run, resultListener::offer);
+ mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
+ datagram, true, Runnable::run, resultListener::offer);
+ mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
+ datagram, true, Runnable::run, resultListener::offer);
+ mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
+ datagram, true, Runnable::run, resultListener::offer);
+ mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
+ datagram, true, Runnable::run, resultListener::offer);
+ try {
+ Integer value = resultListener.poll(1000, TimeUnit.MILLISECONDS);
+ TextView textView = findViewById(R.id.text_id);
+ if (value == 0) {
+ textView.setText("multipleSendSatelliteDatagram is Successful");
+ } else {
+ textView.setText("Status for multipleSendSatelliteDatagram : "
+ + SatelliteErrorUtils.mapError(value));
+ }
+ } catch (InterruptedException e) {
+ Log.e(TAG, "exception caught =" + e);
+ }
+ }
+
+ private void multipleSendReceiveSatelliteDatagramApp(View view) {
+ mSatelliteManager.onDeviceAlignedWithSatellite(true);
+ LinkedBlockingQueue<Integer> resultListener = new LinkedBlockingQueue<>(1);
+ mSatelliteManager.requestSatelliteEnabled(true, true, Runnable::run, resultListener::offer);
+ String mText = "This is a test datagram message";
+ SatelliteDatagram datagram = new SatelliteDatagram(mText.getBytes());
+ mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
+ datagram, true, Runnable::run, resultListener::offer);
+ SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
+ mReceivedDatagram, 4);
+ mSatelliteManager.pollPendingSatelliteDatagrams(Runnable::run, resultListener::offer);
+ mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
+ datagram, true, Runnable::run, resultListener::offer);
+ SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
+ mReceivedDatagram, 3);
+ mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
+ datagram, true, Runnable::run, resultListener::offer);
+ SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
+ mReceivedDatagram, 2);
+ mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
+ datagram, true, Runnable::run, resultListener::offer);
+ SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
+ mReceivedDatagram, 1);
+ mSatelliteManager.sendSatelliteDatagram(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
+ datagram, true, Runnable::run, resultListener::offer);
+ SatelliteTestApp.getTestSatelliteService().sendOnSatelliteDatagramReceived(
+ mReceivedDatagram, 0);
+ try {
+ Integer value = resultListener.poll(1000, TimeUnit.MILLISECONDS);
+ TextView textView = findViewById(R.id.text_id);
+ if (value == 0) {
+ textView.setText("multipleSendReceiveSatelliteDatagram is Successful");
+ } else {
+ textView.setText("Status for multipleSendReceiveSatelliteDatagram : "
+ + SatelliteErrorUtils.mapError(value));
+ }
+ } catch (InterruptedException e) {
+ Log.e(TAG, "exception caught =" + e);
+ }
+ }
+}
diff --git a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/Provisioning.java b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/Provisioning.java
index b403b2c..4f6f7c7 100644
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/Provisioning.java
+++ b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/Provisioning.java
@@ -39,6 +39,8 @@
private static final String TAG = "Provisioning";
+ private boolean mProvisioned = false;
+
private SatelliteManager mSatelliteManager;
private SatelliteProvisionStateCallbackTestApp mCallback;
@@ -59,6 +61,8 @@
.setOnClickListener(this::registerForSatelliteProvisionStateChangedApp);
findViewById(R.id.unregisterForSatelliteProvisionStateChanged)
.setOnClickListener(this::unregisterForSatelliteProvisionStateChangedApp);
+ findViewById(R.id.showCurrentSatelliteProvisionState)
+ .setOnClickListener(this::showCurrentSatelliteProvisionStateApp);
findViewById(R.id.Back).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
@@ -67,12 +71,13 @@
});
}
- protected static class SatelliteProvisionStateCallbackTestApp implements
+ protected class SatelliteProvisionStateCallbackTestApp implements
SatelliteProvisionStateCallback {
@Override
public void onSatelliteProvisionStateChanged(boolean provisioned) {
+ mProvisioned = provisioned;
Log.d(TAG, "onSatelliteProvisionStateChanged in SatelliteTestApp: provisioned="
- + provisioned);
+ + mProvisioned);
}
}
@@ -144,4 +149,9 @@
TextView textView = findViewById(R.id.text_id);
textView.setText("unregisterForSatelliteProvisionStateChanged is successful");
}
+
+ private void showCurrentSatelliteProvisionStateApp(View view) {
+ TextView textView = findViewById(R.id.text_id);
+ textView.setText("Current Provision State is " + mProvisioned);
+ }
}
diff --git a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteControl.java b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteControl.java
index 9cfbc6a..14f3b6b 100644
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteControl.java
+++ b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteControl.java
@@ -47,8 +47,10 @@
mSatelliteManager = getSystemService(SatelliteManager.class);
setContentView(R.layout.activity_SatelliteControl);
- findViewById(R.id.requestSatelliteEnabled)
- .setOnClickListener(this::requestSatelliteEnabledApp);
+ findViewById(R.id.enableSatellite)
+ .setOnClickListener(this::enableSatelliteApp);
+ findViewById(R.id.disableSatellite)
+ .setOnClickListener(this::disableSatelliteApp);
findViewById(R.id.requestIsSatelliteEnabled)
.setOnClickListener(this::requestIsSatelliteEnabledApp);
findViewById(R.id.requestIsDemoModeEnabled)
@@ -70,14 +72,31 @@
});
}
- private void requestSatelliteEnabledApp(View view) {
+ private void enableSatelliteApp(View view) {
LinkedBlockingQueue<Integer> error = new LinkedBlockingQueue<>(1);
mSatelliteManager.requestSatelliteEnabled(true, true, Runnable::run, error::offer);
try {
Integer value = error.poll(1000, TimeUnit.MILLISECONDS);
TextView textView = findViewById(R.id.text_id);
if (value == 0) {
- textView.setText("requestSatelliteEnabled is successful");
+ textView.setText("Enable satellite is successful");
+ } else {
+ textView.setText("Status for requestSatelliteEnabled: "
+ + SatelliteErrorUtils.mapError(value));
+ }
+ } catch (InterruptedException e) {
+ Log.e(TAG, "exception caught =" + e);
+ }
+ }
+
+ private void disableSatelliteApp(View view) {
+ LinkedBlockingQueue<Integer> error = new LinkedBlockingQueue<>(1);
+ mSatelliteManager.requestSatelliteEnabled(false, true, Runnable::run, error::offer);
+ try {
+ Integer value = error.poll(1000, TimeUnit.MILLISECONDS);
+ TextView textView = findViewById(R.id.text_id);
+ if (value == 0) {
+ textView.setText("Disable satellite is successful");
} else {
textView.setText("Status for requestSatelliteEnabled: "
+ SatelliteErrorUtils.mapError(value));
diff --git a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteModemState.java b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteModemState.java
deleted file mode 100644
index aa0d5b0..0000000
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteModemState.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.phone.testapps.satellitetestapp;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.telephony.satellite.SatelliteManager;
-import android.telephony.satellite.SatelliteStateCallback;
-import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.TextView;
-
-/**
- * Activity related to SatelliteModemState APIs.
- */
-public class SatelliteModemState extends Activity {
-
- private static final String TAG = "SatelliteModemState";
-
- private SatelliteManager mSatelliteManager;
- private SatelliteStateCallbackTestApp mCallback;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mSatelliteManager = getSystemService(SatelliteManager.class);
- mCallback = new SatelliteStateCallbackTestApp();
-
- setContentView(R.layout.activity_SatelliteModemState);
- findViewById(R.id.registerForSatelliteModemStateChanged)
- .setOnClickListener(this::registerForSatelliteModemStateChangedApp);
- findViewById(R.id.unregisterForSatelliteModemStateChanged)
- .setOnClickListener(this::unregisterForSatelliteModemStateChangedApp);
- findViewById(R.id.Back).setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View view) {
- startActivity(new Intent(SatelliteModemState.this, SatelliteTestApp.class));
- }
- });
- }
-
- protected static class SatelliteStateCallbackTestApp implements SatelliteStateCallback {
- @Override
- public void onSatelliteModemStateChanged(int state) {
- Log.d(TAG, "onSatelliteModemStateChanged in SatelliteTestApp: state=" + state);
- }
- }
-
- private void registerForSatelliteModemStateChangedApp(View view) {
- int result = mSatelliteManager.registerForSatelliteModemStateChanged(Runnable::run,
- mCallback);
- TextView textView = findViewById(R.id.text_id);
- if (result == 0) {
- textView.setText("registerForSatelliteModemStateChanged is successful");
- } else {
- textView.setText("Status for registerForSatelliteModemStateChanged : "
- + SatelliteErrorUtils.mapError(result));
- }
- }
-
- private void unregisterForSatelliteModemStateChangedApp(View view) {
- mSatelliteManager.unregisterForSatelliteModemStateChanged(mCallback);
- TextView textView = findViewById(R.id.text_id);
- textView.setText("unregisterForSatelliteModemStateChanged is successful");
- }
-}
-
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 ed5b75e..d98e8fb 100644
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteTestApp.java
+++ b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteTestApp.java
@@ -61,14 +61,6 @@
startActivity(intent);
}
});
- findViewById(R.id.SatelliteTransmissionUpdates).setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent = new Intent(SatelliteTestApp.this,
- SatelliteTransmissionUpdates.class);
- startActivity(intent);
- }
- });
findViewById(R.id.Datagram).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
@@ -83,10 +75,10 @@
startActivity(intent);
}
});
- findViewById(R.id.SatelliteModemState).setOnClickListener(new OnClickListener() {
+ findViewById(R.id.MultipleSendReceive).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
- Intent intent = new Intent(SatelliteTestApp.this, SatelliteModemState.class);
+ Intent intent = new Intent(SatelliteTestApp.this, MultipleSendReceive.class);
startActivity(intent);
}
});
diff --git a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteTransmissionUpdates.java b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteTransmissionUpdates.java
deleted file mode 100644
index b41f245..0000000
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteTransmissionUpdates.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.phone.testapps.satellitetestapp;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.telephony.satellite.PointingInfo;
-import android.telephony.satellite.SatelliteManager;
-import android.telephony.satellite.SatelliteTransmissionUpdateCallback;
-import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.TextView;
-
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Activity related to SatelliteTransmissionUpdates APIs.
- */
-public class SatelliteTransmissionUpdates extends Activity {
-
- private static final String TAG = "SatelliteTransmissionUpdates";
-
- private SatelliteManager mSatelliteManager;
- private SatelliteTransmissionUpdateCallbackTestApp mCallback;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mSatelliteManager = getSystemService(SatelliteManager.class);
- mCallback = new SatelliteTransmissionUpdateCallbackTestApp();
-
- setContentView(R.layout.activity_SatelliteTransmissionUpdates);
- findViewById(R.id.startSatelliteTransmissionUpdates)
- .setOnClickListener(this::startSatelliteTransmissionUpdatesApp);
- findViewById(R.id.stopSatelliteTransmissionUpdates)
- .setOnClickListener(this::stopSatelliteTransmissionUpdatesApp);
- findViewById(R.id.Back).setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View view) {
- startActivity(new Intent(SatelliteTransmissionUpdates.this,
- SatelliteTestApp.class));
- }
- });
- }
-
- protected static class SatelliteTransmissionUpdateCallbackTestApp implements
- SatelliteTransmissionUpdateCallback {
- @Override
- public void onSatellitePositionChanged(PointingInfo pointingInfo) {
- Log.d(TAG, "onSatellitePositionChanged in TestApp: pointingInfo =" + pointingInfo);
- }
-
- @Override
- public void onSendDatagramStateChanged(int state, int sendPendingCount, int errorCode) {
- Log.d(TAG, "onSendDatagramStateChanged in TestApp: state =" + state
- + ", sendPendingCount =" + sendPendingCount + ", errorCode=" + errorCode);
- }
-
- @Override
- public void onReceiveDatagramStateChanged(
- int state, int receivePendingCount, int errorCode) {
- Log.d(TAG, "onReceiveDatagramStateChanged in TestApp: state=" + state + ", "
- + "receivePendingCount=" + receivePendingCount + ", errorCode=" + errorCode);
- }
- }
-
- private void startSatelliteTransmissionUpdatesApp(View view) {
- LinkedBlockingQueue<Integer> error = new LinkedBlockingQueue<>(1);
- mSatelliteManager.requestSatelliteEnabled(true, true, Runnable::run, error::offer);
- mSatelliteManager.startSatelliteTransmissionUpdates(Runnable::run, error::offer, mCallback);
- try {
- Integer value = error.poll(1000, TimeUnit.MILLISECONDS);
- TextView textView = findViewById(R.id.text_id);
- if (value == 0) {
- textView.setText("startSatelliteTransmissionUpdates is Successful");
- } else {
- textView.setText("Status for startSatelliteTransmissionUpdates : "
- + SatelliteErrorUtils.mapError(value));
- }
- } catch (InterruptedException e) {
- Log.e(TAG, "exception caught =" + e);
- }
- }
-
- private void stopSatelliteTransmissionUpdatesApp(View view) {
- LinkedBlockingQueue<Integer> error = new LinkedBlockingQueue<>(1);
- mSatelliteManager.stopSatelliteTransmissionUpdates(mCallback, Runnable::run, error::offer);
- try {
- Integer value = error.poll(1000, TimeUnit.MILLISECONDS);
- TextView textView = findViewById(R.id.text_id);
- if (value == 0) {
- textView.setText("stopSatelliteTransmissionUpdates is Successful");
- } else {
- textView.setText("Status for stopSatelliteTransmissionUpdates : "
- + SatelliteErrorUtils.mapError(value));
- }
- } catch (InterruptedException e) {
- Log.e(TAG, "exception caught =" + e);
- }
- }
-}
diff --git a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteService.java b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteService.java
index 5c7f4a2..f7c13d4 100644
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteService.java
+++ b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteService.java
@@ -189,32 +189,6 @@
}
}
- @Override
- public void enableCellularModemWhileSatelliteModeIsOn(boolean enable,
- @NonNull IIntegerConsumer errorCallback) {
- logd("enableCellularModemWhileSatelliteModeIsOn :" + enable + " error Code = " + mErrorCode
- + "mIsCellularModemEnabledMode = " + mIsCellularModemEnabledMode
- + " mIsEnabled = " + mIsEnabled);
- if (mLocalListener != null) {
- runWithExecutor(() -> mLocalListener
- .onEnableCellularModemWhileSatelliteModeIsOn(enable));
- } else {
- loge("requestSatelliteListeningEnabled: mLocalListener is null");
- }
- if (mIsEnabled) {
- if (enable) {
- mIsCellularModemEnabledMode = true;
- disableSatellite(errorCallback);
- } else {
- mIsCellularModemEnabledMode = false;
- enableSatellite(errorCallback);
- }
- } else {
- final int finalError = SatelliteError.INVALID_MODEM_STATE;
- runWithExecutor(() -> errorCallback.accept(finalError));
- }
-
- }
private void enableSatellite(@NonNull IIntegerConsumer errorCallback) {
mIsEnabled = true;
updateSatelliteModemState(SatelliteModemState.SATELLITE_MODEM_STATE_IDLE);