Merge "Add setSatellitePlmn, setSatelliteEnabledForCarrier and requestIsSatelliteEnabledForCarrier for test" into main
diff --git a/testapps/TestSatelliteApp/res/layout/activity_SatelliteControl.xml b/testapps/TestSatelliteApp/res/layout/activity_SatelliteControl.xml
index 40e3c69..6a79412 100644
--- a/testapps/TestSatelliteApp/res/layout/activity_SatelliteControl.xml
+++ b/testapps/TestSatelliteApp/res/layout/activity_SatelliteControl.xml
@@ -15,7 +15,7 @@
~ 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"
@@ -84,6 +84,42 @@
android:paddingRight="4dp"
android:text="@string/requestTimeForNextSatelliteVisibility"/>
<Button
+ android:id="@+id/removeUserRestrictReason"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/removeUserRestrictReason"/>
+ <Button
+ android:id="@+id/addUserRestrictReason"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/addUserRestrictReason"/>
+ <Button
+ android:id="@+id/getSatellitePlmn"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/getSatellitePlmn"/>
+ <Button
+ android:id="@+id/getAllSatellitePlmn"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/getAllSatellitePlmn"/>
+ <Button
+ android:id="@+id/isSatelliteEnabledForCarrier"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/isSatelliteEnabledForCarrier"/>
+ <Button
+ android:id="@+id/isRequestIsSatelliteEnabledForCarrier"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingRight="4dp"
+ android:text="@string/isRequestIsSatelliteEnabledForCarrier"/>
+ <Button
android:id="@+id/Back"
android:onClick="Back"
android:textColor="@android:color/holo_blue_dark"
@@ -102,4 +138,4 @@
android:layout_centerVertical="true"
android:textSize="15dp" />
</LinearLayout>
-</LinearLayout>
+</ScrollView>
diff --git a/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml b/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml
index 8ebe5f3..6c707dd 100644
--- a/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml
+++ b/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml
@@ -65,6 +65,13 @@
<string name="registerForSatelliteCapabilitiesChanged">registerForSatelliteCapabilitiesChanged</string>
<string name="unregisterForSatelliteCapabilitiesChanged">unregisterForSatelliteCapabilitiesChanged</string>
+ <string name="removeUserRestrictReason">removeUserRestrictReason</string>
+ <string name="addUserRestrictReason">addUserRestrictReason</string>
+ <string name="getSatellitePlmn">getSatellitePlmn</string>
+ <string name="getAllSatellitePlmn">getAllSatellitePlmn</string>
+ <string name="isSatelliteEnabledForCarrier">isSatelliteEnabledForCarrier</string>
+ <string name="isRequestIsSatelliteEnabledForCarrier">isRequestIsSatelliteEnabledForCarrier</string>
+
<string name="Back">Back</string>
<string name="ClearLog">Clear Log</string>
</resources>
diff --git a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/ILocalSatelliteListener.aidl b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/ILocalSatelliteListener.aidl
index 2c320c8..0a32432 100644
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/ILocalSatelliteListener.aidl
+++ b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/ILocalSatelliteListener.aidl
@@ -64,4 +64,10 @@
* enableCellularModemWhileSatelliteModeIsOn from Telephony.
*/
void onEnableCellularModemWhileSatelliteModeIsOn(in boolean enable);
+
+ /**
+ * Indicates that MockSatelliteService has just received the request
+ * setSatellitePlmn from Telephony.
+ */
+ void onSetSatellitePlmn();
}
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 2d01aec..9df5d94 100644
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteControl.java
+++ b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteControl.java
@@ -20,6 +20,8 @@
import android.content.Intent;
import android.os.Bundle;
import android.os.OutcomeReceiver;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
import android.telephony.satellite.SatelliteCapabilities;
import android.telephony.satellite.SatelliteManager;
import android.telephony.satellite.stub.SatelliteResult;
@@ -28,6 +30,7 @@
import android.widget.TextView;
import java.time.Duration;
+import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
@@ -40,11 +43,13 @@
private static final long TIMEOUT = 3000;
private SatelliteManager mSatelliteManager;
+ private SubscriptionManager mSubscriptionManager;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mSatelliteManager = getSystemService(SatelliteManager.class);
+ mSubscriptionManager = getSystemService(SubscriptionManager.class);
setContentView(R.layout.activity_SatelliteControl);
findViewById(R.id.enableSatellite)
@@ -63,6 +68,18 @@
.setOnClickListener(this::requestIsCommunicationAllowedForCurrentLocationApp);
findViewById(R.id.requestTimeForNextSatelliteVisibility)
.setOnClickListener(this::requestTimeForNextSatelliteVisibilityApp);
+ findViewById(R.id.removeUserRestrictReason)
+ .setOnClickListener(this::removeUserRestrictReasonApp);
+ findViewById(R.id.addUserRestrictReason)
+ .setOnClickListener(this::addUserRestrictReasonApp);
+ findViewById(R.id.getSatellitePlmn)
+ .setOnClickListener(this::getSatellitePlmnApp);
+ findViewById(R.id.getAllSatellitePlmn)
+ .setOnClickListener(this::getAllSatellitePlmnApp);
+ findViewById(R.id.isSatelliteEnabledForCarrier)
+ .setOnClickListener(this::isSatelliteEnabledForCarrierApp);
+ findViewById(R.id.isRequestIsSatelliteEnabledForCarrier)
+ .setOnClickListener(this::isRequestIsSatelliteEnabledForCarrierApp);
findViewById(R.id.Back).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
@@ -270,4 +287,87 @@
};
mSatelliteManager.requestTimeForNextSatelliteVisibility(Runnable::run, receiver);
}
+
+ private void removeUserRestrictReasonApp(View view) {
+ TextView textView = findViewById(R.id.text_id);
+ LinkedBlockingQueue<Integer> error = new LinkedBlockingQueue<>(1);
+ List<SubscriptionInfo> infoList = mSubscriptionManager.getAvailableSubscriptionInfoList();
+ List<Integer> subIdList = infoList.stream()
+ .map(SubscriptionInfo::getSubscriptionId)
+ .toList();
+ for (int subId : subIdList) {
+ mSatelliteManager.removeAttachRestrictionForCarrier(subId,
+ SatelliteManager.SATELLITE_COMMUNICATION_RESTRICTION_REASON_USER,
+ Runnable::run, error::offer);
+ }
+
+ try {
+ Integer value = error.poll(TIMEOUT, TimeUnit.MILLISECONDS);
+ if (value == null) {
+ textView.setText("Timed out to removeAttachRestrictionForCarrier");
+ } else if (value != SatelliteResult.SATELLITE_RESULT_SUCCESS) {
+ textView.setText("Failed to removeAttachRestrictionForCarrier with error = "
+ + SatelliteErrorUtils.mapError(value));
+ } else {
+ textView.setText(subIdList == null || subIdList.isEmpty() ? "no active subId list" :
+ "removeAttachRestrictionForCarrier for all subIdList=" + subIdList);
+ }
+ } catch (InterruptedException e) {
+ textView.setText("removeAttachRestrictionForCarrier exception caught =" + e);
+ }
+ }
+
+ private void addUserRestrictReasonApp(View view) {
+ TextView textView = findViewById(R.id.text_id);
+ LinkedBlockingQueue<Integer> error = new LinkedBlockingQueue<>(1);
+ List<SubscriptionInfo> infoList = mSubscriptionManager.getAvailableSubscriptionInfoList();
+ List<Integer> subIdList = infoList.stream()
+ .map(SubscriptionInfo::getSubscriptionId)
+ .toList();
+ for (int subId : subIdList) {
+ mSatelliteManager.addAttachRestrictionForCarrier(subId,
+ SatelliteManager.SATELLITE_COMMUNICATION_RESTRICTION_REASON_USER,
+ Runnable::run, error::offer);
+ }
+
+ try {
+ Integer value = error.poll(TIMEOUT, TimeUnit.MILLISECONDS);
+ if (value == null) {
+ textView.setText("Timed out to addAttachRestrictionForCarrier");
+ } else if (value != SatelliteResult.SATELLITE_RESULT_SUCCESS) {
+ textView.setText("Failed to addAttachRestrictionForCarrier with error = "
+ + SatelliteErrorUtils.mapError(value));
+ } else {
+ textView.setText(subIdList == null || subIdList.isEmpty() ? "no active subId list" :
+ "addAttachRestrictionForCarrier for all subIdList=" + subIdList);
+ }
+ } catch (InterruptedException e) {
+ textView.setText("addAttachRestrictionForCarrier exception caught =" + e);
+ }
+ }
+
+ private void getSatellitePlmnApp(View view) {
+ TextView textView = findViewById(R.id.text_id);
+ textView.setText("[SatelliteService] getSatellitePlmnApp = "
+ + SatelliteTestApp.getTestSatelliteService().getCarrierPlmnList());
+ }
+
+ private void getAllSatellitePlmnApp(View view) {
+ TextView textView = findViewById(R.id.text_id);
+ textView.setText("[SatelliteService] getAllSatellitePlmnApp = "
+ + SatelliteTestApp.getTestSatelliteService().getAllSatellitePlmnList());
+ }
+
+ private void isSatelliteEnabledForCarrierApp(View view) {
+ TextView textView = findViewById(R.id.text_id);
+ textView.setText("[SatelliteService] isSatelliteEnabledForCarrier= "
+ + SatelliteTestApp.getTestSatelliteService().isSatelliteEnabledForCarrier());
+ }
+
+ private void isRequestIsSatelliteEnabledForCarrierApp(View view) {
+ TextView textView = findViewById(R.id.text_id);
+ textView.setText("[SatelliteService] isRequestIsSatelliteEnabledForCarrier= "
+ + SatelliteTestApp.getTestSatelliteService()
+ .isRequestIsSatelliteEnabledForCarrier());
+ }
}
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 ced9a06..c8ee5fa 100644
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteTestApp.java
+++ b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteTestApp.java
@@ -138,6 +138,11 @@
public void onEnableCellularModemWhileSatelliteModeIsOn(boolean enable) {
Log.d(TAG, "onEnableCellularModemWhileSatelliteModeIsOn");
}
+
+ @Override
+ public void onSetSatellitePlmn() {
+ Log.d(TAG, "onSetSatellitePlmn");
+ }
};
private class TestSatelliteServiceConnection implements ServiceConnection {
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 9bea30c..af37611 100644
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteService.java
+++ b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteService.java
@@ -41,7 +41,9 @@
import com.android.internal.util.FunctionalUtils;
import com.android.telephony.Rlog;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -94,6 +96,10 @@
private boolean mIsSupported;
private int mModemState;
private boolean mIsCellularModemEnabledMode;
+ private List<String> mCarrierPlmnList = new ArrayList<>();
+ private List<String> mAllPlmnList = new ArrayList<>();
+ private boolean mIsSatelliteEnabledForCarrier;
+ private boolean mIsRequestIsSatelliteEnabledForCarrier;
/**
* Create TestSatelliteService using the Executor specified for methods being called from
@@ -109,6 +115,8 @@
mIsSupported = true;
mModemState = SatelliteModemState.SATELLITE_MODEM_STATE_OFF;
mIsCellularModemEnabledMode = false;
+ mIsSatelliteEnabledForCarrier = false;
+ mIsRequestIsSatelliteEnabledForCarrier = false;
}
/**
@@ -389,6 +397,55 @@
runWithExecutor(() -> callback.accept(SATELLITE_ALWAYS_VISIBLE));
}
+ @Override
+ public void setSatellitePlmn(int simLogicalSlotIndex, List<String> carrierPlmnList,
+ List<String> allSatellitePlmnList, IIntegerConsumer resultCallback) {
+ logd("setSatellitePlmn: simLogicalSlotIndex=" + simLogicalSlotIndex + " , carrierPlmnList="
+ + carrierPlmnList + " , allSatellitePlmnList=" + allSatellitePlmnList);
+ if (mErrorCode != SatelliteResult.SATELLITE_RESULT_SUCCESS) {
+ runWithExecutor(() -> resultCallback.accept(mErrorCode));
+ return;
+ }
+ runWithExecutor(() -> resultCallback.accept(SatelliteResult.SATELLITE_RESULT_SUCCESS));
+
+ mCarrierPlmnList = carrierPlmnList;
+ mAllPlmnList = allSatellitePlmnList;
+
+ if (mLocalListener != null) {
+ runWithExecutor(() -> mLocalListener.onSetSatellitePlmn());
+ } else {
+ loge("setSatellitePlmn: mLocalListener is null");
+ }
+ }
+
+ @Override
+ public void setSatelliteEnabledForCarrier(int simLogicalSlotIndex, boolean satelliteEnabled,
+ IIntegerConsumer callback) {
+ logd("setSatelliteEnabledForCarrier: simLogicalSlotIndex=" + simLogicalSlotIndex
+ + ", satelliteEnabled=" + satelliteEnabled);
+ if (mErrorCode != SatelliteResult.SATELLITE_RESULT_SUCCESS) {
+ runWithExecutor(() -> callback.accept(mErrorCode));
+ return;
+ }
+
+ mIsSatelliteEnabledForCarrier = satelliteEnabled;
+ runWithExecutor(() -> callback.accept(SatelliteResult.SATELLITE_RESULT_SUCCESS));
+ }
+
+ @Override
+ public void requestIsSatelliteEnabledForCarrier(int simLogicalSlotIndex,
+ IIntegerConsumer resultCallback, IBooleanConsumer callback) {
+ logd("requestIsSatelliteEnabledForCarrier: simLogicalSlotIndex=" + simLogicalSlotIndex);
+ if (mErrorCode != SatelliteResult.SATELLITE_RESULT_SUCCESS) {
+ runWithExecutor(() -> resultCallback.accept(mErrorCode));
+ mIsRequestIsSatelliteEnabledForCarrier = false;
+ return;
+ }
+
+ runWithExecutor(() -> callback.accept(mIsSatelliteEnabledForCarrier));
+ mIsRequestIsSatelliteEnabledForCarrier = true;
+ }
+
public void setLocalSatelliteListener(@NonNull ILocalSatelliteListener listener) {
logd("setLocalSatelliteListener: listener=" + listener);
mLocalListener = listener;
@@ -508,6 +565,22 @@
}
}
+ public List<String> getCarrierPlmnList() {
+ return mCarrierPlmnList;
+ }
+
+ public List<String> getAllSatellitePlmnList() {
+ return mAllPlmnList;
+ }
+
+ public boolean isSatelliteEnabledForCarrier() {
+ return mIsSatelliteEnabledForCarrier;
+ }
+
+ public boolean isRequestIsSatelliteEnabledForCarrier() {
+ return mIsRequestIsSatelliteEnabledForCarrier;
+ }
+
/**
* Log the message to the radio buffer with {@code DEBUG} priority.
*