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/res/values/config.xml b/res/values/config.xml
index 5ad369f..38a0b18 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -247,4 +247,7 @@
When this is true, the Telephony stack is able to add additional audio to the outgoing
audio stream which the remote party will be able to hear. -->
<bool name="config_support_telephony_audio_device">false</bool>
+
+ <!-- Intent action to launch target emergency app. -->
+ <string name="config_emergency_app_intent"></string>
</resources>
diff --git a/src/com/android/phone/EmergencyActionGroup.java b/src/com/android/phone/EmergencyActionGroup.java
index d72c265..4f9121a 100644
--- a/src/com/android/phone/EmergencyActionGroup.java
+++ b/src/com/android/phone/EmergencyActionGroup.java
@@ -143,7 +143,7 @@
ComponentName name = EmergencyAssistanceHelper.getComponentName(info);
button.setTag(R.id.tag_intent,
- new Intent(TelephonyManager.ACTION_EMERGENCY_ASSISTANCE)
+ new Intent(EmergencyAssistanceHelper.getIntentAction(getContext()))
.setComponent(name));
button.setText(info.loadLabel(getContext().getPackageManager()));
visible = true;
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);
}
diff --git a/src/com/android/phone/EmergencyInfoGroup.java b/src/com/android/phone/EmergencyInfoGroup.java
index 5c01834..6ce10aa 100644
--- a/src/com/android/phone/EmergencyInfoGroup.java
+++ b/src/com/android/phone/EmergencyInfoGroup.java
@@ -126,7 +126,8 @@
if (infos != null && infos.size() > 0) {
final String packageName = infos.get(0).activityInfo.packageName;
- final Intent intent = new Intent(TelephonyManager.ACTION_EMERGENCY_ASSISTANCE)
+ final Intent intent = new Intent(
+ EmergencyAssistanceHelper.getIntentAction(getContext()))
.setPackage(packageName);
setTag(R.id.tag_intent, intent);
setUserIcon();