Link overlay emergency app by feature flag

Add feature flag to link overlay emergency app instead of Emergency Info
app for teamfood in the future.

Test: Manually
Bug: 118809382
Change-Id: I7956704b9d134647cc0a1a5975a0bf8bea482422
diff --git a/res/values/config.xml b/res/values/config.xml
index d487f46..917f14d 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -150,4 +150,14 @@
     <string name="config_settingsintelligence_package_name" translatable="false">
         com.android.settings.intelligence
     </string>
+
+    <!-- Emergency app package name -->
+    <string name="config_emergency_package_name" translatable="false">
+        com.android.emergency
+    </string>
+    <!-- Emergency app intent action -->
+    <string name="config_emergency_intent_action" translatable="false">
+        android.settings.EDIT_EMERGENCY_INFO
+    </string>
+
 </resources>
diff --git a/src/com/android/settings/accounts/EmergencyInfoPreferenceController.java b/src/com/android/settings/accounts/EmergencyInfoPreferenceController.java
index 31e5613..408db09 100644
--- a/src/com/android/settings/accounts/EmergencyInfoPreferenceController.java
+++ b/src/com/android/settings/accounts/EmergencyInfoPreferenceController.java
@@ -22,6 +22,7 @@
 import android.content.res.Resources;
 import android.os.UserHandle;
 import android.os.UserManager;
+import android.util.FeatureFlagUtils;
 
 import androidx.preference.Preference;
 
@@ -63,7 +64,7 @@
     @Override
     public boolean handlePreferenceTreeClick(Preference preference) {
         if (KEY_EMERGENCY_INFO.equals(preference.getKey())) {
-            Intent intent = new Intent(ACTION_EDIT_EMERGENCY_INFO);
+            Intent intent = new Intent(getIntentAction(mContext));
             intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
             mContext.startActivity(intent);
             return true;
@@ -73,7 +74,7 @@
 
     @Override
     public boolean isAvailable() {
-        Intent intent = new Intent(ACTION_EDIT_EMERGENCY_INFO).setPackage(PACKAGE_NAME_EMERGENCY);
+        Intent intent = new Intent(getIntentAction(mContext)).setPackage(getPackageName(mContext));
         List<ResolveInfo> infos = mContext.getPackageManager().queryIntentActivities(intent, 0);
         return infos != null && !infos.isEmpty();
     }
@@ -82,4 +83,20 @@
     public String getPreferenceKey() {
         return KEY_EMERGENCY_INFO;
     }
+
+    private String getIntentAction(Context context) {
+        if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SAFETY_HUB)) {
+            return context.getResources().getString(R.string.config_emergency_intent_action);
+        }
+
+        return ACTION_EDIT_EMERGENCY_INFO;
+    }
+
+    private String getPackageName(Context context) {
+        if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SAFETY_HUB)) {
+            return context.getResources().getString(R.string.config_emergency_package_name);
+        }
+
+        return PACKAGE_NAME_EMERGENCY;
+    }
 }