Merge "Report satellite communication is allowed for current location satus" into main
diff --git a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
index 97a170b..45340d8 100644
--- a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
+++ b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
@@ -52,6 +52,8 @@
import android.telephony.Rlog;
import android.telephony.SubscriptionManager;
import android.telephony.satellite.ISatelliteCommunicationAllowedStateCallback;
+import android.telephony.satellite.ISatelliteProvisionStateCallback;
+import android.telephony.satellite.ISatelliteSupportedStateCallback;
import android.telephony.satellite.SatelliteManager;
import android.text.TextUtils;
import android.util.Pair;
@@ -147,6 +149,10 @@
@NonNull
private final ResultReceiver mInternalSatelliteProvisionedResultReceiver;
@NonNull
+ private final ISatelliteSupportedStateCallback mInternalSatelliteSupportedStateCallback;
+ @NonNull
+ private final ISatelliteProvisionStateCallback mInternalSatelliteProvisionStateCallback;
+ @NonNull
protected final Object mLock = new Object();
@GuardedBy("mLock")
@NonNull
@@ -209,7 +215,7 @@
@GuardedBy("mSatelliteCommunicationAllowStateLock")
private boolean mCurrentSatelliteAllowedState = false;
- private static final long NANOS_IN_DAY = Duration.ofDays(1).toNanos();
+ private static final long NANOS_IN_12_HOURS = Duration.ofHours(12).toNanos();
private boolean mLatestSatelliteCommunicationAllowed;
private long mLatestSatelliteCommunicationAllowedSetTime;
@@ -262,6 +268,44 @@
mConfigUpdaterMetricsStats = ConfigUpdaterMetricsStats.getOrCreateInstance();
+ mInternalSatelliteSupportedStateCallback = new ISatelliteSupportedStateCallback.Stub() {
+ @Override
+ public void onSatelliteSupportedStateChanged(boolean isSupported) {
+ logd("onSatelliteSupportedStateChanged: isSupported=" + isSupported);
+ if (isSupported) {
+ requestIsCommunicationAllowedForCurrentLocation(
+ SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, new ResultReceiver(null) {
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle resultData) {
+ // do nothing
+ }
+ });
+ }
+ }
+ };
+ mSatelliteController.registerForSatelliteSupportedStateChanged(
+ SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
+ mInternalSatelliteSupportedStateCallback);
+
+ mInternalSatelliteProvisionStateCallback = new ISatelliteProvisionStateCallback.Stub() {
+ @Override
+ public void onSatelliteProvisionStateChanged(boolean isProvisioned) {
+ logd("onSatelliteProvisionStateChanged: isProvisioned=" + isProvisioned);
+ if (isProvisioned) {
+ requestIsCommunicationAllowedForCurrentLocation(
+ SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, new ResultReceiver(null) {
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle resultData) {
+ // do nothing
+ }
+ });
+ }
+ }
+ };
+ mSatelliteController.registerForSatelliteProvisionStateChanged(
+ SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
+ mInternalSatelliteProvisionStateCallback);
+
// Init the SatelliteOnDeviceAccessController so that the S2 level can be cached
initSatelliteOnDeviceAccessController();
}
@@ -877,7 +921,7 @@
private boolean isCommunicationAllowedCacheValid() {
if (mLatestSatelliteCommunicationAllowedSetTime > 0) {
long currentTime = SystemClock.elapsedRealtimeNanos();
- if ((currentTime - mLatestSatelliteCommunicationAllowedSetTime) <= NANOS_IN_DAY) {
+ if ((currentTime - mLatestSatelliteCommunicationAllowedSetTime) <= NANOS_IN_12_HOURS) {
logv("isCommunicationAllowedCacheValid: cache is valid");
return true;
}