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.role.ui;
18 
19 import android.os.Bundle;
20 import android.view.WindowManager;
21 
22 import androidx.annotation.Nullable;
23 import androidx.fragment.app.Fragment;
24 import androidx.fragment.app.FragmentActivity;
25 
26 import com.android.packageinstaller.DeviceUtils;
27 import com.android.packageinstaller.role.ui.auto.AutoSpecialAppAccessListFragment;
28 import com.android.packageinstaller.role.ui.handheld.HandheldSpecialAppAccessListFragment;
29 import com.android.permissioncontroller.R;
30 
31 /**
32  * Activity for the list of special app accesses.
33  */
34 public class SpecialAppAccessListActivity extends FragmentActivity {
35 
36     @Override
onCreate(@ullable Bundle savedInstanceState)37     protected void onCreate(@Nullable Bundle savedInstanceState) {
38         if (DeviceUtils.isAuto(this)) {
39             // Automotive relies on a different theme. Apply before calling super so that
40             // fragments are restored properly on configuration changes.
41             setTheme(R.style.CarSettings);
42         }
43         super.onCreate(savedInstanceState);
44 
45         getWindow().addSystemFlags(
46                 WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
47 
48         if (savedInstanceState == null) {
49             Fragment fragment;
50             if (DeviceUtils.isAuto(this)) {
51                 fragment = AutoSpecialAppAccessListFragment.newInstance();
52             } else {
53                 fragment = HandheldSpecialAppAccessListFragment.newInstance();
54             }
55             getSupportFragmentManager().beginTransaction()
56                     .add(android.R.id.content, fragment)
57                     .commit();
58         }
59     }
60 }
61