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