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.BroadcastReceiver;
20 import android.content.Context;
21 import android.content.Intent;
22 
23 /**
24  * A proxy for Recents events which happens strictly for non-owner users.
25  */
26 public class RecentsUserEventProxyReceiver extends BroadcastReceiver {
27     final public static String ACTION_PROXY_SHOW_RECENTS_TO_USER =
28             "com.android.systemui.recents.action.SHOW_RECENTS_FOR_USER";
29     final public static String ACTION_PROXY_HIDE_RECENTS_TO_USER =
30             "com.android.systemui.recents.action.HIDE_RECENTS_FOR_USER";
31     final public static String ACTION_PROXY_TOGGLE_RECENTS_TO_USER =
32             "com.android.systemui.recents.action.TOGGLE_RECENTS_FOR_USER";
33     final public static String ACTION_PROXY_PRELOAD_RECENTS_TO_USER =
34             "com.android.systemui.recents.action.PRELOAD_RECENTS_FOR_USER";
35     final public static String ACTION_PROXY_CONFIG_CHANGE_TO_USER =
36             "com.android.systemui.recents.action.CONFIG_CHANGED_FOR_USER";
37 
38     @Override
onReceive(Context context, Intent intent)39     public void onReceive(Context context, Intent intent) {
40         Recents recents = Recents.getInstanceAndStartIfNeeded(context);
41         switch (intent.getAction()) {
42             case ACTION_PROXY_SHOW_RECENTS_TO_USER: {
43                 boolean triggeredFromAltTab = intent.getBooleanExtra(
44                         Recents.EXTRA_TRIGGERED_FROM_ALT_TAB, false);
45                 recents.showRecentsInternal(triggeredFromAltTab);
46                 break;
47             }
48             case ACTION_PROXY_HIDE_RECENTS_TO_USER: {
49                 boolean triggeredFromAltTab = intent.getBooleanExtra(
50                         Recents.EXTRA_TRIGGERED_FROM_ALT_TAB, false);
51                 boolean triggeredFromHome = intent.getBooleanExtra(
52                         Recents.EXTRA_TRIGGERED_FROM_HOME_KEY, false);
53                 recents.hideRecentsInternal(triggeredFromAltTab, triggeredFromHome);
54                 break;
55             }
56             case ACTION_PROXY_TOGGLE_RECENTS_TO_USER:
57                 recents.toggleRecentsInternal();
58                 break;
59             case ACTION_PROXY_PRELOAD_RECENTS_TO_USER:
60                 recents.preloadRecentsInternal();
61                 break;
62             case ACTION_PROXY_CONFIG_CHANGE_TO_USER:
63                 recents.configurationChanged();
64                 break;
65         }
66     }
67 }
68