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.safetycenter.ui; 18 19 import android.content.Intent; 20 import android.os.Bundle; 21 import android.permission.PermissionGroupUsage; 22 import android.permission.PermissionManager; 23 24 import androidx.fragment.app.FragmentActivity; 25 26 import com.android.modules.utils.build.SdkLevel; 27 import com.android.permissioncontroller.permission.utils.Utils; 28 29 /** Activity for the Safety Center Quick Settings Activity */ 30 public class SafetyCenterQsActivity extends FragmentActivity { 31 32 @Override 33 @SuppressWarnings("NewApi") onCreate(Bundle savedInstanceState)34 protected void onCreate(Bundle savedInstanceState) { 35 super.onCreate(savedInstanceState); 36 37 if (!SdkLevel.isAtLeastT()) { 38 finish(); 39 return; 40 } 41 42 configureFragment(); 43 } 44 45 @Override onNewIntent(Intent intent)46 protected void onNewIntent(Intent intent) { 47 super.onNewIntent(intent); 48 setIntent(intent); 49 configureFragment(); 50 } 51 52 @SuppressWarnings("NewApi") // Before T, activity finishes before this is called configureFragment()53 private void configureFragment() { 54 getSupportFragmentManager() 55 .beginTransaction() 56 .replace( 57 android.R.id.content, 58 SafetyCenterQsFragment.newInstance( 59 Utils.getOrGenerateSessionId(getIntent()), 60 getIntent() 61 .getParcelableArrayListExtra( 62 PermissionManager.EXTRA_PERMISSION_USAGES, 63 PermissionGroupUsage.class))) 64 .commit(); 65 } 66 } 67