• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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 static com.android.settingslib.emergencynumber.EmergencyNumberUtils.EMERGENCY_SETTING_ON;
20 import static com.android.settingslib.emergencynumber.EmergencyNumberUtils.EMERGENCY_SETTING_OFF;
21 
22 import android.annotation.Nullable;
23 import android.os.Bundle;
24 import android.provider.Settings;
25 import android.support.v4.app.FragmentActivity;
26 import android.util.Log;
27 import android.view.WindowInsets;
28 import android.view.WindowInsetsController;
29 
30 import com.android.emergency.action.EmergencyActionUtils;
31 import com.android.emergency.action.R;
32 
33 /**
34  * Activity for handling emergency action.
35  */
36 public class EmergencyActionActivity extends FragmentActivity {
37 
38     private static final String TAG = "EmergencyAction";
39 
40     @Override
onCreate(@ullable Bundle savedInstanceState)41     protected void onCreate(@Nullable Bundle savedInstanceState) {
42         super.onCreate(savedInstanceState);
43         setContentView(R.layout.emergency_action_activity);
44         if (Settings.Secure.getInt(getContentResolver(),
45                 Settings.Secure.EMERGENCY_GESTURE_ENABLED,
46                 EmergencyActionUtils.isDefaultEmergencyGestureEnabled(this) ?
47                         EMERGENCY_SETTING_ON : EMERGENCY_SETTING_OFF)
48                 != EMERGENCY_SETTING_ON) {
49             Log.w(TAG, "Emergency gesture is not enabled, exiting");
50             finish();
51             return;
52         }
53         getWindow().setDecorFitsSystemWindows(false);
54         WindowInsetsController controller = getWindow().getInsetsController();
55         if (controller != null) {
56             controller.hide(WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars());
57             controller.setSystemBarsBehavior(
58                     WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
59         }
60 
61         if (savedInstanceState == null) {
62             EmergencyActionFragment albumFragment = new EmergencyActionFragment();
63             getSupportFragmentManager().beginTransaction().add(android.R.id.content,
64                     albumFragment).commit();
65         }
66     }
67 
68     @Override
onBackPressed()69     public void onBackPressed() {
70         Log.i(TAG, "Not responding to back press intentionally");
71     }
72 }
73