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