Add activity expose condition for Satellite messaging activity

In case carrier_enabled_satellite_flag or KEY_SATELLITE_ATTACH_SUPPORTED_BOOL is not supported, activity invocation intent will be ignored.
Because the guidance description of the activity cause misunderstanding to users when the satellite feature is not set properly.

Bug: 338377564
Test: manual test adb shell am start -a "android.settings.SATELLITE_SETTING" --ei sub_id (test sub id) for each key's enable/disable combination for KEY_SATELLITE_ATTACH_SUPPORTED_BOOL and carrier_enabled_satellite_flag
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:308ced3fc8e69378611ce333ed5f0e8337ff91fe)
Change-Id: Ib5401f433f802e7aa74cc175179776deb576edfc
This commit is contained in:
Hakjun Choi
2024-05-02 12:57:16 +00:00
parent a719e78a4c
commit 2bc6d77cbf

View File

@@ -16,6 +16,7 @@
package com.android.settings.network.telephony;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_INFORMATION_REDIRECT_URL_STRING;
import android.app.Activity;
@@ -43,6 +44,7 @@ import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import com.android.internal.telephony.flags.Flags;
import com.android.settings.R;
import com.android.settings.dashboard.RestrictedDashboardFragment;
import com.android.settingslib.HelpUtils;
@@ -82,12 +84,27 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
public void onCreate(@NonNull Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// In case carrier roaming satellite is not supported, do nothing.
if (!Flags.carrierEnabledSatelliteFlag()) {
Log.d(TAG, "SatelliteSettings: satellite feature is not supported, do nothing.");
finish();
return;
}
mActivity = getActivity();
mTelephonymanager = mActivity.getSystemService(TelephonyManager.class);
mCarrierConfigManager = mActivity.getSystemService(CarrierConfigManager.class);
mSatelliteManager = mActivity.getSystemService(SatelliteManager.class);
mSubId = mActivity.getIntent().getIntExtra(SUB_ID,
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
mCarrierConfigManager = mActivity.getSystemService(CarrierConfigManager.class);
if (!isSatelliteAttachSupported(mSubId)) {
Log.d(TAG, "SatelliteSettings: KEY_SATELLITE_ATTACH_SUPPORTED_BOOL is false, "
+ "do nothing.");
finish();
return;
}
mTelephonymanager = mActivity.getSystemService(TelephonyManager.class);
mSatelliteManager = mActivity.getSystemService(SatelliteManager.class);
}
@Override
@@ -211,6 +228,16 @@ public class SatelliteSetting extends RestrictedDashboardFragment {
return mConfigBundle.getString(KEY_SATELLITE_INFORMATION_REDIRECT_URL_STRING, "");
}
private boolean isSatelliteAttachSupported(int subId) {
PersistableBundle bundle = mCarrierConfigManager.getConfigForSubId(subId,
KEY_SATELLITE_ATTACH_SUPPORTED_BOOL);
if (bundle.isEmpty()) {
Log.d(TAG, "SatelliteSettings: getDefaultConfig");
bundle = CarrierConfigManager.getDefaultConfig();
}
return bundle.getBoolean(KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, false);
}
private static void loge(String message) {
Log.e(TAG, message);
}