1 /* 2 * Copyright (C) 2010 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.cts.verifier.sensors; 18 19 import com.android.cts.verifier.PassFailButtons; 20 import com.android.cts.verifier.R; 21 import com.android.cts.verifier.sensors.renderers.GLArrowSensorTestRenderer; 22 23 import android.content.Context; 24 import android.hardware.Sensor; 25 import android.hardware.SensorEventListener; 26 import android.hardware.SensorManager; 27 import android.opengl.GLSurfaceView; 28 import android.os.Bundle; 29 30 /** 31 * CTS Verifier case for verifying correct integration of accelerometer. 32 * Displays a wedge using OpenGL that, on a correctly-integrated device, always 33 * points down. 34 * 35 * @deprecated It has been replaced by {@link AccelerometerMeasurementTestActivity} 36 */ 37 @Deprecated 38 public class AccelerometerTestActivity extends PassFailButtons.Activity { 39 private GLSurfaceView mGLSurfaceView; 40 41 private SensorManager mSensorManager; 42 43 private SensorEventListener mListener; 44 45 @Override onCreate(Bundle savedInstanceState)46 protected void onCreate(Bundle savedInstanceState) { 47 super.onCreate(savedInstanceState); 48 49 mSensorManager = (SensorManager) getApplicationContext().getSystemService( 50 Context.SENSOR_SERVICE); 51 GLArrowSensorTestRenderer renderer = 52 new GLArrowSensorTestRenderer(this, Sensor.TYPE_ACCELEROMETER); 53 mListener = renderer; 54 55 setContentView(R.layout.pass_fail_gl); 56 setPassFailButtonClickListeners(); 57 setInfoResources(R.string.snsr_accel_test, R.string.snsr_accel_test_info, -1); 58 mGLSurfaceView = (GLSurfaceView) findViewById(R.id.gl_surface_view); 59 mGLSurfaceView.setRenderer(renderer); 60 } 61 62 @Override onPause()63 protected void onPause() { 64 super.onPause(); 65 mSensorManager.unregisterListener(mListener); 66 mGLSurfaceView.onPause(); 67 } 68 69 @Override onResume()70 protected void onResume() { 71 super.onResume(); 72 mGLSurfaceView.onResume(); 73 mSensorManager.registerListener(mListener, mSensorManager.getSensorList( 74 Sensor.TYPE_ACCELEROMETER).get(0), SensorManager.SENSOR_DELAY_UI); 75 } 76 } 77