1 /* 2 * Copyright 2013 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 package com.android.gltest; 17 18 import android.app.Activity; 19 import android.app.KeyguardManager; 20 import android.content.Context; 21 import android.content.pm.PackageManager; 22 import android.os.Bundle; 23 import android.view.SurfaceHolder; 24 import android.view.SurfaceView; 25 import android.view.Surface; 26 27 public class GLTestActivity extends Activity { 28 29 private class TestThread extends Thread { 30 run()31 public void run() { 32 // it is possible to set the GTest filter flag from here 33 // for example "GLTest.ClearColorTest" to run that specific test only 34 runTests(null); 35 36 try { 37 Thread.sleep(1000); 38 } catch (InterruptedException e) { 39 } 40 41 finish(); 42 System.exit(0); 43 } 44 } 45 46 private SurfaceView mSurfaceView; 47 48 private SurfaceHolder.Callback mHolderCallback = new SurfaceHolder.Callback() { 49 50 public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { 51 setSurface(holder.getSurface()); 52 } 53 54 public void surfaceCreated(SurfaceHolder holder) { 55 setSurface(holder.getSurface()); 56 Thread t = new TestThread(); 57 t.start(); 58 } 59 60 public void surfaceDestroyed(SurfaceHolder holder) { 61 } 62 }; 63 64 @SuppressWarnings("deprecation") 65 @Override onCreate(Bundle savedInstanceState)66 public void onCreate(Bundle savedInstanceState) { 67 if (checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD) 68 == PackageManager.PERMISSION_GRANTED) { 69 KeyguardManager keyguardManager = 70 (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); 71 keyguardManager.newKeyguardLock("gltest").disableKeyguard(); 72 } 73 74 super.onCreate(savedInstanceState); 75 76 mSurfaceView = new SurfaceView(this); 77 mSurfaceView.getHolder().addCallback(mHolderCallback); 78 setContentView(mSurfaceView); 79 System.loadLibrary("stlport_shared"); 80 System.loadLibrary("nativeopengltests"); 81 } 82 setSurface(Surface surface)83 private static native void setSurface(Surface surface); runTests(String filter)84 private static native void runTests(String filter); 85 } 86