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
17package com.android.systemui.tv.pip;
18
19import android.content.pm.PackageManager;
20import android.content.res.Configuration;
21
22import com.android.systemui.SystemUI;
23
24import static android.content.pm.PackageManager.FEATURE_LEANBACK;
25import static android.content.pm.PackageManager.FEATURE_PICTURE_IN_PICTURE;
26
27/**
28 * Controls the picture-in-picture window for TV devices.
29 */
30public class PipUI extends SystemUI {
31    private boolean mSupportPip;
32
33    @Override
34    public void start() {
35        PackageManager pm = mContext.getPackageManager();
36        mSupportPip = pm.hasSystemFeature(FEATURE_PICTURE_IN_PICTURE)
37                && pm.hasSystemFeature(FEATURE_LEANBACK);
38        if (!mSupportPip) {
39            return;
40        }
41        PipManager pipManager = PipManager.getInstance();
42        pipManager.initialize(mContext);
43    }
44
45    @Override
46    protected void onConfigurationChanged(Configuration newConfig) {
47        super.onConfigurationChanged(newConfig);
48        if (!mSupportPip) {
49            return;
50        }
51        PipManager.getInstance().onConfigurationChanged();
52    }
53}
54