Merge "Simplify eSOS platform setting summary."
This commit is contained in:
committed by
Android (Google) Code Review
commit
fd6e5e6d4e
@@ -11986,9 +11986,6 @@
|
||||
<!-- Preference title to enable feature for calling emergency services at panic/distress moments[CHAR_LIMIT=60]-->
|
||||
<string name="emergency_gesture_switchbar_title">Use Emergency SOS</string>
|
||||
|
||||
<!-- Preference summary to enable feature for calling emergency services at panic/distress moments[CHAR_LIMIT=60]-->
|
||||
<string name="emergency_gesture_entrypoint_summary">Managed by <xliff:g id="app_name" example="Emergency Info">%1$s</xliff:g></string>
|
||||
|
||||
<!-- Preference summary to enable feature for calling emergency services at panic/distress moments[CHAR_LIMIT=NONE]-->
|
||||
<string name="emergency_gesture_screen_summary">Press the Power button quickly 5 times or more to start the actions below</string>
|
||||
|
||||
|
@@ -18,23 +18,20 @@ package com.android.settings.emergency;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.emergencynumber.EmergencyNumberUtils;
|
||||
|
||||
/**
|
||||
* Preference controller for emergency gesture setting's entyrpoint preference
|
||||
*/
|
||||
public class EmergencyGestureEntrypointPreferenceController extends BasePreferenceController {
|
||||
private static final String TAG = "EmergencyGestureEntry";
|
||||
|
||||
@VisibleForTesting
|
||||
static final String ACTION_EMERGENCY_GESTURE_SETTINGS =
|
||||
@@ -42,10 +39,12 @@ public class EmergencyGestureEntrypointPreferenceController extends BasePreferen
|
||||
@VisibleForTesting
|
||||
Intent mIntent;
|
||||
|
||||
private final EmergencyNumberUtils mEmergencyNumberUtils;
|
||||
private boolean mUseCustomIntent;
|
||||
|
||||
public EmergencyGestureEntrypointPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mEmergencyNumberUtils = new EmergencyNumberUtils(context);
|
||||
final String emergencyGestureSettingsPackageName = context.getResources().getString(
|
||||
R.string.emergency_gesture_settings_package);
|
||||
if (!TextUtils.isEmpty(emergencyGestureSettingsPackageName)) {
|
||||
@@ -94,23 +93,10 @@ public class EmergencyGestureEntrypointPreferenceController extends BasePreferen
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
if (mUseCustomIntent) {
|
||||
final String packageName = mContext.getResources().getString(
|
||||
R.string.emergency_gesture_settings_package);
|
||||
try {
|
||||
final PackageManager pm = mContext.getPackageManager();
|
||||
final ApplicationInfo appInfo = pm.getApplicationInfo(
|
||||
packageName, PackageManager.MATCH_DISABLED_COMPONENTS
|
||||
| PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS);
|
||||
return mContext.getString(R.string.emergency_gesture_entrypoint_summary,
|
||||
appInfo.loadLabel(pm));
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "Failed to get custom summary, falling back.");
|
||||
return super.getSummary();
|
||||
}
|
||||
}
|
||||
|
||||
return super.getSummary();
|
||||
return mContext.getText(
|
||||
mEmergencyNumberUtils.getEmergencyGestureEnabled()
|
||||
? R.string.gesture_setting_on
|
||||
: R.string.gesture_setting_off);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user