1 /* 2 * Copyright (C) 2015 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.tv.ui; 18 19 import android.content.Context; 20 import android.media.tv.TvView; 21 import android.util.AttributeSet; 22 import android.view.SurfaceView; 23 import android.view.View; 24 25 import com.android.tv.experiments.Experiments; 26 27 /** 28 * A TvView class for application layer when multiple windows are being used in the app. 29 * <p> 30 * Once an app starts using additional window like SubPanel and it gets window focus, the 31 * {@link android.media.tv.TvView#setMain()} does not work because its implementation assumes that 32 * the app uses only application layer. 33 * TODO: remove this class once the TvView.setMain() is revisited. 34 * </p> 35 */ 36 public class AppLayerTvView extends TvView { 37 public AppLayerTvView(Context context) { 38 super(context); 39 } 40 41 public AppLayerTvView(Context context, AttributeSet attrs) { 42 super(context, attrs); 43 } 44 45 public AppLayerTvView(Context context, AttributeSet attrs, int defStyleAttr) { 46 super(context, attrs, defStyleAttr); 47 } 48 49 @Override 50 public boolean hasWindowFocus() { 51 return true; 52 } 53 54 @Override 55 public void onViewAdded(View child) { 56 if (child instanceof SurfaceView) { 57 // Note: See b/29118070 for detail. 58 ((SurfaceView) child).setSecure(!Experiments.ENABLE_DEVELOPER_FEATURES.get()); 59 } 60 super.onViewAdded(child); 61 } 62 } 63