blob: 7b8d27eef8b41cc50a1adc6a622646aeddb1ba47 [file] [log] [blame]
Winson73bc1592016-10-18 18:47:43 -07001/*
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
17package com.android.systemui.pip.phone;
18
19import android.app.ActivityManagerNative;
20import android.app.IActivityManager;
21import android.content.Context;
22import android.view.IWindowManager;
23import android.view.WindowManagerGlobal;
24
25/**
26 * Manages the picture-in-picture (PIP) UI and states for Phones.
27 */
28public class PipManager {
29 private static final String TAG = "PipManager";
30
31 private static PipManager sPipController;
32
33 private Context mContext;
34 private IActivityManager mActivityManager;
35 private IWindowManager mWindowManager;
36
Winson Chung15504af2016-11-02 18:11:36 -070037 private PipMenuActivityController mMenuController;
Winson73bc1592016-10-18 18:47:43 -070038 private PipTouchHandler mTouchHandler;
39
40 private PipManager() {}
41
42 /**
43 * Initializes {@link PipManager}.
44 */
45 public void initialize(Context context) {
46 mContext = context;
47 mActivityManager = ActivityManagerNative.getDefault();
48 mWindowManager = WindowManagerGlobal.getWindowManagerService();
49
Winson Chung15504af2016-11-02 18:11:36 -070050 mMenuController = new PipMenuActivityController(context, mActivityManager, mWindowManager);
51 mTouchHandler = new PipTouchHandler(context, mMenuController, mActivityManager,
52 mWindowManager);
Winson73bc1592016-10-18 18:47:43 -070053 }
54
55 /**
56 * Updates the PIP per configuration changed.
57 */
Winson Chung303c6b72016-10-24 17:12:49 -070058 public void onConfigurationChanged() {
59 mTouchHandler.onConfigurationChanged();
60 }
Winson73bc1592016-10-18 18:47:43 -070061
62 /**
63 * Gets an instance of {@link PipManager}.
64 */
65 public static PipManager getInstance() {
66 if (sPipController == null) {
67 sPipController = new PipManager();
68 }
69 return sPipController;
70 }
71}