Merge "[Satellite] Satellite UX changes in SIM settings as per new UX design." into main
This commit is contained in:
@@ -18,21 +18,13 @@ package com.android.settings.network.telephony;
|
||||
|
||||
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL;
|
||||
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ESOS_SUPPORTED_BOOL;
|
||||
import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_DATA;
|
||||
import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_SMS;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.PersistableBundle;
|
||||
import android.telephony.TelephonyCallback;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.satellite.NtnSignalStrength;
|
||||
import android.telephony.satellite.SatelliteManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.lifecycle.DefaultLifecycleObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
@@ -40,9 +32,6 @@ import com.android.settings.R;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/** Preference controller for Satellite functions in mobile network settings. */
|
||||
public class SatelliteSettingsPreferenceCategoryController
|
||||
extends TelephonyBasePreferenceController implements DefaultLifecycleObserver {
|
||||
@@ -51,17 +40,11 @@ public class SatelliteSettingsPreferenceCategoryController
|
||||
private CarrierConfigCache mCarrierConfigCache;
|
||||
private SatelliteManager mSatelliteManager;
|
||||
private PreferenceCategory mPreferenceCategory;
|
||||
private TelephonyManager mTelephonyManager;
|
||||
|
||||
@VisibleForTesting
|
||||
final CarrierRoamingNtnModeCallback mCarrierRoamingNtnModeCallback =
|
||||
new CarrierRoamingNtnModeCallback();
|
||||
|
||||
public SatelliteSettingsPreferenceCategoryController(Context context, String key) {
|
||||
super(context, key);
|
||||
mCarrierConfigCache = CarrierConfigCache.getInstance(context);
|
||||
mSatelliteManager = context.getSystemService(SatelliteManager.class);
|
||||
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,13 +55,13 @@ public class SatelliteSettingsPreferenceCategoryController
|
||||
public void init(int subId) {
|
||||
Log.d(TAG, "init(), subId=" + subId);
|
||||
mSubId = subId;
|
||||
mTelephonyManager = mTelephonyManager.createForSubscriptionId(subId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mPreferenceCategory = screen.findPreference(getPreferenceKey());
|
||||
mPreferenceCategory.setTitle(R.string.category_title_satellite_connectivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,58 +86,4 @@ public class SatelliteSettingsPreferenceCategoryController
|
||||
return (isSatelliteAttachSupported || isSatelliteSosSupported)
|
||||
? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(@NonNull LifecycleOwner owner) {
|
||||
if (Flags.satelliteOemSettingsUxMigration()) {
|
||||
mTelephonyManager.registerTelephonyCallback(mContext.getMainExecutor(),
|
||||
mCarrierRoamingNtnModeCallback);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause(@NonNull LifecycleOwner owner) {
|
||||
if (Flags.satelliteOemSettingsUxMigration()) {
|
||||
mTelephonyManager.unregisterTelephonyCallback(mCarrierRoamingNtnModeCallback);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
class CarrierRoamingNtnModeCallback extends TelephonyCallback implements
|
||||
TelephonyCallback.CarrierRoamingNtnListener {
|
||||
@Override
|
||||
public void onCarrierRoamingNtnAvailableServicesChanged(int[] availableServices) {
|
||||
CarrierRoamingNtnListener.super.onCarrierRoamingNtnAvailableServicesChanged(
|
||||
availableServices);
|
||||
List<Integer> availableServicesList = Arrays.stream(availableServices).boxed().toList();
|
||||
boolean isSmsAvailable = availableServicesList.contains(SERVICE_TYPE_SMS);
|
||||
boolean isDataAvailable = availableServicesList.contains(SERVICE_TYPE_DATA);
|
||||
Log.i(TAG, "isSmsAvailable : " + isSmsAvailable
|
||||
+ " / isDataAvailable " + isDataAvailable);
|
||||
if (mPreferenceCategory == null) {
|
||||
Log.d(TAG, "Satellite preference category is not initialized yet");
|
||||
return;
|
||||
}
|
||||
if (isDataAvailable) {
|
||||
mPreferenceCategory.setTitle(R.string.category_title_satellite_connectivity);
|
||||
} else if (isSmsAvailable) {
|
||||
mPreferenceCategory.setTitle(R.string.satellite_setting_title);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarrierRoamingNtnEligibleStateChanged(boolean eligible) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarrierRoamingNtnModeChanged(boolean active) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarrierRoamingNtnSignalStrengthChanged(NtnSignalStrength ntnSignalStrength) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user