Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright 2014 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 android.hardware.camera2.cts;
     18 
     19 import android.app.Activity;
     20 import android.os.Bundle;
     21 import android.util.Log;
     22 import android.view.SurfaceView;
     23 import android.view.TextureView;
     24 import android.view.WindowManager;
     25 
     26 import android.camera.cts.R;
     27 
     28 public class Camera2MultiViewCtsActivity extends Activity {
     29     private final static String TAG = "Camera2MultiViewCtsActivity";
     30     public final static int MAX_TEXTURE_VIEWS = 5;
     31     private TextureView[] mTextureView = new TextureView[MAX_TEXTURE_VIEWS];
     32     private SurfaceView[] mSurfaceView = new SurfaceView[2];
     33 
     34     @Override
     35     protected void onCreate(Bundle savedInstanceState) {
     36         super.onCreate(savedInstanceState);
     37         setContentView(R.layout.multi_view);
     38         mTextureView[0] = (TextureView) findViewById(R.id.texture_view_1);
     39         mTextureView[1] = (TextureView) findViewById(R.id.texture_view_2);
     40         mTextureView[2] = (TextureView) findViewById(R.id.texture_view_3);
     41         mTextureView[3] = (TextureView) findViewById(R.id.texture_view_4);
     42         mTextureView[4] = (TextureView) findViewById(R.id.texture_view_5);
     43         mSurfaceView[0] = (SurfaceView) findViewById(R.id.surface_view_1);
     44         mSurfaceView[1] = (SurfaceView) findViewById(R.id.surface_view_2);
     45 
     46         //Make sure screen is on when this activity window is visible to the user.
     47         getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
     48     }
     49 
     50     public TextureView getTextureView(int index) {
     51         if (index < 0 || index > (MAX_TEXTURE_VIEWS - 1)) {
     52             throw new IllegalArgumentException("Texture view index must be between 0 and " +
     53                     MAX_TEXTURE_VIEWS);
     54         }
     55         return mTextureView[index];
     56     }
     57 
     58     public SurfaceView getSurfaceView(int index) {
     59         if (index < 0 || index > 1) {
     60             throw new IllegalArgumentException("Surface view index must be 0 or 1");
     61         }
     62         return mSurfaceView[index];
     63     }
     64 }
     65