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
17package com.android.cts.verifier.sensors;
18
19import com.android.cts.verifier.PassFailButtons;
20import com.android.cts.verifier.R;
21import com.android.cts.verifier.sensors.renderers.GLArrowSensorTestRenderer;
22
23import android.content.Context;
24import android.hardware.Sensor;
25import android.hardware.SensorEventListener;
26import android.hardware.SensorManager;
27import android.opengl.GLSurfaceView;
28import 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
38public class AccelerometerTestActivity extends PassFailButtons.Activity {
39    private GLSurfaceView mGLSurfaceView;
40
41    private SensorManager mSensorManager;
42
43    private SensorEventListener mListener;
44
45    @Override
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
63    protected void onPause() {
64        super.onPause();
65        mSensorManager.unregisterListener(mListener);
66        mGLSurfaceView.onPause();
67    }
68
69    @Override
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