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.dashboard;
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.handheld.PermissionsCollapsingToolbarBaseFragment;
31 
32 /**
33  * Wrapper over PermissionUsageV2Fragment
34  */
35 @RequiresApi(Build.VERSION_CODES.S)
36 public class PermissionUsageV2WrapperFragment extends PermissionsCollapsingToolbarBaseFragment{
37     @NonNull
38     @Override
createPreferenceFragment()39     public PreferenceFragmentCompat createPreferenceFragment() {
40         return new PermissionUsageV2Fragment();
41     }
42 
43     /**
44      * @return A new fragment
45      */
newInstance(@ullable String groupName, long numMillis, long sessionId)46     public static @NonNull PermissionUsageV2WrapperFragment newInstance(@Nullable String groupName,
47             long numMillis, long sessionId) {
48         PermissionUsageV2WrapperFragment fragment = new PermissionUsageV2WrapperFragment();
49         Bundle arguments = new Bundle();
50         if (groupName != null) {
51             arguments.putString(Intent.EXTRA_PERMISSION_GROUP_NAME, groupName);
52         }
53         arguments.putLong(Intent.EXTRA_DURATION_MILLIS, numMillis);
54         arguments.putLong(EXTRA_SESSION_ID, sessionId);
55         fragment.setArguments(arguments);
56         return fragment;
57     }
58 }
59