Loading core/java/android/provider/Settings.java +7 −0 Original line number Diff line number Diff line Loading @@ -8188,6 +8188,13 @@ public final class Settings { */ public static final String CALL_AUTO_RETRY = "call_auto_retry"; /** * A setting that can be read whether the emergency affordance is currently needed. * The value is a boolean (1 or 0). * @hide */ public static final String EMERGENCY_AFFORDANCE_NEEDED = "emergency_affordance_needed"; /** * See RIL_PreferredNetworkType in ril.h * @hide Loading core/java/com/android/internal/policy/EmergencyAffordanceManager.java 0 → 100644 +101 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.internal.policy; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Build; import android.provider.Settings; /** * A class that manages emergency affordances and enables immediate calling to emergency services */ public class EmergencyAffordanceManager { public static final boolean ENABLED = true; /** * Global setting override with the number to call with the emergency affordance. * @hide */ private static final String EMERGENCY_CALL_NUMBER_SETTING = "emergency_affordance_number"; /** * Global setting, whether the emergency affordance should be shown regardless of device state. * The value is a boolean (1 or 0). * @hide */ private static final String FORCE_EMERGENCY_AFFORDANCE_SETTING = "force_emergency_affordance"; private final Context mContext; public EmergencyAffordanceManager(Context context) { mContext = context; } /** * perform an emergency call. */ public final void performEmergencyCall() { performEmergencyCall(mContext); } private static Uri getPhoneUri(Context context) { String number = context.getResources().getString( com.android.internal.R.string.config_emergency_call_number); if (Build.IS_DEBUGGABLE) { String override = Settings.Global.getString( context.getContentResolver(), EMERGENCY_CALL_NUMBER_SETTING); if (override != null) { number = override; } } return Uri.fromParts("tel", number, null); } private static void performEmergencyCall(Context context) { Intent intent = new Intent(Intent.ACTION_CALL_EMERGENCY); intent.setData(getPhoneUri(context)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } /** * @return whether emergency affordance should be active. */ public boolean needsEmergencyAffordance() { if (!ENABLED) { return false; } if (forceShowing()) { return true; } return isEmergencyAffordanceNeeded(); } private boolean isEmergencyAffordanceNeeded() { return Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.EMERGENCY_AFFORDANCE_NEEDED, 0) != 0; } private boolean forceShowing() { return Settings.Global.getInt(mContext.getContentResolver(), FORCE_EMERGENCY_AFFORDANCE_SETTING, 0) != 0; } } core/res/res/drawable/emergency_icon.xml 0 → 100644 +34 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2016 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24.0dp" android:height="24.0dp" android:viewportWidth="68.0" android:viewportHeight="68.0" android:tint="?attr/colorControlNormal"> <path android:fillColor="#FF000000" android:pathData="M55.2,58.3l-6.3,-7.8C54.0,46.3 57.0,40.1 57.0,33.4c0.0,-6.2 -2.6,-12.1 -7.2,-16.3l6.7,-7.4C63.2,15.8 67.0,24.4 67.0,33.4C67.0,43.1 62.7,52.2 55.2,58.3z"/> <path android:fillColor="#FF000000" android:pathData="M12.9,58.3C5.3,52.2 1.0,43.1 1.0,33.4c0.0,-9.0 3.8,-17.6 10.5,-23.7l6.7,7.4C13.6,21.3 11.0,27.2 11.0,33.4c0.0,6.7 3.0,12.9 8.2,17.1L12.9,58.3z"/> <path android:fillColor="#FF000000" android:pathData="M29.0,11.4l10.0,0.0l0.0,29.0l-10.0,0.0z"/> <path android:fillColor="#FF000000" android:pathData="M29.0,48.4l10.0,0.0l0.0,9.0l-10.0,0.0z"/> </vector> core/res/res/values/config.xml +10 −0 Original line number Diff line number Diff line Loading @@ -2486,4 +2486,14 @@ <string-array translatable="false" name="config_defaultPinnerServiceFiles"> </string-array> <!-- emergency call number for the emergency affordance --> <string name="config_emergency_call_number" translatable="false">112</string> <!-- Do not translate. Mcc codes whose existence trigger the presence of emergency affordances--> <integer-array name="config_emergency_mcc_codes" translatable="false"> <item>404</item> <item>405</item> </integer-array> </resources> core/res/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -482,6 +482,9 @@ <!-- label for item that turns off power in phone options dialog --> <string name="global_action_power_off">Power off</string> <!-- label for item that starts emergency call --> <string name="global_action_emergency">Emergency</string> <!-- label for item that generates a bug report in the phone options dialog --> <string name="global_action_bug_report">Bug report</string> Loading Loading
core/java/android/provider/Settings.java +7 −0 Original line number Diff line number Diff line Loading @@ -8188,6 +8188,13 @@ public final class Settings { */ public static final String CALL_AUTO_RETRY = "call_auto_retry"; /** * A setting that can be read whether the emergency affordance is currently needed. * The value is a boolean (1 or 0). * @hide */ public static final String EMERGENCY_AFFORDANCE_NEEDED = "emergency_affordance_needed"; /** * See RIL_PreferredNetworkType in ril.h * @hide Loading
core/java/com/android/internal/policy/EmergencyAffordanceManager.java 0 → 100644 +101 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.internal.policy; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Build; import android.provider.Settings; /** * A class that manages emergency affordances and enables immediate calling to emergency services */ public class EmergencyAffordanceManager { public static final boolean ENABLED = true; /** * Global setting override with the number to call with the emergency affordance. * @hide */ private static final String EMERGENCY_CALL_NUMBER_SETTING = "emergency_affordance_number"; /** * Global setting, whether the emergency affordance should be shown regardless of device state. * The value is a boolean (1 or 0). * @hide */ private static final String FORCE_EMERGENCY_AFFORDANCE_SETTING = "force_emergency_affordance"; private final Context mContext; public EmergencyAffordanceManager(Context context) { mContext = context; } /** * perform an emergency call. */ public final void performEmergencyCall() { performEmergencyCall(mContext); } private static Uri getPhoneUri(Context context) { String number = context.getResources().getString( com.android.internal.R.string.config_emergency_call_number); if (Build.IS_DEBUGGABLE) { String override = Settings.Global.getString( context.getContentResolver(), EMERGENCY_CALL_NUMBER_SETTING); if (override != null) { number = override; } } return Uri.fromParts("tel", number, null); } private static void performEmergencyCall(Context context) { Intent intent = new Intent(Intent.ACTION_CALL_EMERGENCY); intent.setData(getPhoneUri(context)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } /** * @return whether emergency affordance should be active. */ public boolean needsEmergencyAffordance() { if (!ENABLED) { return false; } if (forceShowing()) { return true; } return isEmergencyAffordanceNeeded(); } private boolean isEmergencyAffordanceNeeded() { return Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.EMERGENCY_AFFORDANCE_NEEDED, 0) != 0; } private boolean forceShowing() { return Settings.Global.getInt(mContext.getContentResolver(), FORCE_EMERGENCY_AFFORDANCE_SETTING, 0) != 0; } }
core/res/res/drawable/emergency_icon.xml 0 → 100644 +34 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2016 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24.0dp" android:height="24.0dp" android:viewportWidth="68.0" android:viewportHeight="68.0" android:tint="?attr/colorControlNormal"> <path android:fillColor="#FF000000" android:pathData="M55.2,58.3l-6.3,-7.8C54.0,46.3 57.0,40.1 57.0,33.4c0.0,-6.2 -2.6,-12.1 -7.2,-16.3l6.7,-7.4C63.2,15.8 67.0,24.4 67.0,33.4C67.0,43.1 62.7,52.2 55.2,58.3z"/> <path android:fillColor="#FF000000" android:pathData="M12.9,58.3C5.3,52.2 1.0,43.1 1.0,33.4c0.0,-9.0 3.8,-17.6 10.5,-23.7l6.7,7.4C13.6,21.3 11.0,27.2 11.0,33.4c0.0,6.7 3.0,12.9 8.2,17.1L12.9,58.3z"/> <path android:fillColor="#FF000000" android:pathData="M29.0,11.4l10.0,0.0l0.0,29.0l-10.0,0.0z"/> <path android:fillColor="#FF000000" android:pathData="M29.0,48.4l10.0,0.0l0.0,9.0l-10.0,0.0z"/> </vector>
core/res/res/values/config.xml +10 −0 Original line number Diff line number Diff line Loading @@ -2486,4 +2486,14 @@ <string-array translatable="false" name="config_defaultPinnerServiceFiles"> </string-array> <!-- emergency call number for the emergency affordance --> <string name="config_emergency_call_number" translatable="false">112</string> <!-- Do not translate. Mcc codes whose existence trigger the presence of emergency affordances--> <integer-array name="config_emergency_mcc_codes" translatable="false"> <item>404</item> <item>405</item> </integer-array> </resources>
core/res/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -482,6 +482,9 @@ <!-- label for item that turns off power in phone options dialog --> <string name="global_action_power_off">Power off</string> <!-- label for item that starts emergency call --> <string name="global_action_emergency">Emergency</string> <!-- label for item that generates a bug report in the phone options dialog --> <string name="global_action_bug_report">Bug report</string> Loading