• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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.permission.ui;
18 
19 import static com.android.permissioncontroller.Constants.INVALID_SESSION_ID;
20 
21 import android.os.Bundle;
22 import android.permission.PermissionGroupUsage;
23 import android.permission.PermissionManager;
24 
25 import androidx.fragment.app.FragmentActivity;
26 
27 import com.android.modules.utils.build.SdkLevel;
28 import com.android.permissioncontroller.Constants;
29 import com.android.permissioncontroller.permission.ui.handheld.v33.SafetyCenterQsFragment;
30 
31 import java.util.ArrayList;
32 import java.util.Random;
33 
34 /**
35  * Activity for the Safety Center Quick Settings Activity
36  */
37 public class SafetyCenterQsActivity extends FragmentActivity {
38 
39     @Override
40     @SuppressWarnings("NewApi")
onCreate(Bundle savedInstanceState)41     protected void onCreate(Bundle savedInstanceState) {
42         super.onCreate(savedInstanceState);
43 
44         if (!SdkLevel.isAtLeastT()) {
45             finish();
46             return;
47         }
48 
49         long sessionId = getIntent().getLongExtra(Constants.EXTRA_SESSION_ID, INVALID_SESSION_ID);
50         while (sessionId == INVALID_SESSION_ID) {
51             sessionId = new Random().nextLong();
52         }
53         ArrayList<PermissionGroupUsage> permissionUsages = getIntent().getParcelableArrayListExtra(
54                 PermissionManager.EXTRA_PERMISSION_USAGES);
55         getSupportFragmentManager().beginTransaction().replace(android.R.id.content,
56                 SafetyCenterQsFragment.newInstance(sessionId, permissionUsages)).commit();
57     }
58 }
59