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]-->
|
<!-- 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>
|
<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]-->
|
<!-- 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>
|
<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.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
import com.android.settingslib.emergencynumber.EmergencyNumberUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preference controller for emergency gesture setting's entyrpoint preference
|
* Preference controller for emergency gesture setting's entyrpoint preference
|
||||||
*/
|
*/
|
||||||
public class EmergencyGestureEntrypointPreferenceController extends BasePreferenceController {
|
public class EmergencyGestureEntrypointPreferenceController extends BasePreferenceController {
|
||||||
private static final String TAG = "EmergencyGestureEntry";
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String ACTION_EMERGENCY_GESTURE_SETTINGS =
|
static final String ACTION_EMERGENCY_GESTURE_SETTINGS =
|
||||||
@@ -42,10 +39,12 @@ public class EmergencyGestureEntrypointPreferenceController extends BasePreferen
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Intent mIntent;
|
Intent mIntent;
|
||||||
|
|
||||||
|
private final EmergencyNumberUtils mEmergencyNumberUtils;
|
||||||
private boolean mUseCustomIntent;
|
private boolean mUseCustomIntent;
|
||||||
|
|
||||||
public EmergencyGestureEntrypointPreferenceController(Context context, String key) {
|
public EmergencyGestureEntrypointPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
|
mEmergencyNumberUtils = new EmergencyNumberUtils(context);
|
||||||
final String emergencyGestureSettingsPackageName = context.getResources().getString(
|
final String emergencyGestureSettingsPackageName = context.getResources().getString(
|
||||||
R.string.emergency_gesture_settings_package);
|
R.string.emergency_gesture_settings_package);
|
||||||
if (!TextUtils.isEmpty(emergencyGestureSettingsPackageName)) {
|
if (!TextUtils.isEmpty(emergencyGestureSettingsPackageName)) {
|
||||||
@@ -94,23 +93,10 @@ public class EmergencyGestureEntrypointPreferenceController extends BasePreferen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary() {
|
public CharSequence getSummary() {
|
||||||
if (mUseCustomIntent) {
|
return mContext.getText(
|
||||||
final String packageName = mContext.getResources().getString(
|
mEmergencyNumberUtils.getEmergencyGestureEnabled()
|
||||||
R.string.emergency_gesture_settings_package);
|
? R.string.gesture_setting_on
|
||||||
try {
|
: R.string.gesture_setting_off);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user