Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.systemui.pip.phone; |
| 18 | |
Sudheer Shanka | dc589ac | 2016-11-10 15:30:17 -0800 | [diff] [blame^] | 19 | import android.app.ActivityManager; |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 20 | import android.app.IActivityManager; |
| 21 | import android.content.Context; |
| 22 | import android.view.IWindowManager; |
| 23 | import android.view.WindowManagerGlobal; |
| 24 | |
| 25 | /** |
| 26 | * Manages the picture-in-picture (PIP) UI and states for Phones. |
| 27 | */ |
| 28 | public 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 Chung | 15504af | 2016-11-02 18:11:36 -0700 | [diff] [blame] | 37 | private PipMenuActivityController mMenuController; |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 38 | private PipTouchHandler mTouchHandler; |
| 39 | |
| 40 | private PipManager() {} |
| 41 | |
| 42 | /** |
| 43 | * Initializes {@link PipManager}. |
| 44 | */ |
| 45 | public void initialize(Context context) { |
| 46 | mContext = context; |
Sudheer Shanka | dc589ac | 2016-11-10 15:30:17 -0800 | [diff] [blame^] | 47 | mActivityManager = ActivityManager.getService(); |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 48 | mWindowManager = WindowManagerGlobal.getWindowManagerService(); |
| 49 | |
Winson Chung | 15504af | 2016-11-02 18:11:36 -0700 | [diff] [blame] | 50 | mMenuController = new PipMenuActivityController(context, mActivityManager, mWindowManager); |
| 51 | mTouchHandler = new PipTouchHandler(context, mMenuController, mActivityManager, |
| 52 | mWindowManager); |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Updates the PIP per configuration changed. |
| 57 | */ |
Winson Chung | 303c6b7 | 2016-10-24 17:12:49 -0700 | [diff] [blame] | 58 | public void onConfigurationChanged() { |
| 59 | mTouchHandler.onConfigurationChanged(); |
| 60 | } |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 61 | |
| 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 | } |