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.handheld.v31; 18 19 import static com.android.permissioncontroller.Constants.EXTRA_SESSION_ID; 20 21 import android.content.Intent; 22 import android.os.Build; 23 import android.os.Bundle; 24 25 import androidx.annotation.NonNull; 26 import androidx.annotation.Nullable; 27 import androidx.annotation.RequiresApi; 28 import androidx.preference.PreferenceFragmentCompat; 29 30 import com.android.permissioncontroller.permission.ui.ManagePermissionsActivity; 31 import com.android.permissioncontroller.permission.ui.handheld.PermissionsCollapsingToolbarBaseFragment; 32 33 /** 34 * Wrapper over PermissionDetailsFragment 35 */ 36 @RequiresApi(Build.VERSION_CODES.S) 37 public class PermissionDetailsWrapperFragment extends PermissionsCollapsingToolbarBaseFragment { 38 @NonNull 39 @Override createPreferenceFragment()40 public PreferenceFragmentCompat createPreferenceFragment() { 41 return new PermissionUsageDetailsFragment(); 42 } 43 44 /** 45 * Construct a new instance of PermissionDetailsFragment 46 */ newInstance(@ullable String groupName, long numMillis, boolean showSystem, long sessionId, boolean show7Days)47 public static @NonNull PermissionDetailsWrapperFragment newInstance(@Nullable String groupName, 48 long numMillis, boolean showSystem, long sessionId, boolean show7Days) { 49 PermissionDetailsWrapperFragment fragment = new PermissionDetailsWrapperFragment(); 50 Bundle arguments = new Bundle(); 51 if (groupName != null) { 52 arguments.putString(Intent.EXTRA_PERMISSION_GROUP_NAME, groupName); 53 } 54 arguments.putLong(Intent.EXTRA_DURATION_MILLIS, numMillis); 55 arguments.putBoolean(ManagePermissionsActivity.EXTRA_SHOW_SYSTEM, showSystem); 56 arguments.putBoolean(ManagePermissionsActivity.EXTRA_SHOW_7_DAYS, show7Days); 57 arguments.putLong(EXTRA_SESSION_ID, sessionId); 58 fragment.setArguments(arguments); 59 return fragment; 60 } 61 } 62