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