Launch overlay emergency app by feature flag
Add feature flag to launch overlay emergency app instead of Emergency Info
app for teamfood in the future.
Test: Manually
Bug: 118809382
Change-Id: I618f7aafe0c3896adcd072f5b254d03936e83c16
diff --git a/src/com/android/phone/EmergencyAssistanceHelper.java b/src/com/android/phone/EmergencyAssistanceHelper.java
index 3053125..9e1ac21 100644
--- a/src/com/android/phone/EmergencyAssistanceHelper.java
+++ b/src/com/android/phone/EmergencyAssistanceHelper.java
@@ -26,6 +26,7 @@
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
+import android.util.FeatureFlagUtils;
import java.util.List;
@@ -35,6 +36,24 @@
public class EmergencyAssistanceHelper {
/**
+ * Get intent action of target emergency app.
+ *
+ * @param context The context of the application.
+ * @return A string of intent action to launch target emergency app by feature flag, it will be
+ * used for team food.
+ */
+ public static String getIntentAction(Context context) {
+ if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SAFETY_HUB)) {
+ String action = context.getResources().getString(R.string.config_emergency_app_intent);
+ if (!action.isEmpty()) {
+ return action;
+ }
+ }
+
+ return TelephonyManager.ACTION_EMERGENCY_ASSISTANCE;
+ }
+
+ /**
* Query activities of emergency assistance.
*
* @param context The context of the application.
@@ -46,7 +65,7 @@
if (infos == null || infos.isEmpty()) {
PackageManager packageManager = context.getPackageManager();
- Intent queryIntent = new Intent(TelephonyManager.ACTION_EMERGENCY_ASSISTANCE);
+ Intent queryIntent = new Intent(getIntentAction(context));
infos = packageManager.queryIntentActivities(queryIntent, 0);
PackageInfo bestMatch = null;
@@ -93,7 +112,7 @@
List<ResolveInfo> infos = null;
if (!TextUtils.isEmpty(assistPackage)) {
- Intent queryIntent = new Intent(TelephonyManager.ACTION_EMERGENCY_ASSISTANCE)
+ Intent queryIntent = new Intent(getIntentAction(context))
.setPackage(assistPackage);
infos = context.getPackageManager().queryIntentActivities(queryIntent, 0);
}