blob: f9a4f7ced6cc60bb1312e1dacf41b78cecfcf9fe [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
37 private PipTouchHandler mTouchHandler;
38
39 private PipManager() {}
40
41 /**
42 * Initializes {@link PipManager}.
43 */
44 public void initialize(Context context) {
45 mContext = context;
46 mActivityManager = ActivityManagerNative.getDefault();
47 mWindowManager = WindowManagerGlobal.getWindowManagerService();
48
49 mTouchHandler = new PipTouchHandler(context, mActivityManager, mWindowManager);
50 }
51
52 /**
53 * Updates the PIP per configuration changed.
54 */
Winson Chung303c6b72016-10-24 17:12:49 -070055 public void onConfigurationChanged() {
56 mTouchHandler.onConfigurationChanged();
57 }
Winson73bc1592016-10-18 18:47:43 -070058
59 /**
60 * Gets an instance of {@link PipManager}.
61 */
62 public static PipManager getInstance() {
63 if (sPipController == null) {
64 sPipController = new PipManager();
65 }
66 return sPipController;
67 }
68}