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