1 /*
2  * Copyright (C) 2016 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 package com.android.documentsui.base;
17 
18 import android.content.ContentResolver;
19 import android.os.Bundle;
20 
21 import com.android.documentsui.queries.CommandInterceptor;
22 
23 import javax.annotation.Nullable;
24 
25 /**
26  * Shared values that may be set by {@link CommandInterceptor}.
27  */
28 public final class DebugFlags {
29 
DebugFlags()30     private DebugFlags() {}
31 
32     private static String sQvPackage;
33     private static boolean sDocumentDetailsEnabled;
34     private static int sForcedPageOffset = -1;
35     private static int sForcedPageLimit = -1;
36 
setQuickViewer(@ullable String qvPackage)37     public static void setQuickViewer(@Nullable String qvPackage) {
38         sQvPackage = qvPackage;
39     }
40 
getQuickViewer()41     public static @Nullable String getQuickViewer() {
42         return sQvPackage;
43     }
44 
setDocumentDetailsEnabled(boolean enabled)45     public static void setDocumentDetailsEnabled(boolean enabled) {
46         sDocumentDetailsEnabled = enabled;
47     }
48 
getDocumentDetailsEnabled()49     public static boolean getDocumentDetailsEnabled() {
50         return sDocumentDetailsEnabled;
51     }
52 
setForcedPaging(int offset, int limit)53     public static void setForcedPaging(int offset, int limit) {
54         sForcedPageOffset = offset;
55         sForcedPageLimit = limit;
56     }
57 
addForcedPagingArgs(Bundle queryArgs)58     public static boolean addForcedPagingArgs(Bundle queryArgs) {
59         boolean flagsAdded = false;
60         if (sForcedPageOffset >= 0) {
61             queryArgs.putInt(ContentResolver.QUERY_ARG_OFFSET, sForcedPageOffset);
62             flagsAdded |= true;
63         }
64         if (sForcedPageLimit >= 0) {
65             queryArgs.putInt(ContentResolver.QUERY_ARG_LIMIT, sForcedPageLimit);
66             flagsAdded |= true;
67         }
68         return flagsAdded;
69     }
70 }
71