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.util.AttributeSet; 21 import android.view.SurfaceView; 22 import android.view.View; 23 import com.android.tv.common.compat.TvViewCompat; 24 import com.android.tv.common.util.CommonUtils; 25 import com.android.tv.common.util.Debug; 26 27 /** 28 * A TvView class for application layer when multiple windows are being used in the app. 29 * 30 * <p>Once an app starts using additional window like SubPanel and it gets window focus, the {@link 31 * android.media.tv.TvView#setMain()} does not work because its implementation assumes that the app 32 * uses only application layer. TODO: remove this class once the TvView.setMain() is revisited. 33 */ 34 public class AppLayerTvView extends TvViewCompat { AppLayerTvView(Context context)35 public AppLayerTvView(Context context) { 36 super(context); 37 } 38 AppLayerTvView(Context context, AttributeSet attrs)39 public AppLayerTvView(Context context, AttributeSet attrs) { 40 super(context, attrs); 41 } 42 AppLayerTvView(Context context, AttributeSet attrs, int defStyleAttr)43 public AppLayerTvView(Context context, AttributeSet attrs, int defStyleAttr) { 44 super(context, attrs, defStyleAttr); 45 } 46 47 @Override hasWindowFocus()48 public boolean hasWindowFocus() { 49 return true; 50 } 51 52 @Override onViewAdded(View child)53 public void onViewAdded(View child) { 54 if (child instanceof SurfaceView) { 55 // Note: See b/29118070 for detail. 56 ((SurfaceView) child).setSecure(!CommonUtils.isDeveloper()); 57 } 58 super.onViewAdded(child); 59 } 60 61 @Override getLocationOnScreen(int[] outLocation)62 public void getLocationOnScreen(int[] outLocation) { 63 super.getLocationOnScreen(outLocation); 64 65 // The TvView.MySessionCallback.onSessionCreated() will call this method indirectly. 66 Debug.getTimer(Debug.TAG_START_UP_TIMER) 67 .log("AppLayerTvView.getLocationOnScreen, session created"); 68 } 69 } 70