blob: 3614e22d4d3671b672dab5f2ccf35798e0089195 [file] [log] [blame]
The Android Open Source Projectf8057102009-03-15 16:47:16 -07001/*
2 * Copyright (C) 2008 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 android.tests.getinfo;
18
The Android Open Source Projectf8057102009-03-15 16:47:16 -070019import android.app.Activity;
Keun young Park88e5d1f2011-12-14 14:01:01 -080020import android.app.ActivityManager;
21import android.content.Context;
22import android.content.pm.ConfigurationInfo;
The Android Open Source Projectf8057102009-03-15 16:47:16 -070023import android.content.res.Configuration;
24import android.os.Bundle;
The Android Open Source Projectf8057102009-03-15 16:47:16 -070025
Brett Chabot62a17ce2009-11-12 13:35:13 -080026import java.util.Locale;
Keun young Park88e5d1f2011-12-14 14:01:01 -080027import java.util.concurrent.CountDownLatch;
Brett Chabot62a17ce2009-11-12 13:35:13 -080028
The Android Open Source Projectf8057102009-03-15 16:47:16 -070029
30/**
31 * Collect device information on target device.
32 */
33public class DeviceInfoActivity extends Activity {
Keun young Park88e5d1f2011-12-14 14:01:01 -080034
35 // work done should be reported in GLES..View
36 private CountDownLatch mDone = new CountDownLatch(1);
37 private GLESSurfaceView mGLView;
Bill Napier6c12b462009-05-14 11:07:39 -070038
39 /**
40 * Other classes can call this function to wait for this activity
41 * to finish. */
42 public void waitForAcitityToFinish() {
Keun young Park88e5d1f2011-12-14 14:01:01 -080043 try {
44 mDone.await();
45 } catch (InterruptedException e) {
46 // just move on
Bill Napier6c12b462009-05-14 11:07:39 -070047 }
48 }
The Android Open Source Projectf8057102009-03-15 16:47:16 -070049
50 @Override
51 public void onCreate(Bundle savedInstanceState) {
52 super.onCreate(savedInstanceState);
53
Keun young Park88e5d1f2011-12-14 14:01:01 -080054 ActivityManager am =
55 (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
56 ConfigurationInfo info = am.getDeviceConfigurationInfo();
57 boolean useGL20 = (info.reqGlEsVersion >= 0x20000);
58
59 mGLView = new GLESSurfaceView(this, useGL20, mDone);
60 setContentView(mGLView);
61
Brett Chabot62a17ce2009-11-12 13:35:13 -080062 Configuration con = getResources().getConfiguration();
The Android Open Source Projectf8057102009-03-15 16:47:16 -070063 String touchScreen = null;
64 if (con.touchscreen == Configuration.TOUCHSCREEN_UNDEFINED) {
65 touchScreen = "undefined";
66 } else if (con.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH) {
67 touchScreen = "notouch";
68 } else if (con.touchscreen == Configuration.TOUCHSCREEN_STYLUS) {
69 touchScreen = "stylus";
70 } else if (con.touchscreen == Configuration.TOUCHSCREEN_FINGER) {
71 touchScreen = "finger";
72 }
73 if (touchScreen != null) {
Brett Chabot2f903ad2011-02-02 18:22:18 -080074 DeviceInfoInstrument.addResult(DeviceInfoConstants.TOUCH_SCREEN,
The Android Open Source Projectf8057102009-03-15 16:47:16 -070075 touchScreen);
76 }
77
78 String navigation = null;
79 if (con.navigation == Configuration.NAVIGATION_UNDEFINED) {
80 navigation = "undefined";
81 } else if (con.navigation == Configuration.NAVIGATION_NONAV) {
82 navigation = "nonav";
83 } else if (con.navigation == Configuration.NAVIGATION_DPAD) {
84 navigation = "drap";
85 } else if (con.navigation == Configuration.NAVIGATION_TRACKBALL) {
86 navigation = "trackball";
87 } else if (con.navigation == Configuration.NAVIGATION_WHEEL) {
88 navigation = "wheel";
89 }
90
91 if (navigation != null) {
Brett Chabot2f903ad2011-02-02 18:22:18 -080092 DeviceInfoInstrument.addResult(DeviceInfoConstants.NAVIGATION,
The Android Open Source Projectf8057102009-03-15 16:47:16 -070093 navigation);
94 }
95
96 String keypad = null;
97 if (con.keyboard == Configuration.KEYBOARD_UNDEFINED) {
98 keypad = "undefined";
99 } else if (con.keyboard == Configuration.KEYBOARD_NOKEYS) {
100 keypad = "nokeys";
101 } else if (con.keyboard == Configuration.KEYBOARD_QWERTY) {
102 keypad = "qwerty";
103 } else if (con.keyboard == Configuration.KEYBOARD_12KEY) {
104 keypad = "12key";
105 }
106 if (keypad != null) {
Brett Chabot2f903ad2011-02-02 18:22:18 -0800107 DeviceInfoInstrument.addResult(DeviceInfoConstants.KEYPAD, keypad);
The Android Open Source Projectf8057102009-03-15 16:47:16 -0700108 }
109
110 String[] locales = getAssets().getLocales();
111 StringBuilder localeList = new StringBuilder();
112 for (String s : locales) {
113 if (s.length() == 0) { // default locale
114 localeList.append(new Locale("en", "US").toString());
115 } else {
116 localeList.append(s);
117 }
118 localeList.append(";");
119 }
Brett Chabot2f903ad2011-02-02 18:22:18 -0800120 DeviceInfoInstrument.addResult(DeviceInfoConstants.LOCALES,
The Android Open Source Projectf8057102009-03-15 16:47:16 -0700121 localeList.toString());
The Android Open Source Projectf8057102009-03-15 16:47:16 -0700122 }
123}