1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.emergency.action;
18 
19 import android.content.ContentResolver;
20 import android.content.Context;
21 import android.net.Uri;
22 
23 /**
24  * Util to for emergency action handling
25  */
26 public class EmergencyActionUtils {
27 
28     private static final Uri EMERGENCY_ACTION_AUTHORITY = new Uri.Builder().scheme(
29             ContentResolver.SCHEME_CONTENT)
30             .authority("com.android.settings.emergency")
31             .build();
32     private static final String ACTION_START_EMERGENCY_CALL =
33             "com.android.settings.emergency.MAKE_EMERGENCY_CALL";
34 
35     /**
36      * Triggers the action to place emergency call
37      */
placeEmergencyCall(Context context)38     public static void placeEmergencyCall(Context context) {
39         context.getContentResolver().call(EMERGENCY_ACTION_AUTHORITY,
40                 ACTION_START_EMERGENCY_CALL, null, null);
41     }
42 
isDefaultEmergencyGestureEnabled(Context context)43     public static boolean isDefaultEmergencyGestureEnabled(Context context) {
44         return context.getResources().getBoolean(
45                 com.android.internal.R.bool.config_defaultEmergencyGestureEnabled);
46     }
47 
isDefaultEmergencyGestureSoundEnabled(Context context)48     public static boolean isDefaultEmergencyGestureSoundEnabled(Context context) {
49         return context.getResources().getBoolean(
50                 com.android.internal.R.bool.config_defaultEmergencyGestureSoundEnabled);
51     }
52 }
53