The Android Open Source Project | f805710 | 2009-03-15 16:47:16 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.tests.getinfo; |
| 18 | |
The Android Open Source Project | f805710 | 2009-03-15 16:47:16 -0700 | [diff] [blame] | 19 | import android.app.Activity; |
Keun young Park | 88e5d1f | 2011-12-14 14:01:01 -0800 | [diff] [blame] | 20 | import android.app.ActivityManager; |
| 21 | import android.content.Context; |
| 22 | import android.content.pm.ConfigurationInfo; |
The Android Open Source Project | f805710 | 2009-03-15 16:47:16 -0700 | [diff] [blame] | 23 | import android.content.res.Configuration; |
| 24 | import android.os.Bundle; |
The Android Open Source Project | f805710 | 2009-03-15 16:47:16 -0700 | [diff] [blame] | 25 | |
Brett Chabot | 62a17ce | 2009-11-12 13:35:13 -0800 | [diff] [blame] | 26 | import java.util.Locale; |
Keun young Park | 88e5d1f | 2011-12-14 14:01:01 -0800 | [diff] [blame] | 27 | import java.util.concurrent.CountDownLatch; |
Brett Chabot | 62a17ce | 2009-11-12 13:35:13 -0800 | [diff] [blame] | 28 | |
The Android Open Source Project | f805710 | 2009-03-15 16:47:16 -0700 | [diff] [blame] | 29 | |
| 30 | /** |
| 31 | * Collect device information on target device. |
| 32 | */ |
| 33 | public class DeviceInfoActivity extends Activity { |
Keun young Park | 88e5d1f | 2011-12-14 14:01:01 -0800 | [diff] [blame] | 34 | |
| 35 | // work done should be reported in GLES..View |
| 36 | private CountDownLatch mDone = new CountDownLatch(1); |
| 37 | private GLESSurfaceView mGLView; |
Bill Napier | 6c12b46 | 2009-05-14 11:07:39 -0700 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * Other classes can call this function to wait for this activity |
| 41 | * to finish. */ |
| 42 | public void waitForAcitityToFinish() { |
Keun young Park | 88e5d1f | 2011-12-14 14:01:01 -0800 | [diff] [blame] | 43 | try { |
| 44 | mDone.await(); |
| 45 | } catch (InterruptedException e) { |
| 46 | // just move on |
Bill Napier | 6c12b46 | 2009-05-14 11:07:39 -0700 | [diff] [blame] | 47 | } |
| 48 | } |
The Android Open Source Project | f805710 | 2009-03-15 16:47:16 -0700 | [diff] [blame] | 49 | |
| 50 | @Override |
| 51 | public void onCreate(Bundle savedInstanceState) { |
| 52 | super.onCreate(savedInstanceState); |
| 53 | |
Keun young Park | 88e5d1f | 2011-12-14 14:01:01 -0800 | [diff] [blame] | 54 | 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 Chabot | 62a17ce | 2009-11-12 13:35:13 -0800 | [diff] [blame] | 62 | Configuration con = getResources().getConfiguration(); |
The Android Open Source Project | f805710 | 2009-03-15 16:47:16 -0700 | [diff] [blame] | 63 | 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 Chabot | 2f903ad | 2011-02-02 18:22:18 -0800 | [diff] [blame] | 74 | DeviceInfoInstrument.addResult(DeviceInfoConstants.TOUCH_SCREEN, |
The Android Open Source Project | f805710 | 2009-03-15 16:47:16 -0700 | [diff] [blame] | 75 | 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 Chabot | 2f903ad | 2011-02-02 18:22:18 -0800 | [diff] [blame] | 92 | DeviceInfoInstrument.addResult(DeviceInfoConstants.NAVIGATION, |
The Android Open Source Project | f805710 | 2009-03-15 16:47:16 -0700 | [diff] [blame] | 93 | 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 Chabot | 2f903ad | 2011-02-02 18:22:18 -0800 | [diff] [blame] | 107 | DeviceInfoInstrument.addResult(DeviceInfoConstants.KEYPAD, keypad); |
The Android Open Source Project | f805710 | 2009-03-15 16:47:16 -0700 | [diff] [blame] | 108 | } |
| 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 Chabot | 2f903ad | 2011-02-02 18:22:18 -0800 | [diff] [blame] | 120 | DeviceInfoInstrument.addResult(DeviceInfoConstants.LOCALES, |
The Android Open Source Project | f805710 | 2009-03-15 16:47:16 -0700 | [diff] [blame] | 121 | localeList.toString()); |
The Android Open Source Project | f805710 | 2009-03-15 16:47:16 -0700 | [diff] [blame] | 122 | } |
| 123 | } |