Add faster emergency dialer UI
If flag "faster_emergency_phone_call_enabled" is true, EmergencyDialer
will display emergency dialer shortcuts UI. Otherwise, EmergencyDialer
display original dialer UI.
Faster emergency dialer implement the part of user's Emergency
Infomation, and a button which is used to show dialpad.
Test: Manually
Bug: 80406570
Change-Id: I3637dab0059d6fa87417bb282163ebff04eae71d
Merged-In: I3637dab0059d6fa87417bb282163ebff04eae71d
diff --git a/src/com/android/phone/EmergencyActionGroup.java b/src/com/android/phone/EmergencyActionGroup.java
index b647623..d72c265 100644
--- a/src/com/android/phone/EmergencyActionGroup.java
+++ b/src/com/android/phone/EmergencyActionGroup.java
@@ -22,11 +22,7 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
-import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.Layout;
import android.text.TextUtils;
@@ -125,15 +121,13 @@
mPendingTouchEvent = null;
}
-
-
private void setupAssistActions() {
int[] buttonIds = new int[] {R.id.action1, R.id.action2, R.id.action3};
List<ResolveInfo> infos;
if (TelephonyManager.EMERGENCY_ASSISTANCE_ENABLED) {
- infos = resolveAssistPackageAndQueryActivites();
+ infos = EmergencyAssistanceHelper.resolveAssistPackageAndQueryActivities(getContext());
} else {
infos = null;
}
@@ -146,7 +140,7 @@
if (infos != null && infos.size() > i && infos.get(i) != null) {
ResolveInfo info = infos.get(i);
- ComponentName name = getComponentName(info);
+ ComponentName name = EmergencyAssistanceHelper.getComponentName(info);
button.setTag(R.id.tag_intent,
new Intent(TelephonyManager.ACTION_EMERGENCY_ASSISTANCE)
@@ -159,69 +153,6 @@
}
}
- private List<ResolveInfo> resolveAssistPackageAndQueryActivites() {
- List<ResolveInfo> infos = queryAssistActivities();
-
- if (infos == null || infos.isEmpty()) {
- PackageManager packageManager = getContext().getPackageManager();
- Intent queryIntent = new Intent(TelephonyManager.ACTION_EMERGENCY_ASSISTANCE);
- infos = packageManager.queryIntentActivities(queryIntent, 0);
-
- PackageInfo bestMatch = null;
- for (int i = 0; i < infos.size(); i++) {
- if (infos.get(i).activityInfo == null) continue;
- String packageName = infos.get(i).activityInfo.packageName;
- PackageInfo packageInfo;
- try {
- packageInfo = packageManager.getPackageInfo(packageName, 0);
- } catch (PackageManager.NameNotFoundException e) {
- continue;
- }
- // Get earliest installed system app.
- if (isSystemApp(packageInfo) && (bestMatch == null ||
- bestMatch.firstInstallTime > packageInfo.firstInstallTime)) {
- bestMatch = packageInfo;
- }
- }
-
- if (bestMatch != null) {
- Settings.Secure.putString(getContext().getContentResolver(),
- Settings.Secure.EMERGENCY_ASSISTANCE_APPLICATION,
- bestMatch.packageName);
- return queryAssistActivities();
- } else {
- return null;
- }
- } else {
- return infos;
- }
- }
-
- private List<ResolveInfo> queryAssistActivities() {
- String assistPackage = Settings.Secure.getString(
- getContext().getContentResolver(),
- Settings.Secure.EMERGENCY_ASSISTANCE_APPLICATION);
- List<ResolveInfo> infos = null;
-
- if (!TextUtils.isEmpty(assistPackage)) {
- Intent queryIntent = new Intent(TelephonyManager.ACTION_EMERGENCY_ASSISTANCE)
- .setPackage(assistPackage);
- infos = getContext().getPackageManager().queryIntentActivities(queryIntent, 0);
- }
- return infos;
- }
-
- private boolean isSystemApp(PackageInfo info) {
- return info.applicationInfo != null
- && (info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
- }
-
- private ComponentName getComponentName(ResolveInfo resolveInfo) {
- if (resolveInfo == null || resolveInfo.activityInfo == null) return null;
- return new ComponentName(resolveInfo.activityInfo.packageName,
- resolveInfo.activityInfo.name);
- }
-
@Override
public void onClick(View v) {
Intent intent = (Intent) v.getTag(R.id.tag_intent);
@@ -405,6 +336,4 @@
startRipple();
}
};
-
-
}