1 /* 2 * Copyright (C) 2019 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.packageinstaller.permission.ui; 18 19 import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; 20 21 import android.os.Bundle; 22 import android.view.MenuItem; 23 24 import androidx.annotation.NonNull; 25 import androidx.fragment.app.FragmentActivity; 26 27 import com.android.packageinstaller.DeviceUtils; 28 import com.android.packageinstaller.permission.ui.handheld.AdjustUserSensitiveFragment; 29 30 /** 31 * Contains a {@link AdjustUserSensitiveFragment}. 32 */ 33 public class AdjustUserSensitiveActivity extends FragmentActivity { 34 @Override onCreate(Bundle savedInstanceState)35 public void onCreate(Bundle savedInstanceState) { 36 super.onCreate(savedInstanceState); 37 38 getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); 39 40 getSupportFragmentManager().beginTransaction().replace(android.R.id.content, 41 AdjustUserSensitiveFragment.newInstance()).commit(); 42 } 43 44 @Override onOptionsItemSelected(@onNull MenuItem item)45 public boolean onOptionsItemSelected(@NonNull MenuItem item) { 46 switch (item.getItemId()) { 47 case android.R.id.home: 48 // in automotive mode, there's no system wide back button, so need to add that 49 if (DeviceUtils.isAuto(this)) { 50 onBackPressed(); 51 } else { 52 finish(); 53 } 54 return true; 55 default: 56 return super.onOptionsItemSelected(item); 57 } 58 } 59 } 60