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