1 /*
2  * Copyright (C) 2014 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.systemui.recents;
18 
19 import android.content.Context;
20 
21 import com.android.systemui.recents.events.EventBus;
22 import com.android.systemui.recents.events.activity.DebugFlagsChangedEvent;
23 import com.android.systemui.recents.misc.SystemServicesProxy;
24 import com.android.systemui.tuner.TunerService;
25 
26 /**
27  * Tunable debug flags
28  */
29 public class RecentsDebugFlags implements TunerService.Tunable {
30 
31     public static class Static {
32         // Enables debug drawing for the transition thumbnail
33         public static final boolean EnableTransitionThumbnailDebugMode = false;
34         // This disables the bitmap and icon caches
35         public static final boolean DisableBackgroundCache = false;
36         // Enables the task affiliations
37         public static final boolean EnableAffiliatedTaskGroups = false;
38         // Enables the button above the stack
39         public static final boolean EnableStackActionButton = true;
40         // Overrides the Tuner flags and enables the timeout
41         private static final boolean EnableFastToggleTimeout = false;
42         // Overrides the Tuner flags and enables the paging via the Recents button
43         private static final boolean EnablePaging = false;
44 
45         // Enables us to create mock recents tasks
46         public static final boolean EnableMockTasks = false;
47         // Defines the number of mock recents packages to create
48         public static final int MockTasksPackageCount = 3;
49         // Defines the number of mock recents tasks to create
50         public static final int MockTaskCount = 100;
51         // Enables the simulated task affiliations
52         public static final boolean EnableMockTaskGroups = false;
53         // Defines the number of mock task affiliations per group
54         public static final int MockTaskGroupsTaskCount = 12;
55     }
56 
57     /**
58      * We read the prefs once when we start the activity, then update them as the tuner changes
59      * the flags.
60      */
RecentsDebugFlags(Context context)61     public RecentsDebugFlags(Context context) {
62         // Register all our flags, this will also call onTuningChanged() for each key, which will
63         // initialize the current state of each flag
64     }
65 
66     /**
67      * @return whether we are enabling fast toggling.
68      */
isFastToggleRecentsEnabled()69     public boolean isFastToggleRecentsEnabled() {
70         SystemServicesProxy ssp = Recents.getSystemServices();
71         if (ssp.hasFreeformWorkspaceSupport() || ssp.isTouchExplorationEnabled()) {
72             return false;
73         }
74         return Static.EnableFastToggleTimeout;
75     }
76 
77     /**
78      * @return whether we are enabling paging.
79      */
isPagingEnabled()80     public boolean isPagingEnabled() {
81         return Static.EnablePaging;
82     }
83 
84     @Override
onTuningChanged(String key, String newValue)85     public void onTuningChanged(String key, String newValue) {
86         EventBus.getDefault().send(new DebugFlagsChangedEvent());
87     }
88 }
89