feat(DeviceTest): add Factory DeviceTest App code
.. | .. |
---|
| 1 | +LOCAL_PATH:= $(call my-dir) |
---|
| 2 | +include $(CLEAR_VARS) |
---|
| 3 | + |
---|
| 4 | +LOCAL_MODULE_TAGS := optional |
---|
| 5 | + |
---|
| 6 | +LOCAL_SRC_FILES := $(call all-subdir-java-files) |
---|
| 7 | + |
---|
| 8 | +ifneq ($(PLATFORM_VERSION),8.1.0) |
---|
| 9 | +LOCAL_PRIVATE_PLATFORM_APIS := true |
---|
| 10 | +endif |
---|
| 11 | + |
---|
| 12 | +LOCAL_PACKAGE_NAME := DeviceTest |
---|
| 13 | + |
---|
| 14 | +LOCAL_JAVA_LIBRARIES := javax.obex |
---|
| 15 | + |
---|
| 16 | +LOCAL_STATIC_JAVA_LIBRARIES += user_mode |
---|
| 17 | + |
---|
| 18 | +LOCAL_STATIC_JAVA_LIBRARIES += apache |
---|
| 19 | + |
---|
| 20 | +LOCAL_CERTIFICATE := platform |
---|
| 21 | + |
---|
| 22 | +LOCAL_DEX_PREOPT := false |
---|
| 23 | + |
---|
| 24 | +include $(BUILD_PACKAGE) |
---|
| 25 | + |
---|
| 26 | +include $(CLEAR_VARS) |
---|
| 27 | + |
---|
| 28 | +LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := user_mode:user_mode.jar \ |
---|
| 29 | + apache:org.apache.http.legacy.jar |
---|
| 30 | + |
---|
| 31 | +include $(BUILD_MULTI_PREBUILT) |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 3 | + package="com.DeviceTest"
|
---|
| 4 | + android:sharedUserId="android.uid.system"
|
---|
| 5 | + android:exported="true"
|
---|
| 6 | + >
|
---|
| 7 | + <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
---|
| 8 | + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
---|
| 9 | + <uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES" />
|
---|
| 10 | + <uses-permission android:name="android.permission.WAKE_LOCK" />
|
---|
| 11 | + <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
|
---|
| 12 | + <uses-permission android:name="android.permission.INTERNET" />
|
---|
| 13 | + <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
---|
| 14 | + <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
|
---|
| 15 | + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
---|
| 16 | + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
---|
| 17 | + <uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
---|
| 18 | + <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
|
---|
| 19 | + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
---|
| 20 | + <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
---|
| 21 | + <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
|
---|
| 22 | + <uses-permission android:name="android.permission.BLUETOOTH" />
|
---|
| 23 | + <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
---|
| 24 | + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
---|
| 25 | + <uses-permission android:name="android.permission.RECORD_AUDIO" />
|
---|
| 26 | + <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
---|
| 27 | + <uses-permission android:name="android.permission.READ_CONTACTS" />
|
---|
| 28 | + <uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
---|
| 29 | + <uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
|
---|
| 30 | + <uses-permission android:name="android.permission.HARDWARE_TEST" />
|
---|
| 31 | + <uses-permission android:name="android.permission.DEVICE_POWER" />
|
---|
| 32 | + <uses-permission android:name="android.permission.FLASHLIGHT" />
|
---|
| 33 | + <uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
---|
| 34 | + <uses-permission android:name="android.permission.BATTERY_STATS" />
|
---|
| 35 | + <uses-permission android:name="android.permission.INJECT_EVENTS" />
|
---|
| 36 | + <uses-permission android:name="android.permission.INTERNET" />
|
---|
| 37 | + <uses-permission android:name="android.permission.CAMERA" />
|
---|
| 38 | + <uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" />
|
---|
| 39 | + <uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW" />
|
---|
| 40 | + <uses-permission android:name="android.permission.DEVICE_POWER"/>
|
---|
| 41 | + <uses-permission android:name="android.permission.CONTROL_DISPLAY_BRIGHTNESS" />
|
---|
| 42 | +
|
---|
| 43 | + <!-- <queries>
|
---|
| 44 | + <package android:name="com.example.cam" />
|
---|
| 45 | + </queries> -->
|
---|
| 46 | +
|
---|
| 47 | + <application
|
---|
| 48 | + android:resizeableActivity="true"
|
---|
| 49 | + android:icon="@drawable/devicetest_icon"
|
---|
| 50 | + android:label="@string/app_name"
|
---|
| 51 | + android:exported="true">
|
---|
| 52 | + <activity
|
---|
| 53 | + android:name=".FirstRun"
|
---|
| 54 | + android:label="@string/app_name"
|
---|
| 55 | + android:screenOrientation="landscape"
|
---|
| 56 | + android:configChanges="orientation|keyboardHidden"
|
---|
| 57 | + android:exported="true">
|
---|
| 58 | + <intent-filter>
|
---|
| 59 | + <action android:name="rk.intent.action.FIRSTRUN" />
|
---|
| 60 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 61 | + </intent-filter>
|
---|
| 62 | + </activity>
|
---|
| 63 | + <activity
|
---|
| 64 | + android:name="com.DeviceTest.DeviceTest"
|
---|
| 65 | + android:screenOrientation="landscape"
|
---|
| 66 | + android:configChanges="orientation|keyboardHidden"
|
---|
| 67 | + android:exported="true">
|
---|
| 68 | + <intent-filter>
|
---|
| 69 | + <action android:name="rk.intent.action.startDevicetest" />
|
---|
| 70 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 71 | + </intent-filter>
|
---|
| 72 | + </activity>
|
---|
| 73 | + <activity
|
---|
| 74 | + android:name=".InfomationActivity"
|
---|
| 75 | + android:screenOrientation="landscape"
|
---|
| 76 | + android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" >
|
---|
| 77 | + </activity>
|
---|
| 78 | +
|
---|
| 79 | + <activity
|
---|
| 80 | + android:name=".VersionTestActivity"
|
---|
| 81 | + android:screenOrientation="landscape"
|
---|
| 82 | + android:exported="true">
|
---|
| 83 | + <intent-filter>
|
---|
| 84 | + <action android:name="rk.intent.action.VersionTestActivity" />
|
---|
| 85 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 86 | + </intent-filter>
|
---|
| 87 | + </activity>
|
---|
| 88 | + <activity
|
---|
| 89 | + android:name=".StorageActivity"
|
---|
| 90 | + android:screenOrientation="landscape"
|
---|
| 91 | + android:exported="true">
|
---|
| 92 | + <intent-filter>
|
---|
| 93 | + <action android:name="rk.intent.action.StorageActivity" />
|
---|
| 94 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 95 | + </intent-filter>
|
---|
| 96 | + </activity>
|
---|
| 97 | + <activity
|
---|
| 98 | + android:name=".LcdTestActivity"
|
---|
| 99 | + android:screenOrientation="landscape"
|
---|
| 100 | + android:exported="true">
|
---|
| 101 | + <intent-filter>
|
---|
| 102 | + <action android:name="rk.intent.action.LcdTestActivity" />
|
---|
| 103 | +
|
---|
| 104 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 105 | + </intent-filter>
|
---|
| 106 | + </activity>
|
---|
| 107 | + <activity
|
---|
| 108 | + android:name=".TouchTestActivity"
|
---|
| 109 | + android:screenOrientation="landscape"
|
---|
| 110 | + android:exported="true">
|
---|
| 111 | + <intent-filter>
|
---|
| 112 | + <action
|
---|
| 113 | + android:name="rk.intent.action.TouchTestActivity"
|
---|
| 114 | + android:screenOrientation="landscape" />
|
---|
| 115 | +
|
---|
| 116 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 117 | + </intent-filter>
|
---|
| 118 | + </activity>
|
---|
| 119 | + <activity
|
---|
| 120 | + android:name=".CameraTestActivity"
|
---|
| 121 | + android:screenOrientation="landscape"
|
---|
| 122 | + android:exported="true">
|
---|
| 123 | + <intent-filter>
|
---|
| 124 | + <action
|
---|
| 125 | + android:name="rk.intent.action.CameraTestActivity"
|
---|
| 126 | + android:screenOrientation="landscape" />
|
---|
| 127 | +
|
---|
| 128 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 129 | + </intent-filter>
|
---|
| 130 | + </activity>
|
---|
| 131 | + <activity
|
---|
| 132 | + android:name=".CameraBackTestActivity"
|
---|
| 133 | + android:screenOrientation="landscape"
|
---|
| 134 | + android:exported="true">
|
---|
| 135 | + <intent-filter>
|
---|
| 136 | + <action
|
---|
| 137 | + android:name="rk.intent.action.CameraBackTestActivity"
|
---|
| 138 | + android:screenOrientation="landscape" />
|
---|
| 139 | +
|
---|
| 140 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 141 | + </intent-filter>
|
---|
| 142 | + </activity>
|
---|
| 143 | +
|
---|
| 144 | + <activity
|
---|
| 145 | + android:name=".VibrationTestActivity"
|
---|
| 146 | + android:screenOrientation="landscape"
|
---|
| 147 | + android:exported="true">
|
---|
| 148 | + <intent-filter>
|
---|
| 149 | + <action
|
---|
| 150 | + android:name="rk.intent.action.VibrationTestActivity"
|
---|
| 151 | + android:screenOrientation="landscape" />
|
---|
| 152 | +
|
---|
| 153 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 154 | + </intent-filter>
|
---|
| 155 | + </activity>
|
---|
| 156 | + <activity
|
---|
| 157 | + android:name=".SpeakerTestActivity"
|
---|
| 158 | + android:screenOrientation="landscape"
|
---|
| 159 | + android:exported="true">
|
---|
| 160 | + <intent-filter>
|
---|
| 161 | + <action
|
---|
| 162 | + android:name="rk.intent.action.SpeakerTestActivity"
|
---|
| 163 | + android:screenOrientation="landscape" />
|
---|
| 164 | +
|
---|
| 165 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 166 | + </intent-filter>
|
---|
| 167 | + </activity>
|
---|
| 168 | + <activity
|
---|
| 169 | + android:name=".GsensorTestActivity"
|
---|
| 170 | + android:screenOrientation="sensor"
|
---|
| 171 | + android:exported="true">
|
---|
| 172 | + <intent-filter>
|
---|
| 173 | + <action
|
---|
| 174 | + android:name="rk.intent.action.GsensorTestActivity"
|
---|
| 175 | + android:screenOrientation="portrait" />
|
---|
| 176 | +
|
---|
| 177 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 178 | + </intent-filter>
|
---|
| 179 | + </activity>
|
---|
| 180 | + <activity
|
---|
| 181 | + android:name=".MsensorTestActivity"
|
---|
| 182 | + android:screenOrientation="landscape"
|
---|
| 183 | + android:exported="true">
|
---|
| 184 | + <intent-filter>
|
---|
| 185 | + <action
|
---|
| 186 | + android:name="rk.intent.action.MsensorTestActivity"
|
---|
| 187 | + android:screenOrientation="landscape" />
|
---|
| 188 | +
|
---|
| 189 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 190 | + </intent-filter>
|
---|
| 191 | + </activity>
|
---|
| 192 | + <activity
|
---|
| 193 | + android:name=".GyroscopeTestActivity"
|
---|
| 194 | + android:screenOrientation="portrait"
|
---|
| 195 | + android:exported="true">
|
---|
| 196 | + <intent-filter>
|
---|
| 197 | + <action
|
---|
| 198 | + android:name="rk.intent.action.GyroscopeTestActivity"
|
---|
| 199 | + android:screenOrientation="portrait" />
|
---|
| 200 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 201 | + </intent-filter>
|
---|
| 202 | + </activity>
|
---|
| 203 | + <activity
|
---|
| 204 | + android:name=".LightsensorTestActivity"
|
---|
| 205 | + android:screenOrientation="landscape"
|
---|
| 206 | + android:exported="true">
|
---|
| 207 | + <intent-filter>
|
---|
| 208 | + <action
|
---|
| 209 | + android:name="rk.intent.action.LightsensorTestActivity"
|
---|
| 210 | + android:screenOrientation="landscape" />
|
---|
| 211 | +
|
---|
| 212 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 213 | + </intent-filter>
|
---|
| 214 | + </activity>
|
---|
| 215 | + <activity
|
---|
| 216 | + android:name=".BluetoothTestActivity"
|
---|
| 217 | + android:screenOrientation="landscape"
|
---|
| 218 | + android:exported="true">
|
---|
| 219 | + <intent-filter>
|
---|
| 220 | + <action
|
---|
| 221 | + android:name="rk.intent.action.BluetoothTestActivity"
|
---|
| 222 | + android:screenOrientation="landscape" />
|
---|
| 223 | +
|
---|
| 224 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 225 | + </intent-filter>
|
---|
| 226 | + </activity>
|
---|
| 227 | + <activity
|
---|
| 228 | + android:name=".WifiTestActivity"
|
---|
| 229 | + android:screenOrientation="landscape"
|
---|
| 230 | + android:exported="true">
|
---|
| 231 | + <intent-filter>
|
---|
| 232 | + <action
|
---|
| 233 | + android:name="rk.intent.action.WifiTestActivity"
|
---|
| 234 | + android:screenOrientation="landscape" />
|
---|
| 235 | +
|
---|
| 236 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 237 | + </intent-filter>
|
---|
| 238 | + </activity>
|
---|
| 239 | + <activity
|
---|
| 240 | + android:name=".HeadsetMicTestActivity"
|
---|
| 241 | + android:screenOrientation="landscape"
|
---|
| 242 | + android:exported="true">
|
---|
| 243 | + <intent-filter>
|
---|
| 244 | + <action
|
---|
| 245 | + android:name="rk.intent.action.HeadsetMicTestActivity"
|
---|
| 246 | + android:screenOrientation="landscape" />
|
---|
| 247 | +
|
---|
| 248 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 249 | + </intent-filter>
|
---|
| 250 | + </activity>
|
---|
| 251 | + <activity
|
---|
| 252 | + android:name=".PhoneMicTestActivity"
|
---|
| 253 | + android:screenOrientation="landscape"
|
---|
| 254 | + android:exported="true">
|
---|
| 255 | + <intent-filter>
|
---|
| 256 | + <action
|
---|
| 257 | + android:name="rk.intent.action.PhoneMicTestActivity"
|
---|
| 258 | + android:screenOrientation="landscape" />
|
---|
| 259 | +
|
---|
| 260 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 261 | + </intent-filter>
|
---|
| 262 | + </activity>
|
---|
| 263 | + <activity
|
---|
| 264 | + android:name=".GpsTestActivity"
|
---|
| 265 | + android:screenOrientation="landscape"
|
---|
| 266 | + android:exported="true">
|
---|
| 267 | + <intent-filter>
|
---|
| 268 | + <action
|
---|
| 269 | + android:name="rk.intent.action.GpsTestActivity"
|
---|
| 270 | + android:screenOrientation="landscape" />
|
---|
| 271 | +
|
---|
| 272 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 273 | + </intent-filter>
|
---|
| 274 | + </activity>
|
---|
| 275 | + <activity
|
---|
| 276 | + android:name=".GpsLocationTestActivity"
|
---|
| 277 | + android:screenOrientation="landscape"
|
---|
| 278 | + android:exported="true">
|
---|
| 279 | + <intent-filter>
|
---|
| 280 | + <action
|
---|
| 281 | + android:name="rk.intent.action.GpsLocationTestActivity"
|
---|
| 282 | + android:screenOrientation="landscape" />
|
---|
| 283 | +
|
---|
| 284 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 285 | + </intent-filter>
|
---|
| 286 | + </activity>
|
---|
| 287 | + <activity
|
---|
| 288 | + android:name=".SdCardTestActivity"
|
---|
| 289 | + android:screenOrientation="landscape"
|
---|
| 290 | + android:exported="true">
|
---|
| 291 | + <intent-filter>
|
---|
| 292 | + <action
|
---|
| 293 | + android:name="rk.intent.action.SdCardTestActivity"
|
---|
| 294 | + android:screenOrientation="landscape" />
|
---|
| 295 | +
|
---|
| 296 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 297 | + </intent-filter>
|
---|
| 298 | + </activity>
|
---|
| 299 | + <activity
|
---|
| 300 | + android:name=".PowerTestActivity"
|
---|
| 301 | + android:screenOrientation="landscape"
|
---|
| 302 | + android:exported="true">
|
---|
| 303 | + <intent-filter>
|
---|
| 304 | + <action
|
---|
| 305 | + android:name="rk.intent.action.PowerTestActivity"
|
---|
| 306 | + android:screenOrientation="landscape" />
|
---|
| 307 | +
|
---|
| 308 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 309 | + </intent-filter>
|
---|
| 310 | + </activity>
|
---|
| 311 | + <activity
|
---|
| 312 | + android:name="BrightnessTestActivity"
|
---|
| 313 | + android:screenOrientation="landscape"
|
---|
| 314 | + android:exported="true">
|
---|
| 315 | + <intent-filter>
|
---|
| 316 | + <action
|
---|
| 317 | + android:name="rk.intent.action.BrightnessTestActivity"
|
---|
| 318 | + android:screenOrientation="landscape" />
|
---|
| 319 | +
|
---|
| 320 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 321 | + </intent-filter>
|
---|
| 322 | + </activity>
|
---|
| 323 | + <activity
|
---|
| 324 | + android:name=".KeyboardTestActivity"
|
---|
| 325 | + android:screenOrientation="landscape"
|
---|
| 326 | + android:exported="true">
|
---|
| 327 | + <intent-filter>
|
---|
| 328 | + <action
|
---|
| 329 | + android:name="rk.intent.action.KeyboardTestActivity"
|
---|
| 330 | + android:screenOrientation="landscape" />
|
---|
| 331 | +
|
---|
| 332 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 333 | + </intent-filter>
|
---|
| 334 | + </activity>
|
---|
| 335 | + <activity
|
---|
| 336 | + android:name="MrioUSBTestActivity"
|
---|
| 337 | + android:screenOrientation="landscape"
|
---|
| 338 | + android:exported="true">
|
---|
| 339 | + <intent-filter>
|
---|
| 340 | + <action
|
---|
| 341 | + android:name="rk.intent.action.MrioUSBTestActivity"
|
---|
| 342 | + android:screenOrientation="landscape" />
|
---|
| 343 | + <action android:name="android.hardware.Usb.ACTION_USB_STATE" />
|
---|
| 344 | + <action android:name="android.hardware.Usb.ACTION_USB_CONNECTED" />
|
---|
| 345 | + <action android:name="android.hardware.Usb.ACTION_USB_DISCONNECTED" />
|
---|
| 346 | +
|
---|
| 347 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 348 | + </intent-filter>
|
---|
| 349 | + </activity>
|
---|
| 350 | + <activity
|
---|
| 351 | + android:name=".SimCardTestActivity"
|
---|
| 352 | + android:screenOrientation="landscape"
|
---|
| 353 | + android:exported="true">
|
---|
| 354 | + <intent-filter>
|
---|
| 355 | + <action
|
---|
| 356 | + android:name="rk.intent.action.SimCardTestActivity"
|
---|
| 357 | + android:screenOrientation="landscape" />
|
---|
| 358 | +
|
---|
| 359 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 360 | + </intent-filter>
|
---|
| 361 | + </activity>
|
---|
| 362 | + <activity
|
---|
| 363 | + android:name=".FMRadioTestActivity"
|
---|
| 364 | + android:screenOrientation="landscape"
|
---|
| 365 | + android:exported="true">
|
---|
| 366 | + <intent-filter>
|
---|
| 367 | + <action
|
---|
| 368 | + android:name="rk.intent.action.FMRadioTestActivity"
|
---|
| 369 | + android:screenOrientation="landscape" />
|
---|
| 370 | +
|
---|
| 371 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 372 | + </intent-filter>
|
---|
| 373 | + </activity>
|
---|
| 374 | + <activity
|
---|
| 375 | + android:name=".CompassTestActivity"
|
---|
| 376 | + android:screenOrientation="landscape"
|
---|
| 377 | + android:exported="true">
|
---|
| 378 | + <intent-filter>
|
---|
| 379 | + <action
|
---|
| 380 | + android:name="rk.intent.action.CompassTestActivity"
|
---|
| 381 | + android:screenOrientation="landscape" />
|
---|
| 382 | +
|
---|
| 383 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 384 | + </intent-filter>
|
---|
| 385 | + </activity>
|
---|
| 386 | + <activity
|
---|
| 387 | + android:name=".HdmiTestActivity"
|
---|
| 388 | + android:screenOrientation="landscape"
|
---|
| 389 | + android:exported="true">
|
---|
| 390 | + <intent-filter>
|
---|
| 391 | + <action
|
---|
| 392 | + android:name="rk.intent.action.HdmiTestActivity"
|
---|
| 393 | + android:screenOrientation="landscape" />
|
---|
| 394 | +
|
---|
| 395 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 396 | + </intent-filter>
|
---|
| 397 | + </activity>
|
---|
| 398 | + <activity
|
---|
| 399 | + android:name=".LevelTestActivity"
|
---|
| 400 | + android:screenOrientation="landscape"
|
---|
| 401 | + android:exported="true">
|
---|
| 402 | + <intent-filter>
|
---|
| 403 | + <action
|
---|
| 404 | + android:name="rk.intent.action.LevelTestActivity"
|
---|
| 405 | + android:screenOrientation="landscape" />
|
---|
| 406 | +
|
---|
| 407 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 408 | + </intent-filter>
|
---|
| 409 | + </activity>
|
---|
| 410 | + <activity
|
---|
| 411 | + android:name="StorageTestActivity"
|
---|
| 412 | + android:screenOrientation="landscape"
|
---|
| 413 | + android:exported="true">
|
---|
| 414 | + <intent-filter>
|
---|
| 415 | + <action
|
---|
| 416 | + android:name="rk.intent.action.StorageTestActivity"
|
---|
| 417 | + android:screenOrientation="landscape" />
|
---|
| 418 | +
|
---|
| 419 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 420 | + </intent-filter>
|
---|
| 421 | + </activity>
|
---|
| 422 | + <activity
|
---|
| 423 | + android:name=".UsbHostTestActivity"
|
---|
| 424 | + android:screenOrientation="landscape"
|
---|
| 425 | + android:exported="true">
|
---|
| 426 | + <intent-filter>
|
---|
| 427 | + <action
|
---|
| 428 | + android:name="rk.intent.action.UsbHostTestActivity"
|
---|
| 429 | + android:screenOrientation="landscape" />
|
---|
| 430 | +
|
---|
| 431 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 432 | + </intent-filter>
|
---|
| 433 | + </activity>
|
---|
| 434 | + <activity
|
---|
| 435 | + android:name=".PCIETestActivity"
|
---|
| 436 | + android:screenOrientation="landscape"
|
---|
| 437 | + android:exported="true">
|
---|
| 438 | + <intent-filter>
|
---|
| 439 | + <action
|
---|
| 440 | + android:name="rk.intent.action.PCIETestActivity"
|
---|
| 441 | + android:screenOrientation="landscape" />
|
---|
| 442 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 443 | + </intent-filter>
|
---|
| 444 | + </activity>
|
---|
| 445 | + <activity
|
---|
| 446 | + android:name=".SATATestActivity"
|
---|
| 447 | + android:screenOrientation="landscape"
|
---|
| 448 | + android:exported="true">
|
---|
| 449 | + <intent-filter>
|
---|
| 450 | + <action
|
---|
| 451 | + android:name="rk.intent.action.SATATestActivity"
|
---|
| 452 | + android:screenOrientation="landscape" />
|
---|
| 453 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 454 | + </intent-filter>
|
---|
| 455 | + </activity>
|
---|
| 456 | + <activity
|
---|
| 457 | + android:name=".EthernetTestActivity"
|
---|
| 458 | + android:screenOrientation="landscape"
|
---|
| 459 | + android:exported="true">
|
---|
| 460 | + <intent-filter>
|
---|
| 461 | + <action
|
---|
| 462 | + android:name="rk.intent.action.EthernetTestActivity"
|
---|
| 463 | + android:screenOrientation="landscape" />
|
---|
| 464 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 465 | + </intent-filter>
|
---|
| 466 | + </activity>
|
---|
| 467 | + <activity
|
---|
| 468 | + android:name=".Ethernet2TestActivity"
|
---|
| 469 | + android:screenOrientation="landscape"
|
---|
| 470 | + android:exported="true">
|
---|
| 471 | + <intent-filter>
|
---|
| 472 | + <action
|
---|
| 473 | + android:name="rk.intent.action.EthernetTestActivity"
|
---|
| 474 | + android:screenOrientation="landscape" />
|
---|
| 475 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 476 | + </intent-filter>
|
---|
| 477 | + </activity>
|
---|
| 478 | +
|
---|
| 479 | + <activity
|
---|
| 480 | + android:name=".HardwareInfoTestActivity"
|
---|
| 481 | + android:screenOrientation="landscape"
|
---|
| 482 | + android:exported="true">
|
---|
| 483 | + <intent-filter>
|
---|
| 484 | + <action
|
---|
| 485 | + android:name="rk.intent.action.HardwareInfoTestActivity"
|
---|
| 486 | + android:screenOrientation="landscape" />
|
---|
| 487 | +
|
---|
| 488 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 489 | + </intent-filter>
|
---|
| 490 | + </activity>
|
---|
| 491 | + <activity
|
---|
| 492 | + android:name=".CirTestActivity"
|
---|
| 493 | + android:screenOrientation="landscape"
|
---|
| 494 | + android:exported="true">
|
---|
| 495 | + <intent-filter>
|
---|
| 496 | + <action
|
---|
| 497 | + android:name="rk.intent.action.CirTestActivity"
|
---|
| 498 | + android:screenOrientation="landscape" />
|
---|
| 499 | +
|
---|
| 500 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 501 | + </intent-filter>
|
---|
| 502 | + </activity>
|
---|
| 503 | + <activity
|
---|
| 504 | + android:name=".LedTestActivity"
|
---|
| 505 | + android:screenOrientation="landscape"
|
---|
| 506 | + android:exported="true">
|
---|
| 507 | + <intent-filter>
|
---|
| 508 | + <action
|
---|
| 509 | + android:name="rk.intent.action.LedTestActivity"
|
---|
| 510 | + android:screenOrientation="landscape" />
|
---|
| 511 | +
|
---|
| 512 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 513 | + </intent-filter>
|
---|
| 514 | + </activity>
|
---|
| 515 | + <activity
|
---|
| 516 | + android:name=".IrdaTestActivity"
|
---|
| 517 | + android:screenOrientation="landscape"
|
---|
| 518 | + android:exported="true">
|
---|
| 519 | + <intent-filter>
|
---|
| 520 | + <action
|
---|
| 521 | + android:name="rk.intent.action.IrdaTestActivity"
|
---|
| 522 | + android:screenOrientation="landscape" />
|
---|
| 523 | +
|
---|
| 524 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 525 | + </intent-filter>
|
---|
| 526 | + </activity>
|
---|
| 527 | + <activity
|
---|
| 528 | + android:name=".RuninTestActivity"
|
---|
| 529 | + android:configChanges="orientation"
|
---|
| 530 | + android:screenOrientation="portrait"
|
---|
| 531 | + android:exported="true">
|
---|
| 532 | + <intent-filter>
|
---|
| 533 | + <action
|
---|
| 534 | + android:name="rk.intent.action.RuninTestActivity"
|
---|
| 535 | + android:screenOrientation="landscape" />
|
---|
| 536 | +
|
---|
| 537 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 538 | + </intent-filter>
|
---|
| 539 | + </activity>
|
---|
| 540 | +
|
---|
| 541 | + <activity android:name=".RockVideoPlayer"
|
---|
| 542 | + android:label="@string/app_name"
|
---|
| 543 | + android:configChanges="orientation|keyboardHidden"
|
---|
| 544 | + android:clearTaskOnLaunch="true" android:screenOrientation="landscape"
|
---|
| 545 | + android:exported="true">
|
---|
| 546 | + <intent-filter>
|
---|
| 547 | + <action android:name="rk.intent.action.RuninTestActivity"/>
|
---|
| 548 | + <action android:name="rk.intent.action.RockVideoPlayer" />
|
---|
| 549 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 550 | + <category android:name="android.intent.category.LAUNCHER" />
|
---|
| 551 | + </intent-filter>
|
---|
| 552 | + </activity>
|
---|
| 553 | + <activity
|
---|
| 554 | + android:name=".ClockTestActivity"
|
---|
| 555 | + android:screenOrientation="landscape"
|
---|
| 556 | + android:exported="true">
|
---|
| 557 | + <intent-filter>
|
---|
| 558 | + <action
|
---|
| 559 | + android:name="rk.intent.action.ClockTestActivity"
|
---|
| 560 | + android:screenOrientation="landscape" />
|
---|
| 561 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 562 | + </intent-filter>
|
---|
| 563 | + </activity>
|
---|
| 564 | +
|
---|
| 565 | + <activity
|
---|
| 566 | + android:name=".MobileNetTestActivity"
|
---|
| 567 | + android:screenOrientation="landscape"
|
---|
| 568 | + android:exported="true">
|
---|
| 569 | + <intent-filter>
|
---|
| 570 | + <action
|
---|
| 571 | + android:name="rk.intent.action.MobileNetTestActivity"
|
---|
| 572 | + android:screenOrientation="landscape" />
|
---|
| 573 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 574 | + </intent-filter>
|
---|
| 575 | + </activity>
|
---|
| 576 | + <activity
|
---|
| 577 | + android:name=".USBDeviceTestActivity"
|
---|
| 578 | + android:screenOrientation="landscape"
|
---|
| 579 | + android:exported="true">
|
---|
| 580 | + <intent-filter>
|
---|
| 581 | + <action
|
---|
| 582 | + android:name="rk.intent.action.USBDeviceTestActivity"
|
---|
| 583 | + android:screenOrientation="landscape" />
|
---|
| 584 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 585 | + </intent-filter>
|
---|
| 586 | + </activity>
|
---|
| 587 | + <activity
|
---|
| 588 | + android:name=".RTCTestActivity"
|
---|
| 589 | + android:screenOrientation="landscape"
|
---|
| 590 | + android:exported="true">
|
---|
| 591 | + <intent-filter>
|
---|
| 592 | + <action
|
---|
| 593 | + android:name="rk.intent.action.RTCTestActivity"
|
---|
| 594 | + android:screenOrientation="landscape" />
|
---|
| 595 | + <category android:name="android.intent.category.DEFAULT" />
|
---|
| 596 | + </intent-filter>
|
---|
| 597 | + </activity>
|
---|
| 598 | + <receiver android:name=".EnableAppReceiver"
|
---|
| 599 | + android:exported="true" >
|
---|
| 600 | + <intent-filter>
|
---|
| 601 | + <action android:name="android.rockchip.devicetest.action.APP_STATE_CHANGE" />
|
---|
| 602 | + </intent-filter>
|
---|
| 603 | + </receiver>
|
---|
| 604 | + </application>
|
---|
| 605 | +
|
---|
| 606 | + <uses-permission android:name="android.permission.VIBRATE" />
|
---|
| 607 | +
|
---|
| 608 | + <supports-screens
|
---|
| 609 | + android:anyDensity="true"
|
---|
| 610 | + android:largeScreens="true" />
|
---|
| 611 | +
|
---|
| 612 | +</manifest>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="UTF-8"?>
|
---|
| 2 | +<TestCaseList>
|
---|
| 3 | +
|
---|
| 4 | + <TestCase class_name="VersionTestActivity" test_group="rest">Version</TestCase>
|
---|
| 5 | + <TestCase class_name="HardwareInfoTestActivity" test_group="auto_judged">Hardware</TestCase>
|
---|
| 6 | + <!-- <TestCase class_name="LcdTestActivity" test_group="rest">LCD</TestCase> -->
|
---|
| 7 | + <!-- <TestCase class_name="TouchTestActivity" test_group="rest">Touch</TestCase> -->
|
---|
| 8 | + <TestCase class_name="CameraTestActivity" test_group="rest">Camera</TestCase>
|
---|
| 9 | + <!-- <TestCase class_name="VibrationTestActivity" test_group="rest">Vibration</TestCase> -->
|
---|
| 10 | + <!-- <TestCase class_name="GsensorTestActivity" test_group="auto_judged">Gsensor</TestCase> -->
|
---|
| 11 | + <!-- <TestCase class_name="MsensorTestActivity" test_group="rest">Msensor</TestCase> -->
|
---|
| 12 | + <!-- <TestCase class_name="LightsensorTestActivity" test_group="rest">Lightsensor</TestCase> -->
|
---|
| 13 | + <TestCase class_name="CompassTestActivity" test_group="rest">Compass</TestCase>
|
---|
| 14 | + <!--<TestCase class_name="LevelTestActivity" test_group="rest">Level</TestCase> -->
|
---|
| 15 | + <TestCase class_name="BluetoothTestActivity" test_group="auto_judged">Bluetooth</TestCase>
|
---|
| 16 | + <TestCase class_name="WifiTestActivity" test_group="auto_judged">Wifi</TestCase>
|
---|
| 17 | + <TestCase class_name="GpsTestActivity" test_group="auto_judged">Gps</TestCase>
|
---|
| 18 | + <!--<TestCase class_name="HeadsetMicTestActivity" test_group="rest">Headset MIC</TestCase> -->
|
---|
| 19 | + <TestCase class_name="PhoneMicTestActivity" test_group="rest">MIC</TestCase>
|
---|
| 20 | + <TestCase class_name="SpeakerTestActivity" test_group="rest">Speaker</TestCase>
|
---|
| 21 | + <TestCase class_name="PowerTestActivity" test_group="auto_judged">Battery</TestCase>
|
---|
| 22 | + <TestCase class_name="BrightnessTestActivity" test_group="rest">Brightness</TestCase>
|
---|
| 23 | + <TestCase class_name="KeyboardTestActivity" test_group="auto_judged">Keyboard</TestCase>
|
---|
| 24 | + <!-- <TestCase class_name="SimCardTestActivity" test_group="rest">Sim Card</TestCase> -->
|
---|
| 25 | + <!-- <TestCase class_name="FMRadioTestActivity" test_group="rest">FM Radio</TestCase> -->
|
---|
| 26 | + <!-- <TestCase class_name="SdCardTestActivity" test_group="rest">SD Card</TestCase> -->
|
---|
| 27 | + <TestCase class_name="StorageTestActivity" test_group="auto_judged">Storage R/W</TestCase>
|
---|
| 28 | + <!-- <TestCase class_name="MrioUSBTestActivity" test_group="auto_judged">Mrio USB</TestCase> -->
|
---|
| 29 | + <TestCase class_name="LedTestActivity" test_group="rest">LED</TestCase>
|
---|
| 30 | + <TestCase class_name="CirTestActivity" test_group="rest">Cir</TestCase>
|
---|
| 31 | + <TestCase class_name="IrdaTestActivity" test_group="rest">IrDA</TestCase>
|
---|
| 32 | + <TestCase class_name="RuninTestActivity" test_group="rest">Runin</TestCase>
|
---|
| 33 | +
|
---|
| 34 | +</TestCaseList>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="UTF-8"?>
|
---|
| 2 | +<TestCaseList>
|
---|
| 3 | + <!-- <TestCase class_name="VersionTestActivity" test_group="TEST ALL">Version</TestCase> -->
|
---|
| 4 | + <!-- <TestCase class_name="LcdTestActivity" test_group="TEST ALL">LCD</TestCase> -->
|
---|
| 5 | + <!--<TestCase class_name="CameraTestActivity" test_group="TEST ALL" first_test="yc">Camera_only3</TestCase>-->
|
---|
| 6 | + <!--TestCase class_name="VibrationTestActivity" test_group="TEST ALL">Vibration</TestCase-->
|
---|
| 7 | + <!-- <TestCase class_name="GsensorTestActivity" test_group="TEST ALL" first_test="yc">Gsensor</TestCase> -->
|
---|
| 8 | + <!-- <TestCase class_name="HardwareInfoTestActivity" test_group="TEST AUTO">Hardware</TestCase> -->
|
---|
| 9 | + <!-- <TestCase class_name="GpsTestActivity" test_group="TEST ALL">GPS</TestCase> -->
|
---|
| 10 | +
|
---|
| 11 | + <!-- <TestCase class_name="StorageTestActivity" test_group="TEST AUTO">Storage R/W</TestCase> -->
|
---|
| 12 | + <!-- <TestCase class_name="PowerTestActivity" test_group="TEST ALL">Battery</TestCase> -->
|
---|
| 13 | + <!-- <TestCase class_name="KeyboardTestActivity" test_group="TEST ALL" first_test="yc">Keyboard</TestCase> -->
|
---|
| 14 | + <!-- <TestCase class_name="BrightnessTestActivity" test_group="TEST ALL">Brightness</TestCase> -->
|
---|
| 15 | +
|
---|
| 16 | + <TestCase class_name="BluetoothTestActivity" test_group="TEST ALL">Bluetooth</TestCase>
|
---|
| 17 | + <TestCase class_name="WifiTestActivity" test_group="TEST ALL" first_test="yc">Wifi</TestCase>
|
---|
| 18 | + <TestCase class_name="SdCardTestActivity" test_group="TEST ALL" first_test="yc">SD Card</TestCase>
|
---|
| 19 | + <TestCase class_name="PCIETestActivity" test_group="TEST ALL">PCIE</TestCase>
|
---|
| 20 | + <TestCase class_name="SATATestActivity" test_group="TEST ALL">SATA</TestCase>
|
---|
| 21 | + <TestCase class_name="EthernetTestActivity" test_group="TEST ALL">Ethernet1</TestCase>
|
---|
| 22 | + <TestCase class_name="Ethernet2TestActivity" test_group="TEST ALL">Ethernet2</TestCase>
|
---|
| 23 | + <TestCase class_name="MobileNetTestActivity" test_group="TEST ALL">MobileNet</TestCase>
|
---|
| 24 | +
|
---|
| 25 | + <TestCase class_name="InfomationActivity" test_group="TEST ALL" first_test="yc">DDR/eMMC</TestCase>
|
---|
| 26 | + <TestCase class_name="TouchTestActivity" test_group="TEST ALL">Touch</TestCase>
|
---|
| 27 | + <TestCase class_name="SpeakerTestActivity" test_group="TEST ALL" first_test="yc">Speaker</TestCase>
|
---|
| 28 | + <TestCase class_name="PhoneMicTestActivity" test_group="TEST ALL" first_test="yc">MIC</TestCase>
|
---|
| 29 | + <TestCase class_name="USBDeviceTestActivity" test_group="TEST ALL">USB Device</TestCase>
|
---|
| 30 | + <TestCase class_name="RTCTestActivity" test_group="TEST ALL">RTC</TestCase>
|
---|
| 31 | + <TestCase class_name="CameraBackTestActivity" test_group="TEST ALL" first_test="yc">Camera_only</TestCase>
|
---|
| 32 | + <!-- <TestCase class_name="RtcTestActivity" test_group="TEST ALL">RTC</TestCase> -->
|
---|
| 33 | + <!-- TestCase class_name="GpsLocationTestActivity" test_group="TEST 2">GPS Location</TestCase> -->
|
---|
| 34 | + <!-- <TestCase class_name="MrioUSBTestActivity" test_group="TEST 2">Mrio USB</TestCase> -->
|
---|
| 35 | +
|
---|
| 36 | + <!-- <TestCase class_name="HdmiTestActivity" test_group="TEST ALL">HDMI</TestCase> -->
|
---|
| 37 | + <!-- <TestCase class_name="GpsLocationTestActivity" test_group="TEST ALL">GPS</TestCase> -->
|
---|
| 38 | + <!-- <TestCase class_name="GpsTestActivity" test_group="TEST ALL">GPSTest</TestCase> -->
|
---|
| 39 | + <!-- <TestCase class_name="StorageActivity" test_group="TEST ALL" first_test="yc">Storage</TestCase>-->
|
---|
| 40 | + <!-- <TestCase class_name="CompassTestActivity" test_group="TEST ALL">Compass</TestCase> -->
|
---|
| 41 | +
|
---|
| 42 | + <!--<TestCase class_name="LevelTestActivity" test_group="rest">Level</TestCase> -->
|
---|
| 43 | + <!--<TestCase class_name="MsensorTestActivity" test_group="TEST ALL">Msensor</TestCase>-->
|
---|
| 44 | + <!--<TestCase class_name="GyroscopeTestActivity" test_group="TEST ALL">Gyroscope</TestCase>-->
|
---|
| 45 | + <!--<TestCase class_name="LightsensorTestActivity" test_group="TEST ALL">Lightsensor</TestCase>-->
|
---|
| 46 | + <!--<TestCase class_name="RockVideoPlayer" test_group="TEST ALL">VideoPlayer</TestCase>-->
|
---|
| 47 | + <!-- <TestCase class_name="ClockTestActivity" test_group="TEST ALL">Clock</TestCase>-->
|
---|
| 48 | +
|
---|
| 49 | + <!--<TestCase class_name="HeadsetMicTestActivity" test_group="rest">Headset MIC</TestCase> -->
|
---|
| 50 | + <!-- <TestCase class_name="SimCardTestActivity" test_group="rest">Sim Card</TestCase> -->
|
---|
| 51 | + <!-- <TestCase class_name="FMRadioTestActivity" test_group="rest">FM Radio</TestCase> -->
|
---|
| 52 | +<!-- <TestCase class_name="LedTestActivity" test_group="TEST 1">LED</TestCase>
|
---|
| 53 | + <TestCase class_name="CirTestActivity" test_group="TEST 1">Cir</TestCase>
|
---|
| 54 | + <TestCase class_name="IrdaTestActivity" test_group="TEST 1">IrDA</TestCase> -->
|
---|
| 55 | +<!-- <TestCase class_name="CompassTestActivity" test_group="TEST 3">Compass</TestCase> -->
|
---|
| 56 | + <!-- <TestCase class_name="RuninTestActivity" test_group="RunIn">Runin</TestCase> -->
|
---|
| 57 | +
|
---|
| 58 | +</TestCaseList>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="UTF-8"?>
|
---|
| 2 | +<TestCaseList>
|
---|
| 3 | + <TestCase class_name="VersionTestActivity" test_group="TEST ALL">Version</TestCase>
|
---|
| 4 | + <TestCase class_name="LcdTestActivity" test_group="TEST ALL">LCD</TestCase>
|
---|
| 5 | + <TestCase class_name="TouchTestActivity" test_group="TEST ALL">Touch</TestCase>
|
---|
| 6 | + <TestCase class_name="CameraTestActivity" test_group="TEST ALL">Camera</TestCase>
|
---|
| 7 | + <!-- <TestCase class_name="VibrationTestActivity" test_group="rest">Vibration</TestCase> -->
|
---|
| 8 | + <TestCase class_name="SpeakerTestActivity" test_group="TEST ALL" first_test="yc">Speaker</TestCase>
|
---|
| 9 | + <TestCase class_name="GsensorTestActivity" test_group="TEST ALL" first_test="yc">Gsensor</TestCase>
|
---|
| 10 | + <!-- <TestCase class_name="HardwareInfoTestActivity" test_group="TEST AUTO">Hardware</TestCase> -->
|
---|
| 11 | + <TestCase class_name="BluetoothTestActivity" test_group="TEST ALL">Bluetooth</TestCase>
|
---|
| 12 | + <TestCase class_name="WifiTestActivity" test_group="TEST ALL" first_test="yc">Wifi</TestCase>
|
---|
| 13 | + <!-- <TestCase class_name="GpsTestActivity" test_group="TEST ALL">GPS</TestCase> -->
|
---|
| 14 | + <TestCase class_name="PhoneMicTestActivity" test_group="TEST ALL" first_test="yc">MIC</TestCase>
|
---|
| 15 | + <!-- <TestCase class_name="StorageTestActivity" test_group="TEST AUTO">Storage R/W</TestCase> -->
|
---|
| 16 | + <TestCase class_name="PowerTestActivity" test_group="TEST ALL">Battery</TestCase>
|
---|
| 17 | + <TestCase class_name="SdCardTestActivity" test_group="TEST ALL" first_test="yc">SD Card</TestCase>
|
---|
| 18 | + <TestCase class_name="KeyboardTestActivity" test_group="TEST ALL" first_test="yc">Keyboard</TestCase>
|
---|
| 19 | + <TestCase class_name="BrightnessTestActivity" test_group="TEST ALL">Brightness</TestCase>
|
---|
| 20 | + <TestCase class_name="UsbHostTestActivity" test_group="TEST ALL">UsbHost</TestCase>
|
---|
| 21 | +
|
---|
| 22 | + <!-- TestCase class_name="GpsLocationTestActivity" test_group="TEST 2">GPS Location</TestCase> -->
|
---|
| 23 | + <!-- <TestCase class_name="MrioUSBTestActivity" test_group="TEST 2">Mrio USB</TestCase> -->
|
---|
| 24 | +
|
---|
| 25 | + <TestCase class_name="HdmiTestActivity" test_group="TEST ALL">HDMI</TestCase>
|
---|
| 26 | + <TestCase class_name="GpsLocationTestActivity" test_group="TEST ALL">GPS</TestCase>
|
---|
| 27 | + <!-- <TestCase class_name="GpsTestActivity" test_group="TEST ALL">GPSTest</TestCase> -->
|
---|
| 28 | + <TestCase class_name="StorageActivity" test_group="TEST ALL" first_test="yc">Storage</TestCase>
|
---|
| 29 | + <TestCase class_name="CompassTestActivity" test_group="TEST ALL">Compass</TestCase> -->
|
---|
| 30 | +
|
---|
| 31 | + <!--<TestCase class_name="LevelTestActivity" test_group="rest">Level</TestCase> -->
|
---|
| 32 | + <TestCase class_name="MsensorTestActivity" test_group="TEST ALL">Msensor</TestCase>
|
---|
| 33 | + <TestCase class_name="GyroscopeTestActivity" test_group="TEST ALL">Gyroscope</TestCase>
|
---|
| 34 | + <TestCase class_name="LightsensorTestActivity" test_group="TEST ALL">Lightsensor</TestCase>
|
---|
| 35 | + <!--<TestCase class_name="HeadsetMicTestActivity" test_group="rest">Headset MIC</TestCase> -->
|
---|
| 36 | + <!-- <TestCase class_name="SimCardTestActivity" test_group="rest">Sim Card</TestCase> -->
|
---|
| 37 | + <!-- <TestCase class_name="FMRadioTestActivity" test_group="rest">FM Radio</TestCase> -->
|
---|
| 38 | +<!-- <TestCase class_name="LedTestActivity" test_group="TEST 1">LED</TestCase>
|
---|
| 39 | + <TestCase class_name="CirTestActivity" test_group="TEST 1">Cir</TestCase>
|
---|
| 40 | + <TestCase class_name="IrdaTestActivity" test_group="TEST 1">IrDA</TestCase> -->
|
---|
| 41 | +<!-- <TestCase class_name="CompassTestActivity" test_group="TEST 3">Compass</TestCase> -->
|
---|
| 42 | + <!-- <TestCase class_name="RuninTestActivity" test_group="RunIn">Runin</TestCase> -->
|
---|
| 43 | +
|
---|
| 44 | +</TestCaseList>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="UTF-8"?>
|
---|
| 2 | +<TestCaseList>
|
---|
| 3 | + <TestCase class_name="VersionTestActivity" test_group="TEST ALL">版本</TestCase>
|
---|
| 4 | + <TestCase class_name="InfomationActivity" test_group="TEST ALL" first_test="yc">硬件信息</TestCase>
|
---|
| 5 | + <TestCase class_name="LcdTestActivity" test_group="TEST ALL">LCD</TestCase>
|
---|
| 6 | + <TestCase class_name="TouchTestActivity" test_group="TEST ALL">触屏</TestCase>
|
---|
| 7 | + <TestCase class_name="CameraTestActivity" test_group="TEST ALL">摄像头</TestCase>
|
---|
| 8 | + <TestCase class_name="CameraBackTestActivity" test_group="TEST ALL">单摄像头</TestCase>
|
---|
| 9 | + <TestCase class_name="VibrationTestActivity" test_group="TEST ALL">震动</TestCase>
|
---|
| 10 | + <TestCase class_name="SpeakerTestActivity" test_group="TEST ALL" first_test="yc">喇叭</TestCase>
|
---|
| 11 | + <TestCase class_name="GsensorTestActivity" test_group="TEST ALL" first_test="yc">重力感应</TestCase>
|
---|
| 12 | + <!-- <TestCase class_name="HardwareInfoTestActivity" test_group="TEST AUTO">Hardware</TestCase> -->
|
---|
| 13 | + <TestCase class_name="BluetoothTestActivity" test_group="TEST ALL">蓝牙</TestCase>
|
---|
| 14 | + <TestCase class_name="WifiTestActivity" test_group="TEST ALL" first_test="yc">无线</TestCase>
|
---|
| 15 | + <!-- <TestCase class_name="GpsTestActivity" test_group="TEST ALL">GPS</TestCase> -->
|
---|
| 16 | + <TestCase class_name="PhoneMicTestActivity" test_group="TEST ALL" first_test="yc">录音</TestCase>
|
---|
| 17 | + <!-- <TestCase class_name="StorageTestActivity" test_group="TEST AUTO">Storage R/W</TestCase> -->
|
---|
| 18 | + <TestCase class_name="PowerTestActivity" test_group="TEST ALL">电池</TestCase>
|
---|
| 19 | + <TestCase class_name="SdCardTestActivity" test_group="TEST ALL" first_test="yc">sd卡</TestCase>
|
---|
| 20 | + <TestCase class_name="KeyboardTestActivity" test_group="TEST ALL" first_test="yc">键盘</TestCase>
|
---|
| 21 | + <TestCase class_name="BrightnessTestActivity" test_group="TEST ALL">亮度</TestCase>
|
---|
| 22 | + <TestCase class_name="UsbHostTestActivity" test_group="TEST ALL">u盘</TestCase>
|
---|
| 23 | + <TestCase class_name="PCIETestActivity" test_group="TEST ALL">PCIE</TestCase>
|
---|
| 24 | + <TestCase class_name="SATATestActivity" test_group="TEST ALL">SATA</TestCase>
|
---|
| 25 | + <TestCase class_name="EthernetTestActivity" test_group="TEST ALL">以太网</TestCase>
|
---|
| 26 | + <TestCase class_name="Ethernet2TestActivity" test_group="TEST ALL">以太网2</TestCase>
|
---|
| 27 | +
|
---|
| 28 | + <!-- TestCase class_name="GpsLocationTestActivity" test_group="TEST 2">GPS Location</TestCase> -->
|
---|
| 29 | + <!-- <TestCase class_name="MrioUSBTestActivity" test_group="TEST 2">Mrio USB</TestCase> -->
|
---|
| 30 | +
|
---|
| 31 | + <TestCase class_name="HdmiTestActivity" test_group="TEST ALL">HDMI</TestCase>
|
---|
| 32 | + <TestCase class_name="GpsLocationTestActivity" test_group="TEST ALL">GPS</TestCase>
|
---|
| 33 | + <!-- <TestCase class_name="GpsTestActivity" test_group="TEST ALL">GPSTest</TestCase> -->
|
---|
| 34 | + <TestCase class_name="StorageActivity" test_group="TEST ALL" first_test="yc">存储</TestCase>
|
---|
| 35 | + <TestCase class_name="CompassTestActivity" test_group="TEST ALL">罗盘</TestCase> -->
|
---|
| 36 | +
|
---|
| 37 | + <!--<TestCase class_name="LevelTestActivity" test_group="rest">Level</TestCase> -->
|
---|
| 38 | + <TestCase class_name="MsensorTestActivity" test_group="TEST ALL">磁场感应</TestCase>
|
---|
| 39 | + <TestCase class_name="GyroscopeTestActivity" test_group="TEST ALL">陀螺仪</TestCase>
|
---|
| 40 | + <TestCase class_name="LightsensorTestActivity" test_group="TEST ALL">光感</TestCase>
|
---|
| 41 | + <TestCase class_name="RockVideoPlayer" test_group="TEST ALL">视频播放</TestCase>
|
---|
| 42 | + <!-- <TestCase class_name="ClockTestActivity" test_group="TEST ALL">Clock</TestCase>-->
|
---|
| 43 | +
|
---|
| 44 | + <!--<TestCase class_name="HeadsetMicTestActivity" test_group="rest">Headset MIC</TestCase> -->
|
---|
| 45 | + <!-- <TestCase class_name="SimCardTestActivity" test_group="rest">Sim Card</TestCase> -->
|
---|
| 46 | + <!-- <TestCase class_name="FMRadioTestActivity" test_group="rest">FM Radio</TestCase> -->
|
---|
| 47 | +<!-- <TestCase class_name="LedTestActivity" test_group="TEST 1">LED</TestCase>
|
---|
| 48 | + <TestCase class_name="CirTestActivity" test_group="TEST 1">Cir</TestCase>
|
---|
| 49 | + <TestCase class_name="IrdaTestActivity" test_group="TEST 1">IrDA</TestCase> -->
|
---|
| 50 | +<!-- <TestCase class_name="CompassTestActivity" test_group="TEST 3">Compass</TestCase> -->
|
---|
| 51 | + <!-- <TestCase class_name="RuninTestActivity" test_group="RunIn">Runin</TestCase> -->
|
---|
| 52 | +
|
---|
| 53 | +</TestCaseList> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="UTF-8"?>
|
---|
| 2 | +<TestCaseList>
|
---|
| 3 | + <!-- <TestCase class_name="VersionTestActivity" test_group="TEST ALL">Version</TestCase> -->
|
---|
| 4 | + <!-- <TestCase class_name="LcdTestActivity" test_group="TEST ALL">LCD</TestCase> -->
|
---|
| 5 | + <!--<TestCase class_name="CameraTestActivity" test_group="TEST ALL" first_test="yc">Camera_only3</TestCase>-->
|
---|
| 6 | + <!--TestCase class_name="VibrationTestActivity" test_group="TEST ALL">Vibration</TestCase-->
|
---|
| 7 | + <!-- <TestCase class_name="GsensorTestActivity" test_group="TEST ALL" first_test="yc">Gsensor</TestCase> -->
|
---|
| 8 | + <!-- <TestCase class_name="HardwareInfoTestActivity" test_group="TEST AUTO">Hardware</TestCase> -->
|
---|
| 9 | + <!-- <TestCase class_name="GpsTestActivity" test_group="TEST ALL">GPS</TestCase> -->
|
---|
| 10 | +
|
---|
| 11 | + <!-- <TestCase class_name="StorageTestActivity" test_group="TEST AUTO">Storage R/W</TestCase> -->
|
---|
| 12 | + <!-- <TestCase class_name="PowerTestActivity" test_group="TEST ALL">Battery</TestCase> -->
|
---|
| 13 | + <!-- <TestCase class_name="KeyboardTestActivity" test_group="TEST ALL" first_test="yc">Keyboard</TestCase> -->
|
---|
| 14 | + <!-- <TestCase class_name="BrightnessTestActivity" test_group="TEST ALL">Brightness</TestCase> -->
|
---|
| 15 | +
|
---|
| 16 | + <TestCase class_name="WifiTestActivity" test_group="TEST ALL" first_test="yc">Wifi</TestCase>
|
---|
| 17 | + <TestCase class_name="BluetoothTestActivity" test_group="TEST ALL">Bluetooth</TestCase>
|
---|
| 18 | + <!-- <TestCase class_name="SdCardTestActivity" test_group="TEST ALL" first_test="yc">SD Card</TestCase> -->
|
---|
| 19 | + <!-- <TestCase class_name="PCIETestActivity" test_group="TEST ALL">PCIE</TestCase> -->
|
---|
| 20 | + <!-- <TestCase class_name="SATATestActivity" test_group="TEST ALL">SATA</TestCase> -->
|
---|
| 21 | + <!-- <TestCase class_name="Ethernet2TestActivity" test_group="TEST ALL">Ethernet0</TestCase> -->
|
---|
| 22 | + <!-- <TestCase class_name="EthernetTestActivity" test_group="TEST ALL">Ethernet1</TestCase> -->
|
---|
| 23 | + <!-- <TestCase class_name="MobileNetTestActivity" test_group="TEST ALL">MobileNet</TestCase> -->
|
---|
| 24 | +
|
---|
| 25 | + <TestCase class_name="InfomationActivity" test_group="TEST ALL" first_test="yc">DDR/eMMC</TestCase>
|
---|
| 26 | + <TestCase class_name="TouchTestActivity" test_group="TEST ALL">Touch</TestCase>
|
---|
| 27 | + <TestCase class_name="SpeakerTestActivity" test_group="TEST ALL" first_test="yc">Speaker</TestCase>
|
---|
| 28 | + <!-- <TestCase class_name="PhoneMicTestActivity" test_group="TEST ALL" first_test="yc">MIC</TestCase> -->
|
---|
| 29 | + <!-- <TestCase class_name="USBDeviceTestActivity" test_group="TEST ALL">USB Device</TestCase> -->
|
---|
| 30 | + <!-- <TestCase class_name="RTCTestActivity" test_group="TEST ALL">RTC</TestCase> -->
|
---|
| 31 | + <!-- <TestCase class_name="CameraBackTestActivity" test_group="TEST ALL" first_test="yc">Camera_only</TestCase> -->
|
---|
| 32 | + <!-- <TestCase class_name="RtcTestActivity" test_group="TEST ALL">RTC</TestCase> -->
|
---|
| 33 | + <!-- TestCase class_name="GpsLocationTestActivity" test_group="TEST 2">GPS Location</TestCase> -->
|
---|
| 34 | + <!-- <TestCase class_name="MrioUSBTestActivity" test_group="TEST 2">Mrio USB</TestCase> -->
|
---|
| 35 | +
|
---|
| 36 | + <!-- <TestCase class_name="HdmiTestActivity" test_group="TEST ALL">HDMI</TestCase> -->
|
---|
| 37 | + <!-- <TestCase class_name="GpsLocationTestActivity" test_group="TEST ALL">GPS</TestCase> -->
|
---|
| 38 | + <!-- <TestCase class_name="GpsTestActivity" test_group="TEST ALL">GPSTest</TestCase> -->
|
---|
| 39 | + <!-- <TestCase class_name="StorageActivity" test_group="TEST ALL" first_test="yc">Storage</TestCase>-->
|
---|
| 40 | + <!-- <TestCase class_name="CompassTestActivity" test_group="TEST ALL">Compass</TestCase> -->
|
---|
| 41 | +
|
---|
| 42 | + <!--<TestCase class_name="LevelTestActivity" test_group="rest">Level</TestCase> -->
|
---|
| 43 | + <!--<TestCase class_name="MsensorTestActivity" test_group="TEST ALL">Msensor</TestCase>-->
|
---|
| 44 | + <!--<TestCase class_name="GyroscopeTestActivity" test_group="TEST ALL">Gyroscope</TestCase>-->
|
---|
| 45 | + <!--<TestCase class_name="LightsensorTestActivity" test_group="TEST ALL">Lightsensor</TestCase>-->
|
---|
| 46 | + <!--<TestCase class_name="RockVideoPlayer" test_group="TEST ALL">VideoPlayer</TestCase>-->
|
---|
| 47 | + <!-- <TestCase class_name="ClockTestActivity" test_group="TEST ALL">Clock</TestCase>-->
|
---|
| 48 | +
|
---|
| 49 | + <!--<TestCase class_name="HeadsetMicTestActivity" test_group="rest">Headset MIC</TestCase> -->
|
---|
| 50 | + <!-- <TestCase class_name="SimCardTestActivity" test_group="rest">Sim Card</TestCase> -->
|
---|
| 51 | + <!-- <TestCase class_name="FMRadioTestActivity" test_group="rest">FM Radio</TestCase> -->
|
---|
| 52 | +<!-- <TestCase class_name="LedTestActivity" test_group="TEST 1">LED</TestCase>
|
---|
| 53 | + <TestCase class_name="CirTestActivity" test_group="TEST 1">Cir</TestCase>
|
---|
| 54 | + <TestCase class_name="IrdaTestActivity" test_group="TEST 1">IrDA</TestCase> -->
|
---|
| 55 | +<!-- <TestCase class_name="CompassTestActivity" test_group="TEST 3">Compass</TestCase> -->
|
---|
| 56 | + <!-- <TestCase class_name="RuninTestActivity" test_group="RunIn">Runin</TestCase> -->
|
---|
| 57 | +
|
---|
| 58 | +</TestCaseList>
|
---|
.. | .. |
---|
| 1 | +-optimizationpasses 5
|
---|
| 2 | +-dontusemixedcaseclassnames
|
---|
| 3 | +-dontskipnonpubliclibraryclasses
|
---|
| 4 | +-dontpreverify
|
---|
| 5 | +-verbose
|
---|
| 6 | +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
|
---|
| 7 | +
|
---|
| 8 | +-keep public class * extends android.app.Activity
|
---|
| 9 | +-keep public class * extends android.app.Application
|
---|
| 10 | +-keep public class * extends android.app.Service
|
---|
| 11 | +-keep public class * extends android.content.BroadcastReceiver
|
---|
| 12 | +-keep public class * extends android.content.ContentProvider
|
---|
| 13 | +-keep public class * extends android.app.backup.BackupAgentHelper
|
---|
| 14 | +-keep public class * extends android.preference.Preference
|
---|
| 15 | +-keep public class com.android.vending.licensing.ILicensingService
|
---|
| 16 | +
|
---|
| 17 | +-keepclasseswithmembernames class * {
|
---|
| 18 | + native <methods>;
|
---|
| 19 | +}
|
---|
| 20 | +
|
---|
| 21 | +-keepclasseswithmembers class * {
|
---|
| 22 | + public <init>(android.content.Context, android.util.AttributeSet);
|
---|
| 23 | +}
|
---|
| 24 | +
|
---|
| 25 | +-keepclasseswithmembers class * {
|
---|
| 26 | + public <init>(android.content.Context, android.util.AttributeSet, int);
|
---|
| 27 | +}
|
---|
| 28 | +
|
---|
| 29 | +-keepclassmembers class * extends android.app.Activity {
|
---|
| 30 | + public void *(android.view.View);
|
---|
| 31 | +}
|
---|
| 32 | +
|
---|
| 33 | +-keepclassmembers enum * {
|
---|
| 34 | + public static **[] values();
|
---|
| 35 | + public static ** valueOf(java.lang.String);
|
---|
| 36 | +}
|
---|
| 37 | +
|
---|
| 38 | +-keep class * implements android.os.Parcelable {
|
---|
| 39 | + public static final android.os.Parcelable$Creator *;
|
---|
| 40 | +}
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +
|
---|
| 3 | +<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 4 | + <item android:state_pressed="true" android:drawable="@drawable/icon" />
|
---|
| 5 | +</selector> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 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 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 18 | + android:layout_width="match_parent"
|
---|
| 19 | + android:layout_height="wrap_content"
|
---|
| 20 | + android:orientation="vertical">
|
---|
| 21 | +
|
---|
| 22 | +<!-- <TextView
|
---|
| 23 | + android:id="@+id/username_view"
|
---|
| 24 | + android:layout_height="wrap_content"
|
---|
| 25 | + android:layout_width="wrap_content"
|
---|
| 26 | + android:layout_marginLeft="20dip"
|
---|
| 27 | + android:layout_marginRight="20dip"
|
---|
| 28 | + android:text="@string/alert_dialog_username"
|
---|
| 29 | + android:gravity="left"
|
---|
| 30 | + android:textAppearance="?android:attr/textAppearanceMedium" />
|
---|
| 31 | +
|
---|
| 32 | + <EditText
|
---|
| 33 | + android:id="@+id/username_edit"
|
---|
| 34 | + android:layout_height="wrap_content"
|
---|
| 35 | + android:layout_width="match_parent"
|
---|
| 36 | + android:layout_marginLeft="20dip"
|
---|
| 37 | + android:layout_marginRight="20dip"
|
---|
| 38 | + android:scrollHorizontally="true"
|
---|
| 39 | + android:autoText="false"
|
---|
| 40 | + android:capitalize="none"
|
---|
| 41 | + android:gravity="fill_horizontal"
|
---|
| 42 | + android:textAppearance="?android:attr/textAppearanceMedium" />
|
---|
| 43 | + -->
|
---|
| 44 | + <TextView
|
---|
| 45 | + android:id="@+id/password_view"
|
---|
| 46 | + android:layout_height="wrap_content"
|
---|
| 47 | + android:layout_width="wrap_content"
|
---|
| 48 | + android:layout_marginLeft="20dip"
|
---|
| 49 | + android:layout_marginRight="20dip"
|
---|
| 50 | + android:text="@string/alert_dialog_password"
|
---|
| 51 | + android:gravity="left"
|
---|
| 52 | + android:textAppearance="?android:attr/textAppearanceMedium" />
|
---|
| 53 | +
|
---|
| 54 | + <EditText
|
---|
| 55 | + android:id="@+id/password_edit"
|
---|
| 56 | + android:layout_height="wrap_content"
|
---|
| 57 | + android:layout_width="match_parent"
|
---|
| 58 | + android:layout_marginLeft="20dip"
|
---|
| 59 | + android:layout_marginRight="20dip"
|
---|
| 60 | + android:scrollHorizontally="true"
|
---|
| 61 | + android:autoText="false"
|
---|
| 62 | + android:capitalize="none"
|
---|
| 63 | + android:gravity="fill_horizontal"
|
---|
| 64 | + android:password="true"
|
---|
| 65 | + android:textAppearance="?android:attr/textAppearanceMedium" />
|
---|
| 66 | +
|
---|
| 67 | +</LinearLayout>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout
|
---|
| 3 | + android:id="@+id/layout1"
|
---|
| 4 | + android:layout_width="fill_parent"
|
---|
| 5 | + android:layout_height="fill_parent"
|
---|
| 6 | + xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 7 | +>
|
---|
| 8 | + <LinearLayout
|
---|
| 9 | + android:layout_width="fill_parent"
|
---|
| 10 | + android:layout_height="wrap_content"
|
---|
| 11 | + android:orientation="vertical"
|
---|
| 12 | + android:paddingBottom= "60dip"
|
---|
| 13 | + >
|
---|
| 14 | +
|
---|
| 15 | + <TextView
|
---|
| 16 | + android:id="@+id/textTitle"
|
---|
| 17 | + android:visibility="visible"
|
---|
| 18 | + android:layout_width="fill_parent"
|
---|
| 19 | + android:layout_height="wrap_content"
|
---|
| 20 | + android:layout_centerInParent="true"
|
---|
| 21 | + android:gravity="center_horizontal"
|
---|
| 22 | + android:paddingTop="20px"
|
---|
| 23 | + android:textSize="24sp"
|
---|
| 24 | + android:text="@string/BluetoothTitle"
|
---|
| 25 | +/>
|
---|
| 26 | +
|
---|
| 27 | +
|
---|
| 28 | + <TextView
|
---|
| 29 | + android:id="@+id/textSubTitle"
|
---|
| 30 | + android:visibility="visible"
|
---|
| 31 | + android:layout_width="fill_parent"
|
---|
| 32 | + android:layout_height="wrap_content"
|
---|
| 33 | + android:layout_centerInParent="true"
|
---|
| 34 | + android:gravity="center_horizontal"
|
---|
| 35 | + android:paddingTop="20px"
|
---|
| 36 | + android:textSize="20sp"
|
---|
| 37 | + android:text="@string/BluetoothSubTitle"
|
---|
| 38 | + />
|
---|
| 39 | + <TextView
|
---|
| 40 | + android:id="@+id/resultText"
|
---|
| 41 | + android:layout_width="fill_parent"
|
---|
| 42 | + android:layout_height="wrap_content"
|
---|
| 43 | + android:layout_centerInParent="true"
|
---|
| 44 | + android:gravity="center_horizontal"
|
---|
| 45 | + android:paddingTop="20px"
|
---|
| 46 | + android:textSize="18sp"
|
---|
| 47 | + android:visibility="visible"
|
---|
| 48 | + />
|
---|
| 49 | +
|
---|
| 50 | + <RelativeLayout android:gravity="center_horizontal" android:layout_width="match_parent" android:id="@+id/relativeLayout1" android:layout_height="wrap_content">
|
---|
| 51 | +
|
---|
| 52 | + <ProgressBar android:visibility="visible"
|
---|
| 53 | + android:layout_width="wrap_content"
|
---|
| 54 | + android:layout_height="wrap_content" android:id="@+id/progress"/>
|
---|
| 55 | + </RelativeLayout>
|
---|
| 56 | +
|
---|
| 57 | +
|
---|
| 58 | +
|
---|
| 59 | + </LinearLayout>
|
---|
| 60 | +
|
---|
| 61 | + <include layout="@xml/control_buttons"/>
|
---|
| 62 | +
|
---|
| 63 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:id="@+id/layout1"
|
---|
| 3 | + android:layout_width="fill_parent" android:layout_height="fill_parent"
|
---|
| 4 | + xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 5 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 6 | + android:layout_height="wrap_content" android:orientation="vertical"
|
---|
| 7 | + android:paddingBottom="60dip">
|
---|
| 8 | +
|
---|
| 9 | + <TextView android:id="@+id/backLightTitle"
|
---|
| 10 | + android:visibility="visible" android:layout_width="fill_parent"
|
---|
| 11 | + android:layout_height="wrap_content" android:layout_centerInParent="true"
|
---|
| 12 | + android:gravity="center_horizontal" android:paddingTop="20px"
|
---|
| 13 | + android:textSize="24sp" android:text="@string/BrightnessTitle" />
|
---|
| 14 | +
|
---|
| 15 | +
|
---|
| 16 | + <TextView android:id="@+id/backLightSubTitle"
|
---|
| 17 | + android:visibility="visible" android:layout_width="fill_parent"
|
---|
| 18 | + android:layout_height="wrap_content" android:layout_centerInParent="true"
|
---|
| 19 | + android:gravity="center_horizontal" android:paddingTop="20px"
|
---|
| 20 | + android:text="@string/BrightnessSubTitle" />
|
---|
| 21 | +
|
---|
| 22 | +
|
---|
| 23 | +
|
---|
| 24 | + </LinearLayout>
|
---|
| 25 | +
|
---|
| 26 | + <ProgressBar android:id="@+id/brightnessBar"
|
---|
| 27 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 28 | + android:orientation="horizontal" android:layout_centerInParent="true"
|
---|
| 29 | + style="?android:attr/progressBarStyleHorizontal" />
|
---|
| 30 | + <TextView android:id="@+id/progressText" android:visibility="visible"
|
---|
| 31 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 32 | + android:layout_above="@id/brightnessBar" android:gravity="center_horizontal"
|
---|
| 33 | + android:paddingTop="20px" />
|
---|
| 34 | +
|
---|
| 35 | + <include layout="@xml/control_buttons"/>
|
---|
| 36 | +
|
---|
| 37 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout
|
---|
| 3 | + android:layout_width="fill_parent"
|
---|
| 4 | + android:layout_height="fill_parent"
|
---|
| 5 | + xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 6 | +>
|
---|
| 7 | +
|
---|
| 8 | + <TextView
|
---|
| 9 | + android:id="@+id/CameratestTitle"
|
---|
| 10 | + android:visibility="visible"
|
---|
| 11 | + android:layout_width="fill_parent"
|
---|
| 12 | + android:layout_height="wrap_content"
|
---|
| 13 | + android:gravity="center_horizontal"
|
---|
| 14 | + android:textSize="24sp"
|
---|
| 15 | + android:text="@string/CameraTitle"
|
---|
| 16 | + android:paddingTop = "20px"
|
---|
| 17 | + />
|
---|
| 18 | +
|
---|
| 19 | + <LinearLayout
|
---|
| 20 | + android:layout_width="fill_parent"
|
---|
| 21 | + android:layout_height="wrap_content"
|
---|
| 22 | + android:orientation="vertical"
|
---|
| 23 | + android:paddingBottom= "60dip"
|
---|
| 24 | + android:layout_below="@id/CameratestTitle"
|
---|
| 25 | + >
|
---|
| 26 | +
|
---|
| 27 | +
|
---|
| 28 | + <TextView android:id="@+id/CameratextMsg"
|
---|
| 29 | + android:visibility="visible"
|
---|
| 30 | + android:layout_height="wrap_content"
|
---|
| 31 | + android:text="@string/CameratextMsgText"
|
---|
| 32 | + android:layout_width="fill_parent"
|
---|
| 33 | + android:gravity="center_horizontal"
|
---|
| 34 | + android:paddingTop = "40px"
|
---|
| 35 | + android:textSize="18sp"
|
---|
| 36 | + />
|
---|
| 37 | +
|
---|
| 38 | +
|
---|
| 39 | +
|
---|
| 40 | + </LinearLayout>
|
---|
| 41 | +
|
---|
| 42 | + <include layout="@xml/control_buttons"/>
|
---|
| 43 | +
|
---|
| 44 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
---|
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
---|
| 3 | + android:layout_width="fill_parent" |
---|
| 4 | + android:layout_height="fill_parent" > |
---|
| 5 | + |
---|
| 6 | + <ImageView |
---|
| 7 | + android:id="@+id/imgV" |
---|
| 8 | + android:layout_width="wrap_content" |
---|
| 9 | + android:layout_height="wrap_content" |
---|
| 10 | + android:layout_centerHorizontal="true" |
---|
| 11 | + android:src="@drawable/arrow_up"/> |
---|
| 12 | + |
---|
| 13 | + |
---|
| 14 | +<include layout="@xml/control_buttons" android:id="@+id/compass_buttons"/> |
---|
| 15 | + |
---|
| 16 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
---|
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
---|
| 3 | + android:layout_width="fill_parent" |
---|
| 4 | + android:layout_height="fill_parent" > |
---|
| 5 | + |
---|
| 6 | + <TextView |
---|
| 7 | + android:id="@+id/CameratestTitle" |
---|
| 8 | + android:layout_width="fill_parent" |
---|
| 9 | + android:layout_height="wrap_content" |
---|
| 10 | + android:gravity="center_horizontal" |
---|
| 11 | + android:paddingTop="20px" |
---|
| 12 | + android:text="@string/CameraFlashTitle" |
---|
| 13 | + android:textSize="24sp" |
---|
| 14 | + android:visibility="visible" /> |
---|
| 15 | + |
---|
| 16 | + <LinearLayout |
---|
| 17 | + android:layout_width="fill_parent" |
---|
| 18 | + android:layout_height="wrap_content" |
---|
| 19 | + android:layout_below="@id/CameratestTitle" |
---|
| 20 | + android:orientation="vertical" |
---|
| 21 | + android:paddingBottom="60dip" > |
---|
| 22 | + |
---|
| 23 | + <TextView |
---|
| 24 | + android:id="@+id/CameratextMsg" |
---|
| 25 | + android:layout_width="fill_parent" |
---|
| 26 | + android:layout_height="wrap_content" |
---|
| 27 | + android:gravity="center_horizontal" |
---|
| 28 | + android:textSize="18sp" |
---|
| 29 | + android:paddingTop="40px" |
---|
| 30 | + android:text="@string/CameraFlashtextFront" |
---|
| 31 | + android:visibility="visible" /> |
---|
| 32 | + </LinearLayout> |
---|
| 33 | + <include layout="@xml/control_buttons" android:id="@+id/compass_buttons"/> |
---|
| 34 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:id="@+id/layout1"
|
---|
| 3 | + android:layout_width="fill_parent" android:layout_height="fill_parent"
|
---|
| 4 | + xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 5 | + <TextView android:id="@+id/CirTest" android:layout_width="fill_parent"
|
---|
| 6 | + android:layout_height="wrap_content" android:layout_alignParentTop="true"
|
---|
| 7 | + android:gravity="center_horizontal" android:paddingBottom="20px"
|
---|
| 8 | + android:textSize="24sp" android:visibility="visible" android:text="@string/CirTestTitle" />
|
---|
| 9 | + <TextView android:id="@+id/CirResult" android:layout_width="fill_parent"
|
---|
| 10 | + android:layout_height="wrap_content" android:layout_below="@id/CirTest"
|
---|
| 11 | + android:gravity="center_horizontal" android:textSize="20sp" />
|
---|
| 12 | + <TextView android:id="@+id/CirSendData" android:layout_width="fill_parent"
|
---|
| 13 | + android:layout_height="wrap_content" android:layout_below="@id/CirResult"
|
---|
| 14 | + android:gravity="center_horizontal" android:textSize="20sp" />
|
---|
| 15 | +
|
---|
| 16 | + <include layout="@xml/control_buttons"/>
|
---|
| 17 | +
|
---|
| 18 | +
|
---|
| 19 | + <Button android:id="@+id/send" android:layout_width="wrap_content"
|
---|
| 20 | + android:layout_height="wrap_content" android:text="@string/CirSend"
|
---|
| 21 | + android:layout_below="@id/CirSendData" />
|
---|
| 22 | +
|
---|
| 23 | +
|
---|
| 24 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:layout_width="fill_parent"
|
---|
| 3 | + android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 4 | +
|
---|
| 5 | + <RelativeLayout android:layout_width="fill_parent"
|
---|
| 6 | + android:layout_height="60sp" android:id="@+id/Titles">
|
---|
| 7 | + <TextView android:id="@+id/compassText"
|
---|
| 8 | + android:layout_alignParentLeft="true" android:layout_width="wrap_content"
|
---|
| 9 | + android:layout_height="fill_parent" android:textSize="20sp" />
|
---|
| 10 | + <Button android:id="@+id/Start"
|
---|
| 11 | + android:layout_alignParentRight="true" android:layout_height="wrap_content"
|
---|
| 12 | + android:layout_width="wrap_content" android:text="@string/start" />
|
---|
| 13 | + </RelativeLayout>
|
---|
| 14 | +
|
---|
| 15 | +<include layout="@xml/control_buttons" android:id="@+id/compass_buttons"/>
|
---|
| 16 | + <com.DeviceTest.view.CompassView
|
---|
| 17 | + android:id="@+id/compasstestview" android:layout_above="@id/compass_buttons"
|
---|
| 18 | + android:layout_below="@id/Titles" android:layout_width="match_parent"
|
---|
| 19 | + android:layout_height="match_parent" />
|
---|
| 20 | +
|
---|
| 21 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 3 | + android:layout_width="match_parent"
|
---|
| 4 | + android:layout_height="match_parent">
|
---|
| 5 | +
|
---|
| 6 | + <LinearLayout
|
---|
| 7 | + android:layout_width="match_parent"
|
---|
| 8 | + android:layout_height="wrap_content"
|
---|
| 9 | + android:orientation="vertical"
|
---|
| 10 | + android:paddingBottom="60dp">
|
---|
| 11 | +
|
---|
| 12 | + <TextView
|
---|
| 13 | + android:id="@+id/textTitle"
|
---|
| 14 | + android:layout_width="match_parent"
|
---|
| 15 | + android:layout_height="wrap_content"
|
---|
| 16 | + android:gravity="center_horizontal"
|
---|
| 17 | + android:paddingTop="20px"
|
---|
| 18 | + android:text="@string/EthernetTitle"
|
---|
| 19 | + android:textSize="24sp"
|
---|
| 20 | + android:visibility="visible" />
|
---|
| 21 | +
|
---|
| 22 | + <TextView
|
---|
| 23 | + android:id="@+id/txt_ethInfo"
|
---|
| 24 | + android:layout_width="match_parent"
|
---|
| 25 | + android:layout_height="wrap_content"
|
---|
| 26 | + android:gravity="center_horizontal"
|
---|
| 27 | + android:paddingTop="20px"
|
---|
| 28 | + android:textSize="20sp"
|
---|
| 29 | + android:visibility="visible" />
|
---|
| 30 | +
|
---|
| 31 | + <ProgressBar
|
---|
| 32 | + android:id="@+id/progress"
|
---|
| 33 | + android:layout_width="wrap_content"
|
---|
| 34 | + android:layout_height="wrap_content"
|
---|
| 35 | + android:layout_gravity="center"
|
---|
| 36 | + android:visibility="gone" />
|
---|
| 37 | +
|
---|
| 38 | + <TextView
|
---|
| 39 | + android:id="@+id/txt_result"
|
---|
| 40 | + android:layout_width="match_parent"
|
---|
| 41 | + android:layout_height="wrap_content"
|
---|
| 42 | + android:gravity="center_horizontal"
|
---|
| 43 | + android:text="@string/EthernetConnectWarn"
|
---|
| 44 | + android:textSize="18sp"
|
---|
| 45 | + android:visibility="visible" />
|
---|
| 46 | +
|
---|
| 47 | + </LinearLayout>
|
---|
| 48 | +
|
---|
| 49 | + <include layout="@xml/control_buttons" />
|
---|
| 50 | +
|
---|
| 51 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 2 | + android:layout_width="fill_parent"
|
---|
| 3 | + android:layout_height="fill_parent"
|
---|
| 4 | + android:orientation="vertical">
|
---|
| 5 | + <!-- firmeware version -->
|
---|
| 6 | + <LinearLayout
|
---|
| 7 | + android:background="@drawable/per_bk"
|
---|
| 8 | + android:layout_width="fill_parent"
|
---|
| 9 | + android:layout_height="0dip"
|
---|
| 10 | + android:layout_weight="1"
|
---|
| 11 | + android:orientation="horizontal">
|
---|
| 12 | + <TextView
|
---|
| 13 | + android:id="@+id/product_name"
|
---|
| 14 | + android:textColor="@android:color/white"
|
---|
| 15 | + android:paddingLeft="20dip"
|
---|
| 16 | + android:gravity="center_vertical"
|
---|
| 17 | + android:layout_width="0dip"
|
---|
| 18 | + android:layout_weight="1"
|
---|
| 19 | + android:layout_height="fill_parent"/>
|
---|
| 20 | + <TextView
|
---|
| 21 | + android:id="@+id/product_version"
|
---|
| 22 | + android:textColor="@android:color/white"
|
---|
| 23 | + android:paddingLeft="20dip"
|
---|
| 24 | + android:gravity="center_vertical"
|
---|
| 25 | + android:maxLines="1"
|
---|
| 26 | + android:layout_width="0dip"
|
---|
| 27 | + android:layout_weight="3"
|
---|
| 28 | + android:layout_height="fill_parent"/>
|
---|
| 29 | + </LinearLayout>
|
---|
| 30 | +
|
---|
| 31 | + <!-- Storage inforamtion -->
|
---|
| 32 | + <LinearLayout
|
---|
| 33 | + android:background="@drawable/per_bk"
|
---|
| 34 | + android:layout_width="fill_parent"
|
---|
| 35 | + android:layout_height="0dip"
|
---|
| 36 | + android:layout_weight="1">
|
---|
| 37 | + <TextView
|
---|
| 38 | + android:id="@+id/nand_storage"
|
---|
| 39 | + android:textColor="@android:color/white"
|
---|
| 40 | + android:paddingLeft="20dip"
|
---|
| 41 | + android:gravity="center_vertical"
|
---|
| 42 | + android:layout_width="0dip"
|
---|
| 43 | + android:layout_weight="1"
|
---|
| 44 | + android:layout_height="fill_parent"/>
|
---|
| 45 | + <TextView
|
---|
| 46 | + android:id="@+id/available_nand_storage"
|
---|
| 47 | + android:textColor="@android:color/white"
|
---|
| 48 | + android:paddingLeft="20dip"
|
---|
| 49 | + android:gravity="center_vertical"
|
---|
| 50 | + android:layout_width="0dip"
|
---|
| 51 | + android:layout_weight="1"
|
---|
| 52 | + android:layout_height="fill_parent"/>
|
---|
| 53 | + </LinearLayout>
|
---|
| 54 | +
|
---|
| 55 | + <!-- wifi & sdcard & otg -->
|
---|
| 56 | + <LinearLayout
|
---|
| 57 | + android:layout_width="fill_parent"
|
---|
| 58 | + android:layout_height="0dip"
|
---|
| 59 | + android:layout_weight="2">
|
---|
| 60 | + <com.DeviceTest.view.TestView
|
---|
| 61 | + android:background="@drawable/per_bk"
|
---|
| 62 | + android:id="@+id/wifitestview"
|
---|
| 63 | + android:layout_width="0dip"
|
---|
| 64 | + android:layout_weight="1"
|
---|
| 65 | + android:layout_height="fill_parent"
|
---|
| 66 | + android:textColor="@android:color/white"
|
---|
| 67 | + android:paddingLeft="20dip"
|
---|
| 68 | + android:paddingTop="20dip"
|
---|
| 69 | + android:textSize="22sp"
|
---|
| 70 | + android:text="@string/Wifitest"/>
|
---|
| 71 | + <com.DeviceTest.view.TestView
|
---|
| 72 | + android:background="@drawable/per_bk"
|
---|
| 73 | + android:id="@+id/sdcardtestview"
|
---|
| 74 | + android:layout_width="0dip"
|
---|
| 75 | + android:layout_weight="1"
|
---|
| 76 | + android:layout_height="fill_parent"
|
---|
| 77 | + android:textColor="@android:color/white"
|
---|
| 78 | + android:paddingLeft="20dip"
|
---|
| 79 | + android:paddingTop="20dip"
|
---|
| 80 | + android:textSize="22sp"
|
---|
| 81 | + android:text="@string/SdCardTitle"/>
|
---|
| 82 | + <com.DeviceTest.view.TestView
|
---|
| 83 | + android:background="@drawable/per_bk"
|
---|
| 84 | + android:id="@+id/usbhosttestview"
|
---|
| 85 | + android:layout_width="0dip"
|
---|
| 86 | + android:layout_weight="1"
|
---|
| 87 | + android:layout_height="fill_parent"
|
---|
| 88 | + android:textColor="@android:color/white"
|
---|
| 89 | + android:paddingLeft="20dip"
|
---|
| 90 | + android:paddingTop="20dip"
|
---|
| 91 | + android:textSize="22sp"
|
---|
| 92 | + android:text="@string/UsbHostTestTitle"/>
|
---|
| 93 | + </LinearLayout>
|
---|
| 94 | +
|
---|
| 95 | + <!--powerinformation & gsensor & camera -->
|
---|
| 96 | + <LinearLayout
|
---|
| 97 | + android:layout_width="fill_parent"
|
---|
| 98 | + android:layout_height="0dip"
|
---|
| 99 | + android:layout_weight="4"
|
---|
| 100 | + android:orientation="horizontal">
|
---|
| 101 | + <LinearLayout
|
---|
| 102 | + android:orientation="vertical"
|
---|
| 103 | + android:background="@drawable/per_bk"
|
---|
| 104 | + android:layout_width="0dip"
|
---|
| 105 | + android:layout_weight="1"
|
---|
| 106 | + android:layout_height="fill_parent">
|
---|
| 107 | + <TextView
|
---|
| 108 | + android:textColor="@android:color/white"
|
---|
| 109 | + android:textSize="22sp" android:layout_width="fill_parent"
|
---|
| 110 | + android:layout_height="wrap_content" android:layout_centerInParent="true"
|
---|
| 111 | + android:gravity="left" android:paddingTop="10sp"
|
---|
| 112 | + android:visibility="visible" android:id="@+id/chargeStatusText" />
|
---|
| 113 | + <TextView
|
---|
| 114 | + android:textColor="@android:color/white"
|
---|
| 115 | + android:textSize="22sp" android:layout_width="fill_parent"
|
---|
| 116 | + android:layout_height="wrap_content" android:layout_centerInParent="true"
|
---|
| 117 | + android:gravity="left" android:paddingTop="10sp"
|
---|
| 118 | + android:visibility="visible" android:id="@+id/voltageText" />
|
---|
| 119 | + <TextView
|
---|
| 120 | + android:textColor="@android:color/white"
|
---|
| 121 | + android:textSize="22sp" android:layout_width="fill_parent"
|
---|
| 122 | + android:layout_height="wrap_content" android:layout_centerInParent="true"
|
---|
| 123 | + android:gravity="left" android:paddingTop="10sp"
|
---|
| 124 | + android:visibility="visible" android:id="@+id/currentText" />
|
---|
| 125 | + <TextView
|
---|
| 126 | + android:textColor="@android:color/white"
|
---|
| 127 | + android:textSize="22sp" android:layout_width="fill_parent"
|
---|
| 128 | + android:layout_height="wrap_content" android:layout_centerInParent="true"
|
---|
| 129 | + android:gravity="left" android:paddingTop="10sp"
|
---|
| 130 | + android:visibility="visible" android:id="@+id/capacityText" />
|
---|
| 131 | + <TextView
|
---|
| 132 | + android:textColor="@android:color/white"
|
---|
| 133 | + android:textSize="22sp" android:layout_width="fill_parent"
|
---|
| 134 | + android:layout_height="wrap_content" android:layout_centerInParent="true"
|
---|
| 135 | + android:gravity="left" android:paddingTop="10sp"
|
---|
| 136 | + android:visibility="visible" android:id="@+id/plugText" />
|
---|
| 137 | + </LinearLayout>
|
---|
| 138 | + <FrameLayout
|
---|
| 139 | + android:background="@drawable/per_bk"
|
---|
| 140 | + android:layout_width="0dip"
|
---|
| 141 | + android:layout_weight="1"
|
---|
| 142 | + android:layout_height="fill_parent">
|
---|
| 143 | + <com.DeviceTest.view.GsensorBall
|
---|
| 144 | + android:id="@+id/gsensorball"
|
---|
| 145 | + android:layout_width="fill_parent"
|
---|
| 146 | + android:layout_height="fill_parent"/>
|
---|
| 147 | + <TextView
|
---|
| 148 | + android:id="@+id/gsensortext"
|
---|
| 149 | + android:textColor="@android:color/white"
|
---|
| 150 | + android:textSize="22sp"
|
---|
| 151 | + android:layout_width="wrap_content"
|
---|
| 152 | + android:layout_height="wrap_content"/>
|
---|
| 153 | + </FrameLayout>
|
---|
| 154 | + <FrameLayout
|
---|
| 155 | + android:background="@drawable/per_bk"
|
---|
| 156 | + android:layout_width="0dip"
|
---|
| 157 | + android:layout_weight="1"
|
---|
| 158 | + android:layout_height="fill_parent">
|
---|
| 159 | + <SurfaceView
|
---|
| 160 | + android:layout_width="fill_parent"
|
---|
| 161 | + android:layout_height="fill_parent"
|
---|
| 162 | + android:id="@+id/camera_preview"/>
|
---|
| 163 | + <Button
|
---|
| 164 | + android:layout_gravity="top|right"
|
---|
| 165 | + android:layout_width="100dip"
|
---|
| 166 | + android:layout_height="60dip"
|
---|
| 167 | + android:id="@+id/camera_switch_btu"
|
---|
| 168 | + android:text="@string/camera_switch"
|
---|
| 169 | + android:textStyle="bold"
|
---|
| 170 | + android:textSize="20sp"
|
---|
| 171 | + android:textColor="#ffffff00"/>
|
---|
| 172 | + <TextView
|
---|
| 173 | + android:id="@+id/nocamera"
|
---|
| 174 | + android:layout_width="fill_parent"
|
---|
| 175 | + android:layout_height="fill_parent"
|
---|
| 176 | + android:text="@string/nocamera"
|
---|
| 177 | + android:visibility="gone"
|
---|
| 178 | + android:textStyle="bold"
|
---|
| 179 | + android:textSize="20sp"
|
---|
| 180 | + android:textColor="#ffff0000"/>
|
---|
| 181 | + </FrameLayout>
|
---|
| 182 | + </LinearLayout>
|
---|
| 183 | +
|
---|
| 184 | +
|
---|
| 185 | + <!-- record & button(single test & close application) -->
|
---|
| 186 | + <LinearLayout
|
---|
| 187 | + android:layout_width="fill_parent"
|
---|
| 188 | + android:layout_height="0dip"
|
---|
| 189 | + android:orientation="horizontal"
|
---|
| 190 | + android:layout_weight="5"
|
---|
| 191 | + >
|
---|
| 192 | + <LinearLayout
|
---|
| 193 | + android:background="@drawable/per_bk"
|
---|
| 194 | + android:orientation="vertical"
|
---|
| 195 | + android:layout_width="0dip"
|
---|
| 196 | + android:layout_weight="2"
|
---|
| 197 | + android:layout_height="fill_parent">
|
---|
| 198 | + <!-- brightness -->
|
---|
| 199 | + <LinearLayout
|
---|
| 200 | + android:background="@drawable/per_bk"
|
---|
| 201 | + android:layout_width="fill_parent"
|
---|
| 202 | + android:layout_height="50dp"
|
---|
| 203 | + android:orientation="horizontal">
|
---|
| 204 | + <Button
|
---|
| 205 | + android:id="@+id/brightnesstestbut"
|
---|
| 206 | + android:layout_width="0dip"
|
---|
| 207 | + android:layout_weight="3"
|
---|
| 208 | + android:layout_height="fill_parent"
|
---|
| 209 | + android:text="@string/BrightnessTitle"
|
---|
| 210 | + android:textStyle="bold"
|
---|
| 211 | + android:textSize="18sp"
|
---|
| 212 | + android:textColor="#ffffff00"/>
|
---|
| 213 | + <ProgressBar android:id="@+id/brightnessBar"
|
---|
| 214 | + android:layout_gravity="center_vertical"
|
---|
| 215 | + android:layout_width="0dip"
|
---|
| 216 | + android:layout_weight="7"
|
---|
| 217 | + android:layout_height="wrap_content"
|
---|
| 218 | + android:orientation="horizontal"
|
---|
| 219 | + android:layout_centerInParent="true"
|
---|
| 220 | + style="?android:attr/progressBarStyleHorizontal" />
|
---|
| 221 | + </LinearLayout>
|
---|
| 222 | + <LinearLayout
|
---|
| 223 | + android:layout_width="fill_parent"
|
---|
| 224 | + android:layout_height="fill_parent"
|
---|
| 225 | + android:orientation="horizontal">
|
---|
| 226 | + <LinearLayout
|
---|
| 227 | + android:background="@drawable/per_bk"
|
---|
| 228 | + android:orientation="vertical"
|
---|
| 229 | + android:layout_width="0dip"
|
---|
| 230 | + android:layout_weight="1"
|
---|
| 231 | + android:layout_height="fill_parent">
|
---|
| 232 | + <com.DeviceTest.helper.VUMeter android:id="@+id/uvMeter"
|
---|
| 233 | + android:background="@drawable/vumeter"
|
---|
| 234 | + android:layout_gravity="center_horizontal"
|
---|
| 235 | + android:layout_width="150dp"
|
---|
| 236 | + android:layout_height="40dp"
|
---|
| 237 | + android:layout_centerInParent="true" />
|
---|
| 238 | + <LinearLayout
|
---|
| 239 | + android:orientation="horizontal"
|
---|
| 240 | + android:layout_width="fill_parent"
|
---|
| 241 | + android:layout_height="fill_parent">
|
---|
| 242 | + <TextView
|
---|
| 243 | + android:gravity="center_vertical|center_horizontal"
|
---|
| 244 | + android:textSize="20sp"
|
---|
| 245 | + android:id="@+id/recordtext"
|
---|
| 246 | + android:layout_width="0dip"
|
---|
| 247 | + android:layout_weight="1"
|
---|
| 248 | + android:layout_height="fill_parent"/>
|
---|
| 249 | + <Button
|
---|
| 250 | + android:id="@+id/recordtestbutton"
|
---|
| 251 | + android:text="@string/RecordTest"
|
---|
| 252 | + android:textStyle="bold"
|
---|
| 253 | + android:textSize="20sp"
|
---|
| 254 | + android:textColor="#ffffff00"
|
---|
| 255 | + android:layout_width="0dip"
|
---|
| 256 | + android:layout_weight="1"
|
---|
| 257 | + android:layout_height="fill_parent"/>
|
---|
| 258 | + </LinearLayout>
|
---|
| 259 | + </LinearLayout>
|
---|
| 260 | + <LinearLayout
|
---|
| 261 | + android:background="@drawable/per_bk"
|
---|
| 262 | + android:layout_width="0dip"
|
---|
| 263 | + android:layout_weight="1"
|
---|
| 264 | + android:layout_height="fill_parent"
|
---|
| 265 | + android:orientation="vertical">
|
---|
| 266 | + <TextView
|
---|
| 267 | + android:text="@string/KeyboardTestTitle"
|
---|
| 268 | + android:textColor="@android:color/white"
|
---|
| 269 | + android:textSize="18sp"
|
---|
| 270 | + android:layout_width="fill_parent"
|
---|
| 271 | + android:layout_height="wrap_content"
|
---|
| 272 | + />
|
---|
| 273 | + <com.DeviceTest.view.KeyTestView
|
---|
| 274 | + android:id="@+id/keytestview"
|
---|
| 275 | + android:layout_width="fill_parent"
|
---|
| 276 | + android:layout_height="wrap_content"
|
---|
| 277 | + />
|
---|
| 278 | + </LinearLayout>
|
---|
| 279 | + </LinearLayout>
|
---|
| 280 | + </LinearLayout>
|
---|
| 281 | + <LinearLayout
|
---|
| 282 | + android:background="@drawable/per_bk"
|
---|
| 283 | + android:orientation="vertical"
|
---|
| 284 | + android:layout_width="0dip"
|
---|
| 285 | + android:layout_weight="1"
|
---|
| 286 | + android:layout_height="fill_parent">
|
---|
| 287 | + <Button
|
---|
| 288 | + android:id="@+id/singletest"
|
---|
| 289 | + android:text="@string/SingleTest"
|
---|
| 290 | + android:textStyle="bold"
|
---|
| 291 | + android:textSize="22sp"
|
---|
| 292 | + android:textColor="#ffffff00"
|
---|
| 293 | + android:layout_width="fill_parent"
|
---|
| 294 | + android:layout_height="0dip"
|
---|
| 295 | + android:layout_weight="1"/>
|
---|
| 296 | + <Button
|
---|
| 297 | + android:id="@+id/closefirstrun"
|
---|
| 298 | + android:text="@string/Cancel"
|
---|
| 299 | + android:textStyle="bold"
|
---|
| 300 | + android:textSize="22sp"
|
---|
| 301 | + android:textColor="#ffffff00"
|
---|
| 302 | + android:layout_marginTop="5dip"
|
---|
| 303 | + android:layout_width="fill_parent"
|
---|
| 304 | + android:layout_height="0dip"
|
---|
| 305 | + android:layout_weight="1"/>
|
---|
| 306 | + </LinearLayout>
|
---|
| 307 | + </LinearLayout>
|
---|
| 308 | +</LinearLayout>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:id="@+id/layout1"
|
---|
| 3 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 4 | + xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 5 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 6 | + android:layout_height="wrap_content" android:orientation="vertical"
|
---|
| 7 | + android:paddingBottom="60dip">
|
---|
| 8 | +
|
---|
| 9 | + <TextView android:id="@+id/textTitle" android:visibility="visible"
|
---|
| 10 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 11 | + android:layout_centerInParent="true" android:gravity="center_horizontal"
|
---|
| 12 | + android:textSize="24sp" android:text="@string/FlashLightTest" android:paddingTop="20px" />
|
---|
| 13 | +
|
---|
| 14 | +
|
---|
| 15 | + <TextView android:id="@+id/textSubTitle" android:visibility="visible"
|
---|
| 16 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 17 | + android:layout_centerInParent="true" android:gravity="center_horizontal"
|
---|
| 18 | + android:text="@string/FlashLightTestSubText" android:textSize="20sp" android:paddingTop="20px" />
|
---|
| 19 | + </LinearLayout>
|
---|
| 20 | +
|
---|
| 21 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 22 | + android:layout_height="wrap_content"
|
---|
| 23 | + android:orientation="horizontal"
|
---|
| 24 | + android:layout_centerVertical="true"
|
---|
| 25 | + >
|
---|
| 26 | +
|
---|
| 27 | + <Button android:id="@+id/btn_open_flashlight"
|
---|
| 28 | + android:layout_width="0dip"
|
---|
| 29 | + android:layout_height="wrap_content"
|
---|
| 30 | + android:layout_weight="1"
|
---|
| 31 | + android:text="@string/OpenFlashLight"
|
---|
| 32 | + />
|
---|
| 33 | +
|
---|
| 34 | + <Button android:id="@+id/btn_shutdown_flashlight"
|
---|
| 35 | + android:layout_width="0dip"
|
---|
| 36 | + android:layout_height="wrap_content"
|
---|
| 37 | + android:layout_weight="1"
|
---|
| 38 | + android:text="@string/ShutDownFlashLight"
|
---|
| 39 | + />
|
---|
| 40 | + </LinearLayout>
|
---|
| 41 | +
|
---|
| 42 | + <include layout="@xml/control_buttons" android:id="@+id/compass_buttons"/>
|
---|
| 43 | +
|
---|
| 44 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout
|
---|
| 3 | + android:layout_width="fill_parent"
|
---|
| 4 | + android:layout_height="fill_parent"
|
---|
| 5 | + xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 6 | +>
|
---|
| 7 | + <TextView
|
---|
| 8 | + android:id="@+id/FMRadioTestId"
|
---|
| 9 | + android:visibility="visible"
|
---|
| 10 | + android:layout_width="fill_parent"
|
---|
| 11 | + android:layout_height="wrap_content"
|
---|
| 12 | + android:gravity="center_horizontal"
|
---|
| 13 | + android:textSize="24sp"
|
---|
| 14 | + android:text="@string/FMRadioTestTitle"
|
---|
| 15 | + android:paddingTop = "20px"/>
|
---|
| 16 | +
|
---|
| 17 | + <LinearLayout
|
---|
| 18 | + android:layout_width="fill_parent"
|
---|
| 19 | + android:layout_height="wrap_content"
|
---|
| 20 | + android:orientation="vertical"
|
---|
| 21 | + android:paddingBottom= "60dip"
|
---|
| 22 | + android:layout_below="@id/FMRadioTestId">
|
---|
| 23 | +
|
---|
| 24 | + <TextView
|
---|
| 25 | + android:id="@+id/FMRadioTextMsgID"
|
---|
| 26 | + android:visibility="visible"
|
---|
| 27 | + android:layout_height="wrap_content"
|
---|
| 28 | + android:text="@string/FMRadioTextMsgText"
|
---|
| 29 | + android:layout_width="fill_parent"
|
---|
| 30 | + android:gravity="center_horizontal"
|
---|
| 31 | + android:paddingTop = "40px"/>
|
---|
| 32 | +
|
---|
| 33 | + <TextView
|
---|
| 34 | + android:id="@+id/FMRadioTestResult"
|
---|
| 35 | + android:visibility="invisible"
|
---|
| 36 | + android:layout_height="wrap_content"
|
---|
| 37 | + android:text="@string/OKText"
|
---|
| 38 | + android:layout_width="fill_parent"
|
---|
| 39 | + android:gravity="center_horizontal"
|
---|
| 40 | + android:paddingTop = "40px"/>
|
---|
| 41 | +
|
---|
| 42 | +
|
---|
| 43 | + </LinearLayout>
|
---|
| 44 | +
|
---|
| 45 | + <include layout="@xml/control_buttons" android:id="@+id/compass_buttons"/>
|
---|
| 46 | +
|
---|
| 47 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:id="@+id/layout1"
|
---|
| 3 | + android:layout_width="fill_parent" android:layout_height="fill_parent"
|
---|
| 4 | + xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 5 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 6 | + android:layout_height="wrap_content" android:orientation="vertical"
|
---|
| 7 | + android:paddingBottom="60dip">
|
---|
| 8 | +
|
---|
| 9 | + <TextView android:id="@+id/textTitle" android:visibility="visible"
|
---|
| 10 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 11 | + android:layout_centerInParent="true" android:gravity="center_horizontal"
|
---|
| 12 | + android:textSize="24sp" android:paddingTop="20px" android:text="@string/GpsLocationTestTitle" />
|
---|
| 13 | +
|
---|
| 14 | +
|
---|
| 15 | + <TextView android:id="@+id/textSubTitle" android:visibility="visible"
|
---|
| 16 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 17 | + android:layout_centerInParent="true" android:gravity="center_horizontal"
|
---|
| 18 | + android:paddingTop="20px" android:textSize="20sp" />
|
---|
| 19 | + <TextView android:layout_width="fill_parent"
|
---|
| 20 | + android:layout_height="wrap_content" android:layout_centerInParent="true"
|
---|
| 21 | + android:gravity="center_horizontal" android:paddingTop="20px"
|
---|
| 22 | + android:textSize="18sp" android:visibility="visible" android:id="@+id/gpslocationresultText" />
|
---|
| 23 | + <TextView android:layout_width="fill_parent"
|
---|
| 24 | + android:layout_height="wrap_content" android:layout_centerInParent="true"
|
---|
| 25 | + android:gravity="center_horizontal" android:paddingTop="20px"
|
---|
| 26 | + android:textSize="18sp" android:visibility="visible" android:id="@+id/nmealocationresultText" />
|
---|
| 27 | + </LinearLayout>
|
---|
| 28 | +
|
---|
| 29 | + <include layout="@xml/control_buttons" android:id="@+id/compass_buttons"/>
|
---|
| 30 | +
|
---|
| 31 | +
|
---|
| 32 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:id="@+id/layout1"
|
---|
| 3 | + android:layout_width="fill_parent" android:layout_height="fill_parent"
|
---|
| 4 | + xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 5 | +
|
---|
| 6 | + <include layout="@xml/control_buttons" android:id="@+id/gps_btns"/>
|
---|
| 7 | +
|
---|
| 8 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 9 | + android:layout_height="wrap_content" android:orientation="vertical"
|
---|
| 10 | + android:layout_above="@id/gps_btns" android:layout_alignParentTop="true">
|
---|
| 11 | +
|
---|
| 12 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 13 | + android:layout_height="wrap_content" android:orientation="horizontal"
|
---|
| 14 | + >
|
---|
| 15 | + <TextView android:id="@+id/gpsTTFF" android:visibility="visible"
|
---|
| 16 | + android:layout_width="0dip" android:layout_height="wrap_content"
|
---|
| 17 | + android:textSize="30sp" android:layout_weight="2"/>
|
---|
| 18 | + <TextView android:id="@+id/gpsCN" android:visibility="visible"
|
---|
| 19 | + android:layout_width="0dip" android:layout_height="wrap_content"
|
---|
| 20 | + android:textSize="30sp" android:layout_weight="2"/>
|
---|
| 21 | + <TextView android:id="@+id/gpsTimer" android:visibility="visible"
|
---|
| 22 | + android:layout_width="0dip" android:layout_height="wrap_content"
|
---|
| 23 | + android:textSize="30sp" android:layout_weight="1"/>
|
---|
| 24 | +
|
---|
| 25 | + </LinearLayout>
|
---|
| 26 | +
|
---|
| 27 | + <TextView android:id="@+id/gpsSatellite" android:visibility="visible"
|
---|
| 28 | + android:layout_width="fill_parent" android:layout_height="fill_parent"
|
---|
| 29 | + android:textSize="20sp"/>
|
---|
| 30 | + </LinearLayout>
|
---|
| 31 | +
|
---|
| 32 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 3 | + android:layout_width="match_parent"
|
---|
| 4 | + android:layout_height="match_parent"
|
---|
| 5 | + android:orientation="vertical"
|
---|
| 6 | + android:background="@drawable/android_wallpaper">
|
---|
| 7 | +
|
---|
| 8 | + <RelativeLayout android:layout_height="wrap_content"
|
---|
| 9 | + android:layout_width="wrap_content" android:id="@+id/relativeLayout1"
|
---|
| 10 | + >
|
---|
| 11 | + <TextView android:text="@string/GsensorTest" android:id="@+id/txtTitle"
|
---|
| 12 | + android:textSize="30dip" android:gravity="center"
|
---|
| 13 | + android:layout_centerHorizontal="true" android:layout_width="fill_parent"
|
---|
| 14 | + android:layout_height="wrap_content" />
|
---|
| 15 | +
|
---|
| 16 | + <TextView android:id="@+id/Accelerometer"
|
---|
| 17 | + android:layout_below="@id/txtTitle" android:layout_width="fill_parent"
|
---|
| 18 | + android:layout_height="wrap_content" android:textSize="20dip"
|
---|
| 19 | + android:text="@string/Accelerometer" />
|
---|
| 20 | + <TextView android:id="@+id/prompt"
|
---|
| 21 | + android:layout_below="@id/Accelerometer" android:layout_width="fill_parent"
|
---|
| 22 | + android:layout_height="wrap_content" android:textSize="20dip"
|
---|
| 23 | + android:text="@string/prompt" />
|
---|
| 24 | +
|
---|
| 25 | + <Button android:id="@+id/save_calibration_button"
|
---|
| 26 | + android:layout_below="@id/prompt" android:layout_width="wrap_content"
|
---|
| 27 | + android:layout_height="wrap_content" android:textSize="20dip"
|
---|
| 28 | + android:text="@string/save_calibration" />
|
---|
| 29 | + <!-- for accelerator -->
|
---|
| 30 | + <ScrollView
|
---|
| 31 | + android:layout_below="@id/Accelerometer"
|
---|
| 32 | + android:layout_width="fill_parent"
|
---|
| 33 | + android:layout_height="wrap_content"
|
---|
| 34 | + android:visibility="gone">
|
---|
| 35 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 36 | + android:layout_height="wrap_content" android:orientation="vertical">
|
---|
| 37 | +
|
---|
| 38 | + <TextView android:id="@+id/gsensorTestX"
|
---|
| 39 | + android:layout_width="wrap_content" android:layout_height="wrap_content"
|
---|
| 40 | + android:textSize="40dip" android:text="@string/Gsensor_x"
|
---|
| 41 | + android:visibility="invisible" />
|
---|
| 42 | + <TextView android:id="@+id/gsensorTestY"
|
---|
| 43 | + android:layout_width="wrap_content" android:layout_height="wrap_content"
|
---|
| 44 | + android:textSize="40dip" android:text="@string/Gsensor_y"
|
---|
| 45 | + android:visibility="invisible" />
|
---|
| 46 | + <TextView android:id="@+id/gsensorTestZ"
|
---|
| 47 | + android:layout_width="wrap_content" android:layout_height="wrap_content"
|
---|
| 48 | + android:textSize="40dip" android:text="@string/Gsensor_z"
|
---|
| 49 | + android:visibility="invisible" />
|
---|
| 50 | + </LinearLayout>
|
---|
| 51 | + </ScrollView>
|
---|
| 52 | + </RelativeLayout>
|
---|
| 53 | +
|
---|
| 54 | + <!-- com.DeviceTest.view.GsensorBall
|
---|
| 55 | + android:id="@+id/gsensorball"
|
---|
| 56 | + android:layout_width="fill_parent"
|
---|
| 57 | + android:layout_height="0dip"
|
---|
| 58 | + android:layout_weight="1"/>-->
|
---|
| 59 | +
|
---|
| 60 | +<RelativeLayout
|
---|
| 61 | + android:layout_width="fill_parent"
|
---|
| 62 | + android:layout_height="wrap_content"
|
---|
| 63 | + android:layout_gravity="bottom">
|
---|
| 64 | + <include layout="@xml/control_buttons" android:id="@+id/acc_buttons"/>
|
---|
| 65 | +</RelativeLayout>
|
---|
| 66 | +
|
---|
| 67 | +</FrameLayout>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 3 | + android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">
|
---|
| 4 | +
|
---|
| 5 | + <RelativeLayout android:layout_height="wrap_content"
|
---|
| 6 | + android:layout_width="wrap_content" android:id="@+id/relativeLayout1">
|
---|
| 7 | + <TextView android:text="@string/GyroscopeTest" android:id="@+id/txtTitle"
|
---|
| 8 | + android:textSize="30dip" android:gravity="center"
|
---|
| 9 | + android:layout_centerHorizontal="true" android:layout_width="fill_parent"
|
---|
| 10 | + android:layout_height="wrap_content" />
|
---|
| 11 | +
|
---|
| 12 | + <!-- for Magnetic -->
|
---|
| 13 | + <TextView android:id="@+id/Gyroscope" android:layout_below="@id/txtTitle"
|
---|
| 14 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 15 | + android:textSize="20dip" android:text="@string/Gyroscope" />
|
---|
| 16 | +
|
---|
| 17 | +
|
---|
| 18 | + <!-- <RelativeLayout android:layout_height="wrap_content"
|
---|
| 19 | + android:layout_width="wrap_content" android:id="@+id/gy_buttons">
|
---|
| 20 | + <include layout="@xml/control_buttons" />
|
---|
| 21 | + </RelativeLayout> -->
|
---|
| 22 | +
|
---|
| 23 | + <!-- for accelerator -->
|
---|
| 24 | + <ScrollView android:layout_below="@+id/Gyroscope" android:id="@+id/gy_xyz"
|
---|
| 25 | + android:layout_width="fill_parent"
|
---|
| 26 | + android:layout_height="wrap_content">
|
---|
| 27 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 28 | + android:layout_height="wrap_content" android:orientation="vertical">
|
---|
| 29 | + <TextView android:id="@+id/magnetic_info"
|
---|
| 30 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 31 | + android:textSize="20dip" />
|
---|
| 32 | + <TextView android:id="@+id/magnetic_x"
|
---|
| 33 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 34 | + android:textSize="20dip" android:text="@string/sensor_x" />
|
---|
| 35 | +
|
---|
| 36 | + <TextView android:id="@+id/magnetic_y"
|
---|
| 37 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 38 | + android:textSize="20dip" android:text="@string/sensor_y" />
|
---|
| 39 | + <TextView android:id="@+id/magnetic_z"
|
---|
| 40 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 41 | + android:textSize="20dip" android:text="@string/sensor_z" />
|
---|
| 42 | + </LinearLayout>
|
---|
| 43 | + </ScrollView>
|
---|
| 44 | +
|
---|
| 45 | + <TextView android:id="@+id/prompt_Gyroscope"
|
---|
| 46 | + android:layout_below="@id/gy_xyz" android:layout_width="fill_parent"
|
---|
| 47 | + android:layout_height="wrap_content" android:textSize="20dip"
|
---|
| 48 | + android:text="@string/prompt_Gyroscope" />
|
---|
| 49 | +
|
---|
| 50 | + <Button android:id="@+id/save_calibration_button"
|
---|
| 51 | + android:layout_below="@id/prompt_Gyroscope" android:layout_width="wrap_content"
|
---|
| 52 | + android:layout_height="wrap_content" android:textSize="20dip"
|
---|
| 53 | + android:text="@string/save_calibration" />
|
---|
| 54 | +
|
---|
| 55 | +<LinearLayout android:id="@+id/gy_buttons" android:layout_below="@+id/save_calibration_button"
|
---|
| 56 | + android:layout_width="fill_parent"
|
---|
| 57 | + android:layout_height="wrap_content"
|
---|
| 58 | + android:orientation="horizontal" >
|
---|
| 59 | +<Button
|
---|
| 60 | + android:id="@+id/btn_return"
|
---|
| 61 | + android:layout_width="0dip"
|
---|
| 62 | + android:layout_height="wrap_content"
|
---|
| 63 | + android:layout_weight="1"
|
---|
| 64 | + android:text="@string/btnreturnText" />
|
---|
| 65 | + <Button
|
---|
| 66 | + android:id="@+id/btn_Pass"
|
---|
| 67 | + android:layout_width="0dip"
|
---|
| 68 | + android:layout_height="wrap_content"
|
---|
| 69 | + android:layout_weight="1"
|
---|
| 70 | + android:text="@string/btnPassText" />
|
---|
| 71 | +
|
---|
| 72 | + <Button
|
---|
| 73 | + android:id="@+id/btn_Fail"
|
---|
| 74 | + android:layout_width="0dip"
|
---|
| 75 | + android:layout_height="wrap_content"
|
---|
| 76 | + android:layout_weight="1"
|
---|
| 77 | + android:text="@string/btnFailText" />
|
---|
| 78 | +
|
---|
| 79 | + <Button
|
---|
| 80 | + android:id="@+id/btn_Skip"
|
---|
| 81 | + android:layout_width="0dip"
|
---|
| 82 | + android:layout_height="wrap_content"
|
---|
| 83 | + android:layout_weight="1"
|
---|
| 84 | + android:text="@string/btnSkipText" />
|
---|
| 85 | +
|
---|
| 86 | +</LinearLayout>
|
---|
| 87 | + </RelativeLayout>
|
---|
| 88 | +<RelativeLayout android:layout_height="wrap_content"
|
---|
| 89 | + android:layout_width="wrap_content" android:id="@+id/relativeLayout2"/>
|
---|
| 90 | +
|
---|
| 91 | +
|
---|
| 92 | +</LinearLayout>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 3 | + android:layout_width="match_parent" android:layout_height="match_parent">
|
---|
| 4 | +
|
---|
| 5 | + <RelativeLayout android:layout_height="match_parent"
|
---|
| 6 | + android:layout_width="wrap_content" android:id="@+id/relativeLayout1">
|
---|
| 7 | +
|
---|
| 8 | + <include layout="@xml/control_buttons" android:id="@+id/hd_buttons"/>
|
---|
| 9 | +
|
---|
| 10 | + <LinearLayout android:id="@+id/switch_btns"
|
---|
| 11 | + android:layout_above="@id/hd_buttons" android:layout_width="fill_parent"
|
---|
| 12 | + android:layout_height="wrap_content" android:orientation="horizontal">
|
---|
| 13 | + <Button android:id="@+id/btn_cpu" android:layout_width="0dip"
|
---|
| 14 | + android:layout_height="wrap_content" android:layout_weight="1"
|
---|
| 15 | + android:text="@string/CpuInfo" />
|
---|
| 16 | + <Button android:id="@+id/btn_mem" android:layout_width="0dip"
|
---|
| 17 | + android:layout_height="wrap_content" android:layout_weight="1"
|
---|
| 18 | + android:text="@string/MemInfo" />
|
---|
| 19 | + <Button android:id="@+id/btn_dmi" android:layout_width="0dip"
|
---|
| 20 | + android:layout_height="wrap_content" android:layout_weight="1"
|
---|
| 21 | + android:text="@string/DmiInfo" />
|
---|
| 22 | + </LinearLayout>
|
---|
| 23 | +
|
---|
| 24 | + <TextView android:id="@+id/hwinfoText" android:layout_width="fill_parent"
|
---|
| 25 | + android:layout_height="wrap_content" android:textSize="20dip" />
|
---|
| 26 | +
|
---|
| 27 | + <ScrollView android:layout_above="@id/switch_btns"
|
---|
| 28 | + android:layout_below="@id/hwinfoText"
|
---|
| 29 | + android:layout_width="fill_parent" android:layout_height="wrap_content">
|
---|
| 30 | + <FrameLayout android:layout_width="fill_parent"
|
---|
| 31 | + android:layout_height="wrap_content">
|
---|
| 32 | + <TextView android:id="@+id/cpu_info" android:layout_width="fill_parent"
|
---|
| 33 | + android:layout_height="wrap_content" android:textSize="20dip"
|
---|
| 34 | + android:visibility="gone" />
|
---|
| 35 | +
|
---|
| 36 | + <TextView android:id="@+id/mem_info" android:layout_width="fill_parent"
|
---|
| 37 | + android:layout_height="wrap_content" android:textSize="20dip"
|
---|
| 38 | + android:visibility="gone" />
|
---|
| 39 | +
|
---|
| 40 | + <TextView android:id="@+id/dmi_info" android:layout_width="fill_parent"
|
---|
| 41 | + android:layout_height="wrap_content" android:textSize="20dip"
|
---|
| 42 | + android:visibility="gone" />
|
---|
| 43 | + </FrameLayout>
|
---|
| 44 | + </ScrollView>
|
---|
| 45 | +
|
---|
| 46 | + </RelativeLayout>
|
---|
| 47 | +
|
---|
| 48 | +
|
---|
| 49 | +
|
---|
| 50 | +</LinearLayout>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 3 | + android:id="@+id/layout1"
|
---|
| 4 | + android:layout_width="fill_parent"
|
---|
| 5 | + android:layout_height="fill_parent" >
|
---|
| 6 | +
|
---|
| 7 | + <com.DeviceTest.view.LcdTestView
|
---|
| 8 | + android:id="@+id/lcdtestview"
|
---|
| 9 | + android:layout_width="match_parent"
|
---|
| 10 | + android:layout_height="match_parent" />
|
---|
| 11 | +
|
---|
| 12 | + <TextView
|
---|
| 13 | + android:id="@+id/hdmitestTitle"
|
---|
| 14 | + android:layout_width="fill_parent"
|
---|
| 15 | + android:layout_height="wrap_content"
|
---|
| 16 | + android:gravity="center_horizontal"
|
---|
| 17 | + android:paddingTop="20dp"
|
---|
| 18 | + android:text="@string/HdmiTestTitle"
|
---|
| 19 | + android:textSize="24sp"
|
---|
| 20 | + android:visibility="visible" />
|
---|
| 21 | +
|
---|
| 22 | + <LinearLayout
|
---|
| 23 | + android:layout_width="fill_parent"
|
---|
| 24 | + android:layout_height="wrap_content"
|
---|
| 25 | + android:layout_below="@id/hdmitestTitle"
|
---|
| 26 | + android:orientation="vertical"
|
---|
| 27 | + android:paddingBottom="60dip" >
|
---|
| 28 | +
|
---|
| 29 | + <TextView
|
---|
| 30 | + android:id="@+id/result"
|
---|
| 31 | + android:layout_width="fill_parent"
|
---|
| 32 | + android:layout_height="wrap_content"
|
---|
| 33 | + android:gravity="center_horizontal"
|
---|
| 34 | + android:paddingTop="40dp"
|
---|
| 35 | + android:visibility="visible" />
|
---|
| 36 | + </LinearLayout>
|
---|
| 37 | +
|
---|
| 38 | + <TextView
|
---|
| 39 | + android:id="@+id/TimeShow"
|
---|
| 40 | + android:layout_width="wrap_content"
|
---|
| 41 | + android:layout_height="wrap_content"
|
---|
| 42 | + android:gravity="center_horizontal"
|
---|
| 43 | + android:layout_centerInParent="true"
|
---|
| 44 | + android:textSize="30sp"
|
---|
| 45 | + android:visibility="visible" />
|
---|
| 46 | +
|
---|
| 47 | + <include layout="@xml/control_buttons" android:id="@+id/acc_buttons"/>
|
---|
| 48 | +
|
---|
| 49 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout
|
---|
| 3 | + android:id="@+id/layout1"
|
---|
| 4 | + android:layout_width="fill_parent"
|
---|
| 5 | + android:layout_height="fill_parent"
|
---|
| 6 | + xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 7 | +>
|
---|
| 8 | + <LinearLayout
|
---|
| 9 | + android:layout_width="fill_parent"
|
---|
| 10 | + android:layout_height="wrap_content"
|
---|
| 11 | + android:orientation="vertical"
|
---|
| 12 | + android:paddingBottom= "60dip"
|
---|
| 13 | + >
|
---|
| 14 | +
|
---|
| 15 | + <TextView
|
---|
| 16 | + android:id="@+id/textTitle"
|
---|
| 17 | + android:visibility="visible"
|
---|
| 18 | + android:layout_width="fill_parent"
|
---|
| 19 | + android:layout_height="wrap_content"
|
---|
| 20 | + android:layout_centerInParent="true"
|
---|
| 21 | + android:gravity="center_horizontal"
|
---|
| 22 | + android:textSize="24sp"
|
---|
| 23 | + android:paddingTop="20px"
|
---|
| 24 | + android:text="@string/HeadsetMicTitle"
|
---|
| 25 | +/>
|
---|
| 26 | +
|
---|
| 27 | +
|
---|
| 28 | + <TextView
|
---|
| 29 | + android:id="@+id/textSubTitle"
|
---|
| 30 | + android:visibility="visible"
|
---|
| 31 | + android:layout_width="fill_parent"
|
---|
| 32 | + android:layout_height="wrap_content"
|
---|
| 33 | + android:layout_centerInParent="true"
|
---|
| 34 | + android:gravity="center_horizontal"
|
---|
| 35 | + android:paddingTop="20px"
|
---|
| 36 | + android:textSize="20sp"
|
---|
| 37 | + android:text="@string/HeadsetMicSubTitle"
|
---|
| 38 | + />
|
---|
| 39 | + <TextView
|
---|
| 40 | + android:layout_width="fill_parent"
|
---|
| 41 | + android:layout_height="wrap_content"
|
---|
| 42 | + android:layout_centerInParent="true"
|
---|
| 43 | + android:gravity="center_horizontal"
|
---|
| 44 | + android:paddingTop="20px"
|
---|
| 45 | + android:textSize="18sp"
|
---|
| 46 | + android:visibility="visible" android:id="@+id/headsetresultText"/>
|
---|
| 47 | +
|
---|
| 48 | +
|
---|
| 49 | +
|
---|
| 50 | +
|
---|
| 51 | +
|
---|
| 52 | + </LinearLayout>
|
---|
| 53 | +
|
---|
| 54 | + <include layout="@xml/control_buttons" android:id="@+id/acc_buttons"/>
|
---|
| 55 | +
|
---|
| 56 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
---|
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
---|
| 3 | + android:layout_width="fill_parent" |
---|
| 4 | + android:layout_height="fill_parent" > |
---|
| 5 | + |
---|
| 6 | + <LinearLayout |
---|
| 7 | + android:layout_width="match_parent" |
---|
| 8 | + android:layout_height="match_parent" |
---|
| 9 | + android:orientation="vertical" > |
---|
| 10 | + |
---|
| 11 | + <TextView |
---|
| 12 | + android:layout_width="fill_parent" |
---|
| 13 | + android:layout_height="wrap_content" |
---|
| 14 | + android:layout_marginLeft="20dip" |
---|
| 15 | + android:layout_marginTop="20dip" |
---|
| 16 | + android:text="@string/cpu_title" |
---|
| 17 | + android:textSize="20sp" |
---|
| 18 | + android:textStyle="bold" /> |
---|
| 19 | + |
---|
| 20 | + <TextView |
---|
| 21 | + android:id="@+id/cpuinfo_tv" |
---|
| 22 | + android:layout_width="fill_parent" |
---|
| 23 | + android:layout_height="wrap_content" |
---|
| 24 | + android:layout_marginLeft="40dip" |
---|
| 25 | + android:layout_marginTop="10dip" |
---|
| 26 | + android:textSize="22sp" /> |
---|
| 27 | + |
---|
| 28 | + <TextView |
---|
| 29 | + android:layout_width="fill_parent" |
---|
| 30 | + android:layout_height="wrap_content" |
---|
| 31 | + android:layout_marginLeft="20dip" |
---|
| 32 | + android:layout_marginTop="20dip" |
---|
| 33 | + android:text="@string/memory_title" |
---|
| 34 | + android:textSize="20sp" |
---|
| 35 | + android:textStyle="bold" /> |
---|
| 36 | + |
---|
| 37 | + <TextView |
---|
| 38 | + android:id="@+id/meminfo_tv" |
---|
| 39 | + android:layout_width="fill_parent" |
---|
| 40 | + android:layout_height="wrap_content" |
---|
| 41 | + android:layout_marginLeft="40dip" |
---|
| 42 | + android:layout_marginTop="10dip" |
---|
| 43 | + android:textSize="22sp" /> |
---|
| 44 | + |
---|
| 45 | + <!--TextView |
---|
| 46 | + android:layout_width="fill_parent" |
---|
| 47 | + android:layout_height="wrap_content" |
---|
| 48 | + android:layout_marginLeft="20dip" |
---|
| 49 | + android:layout_marginTop="20dip" |
---|
| 50 | + android:text="@string/storage_title" |
---|
| 51 | + android:textSize="20sp" |
---|
| 52 | + android:textStyle="bold" /> |
---|
| 53 | + |
---|
| 54 | + <TextView |
---|
| 55 | + android:layout_width="fill_parent" |
---|
| 56 | + android:layout_height="wrap_content" |
---|
| 57 | + android:layout_marginLeft="40dip" |
---|
| 58 | + android:layout_marginTop="20dip" |
---|
| 59 | + android:text="@string/nand_flash" |
---|
| 60 | + android:textSize="20sp" /> |
---|
| 61 | + |
---|
| 62 | + <TextView |
---|
| 63 | + android:id="@+id/nand_total_tv" |
---|
| 64 | + android:layout_width="fill_parent" |
---|
| 65 | + android:layout_height="wrap_content" |
---|
| 66 | + android:layout_marginLeft="60dip" |
---|
| 67 | + android:layout_marginTop="10dip" |
---|
| 68 | + android:text="@string/total_space" |
---|
| 69 | + android:textSize="22sp" /> |
---|
| 70 | + |
---|
| 71 | + <TextView |
---|
| 72 | + android:id="@+id/nand_avail_tv" |
---|
| 73 | + android:layout_width="fill_parent" |
---|
| 74 | + android:layout_height="wrap_content" |
---|
| 75 | + android:layout_marginLeft="60dip" |
---|
| 76 | + android:layout_marginTop="10dip" |
---|
| 77 | + android:text="@string/available_space" |
---|
| 78 | + android:textSize="22sp" /> |
---|
| 79 | + |
---|
| 80 | + <TextView |
---|
| 81 | + android:layout_width="fill_parent" |
---|
| 82 | + android:layout_height="wrap_content" |
---|
| 83 | + android:layout_marginLeft="40dip" |
---|
| 84 | + android:layout_marginTop="20dip" |
---|
| 85 | + android:text="@string/internal_storage" |
---|
| 86 | + android:textSize="20sp" |
---|
| 87 | + android:textStyle="bold" /--> |
---|
| 88 | + |
---|
| 89 | + <TextView |
---|
| 90 | + android:id="@+id/internal_avail_tv" |
---|
| 91 | + android:layout_width="fill_parent" |
---|
| 92 | + android:layout_height="wrap_content" |
---|
| 93 | + android:layout_marginLeft="20dip" |
---|
| 94 | + android:layout_marginTop="20dip" |
---|
| 95 | + android:text="@string/total_space" |
---|
| 96 | + android:textSize="22sp" |
---|
| 97 | + android:textStyle="bold"/> |
---|
| 98 | + |
---|
| 99 | + <TextView |
---|
| 100 | + android:id="@+id/internal_avail_size_tv" |
---|
| 101 | + android:layout_width="fill_parent" |
---|
| 102 | + android:layout_height="wrap_content" |
---|
| 103 | + android:layout_marginLeft="40dip" |
---|
| 104 | + android:layout_marginTop="20dip" |
---|
| 105 | + android:textSize="20sp" /> |
---|
| 106 | + |
---|
| 107 | + </LinearLayout> |
---|
| 108 | + |
---|
| 109 | + <RelativeLayout |
---|
| 110 | + android:layout_width="fill_parent" |
---|
| 111 | + android:layout_height="wrap_content" |
---|
| 112 | + android:layout_gravity="bottom"> |
---|
| 113 | + <include layout="@xml/control_buttons" android:id="@+id/acc_buttons"/> |
---|
| 114 | +</RelativeLayout> |
---|
| 115 | + |
---|
| 116 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:id="@+id/layout1"
|
---|
| 3 | + android:layout_width="fill_parent" android:layout_height="fill_parent"
|
---|
| 4 | + xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 5 | + <TextView android:id="@+id/IrdaTest" android:layout_width="fill_parent"
|
---|
| 6 | + android:layout_height="wrap_content" android:layout_alignParentTop="true"
|
---|
| 7 | + android:gravity="center_horizontal" android:paddingBottom="20px"
|
---|
| 8 | + android:textSize="24sp" android:visibility="visible" android:text="@string/IrdaTestTitle" />
|
---|
| 9 | +
|
---|
| 10 | +<include layout="@xml/control_buttons" android:id="@+id/irda_btns"/>
|
---|
| 11 | +
|
---|
| 12 | + <LinearLayout android:layout_above="@id/irda_btns"
|
---|
| 13 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 14 | + android:orientation="vertical">
|
---|
| 15 | +
|
---|
| 16 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 17 | + android:layout_height="wrap_content" android:orientation="horizontal">
|
---|
| 18 | + <Button android:id="@+id/sir_send" android:layout_width="0dip"
|
---|
| 19 | + android:layout_weight="1" android:layout_height="wrap_content"
|
---|
| 20 | + android:text="@string/SirSend" android:textSize="30sp"/>
|
---|
| 21 | + <Button android:id="@+id/sir_receive" android:layout_width="0dip"
|
---|
| 22 | + android:layout_weight="1" android:layout_height="wrap_content"
|
---|
| 23 | + android:text="@string/SirReceive" android:textSize="30sp"/>
|
---|
| 24 | +
|
---|
| 25 | + </LinearLayout>
|
---|
| 26 | +
|
---|
| 27 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 28 | + android:layout_height="wrap_content" android:orientation="horizontal">
|
---|
| 29 | + <Button android:id="@+id/fir_send" android:layout_width="0dip"
|
---|
| 30 | + android:layout_weight="1" android:layout_height="wrap_content"
|
---|
| 31 | + android:text="@string/FirSend" android:textSize="30sp"/>
|
---|
| 32 | + <Button android:id="@+id/fir_receive" android:layout_width="0dip"
|
---|
| 33 | + android:layout_weight="1" android:layout_height="wrap_content"
|
---|
| 34 | + android:text="@string/FirReceive" android:textSize="30sp"/>
|
---|
| 35 | +
|
---|
| 36 | + </LinearLayout>
|
---|
| 37 | + <ProgressBar android:id="@+id/irda_progress"
|
---|
| 38 | + android:visibility="invisible" android:layout_width="wrap_content"
|
---|
| 39 | + android:paddingTop="20px" android:layout_height="wrap_content"
|
---|
| 40 | + android:layout_gravity="center"></ProgressBar>
|
---|
| 41 | +
|
---|
| 42 | + </LinearLayout>
|
---|
| 43 | +
|
---|
| 44 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:layout_width="fill_parent"
|
---|
| 3 | + android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 4 | + <TextView android:textSize="24.0sp" android:gravity="center"
|
---|
| 5 | + android:id="@+id/keyboardtest_title" android:text="@string/KeyboardTestTitle"
|
---|
| 6 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 7 | + android:layout_marginTop="50.0dip" android:layout_alignParentTop="true" />
|
---|
| 8 | +
|
---|
| 9 | + <LinearLayout android:layout_below="@id/keyboardtest_title"
|
---|
| 10 | + android:orientation="horizontal" android:layout_width="fill_parent"
|
---|
| 11 | + android:layout_height="fill_parent" android:gravity="center">
|
---|
| 12 | + <Button android:id="@+id/bt_sounddown" android:layout_width="wrap_content"
|
---|
| 13 | + android:layout_height="50.0dip" style="@+style/Keyboard"
|
---|
| 14 | + android:text="@string/VolDown" android:layout_marginLeft="5dip"/>
|
---|
| 15 | + <Button android:id="@+id/bt_soundup" android:layout_width="wrap_content"
|
---|
| 16 | + android:layout_height="50.0dip" style="@+style/Keyboard"
|
---|
| 17 | + android:text="@string/VolUp" android:layout_marginLeft="5dip"/>
|
---|
| 18 | + <Button android:id="@+id/bt_back" android:layout_width="wrap_content"
|
---|
| 19 | + android:layout_height="50.0dip" style="@+style/Keyboard"
|
---|
| 20 | + android:text="@string/Back" android:layout_marginLeft="5dip"/>
|
---|
| 21 | +
|
---|
| 22 | + <Button android:id="@+id/bt_menu" android:layout_width="wrap_content"
|
---|
| 23 | + android:layout_height="50.0dip" style="@+style/Keyboard"
|
---|
| 24 | + android:text="@string/Menu" android:layout_marginLeft="5dip"/>
|
---|
| 25 | +
|
---|
| 26 | + <Button android:id="@+id/bt_home" android:layout_width="wrap_content"
|
---|
| 27 | + android:layout_height="50.0dip" style="@+style/Keyboard"
|
---|
| 28 | + android:text="@string/Home" android:layout_marginLeft="5dip"
|
---|
| 29 | + android:visibility="gone"/>
|
---|
| 30 | +
|
---|
| 31 | + </LinearLayout>
|
---|
| 32 | +
|
---|
| 33 | +
|
---|
| 34 | + <include layout="@xml/control_buttons" android:id="@+id/result_bt_layout"/>
|
---|
| 35 | +</RelativeLayout>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<!-- Copyright (C) 2009 The Rockchip Android MID 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 | +<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 18 | + <ImageView
|
---|
| 19 | + android:layout_width="fill_parent"
|
---|
| 20 | + android:layout_height="fill_parent"
|
---|
| 21 | + android:layout_gravity="center_horizontal"
|
---|
| 22 | + android:background="@drawable/novideofile"/>
|
---|
| 23 | +</merge>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:layout_width="fill_parent"
|
---|
| 3 | + android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 4 | + <com.DeviceTest.view.LcdTestView android:id="@+id/lcdtestview" android:layout_width="match_parent"
|
---|
| 5 | + android:layout_height="match_parent" />
|
---|
| 6 | +
|
---|
| 7 | + <TextView android:id="@+id/lcdtextTitle" android:visibility="visible"
|
---|
| 8 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 9 | + android:gravity="center_horizontal" android:textSize="24sp"
|
---|
| 10 | + android:text="@string/LcdTestTitle" android:paddingTop="20px" />
|
---|
| 11 | +
|
---|
| 12 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 13 | + android:layout_height="wrap_content" android:orientation="vertical"
|
---|
| 14 | + android:paddingBottom="60dip" android:layout_below="@id/lcdtextTitle">
|
---|
| 15 | +
|
---|
| 16 | +
|
---|
| 17 | + <TextView android:id="@+id/lcdtestresult" android:visibility="visible"
|
---|
| 18 | + android:layout_height="wrap_content" android:text="@string/LcdTestStart"
|
---|
| 19 | + android:layout_width="fill_parent" android:gravity="center_horizontal"
|
---|
| 20 | + android:paddingTop="40px"
|
---|
| 21 | + android:textSize="18sp" />
|
---|
| 22 | +
|
---|
| 23 | +
|
---|
| 24 | +
|
---|
| 25 | + </LinearLayout>
|
---|
| 26 | +
|
---|
| 27 | + <include layout="@xml/control_buttons" android:id="@+id/acc_buttons"/>
|
---|
| 28 | +
|
---|
| 29 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 3 | + android:layout_width="match_parent" android:layout_height="match_parent">
|
---|
| 4 | +
|
---|
| 5 | + <RelativeLayout android:layout_height="match_parent"
|
---|
| 6 | + android:layout_width="wrap_content" android:id="@+id/relativeLayout1">
|
---|
| 7 | + <TextView android:id="@+id/LedTest" android:layout_width="fill_parent"
|
---|
| 8 | + android:layout_height="wrap_content" android:layout_alignParentTop="true"
|
---|
| 9 | + android:gravity="center_horizontal" android:paddingBottom="20px"
|
---|
| 10 | + android:textSize="24sp" android:visibility="visible" android:text="@string/LedTestTitle" />
|
---|
| 11 | +
|
---|
| 12 | +
|
---|
| 13 | + <include layout="@xml/control_buttons" android:id="@+id/led_buttons"/>
|
---|
| 14 | +
|
---|
| 15 | + <LinearLayout android:layout_above="@id/led_buttons"
|
---|
| 16 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 17 | + android:orientation="horizontal">
|
---|
| 18 | + <Button android:id="@+id/red_btn" android:layout_width="0dip"
|
---|
| 19 | + android:layout_height="wrap_content" android:layout_weight="1"
|
---|
| 20 | + android:text="@string/Red" />
|
---|
| 21 | + <Button android:id="@+id/green_btn" android:layout_width="0dip"
|
---|
| 22 | + android:layout_height="wrap_content" android:layout_weight="1"
|
---|
| 23 | + android:text="@string/Green" />
|
---|
| 24 | + <Button android:id="@+id/blue_btn" android:layout_width="0dip"
|
---|
| 25 | + android:layout_height="wrap_content" android:layout_weight="1"
|
---|
| 26 | + android:text="@string/Blue" />
|
---|
| 27 | + <!-- Button android:id="@+id/power_btn" android:layout_width="0dip"
|
---|
| 28 | + android:layout_height="wrap_content" android:layout_weight="1" /-->
|
---|
| 29 | + </LinearLayout>
|
---|
| 30 | + </RelativeLayout>
|
---|
| 31 | +
|
---|
| 32 | +
|
---|
| 33 | +
|
---|
| 34 | +</LinearLayout>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:layout_width="fill_parent"
|
---|
| 3 | + android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 4 | +
|
---|
| 5 | +
|
---|
| 6 | + <include layout="@xml/control_buttons" android:id="@+id/level_buttons"/>
|
---|
| 7 | +
|
---|
| 8 | + <com.DeviceTest.view.LevelView android:id="@+id/leveltestview"
|
---|
| 9 | + android:layout_above="@id/level_buttons" android:layout_width="match_parent"
|
---|
| 10 | + android:layout_height="match_parent" />
|
---|
| 11 | +
|
---|
| 12 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<LinearLayout
|
---|
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 4 | + android:layout_width="match_parent"
|
---|
| 5 | + android:layout_height="match_parent">
|
---|
| 6 | +
|
---|
| 7 | + <RelativeLayout android:layout_height="match_parent" android:layout_width="wrap_content" android:id="@+id/relativeLayout1">
|
---|
| 8 | + <TextView
|
---|
| 9 | + android:text="@string/LightsensorTest"
|
---|
| 10 | + android:id="@+id/txtTitle"
|
---|
| 11 | + android:textSize= "30dip"
|
---|
| 12 | + android:gravity="center"
|
---|
| 13 | + android:layout_centerHorizontal="true"
|
---|
| 14 | + android:layout_width="fill_parent"
|
---|
| 15 | + android:layout_height="wrap_content"/>
|
---|
| 16 | +
|
---|
| 17 | +
|
---|
| 18 | +
|
---|
| 19 | +<!-- for Light -->
|
---|
| 20 | +<TextView
|
---|
| 21 | + android:id="@+id/Light"
|
---|
| 22 | + android:layout_below="@id/txtTitle"
|
---|
| 23 | + android:textSize= "25dip"
|
---|
| 24 | + android:layout_width="fill_parent"
|
---|
| 25 | + android:layout_height="wrap_content"
|
---|
| 26 | + android:text="@string/Light"
|
---|
| 27 | + />
|
---|
| 28 | +
|
---|
| 29 | + <TextView
|
---|
| 30 | + android:id="@+id/txt_sensor_info"
|
---|
| 31 | + android:textSize= "20dip"
|
---|
| 32 | + android:layout_below="@+id/Light"
|
---|
| 33 | + android:layout_width="fill_parent"
|
---|
| 34 | + android:layout_height="wrap_content"/>
|
---|
| 35 | +
|
---|
| 36 | + <TextView
|
---|
| 37 | + android:id="@+id/txt_sensor_event"
|
---|
| 38 | + android:textSize="20dip"
|
---|
| 39 | + android:layout_marginTop="30dp"
|
---|
| 40 | + android:layout_below="@id/txt_sensor_info"
|
---|
| 41 | + android:layout_width="fill_parent"
|
---|
| 42 | + android:layout_height="wrap_content"/>
|
---|
| 43 | +
|
---|
| 44 | + <include layout="@xml/control_buttons" android:id="@+id/level_buttons"/>
|
---|
| 45 | +
|
---|
| 46 | + </RelativeLayout>
|
---|
| 47 | +
|
---|
| 48 | +
|
---|
| 49 | +
|
---|
| 50 | +</LinearLayout>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:id="@+id/layout1"
|
---|
| 3 | + android:background="@android:color/black"
|
---|
| 4 | + android:layout_width="fill_parent" android:layout_height="fill_parent"
|
---|
| 5 | + xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 6 | +
|
---|
| 7 | +
|
---|
| 8 | + <LinearLayout android:id="@+id/btnLayout"
|
---|
| 9 | + android:layout_margin="10dip"
|
---|
| 10 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 11 | + android:orientation="horizontal" android:layout_alignParentBottom="true">
|
---|
| 12 | + <Spinner android:id="@+id/GroupTestSpinner"
|
---|
| 13 | + android:visibility="gone"
|
---|
| 14 | + android:layout_width="0dip" android:layout_height="wrap_content"
|
---|
| 15 | + android:layout_weight="2" />
|
---|
| 16 | +
|
---|
| 17 | + <Button android:id="@+id/btn_testall" android:layout_width="0dip"
|
---|
| 18 | + android:layout_height="wrap_content" android:layout_weight="1"
|
---|
| 19 | + android:text="@string/testall" />
|
---|
| 20 | + <Button android:id="@+id/btn_cancel" android:layout_width="0dip"
|
---|
| 21 | + android:layout_height="wrap_content" android:layout_weight="1"
|
---|
| 22 | + android:text="@string/Cancel" />
|
---|
| 23 | + <Button android:id="@+id/btn_save" android:layout_width="0dip"
|
---|
| 24 | + android:layout_height="wrap_content" android:layout_weight="1"
|
---|
| 25 | + android:text="@string/Save" />
|
---|
| 26 | + <Button android:id="@+id/btn_clear" android:layout_width="0dip"
|
---|
| 27 | + android:layout_height="wrap_content" android:layout_weight="1"
|
---|
| 28 | + android:text="@string/Clear" />
|
---|
| 29 | +
|
---|
| 30 | + <Button android:id="@+id/btn_uninstall" android:layout_width="0dip"
|
---|
| 31 | + android:layout_height="wrap_content" android:layout_weight="1"
|
---|
| 32 | + android:text="@string/Uninstall" />
|
---|
| 33 | +
|
---|
| 34 | + </LinearLayout>
|
---|
| 35 | +
|
---|
| 36 | + <LinearLayout android:layout_alignParentTop="true"
|
---|
| 37 | + android:layout_above="@id/btnLayout" android:layout_width="fill_parent"
|
---|
| 38 | + android:layout_height="fill_parent">
|
---|
| 39 | + <com.DeviceTest.view.MyGridView
|
---|
| 40 | + android:id="@+id/myGridView" android:layout_width="fill_parent"
|
---|
| 41 | + android:layout_height="fill_parent" />
|
---|
| 42 | + </LinearLayout>
|
---|
| 43 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<!-- Copyright (C) 2009 The Rockchip Android MID 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 | +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 17 | + android:layout_height="fill_parent"
|
---|
| 18 | + android:layout_width="fill_parent"
|
---|
| 19 | + android:id="@+id/main_layout"
|
---|
| 20 | + android:orientation="vertical">
|
---|
| 21 | + <LinearLayout android:id="@+id/novideofile"
|
---|
| 22 | + android:layout_height="fill_parent"
|
---|
| 23 | + android:layout_width="fill_parent"
|
---|
| 24 | + android:visibility="gone">
|
---|
| 25 | + <ImageView android:id="@+id/novideofile_image"
|
---|
| 26 | + android:layout_width="fill_parent"
|
---|
| 27 | + android:layout_height="fill_parent"
|
---|
| 28 | + android:layout_gravity="center_horizontal"
|
---|
| 29 | + android:background="@drawable/novideofile"
|
---|
| 30 | + />
|
---|
| 31 | + </LinearLayout>
|
---|
| 32 | + <ListView android:id="@android:id/list"
|
---|
| 33 | + android:layout_width="wrap_content"
|
---|
| 34 | + android:layout_height="wrap_content"/>
|
---|
| 35 | + <RelativeLayout
|
---|
| 36 | + android:layout_width="fill_parent"
|
---|
| 37 | + android:layout_height="wrap_content"
|
---|
| 38 | + android:layout_gravity="bottom"
|
---|
| 39 | + >
|
---|
| 40 | + <include layout="@xml/control_buttons" android:id="@+id/btns" />
|
---|
| 41 | + </RelativeLayout>
|
---|
| 42 | +</FrameLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout
|
---|
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 4 | + android:layout_width="fill_parent"
|
---|
| 5 | + android:layout_height="fill_parent">
|
---|
| 6 | +
|
---|
| 7 | +
|
---|
| 8 | + <LinearLayout
|
---|
| 9 | + android:layout_width="fill_parent"
|
---|
| 10 | + android:layout_height="wrap_content"
|
---|
| 11 | + android:orientation="vertical"
|
---|
| 12 | + android:paddingBottom= "60dip">
|
---|
| 13 | +
|
---|
| 14 | + <TextView
|
---|
| 15 | + android:visibility="visible"
|
---|
| 16 | + android:layout_width="fill_parent"
|
---|
| 17 | + android:layout_height="wrap_content"
|
---|
| 18 | + android:layout_centerInParent="true"
|
---|
| 19 | + android:gravity="center_horizontal"
|
---|
| 20 | + android:paddingTop="20px"
|
---|
| 21 | + android:textSize="24sp"
|
---|
| 22 | + android:text="@string/MobileNetTitle"/>
|
---|
| 23 | +
|
---|
| 24 | +
|
---|
| 25 | + <TextView
|
---|
| 26 | + android:visibility="visible"
|
---|
| 27 | + android:layout_width="fill_parent"
|
---|
| 28 | + android:layout_height="wrap_content"
|
---|
| 29 | + android:layout_centerInParent="true"
|
---|
| 30 | + android:gravity="center_horizontal"
|
---|
| 31 | + android:paddingTop="20px"
|
---|
| 32 | + android:textSize="20sp"
|
---|
| 33 | + android:text="@string/MobileNetSubTitle"/>
|
---|
| 34 | +
|
---|
| 35 | + <TextView
|
---|
| 36 | + android:id="@+id/simView"
|
---|
| 37 | + android:visibility="visible"
|
---|
| 38 | + android:layout_width="wrap_content"
|
---|
| 39 | + android:layout_height="wrap_content"
|
---|
| 40 | + android:layout_centerInParent="true"
|
---|
| 41 | + android:gravity="center_horizontal"
|
---|
| 42 | + android:paddingTop="20px"
|
---|
| 43 | + android:layout_marginLeft="200dp"
|
---|
| 44 | + android:textSize="30sp"/>
|
---|
| 45 | +
|
---|
| 46 | + <TextView
|
---|
| 47 | + android:id="@+id/moduleView"
|
---|
| 48 | + android:visibility="visible"
|
---|
| 49 | + android:layout_width="wrap_content"
|
---|
| 50 | + android:layout_height="wrap_content"
|
---|
| 51 | + android:layout_centerInParent="true"
|
---|
| 52 | + android:gravity="center_horizontal"
|
---|
| 53 | + android:paddingTop="20px"
|
---|
| 54 | + android:layout_marginLeft="200dp"
|
---|
| 55 | + android:textSize="30sp"/>
|
---|
| 56 | +
|
---|
| 57 | + </LinearLayout>
|
---|
| 58 | +
|
---|
| 59 | + <include layout="@xml/control_buttons"/>
|
---|
| 60 | +</RelativeLayout>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout
|
---|
| 3 | + android:id="@+id/layout1"
|
---|
| 4 | + android:layout_width="fill_parent"
|
---|
| 5 | + android:layout_height="fill_parent"
|
---|
| 6 | + xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 7 | + <LinearLayout
|
---|
| 8 | + android:layout_width="fill_parent"
|
---|
| 9 | + android:layout_height="wrap_content"
|
---|
| 10 | + android:orientation="vertical"
|
---|
| 11 | + android:paddingBottom="60dip">
|
---|
| 12 | +
|
---|
| 13 | + <TextView
|
---|
| 14 | + android:id="@+id/textTitle"
|
---|
| 15 | + android:visibility="visible"
|
---|
| 16 | + android:layout_width="fill_parent"
|
---|
| 17 | + android:layout_height="wrap_content"
|
---|
| 18 | + android:layout_centerInParent="true"
|
---|
| 19 | + android:gravity="center_horizontal"
|
---|
| 20 | + android:textSize="24sp"
|
---|
| 21 | + android:paddingTop="20px"
|
---|
| 22 | + android:text="@string/MrioUSBTitle"
|
---|
| 23 | + />
|
---|
| 24 | +
|
---|
| 25 | +
|
---|
| 26 | + <TextView
|
---|
| 27 | + android:id="@+id/infoText"
|
---|
| 28 | + android:visibility="visible"
|
---|
| 29 | + android:layout_width="fill_parent"
|
---|
| 30 | + android:layout_height="wrap_content"
|
---|
| 31 | + android:layout_centerInParent="true"
|
---|
| 32 | + android:gravity="center_horizontal"
|
---|
| 33 | + android:paddingTop="20px"
|
---|
| 34 | + android:paddingBottom="20px"
|
---|
| 35 | + android:textSize="20sp"
|
---|
| 36 | + android:text="@string/MrioUSBsubTitle"/>
|
---|
| 37 | +
|
---|
| 38 | +
|
---|
| 39 | + <LinearLayout
|
---|
| 40 | + android:layout_width="fill_parent"
|
---|
| 41 | + android:layout_height="wrap_content"
|
---|
| 42 | + android:orientation="vertical"
|
---|
| 43 | + >
|
---|
| 44 | +
|
---|
| 45 | + <TextView
|
---|
| 46 | + android:layout_width="fill_parent"
|
---|
| 47 | + android:layout_height="wrap_content"
|
---|
| 48 | + android:gravity="left"
|
---|
| 49 | + android:paddingTop="10px"
|
---|
| 50 | + android:textSize="40sp"
|
---|
| 51 | + android:visibility="visible"
|
---|
| 52 | + android:id="@+id/unplugTest"
|
---|
| 53 | + android:text="@string/UsbUnplug"
|
---|
| 54 | + android:textColor="#ff0000"/>
|
---|
| 55 | +
|
---|
| 56 | + <TextView
|
---|
| 57 | + android:layout_width="fill_parent"
|
---|
| 58 | + android:layout_height="wrap_content"
|
---|
| 59 | + android:gravity="left"
|
---|
| 60 | + android:paddingTop="10px"
|
---|
| 61 | + android:textSize="40sp"
|
---|
| 62 | + android:visibility="visible"
|
---|
| 63 | + android:id="@+id/pluginTest"
|
---|
| 64 | + android:text="@string/UsbPlugin"
|
---|
| 65 | + android:textColor="#ff0000"/>
|
---|
| 66 | +
|
---|
| 67 | + </LinearLayout>
|
---|
| 68 | +
|
---|
| 69 | +
|
---|
| 70 | +
|
---|
| 71 | +
|
---|
| 72 | +
|
---|
| 73 | + </LinearLayout>
|
---|
| 74 | +
|
---|
| 75 | + <include layout="@xml/control_buttons" android:id="@+id/level_buttons"/>
|
---|
| 76 | +
|
---|
| 77 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 3 | + android:layout_width="match_parent" android:layout_height="match_parent">
|
---|
| 4 | +
|
---|
| 5 | + <RelativeLayout android:layout_height="match_parent"
|
---|
| 6 | + android:layout_width="wrap_content" android:id="@+id/relativeLayout1">
|
---|
| 7 | + <TextView android:text="@string/MsensorTest" android:id="@+id/txtTitle"
|
---|
| 8 | + android:textSize="30dip" android:gravity="center"
|
---|
| 9 | + android:layout_centerHorizontal="true" android:layout_width="fill_parent"
|
---|
| 10 | + android:layout_height="wrap_content" />
|
---|
| 11 | +
|
---|
| 12 | + <include layout="@xml/control_buttons" android:id="@+id/ms_buttons"/>
|
---|
| 13 | +
|
---|
| 14 | + <!-- for Magnetic -->
|
---|
| 15 | + <TextView android:id="@+id/Magnetic" android:layout_below="@id/txtTitle"
|
---|
| 16 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 17 | + android:textSize="20dip" android:text="@string/Magnetic_Field" />
|
---|
| 18 | +
|
---|
| 19 | +
|
---|
| 20 | + <!-- for accelerator -->
|
---|
| 21 | + <ScrollView android:layout_below="@id/Magnetic"
|
---|
| 22 | + android:layout_above="@id/ms_buttons" android:layout_width="fill_parent"
|
---|
| 23 | + android:layout_height="wrap_content">
|
---|
| 24 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 25 | + android:layout_height="wrap_content" android:orientation="vertical">
|
---|
| 26 | + <TextView android:id="@+id/magnetic_info"
|
---|
| 27 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 28 | + android:textSize="20dip" />
|
---|
| 29 | +
|
---|
| 30 | +
|
---|
| 31 | + <TextView android:id="@+id/magnetic_x"
|
---|
| 32 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 33 | + android:textSize="20dip" android:text="@string/sensor_x" />
|
---|
| 34 | +
|
---|
| 35 | + <TextView android:id="@+id/magnetic_y"
|
---|
| 36 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 37 | + android:textSize="20dip" android:text="@string/sensor_y" />
|
---|
| 38 | + <TextView android:id="@+id/magnetic_z"
|
---|
| 39 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 40 | + android:textSize="20dip" android:text="@string/sensor_z" />
|
---|
| 41 | + </LinearLayout>
|
---|
| 42 | + </ScrollView>
|
---|
| 43 | +
|
---|
| 44 | +
|
---|
| 45 | + </RelativeLayout>
|
---|
| 46 | +
|
---|
| 47 | +
|
---|
| 48 | +
|
---|
| 49 | +</LinearLayout>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 3 | + android:id="@+id/layout1"
|
---|
| 4 | + android:layout_width="fill_parent"
|
---|
| 5 | + android:layout_height="fill_parent" >
|
---|
| 6 | +
|
---|
| 7 | + <LinearLayout
|
---|
| 8 | + android:layout_width="fill_parent"
|
---|
| 9 | + android:layout_height="wrap_content"
|
---|
| 10 | + android:orientation="vertical"
|
---|
| 11 | + android:paddingBottom="60dip" >
|
---|
| 12 | +
|
---|
| 13 | + <TextView
|
---|
| 14 | + android:layout_width="fill_parent"
|
---|
| 15 | + android:layout_height="50dip"
|
---|
| 16 | + android:text="@string/clock_test" />
|
---|
| 17 | +
|
---|
| 18 | + <LinearLayout
|
---|
| 19 | + android:id="@+id/clock1"
|
---|
| 20 | + android:layout_width="300dip"
|
---|
| 21 | + android:layout_height="300dip"
|
---|
| 22 | + android:layout_gravity="center" />
|
---|
| 23 | + </LinearLayout>
|
---|
| 24 | +
|
---|
| 25 | + <include layout="@xml/control_buttons" />
|
---|
| 26 | +
|
---|
| 27 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout
|
---|
| 3 | + android:id="@+id/layout1"
|
---|
| 4 | + android:layout_width="fill_parent"
|
---|
| 5 | + android:layout_height="fill_parent"
|
---|
| 6 | + xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 7 | +>
|
---|
| 8 | + <LinearLayout
|
---|
| 9 | + android:layout_width="fill_parent"
|
---|
| 10 | + android:layout_height="wrap_content"
|
---|
| 11 | + android:orientation="vertical"
|
---|
| 12 | + android:paddingBottom= "60dip"
|
---|
| 13 | + >
|
---|
| 14 | +
|
---|
| 15 | + <TextView
|
---|
| 16 | + android:id="@+id/textTitle"
|
---|
| 17 | + android:visibility="visible"
|
---|
| 18 | + android:layout_width="fill_parent"
|
---|
| 19 | + android:layout_height="wrap_content"
|
---|
| 20 | + android:layout_centerInParent="true"
|
---|
| 21 | + android:gravity="center_horizontal"
|
---|
| 22 | + android:textSize="24sp"
|
---|
| 23 | + android:paddingTop="20px"
|
---|
| 24 | + android:text="@string/PhoneMictTitle"
|
---|
| 25 | + />
|
---|
| 26 | + <TextView
|
---|
| 27 | + android:id="@+id/textSubTitle"
|
---|
| 28 | + android:visibility="visible"
|
---|
| 29 | + android:layout_width="fill_parent"
|
---|
| 30 | + android:layout_height="wrap_content"
|
---|
| 31 | + android:layout_centerInParent="true"
|
---|
| 32 | + android:gravity="center_horizontal"
|
---|
| 33 | + android:paddingTop="20px"
|
---|
| 34 | + android:textSize="20sp"
|
---|
| 35 | + android:text="@string/PhoneMicSubTitle"
|
---|
| 36 | + />
|
---|
| 37 | + <TextView
|
---|
| 38 | + android:layout_width="fill_parent"
|
---|
| 39 | + android:layout_height="wrap_content"
|
---|
| 40 | + android:layout_centerInParent="true"
|
---|
| 41 | + android:gravity="center_horizontal"
|
---|
| 42 | + android:paddingTop="20px"
|
---|
| 43 | + android:textSize="18sp"
|
---|
| 44 | + android:visibility="visible" android:id="@+id/phoneresultText"/>
|
---|
| 45 | +
|
---|
| 46 | + <RelativeLayout
|
---|
| 47 | + android:layout_width="match_parent"
|
---|
| 48 | + android:layout_height="match_parent">
|
---|
| 49 | +
|
---|
| 50 | + <com.DeviceTest.helper.VUMeter android:id="@+id/uvMeter"
|
---|
| 51 | + android:background="@drawable/vumeter"
|
---|
| 52 | + android:layout_width="150px"
|
---|
| 53 | + android:layout_height="60px"
|
---|
| 54 | + android:layout_centerInParent="true" />
|
---|
| 55 | + </RelativeLayout>
|
---|
| 56 | +
|
---|
| 57 | + <Button android:id="@+id/btn_retest"
|
---|
| 58 | + android:layout_width="wrap_content"
|
---|
| 59 | + android:layout_height="wrap_content"
|
---|
| 60 | + android:text="@string/btnRetest"
|
---|
| 61 | + android:layout_gravity="center_horizontal"
|
---|
| 62 | + android:gravity="center_horizontal"
|
---|
| 63 | + android:textSize="22sp"
|
---|
| 64 | + android:textStyle="bold"
|
---|
| 65 | + />
|
---|
| 66 | +
|
---|
| 67 | +
|
---|
| 68 | + </LinearLayout>
|
---|
| 69 | +
|
---|
| 70 | +
|
---|
| 71 | + <include layout="@xml/control_buttons" android:id="@+id/level_buttons"/>
|
---|
| 72 | +
|
---|
| 73 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:id="@+id/layout1"
|
---|
| 3 | + android:layout_width="fill_parent" android:layout_height="fill_parent"
|
---|
| 4 | + xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 5 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 6 | + android:layout_height="wrap_content" android:orientation="vertical"
|
---|
| 7 | + android:paddingBottom="60dip">
|
---|
| 8 | +
|
---|
| 9 | + <TextView android:id="@+id/textTitle" android:visibility="visible"
|
---|
| 10 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 11 | + android:layout_centerInParent="true" android:gravity="center_horizontal"
|
---|
| 12 | + android:textSize="24sp" android:paddingTop="20px" android:text="@string/PowertestTitle" />
|
---|
| 13 | +
|
---|
| 14 | +
|
---|
| 15 | +
|
---|
| 16 | +
|
---|
| 17 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 18 | + android:layout_height="wrap_content" android:orientation="vertical">
|
---|
| 19 | + <TextView android:layout_width="fill_parent"
|
---|
| 20 | + android:layout_height="wrap_content" android:layout_centerInParent="true"
|
---|
| 21 | + android:gravity="left" android:paddingTop="10px" android:textSize="18sp"
|
---|
| 22 | + android:visibility="visible" android:id="@+id/chargeStatusText" />
|
---|
| 23 | + <TextView android:layout_width="fill_parent"
|
---|
| 24 | + android:layout_height="wrap_content" android:layout_centerInParent="true"
|
---|
| 25 | + android:gravity="left" android:paddingTop="10px" android:textSize="18sp"
|
---|
| 26 | + android:visibility="visible" android:id="@+id/voltageText" />
|
---|
| 27 | + <TextView android:layout_width="fill_parent"
|
---|
| 28 | + android:layout_height="wrap_content" android:layout_centerInParent="true"
|
---|
| 29 | + android:gravity="left" android:paddingTop="10px" android:textSize="18sp"
|
---|
| 30 | + android:visibility="visible" android:id="@+id/currentText" />
|
---|
| 31 | + <TextView android:layout_width="fill_parent"
|
---|
| 32 | + android:layout_height="wrap_content" android:layout_centerInParent="true"
|
---|
| 33 | + android:gravity="left" android:paddingTop="10px" android:textSize="18sp"
|
---|
| 34 | + android:visibility="visible" android:id="@+id/capacityText" />
|
---|
| 35 | + <TextView android:layout_width="fill_parent"
|
---|
| 36 | + android:layout_height="wrap_content" android:layout_centerInParent="true"
|
---|
| 37 | + android:gravity="left" android:paddingTop="10px" android:textSize="18sp"
|
---|
| 38 | + android:visibility="visible" android:id="@+id/plugText" />
|
---|
| 39 | +<!-- <TextView
|
---|
| 40 | + android:layout_width="fill_parent"
|
---|
| 41 | + android:layout_height="wrap_content"
|
---|
| 42 | + android:gravity="left"
|
---|
| 43 | + android:paddingTop="10px"
|
---|
| 44 | + android:textSize="30sp"
|
---|
| 45 | + android:visibility="visible"
|
---|
| 46 | + android:id="@+id/unplugTest"
|
---|
| 47 | + android:text="@string/AcUnplug"
|
---|
| 48 | + android:textColor="#ff0000"/>
|
---|
| 49 | +
|
---|
| 50 | + <TextView
|
---|
| 51 | + android:layout_width="fill_parent"
|
---|
| 52 | + android:layout_height="wrap_content"
|
---|
| 53 | + android:gravity="left"
|
---|
| 54 | + android:paddingTop="10px"
|
---|
| 55 | + android:textSize="30sp"
|
---|
| 56 | + android:visibility="visible"
|
---|
| 57 | + android:id="@+id/pluginTest"
|
---|
| 58 | + android:text="@string/AcPlugin"
|
---|
| 59 | + android:textColor="#ff0000"/>
|
---|
| 60 | + -->
|
---|
| 61 | + </LinearLayout>
|
---|
| 62 | +
|
---|
| 63 | +
|
---|
| 64 | +
|
---|
| 65 | +
|
---|
| 66 | +
|
---|
| 67 | + </LinearLayout>
|
---|
| 68 | +
|
---|
| 69 | +
|
---|
| 70 | + <include layout="@xml/control_buttons" android:id="@+id/level_buttons"/>
|
---|
| 71 | +
|
---|
| 72 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout
|
---|
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 4 | + android:layout_width="fill_parent"
|
---|
| 5 | + android:layout_height="fill_parent">
|
---|
| 6 | +
|
---|
| 7 | + <LinearLayout
|
---|
| 8 | + android:layout_width="fill_parent"
|
---|
| 9 | + android:layout_height="wrap_content"
|
---|
| 10 | + android:orientation="vertical"
|
---|
| 11 | + android:paddingBottom= "60dip">
|
---|
| 12 | +
|
---|
| 13 | + <TextView
|
---|
| 14 | + android:visibility="visible"
|
---|
| 15 | + android:layout_width="fill_parent"
|
---|
| 16 | + android:layout_height="wrap_content"
|
---|
| 17 | + android:layout_centerInParent="true"
|
---|
| 18 | + android:gravity="center_horizontal"
|
---|
| 19 | + android:paddingTop="20px"
|
---|
| 20 | + android:textSize="24sp"
|
---|
| 21 | + android:text="@string/RTCTitle"/>
|
---|
| 22 | +
|
---|
| 23 | +
|
---|
| 24 | +
|
---|
| 25 | +
|
---|
| 26 | + <TextView
|
---|
| 27 | + android:id="@+id/RTCResult"
|
---|
| 28 | + android:visibility="visible"
|
---|
| 29 | + android:layout_width="fill_parent"
|
---|
| 30 | + android:layout_height="wrap_content"
|
---|
| 31 | + android:layout_centerInParent="true"
|
---|
| 32 | + android:gravity="center_horizontal"
|
---|
| 33 | + android:paddingTop="40px"
|
---|
| 34 | + android:textSize="40sp"/>
|
---|
| 35 | +
|
---|
| 36 | +
|
---|
| 37 | + </LinearLayout>
|
---|
| 38 | +
|
---|
| 39 | + <include layout="@xml/control_buttons"/>
|
---|
| 40 | +</RelativeLayout>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:id="@+id/layout1"
|
---|
| 3 | + android:layout_width="fill_parent" android:layout_height="fill_parent"
|
---|
| 4 | + xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 5 | +
|
---|
| 6 | +
|
---|
| 7 | + <include layout="@xml/control_buttons" android:id="@+id/btns"/>
|
---|
| 8 | + <Button android:id="@+id/StopVideo"
|
---|
| 9 | + android:layout_alignParentBottom="true" android:layout_width="wrap_content"
|
---|
| 10 | + android:layout_height="wrap_content" android:text="@string/stop"
|
---|
| 11 | + android:visibility="gone" />
|
---|
| 12 | +
|
---|
| 13 | + <VideoView android:id="@+id/VideoView" android:visibility="gone"
|
---|
| 14 | + android:layout_width="fill_parent" android:layout_height="fill_parent"
|
---|
| 15 | + android:layout_above="@id/StopVideo" />
|
---|
| 16 | + <TextView android:id="@+id/textTitle" android:visibility="visible"
|
---|
| 17 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 18 | + android:gravity="center_horizontal" android:textSize="24sp"
|
---|
| 19 | + android:text="@string/RuninTestTitle" />
|
---|
| 20 | +
|
---|
| 21 | +
|
---|
| 22 | +
|
---|
| 23 | + <TextView android:id="@+id/SleepWakeText"
|
---|
| 24 | + android:layout_height="wrap_content" android:layout_width="wrap_content"
|
---|
| 25 | + android:textSize="55sp" android:layout_below="@id/textTitle" />
|
---|
| 26 | +
|
---|
| 27 | + <Spinner android:id="@+id/SleepWakeTimesSpinner"
|
---|
| 28 | + android:layout_width="wrap_content" android:layout_height="55sp"
|
---|
| 29 | + android:layout_alignParentRight="true" android:layout_marginTop="10sp"
|
---|
| 30 | + android:layout_alignTop="@id/SleepWakeText" />
|
---|
| 31 | +
|
---|
| 32 | + <TextView android:id="@+id/MemText" android:layout_height="wrap_content"
|
---|
| 33 | + android:layout_width="wrap_content" android:textSize="55sp"
|
---|
| 34 | + android:gravity="center_horizontal" android:layout_below="@id/SleepWakeText" />
|
---|
| 35 | +
|
---|
| 36 | + <Spinner android:id="@+id/MemSizeSpinner" android:layout_width="wrap_content"
|
---|
| 37 | + android:layout_height="55sp" android:layout_alignParentRight="true"
|
---|
| 38 | + android:layout_marginTop="10sp" android:layout_alignTop="@id/MemText" />
|
---|
| 39 | +
|
---|
| 40 | + <TextView android:id="@+id/VideoText" android:layout_height="wrap_content"
|
---|
| 41 | + android:layout_width="wrap_content" android:textSize="55sp"
|
---|
| 42 | + android:layout_below="@id/MemText" />
|
---|
| 43 | +
|
---|
| 44 | + <Spinner android:id="@+id/VideoLengthSpinner"
|
---|
| 45 | + android:layout_width="wrap_content" android:layout_height="55sp"
|
---|
| 46 | + android:layout_alignParentRight="true" android:layout_marginTop="10sp"
|
---|
| 47 | + android:layout_alignTop="@id/VideoText" />
|
---|
| 48 | +
|
---|
| 49 | + <TextView android:id="@+id/BatteryTempText"
|
---|
| 50 | + android:layout_height="wrap_content" android:layout_width="wrap_content"
|
---|
| 51 | + android:textSize="55sp" android:layout_below="@id/VideoText"/>
|
---|
| 52 | +
|
---|
| 53 | + <ScrollView android:layout_width="fill_parent"
|
---|
| 54 | + android:layout_height="wrap_content" android:layout_above="@id/btns"
|
---|
| 55 | + android:layout_below="@id/MemText">
|
---|
| 56 | + <TextView android:id="@+id/MemResult" android:layout_height="wrap_content"
|
---|
| 57 | + android:layout_width="wrap_content" android:textSize="18sp"
|
---|
| 58 | + android:visibility="gone" />
|
---|
| 59 | + </ScrollView>
|
---|
| 60 | + <Button android:id="@+id/TestStart" android:layout_below="@id/BatteryTempText"
|
---|
| 61 | + android:layout_width="wrap_content" android:layout_height="wrap_content" />
|
---|
| 62 | +
|
---|
| 63 | + <ProgressBar android:visibility="gone"
|
---|
| 64 | + android:layout_below="@id/BatteryTempText" android:layout_width="wrap_content"
|
---|
| 65 | + android:layout_height="wrap_content" android:id="@+id/progress" />
|
---|
| 66 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 3 | + android:id="@+id/layout1"
|
---|
| 4 | + android:layout_width="fill_parent"
|
---|
| 5 | + android:layout_height="fill_parent" >
|
---|
| 6 | +
|
---|
| 7 | + <LinearLayout
|
---|
| 8 | + android:layout_width="fill_parent"
|
---|
| 9 | + android:layout_height="wrap_content"
|
---|
| 10 | + android:orientation="vertical"
|
---|
| 11 | + android:paddingBottom="60dip" >
|
---|
| 12 | +
|
---|
| 13 | + <TextView
|
---|
| 14 | + android:id="@+id/textTitle"
|
---|
| 15 | + android:layout_width="fill_parent"
|
---|
| 16 | + android:layout_height="wrap_content"
|
---|
| 17 | + android:layout_centerInParent="true"
|
---|
| 18 | + android:gravity="center_horizontal"
|
---|
| 19 | + android:paddingTop="20px"
|
---|
| 20 | + android:text="@string/SdCardTitle"
|
---|
| 21 | + android:textSize="24sp"
|
---|
| 22 | + android:visibility="visible" />
|
---|
| 23 | +
|
---|
| 24 | + <ScrollView
|
---|
| 25 | + android:layout_width="fill_parent"
|
---|
| 26 | + android:layout_height="wrap_content" >
|
---|
| 27 | +
|
---|
| 28 | + <TextView
|
---|
| 29 | + android:id="@+id/sdresultText"
|
---|
| 30 | + android:layout_width="fill_parent"
|
---|
| 31 | + android:layout_height="wrap_content"
|
---|
| 32 | + android:paddingTop="20px"
|
---|
| 33 | + android:textSize="18sp"
|
---|
| 34 | + android:text="@string/InsertSdCard"
|
---|
| 35 | + android:visibility="visible" />
|
---|
| 36 | + </ScrollView>
|
---|
| 37 | + </LinearLayout>
|
---|
| 38 | +
|
---|
| 39 | + <include layout="@xml/control_buttons" android:id="@+id/level_buttons"/>
|
---|
| 40 | +
|
---|
| 41 | +
|
---|
| 42 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:id="@+id/layout1"
|
---|
| 3 | + android:layout_width="fill_parent" android:layout_height="fill_parent"
|
---|
| 4 | + xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 5 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 6 | + android:layout_height="wrap_content" android:orientation="vertical"
|
---|
| 7 | + android:paddingBottom="60dip">
|
---|
| 8 | +
|
---|
| 9 | + <TextView android:id="@+id/SimCardTestTitle" android:visibility="visible"
|
---|
| 10 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 11 | + android:layout_centerInParent="true" android:gravity="center_horizontal"
|
---|
| 12 | + android:textSize="40sp" android:text="@string/SimCardTestTitle" android:paddingTop="20px" />
|
---|
| 13 | +
|
---|
| 14 | + <TextView android:id="@+id/text"
|
---|
| 15 | + android:layout_gravity="center_vertical"
|
---|
| 16 | + android:visibility="visible"
|
---|
| 17 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 18 | + android:layout_centerInParent="true" android:gravity="center_horizontal"
|
---|
| 19 | + android:textSize="20sp" android:paddingTop="80px" />
|
---|
| 20 | + </LinearLayout>
|
---|
| 21 | +
|
---|
| 22 | + <include layout="@xml/control_buttons" android:id="@+id/btns"/>
|
---|
| 23 | +
|
---|
| 24 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 3 | + android:layout_width="match_parent" android:layout_height="match_parent">
|
---|
| 4 | +
|
---|
| 5 | + <RelativeLayout android:layout_height="match_parent"
|
---|
| 6 | + android:layout_width="wrap_content" android:id="@+id/relativeLayout1">
|
---|
| 7 | + <TextView android:text="@string/SpeakerTitle" android:id="@+id/txtTitle"
|
---|
| 8 | + android:textSize="30dip" android:gravity="center"
|
---|
| 9 | + android:layout_centerHorizontal="true" android:layout_width="fill_parent"
|
---|
| 10 | + android:layout_height="wrap_content" />
|
---|
| 11 | +
|
---|
| 12 | + <TextView android:id="@+id/txtContent" android:layout_below="@+id/txtTitle"
|
---|
| 13 | + android:gravity="center" android:layout_centerHorizontal="true"
|
---|
| 14 | + android:layout_width="fill_parent" android:layout_height="wrap_content" />
|
---|
| 15 | +
|
---|
| 16 | +
|
---|
| 17 | + <include layout="@xml/control_buttons" android:id="@+id/spk_btn"/>
|
---|
| 18 | +
|
---|
| 19 | + <LinearLayout android:layout_centerInParent="true"
|
---|
| 20 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 21 | + android:orientation="horizontal">
|
---|
| 22 | +
|
---|
| 23 | + <Button android:id="@+id/spk_btn_left" android:layout_width="0dip"
|
---|
| 24 | + android:layout_height="wrap_content" android:layout_weight="1"
|
---|
| 25 | + android:text="@string/Left" />
|
---|
| 26 | +
|
---|
| 27 | + <Button android:id="@+id/spk_btn_right" android:layout_width="0dip"
|
---|
| 28 | + android:layout_height="wrap_content" android:layout_weight="1"
|
---|
| 29 | + android:text="@string/Right" />
|
---|
| 30 | +
|
---|
| 31 | + </LinearLayout>
|
---|
| 32 | +
|
---|
| 33 | + </RelativeLayout>
|
---|
| 34 | +
|
---|
| 35 | +
|
---|
| 36 | +</LinearLayout>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 3 | + android:orientation="vertical"
|
---|
| 4 | + android:layout_width="fill_parent"
|
---|
| 5 | + android:layout_height="fill_parent">
|
---|
| 6 | + <TextView
|
---|
| 7 | + android:text="@string/nand_flash"
|
---|
| 8 | + android:textStyle="bold"
|
---|
| 9 | + android:textSize="20dip"
|
---|
| 10 | + android:layout_width="fill_parent"
|
---|
| 11 | + android:layout_height="wrap_content"
|
---|
| 12 | + android:layout_marginLeft="20dip"
|
---|
| 13 | + android:layout_marginTop="20dip"/>
|
---|
| 14 | + <TextView
|
---|
| 15 | + android:text="@string/total_space"
|
---|
| 16 | + android:textSize="22dip"
|
---|
| 17 | + android:layout_width="fill_parent"
|
---|
| 18 | + android:layout_height="wrap_content"
|
---|
| 19 | + android:layout_marginLeft="40dip"
|
---|
| 20 | + android:layout_marginTop="10dip"/>
|
---|
| 21 | + <TextView
|
---|
| 22 | + android:id="@+id/nand_total_space"
|
---|
| 23 | + android:textSize="20dip"
|
---|
| 24 | + android:layout_width="fill_parent"
|
---|
| 25 | + android:layout_height="wrap_content"
|
---|
| 26 | + android:layout_marginLeft="50dip"/>
|
---|
| 27 | + <TextView
|
---|
| 28 | + android:layout_marginTop="10dip"
|
---|
| 29 | + android:text="@string/available_space"
|
---|
| 30 | + android:textSize="22dip"
|
---|
| 31 | + android:layout_width="fill_parent"
|
---|
| 32 | + android:layout_height="wrap_content"
|
---|
| 33 | + android:layout_marginLeft="40dip"/>
|
---|
| 34 | + <TextView
|
---|
| 35 | + android:id="@+id/nand_available_space"
|
---|
| 36 | + android:textSize="20dip"
|
---|
| 37 | + android:layout_width="fill_parent"
|
---|
| 38 | + android:layout_height="wrap_content"
|
---|
| 39 | + android:layout_marginLeft="50dip"/>
|
---|
| 40 | +
|
---|
| 41 | + <TextView
|
---|
| 42 | + android:text="@string/internal_storage"
|
---|
| 43 | + android:textStyle="bold"
|
---|
| 44 | + android:textSize="20dip"
|
---|
| 45 | + android:layout_width="fill_parent"
|
---|
| 46 | + android:layout_height="wrap_content"
|
---|
| 47 | + android:layout_marginLeft="20dip"
|
---|
| 48 | + android:layout_marginTop="20dip"/>
|
---|
| 49 | + <TextView
|
---|
| 50 | + android:layout_marginTop="10dip"
|
---|
| 51 | + android:text="@string/available_space"
|
---|
| 52 | + android:textSize="22dip"
|
---|
| 53 | + android:layout_width="fill_parent"
|
---|
| 54 | + android:layout_height="wrap_content"
|
---|
| 55 | + android:layout_marginLeft="40dip"/>
|
---|
| 56 | + <TextView
|
---|
| 57 | + android:id="@+id/data_available_space"
|
---|
| 58 | + android:textSize="20dip"
|
---|
| 59 | + android:layout_width="fill_parent"
|
---|
| 60 | + android:layout_height="wrap_content"
|
---|
| 61 | + android:layout_marginLeft="50dip"/>
|
---|
| 62 | +
|
---|
| 63 | + <TextView
|
---|
| 64 | + android:layout_width="fill_parent"
|
---|
| 65 | + android:layout_height="0dip"
|
---|
| 66 | + android:layout_weight="1"/>
|
---|
| 67 | + <include layout="@xml/control_buttons" android:id="@+id/btns"/>
|
---|
| 68 | +</LinearLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:id="@+id/layout1"
|
---|
| 3 | + android:layout_width="fill_parent" android:layout_height="fill_parent"
|
---|
| 4 | + xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 5 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 6 | + android:layout_height="wrap_content" android:orientation="vertical"
|
---|
| 7 | + android:paddingBottom="60dip">
|
---|
| 8 | + <TextView android:text="@string/StorageTestTitle" android:id="@+id/storageTitle"
|
---|
| 9 | + android:textSize="30dip" android:gravity="center"
|
---|
| 10 | + android:layout_centerHorizontal="true" android:layout_width="fill_parent"
|
---|
| 11 | + android:layout_height="wrap_content" />
|
---|
| 12 | +
|
---|
| 13 | + <TextView android:id="@+id/resultText" android:layout_width="fill_parent"
|
---|
| 14 | + android:layout_height="wrap_content" android:layout_centerInParent="true"
|
---|
| 15 | + android:gravity="center_horizontal" android:paddingTop="20px"
|
---|
| 16 | + android:textSize="18sp" android:visibility="visible" />
|
---|
| 17 | +
|
---|
| 18 | + </LinearLayout>
|
---|
| 19 | + <include layout="@xml/control_buttons" android:id="@+id/btns"/>
|
---|
| 20 | +
|
---|
| 21 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:layout_width="fill_parent"
|
---|
| 3 | + android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 4 | +
|
---|
| 5 | + <include layout="@xml/control_buttons" android:id="@+id/btns"/>
|
---|
| 6 | +
|
---|
| 7 | + <com.DeviceTest.view.PointerLocationView
|
---|
| 8 | + android:id="@+id/pointerview" android:layout_width="fill_parent"
|
---|
| 9 | + android:layout_height="fill_parent" />
|
---|
| 10 | +
|
---|
| 11 | + <TextView android:id="@+id/TouchtextTitle" android:visibility="visible"
|
---|
| 12 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 13 | + android:gravity="center_horizontal" android:textSize="24sp"
|
---|
| 14 | + android:text="@string/TouchtestTitle" android:paddingTop="20px" />
|
---|
| 15 | + <TextView android:id="@+id/TouchInfoText" android:visibility="visible"
|
---|
| 16 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 17 | + android:gravity="center_horizontal" android:textSize="24sp"
|
---|
| 18 | + android:text="@string/TouchtestSubTitle" android:paddingTop="20px"
|
---|
| 19 | + android:layout_below="@id/TouchtextTitle" />
|
---|
| 20 | +
|
---|
| 21 | + <LinearLayout android:layout_width="wrap_content"
|
---|
| 22 | + android:layout_height="wrap_content" android:paddingBottom="20dip"
|
---|
| 23 | + android:layout_below="@id/TouchInfoText">
|
---|
| 24 | +
|
---|
| 25 | +
|
---|
| 26 | + <TextView android:id="@+id/TouchtextMsg" android:visibility="visible"
|
---|
| 27 | + android:layout_height="wrap_content" android:text="@string/TouchtestSubTitle"
|
---|
| 28 | + android:layout_width="wrap_content" android:paddingTop="20px" />
|
---|
| 29 | + </LinearLayout>
|
---|
| 30 | +
|
---|
| 31 | +
|
---|
| 32 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout
|
---|
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 4 | + android:layout_width="fill_parent"
|
---|
| 5 | + android:layout_height="fill_parent">
|
---|
| 6 | +
|
---|
| 7 | + <LinearLayout
|
---|
| 8 | + android:layout_width="fill_parent"
|
---|
| 9 | + android:layout_height="wrap_content"
|
---|
| 10 | + android:orientation="vertical"
|
---|
| 11 | + android:paddingBottom= "60dip">
|
---|
| 12 | +
|
---|
| 13 | + <Button
|
---|
| 14 | + android:id="@+id/goOTGModeSetBtn"
|
---|
| 15 | + android:layout_marginLeft="40dp"
|
---|
| 16 | + android:layout_width="wrap_content"
|
---|
| 17 | + android:layout_height="wrap_content"
|
---|
| 18 | + android:layout_marginTop="20dp"
|
---|
| 19 | + android:text="OTG 模式切换"
|
---|
| 20 | + android:onClick="onGoOtgModeSetBtnClick"/>
|
---|
| 21 | +
|
---|
| 22 | + <TextView
|
---|
| 23 | + android:visibility="visible"
|
---|
| 24 | + android:layout_width="fill_parent"
|
---|
| 25 | + android:layout_height="wrap_content"
|
---|
| 26 | + android:layout_centerInParent="true"
|
---|
| 27 | + android:gravity="center_horizontal"
|
---|
| 28 | + android:paddingTop="20px"
|
---|
| 29 | + android:textSize="24sp"
|
---|
| 30 | + android:text="@string/USBDeviceTitle"/>
|
---|
| 31 | +
|
---|
| 32 | + <TextView
|
---|
| 33 | + android:visibility="visible"
|
---|
| 34 | + android:layout_width="fill_parent"
|
---|
| 35 | + android:layout_height="wrap_content"
|
---|
| 36 | + android:layout_centerInParent="true"
|
---|
| 37 | + android:gravity="center_horizontal"
|
---|
| 38 | + android:paddingTop="20px"
|
---|
| 39 | + android:textSize="20sp"
|
---|
| 40 | + android:text="@string/USBDeviceSubTitle"/>
|
---|
| 41 | +
|
---|
| 42 | +
|
---|
| 43 | +
|
---|
| 44 | + <TextView
|
---|
| 45 | + android:id="@+id/USBNum"
|
---|
| 46 | + android:visibility="visible"
|
---|
| 47 | + android:layout_width="fill_parent"
|
---|
| 48 | + android:layout_height="wrap_content"
|
---|
| 49 | + android:layout_centerInParent="true"
|
---|
| 50 | + android:gravity="center_horizontal"
|
---|
| 51 | + android:paddingTop="40px"
|
---|
| 52 | + android:textSize="40sp"/>
|
---|
| 53 | +
|
---|
| 54 | +
|
---|
| 55 | + </LinearLayout>
|
---|
| 56 | +
|
---|
| 57 | + <include layout="@xml/control_buttons"/>
|
---|
| 58 | +</RelativeLayout>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
---|
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
---|
| 3 | + android:id="@+id/layout1" |
---|
| 4 | + android:layout_width="fill_parent" |
---|
| 5 | + android:layout_height="fill_parent" > |
---|
| 6 | + |
---|
| 7 | + <LinearLayout |
---|
| 8 | + android:layout_width="fill_parent" |
---|
| 9 | + android:layout_height="wrap_content" |
---|
| 10 | + android:orientation="vertical" |
---|
| 11 | + android:paddingBottom="60dip" > |
---|
| 12 | + |
---|
| 13 | + <TextView |
---|
| 14 | + android:id="@+id/textTitle" |
---|
| 15 | + android:layout_width="fill_parent" |
---|
| 16 | + android:layout_height="wrap_content" |
---|
| 17 | + android:layout_centerInParent="true" |
---|
| 18 | + android:gravity="center_horizontal" |
---|
| 19 | + android:paddingTop="20px" |
---|
| 20 | + android:text="@string/UsbHostTestTitle" |
---|
| 21 | + android:textSize="24sp" |
---|
| 22 | + android:visibility="visible" /> |
---|
| 23 | + |
---|
| 24 | + <ScrollView |
---|
| 25 | + android:layout_width="fill_parent" |
---|
| 26 | + android:layout_height="wrap_content" > |
---|
| 27 | + |
---|
| 28 | + <TextView |
---|
| 29 | + android:id="@+id/sdresultText" |
---|
| 30 | + android:layout_width="fill_parent" |
---|
| 31 | + android:layout_height="wrap_content" |
---|
| 32 | + android:paddingTop="20px" |
---|
| 33 | + android:textSize="18sp" |
---|
| 34 | + android:text="@string/InsertSdCard" |
---|
| 35 | + android:visibility="visible" /> |
---|
| 36 | + </ScrollView> |
---|
| 37 | + </LinearLayout> |
---|
| 38 | + |
---|
| 39 | + <include layout="@xml/control_buttons" android:id="@+id/level_buttons"/> |
---|
| 40 | + |
---|
| 41 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 3 | + android:id="@+id/layout1"
|
---|
| 4 | + android:layout_width="fill_parent"
|
---|
| 5 | + android:layout_height="fill_parent" >
|
---|
| 6 | +
|
---|
| 7 | + <TextView
|
---|
| 8 | + android:id="@+id/textTitle"
|
---|
| 9 | + android:layout_width="fill_parent"
|
---|
| 10 | + android:layout_height="wrap_content"
|
---|
| 11 | + android:gravity="center_horizontal"
|
---|
| 12 | + android:text="@string/VersionTitle"
|
---|
| 13 | + android:textSize="24sp"
|
---|
| 14 | + android:visibility="visible" />
|
---|
| 15 | +
|
---|
| 16 | + <LinearLayout
|
---|
| 17 | + android:layout_width="fill_parent"
|
---|
| 18 | + android:layout_height="wrap_content"
|
---|
| 19 | + android:layout_below="@id/textTitle"
|
---|
| 20 | + android:orientation="vertical"
|
---|
| 21 | + android:paddingBottom="60dip" >
|
---|
| 22 | +
|
---|
| 23 | + <LinearLayout
|
---|
| 24 | + android:id="@+id/versionlayout1"
|
---|
| 25 | + android:layout_width="fill_parent"
|
---|
| 26 | + android:layout_height="wrap_content"
|
---|
| 27 | + android:orientation="horizontal" >
|
---|
| 28 | +
|
---|
| 29 | + <TextView
|
---|
| 30 | + android:layout_width="130px"
|
---|
| 31 | + android:layout_height="wrap_content"
|
---|
| 32 | + android:text="@string/Firmwareversion"
|
---|
| 33 | + android:visibility="visible" />
|
---|
| 34 | +
|
---|
| 35 | + <TextView
|
---|
| 36 | + android:id="@+id/TextFirmwareversion"
|
---|
| 37 | + android:layout_width="wrap_content"
|
---|
| 38 | + android:layout_height="wrap_content"
|
---|
| 39 | + android:visibility="visible" />
|
---|
| 40 | + </LinearLayout>
|
---|
| 41 | +
|
---|
| 42 | + <LinearLayout
|
---|
| 43 | + android:id="@+id/versionlayout2"
|
---|
| 44 | + android:layout_width="fill_parent"
|
---|
| 45 | + android:layout_height="wrap_content"
|
---|
| 46 | + android:layout_below="@id/versionlayout1"
|
---|
| 47 | + android:orientation="horizontal" >
|
---|
| 48 | +
|
---|
| 49 | + <TextView
|
---|
| 50 | + android:layout_width="130px"
|
---|
| 51 | + android:layout_height="wrap_content"
|
---|
| 52 | + android:text="@string/Kernelversion"
|
---|
| 53 | + android:visibility="visible" />
|
---|
| 54 | +
|
---|
| 55 | + <TextView
|
---|
| 56 | + android:id="@+id/TextKernelversion"
|
---|
| 57 | + android:layout_width="wrap_content"
|
---|
| 58 | + android:layout_height="wrap_content"
|
---|
| 59 | + android:visibility="visible" />
|
---|
| 60 | + </LinearLayout>
|
---|
| 61 | +
|
---|
| 62 | + <LinearLayout
|
---|
| 63 | + android:id="@+id/versionlayout3"
|
---|
| 64 | + android:layout_width="fill_parent"
|
---|
| 65 | + android:layout_height="wrap_content"
|
---|
| 66 | + android:layout_below="@id/versionlayout2"
|
---|
| 67 | + android:orientation="horizontal" >
|
---|
| 68 | +
|
---|
| 69 | + <TextView
|
---|
| 70 | + android:layout_width="130px"
|
---|
| 71 | + android:layout_height="wrap_content"
|
---|
| 72 | + android:text="@string/Basebandversion"
|
---|
| 73 | + android:visibility="visible" />
|
---|
| 74 | +
|
---|
| 75 | + <TextView
|
---|
| 76 | + android:id="@+id/TextBasebandversion"
|
---|
| 77 | + android:layout_width="wrap_content"
|
---|
| 78 | + android:layout_height="wrap_content"
|
---|
| 79 | + android:visibility="visible" />
|
---|
| 80 | + </LinearLayout>
|
---|
| 81 | +
|
---|
| 82 | + <LinearLayout
|
---|
| 83 | + android:id="@+id/versionlayout4"
|
---|
| 84 | + android:layout_width="fill_parent"
|
---|
| 85 | + android:layout_height="wrap_content"
|
---|
| 86 | + android:layout_below="@id/versionlayout3"
|
---|
| 87 | + android:orientation="horizontal" >
|
---|
| 88 | +
|
---|
| 89 | + <TextView
|
---|
| 90 | + android:layout_width="130px"
|
---|
| 91 | + android:layout_height="wrap_content"
|
---|
| 92 | + android:text="@string/Buildversion"
|
---|
| 93 | + android:visibility="visible" />
|
---|
| 94 | +
|
---|
| 95 | + <TextView
|
---|
| 96 | + android:id="@+id/TextBuildversion"
|
---|
| 97 | + android:layout_width="wrap_content"
|
---|
| 98 | + android:layout_height="wrap_content"
|
---|
| 99 | + android:visibility="visible" />
|
---|
| 100 | + </LinearLayout>
|
---|
| 101 | + </LinearLayout>
|
---|
| 102 | +
|
---|
| 103 | + <include layout="@xml/control_buttons"/>
|
---|
| 104 | +
|
---|
| 105 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<!-- android:layout_centerHorizontal="true" -->
|
---|
| 3 | +<LinearLayout
|
---|
| 4 | + xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 5 | + android:layout_width="match_parent"
|
---|
| 6 | + android:layout_height="match_parent">
|
---|
| 7 | + <RelativeLayout android:layout_height="match_parent" android:layout_width="wrap_content" android:id="@+id/relativeLayout1">
|
---|
| 8 | + <TextView
|
---|
| 9 | + android:text="@string/VibrationTest"
|
---|
| 10 | + android:id="@+id/txtTitle"
|
---|
| 11 | + android:textSize= "30dip"
|
---|
| 12 | + android:gravity="center"
|
---|
| 13 | + android:layout_centerHorizontal="true"
|
---|
| 14 | + android:layout_width="fill_parent"
|
---|
| 15 | + android:layout_height="wrap_content"/>
|
---|
| 16 | +
|
---|
| 17 | + <TextView
|
---|
| 18 | + android:id="@+id/txtContent"
|
---|
| 19 | + android:layout_below ="@+id/txtTitle"
|
---|
| 20 | + android:gravity="center"
|
---|
| 21 | + android:layout_centerHorizontal="true"
|
---|
| 22 | + android:layout_width="fill_parent"
|
---|
| 23 | + android:layout_height="wrap_content"
|
---|
| 24 | +
|
---|
| 25 | + />
|
---|
| 26 | +
|
---|
| 27 | + <include layout="@xml/control_buttons" android:id="@+id/btns"/>
|
---|
| 28 | +
|
---|
| 29 | + </RelativeLayout>
|
---|
| 30 | +
|
---|
| 31 | +
|
---|
| 32 | +
|
---|
| 33 | +
|
---|
| 34 | +</LinearLayout>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<!-- Copyright (C) 2009 The Rockchip Android MID 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 | +<LinearLayout android:id="@+id/video_item"
|
---|
| 17 | + android:layout_width="fill_parent"
|
---|
| 18 | + android:layout_height="80dip"
|
---|
| 19 | + xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 20 | + android:orientation="horizontal">
|
---|
| 21 | + <ImageView android:id="@+id/video_image"
|
---|
| 22 | + android:layout_height="79dip"
|
---|
| 23 | + android:layout_width="140dip"/>
|
---|
| 24 | + <LinearLayout android:id="@+id/video_info"
|
---|
| 25 | + android:layout_width="510dip"
|
---|
| 26 | + android:layout_height="80dip"
|
---|
| 27 | + android:orientation="vertical">
|
---|
| 28 | + <TextView android:id="@+id/video_name"
|
---|
| 29 | + android:layout_width="fill_parent"
|
---|
| 30 | + android:gravity="center_vertical"
|
---|
| 31 | + android:layout_height="45dip"
|
---|
| 32 | + android:paddingLeft="1dip"
|
---|
| 33 | + android:singleLine="true"
|
---|
| 34 | + android:textSize="22dip"/>
|
---|
| 35 | + <LinearLayout android:id="@+id/video_info"
|
---|
| 36 | + android:layout_width="fill_parent"
|
---|
| 37 | + android:layout_height="35dip"
|
---|
| 38 | + android:orientation="horizontal">
|
---|
| 39 | + <TextView android:id="@+id/time_info"
|
---|
| 40 | + android:layout_width="120dip"
|
---|
| 41 | + android:singleLine="true"
|
---|
| 42 | + android:layout_height="35dip"
|
---|
| 43 | + android:paddingLeft="1dip"
|
---|
| 44 | + android:textSize="15dip"/>
|
---|
| 45 | + <TextView android:id="@+id/type_info"
|
---|
| 46 | + android:layout_width="110dip"
|
---|
| 47 | + android:singleLine="true"
|
---|
| 48 | + android:layout_height="35dip"
|
---|
| 49 | + android:paddingLeft="1dip"
|
---|
| 50 | + android:textSize="15dip"/>
|
---|
| 51 | + </LinearLayout>
|
---|
| 52 | + </LinearLayout>
|
---|
| 53 | + <TextView android:id="@+id/size_info"
|
---|
| 54 | + android:layout_width="150dip"
|
---|
| 55 | + android:singleLine="true"
|
---|
| 56 | + android:layout_height="80dip"
|
---|
| 57 | + android:paddingLeft="45dip"
|
---|
| 58 | + android:paddingRight="15dip"
|
---|
| 59 | + android:paddingTop="30dip"
|
---|
| 60 | + android:textSize="25dip"
|
---|
| 61 | + android:gravity="right"/>
|
---|
| 62 | +
|
---|
| 63 | + </LinearLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<RelativeLayout android:id="@+id/layout1"
|
---|
| 3 | + android:layout_width="fill_parent" android:layout_height="fill_parent"
|
---|
| 4 | + xmlns:android="http://schemas.android.com/apk/res/android">
|
---|
| 5 | + <LinearLayout android:layout_width="fill_parent"
|
---|
| 6 | + android:layout_height="wrap_content" android:orientation="vertical"
|
---|
| 7 | + android:paddingBottom="60dip">
|
---|
| 8 | +
|
---|
| 9 | + <TextView android:id="@+id/textTitle" android:visibility="visible"
|
---|
| 10 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 11 | + android:layout_centerInParent="true" android:gravity="center_horizontal"
|
---|
| 12 | + android:textSize="24sp" android:text="@string/Wifitest"
|
---|
| 13 | + android:paddingTop="20px" />
|
---|
| 14 | +
|
---|
| 15 | +
|
---|
| 16 | + <TextView android:id="@+id/wifiInfoText" android:visibility="visible"
|
---|
| 17 | + android:layout_width="fill_parent" android:layout_height="wrap_content"
|
---|
| 18 | + android:layout_centerInParent="true" android:gravity="center_horizontal"
|
---|
| 19 | + android:textSize="20sp" android:paddingTop="20px" />
|
---|
| 20 | +
|
---|
| 21 | + <RelativeLayout android:gravity="center_horizontal"
|
---|
| 22 | + android:layout_width="match_parent" android:id="@+id/relativeLayout1"
|
---|
| 23 | + android:layout_height="wrap_content">
|
---|
| 24 | + <ProgressBar android:id="@+id/wifiprogress"
|
---|
| 25 | + android:visibility="visible" android:layout_width="wrap_content"
|
---|
| 26 | + android:layout_height="wrap_content"></ProgressBar>
|
---|
| 27 | + </RelativeLayout>
|
---|
| 28 | + <TextView android:layout_width="fill_parent"
|
---|
| 29 | + android:layout_height="wrap_content" android:visibility="visible"
|
---|
| 30 | + android:textSize="18sp" android:text="@string/WifiResultText"
|
---|
| 31 | + android:id="@+id/wifiresultText" />
|
---|
| 32 | +
|
---|
| 33 | + </LinearLayout>
|
---|
| 34 | +
|
---|
| 35 | + <include layout="@xml/control_buttons" android:id="@+id/acc_buttons"/>
|
---|
| 36 | +
|
---|
| 37 | +</RelativeLayout> |
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<resources>
|
---|
| 3 | + <string name="app_name">设备测试工具</string>
|
---|
| 4 | +
|
---|
| 5 | + <string name="SpeakerTitle">扬声器测试</string>
|
---|
| 6 | + <string name="SpeakerContent">是否听到声音?</string>
|
---|
| 7 | + <string name="Left">左</string>
|
---|
| 8 | + <string name="Right">右</string>
|
---|
| 9 | + <string name="SpeakerTip">左:男, 右:女</string>
|
---|
| 10 | +
|
---|
| 11 | + <string name="BrightnessTitle">背光测试</string>
|
---|
| 12 | + <string name="BrightnessTitleStop">停止背光测试</string>
|
---|
| 13 | + <string name="BrightnessSubTitle">请观察背光的变化</string>
|
---|
| 14 | +
|
---|
| 15 | + <string name="BluetoothTitle">蓝牙测试</string>
|
---|
| 16 | + <string name="BluetoothSubTitle">请察看设备</string>
|
---|
| 17 | + <string name="BluetoothAdapterFail">获取适配器失败!</string>
|
---|
| 18 | + <string name="BluetoothScan">搜索设备...</string>
|
---|
| 19 | + <string name="BluetoothInit">请等待设备初始化.</string>
|
---|
| 20 | + <string name="BluetoothOpenF">打开蓝牙失败!</string>
|
---|
| 21 | + <string name="BluetoothFindF">查找设备失败.</string>
|
---|
| 22 | + <string name="BluetoothFindS">找到设备....\n 通过!</string>
|
---|
| 23 | +
|
---|
| 24 | + <string name="CameraTitle">摄像头测试</string>
|
---|
| 25 | + <string name="CameratextMsgText">请点击屏幕打开摄像头</string>
|
---|
| 26 | + <string name="CameraFlashTitle">照相和闪光灯测试</string>
|
---|
| 27 | + <string name="CameraFlashtextFront">请点击屏幕打开摄像头\n然后点击预览屏幕拍照</string>
|
---|
| 28 | + <string name="CameraFlashtextBack">请点击屏幕打开摄像头\n然后点击预览屏幕拍照,并注意闪光灯是否亮起</string>
|
---|
| 29 | + <string name="btnRetestText">重测</string>
|
---|
| 30 | +
|
---|
| 31 | + <string name="GpsTestTitle">Gps C/No 测试</string>
|
---|
| 32 | + <string name="GpsTestSubTitle">请察看设备</string>
|
---|
| 33 | + <string name="GpsTestResult">请等待设备初始化</string>
|
---|
| 34 | +
|
---|
| 35 | + <string name="GpsLocationTestTitle">Gps Location test</string>
|
---|
| 36 | + <string name="GpsLocationTestSubTitle">Please observe the equipment</string>
|
---|
| 37 | + <string name="GpsLocationTestResult">Please wait for init the equipment</string>
|
---|
| 38 | + <string name="gpstextx">X axis C/No:</string>
|
---|
| 39 | + <string name="gpstexty">Y axis C/No:</string>
|
---|
| 40 | + <string name="gpstestx">Test X axis</string>
|
---|
| 41 | + <string name="gpstesty">Test Y axis</string>
|
---|
| 42 | +
|
---|
| 43 | + <string name="HeadsetMicTitle">Headset MIC Test</string>
|
---|
| 44 | + <string name="HeadsetMicSubTitle">Please say something to the headset\'s mic and hear
|
---|
| 45 | + from the headset</string>
|
---|
| 46 | +
|
---|
| 47 | + <string name="LcdTestTitle">显示屏测试</string>
|
---|
| 48 | + <string name="LcdTestStart">点击屏幕开始测试</string>
|
---|
| 49 | +
|
---|
| 50 | + <string name="PhoneMictTitle">录音测试</string>
|
---|
| 51 | + <string name="PhoneMicSubTitle">请说话,马上开始录音,录音后将自动播放刚才说的内容</string>
|
---|
| 52 | +
|
---|
| 53 | + <string name="PowertestTitle">电池信息</string>
|
---|
| 54 | + <string name="PowertestSubTitle"> </string>
|
---|
| 55 | + <string name="AcUnplug">未充电测试(unplug ac):</string>
|
---|
| 56 | + <string name="AcPlugin">充电测试(plug in ac):</string>
|
---|
| 57 | + <string name="ChargeState">电池状态</string>
|
---|
| 58 | + <string name="Voltage">电池电压:</string>
|
---|
| 59 | + <string name="Capacity">电池电量:</string>
|
---|
| 60 | + <string name="Plug">电池连接:</string>
|
---|
| 61 | +
|
---|
| 62 | + <string name="SdCardTitle">SD卡测试</string>
|
---|
| 63 | + <string name="SdCardSubTitle">请察看设备</string>
|
---|
| 64 | + <string name="SdCardFail">失败!找不到SD卡</string>
|
---|
| 65 | + <string name="SdCardFind">发现SD卡,容量大小: </string>
|
---|
| 66 | +
|
---|
| 67 | + <string name="TouchtestTitle">触摸测试</string>
|
---|
| 68 | + <string name="TouchtestSubTitle">请先做单点滑动测试,再做多点测试
|
---|
| 69 | + </string>
|
---|
| 70 | +
|
---|
| 71 | + <string name="VersionTitle">版本测试</string>
|
---|
| 72 | + <string name="Firmwareversion">固件版本:</string>
|
---|
| 73 | + <string name="Kernelversion">内核版本:</string>
|
---|
| 74 | + <string name="Basebandversion">基带版本:</string>
|
---|
| 75 | + <string name="Buildversion">产品版本:</string>
|
---|
| 76 | +
|
---|
| 77 | + <string name="VibrationTest">Vibration Test</string>
|
---|
| 78 | +
|
---|
| 79 | + <string name="Wifitest">无线测试</string>
|
---|
| 80 | + <string name="WifiSubText">请查看设备</string>
|
---|
| 81 | + <string name="WifiResultText">请等待设备初始化</string>
|
---|
| 82 | + <string name="WifiError">无线测试失败!</string>
|
---|
| 83 | + <string name="WifiFind">找到网络-</string>
|
---|
| 84 | + <string name="WifiTry">尝试连接到 </string>
|
---|
| 85 | + <string name="WifiConnect">已连接到 </string>
|
---|
| 86 | + <string name="WifiConnectErr">找不到一个可连接的路由!</string>
|
---|
| 87 | + <string name="WifiPing">Ping 测试 : </string>
|
---|
| 88 | + <string name="WifiHttp">Http 连接测试: </string>
|
---|
| 89 | + <string name="WifiSignal3">信号(强)</string>
|
---|
| 90 | + <string name="WifiSignal2">信号(中)</string>
|
---|
| 91 | + <string name="WifiSignal1">信号(弱)</string>
|
---|
| 92 | + <string name="WifiSignal0">信号(差)</string>
|
---|
| 93 | + <string name="SensorTest">感应器测试</string>
|
---|
| 94 | + <string name="num200">200</string>
|
---|
| 95 | + <string name="gsensorvalue">gsensor值: </string>
|
---|
| 96 | + <string name="Accelerometer">=== 加速仪 === </string>
|
---|
| 97 | + <string name="prompt">请将设备屏幕朝上,并按下按钮存储校准数据!</string>
|
---|
| 98 | + <string name="save_calibration">存储校准数据</string>
|
---|
| 99 | + <string name="save_isok">保存成功!</string>
|
---|
| 100 | + <string name="prompt_Gyroscope">按下按钮存储校准数据!</string>
|
---|
| 101 | +
|
---|
| 102 | + <string name="name_acc"> 名字:</string>
|
---|
| 103 | + <string name="vendor_acc"> 厂家:</string>
|
---|
| 104 | + <string name="version_acc">版本:</string>
|
---|
| 105 | + <string name="maxRange_acc">最大值:</string>
|
---|
| 106 | + <string name="resolution_acc">解析度:</string>
|
---|
| 107 | + <string name="power_acc">电源:</string>
|
---|
| 108 | + <string name="sensor_x">x:</string>
|
---|
| 109 | + <string name="sensor_y">y:</string>
|
---|
| 110 | + <string name="sensor_z">z:</string>
|
---|
| 111 | + <string name="Orientation">=== 方向 === </string>
|
---|
| 112 | + <string name="Azimuth"> 方位角:</string>
|
---|
| 113 | + <string name="Pitch"> Pitch:</string>
|
---|
| 114 | + <string name="Roll"> Roll:</string>
|
---|
| 115 | + <string name="Light">=== 光感 === </string>
|
---|
| 116 | + <string name="lightvalue">光感:</string>
|
---|
| 117 | + <string name="Proximity">=== Proximity === </string>
|
---|
| 118 | + <string name="Magnetic_Field">=== Magnetic_Field === </string>
|
---|
| 119 | + <string name="Temperature">=== Temperature === </string>
|
---|
| 120 | + <string name="Gyroscope">=== 陀螺仪 === </string>
|
---|
| 121 | + <string name="Gsensor_x">x轴朝上(x:9,y:0,z:0)</string>
|
---|
| 122 | + <string name="Gsensor_y">y轴朝上(x:0,y:9,z:0)</string>
|
---|
| 123 | + <string name="Gsensor_z">z轴朝上(x:0,y:0,z:9)</string>
|
---|
| 124 | +
|
---|
| 125 | + <string name="GsensorTest">重力感应测试</string>
|
---|
| 126 | + <string name="MsensorTest">磁感应测试</string>
|
---|
| 127 | + <string name="GyroscopeTest">陀螺仪测试</string>
|
---|
| 128 | + <string name="LightsensorTest">光感应测试</string>
|
---|
| 129 | +
|
---|
| 130 | + <string name="KeyboardTestTitle">按键测试</string>
|
---|
| 131 | + <string name="KeyboardTestSubTitle">请测试所有按键</string>
|
---|
| 132 | +
|
---|
| 133 | + <string name="VolUp">Vol+</string>
|
---|
| 134 | + <string name="VolDown">Vol-</string>
|
---|
| 135 | + <string name="Back">Back</string>
|
---|
| 136 | + <string name="Menu">Menu</string>
|
---|
| 137 | + <string name="Home">Home</string>
|
---|
| 138 | +
|
---|
| 139 | +
|
---|
| 140 | + <string name="FlashLightTest">FlashLight Test</string>
|
---|
| 141 | + <string name="FlashLightTestSubText">Please observe the flashlight of your device when
|
---|
| 142 | + you touch the buttons</string>
|
---|
| 143 | + <string name="OpenFlashLight">Open Flash Light</string>
|
---|
| 144 | + <string name="ShutDownFlashLight">Shut Down Flash Light</string>
|
---|
| 145 | +
|
---|
| 146 | + <string name="SimCardTestTitle">Sim Card Test</string>
|
---|
| 147 | +
|
---|
| 148 | + <string name="MrioUSBTitle">Mrio USB Test</string>
|
---|
| 149 | + <string name="MrioUSBsubTitle">Plug in usb and unplug usb</string>
|
---|
| 150 | + <string name="UsbUnplug">Unplug usb test:</string>
|
---|
| 151 | + <string name="UsbPlugin">Plug in usb test:</string>
|
---|
| 152 | + <string name="UsbHostTestFail">失败!找不到USB设备</string>
|
---|
| 153 | + <string name="UsbFind">发现USB设备,容量大小: </string>
|
---|
| 154 | + <string name="PCIETestFail">失败!找不到PCIE存储设备</string>
|
---|
| 155 | + <string name="PCIEFind">发现PCIE存储设备,容量大小: </string>
|
---|
| 156 | + <string name="SATATestFail">失败!找不到SATA存储设备</string>
|
---|
| 157 | + <string name="SATAFind">发现SATA存储设备,容量大小: </string>
|
---|
| 158 | +
|
---|
| 159 | + <string name="EthernetTitle">以太网</string>
|
---|
| 160 | + <string name="EthernetManagerFail">当前系统不支持以太网</string>
|
---|
| 161 | + <string name="EthernetInterfacesFail">未找到以太网配置</string>
|
---|
| 162 | + <string name="EthernetGetInfoTimeoutFail">获取以太网信息超时</string>
|
---|
| 163 | + <string name="EthernetConnectWarn">测试时请确保以太网是连接的</string>
|
---|
| 164 | +
|
---|
| 165 | + <string name="FMRadioTestTitle">FM Radio Test</string>
|
---|
| 166 | + <string name="FMRadioTextMsgText">Please touch the screen, Open the FM Radio</string>
|
---|
| 167 | +
|
---|
| 168 | + <string name="CirTestTitle">Cir Test</string>
|
---|
| 169 | + <string name="CirSend">Send</string>
|
---|
| 170 | +
|
---|
| 171 | + <string name="CpuInfo">CPU 信息</string>
|
---|
| 172 | + <string name="MemInfo">内存信息</string>
|
---|
| 173 | + <string name="DmiInfo">存储空间信息</string>
|
---|
| 174 | + <string name="cpu_title">CPU 信息:</string>
|
---|
| 175 | + <string name="memory_title">内存信息 :</string>
|
---|
| 176 | + <string name="storage_title">存储空间信息 :</string>
|
---|
| 177 | +
|
---|
| 178 | + <string name="IrdaTestTitle">IrDA Test</string>
|
---|
| 179 | + <string name="SirSend">Sir Send</string>
|
---|
| 180 | + <string name="SirReceive">Sir Receive</string>
|
---|
| 181 | + <string name="SirTest">Sir Test</string>
|
---|
| 182 | + <string name="FirSend">Fir Send</string>
|
---|
| 183 | + <string name="FirReceive">Fir Receive</string>
|
---|
| 184 | + <string name="FirTest">Fir Test</string>
|
---|
| 185 | +
|
---|
| 186 | + <string name="InsertSdCard">请插入SD卡!</string>
|
---|
| 187 | + <string name="SdCardNospace">SD卡没有空间!</string>
|
---|
| 188 | +
|
---|
| 189 | + <string name="RecordTest">录音测试</string>
|
---|
| 190 | + <string name="HeadsetRecodrSuccess">录音成功!开始回放.</string>
|
---|
| 191 | + <string name="RecordError">录音失败!</string>
|
---|
| 192 | +
|
---|
| 193 | + <string name="LedTestTitle">Led Test</string>
|
---|
| 194 | + <string name="Red">RED</string>
|
---|
| 195 | + <string name="Green">GREEN</string>
|
---|
| 196 | + <string name="Blue">BLUE</string>
|
---|
| 197 | +
|
---|
| 198 | + <string name="HdmiTestTitle">HDMI测试</string>
|
---|
| 199 | + <string name="HdmiNoInsert">请插入HDMI并点击屏幕开始测试!</string>
|
---|
| 200 | + <string name="HdmiPrepare">HDMI初始化... 请等待3秒左右.</string>
|
---|
| 201 | + <string name="HdmiResult">测试完成 \n屏幕能正常显示吗?</string>
|
---|
| 202 | + <string name="HdmiStart">开始测试!</string>
|
---|
| 203 | + <string name="HdmiStartFail">启动失败! 请确认HDMI是否插入.</string>
|
---|
| 204 | +
|
---|
| 205 | + <string name="StorageTestTitle">存储读写测试</string>
|
---|
| 206 | + <string name="StorageSDNoFind">SD卡路径未找到...\n</string>
|
---|
| 207 | + <string name="StorageSDCopyF">复制到SD卡失败!\n</string>
|
---|
| 208 | + <string name="StorageSDCopyS">复制到SD卡成功!\n</string>
|
---|
| 209 | + <string name="StorageUsbNoFind">Usb host路径未找到...\n</string>
|
---|
| 210 | + <string name="StorageUsbCopyF">复制到UbsHost 失败!\n</string>
|
---|
| 211 | + <string name="StorageUsbCopyS">复制到UbsHost 成功!\n</string>
|
---|
| 212 | +
|
---|
| 213 | + <string name="RuninTestTitle">Run In Test</string>
|
---|
| 214 | + <string name="stop">Stop</string>
|
---|
| 215 | + <string name="start">Start</string>
|
---|
| 216 | +
|
---|
| 217 | + <string name="btnPassText">通过</string>
|
---|
| 218 | + <string name="btnFailText">失败</string>
|
---|
| 219 | + <string name="btnSkipText">返回上一项测试</string>
|
---|
| 220 | + <string name="OKText">OK!</string>
|
---|
| 221 | +
|
---|
| 222 | + <string name="Testall">Test all</string>
|
---|
| 223 | + <string name="Cancel">关闭</string>
|
---|
| 224 | + <string name="Save">保存结果</string>
|
---|
| 225 | + <string name="Clear">清除</string>
|
---|
| 226 | + <string name="Uninstall">卸载</string>
|
---|
| 227 | +
|
---|
| 228 | + <string name="success">成功</string>
|
---|
| 229 | + <string name="fail">失败</string>
|
---|
| 230 | +
|
---|
| 231 | + <string name="UsbHostTestTitle">Usb Host测试</string>
|
---|
| 232 | + <string name="PCIETestTitle">PCIE存储测试</string>
|
---|
| 233 | + <string name="SATATestTitle">SATA存储测试</string>
|
---|
| 234 | + <string name="Hardware">硬件 : </string>
|
---|
| 235 | + <string name="HostStorageState">存储状态 : </string>
|
---|
| 236 | + <string name="Writable">写测试 : </string>
|
---|
| 237 | + <string name="WriteData">写数据! </string>
|
---|
| 238 | + <string name="ReadData">读数据! </string>
|
---|
| 239 | + <string name="MakeDir">创建文件夹 </string>
|
---|
| 240 | + <string name="CreateFile">创建新文件 </string>
|
---|
| 241 | + <string name="FileDel">删除文件 </string>
|
---|
| 242 | + <string name="DirDel">删除文件夹 </string>
|
---|
| 243 | + <string name="Compare">文件比较 </string>
|
---|
| 244 | + <string name="HardwareSupport">硬件 : 支持. \n发现设备 :</string>
|
---|
| 245 | + <string name="HardwareNoSupport">硬件 : 找不到设备! \n请插入设备并等待5秒左右.</string>
|
---|
| 246 | + <string name="total_space">总存储空间</string>
|
---|
| 247 | + <string name="available_space">可用存储空间</string>
|
---|
| 248 | + <string name="camera_switch">切换</string>
|
---|
| 249 | + <string name="SingleTest">单项测试</string>
|
---|
| 250 | + <string name="testall">测试选中的选项</string>
|
---|
| 251 | + <string name="nocamera">没有摄像头</string>
|
---|
| 252 | + <string name="btnRetest">重测</string>
|
---|
| 253 | + <string name="btnreturnText">返回测试界面</string>
|
---|
| 254 | + <string name="alert_dialog_text_entry">请输入你的密码确保拥有相应的权限 </string>
|
---|
| 255 | + <string name="alert_dialog_ok">确定</string>
|
---|
| 256 | + <string name="alert_dialog_cancel">取消</string>
|
---|
| 257 | + <string name="alert_dialog_warning_title">警告</string>
|
---|
| 258 | + <string name="alert_dialog_password">密码:</string>
|
---|
| 259 | + <string name="MobileNetTitle">移动网络测试</string>
|
---|
| 260 | + <string name="MobileNetSubTitle">请插入4G模块和SIM卡</string>
|
---|
| 261 | + <string name="USBDeviceTitle">USB设备测试</string>
|
---|
| 262 | + <string name="USBDeviceSubTitle">请插入USB设备,并观察USB设备数量</string>
|
---|
| 263 | +
|
---|
| 264 | + <string name="RTCTitle">RTC设备测试</string>
|
---|
| 265 | +</resources>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<resources>
|
---|
| 3 | + <string name="app_name">DeviceTest</string>
|
---|
| 4 | + <string name="VibrationTitle">Vibration Test</string>
|
---|
| 5 | + <string name="VibrationContent">Please judge that if the equipment is vibrating
|
---|
| 6 | + </string>
|
---|
| 7 | +
|
---|
| 8 | + <string name="SpeakerTitle">Speaker Test</string>
|
---|
| 9 | + <string name="SpeakerContent">Can you hear from the sound?</string>
|
---|
| 10 | + <string name="Left">Left</string>
|
---|
| 11 | + <string name="Right">Right</string>
|
---|
| 12 | + <string name="SpeakerTip">left:man, right:woman</string>
|
---|
| 13 | +
|
---|
| 14 | + <string name="BrightnessTitle">Brightness Test</string>
|
---|
| 15 | + <string name="BrightnessTitleStop">Stop Test</string>
|
---|
| 16 | + <string name="BrightnessSubTitle">Please observe the changes of brightness</string>
|
---|
| 17 | +
|
---|
| 18 | + <string name="BluetoothTitle">Bluetooth Test</string>
|
---|
| 19 | + <string name="BluetoothSubTitle">Please observe the equipment</string>
|
---|
| 20 | + <string name="BluetoothAdapterFail">Get adapter failed!</string>
|
---|
| 21 | + <string name="BluetoothScan">Scanning equipment...</string>
|
---|
| 22 | + <string name="BluetoothInit">Please wait for init the equipment.</string>
|
---|
| 23 | + <string name="BluetoothOpenF">Open bluetooth failed.</string>
|
---|
| 24 | + <string name="BluetoothFindF">Find equitment failed.</string>
|
---|
| 25 | + <string name="BluetoothFindS">Find equipment....\n Pass!</string>
|
---|
| 26 | +
|
---|
| 27 | + <string name="CameraTitle">Camera Test</string>
|
---|
| 28 | + <string name="CameratextMsgText">Please touch the screen , open the camera</string>
|
---|
| 29 | + <string name="CameraFlashTitle">Camera and Flash Test</string>
|
---|
| 30 | + <string name="CameraFlashtextFront">Please click screen to open camera,then click preview screen to take photo</string>
|
---|
| 31 | + <string name="CameraFlashtextBack">Please click screen to open camera,then click preview screen to take photo with flash on</string>
|
---|
| 32 | + <string name="btnRetestText">Retest</string>
|
---|
| 33 | +
|
---|
| 34 | + <string name="GpsTestTitle">Gps C/No test</string>
|
---|
| 35 | + <string name="GpsTestSubTitle">Please observe the equipment</string>
|
---|
| 36 | + <string name="GpsTestResult">Please wait for init the equipment</string>
|
---|
| 37 | +
|
---|
| 38 | + <string name="GpsLocationTestTitle">Gps Location test</string>
|
---|
| 39 | + <string name="GpsLocationTestSubTitle">Please observe the equipment</string>
|
---|
| 40 | + <string name="GpsLocationTestResult">Please wait for init the equipment</string>
|
---|
| 41 | + <string name="gpstextx">X axis C/No:</string>
|
---|
| 42 | + <string name="gpstexty">Y axis C/No:</string>
|
---|
| 43 | + <string name="gpstestx">Test X axis</string>
|
---|
| 44 | + <string name="gpstesty">Test Y axis</string>
|
---|
| 45 | +
|
---|
| 46 | + <string name="HeadsetMicTitle">Headset MIC Test</string>
|
---|
| 47 | + <string name="HeadsetMicSubTitle">Please say something to the headset\'s mic and hear
|
---|
| 48 | + from the headset</string>
|
---|
| 49 | +
|
---|
| 50 | + <string name="LcdTestTitle">LCD Test</string>
|
---|
| 51 | + <string name="LcdTestStart">Click LCD to start</string>
|
---|
| 52 | +
|
---|
| 53 | + <string name="PhoneMictTitle">Mobile phone MIC test</string>
|
---|
| 54 | + <string name="PhoneMicSubTitle">Please say something to the mobile and hear from
|
---|
| 55 | + the speaker</string>
|
---|
| 56 | +
|
---|
| 57 | + <string name="PowertestTitle">Battery Information</string>
|
---|
| 58 | + <string name="PowertestSubTitle"> </string>
|
---|
| 59 | + <string name="AcUnplug">Discharge test(unplug ac):</string>
|
---|
| 60 | + <string name="AcPlugin">Charge test(plug in ac):</string>
|
---|
| 61 | + <string name="ChargeState">Charge status:</string>
|
---|
| 62 | + <string name="Voltage">Voltage:</string>
|
---|
| 63 | + <string name="Capacity">Capacity:</string>
|
---|
| 64 | + <string name="Plug">Plug:</string>
|
---|
| 65 | +
|
---|
| 66 | + <string name="SdCardTitle">SD card test</string>
|
---|
| 67 | + <string name="SdCardSubTitle">Please observe the equipment</string>
|
---|
| 68 | + <string name="SdCardFail">Fail! Can not find SD card</string>
|
---|
| 69 | + <string name="SdCardFind">Find sd card, total space: </string>
|
---|
| 70 | + <string name="resume_findSD">Please wait......</string>
|
---|
| 71 | +
|
---|
| 72 | + <string name="TouchtestTitle">Touch test</string>
|
---|
| 73 | + <string name="TouchtestSubTitle">Do diagonal test before multi-touch point test
|
---|
| 74 | + </string>
|
---|
| 75 | +
|
---|
| 76 | + <string name="VersionTitle">Version test</string>
|
---|
| 77 | + <string name="Firmwareversion">Firmware version:</string>
|
---|
| 78 | + <string name="Kernelversion">Kernel version:</string>
|
---|
| 79 | + <string name="Basebandversion">Baseband version:</string>
|
---|
| 80 | + <string name="Buildversion">Product version:</string>
|
---|
| 81 | +
|
---|
| 82 | + <string name="VibrationTest">Vibration Test</string>
|
---|
| 83 | + <string name="testall">Test Checked</string>
|
---|
| 84 | + <string name="Wifitest">Wifi test</string>
|
---|
| 85 | + <string name="WifiError">Wifi test fail</string>
|
---|
| 86 | + <string name="WifiFind">Wifi has find</string>
|
---|
| 87 | + <string name="WifiTry">Try to connect </string>
|
---|
| 88 | + <string name="wififindtest">Wifi has find</string>
|
---|
| 89 | + <string name="WifiConnect">Wifi has connect</string>
|
---|
| 90 | + <string name="WifiPing">Ping test : </string>
|
---|
| 91 | + <string name="WifiHttp">Http connect test: </string>
|
---|
| 92 | + <string name="WifiConnectErr">Can not get connection</string>
|
---|
| 93 | + <string name="WifiSubText">Please observe the equipment</string>
|
---|
| 94 | + <string name="WifiResultText">Please wait for init the equipment</string>
|
---|
| 95 | + <string name="WifiSignal3">信号(强)</string>
|
---|
| 96 | + <string name="WifiSignal2">信号(中)</string>
|
---|
| 97 | + <string name="WifiSignal1">信号(弱)</string>
|
---|
| 98 | + <string name="WifiSignal0">信号(差)</string>
|
---|
| 99 | +
|
---|
| 100 | + <string name="SensorTest">Sensor Test</string>
|
---|
| 101 | + <string name="num200">200</string>
|
---|
| 102 | + <string name="gsensorvalue">gsensor value: </string>
|
---|
| 103 | + <string name="Accelerometer">=== Accelerometer === </string>
|
---|
| 104 | + <string name="prompt">Please make device screen above and touch button to save calibration value!</string>
|
---|
| 105 | + <string name="save_calibration">Save calibration value </string>
|
---|
| 106 | + <string name="save_isok">Save Success!</string>
|
---|
| 107 | + <string name="prompt_Gyroscope">touch button to save calibration value!</string>
|
---|
| 108 | +
|
---|
| 109 | + <string name="name_acc"> name:</string>
|
---|
| 110 | + <string name="vendor_acc"> vendor:</string>
|
---|
| 111 | + <string name="version_acc">version:</string>
|
---|
| 112 | + <string name="maxRange_acc">maxRange:</string>
|
---|
| 113 | + <string name="resolution_acc">resolution:</string>
|
---|
| 114 | + <string name="power_acc">power:</string>
|
---|
| 115 | + <string name="sensor_x">x:</string>
|
---|
| 116 | + <string name="sensor_y">y:</string>
|
---|
| 117 | + <string name="sensor_z">z:</string>
|
---|
| 118 | + <string name="Orientation">=== Orientation === </string>
|
---|
| 119 | + <string name="Azimuth"> Azimuth:</string>
|
---|
| 120 | + <string name="Pitch"> Pitch:</string>
|
---|
| 121 | + <string name="Roll"> Roll:</string>
|
---|
| 122 | + <string name="Light">=== Light === </string>
|
---|
| 123 | + <string name="lightvalue">Light:</string>
|
---|
| 124 | + <string name="Proximity">=== Proximity === </string>
|
---|
| 125 | + <string name="Magnetic_Field">=== Magnetic_Field === </string>
|
---|
| 126 | + <string name="Temperature">=== Temperature === </string>
|
---|
| 127 | + <string name="Gyroscope">=== Gyroscope === </string>
|
---|
| 128 | +
|
---|
| 129 | + <string name="Gsensor_x">x axis points up(x:9,y:0,z:0)</string>
|
---|
| 130 | + <string name="Gsensor_y">y axis points up(x:0,y:9,z:0)</string>
|
---|
| 131 | + <string name="Gsensor_z">z axis points up(x:0,y:0,z:9)</string>
|
---|
| 132 | +
|
---|
| 133 | + <string name="GsensorTest">Gsensor Test</string>
|
---|
| 134 | + <string name="MsensorTest">Msensor Test</string>
|
---|
| 135 | + <string name="LightsensorTest">Lightsensor Test</string>
|
---|
| 136 | + <string name="GyroscopeTest">Gyroscope Test</string>
|
---|
| 137 | + <string name="KeyboardTestTitle">Keyboard Test</string>
|
---|
| 138 | + <string name="KeyboardTestSubTitle">Please test all keys</string>
|
---|
| 139 | +
|
---|
| 140 | + <string name="VolUp">Vol+</string>
|
---|
| 141 | + <string name="VolDown">Vol-</string>
|
---|
| 142 | + <string name="Back">Back</string>
|
---|
| 143 | + <string name="Menu">Menu</string>
|
---|
| 144 | + <string name="Home">Home</string>
|
---|
| 145 | +
|
---|
| 146 | +
|
---|
| 147 | + <string name="FlashLightTest">FlashLight Test</string>
|
---|
| 148 | + <string name="FlashLightTestSubText">Please observe the flashlight of your device when
|
---|
| 149 | + you touch the buttons</string>
|
---|
| 150 | + <string name="OpenFlashLight">Open Flash Light</string>
|
---|
| 151 | + <string name="ShutDownFlashLight">Shut Down Flash Light</string>
|
---|
| 152 | +
|
---|
| 153 | + <string name="SimCardTestTitle">Sim Card Test</string>
|
---|
| 154 | +
|
---|
| 155 | + <string name="MrioUSBTitle">Mrio USB Test</string>
|
---|
| 156 | + <string name="MrioUSBsubTitle">Plug in usb and unplug usb</string>
|
---|
| 157 | + <string name="UsbUnplug">Unplug usb test:</string>
|
---|
| 158 | + <string name="UsbPlugin">Plug in usb test:</string>
|
---|
| 159 | + <string name="UsbHostTestFail">Fail! Cannot find the USB</string>
|
---|
| 160 | + <string name="UsbFind">USB found, memory: </string>
|
---|
| 161 | + <string name="PCIETestFail">Fail! Cannot find the PCIE Storage</string>
|
---|
| 162 | + <string name="PCIEFind">PCIE Storage found, memory: </string>
|
---|
| 163 | + <string name="SATATestFail">Fail! Cannot find the SATA storage</string>
|
---|
| 164 | + <string name="SATAFind">SATA storage found, memory: </string>
|
---|
| 165 | +
|
---|
| 166 | + <string name="EthernetTitle">Ethernet test</string>
|
---|
| 167 | + <string name="EthernetManagerFail">System not support ethernet</string>
|
---|
| 168 | + <string name="EthernetInterfacesFail">Not ethernet interfaces</string>
|
---|
| 169 | + <string name="EthernetGetInfoTimeoutFail">Get ethernet info timeout</string>
|
---|
| 170 | + <string name="EthernetConnectWarn">Confirm ethernet is connect during test</string>
|
---|
| 171 | +
|
---|
| 172 | + <string name="FMRadioTestTitle">FM Radio Test</string>
|
---|
| 173 | + <string name="FMRadioTextMsgText">Please touch the screen, Open the FM Radio</string>
|
---|
| 174 | +
|
---|
| 175 | + <string name="CirTestTitle">Cir Test</string>
|
---|
| 176 | + <string name="CirSend">Send</string>
|
---|
| 177 | +
|
---|
| 178 | + <string name="CpuInfo">CPU info</string>
|
---|
| 179 | + <string name="MemInfo">MEM info</string>
|
---|
| 180 | + <string name="DmiInfo">DMI info</string>
|
---|
| 181 | +
|
---|
| 182 | + <string name="cpu_title">CPU Info:</string>
|
---|
| 183 | + <string name="memory_title">Memory Info:</string>
|
---|
| 184 | + <string name="storage_title">Storage Info:</string>
|
---|
| 185 | +
|
---|
| 186 | + <string name="IrdaTestTitle">IrDA Test</string>
|
---|
| 187 | + <string name="SirSend">Sir Send</string>
|
---|
| 188 | + <string name="SirReceive">Sir Receive</string>
|
---|
| 189 | + <string name="SirTest">Sir Test</string>
|
---|
| 190 | + <string name="FirSend">Fir Send</string>
|
---|
| 191 | + <string name="FirReceive">Fir Receive</string>
|
---|
| 192 | + <string name="FirTest">Fir Test</string>
|
---|
| 193 | +
|
---|
| 194 | + <string name="InsertSdCard">Please Insert SD Card!</string>
|
---|
| 195 | + <string name="SdCardNospace">SD Card No Space!</string>
|
---|
| 196 | +
|
---|
| 197 | + <string name="RecordTest">RecordTest</string>
|
---|
| 198 | + <string name="HeadsetRecodrSuccess">record successs!start Play back.</string>
|
---|
| 199 | + <string name="RecordError">Record error!</string>
|
---|
| 200 | +
|
---|
| 201 | + <string name="LedTestTitle">Led Test</string>
|
---|
| 202 | + <string name="Red">RED</string>
|
---|
| 203 | + <string name="Green">GREEN</string>
|
---|
| 204 | + <string name="Blue">BLUE</string>
|
---|
| 205 | +
|
---|
| 206 | + <string name="HdmiTestTitle">HDMI Test</string>
|
---|
| 207 | + <string name="HdmiNoInsert">Please insert HDMI and Touch screen to start test!</string>
|
---|
| 208 | + <string name="HdmiPrepare">Please Wait 3 seconds for Hdmi init!</string>
|
---|
| 209 | + <string name="HdmiResult">Test Finish! \nCan you see the right color in Screen?</string>
|
---|
| 210 | + <string name="HdmiStart">Start Test!</string>
|
---|
| 211 | + <string name="HdmiStartFail">Start failed! Please make sure the HDMI is inserted.</string>
|
---|
| 212 | +
|
---|
| 213 | + <string name="StorageTestTitle">Storage R/W Test</string>
|
---|
| 214 | + <string name="StorageSDNoFind">Sdcard path not found...\n</string>
|
---|
| 215 | + <string name="StorageSDCopyF">Failed copy to sdcard!\n</string>
|
---|
| 216 | + <string name="StorageSDCopyS">Copy to sdcard success!\n</string>
|
---|
| 217 | + <string name="StorageUsbNoFind">Usb host path not found...\n</string>
|
---|
| 218 | + <string name="StorageUsbCopyF">Failed copy to usb host!\n</string>
|
---|
| 219 | + <string name="StorageUsbCopyS">Copy to usb host success!\n</string>
|
---|
| 220 | +
|
---|
| 221 | +
|
---|
| 222 | +
|
---|
| 223 | + <string name="RuninTestTitle">Run In Test</string>
|
---|
| 224 | + <string name="stop">Stop</string>
|
---|
| 225 | + <string name="start">Start</string>
|
---|
| 226 | +
|
---|
| 227 | + <string name="btnPassText">Pass</string>
|
---|
| 228 | + <string name="btnFailText">Fail</string>
|
---|
| 229 | + <string name="btnSkipText">Back</string>
|
---|
| 230 | + <string name="OKText">OK!</string>
|
---|
| 231 | +
|
---|
| 232 | + <string name="Testall">Test all</string>
|
---|
| 233 | + <string name="Cancel">Close</string>
|
---|
| 234 | + <string name="Save">Save Result</string>
|
---|
| 235 | + <string name="Clear">Clear</string>
|
---|
| 236 | + <string name="Uninstall">Uninstall</string>
|
---|
| 237 | +
|
---|
| 238 | + <string name="success">Success</string>
|
---|
| 239 | + <string name="fail">Fail</string>
|
---|
| 240 | +
|
---|
| 241 | + <string name="Version">V20210722</string>
|
---|
| 242 | + <string name="UsbHostTestTitle">Usb Host Test </string>
|
---|
| 243 | + <string name="PCIETestTitle">PCIE Stoarage Test </string>
|
---|
| 244 | + <string name="SATATestTitle">SATA Storage Test </string>
|
---|
| 245 | + <string name="Hardware">Hardware : </string>
|
---|
| 246 | + <string name="HostStorageState">HostStorageState : </string>
|
---|
| 247 | + <string name="Writable">Write Test : </string>
|
---|
| 248 | + <string name="WriteData">Write Data! </string>
|
---|
| 249 | + <string name="ReadData">Read Data! </string>
|
---|
| 250 | + <string name="MakeDir">Create Dir </string>
|
---|
| 251 | + <string name="CreateFile">Create New File </string>
|
---|
| 252 | + <string name="FileDel">File delete </string>
|
---|
| 253 | + <string name="DirDel">Dir delete </string>
|
---|
| 254 | + <string name="Compare">Compare </string>
|
---|
| 255 | + <string name="HardwareSupport">Hardware : Support. \nFind Device : </string>
|
---|
| 256 | + <string name="HardwareNoSupport">Hardware : Can\'t find Device! \nPlease insert USB device and wait 5 seconds.</string>
|
---|
| 257 | + <string name="nand_flash">NAND flash</string>
|
---|
| 258 | + <string name="total_space">Total space</string>
|
---|
| 259 | + <string name="available_space">Available space</string>
|
---|
| 260 | + <string name="internal_storage">Internal storage</string>
|
---|
| 261 | + <string name="nand_unavailable">Unavailable</string>
|
---|
| 262 | + <string name="read_only">\u0020(Read-only)</string>
|
---|
| 263 | + <string name="camera_switch">Switch</string>
|
---|
| 264 | + <string name="SingleTest">SingleTest</string>
|
---|
| 265 | + <string name="nocamera">No Camera</string>
|
---|
| 266 | +
|
---|
| 267 | + <string name="btnRetest">Test again</string>
|
---|
| 268 | + <string name="btnreturnText">Return Main Test</string>
|
---|
| 269 | + <string name="load_title">Loading..</string>
|
---|
| 270 | + <string name="wait">Please wait for a moment</string>
|
---|
| 271 | + <string name="no_mediafiles">No media files</string>
|
---|
| 272 | + <string name="alert_checkfile">Please check whether the video file is exist.</string>
|
---|
| 273 | + <string name="clock_test">Clock Test</string>
|
---|
| 274 | + <string name="alert_dialog_text_entry">Please enter your password make sure you have the appropriate permissions</string>
|
---|
| 275 | + <string name="alert_dialog_ok">OK</string>
|
---|
| 276 | + <string name="alert_dialog_cancel">Cancle</string>
|
---|
| 277 | + <string name="alert_dialog_warning_title">Warning</string>
|
---|
| 278 | + <string name="alert_dialog_password">Password:</string>
|
---|
| 279 | + <string name="MobileNetTitle">MobileNetwork Test</string>
|
---|
| 280 | + <string name="MobileNetSubTitle">Please insert the 4G module and sim card</string>
|
---|
| 281 | + <string name="USBDeviceTitle">USB Device Test</string>
|
---|
| 282 | + <string name="USBDeviceSubTitle">Please insert the USB device, and observe the USB device number</string>
|
---|
| 283 | + <string name="RTCTitle">RTC Device Test</string>
|
---|
| 284 | +</resources>
|
---|
.. | .. |
---|
| 1 | +<?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
---|
| 3 | + android:layout_width="fill_parent"
|
---|
| 4 | + android:layout_height="wrap_content"
|
---|
| 5 | + android:layout_alignParentBottom="true"
|
---|
| 6 | + android:layout_gravity="bottom"
|
---|
| 7 | + android:orientation="horizontal"
|
---|
| 8 | + android:background="#000000" >
|
---|
| 9 | +<Button
|
---|
| 10 | + android:id="@+id/btn_return"
|
---|
| 11 | + android:layout_width="0dip"
|
---|
| 12 | + android:layout_height="wrap_content"
|
---|
| 13 | + android:layout_weight="1"
|
---|
| 14 | + android:text="@string/btnreturnText" />
|
---|
| 15 | + <Button
|
---|
| 16 | + android:id="@+id/btn_Pass"
|
---|
| 17 | + android:layout_width="0dip"
|
---|
| 18 | + android:layout_height="wrap_content"
|
---|
| 19 | + android:layout_weight="1"
|
---|
| 20 | + android:text="@string/btnPassText" />
|
---|
| 21 | +
|
---|
| 22 | + <Button
|
---|
| 23 | + android:id="@+id/btn_Fail"
|
---|
| 24 | + android:layout_width="0dip"
|
---|
| 25 | + android:layout_height="wrap_content"
|
---|
| 26 | + android:layout_weight="1"
|
---|
| 27 | + android:text="@string/btnFailText" />
|
---|
| 28 | +
|
---|
| 29 | + <Button
|
---|
| 30 | + android:id="@+id/btn_Skip"
|
---|
| 31 | + android:layout_width="0dip"
|
---|
| 32 | + android:layout_height="wrap_content"
|
---|
| 33 | + android:layout_weight="1"
|
---|
| 34 | + android:text="@string/btnSkipText" />
|
---|
| 35 | +
|
---|
| 36 | +</LinearLayout> |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import java.util.ArrayList;
|
---|
| 7 | +
|
---|
| 8 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 9 | +import com.DeviceTest.helper.TestCase.RESULT;
|
---|
| 10 | +
|
---|
| 11 | +import android.app.Activity;
|
---|
| 12 | +import android.bluetooth.BluetoothAdapter;
|
---|
| 13 | +import android.bluetooth.BluetoothDevice;
|
---|
| 14 | +import android.content.BroadcastReceiver;
|
---|
| 15 | +import android.content.Context;
|
---|
| 16 | +import android.content.Intent;
|
---|
| 17 | +import android.content.IntentFilter;
|
---|
| 18 | +import android.net.wifi.WifiManager;
|
---|
| 19 | +import android.os.Bundle;
|
---|
| 20 | +import android.os.Handler;
|
---|
| 21 | +import android.os.Message;
|
---|
| 22 | +import android.util.Log;
|
---|
| 23 | +import android.view.KeyEvent;
|
---|
| 24 | +import android.view.View;
|
---|
| 25 | +import android.view.Window;
|
---|
| 26 | +import android.widget.Button;
|
---|
| 27 | +import android.widget.ProgressBar;
|
---|
| 28 | +import android.widget.TextView;
|
---|
| 29 | +
|
---|
| 30 | +public class BluetoothTestActivity extends Activity {
|
---|
| 31 | + private static final String TAG = BluetoothTestActivity.class
|
---|
| 32 | + .getSimpleName();
|
---|
| 33 | + private final static String ERRMSG = "FAIL!Can not find a bluetooth equipment!";
|
---|
| 34 | +
|
---|
| 35 | + private static final int MSG_OPEN = 0;
|
---|
| 36 | + private static final int MSG_FAILED = 1;
|
---|
| 37 | + private static final int MSG_FINISH_TEST = 2;
|
---|
| 38 | +
|
---|
| 39 | + private boolean isTestFinish = false;
|
---|
| 40 | +// private boolean isUnRegOver = false;
|
---|
| 41 | + private BluetoothAdapter mAdapter;
|
---|
| 42 | + private BroadcastReceiver mBluetoothReceiver;
|
---|
| 43 | +
|
---|
| 44 | +// private ArrayList<String> mDeviceNames;
|
---|
| 45 | + private Handler mHandler;
|
---|
| 46 | + private TextView mResult;
|
---|
| 47 | + private int mTestCount;
|
---|
| 48 | + private int mTestOpen;
|
---|
| 49 | + private ProgressBar progressBar;
|
---|
| 50 | + boolean stop = false;
|
---|
| 51 | +
|
---|
| 52 | + public BluetoothTestActivity() {
|
---|
| 53 | +// this.mDeviceNames = new ArrayList<String>();
|
---|
| 54 | + this.mHandler = new MyHandler();
|
---|
| 55 | + this.mBluetoothReceiver = new MyBroadcastReceiver();
|
---|
| 56 | +
|
---|
| 57 | + }
|
---|
| 58 | +
|
---|
| 59 | +
|
---|
| 60 | + protected void onCreate(Bundle savedInstanceState) {
|
---|
| 61 | + super.onCreate(savedInstanceState);
|
---|
| 62 | +
|
---|
| 63 | + setTitle(getTitle() + "----("
|
---|
| 64 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")");
|
---|
| 65 | + //requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 66 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 67 | +
|
---|
| 68 | + setContentView(R.layout.bluetoothtest);
|
---|
| 69 | +
|
---|
| 70 | + mResult = (TextView) findViewById(R.id.resultText);
|
---|
| 71 | +
|
---|
| 72 | + progressBar = (ProgressBar) findViewById(R.id.progress);
|
---|
| 73 | + findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 74 | + //findViewById(R.id.btn_Fail).setVisibility(View.INVISIBLE);
|
---|
| 75 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 76 | + //findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 77 | +
|
---|
| 78 | + this.mAdapter = BluetoothAdapter.getDefaultAdapter();
|
---|
| 79 | +
|
---|
| 80 | + /*if (mAdapter == null) {
|
---|
| 81 | + Log.d(TAG, "cdy --- mAdapter == null");
|
---|
| 82 | +// isTestFinish = true;
|
---|
| 83 | + findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 84 | + this.mResult.setText(getString(R.string.BluetoothAdapterFail));
|
---|
| 85 | + progressBar.setVisibility(View.GONE);
|
---|
| 86 | + //failed();
|
---|
| 87 | + }*/
|
---|
| 88 | +
|
---|
| 89 | + }
|
---|
| 90 | +
|
---|
| 91 | +
|
---|
| 92 | + protected void onResume() {
|
---|
| 93 | +
|
---|
| 94 | + super.onResume();
|
---|
| 95 | + stop = false;
|
---|
| 96 | + if ((this.mAdapter != null)){
|
---|
| 97 | +// if ((this.mAdapter != null) && (!this.isTestFinish)) {
|
---|
| 98 | +
|
---|
| 99 | +// this.isUnRegOver = false;
|
---|
| 100 | +
|
---|
| 101 | + IntentFilter intentFilter = new IntentFilter();
|
---|
| 102 | + intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
|
---|
| 103 | + intentFilter
|
---|
| 104 | + .addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
|
---|
| 105 | + intentFilter
|
---|
| 106 | + .addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
|
---|
| 107 | + intentFilter.addAction(BluetoothDevice.ACTION_FOUND);
|
---|
| 108 | +
|
---|
| 109 | + registerReceiver(this.mBluetoothReceiver, intentFilter);
|
---|
| 110 | +
|
---|
| 111 | +// this.mDeviceNames.clear();
|
---|
| 112 | +
|
---|
| 113 | + if(this.mAdapter == null)
|
---|
| 114 | + {
|
---|
| 115 | + Log.d(TAG, "cdy --onResume- mAdapter == null");
|
---|
| 116 | +
|
---|
| 117 | + }
|
---|
| 118 | + Log.d(TAG, "cdy --onResume else- mAdapter == null");
|
---|
| 119 | + if (this.mAdapter.isEnabled()) {
|
---|
| 120 | + mAdapter.startDiscovery();
|
---|
| 121 | + mResult.setText(getString(R.string.BluetoothScan));
|
---|
| 122 | + } else {
|
---|
| 123 | + this.mHandler.sendEmptyMessage(MSG_OPEN);
|
---|
| 124 | + mResult.setText(getString(R.string.BluetoothInit));
|
---|
| 125 | + }
|
---|
| 126 | + }else
|
---|
| 127 | + {
|
---|
| 128 | + findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 129 | + this.mResult.setText(getString(R.string.BluetoothAdapterFail));
|
---|
| 130 | + progressBar.setVisibility(View.GONE);
|
---|
| 131 | + //failed();
|
---|
| 132 | + }
|
---|
| 133 | + }
|
---|
| 134 | +
|
---|
| 135 | +
|
---|
| 136 | + public void onPause() {
|
---|
| 137 | + super.onPause();
|
---|
| 138 | + stop = true;
|
---|
| 139 | +// if ((this.mAdapter == null) || (this.isTestFinish)) {
|
---|
| 140 | +// return;
|
---|
| 141 | +// }
|
---|
| 142 | +// this.isUnRegOver = true;
|
---|
| 143 | + if (this.mAdapter == null) {
|
---|
| 144 | + return;
|
---|
| 145 | + }
|
---|
| 146 | + unregisterReceiver(mBluetoothReceiver);
|
---|
| 147 | + mAdapter.cancelDiscovery();
|
---|
| 148 | + // this.mAdapter.disable();
|
---|
| 149 | + mHandler.removeMessages(MSG_FAILED);
|
---|
| 150 | + }
|
---|
| 151 | +
|
---|
| 152 | +
|
---|
| 153 | +
|
---|
| 154 | + class MyHandler extends Handler {
|
---|
| 155 | +
|
---|
| 156 | + public void handleMessage(Message msg) {
|
---|
| 157 | + if(stop) {
|
---|
| 158 | + return;
|
---|
| 159 | + }
|
---|
| 160 | + switch (msg.what) {
|
---|
| 161 | + case MSG_OPEN:
|
---|
| 162 | +
|
---|
| 163 | +// if ((isTestFinish) && (!isUnRegOver)) {
|
---|
| 164 | +// isUnRegOver = true;
|
---|
| 165 | +// removeMessages(MSG_OPEN);
|
---|
| 166 | +//
|
---|
| 167 | +// unregisterReceiver(mBluetoothReceiver);
|
---|
| 168 | +// // mAdapter.disable();
|
---|
| 169 | +//
|
---|
| 170 | +// break;
|
---|
| 171 | +// }
|
---|
| 172 | + Log.i(TAG, "142,mAdapter.isEnabled()" + mAdapter.isEnabled());
|
---|
| 173 | + if (mAdapter.isEnabled()) {
|
---|
| 174 | +
|
---|
| 175 | + Log.i(TAG, "145,bluetooth is open and then startDiscovery!");
|
---|
| 176 | + mAdapter.startDiscovery();
|
---|
| 177 | +
|
---|
| 178 | + removeMessages(MSG_OPEN);
|
---|
| 179 | +
|
---|
| 180 | + } else {
|
---|
| 181 | +
|
---|
| 182 | + if (mTestOpen < 15) {
|
---|
| 183 | +
|
---|
| 184 | + Log.i(TAG,
|
---|
| 185 | + "bluetooth is close and then open it! mTestOpen="
|
---|
| 186 | + + mTestOpen);
|
---|
| 187 | +
|
---|
| 188 | + mTestOpen++;
|
---|
| 189 | +
|
---|
| 190 | + mAdapter.enable();
|
---|
| 191 | + sendEmptyMessageDelayed(MSG_OPEN, 1000L);
|
---|
| 192 | +
|
---|
| 193 | + } else {
|
---|
| 194 | +
|
---|
| 195 | +// isTestFinish = true;
|
---|
| 196 | + progressBar.setVisibility(View.GONE);
|
---|
| 197 | + mResult.setText(getString(R.string.BluetoothOpenF));
|
---|
| 198 | + failed();
|
---|
| 199 | + }
|
---|
| 200 | +
|
---|
| 201 | + }
|
---|
| 202 | +
|
---|
| 203 | + break;
|
---|
| 204 | + case MSG_FAILED:
|
---|
| 205 | + ((Button)findViewById(R.id.btn_Fail)).performClick();
|
---|
| 206 | + break;
|
---|
| 207 | + case MSG_FINISH_TEST:
|
---|
| 208 | + removeMessages(MSG_OPEN);
|
---|
| 209 | + ((Button)findViewById(R.id.btn_Pass)).performClick();
|
---|
| 210 | + }
|
---|
| 211 | + }
|
---|
| 212 | + }
|
---|
| 213 | +
|
---|
| 214 | + private void failed() {
|
---|
| 215 | + mHandler.removeMessages(MSG_FAILED);
|
---|
| 216 | + mHandler.sendEmptyMessageAtTime(MSG_FAILED, DeviceTest.TEST_FAILED_DELAY);
|
---|
| 217 | + }
|
---|
| 218 | +
|
---|
| 219 | + class MyBroadcastReceiver extends BroadcastReceiver {
|
---|
| 220 | +
|
---|
| 221 | +
|
---|
| 222 | + public void onReceive(Context context, Intent intent) {
|
---|
| 223 | + String action = intent.getAction();
|
---|
| 224 | + if(stop) {
|
---|
| 225 | + return;
|
---|
| 226 | + }
|
---|
| 227 | + if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
|
---|
| 228 | + int state = intent.getIntExtra(
|
---|
| 229 | + BluetoothAdapter.EXTRA_STATE,
|
---|
| 230 | + Integer.MIN_VALUE);
|
---|
| 231 | + if (state == BluetoothAdapter.STATE_ON) {
|
---|
| 232 | + Log.i(TAG, "onReceive -- STATE_ON");
|
---|
| 233 | + mAdapter.startDiscovery();
|
---|
| 234 | + } else if (state == BluetoothAdapter.STATE_OFF) {
|
---|
| 235 | + Log.i(TAG, "onReceive -- STATE_OFF");
|
---|
| 236 | +
|
---|
| 237 | + }
|
---|
| 238 | +
|
---|
| 239 | + } else if (action.equals(BluetoothAdapter.ACTION_DISCOVERY_STARTED)) {
|
---|
| 240 | + Log.i(TAG, "onReceive -- ACTION_DISCOVERY_STARTED mTestCount="
|
---|
| 241 | + + mTestCount);
|
---|
| 242 | +
|
---|
| 243 | + mResult.setText(getString(R.string.BluetoothScan));
|
---|
| 244 | +
|
---|
| 245 | + } else if (action
|
---|
| 246 | + .equals(BluetoothAdapter.ACTION_DISCOVERY_FINISHED)) {
|
---|
| 247 | + Log.i(TAG, "onReceive -- ACTION_DISCOVERY_FINISHED");
|
---|
| 248 | +
|
---|
| 249 | +// if (!mDeviceNames.isEmpty()) {
|
---|
| 250 | + /*
|
---|
| 251 | + * progressBar.setVisibility(View.GONE); String findstr =
|
---|
| 252 | + * "Find equipment-"; StringBuilder sb = new
|
---|
| 253 | + * StringBuilder().append(findstr) .append("\n");
|
---|
| 254 | + *
|
---|
| 255 | + * for (int i = 0; i < mDeviceNames.size(); i++) {
|
---|
| 256 | + *
|
---|
| 257 | + * sb.append(" <"); String name = (String)
|
---|
| 258 | + * mDeviceNames.get(i);
|
---|
| 259 | + * sb.append(name).append(">").append("\n"); }
|
---|
| 260 | + *
|
---|
| 261 | + * mResult.setText(sb.toString());
|
---|
| 262 | + */
|
---|
| 263 | +// } else {
|
---|
| 264 | +
|
---|
| 265 | +// if ((isTestFinish) && (!isUnRegOver)) {
|
---|
| 266 | +// isUnRegOver = true;
|
---|
| 267 | +// mHandler.removeMessages(0);
|
---|
| 268 | +// unregisterReceiver(mBluetoothReceiver);
|
---|
| 269 | +// progressBar.setVisibility(View.GONE);
|
---|
| 270 | +// mResult.setText(ERRMSG);
|
---|
| 271 | +// }
|
---|
| 272 | + if(isTestFinish) return;
|
---|
| 273 | + if (mTestCount < 15 ) {
|
---|
| 274 | + mTestCount++;
|
---|
| 275 | + mAdapter.startDiscovery();
|
---|
| 276 | +
|
---|
| 277 | + } else {
|
---|
| 278 | +
|
---|
| 279 | +
|
---|
| 280 | + progressBar.setVisibility(View.GONE);
|
---|
| 281 | + mResult.setText(getString(R.string.BluetoothFindF));
|
---|
| 282 | +
|
---|
| 283 | + failed();
|
---|
| 284 | + }
|
---|
| 285 | +
|
---|
| 286 | +// }
|
---|
| 287 | +
|
---|
| 288 | + } else if (action.equals(BluetoothDevice.ACTION_FOUND)) {
|
---|
| 289 | + BluetoothDevice device = intent
|
---|
| 290 | + .getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
---|
| 291 | +
|
---|
| 292 | + // String name =
|
---|
| 293 | + // intent.getStringExtra("android.bluetooth.device.extra.NAME");
|
---|
| 294 | + if (device != null) {
|
---|
| 295 | + isTestFinish = true;
|
---|
| 296 | + progressBar.setVisibility(View.GONE);
|
---|
| 297 | + StringBuilder sb = new StringBuilder().append(getString(R.string.BluetoothFindS)).append(
|
---|
| 298 | + ":");
|
---|
| 299 | + sb.append(
|
---|
| 300 | + " \t- name :"
|
---|
| 301 | + + device.getName()
|
---|
| 302 | + ).append(
|
---|
| 303 | + "\n");
|
---|
| 304 | + mResult.setText(sb.toString());
|
---|
| 305 | + // mDeviceNames.add(device.getName() + "-" +
|
---|
| 306 | + // device.getAddress());
|
---|
| 307 | + mHandler.sendEmptyMessageDelayed(MSG_FINISH_TEST, 2000);
|
---|
| 308 | + }
|
---|
| 309 | +
|
---|
| 310 | + // String address = localBluetoothDevice.getAddress();
|
---|
| 311 | + // mDeviceNames.add(address);
|
---|
| 312 | +
|
---|
| 313 | + }
|
---|
| 314 | +
|
---|
| 315 | + }
|
---|
| 316 | +
|
---|
| 317 | + }
|
---|
| 318 | +
|
---|
| 319 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 320 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 321 | + return false;
|
---|
| 322 | + }
|
---|
| 323 | + return super.dispatchKeyEvent(event);
|
---|
| 324 | + }
|
---|
| 325 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.*;
|
---|
| 4 | +
|
---|
| 5 | +import com.DeviceTest.helper.ConfigUtil;
|
---|
| 6 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 7 | +
|
---|
| 8 | +import android.app.Activity;
|
---|
| 9 | +import android.content.Context;
|
---|
| 10 | +import android.hardware.display.DisplayManager;
|
---|
| 11 | +import android.os.Build;
|
---|
| 12 | +import android.os.Bundle;
|
---|
| 13 | +import android.os.Handler;
|
---|
| 14 | +import android.os.Message;
|
---|
| 15 | +import android.os.PowerManager;
|
---|
| 16 | +import android.os.PowerManager.WakeLock;
|
---|
| 17 | +import android.os.RemoteException;
|
---|
| 18 | +import android.os.SystemClock;
|
---|
| 19 | +import android.provider.Settings;
|
---|
| 20 | +import android.provider.Settings.SettingNotFoundException;
|
---|
| 21 | +import android.util.Log;
|
---|
| 22 | +import android.view.KeyEvent;
|
---|
| 23 | +import android.view.Window;
|
---|
| 24 | +import android.view.WindowManager;
|
---|
| 25 | +import android.widget.ProgressBar;
|
---|
| 26 | +import android.widget.TextView;
|
---|
| 27 | +import android.os.IPowerManager;
|
---|
| 28 | +import android.os.ServiceManager;
|
---|
| 29 | +
|
---|
| 30 | +import java.lang.reflect.Method;
|
---|
| 31 | +
|
---|
| 32 | +public class BrightnessTestActivity extends Activity {
|
---|
| 33 | + private static final String TAG = BrightnessTestActivity.class
|
---|
| 34 | + .getSimpleName();
|
---|
| 35 | + static final int MAXIMUM_BRIGHTNESS = 255;
|
---|
| 36 | + static final int MINIMUM_BRIGHTNESS = 2;
|
---|
| 37 | + static final int MSG_TEST_BRIGHTNESS = 0;
|
---|
| 38 | + private int mCurBrightness = -1;
|
---|
| 39 | + static final int ONE_STAGE = 2;
|
---|
| 40 | + MyHandler mHandler;
|
---|
| 41 | + TextView mText;
|
---|
| 42 | + TextView mTitle;
|
---|
| 43 | + TextView progressText;
|
---|
| 44 | + int mBrightness = 30;
|
---|
| 45 | + boolean increase = true;
|
---|
| 46 | + private static final int SEEK_BAR_RANGE = 10000;
|
---|
| 47 | + private static final int MAXIMUM_BACKLIGHT = android.os.PowerManager.BRIGHTNESS_ON;
|
---|
| 48 | + private float oldScreenBrightness;
|
---|
| 49 | + private int mScreenBrightnessDim = 20;
|
---|
| 50 | + private DisplayManager mDisplayManager = null;
|
---|
| 51 | +
|
---|
| 52 | + public BrightnessTestActivity() {
|
---|
| 53 | + mHandler = new MyHandler();
|
---|
| 54 | +
|
---|
| 55 | + }
|
---|
| 56 | +
|
---|
| 57 | + ProgressBar progressBar;
|
---|
| 58 | +
|
---|
| 59 | + protected void onCreate(Bundle savedInstanceState) {
|
---|
| 60 | +
|
---|
| 61 | + super.onCreate(savedInstanceState);
|
---|
| 62 | +
|
---|
| 63 | + setContentView(R.layout.brightnesstest);
|
---|
| 64 | +
|
---|
| 65 | + setTitle(getTitle() + "----("
|
---|
| 66 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS)
|
---|
| 67 | + + ")");
|
---|
| 68 | + // requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 69 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 70 | +
|
---|
| 71 | + progressBar = (ProgressBar) findViewById(R.id.brightnessBar);
|
---|
| 72 | + progressBar.setClickable(false);
|
---|
| 73 | + progressBar.setMax(MAXIMUM_BACKLIGHT);
|
---|
| 74 | + //mSeekBar.setMax(SEEK_BAR_RANGE);
|
---|
| 75 | + progressText = (TextView) findViewById(R.id.progressText);
|
---|
| 76 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 77 | + WindowManager.LayoutParams lp = getWindow().getAttributes();
|
---|
| 78 | + oldScreenBrightness = lp.screenBrightness;
|
---|
| 79 | + Log.d(TAG, oldScreenBrightness + " _____________________- onPause()");
|
---|
| 80 | + }
|
---|
| 81 | +
|
---|
| 82 | + protected void onResume() {
|
---|
| 83 | + super.onResume();
|
---|
| 84 | + this.mHandler.sendEmptyMessage(MSG_TEST_BRIGHTNESS);
|
---|
| 85 | + }
|
---|
| 86 | +
|
---|
| 87 | + protected void onPause() {
|
---|
| 88 | + super.onPause();
|
---|
| 89 | + Log.d(TAG, " _____________________- onPause()");
|
---|
| 90 | + this.mHandler.removeMessages(MSG_TEST_BRIGHTNESS);
|
---|
| 91 | + }
|
---|
| 92 | +
|
---|
| 93 | + @Override
|
---|
| 94 | + protected void onDestroy() {
|
---|
| 95 | + setBrightnessToSystem(140);
|
---|
| 96 | + Log.d(TAG, oldScreenBrightness + " _____________________- onDestroy()");
|
---|
| 97 | + super.onDestroy();
|
---|
| 98 | + }
|
---|
| 99 | +
|
---|
| 100 | + private void setBrightness(int paramInt) {
|
---|
| 101 | + WindowManager.LayoutParams lp = getWindow().getAttributes();
|
---|
| 102 | +
|
---|
| 103 | + /*float brightness = 0;
|
---|
| 104 | +
|
---|
| 105 | + int range = (MAXIMUM_BACKLIGHT - mScreenBrightnessDim);
|
---|
| 106 | + brightness = (paramInt*range)/SEEK_BAR_RANGE + mScreenBrightnessDim;
|
---|
| 107 | + mCurBrightness =(int) brightness;*/
|
---|
| 108 | + float brightness = (float) paramInt / MAXIMUM_BRIGHTNESS;
|
---|
| 109 | + lp.screenBrightness = (float) paramInt / MAXIMUM_BRIGHTNESS;
|
---|
| 110 | + System.out.println(mBrightness + "-------------------------------------------" + brightness);
|
---|
| 111 | + getWindow().setAttributes(lp);
|
---|
| 112 | + }
|
---|
| 113 | +
|
---|
| 114 | + class MyHandler extends Handler {
|
---|
| 115 | + MyHandler() {
|
---|
| 116 | + }
|
---|
| 117 | +
|
---|
| 118 | + public void handleMessage(Message msg) {
|
---|
| 119 | +
|
---|
| 120 | + super.handleMessage(msg);
|
---|
| 121 | + int delay = 25;
|
---|
| 122 | + if (msg.what == MSG_TEST_BRIGHTNESS) {
|
---|
| 123 | + if (increase) {
|
---|
| 124 | + mBrightness += ONE_STAGE;
|
---|
| 125 | + if (mBrightness >= MAXIMUM_BRIGHTNESS) {
|
---|
| 126 | + mBrightness = MAXIMUM_BRIGHTNESS;
|
---|
| 127 | + increase = false;
|
---|
| 128 | + delay = 500;
|
---|
| 129 | + }
|
---|
| 130 | + } else {
|
---|
| 131 | + mBrightness -= ONE_STAGE;
|
---|
| 132 | + if (mBrightness <= MINIMUM_BRIGHTNESS) {
|
---|
| 133 | + mBrightness = MINIMUM_BRIGHTNESS;
|
---|
| 134 | + increase = true;
|
---|
| 135 | + delay = 500;
|
---|
| 136 | + }
|
---|
| 137 | + }
|
---|
| 138 | + // System.out.println("==========================================="+mBrightness);
|
---|
| 139 | + setBrightnessToSystem(mBrightness);
|
---|
| 140 | + float brightness = mBrightness * 100;
|
---|
| 141 | +
|
---|
| 142 | + brightness = (brightness - mScreenBrightnessDim)
|
---|
| 143 | + / (MAXIMUM_BACKLIGHT - mScreenBrightnessDim);
|
---|
| 144 | +
|
---|
| 145 | + brightness = (int) (brightness * SEEK_BAR_RANGE);
|
---|
| 146 | + //System.out.println("------------SEEK_BAR_RANGE-------------------"+mBrightness);
|
---|
| 147 | + progressBar.setProgress(mBrightness);
|
---|
| 148 | + progressText.setText(mBrightness + "/" + MAXIMUM_BRIGHTNESS);
|
---|
| 149 | + //setBrightness(mBrightness);
|
---|
| 150 | +
|
---|
| 151 | + sendEmptyMessageDelayed(MSG_TEST_BRIGHTNESS, delay);
|
---|
| 152 | +
|
---|
| 153 | + }
|
---|
| 154 | + }
|
---|
| 155 | +
|
---|
| 156 | + }
|
---|
| 157 | +
|
---|
| 158 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 159 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 160 | + return false;
|
---|
| 161 | + }
|
---|
| 162 | + return super.dispatchKeyEvent(event);
|
---|
| 163 | + }
|
---|
| 164 | +
|
---|
| 165 | + private void setBrightnessToSystem(int brightness) {
|
---|
| 166 | + try {
|
---|
| 167 | + if (null == mDisplayManager) {
|
---|
| 168 | + mDisplayManager = getSystemService(DisplayManager.class);
|
---|
| 169 | + }
|
---|
| 170 | + if (Build.VERSION.SDK_INT >= ConfigUtil.ANDROID_SDK_VERSION_S) {
|
---|
| 171 | + float fBrightness = 1.0f * brightness / MAXIMUM_BRIGHTNESS;
|
---|
| 172 | + Method m = DisplayManager.class.getMethod("setTemporaryBrightness", int.class, float.class);
|
---|
| 173 | + Method m2 = Context.class.getMethod("getDisplayId");
|
---|
| 174 | + int displayId = Integer.parseInt(m2.invoke(this).toString());
|
---|
| 175 | + m.invoke(mDisplayManager, displayId, fBrightness);
|
---|
| 176 | + } else if (Build.VERSION.SDK_INT == ConfigUtil.ANDROID_SDK_VERSION_R) {//Build.VERSION_CODES.R
|
---|
| 177 | + float fBrightness = 1.0f * brightness / MAXIMUM_BRIGHTNESS;
|
---|
| 178 | + Method m = DisplayManager.class.getMethod("setTemporaryBrightness", float.class);
|
---|
| 179 | + m.invoke(mDisplayManager, fBrightness);
|
---|
| 180 | + } else if (Build.VERSION.SDK_INT >= ConfigUtil.ANDROID_SDK_VERSION_P) {
|
---|
| 181 | + Method m = DisplayManager.class.getMethod("setTemporaryBrightness", int.class);
|
---|
| 182 | + m.invoke(mDisplayManager, brightness);
|
---|
| 183 | + } else {
|
---|
| 184 | + IPowerManager power = IPowerManager.Stub.asInterface(
|
---|
| 185 | + ServiceManager.getService(Context.POWER_SERVICE));
|
---|
| 186 | + if (null != power) {
|
---|
| 187 | + Method m = IPowerManager.class.getMethod("setTemporaryScreenBrightnessSettingOverride", int.class);
|
---|
| 188 | + m.invoke(power, brightness);
|
---|
| 189 | + }
|
---|
| 190 | + }
|
---|
| 191 | + } catch (Exception doe) {
|
---|
| 192 | + doe.printStackTrace();
|
---|
| 193 | + }
|
---|
| 194 | + }
|
---|
| 195 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | + |
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN; |
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; |
---|
| 5 | + |
---|
| 6 | +import com.DeviceTest.helper.ConfigUtil; |
---|
| 7 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 8 | + |
---|
| 9 | +import java.io.FileOutputStream; |
---|
| 10 | +import android.content.Intent; |
---|
| 11 | + |
---|
| 12 | +import android.app.Activity; |
---|
| 13 | +import android.content.Context; |
---|
| 14 | +import android.hardware.Camera; |
---|
| 15 | +import android.os.Bundle; |
---|
| 16 | +import android.os.Environment; |
---|
| 17 | +import android.util.Log; |
---|
| 18 | +import android.view.MotionEvent; |
---|
| 19 | +import android.view.SurfaceHolder; |
---|
| 20 | +import android.view.SurfaceView; |
---|
| 21 | +import android.view.Window; |
---|
| 22 | +import android.view.WindowManager; |
---|
| 23 | +import android.view.KeyEvent; |
---|
| 24 | +import android.widget.Button; |
---|
| 25 | +import android.widget.TextView; |
---|
| 26 | +import android.graphics.Bitmap; |
---|
| 27 | +import android.graphics.BitmapFactory; |
---|
| 28 | +import android.view.View; |
---|
| 29 | +import android.os.Handler; |
---|
| 30 | +import android.os.Message; |
---|
| 31 | +import android.view.Surface; |
---|
| 32 | +import android.widget.ImageView; |
---|
| 33 | +import android.content.pm.PackageManager; |
---|
| 34 | +import android.content.pm.PackageInfo; |
---|
| 35 | +import android.content.pm.PackageManager.NameNotFoundException; |
---|
| 36 | +import android.app.ActivityManager; |
---|
| 37 | +import java.lang.reflect.Method; |
---|
| 38 | + |
---|
| 39 | + |
---|
| 40 | +public class CameraBackTestActivity extends Activity{ |
---|
| 41 | + |
---|
| 42 | + private static final String TAG="CameraWithFlashTestActivity"; |
---|
| 43 | + |
---|
| 44 | + private static final int MSG_TAKE_OVER = 1; |
---|
| 45 | + private static final int MSG_TAKE_ERROR = 2; |
---|
| 46 | + private TextView tv_prompt; |
---|
| 47 | + private ImageView imageView; |
---|
| 48 | + private boolean isTakeStat=false; //FOR ESC key |
---|
| 49 | + private boolean isCanTake=true; //if in taking process,click preview screen should not call take photo again! |
---|
| 50 | +// private int CameraCount=0; |
---|
| 51 | +// private int testCount=0; |
---|
| 52 | + private Bitmap bitmap; |
---|
| 53 | + private int testCameraID=0; |
---|
| 54 | + private boolean mCameraPrepared; |
---|
| 55 | + public void onCreate(Bundle bundle) { |
---|
| 56 | + super.onCreate(bundle); |
---|
| 57 | + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); |
---|
| 58 | + getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); |
---|
| 59 | + requestWindowFeature(Window.FEATURE_NO_TITLE); |
---|
| 60 | + // setContentView(new CameraView(this)); |
---|
| 61 | + setContentView(R.layout.camerawithflashtest); |
---|
| 62 | + tv_prompt=(TextView)findViewById(R.id.CameratextMsg); |
---|
| 63 | + // tv_prompt.setText("请点击屏幕打开后置摄像头\n然后点击预览屏幕拍照"); |
---|
| 64 | + tv_prompt.setText(getString(R.string.CameraFlashtextBack)); |
---|
| 65 | + ControlButtonUtil.initControlButtonView(this); |
---|
| 66 | +// CameraCount=getCameraCount(); |
---|
| 67 | + if(isAppInstalled(this, "com.example.cam")) { |
---|
| 68 | + Intent intent = getPackageManager().getLaunchIntentForPackage("com.example.cam"); |
---|
| 69 | + if( intent != null ) { |
---|
| 70 | + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); |
---|
| 71 | + startActivity(intent); |
---|
| 72 | + } |
---|
| 73 | + new Handler().postDelayed(new Runnable() { |
---|
| 74 | + @Override |
---|
| 75 | + public void run() { |
---|
| 76 | + stopAppByForce(CameraBackTestActivity.this,"com.example.cam"); |
---|
| 77 | + } |
---|
| 78 | + }, 5000); |
---|
| 79 | + } |
---|
| 80 | + } |
---|
| 81 | + private void stopAppByForce(Context context , String packageName) { |
---|
| 82 | + ActivityManager mActivityManager = (ActivityManager) |
---|
| 83 | + context.getSystemService(Context.ACTIVITY_SERVICE); |
---|
| 84 | + Method method = null; |
---|
| 85 | + try { |
---|
| 86 | + method = Class.forName("android.app.ActivityManager").getMethod("forceStopPackage", String.class); |
---|
| 87 | + method.invoke(mActivityManager, packageName); |
---|
| 88 | + } catch (Exception e) { |
---|
| 89 | + e.printStackTrace(); |
---|
| 90 | + } |
---|
| 91 | + } |
---|
| 92 | + protected void onResume() { |
---|
| 93 | + super.onResume(); |
---|
| 94 | +// Log.d(TAG,"onResume... CameraCount="+CameraCount); |
---|
| 95 | + //findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE); |
---|
| 96 | + // findViewById(R.id.btn_Pass).setEnabled(false); |
---|
| 97 | + isTakeStat=false; |
---|
| 98 | + isCanTake=true; |
---|
| 99 | +// testCount=0; |
---|
| 100 | + |
---|
| 101 | + } |
---|
| 102 | + |
---|
| 103 | + public boolean isAppInstalled(Context context, String packageName) { |
---|
| 104 | + PackageManager packageManager = context.getPackageManager(); |
---|
| 105 | + try { |
---|
| 106 | + packageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); |
---|
| 107 | + android.util.Log.d("RRRRRRRR", "com.example.cam can use"); |
---|
| 108 | + return true; |
---|
| 109 | + } catch (PackageManager.NameNotFoundException e) { |
---|
| 110 | + return false; |
---|
| 111 | + } |
---|
| 112 | + } |
---|
| 113 | + |
---|
| 114 | + public boolean onTouchEvent(MotionEvent paramMotionEvent) { |
---|
| 115 | + if(isCanTake){ |
---|
| 116 | + if (paramMotionEvent.getAction() == MotionEvent.ACTION_DOWN) { |
---|
| 117 | + |
---|
| 118 | + if(isAppInstalled(this, "com.example.cam")) { |
---|
| 119 | + android.util.Log.d("RRRRRRRR", "com.example.cam"); |
---|
| 120 | + Intent intent = getPackageManager().getLaunchIntentForPackage("com.example.cam"); |
---|
| 121 | + if( intent != null ) { |
---|
| 122 | + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); |
---|
| 123 | + startActivity(intent); |
---|
| 124 | + return true; |
---|
| 125 | + } |
---|
| 126 | + Log.d("RRRRR", "CameraExample Not Available"); |
---|
| 127 | + } |
---|
| 128 | + |
---|
| 129 | + setContentView(new CameraView(this,testCameraID)); |
---|
| 130 | + testCameraID=0; |
---|
| 131 | + isTakeStat=true; |
---|
| 132 | + } |
---|
| 133 | + } |
---|
| 134 | + return super.onTouchEvent(paramMotionEvent); |
---|
| 135 | + } |
---|
| 136 | + |
---|
| 137 | + public boolean dispatchKeyEvent(KeyEvent event) { |
---|
| 138 | + //open camera maybe error,allow user back. |
---|
| 139 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
---|
| 140 | + if(isTakeStat) |
---|
| 141 | + { |
---|
| 142 | + myHandler.sendEmptyMessage(MSG_TAKE_OVER); |
---|
| 143 | + } |
---|
| 144 | + else |
---|
| 145 | + return false; |
---|
| 146 | + } |
---|
| 147 | + return super.dispatchKeyEvent(event); |
---|
| 148 | + } |
---|
| 149 | + |
---|
| 150 | +// private int getCameraCount() |
---|
| 151 | +// { |
---|
| 152 | +// int cameraCount = 0; |
---|
| 153 | +// Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); |
---|
| 154 | +// cameraCount = Camera.getNumberOfCameras(); // get cameras number c |
---|
| 155 | +// return cameraCount; |
---|
| 156 | +// } |
---|
| 157 | + |
---|
| 158 | + Handler myHandler = new Handler() { |
---|
| 159 | + public void handleMessage(Message msg) { |
---|
| 160 | + switch (msg.what) { |
---|
| 161 | + case MSG_TAKE_OVER: |
---|
| 162 | + setContentView(R.layout.cameratestv); |
---|
| 163 | + ControlButtonUtil.initControlButtonView(CameraBackTestActivity.this); |
---|
| 164 | + imageView=(ImageView) findViewById(R.id.imgV); |
---|
| 165 | + imageView.setImageBitmap(bitmap); |
---|
| 166 | + //Log.i("lzx", "-------------bitmap----"+bitmap.toString()); |
---|
| 167 | + findViewById(R.id.btn_Pass).setVisibility(View.VISIBLE); |
---|
| 168 | + // findViewById(R.id.btn_Pass).setEnabled(true); |
---|
| 169 | + break; |
---|
| 170 | + case MSG_TAKE_ERROR: |
---|
| 171 | + isTakeStat=false; |
---|
| 172 | + isCanTake=true; |
---|
| 173 | +// testCount=0; |
---|
| 174 | + setContentView(R.layout.camerawithflashtest); |
---|
| 175 | + |
---|
| 176 | + ControlButtonUtil.initControlButtonView(CameraBackTestActivity.this); |
---|
| 177 | + //findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE); |
---|
| 178 | + if (!mCameraPrepared) { |
---|
| 179 | + findViewById(R.id.btn_Fail).performClick(); |
---|
| 180 | + } |
---|
| 181 | + //findViewById(R.id.btn_Pass).setEnabled(false); |
---|
| 182 | + break; |
---|
| 183 | + |
---|
| 184 | + } |
---|
| 185 | + super.handleMessage(msg); |
---|
| 186 | + } |
---|
| 187 | + }; |
---|
| 188 | + |
---|
| 189 | + public class CameraView extends SurfaceView implements SurfaceHolder.Callback, Camera.PictureCallback { |
---|
| 190 | + private SurfaceHolder holder; |
---|
| 191 | + private Camera camera; |
---|
| 192 | + private boolean af; |
---|
| 193 | + private int cameraId; |
---|
| 194 | + |
---|
| 195 | + public CameraView(Context context) { |
---|
| 196 | + super(context); |
---|
| 197 | + Log.d(TAG,"constructed..."); |
---|
| 198 | + holder = getHolder(); |
---|
| 199 | + holder.addCallback(this); |
---|
| 200 | + |
---|
| 201 | + //holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); |
---|
| 202 | + } |
---|
| 203 | + |
---|
| 204 | + public CameraView(Context context,int camera_Id) { |
---|
| 205 | + super(context); |
---|
| 206 | + Log.d(TAG,"constructed... 2"); |
---|
| 207 | + holder = getHolder(); |
---|
| 208 | + holder.addCallback(this); |
---|
| 209 | + cameraId=camera_Id; |
---|
| 210 | + |
---|
| 211 | + //holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);// |
---|
| 212 | + } |
---|
| 213 | + |
---|
| 214 | + public void surfaceCreated(SurfaceHolder holder) {// |
---|
| 215 | + try { |
---|
| 216 | + |
---|
| 217 | + camera = Camera.open(cameraId); |
---|
| 218 | + Log.d(TAG,"surfaceCreated:camera!=null is:"+(camera!=null)+",cameraId="+cameraId); |
---|
| 219 | + camera.setPreviewDisplay(holder); |
---|
| 220 | +// if (cameraId == 0 && !ConfigUtil.isSpecialEvb()) { |
---|
| 221 | +// Camera.Parameters parameters = camera.getParameters(); |
---|
| 222 | +// //parameters.setPreviewSize(width, height); |
---|
| 223 | +// parameters.setFlashMode(Camera.Parameters.FLASH_MODE_ON); |
---|
| 224 | +// camera.setParameters(parameters); |
---|
| 225 | +// } |
---|
| 226 | + setRightCameraOrientation(cameraId, camera); |
---|
| 227 | + camera.startPreview(); |
---|
| 228 | + mCameraPrepared = true; |
---|
| 229 | + } catch (Exception e) { |
---|
| 230 | + Log.w(TAG,"surfaceCreated e:"+e.getMessage()); |
---|
| 231 | + myHandler.sendEmptyMessage(MSG_TAKE_ERROR); |
---|
| 232 | + } |
---|
| 233 | + } |
---|
| 234 | + |
---|
| 235 | + @Override |
---|
| 236 | + public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { |
---|
| 237 | + |
---|
| 238 | + } |
---|
| 239 | + |
---|
| 240 | + public void surfaceDestroyed(SurfaceHolder holder) { |
---|
| 241 | + if(null != camera) |
---|
| 242 | + { |
---|
| 243 | + camera.setPreviewCallback(null); |
---|
| 244 | + camera.stopPreview(); |
---|
| 245 | + camera.release(); |
---|
| 246 | + camera = null; |
---|
| 247 | + } |
---|
| 248 | + Log.d(TAG,"surfaceDestroyed"); |
---|
| 249 | + } |
---|
| 250 | + |
---|
| 251 | + @Override |
---|
| 252 | + public boolean onTouchEvent(MotionEvent event) { |
---|
| 253 | + if (!mCameraPrepared) { |
---|
| 254 | + Log.d(TAG,"!mCameraPrepared not do onTouchEvent"); |
---|
| 255 | + return true; |
---|
| 256 | + } |
---|
| 257 | + if (event.getAction() == MotionEvent.ACTION_DOWN) { |
---|
| 258 | + Log.d(TAG,"MotionEvent.ACTION_DOWN"); |
---|
| 259 | + if(null != camera) |
---|
| 260 | + { |
---|
| 261 | + camera.autoFocus(null); |
---|
| 262 | + af = true; |
---|
| 263 | + Log.i("lzx", "-------------------------touch event---------------------"); |
---|
| 264 | + } |
---|
| 265 | + else |
---|
| 266 | + { |
---|
| 267 | + |
---|
| 268 | + myHandler.sendEmptyMessage(MSG_TAKE_ERROR); |
---|
| 269 | + } |
---|
| 270 | + } |
---|
| 271 | + if (event.getAction() == MotionEvent.ACTION_UP){ |
---|
| 272 | + Log.d(TAG,"event.getAction() == MotionEvent.ACTION_UP"); |
---|
| 273 | + if( af == true && isCanTake) { |
---|
| 274 | + camera.takePicture(null, null, this); |
---|
| 275 | + isCanTake=false; |
---|
| 276 | + af = false; |
---|
| 277 | + |
---|
| 278 | + } |
---|
| 279 | + } |
---|
| 280 | + return true; |
---|
| 281 | + } |
---|
| 282 | + |
---|
| 283 | + public void onPictureTaken(byte[] data, Camera camera) { |
---|
| 284 | + try { |
---|
| 285 | + isTakeStat=false; |
---|
| 286 | + isCanTake=false; |
---|
| 287 | + bitmap= BitmapFactory.decodeByteArray(data, 0, data.length); |
---|
| 288 | + } catch (Exception e) { |
---|
| 289 | + } |
---|
| 290 | + // camera.startPreview(); |
---|
| 291 | + |
---|
| 292 | + myHandler.sendEmptyMessage(MSG_TAKE_OVER); |
---|
| 293 | + Log.i("lzx", "-------------picture-bitmap---"+bitmap.toString()); |
---|
| 294 | + } |
---|
| 295 | + |
---|
| 296 | + private void data2file(byte[] w, String fileName) throws Exception { |
---|
| 297 | + FileOutputStream out = null; |
---|
| 298 | + try { |
---|
| 299 | + out = new FileOutputStream(fileName); |
---|
| 300 | + out.write(w); |
---|
| 301 | + out.close(); |
---|
| 302 | + } catch (Exception e) { |
---|
| 303 | + if (out != null) |
---|
| 304 | + out.close(); |
---|
| 305 | + throw e; |
---|
| 306 | + } |
---|
| 307 | + } |
---|
| 308 | + |
---|
| 309 | + } |
---|
| 310 | + private void setRightCameraOrientation(int cameraId, Camera mCamera) { |
---|
| 311 | + Camera.CameraInfo info = new Camera.CameraInfo(); |
---|
| 312 | + Camera.getCameraInfo(cameraId, info); |
---|
| 313 | + int rotation = this.getWindowManager().getDefaultDisplay() |
---|
| 314 | + .getRotation(); |
---|
| 315 | + int degrees = 0; |
---|
| 316 | + switch (rotation) { |
---|
| 317 | + case Surface.ROTATION_0: |
---|
| 318 | + degrees = 0; |
---|
| 319 | + break; |
---|
| 320 | + case Surface.ROTATION_90: |
---|
| 321 | + degrees = 90; |
---|
| 322 | + break; |
---|
| 323 | + case Surface.ROTATION_180: |
---|
| 324 | + degrees = 180; |
---|
| 325 | + break; |
---|
| 326 | + case Surface.ROTATION_270: |
---|
| 327 | + degrees = 270; |
---|
| 328 | + break; |
---|
| 329 | + } |
---|
| 330 | + int result; |
---|
| 331 | + if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { |
---|
| 332 | + result = (info.orientation + degrees) % 360; |
---|
| 333 | + result = (360 - result) % 360; // compensate the mirror |
---|
| 334 | + } else { // back-facing |
---|
| 335 | + result = (info.orientation - degrees + 360) % 360; |
---|
| 336 | + } |
---|
| 337 | + mCamera.setDisplayOrientation(result); |
---|
| 338 | + } |
---|
| 339 | + } |
---|
| 340 | + |
---|
| 341 | + |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 7 | +
|
---|
| 8 | +import android.app.Activity;
|
---|
| 9 | +import android.content.Intent;
|
---|
| 10 | +import android.hardware.Camera;
|
---|
| 11 | +import android.os.Bundle;
|
---|
| 12 | +
|
---|
| 13 | +import android.view.KeyEvent;
|
---|
| 14 | +import android.view.MotionEvent;
|
---|
| 15 | +import android.view.View;
|
---|
| 16 | +import android.view.Window;
|
---|
| 17 | +import android.widget.TextView;
|
---|
| 18 | +import android.util.Log;
|
---|
| 19 | +
|
---|
| 20 | +public class CameraTestActivity extends Activity {
|
---|
| 21 | + private static final int mRequestCode = 1000;
|
---|
| 22 | + private boolean isCanUse = true;
|
---|
| 23 | + public void onCreate(Bundle paramBundle) {
|
---|
| 24 | + super.onCreate(paramBundle);
|
---|
| 25 | +
|
---|
| 26 | + setTitle(getTitle() + "----("
|
---|
| 27 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")");
|
---|
| 28 | + //requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 29 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 30 | +
|
---|
| 31 | + setContentView(R.layout.cameratest);
|
---|
| 32 | +
|
---|
| 33 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 34 | + isCameraCanUse();
|
---|
| 35 | + if(!isCanUse)
|
---|
| 36 | + findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 37 | + }
|
---|
| 38 | + public boolean isCameraCanUse() {
|
---|
| 39 | + Camera mCamera = null;
|
---|
| 40 | + try {
|
---|
| 41 | + mCamera = Camera.open();
|
---|
| 42 | + if(null == mCamera) isCanUse = false;
|
---|
| 43 | + } catch (Exception e) {
|
---|
| 44 | + isCanUse = false;
|
---|
| 45 | + }
|
---|
| 46 | +
|
---|
| 47 | + if (mCamera != null && isCanUse) {
|
---|
| 48 | + mCamera.release();
|
---|
| 49 | + mCamera = null;
|
---|
| 50 | + }
|
---|
| 51 | + return isCanUse;
|
---|
| 52 | + }
|
---|
| 53 | +
|
---|
| 54 | +
|
---|
| 55 | + public boolean onTouchEvent(MotionEvent paramMotionEvent) {
|
---|
| 56 | + if (paramMotionEvent.getAction() == MotionEvent.ACTION_DOWN && isCanUse) {
|
---|
| 57 | + Intent localIntent = new Intent(
|
---|
| 58 | + "android.media.action.IMAGE_CAPTURE");
|
---|
| 59 | + startActivityIfNeeded(localIntent, 10);
|
---|
| 60 | + }
|
---|
| 61 | + return super.onTouchEvent(paramMotionEvent);
|
---|
| 62 | + }
|
---|
| 63 | +
|
---|
| 64 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 65 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 66 | + return false;
|
---|
| 67 | + }
|
---|
| 68 | + return super.dispatchKeyEvent(event);
|
---|
| 69 | + }
|
---|
| 70 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | + |
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN; |
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; |
---|
| 5 | + |
---|
| 6 | +import java.io.IOException; |
---|
| 7 | + |
---|
| 8 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 9 | + |
---|
| 10 | +import jp.co.ntt.east.hardware.IrRemoteController; |
---|
| 11 | +import jp.co.ntt.east.hardware.IrRemoteController.Data; |
---|
| 12 | +import jp.co.toshiba.newtion.cir.RemoteControl; |
---|
| 13 | + |
---|
| 14 | +import android.app.Activity; |
---|
| 15 | +import android.os.Bundle; |
---|
| 16 | +import android.util.Log; |
---|
| 17 | +import android.view.KeyEvent; |
---|
| 18 | +import android.view.View; |
---|
| 19 | +import android.view.View.OnClickListener; |
---|
| 20 | +import android.widget.Button; |
---|
| 21 | +import android.widget.TextView; |
---|
| 22 | + |
---|
| 23 | +public class CirTestActivity extends Activity implements OnClickListener { |
---|
| 24 | + /** Called when the activity is first created. */ |
---|
| 25 | + public Button btn_send; |
---|
| 26 | + // public Button btn_stop; |
---|
| 27 | + String TAG = "CirTest"; |
---|
| 28 | + int ret; |
---|
| 29 | + // IrRemoteController ir_ctl = null; |
---|
| 30 | + // IrRemoteController.Data[] data; |
---|
| 31 | + |
---|
| 32 | + private TextView resultView; |
---|
| 33 | + |
---|
| 34 | + public void onCreate(Bundle savedInstanceState) { |
---|
| 35 | + super.onCreate(savedInstanceState); |
---|
| 36 | + setContentView(R.layout.cirtest); |
---|
| 37 | + |
---|
| 38 | + setTitle(getTitle() + "----(" |
---|
| 39 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")"); |
---|
| 40 | + // requestWindowFeature(Window.FEATURE_NO_TITLE); |
---|
| 41 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON); |
---|
| 42 | + |
---|
| 43 | + this.btn_send = (Button) findViewById(R.id.send); |
---|
| 44 | + // this.btn_stop = (Button) findViewById(R.id.stop); |
---|
| 45 | + this.btn_send.setOnClickListener(this); |
---|
| 46 | + // this.btn_stop.setOnClickListener(this); |
---|
| 47 | + |
---|
| 48 | + // ir_ctl = IrRemoteController.getInstance(); |
---|
| 49 | + // Log.i("Cir", "init"); |
---|
| 50 | + // data = new IrRemoteController.Data[2]; |
---|
| 51 | + // |
---|
| 52 | + // data[0] = new IrRemoteController.Data(); |
---|
| 53 | + // |
---|
| 54 | + // data[0].setCarrier(8, 18); |
---|
| 55 | + // data[0].setDuration(1080); |
---|
| 56 | + // data[0].setParameter(9000, 4500, 560); |
---|
| 57 | + // data[0].setPulse(0, 560, 560, 0, 1690, 560); |
---|
| 58 | + // |
---|
| 59 | + // data[1] = new IrRemoteController.Data(); |
---|
| 60 | + // data[1].setCarrier(8, 18); |
---|
| 61 | + // data[1].setDuration(1080); |
---|
| 62 | + // data[1].setParameter(9000, 2250, 560); |
---|
| 63 | + // data[1].setPulse(0, 560, 560, 0, 1690, 560); |
---|
| 64 | + |
---|
| 65 | + ControlButtonUtil.initControlButtonView(this); |
---|
| 66 | + resultView = (TextView) findViewById(R.id.CirResult); |
---|
| 67 | + ((TextView) findViewById(R.id.CirSendData)) |
---|
| 68 | + .setText("Send command:COMMAND_POWER(0x12)"); |
---|
| 69 | + } |
---|
| 70 | + |
---|
| 71 | + public void onClick(View v) { |
---|
| 72 | + // TODO Auto-generated method stub |
---|
| 73 | + // if (v.getId() == R.id.send) { |
---|
| 74 | + Log.d(TAG, "cir send"); |
---|
| 75 | + resultView.setText(onCirSend() ? "Pass!" : "Failed!"); |
---|
| 76 | + // } else if (v.getId() == R.id.stop) { |
---|
| 77 | + // Log.d(TAG, "cir stop"); |
---|
| 78 | + // resultView.setText(onCirStop() ? "Pass!" : "Failed!"); |
---|
| 79 | + // } |
---|
| 80 | + // v.setEnabled(false); |
---|
| 81 | + } |
---|
| 82 | + |
---|
| 83 | + public boolean onCirSend() { |
---|
| 84 | + return RemoteControl.sendCommand(RemoteControl.COMMAND_POWER); |
---|
| 85 | + } |
---|
| 86 | + |
---|
| 87 | + // |
---|
| 88 | + // public boolean onCirStop() { |
---|
| 89 | + // |
---|
| 90 | + // try { |
---|
| 91 | + // ir_ctl.stop(); |
---|
| 92 | + // return true; |
---|
| 93 | + // } catch (IOException e) { |
---|
| 94 | + // // TODO Auto-generated catch block |
---|
| 95 | + // e.printStackTrace(); |
---|
| 96 | + // Log.e(TAG, "stop err!"); |
---|
| 97 | + // return false; |
---|
| 98 | + // } |
---|
| 99 | + // |
---|
| 100 | + // } |
---|
| 101 | + |
---|
| 102 | + protected void onDestroy() { |
---|
| 103 | + // TODO Auto-generated method stub |
---|
| 104 | + super.onDestroy(); |
---|
| 105 | + |
---|
| 106 | + } |
---|
| 107 | + |
---|
| 108 | + public boolean dispatchKeyEvent(KeyEvent event) { |
---|
| 109 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
---|
| 110 | + return false; |
---|
| 111 | + } |
---|
| 112 | + return super.dispatchKeyEvent(event); |
---|
| 113 | + } |
---|
| 114 | +} |
---|
.. | .. |
---|
| 1 | +
|
---|
| 2 | +package com.DeviceTest;
|
---|
| 3 | +
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 5 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 6 | +
|
---|
| 7 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 8 | +import com.DeviceTest.view.DrawClock;
|
---|
| 9 | +
|
---|
| 10 | +import android.app.Activity;
|
---|
| 11 | +import android.content.Intent;
|
---|
| 12 | +import android.os.Bundle;
|
---|
| 13 | +import android.os.Handler;
|
---|
| 14 | +import android.os.Message;
|
---|
| 15 | +
|
---|
| 16 | +import android.view.KeyEvent;
|
---|
| 17 | +import android.view.MotionEvent;
|
---|
| 18 | +import android.view.View;
|
---|
| 19 | +import android.view.Window;
|
---|
| 20 | +import android.widget.LinearLayout;
|
---|
| 21 | +import android.widget.TextView;
|
---|
| 22 | +import android.util.Log;
|
---|
| 23 | +
|
---|
| 24 | +public class ClockTestActivity extends Activity {
|
---|
| 25 | + protected static final int MSG_CLOCK = 0x1234;
|
---|
| 26 | +
|
---|
| 27 | + private LinearLayout clock_pannel;
|
---|
| 28 | +
|
---|
| 29 | + private DrawClock clock;
|
---|
| 30 | +
|
---|
| 31 | + public Handler mHandler;
|
---|
| 32 | +
|
---|
| 33 | + private Thread mClockThread;
|
---|
| 34 | +
|
---|
| 35 | + public void onCreate(Bundle paramBundle) {
|
---|
| 36 | + super.onCreate(paramBundle);
|
---|
| 37 | + setTitle(getTitle() + "----("
|
---|
| 38 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")");
|
---|
| 39 | + // requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 40 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 41 | +
|
---|
| 42 | + setContentView(R.layout.myclocktest);
|
---|
| 43 | +
|
---|
| 44 | + clock_pannel = (LinearLayout) findViewById(R.id.clock1);
|
---|
| 45 | +
|
---|
| 46 | + clock = new DrawClock(this);
|
---|
| 47 | +
|
---|
| 48 | + clock_pannel.addView(clock);
|
---|
| 49 | +
|
---|
| 50 | + mHandler = new Handler()
|
---|
| 51 | + {
|
---|
| 52 | +
|
---|
| 53 | + public void handleMessage(Message msg)
|
---|
| 54 | +
|
---|
| 55 | + {
|
---|
| 56 | +
|
---|
| 57 | + switch (msg.what)
|
---|
| 58 | +
|
---|
| 59 | + {
|
---|
| 60 | +
|
---|
| 61 | + case ClockTestActivity.MSG_CLOCK:
|
---|
| 62 | +
|
---|
| 63 | + {
|
---|
| 64 | +
|
---|
| 65 | + clock_pannel.removeView(clock);
|
---|
| 66 | +
|
---|
| 67 | + clock = new DrawClock(ClockTestActivity.this);
|
---|
| 68 | +
|
---|
| 69 | + clock_pannel.addView(clock);
|
---|
| 70 | +
|
---|
| 71 | + }
|
---|
| 72 | +
|
---|
| 73 | + break;
|
---|
| 74 | +
|
---|
| 75 | + }
|
---|
| 76 | +
|
---|
| 77 | + super.handleMessage(msg);
|
---|
| 78 | +
|
---|
| 79 | + }
|
---|
| 80 | +
|
---|
| 81 | + };
|
---|
| 82 | +
|
---|
| 83 | + mClockThread = new LooperThread();
|
---|
| 84 | +
|
---|
| 85 | + mClockThread.start();
|
---|
| 86 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 87 | + }
|
---|
| 88 | +
|
---|
| 89 | + class LooperThread extends Thread
|
---|
| 90 | +
|
---|
| 91 | + {
|
---|
| 92 | +
|
---|
| 93 | + public void run()
|
---|
| 94 | +
|
---|
| 95 | + {
|
---|
| 96 | +
|
---|
| 97 | + super.run();
|
---|
| 98 | +
|
---|
| 99 | + try
|
---|
| 100 | +
|
---|
| 101 | + {
|
---|
| 102 | +
|
---|
| 103 | + do
|
---|
| 104 | +
|
---|
| 105 | + {
|
---|
| 106 | +
|
---|
| 107 | + Thread.sleep(1000);
|
---|
| 108 | +
|
---|
| 109 | + Message m = new Message();
|
---|
| 110 | +
|
---|
| 111 | + m.what = ClockTestActivity.MSG_CLOCK;
|
---|
| 112 | +
|
---|
| 113 | + ClockTestActivity.this.mHandler.sendMessage(m);
|
---|
| 114 | +
|
---|
| 115 | + } while (ClockTestActivity.LooperThread.interrupted() == false);
|
---|
| 116 | +
|
---|
| 117 | + }
|
---|
| 118 | +
|
---|
| 119 | + catch (Exception e)
|
---|
| 120 | +
|
---|
| 121 | + {
|
---|
| 122 | +
|
---|
| 123 | + e.printStackTrace();
|
---|
| 124 | +
|
---|
| 125 | + }
|
---|
| 126 | +
|
---|
| 127 | + }
|
---|
| 128 | +
|
---|
| 129 | + }
|
---|
| 130 | +
|
---|
| 131 | +
|
---|
| 132 | +
|
---|
| 133 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 134 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 135 | + return false;
|
---|
| 136 | + }
|
---|
| 137 | + return super.dispatchKeyEvent(event);
|
---|
| 138 | + }
|
---|
| 139 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 7 | +import com.DeviceTest.helper.SystemUtil;
|
---|
| 8 | +import com.DeviceTest.view.CompassView;
|
---|
| 9 | +
|
---|
| 10 | +import android.app.Activity;
|
---|
| 11 | +import android.content.Context;
|
---|
| 12 | +import android.hardware.SensorListener;
|
---|
| 13 | +import android.hardware.SensorManager;
|
---|
| 14 | +import android.os.Bundle;
|
---|
| 15 | +import android.os.Handler;
|
---|
| 16 | +import android.util.Log;
|
---|
| 17 | +import android.view.KeyEvent;
|
---|
| 18 | +import android.view.View;
|
---|
| 19 | +import android.widget.Button;
|
---|
| 20 | +import android.widget.TextView;
|
---|
| 21 | +
|
---|
| 22 | +public class CompassTestActivity extends Activity {
|
---|
| 23 | +
|
---|
| 24 | + private CompassView compassView;
|
---|
| 25 | + private float firstYaw = 0;
|
---|
| 26 | + private int count;
|
---|
| 27 | + private float lastYaw = 0;
|
---|
| 28 | + private float STABLE_VALUE = 0.5F;
|
---|
| 29 | + private int STABLE_COUNT = 10;
|
---|
| 30 | + TextView compassText;
|
---|
| 31 | + String accuracyStr = "";
|
---|
| 32 | +
|
---|
| 33 | + int[] yawRange = new int[] { 285 - 30, 285 + 30 };
|
---|
| 34 | + boolean start = false;
|
---|
| 35 | +
|
---|
| 36 | + private static enum STATE {
|
---|
| 37 | + WAIT_FOR_FIRST_STABLE, WAIT_FOR_ROTATE, WAIT_FOR_SECOND_STABLE, UNDEF
|
---|
| 38 | + };
|
---|
| 39 | +
|
---|
| 40 | + Button startButton;
|
---|
| 41 | + STATE state;
|
---|
| 42 | + boolean stop = false;
|
---|
| 43 | + Handler mHandler = new Handler();
|
---|
| 44 | + Runnable mFailedRunnable = new Runnable() {
|
---|
| 45 | +
|
---|
| 46 | + public void run() {
|
---|
| 47 | + if (stop) {
|
---|
| 48 | + return;
|
---|
| 49 | + }
|
---|
| 50 | + mHandler.removeCallbacks(mFailedRunnable);
|
---|
| 51 | + findViewById(R.id.btn_Fail).performClick();
|
---|
| 52 | + }
|
---|
| 53 | + };
|
---|
| 54 | + protected String text = "";
|
---|
| 55 | +
|
---|
| 56 | + @SuppressWarnings("deprecation")
|
---|
| 57 | + public void onCreate(Bundle paramBundle) {
|
---|
| 58 | + super.onCreate(paramBundle);
|
---|
| 59 | +
|
---|
| 60 | + setTitle(getTitle() + "----("
|
---|
| 61 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS)
|
---|
| 62 | + + ")");
|
---|
| 63 | + // requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 64 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 65 | +
|
---|
| 66 | + setContentView(R.layout.compasstest);
|
---|
| 67 | + compassView = (CompassView) findViewById(R.id.compasstestview);
|
---|
| 68 | + state = STATE.WAIT_FOR_FIRST_STABLE;
|
---|
| 69 | + count = 0;
|
---|
| 70 | + compassText = (TextView) findViewById(R.id.compassText);
|
---|
| 71 | +
|
---|
| 72 | + startButton = (Button) findViewById(R.id.Start);
|
---|
| 73 | + startButton.setOnClickListener(new View.OnClickListener() {
|
---|
| 74 | +
|
---|
| 75 | + @Override
|
---|
| 76 | + public void onClick(View v) {
|
---|
| 77 | + start = true;
|
---|
| 78 | + count = 0;
|
---|
| 79 | + state = STATE.WAIT_FOR_FIRST_STABLE;
|
---|
| 80 | + startButton.setEnabled(false);
|
---|
| 81 | + text = "wait for stable data...";
|
---|
| 82 | + }
|
---|
| 83 | + });
|
---|
| 84 | +
|
---|
| 85 | + final SensorManager sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
|
---|
| 86 | +
|
---|
| 87 | + sensorManager.registerListener(new SensorListener() {
|
---|
| 88 | + public void onSensorChanged(int sensor, float[] values) {
|
---|
| 89 | + if (stop) {
|
---|
| 90 | + sensorManager.unregisterListener(this);
|
---|
| 91 | + }
|
---|
| 92 | + if ((int) values[0] == 0 || values[0] == 360) {
|
---|
| 93 | + return;
|
---|
| 94 | + }
|
---|
| 95 | +
|
---|
| 96 | + float yaw = values[0];
|
---|
| 97 | + compassView.update(yaw);
|
---|
| 98 | + Log.e("jeffy", "yaw:" + yaw);
|
---|
| 99 | + if (!start) {
|
---|
| 100 | + return;
|
---|
| 101 | + }
|
---|
| 102 | + boolean pass = Math.abs(lastYaw - yaw) < STABLE_VALUE;
|
---|
| 103 | + if (state == STATE.WAIT_FOR_ROTATE) {
|
---|
| 104 | + pass = !pass;
|
---|
| 105 | + }
|
---|
| 106 | +
|
---|
| 107 | + if (pass) {
|
---|
| 108 | + count++;
|
---|
| 109 | + } else {
|
---|
| 110 | + count = 0;
|
---|
| 111 | + }
|
---|
| 112 | + if (count >= STABLE_COUNT) {
|
---|
| 113 | + switch (state) {
|
---|
| 114 | + case WAIT_FOR_FIRST_STABLE:
|
---|
| 115 | + firstYaw = yaw;
|
---|
| 116 | + if (firstYaw < yawRange[0] || firstYaw > yawRange[1]) {
|
---|
| 117 | + text = "invalid orientation:" + (int) firstYaw;
|
---|
| 118 | +
|
---|
| 119 | + state = STATE.UNDEF;
|
---|
| 120 | + mHandler.postDelayed(mFailedRunnable, 2000);
|
---|
| 121 | + sensorManager.unregisterListener(this);
|
---|
| 122 | + break;
|
---|
| 123 | + }
|
---|
| 124 | +
|
---|
| 125 | + state = STATE.WAIT_FOR_ROTATE;
|
---|
| 126 | + count = 0;
|
---|
| 127 | + text = "valid orientation, first stable data:"
|
---|
| 128 | + + (int) firstYaw + ", wait for rotate...";
|
---|
| 129 | + break;
|
---|
| 130 | + case WAIT_FOR_ROTATE:
|
---|
| 131 | + state = STATE.WAIT_FOR_SECOND_STABLE;
|
---|
| 132 | + count = 0;
|
---|
| 133 | + text = "first stable data:" + (int) firstYaw
|
---|
| 134 | + + ", wait for stable data...";
|
---|
| 135 | + break;
|
---|
| 136 | + case WAIT_FOR_SECOND_STABLE:
|
---|
| 137 | + state = STATE.UNDEF;
|
---|
| 138 | + float deltaYaw = Math.abs(yaw - firstYaw);
|
---|
| 139 | + if (deltaYaw <= 5) {
|
---|
| 140 | + findViewById(R.id.btn_Pass).performClick();
|
---|
| 141 | + } else {
|
---|
| 142 | + findViewById(R.id.btn_Fail).performClick();
|
---|
| 143 | + }
|
---|
| 144 | + count = 0;
|
---|
| 145 | + sensorManager.unregisterListener(this);
|
---|
| 146 | + text = "first stable data:" + (int) firstYaw
|
---|
| 147 | + + ", second stable data:" + (int) yaw;
|
---|
| 148 | + break;
|
---|
| 149 | + default:
|
---|
| 150 | + return;
|
---|
| 151 | + }
|
---|
| 152 | + }
|
---|
| 153 | + compassText.setText(accuracyStr + "\n" + text);
|
---|
| 154 | + lastYaw = yaw;
|
---|
| 155 | + }
|
---|
| 156 | +
|
---|
| 157 | + public void onAccuracyChanged(int sensor, int accuracy) {
|
---|
| 158 | + Log.e("Jeffy", "onAccuracyChanged" + accuracy);
|
---|
| 159 | + accuracyStr = "accuracy:" + accuracy;
|
---|
| 160 | + if (accuracy == 3) {
|
---|
| 161 | + accuracyStr += ",pass";
|
---|
| 162 | + if (!start) {
|
---|
| 163 | + accuracyStr += ",ready";
|
---|
| 164 | + startButton.setEnabled(true);
|
---|
| 165 | + }
|
---|
| 166 | + } else {
|
---|
| 167 | + accuracyStr += ",failed";
|
---|
| 168 | + accuracyStr += ",needs correction!";
|
---|
| 169 | + state = STATE.UNDEF;
|
---|
| 170 | + start = false;
|
---|
| 171 | + text = "";
|
---|
| 172 | + startButton.setEnabled(false);
|
---|
| 173 | + }
|
---|
| 174 | +
|
---|
| 175 | + compassText.setText(accuracyStr + "\n" + text);
|
---|
| 176 | + }
|
---|
| 177 | + }, SensorManager.SENSOR_ORIENTATION);
|
---|
| 178 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 179 | + // findViewById(R.id.btn_Fail).setVisibility(View.INVISIBLE);
|
---|
| 180 | + // findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 181 | + }
|
---|
| 182 | +
|
---|
| 183 | + protected void onStop() {
|
---|
| 184 | + super.onStop();
|
---|
| 185 | + stop = true;
|
---|
| 186 | + mHandler.removeCallbacks(mFailedRunnable);
|
---|
| 187 | + }
|
---|
| 188 | +
|
---|
| 189 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 190 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 191 | + return false;
|
---|
| 192 | + }
|
---|
| 193 | + return super.dispatchKeyEvent(event);
|
---|
| 194 | + }
|
---|
| 195 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | +import android.os.Environment; |
---|
| 3 | +import android.app.Activity; |
---|
| 4 | +import android.app.AlertDialog; |
---|
| 5 | +import android.app.Dialog; |
---|
| 6 | +import android.content.ComponentName; |
---|
| 7 | +import android.content.Context; |
---|
| 8 | +import android.content.DialogInterface; |
---|
| 9 | +import android.content.Intent; |
---|
| 10 | +import android.database.DataSetObserver; |
---|
| 11 | +import android.net.Uri; |
---|
| 12 | +import android.os.Bundle; |
---|
| 13 | + |
---|
| 14 | +import java.io.File; |
---|
| 15 | +import java.io.FileInputStream; |
---|
| 16 | +import java.io.FileNotFoundException; |
---|
| 17 | +import java.io.FileOutputStream; |
---|
| 18 | +import java.io.FileWriter; |
---|
| 19 | +import java.io.IOException; |
---|
| 20 | +import java.io.InputStream; |
---|
| 21 | +import java.io.ObjectInputStream; |
---|
| 22 | +import java.io.ObjectOutputStream; |
---|
| 23 | +import java.io.OutputStream; |
---|
| 24 | +import java.io.StreamCorruptedException; |
---|
| 25 | +import java.util.ArrayList; |
---|
| 26 | +import java.util.Arrays; |
---|
| 27 | +import java.util.Collections; |
---|
| 28 | +import java.util.Date; |
---|
| 29 | +import java.util.HashMap; |
---|
| 30 | +import java.util.Iterator; |
---|
| 31 | +import java.util.List; |
---|
| 32 | +import java.util.Map; |
---|
| 33 | +import java.util.Set; |
---|
| 34 | + |
---|
| 35 | +import org.xmlpull.v1.XmlSerializer; |
---|
| 36 | + |
---|
| 37 | +import com.DeviceTest.helper.ConfigUtil; |
---|
| 38 | +import com.DeviceTest.helper.SystemUtil; |
---|
| 39 | +import com.DeviceTest.helper.TestCase; |
---|
| 40 | +import com.DeviceTest.helper.XmlDeal; |
---|
| 41 | +import com.DeviceTest.helper.TestCase.RESULT; |
---|
| 42 | +import com.DeviceTest.view.MyGridView; |
---|
| 43 | +import com.DeviceTest.view.MyItemView; |
---|
| 44 | + |
---|
| 45 | +import android.view.ContextMenu; |
---|
| 46 | +import android.view.LayoutInflater; |
---|
| 47 | +import android.view.View.OnLongClickListener; |
---|
| 48 | +import android.view.ViewGroup; |
---|
| 49 | +import android.view.ViewParent; |
---|
| 50 | +import android.view.ContextMenu.ContextMenuInfo; |
---|
| 51 | +import android.view.View.OnClickListener; |
---|
| 52 | +import android.widget.AdapterView; |
---|
| 53 | +import android.widget.AdapterView.OnItemSelectedListener; |
---|
| 54 | +import android.widget.ArrayAdapter; |
---|
| 55 | +import android.widget.Button; |
---|
| 56 | +import android.widget.EditText; |
---|
| 57 | +import android.widget.ListView; |
---|
| 58 | +import android.widget.Spinner; |
---|
| 59 | +import android.widget.SpinnerAdapter; |
---|
| 60 | +import android.widget.Toast; |
---|
| 61 | +import android.view.View; |
---|
| 62 | +import android.util.Log; |
---|
| 63 | +import android.util.Xml; |
---|
| 64 | +import android.content.res.Resources; |
---|
| 65 | + |
---|
| 66 | +public class DeviceTest extends Activity { |
---|
| 67 | + |
---|
| 68 | + public static final int DEVICE_TEST_MAX_NUM = 1000; |
---|
| 69 | + public static final int TEST_FAILED_DELAY = 5000; |
---|
| 70 | + public static final String EXTRA_TEST_PROGRESS = "test progress"; |
---|
| 71 | + public static final String EXTRA_TEST_RESULT_INFO = "test result info"; |
---|
| 72 | + |
---|
| 73 | + public static final String RESULT_INFO_HEAD = ";"; |
---|
| 74 | + public static final String RESULT_INFO_HEAD_JUST_INFO = "just info;"; |
---|
| 75 | + |
---|
| 76 | + public static final String EXTRA_PATH = "/vendor/etc/"; |
---|
| 77 | + private static final String CONFIG_FILE_NAME = "DeviceTestConfig.xml"; |
---|
| 78 | + private static final String CONFIG_FILE_NAME_CN = "DeviceTestConfig_CN1.xml"; |
---|
| 79 | + private static final String EXTRA_CONFIG_FILE_NAME = EXTRA_PATH |
---|
| 80 | + + CONFIG_FILE_NAME; |
---|
| 81 | + private static final String EXTRA_CONFIG_FILE_NAME_CN = EXTRA_PATH |
---|
| 82 | + + CONFIG_FILE_NAME_CN; |
---|
| 83 | + public static final String DATA_PATH = "/data/data/com.DeviceTest/"; |
---|
| 84 | + private static final String SAVE_FILE_PATH = EXTRA_PATH |
---|
| 85 | + + "DeviceTestResult"; |
---|
| 86 | + private static final String TAG = "DeviceTest"; |
---|
| 87 | + private static final String SAVE_DATA_PATH = DATA_PATH + "DeviceTest.tmp"; |
---|
| 88 | + public static final String TEMP_FILE_PATH = DeviceTest.DATA_PATH + "test"; |
---|
| 89 | + private static final String[] BLACK_LIST_SPECIAL_EVB = new String[] { |
---|
| 90 | + "VibrationTestActivity", |
---|
| 91 | + "BrightnessTestActivity", |
---|
| 92 | + "GpsLocationTestActivity", |
---|
| 93 | + "CompassTestActivity", |
---|
| 94 | + "MsensorTestActivity", |
---|
| 95 | + "GyroscopeTestActivity", |
---|
| 96 | + "LightsensorTestActivity", |
---|
| 97 | + }; |
---|
| 98 | + private static final String[] WHITE_LIST_SPECIAL_EVB = new String[] { |
---|
| 99 | + //"PCIETestActivity", |
---|
| 100 | + //"SATATestActivity", |
---|
| 101 | + //"Ethernet2TestActivity", |
---|
| 102 | + }; |
---|
| 103 | + |
---|
| 104 | + private XmlDeal xmldoc = null; |
---|
| 105 | + private Spinner mGroupTestSpinner; |
---|
| 106 | + private Button mButtonCancel; |
---|
| 107 | + private Button mTestChecked; |
---|
| 108 | + MyGridView myGridView; |
---|
| 109 | + |
---|
| 110 | + private List<TestCase> mTestCases; |
---|
| 111 | + private List<TestCase> mCurrentCaseGroup; |
---|
| 112 | + private Object[] mTestGroupNames; |
---|
| 113 | + private int mPosition =-1; |
---|
| 114 | + /** Called when the activity is first created. */ |
---|
| 115 | + |
---|
| 116 | + public void onCreate(Bundle savedInstanceState) { |
---|
| 117 | + super.onCreate(savedInstanceState); |
---|
| 118 | +// Environment.getFlashStorageDirectory(); |
---|
| 119 | + setContentView(R.layout.main); |
---|
| 120 | + if (!InitTestData()) { |
---|
| 121 | + System.exit(-1); |
---|
| 122 | + } |
---|
| 123 | + this.setTitle("DeviceTest Version:" |
---|
| 124 | + + getResources().getString(R.string.Version) + " (for 8.1~12.0)"); |
---|
| 125 | + mTestCases = new ArrayList<TestCase>(); |
---|
| 126 | + for (TestCase temp : xmldoc.mTestCases) { |
---|
| 127 | + boolean skip = false; |
---|
| 128 | + if (ConfigUtil.isSpecialEvb()) { |
---|
| 129 | + for (String black: BLACK_LIST_SPECIAL_EVB) { |
---|
| 130 | + if (temp.getClassName().equals(black)) { |
---|
| 131 | + skip = true; |
---|
| 132 | + break; |
---|
| 133 | + } |
---|
| 134 | + } |
---|
| 135 | + } else { |
---|
| 136 | + for (String black: WHITE_LIST_SPECIAL_EVB) { |
---|
| 137 | + if (temp.getClassName().equals(black)) { |
---|
| 138 | + skip = true; |
---|
| 139 | + break; |
---|
| 140 | + } |
---|
| 141 | + } |
---|
| 142 | + } |
---|
| 143 | + if (!skip) { |
---|
| 144 | + mTestCases.add(temp); |
---|
| 145 | + } |
---|
| 146 | + } |
---|
| 147 | + try { |
---|
| 148 | + loadData(); |
---|
| 149 | + } catch (Exception e) { |
---|
| 150 | + Log.e("Jeffy", "load data error."); |
---|
| 151 | + e.printStackTrace(); |
---|
| 152 | + } |
---|
| 153 | + |
---|
| 154 | + myGridView = (MyGridView) findViewById(R.id.myGridView); |
---|
| 155 | + myGridView.setColumnCount(3); |
---|
| 156 | + |
---|
| 157 | + for (TestCase testCase : mTestCases) { |
---|
| 158 | + MyItemView itemView = new MyItemView(this); |
---|
| 159 | + itemView.setText(testCase.getTestName()); |
---|
| 160 | + itemView.setTag(testCase.getTestNo()); |
---|
| 161 | + itemView.setCheck(testCase.getneedtest()); |
---|
| 162 | + if (testCase.isShowResult()) { |
---|
| 163 | + RESULT result = testCase.getResult(); |
---|
| 164 | + itemView.setResult(result); |
---|
| 165 | + } |
---|
| 166 | + System.out.println("================="+testCase.getTestName()); |
---|
| 167 | + myGridView.addView(itemView); |
---|
| 168 | + } |
---|
| 169 | + |
---|
| 170 | + myGridView.setOnItemClickListener(new MyGridView.OnItemClickListener() { |
---|
| 171 | + public void onItemClick(ViewParent parent, View view, int position) { |
---|
| 172 | + if(((MyItemView)view). getTemcheckclick()){ |
---|
| 173 | + showDialog(DIALOG_PASSWORK_ID); |
---|
| 174 | + mPosition =position; |
---|
| 175 | + return; |
---|
| 176 | + } |
---|
| 177 | + if(enableitemclick) |
---|
| 178 | + enableitemclick = false; |
---|
| 179 | + else |
---|
| 180 | + return; |
---|
| 181 | + Intent intent = new Intent(); |
---|
| 182 | + try { |
---|
| 183 | + if (mTestCases.get(position) != null) { |
---|
| 184 | + String strClsPath = "com.DeviceTest." |
---|
| 185 | + + mTestCases.get(position).getClassName(); |
---|
| 186 | + intent.setClass(DeviceTest.this, |
---|
| 187 | + Class.forName(strClsPath).newInstance() |
---|
| 188 | + .getClass()); |
---|
| 189 | + intent.putExtra(EXTRA_TEST_PROGRESS, "0/1"); |
---|
| 190 | + startActivityForResult(intent, position); |
---|
| 191 | + } |
---|
| 192 | + } catch (Exception e) { |
---|
| 193 | + e.printStackTrace(); |
---|
| 194 | + } |
---|
| 195 | + } |
---|
| 196 | + }); |
---|
| 197 | + |
---|
| 198 | + mGroupTestSpinner = (Spinner) findViewById(R.id.GroupTestSpinner); |
---|
| 199 | + |
---|
| 200 | + mTestGroupNames = xmldoc.mCaseGroups.keySet().toArray(); |
---|
| 201 | + String[] testGroupTexts = new String[mTestGroupNames.length + 1]; |
---|
| 202 | + for (int i = 1; i < testGroupTexts.length; i++) { |
---|
| 203 | + testGroupTexts[i] = "Group: " + mTestGroupNames[i - 1].toString(); |
---|
| 204 | + } |
---|
| 205 | + testGroupTexts[0] = "CaseGroups"; |
---|
| 206 | + |
---|
| 207 | + ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, |
---|
| 208 | + android.R.layout.simple_spinner_dropdown_item, testGroupTexts); |
---|
| 209 | + mGroupTestSpinner.setAdapter(adapter); |
---|
| 210 | + mGroupTestSpinner.setSelection(0, false); |
---|
| 211 | + mGroupTestSpinner |
---|
| 212 | + .setOnItemSelectedListener(new OnItemSelectedListener() { |
---|
| 213 | + |
---|
| 214 | + public void onItemSelected(AdapterView<?> parent, |
---|
| 215 | + View view, int position, long id) { |
---|
| 216 | + if (position == 0) { |
---|
| 217 | + return; |
---|
| 218 | + } |
---|
| 219 | + testGroup(mTestGroupNames[position - 1].toString()); |
---|
| 220 | + mGroupTestSpinner.setSelection(0, false); |
---|
| 221 | + } |
---|
| 222 | + |
---|
| 223 | + public void onNothingSelected(AdapterView<?> parent) { |
---|
| 224 | + |
---|
| 225 | + } |
---|
| 226 | + }); |
---|
| 227 | + |
---|
| 228 | + mButtonCancel = (Button) findViewById(R.id.btn_cancel); |
---|
| 229 | + mButtonCancel.setOnClickListener(new Button.OnClickListener() { |
---|
| 230 | + public void onClick(View v) { |
---|
| 231 | + try { |
---|
| 232 | + save(SAVE_FILE_PATH); |
---|
| 233 | + } catch (Exception e) { |
---|
| 234 | + Log.e(TAG, "Failed to save test result!"); |
---|
| 235 | + e.printStackTrace(); |
---|
| 236 | + } |
---|
| 237 | + finish(); |
---|
| 238 | + } |
---|
| 239 | + |
---|
| 240 | + }); |
---|
| 241 | + mTestChecked = (Button) findViewById(R.id.btn_testall); |
---|
| 242 | + mTestChecked.setOnClickListener(new Button.OnClickListener() { |
---|
| 243 | + public void onClick(View v) { |
---|
| 244 | + testGroup(mTestGroupNames[0].toString()); |
---|
| 245 | + } |
---|
| 246 | + }); |
---|
| 247 | + |
---|
| 248 | + Button saveButton = (Button) findViewById(R.id.btn_save); |
---|
| 249 | + saveButton.setOnClickListener(new OnClickListener() |
---|
| 250 | + { |
---|
| 251 | + |
---|
| 252 | + @Override |
---|
| 253 | + public void onClick(View v) |
---|
| 254 | + { |
---|
| 255 | + // TODO Auto-generated method stub |
---|
| 256 | + // zyt ++ |
---|
| 257 | + File savefile = new File("/cache/Result.txt"); |
---|
| 258 | + if (savefile.exists()) |
---|
| 259 | + { |
---|
| 260 | + savefile.delete(); |
---|
| 261 | + } |
---|
| 262 | + if (!savefile.exists()) |
---|
| 263 | + { |
---|
| 264 | + try |
---|
| 265 | + { |
---|
| 266 | + savefile.createNewFile(); |
---|
| 267 | + } catch (IOException e) |
---|
| 268 | + { |
---|
| 269 | + // TODO Auto-generated catch block |
---|
| 270 | + e.printStackTrace(); |
---|
| 271 | + } |
---|
| 272 | + } |
---|
| 273 | + StringBuilder sb = new StringBuilder(); |
---|
| 274 | + |
---|
| 275 | + for (int i = 0; i < myGridView.getChildCount(); i++) |
---|
| 276 | + { |
---|
| 277 | + MyItemView myItemView = (MyItemView) myGridView.getChildAt(i); |
---|
| 278 | + RESULT r = myItemView.getResult(); |
---|
| 279 | + String testName = mTestCases.get(i).getTestName(); |
---|
| 280 | + String result = mAkeEnumToString(r); |
---|
| 281 | + sb.append(testName).append(":").append(result).append("\n"); |
---|
| 282 | + |
---|
| 283 | + /* |
---|
| 284 | + * myItemView.setResult(RESULT.UNDEF); |
---|
| 285 | + * myItemView.setCheck(true); |
---|
| 286 | + * mTestCases.get(i).setShowResult(false); |
---|
| 287 | + * mTestCases.get(i).setneedtest(true); |
---|
| 288 | + */ |
---|
| 289 | + } |
---|
| 290 | + String sbStirng = sb.toString(); |
---|
| 291 | + FileOutputStream fos = null; |
---|
| 292 | + try |
---|
| 293 | + { |
---|
| 294 | + fos = new FileOutputStream(savefile, false); |
---|
| 295 | + fos.write(sbStirng.getBytes()); |
---|
| 296 | + fos.close(); |
---|
| 297 | + } catch (FileNotFoundException e) |
---|
| 298 | + { |
---|
| 299 | + // TODO Auto-generated catch block |
---|
| 300 | + e.printStackTrace(); |
---|
| 301 | + } catch (IOException e) |
---|
| 302 | + { |
---|
| 303 | + // TODO Auto-generated catch block |
---|
| 304 | + e.printStackTrace(); |
---|
| 305 | + } finally |
---|
| 306 | + { |
---|
| 307 | + if (fos != null) |
---|
| 308 | + { |
---|
| 309 | + try |
---|
| 310 | + { |
---|
| 311 | + fos.close(); |
---|
| 312 | + } catch (IOException e) |
---|
| 313 | + { |
---|
| 314 | + e.printStackTrace(); |
---|
| 315 | + } |
---|
| 316 | + } |
---|
| 317 | + } |
---|
| 318 | + Toast.makeText(getApplicationContext(), getString(R.string.save_isok), Toast.LENGTH_SHORT).show(); |
---|
| 319 | + |
---|
| 320 | + |
---|
| 321 | + } |
---|
| 322 | + }); |
---|
| 323 | + |
---|
| 324 | + |
---|
| 325 | + |
---|
| 326 | + Button clearButton = (Button) findViewById(R.id.btn_clear); |
---|
| 327 | + clearButton.setOnClickListener(new View.OnClickListener() { |
---|
| 328 | + |
---|
| 329 | + public void onClick(View v) { |
---|
| 330 | + showDialog(DIALOG_CLEAR_ID); |
---|
| 331 | + } |
---|
| 332 | + }); |
---|
| 333 | + |
---|
| 334 | + Button uninstallButton = (Button) findViewById(R.id.btn_uninstall); |
---|
| 335 | + uninstallButton.setOnClickListener(new OnClickListener() { |
---|
| 336 | + |
---|
| 337 | + public void onClick(View v) { |
---|
| 338 | + uninstallPackage("com.DeviceTest"); |
---|
| 339 | + } |
---|
| 340 | + }); |
---|
| 341 | + createAssetFile("memtester", MEMTESTER_PATH); |
---|
| 342 | + createAssetFile("gps_coldstart", GPS_COLD_START_PATH); |
---|
| 343 | + } |
---|
| 344 | + private boolean enableitemclick = true; |
---|
| 345 | + @Override |
---|
| 346 | + protected void onResume() { |
---|
| 347 | + enableitemclick = true; |
---|
| 348 | + mPosition =-1; |
---|
| 349 | + super.onResume(); |
---|
| 350 | + } |
---|
| 351 | + private void createAssetFile(String name, String destPath) { |
---|
| 352 | + |
---|
| 353 | + InputStream is = null; |
---|
| 354 | + OutputStream os = null; |
---|
| 355 | + try { |
---|
| 356 | + is = getAssets().open(name); |
---|
| 357 | + os = new FileOutputStream(destPath); |
---|
| 358 | + int data = 0; |
---|
| 359 | + while (true) { |
---|
| 360 | + data = is.read(); |
---|
| 361 | + if (data < 0) { |
---|
| 362 | + break; |
---|
| 363 | + } |
---|
| 364 | + os.write(data); |
---|
| 365 | + } |
---|
| 366 | + } catch (Exception e) { |
---|
| 367 | + e.printStackTrace(); |
---|
| 368 | + } finally { |
---|
| 369 | + if (is != null) { |
---|
| 370 | + try { |
---|
| 371 | + is.close(); |
---|
| 372 | + } catch (Exception e) { |
---|
| 373 | + } |
---|
| 374 | + } |
---|
| 375 | + if (os != null) { |
---|
| 376 | + try { |
---|
| 377 | + os.close(); |
---|
| 378 | + } catch (Exception e) { |
---|
| 379 | + } |
---|
| 380 | + } |
---|
| 381 | + SystemUtil.execRootCmd("chmod 777 " + destPath); |
---|
| 382 | + } |
---|
| 383 | + } |
---|
| 384 | + |
---|
| 385 | + public final static String MEMTESTER_PATH = DeviceTest.DATA_PATH |
---|
| 386 | + + "memtester"; |
---|
| 387 | + public final static String GPS_COLD_START_PATH = DeviceTest.DATA_PATH |
---|
| 388 | + + "gps_coldstart"; |
---|
| 389 | + private static final int DIALOG_CLEAR_ID = 10; |
---|
| 390 | + private static final int DIALOG_PASSWORK_ID =11; |
---|
| 391 | + protected Dialog onCreateDialog(int id) { |
---|
| 392 | + switch(id){ |
---|
| 393 | + case DIALOG_CLEAR_ID: |
---|
| 394 | + AlertDialog.Builder builder = new AlertDialog.Builder(this); |
---|
| 395 | + return builder.setMessage("Clear all test status?") |
---|
| 396 | + .setCancelable(false) |
---|
| 397 | + .setPositiveButton("Yes", |
---|
| 398 | + new DialogInterface.OnClickListener() { |
---|
| 399 | + public void onClick(DialogInterface dialog, int id) { |
---|
| 400 | + for (int i = 0; i < myGridView.getChildCount(); i++) { |
---|
| 401 | + MyItemView myItemView = (MyItemView) myGridView |
---|
| 402 | + .getChildAt(i); |
---|
| 403 | + myItemView.setResult(RESULT.UNDEF); |
---|
| 404 | + myItemView.setCheck(true); |
---|
| 405 | + mTestCases.get(i).setShowResult(false); |
---|
| 406 | + mTestCases.get(i).setneedtest(true); |
---|
| 407 | + } |
---|
| 408 | + try { |
---|
| 409 | + save(SAVE_FILE_PATH); |
---|
| 410 | + } catch (IOException e) { |
---|
| 411 | + e.printStackTrace(); |
---|
| 412 | + } |
---|
| 413 | + } |
---|
| 414 | + }) |
---|
| 415 | + .setNegativeButton("No", new DialogInterface.OnClickListener() { |
---|
| 416 | + public void onClick(DialogInterface dialog, int id) { |
---|
| 417 | + dialog.cancel(); |
---|
| 418 | + } |
---|
| 419 | + }).create(); |
---|
| 420 | + case DIALOG_PASSWORK_ID: |
---|
| 421 | + LayoutInflater factory = LayoutInflater.from(this); |
---|
| 422 | + final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null); |
---|
| 423 | + final EditText text = (EditText)textEntryView.findViewById(R.id.password_edit); |
---|
| 424 | + return new AlertDialog.Builder(this) |
---|
| 425 | + .setIconAttribute(android.R.attr.alertDialogIcon) |
---|
| 426 | + .setTitle(R.string.alert_dialog_warning_title) |
---|
| 427 | + .setMessage(R.string.alert_dialog_text_entry) |
---|
| 428 | + .setView(textEntryView) |
---|
| 429 | + .setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() { |
---|
| 430 | + public void onClick(DialogInterface dialog, int whichButton) { |
---|
| 431 | + String password = text.getText().toString(); |
---|
| 432 | + if("123456".equals(password)){ |
---|
| 433 | + MyItemView myItemView = (MyItemView) myGridView |
---|
| 434 | + .getChildAt(mPosition); |
---|
| 435 | + if(myItemView.setCheckClick()){ |
---|
| 436 | + if(!(myItemView).getischeck()){ |
---|
| 437 | + mTestCases.get(mPosition).setneedtest(false); |
---|
| 438 | + }else{ |
---|
| 439 | + mTestCases.get(mPosition).setneedtest(true); |
---|
| 440 | + } |
---|
| 441 | + } |
---|
| 442 | + |
---|
| 443 | + }else{ |
---|
| 444 | + Toast.makeText(DeviceTest.this, |
---|
| 445 | + " Password error !!! ", |
---|
| 446 | + Toast.LENGTH_LONG).show(); |
---|
| 447 | + } |
---|
| 448 | + /* User clicked OK so do some stuff */ |
---|
| 449 | + } |
---|
| 450 | + }) |
---|
| 451 | + .setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() { |
---|
| 452 | + public void onClick(DialogInterface dialog, int whichButton) { |
---|
| 453 | + |
---|
| 454 | + /* User clicked cancel so do some stuff */ |
---|
| 455 | + } |
---|
| 456 | + }) |
---|
| 457 | + .create(); |
---|
| 458 | + } |
---|
| 459 | + return null; |
---|
| 460 | + } |
---|
| 461 | + |
---|
| 462 | + private void loadData() throws Exception { |
---|
| 463 | + ObjectInputStream ois = new ObjectInputStream(new FileInputStream( |
---|
| 464 | + SAVE_DATA_PATH)); |
---|
| 465 | + try{ |
---|
| 466 | + List<TestCase> savedData = (List<TestCase>) ois.readObject(); |
---|
| 467 | + for (TestCase savedCase : savedData) { |
---|
| 468 | + for (TestCase testCase : mTestCases) { |
---|
| 469 | + if (testCase.getClassName().equals(savedCase.getClassName())) { |
---|
| 470 | + testCase.setResult(savedCase.getResult()); |
---|
| 471 | + testCase.setDetail(savedCase.getDetail()); |
---|
| 472 | + testCase.setShowResult(savedCase.isShowResult()); |
---|
| 473 | + } |
---|
| 474 | + } |
---|
| 475 | + } |
---|
| 476 | + }catch(Exception e){ |
---|
| 477 | + e.printStackTrace(); |
---|
| 478 | + }finally{ |
---|
| 479 | + if(ois != null){ |
---|
| 480 | + ois.close(); |
---|
| 481 | + } |
---|
| 482 | + } |
---|
| 483 | + |
---|
| 484 | + } |
---|
| 485 | + |
---|
| 486 | + public static String formatResult(String testName, RESULT result, |
---|
| 487 | + String detail) { |
---|
| 488 | + if (detail == null) { |
---|
| 489 | + return "[" + testName + "]\n" + result.name(); |
---|
| 490 | + } |
---|
| 491 | + if (detail.startsWith(RESULT_INFO_HEAD_JUST_INFO)) { |
---|
| 492 | + return detail.substring(RESULT_INFO_HEAD_JUST_INFO.length()); |
---|
| 493 | + } |
---|
| 494 | + return "[" + testName + "]\n" + result.name() + detail; |
---|
| 495 | + } |
---|
| 496 | + |
---|
| 497 | + synchronized private void save(String saveFilePath) throws IOException { |
---|
| 498 | + FileWriter fw; |
---|
| 499 | + String tempSavePath = DATA_PATH + "save"; |
---|
| 500 | + fw = new FileWriter(tempSavePath); |
---|
| 501 | + FileWriter fw2 = null; |
---|
| 502 | + if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){ |
---|
| 503 | + fw2 = new FileWriter("/mnt/sdcard/testResult.txt"); |
---|
| 504 | + } |
---|
| 505 | + for (TestCase testCase : mTestCases) { |
---|
| 506 | + if (testCase.getClassName().equals( |
---|
| 507 | + RuninTestActivity.class.getSimpleName())) { |
---|
| 508 | + if (testCase.getDetail() == null) { |
---|
| 509 | + testCase.setDetail(new RuninTestActivity().getResult()); |
---|
| 510 | + } |
---|
| 511 | + } else if(testCase.getClassName().equals(GpsTestActivity.class.getSimpleName())) { |
---|
| 512 | + if (testCase.getDetail() == null) { |
---|
| 513 | + testCase.setDetail(new GpsTestActivity().getResult()); |
---|
| 514 | + } |
---|
| 515 | + } |
---|
| 516 | + fw.write(formatResult(testCase.getTestName(), testCase.getResult(), |
---|
| 517 | + testCase.getDetail()) + "\n"); |
---|
| 518 | + if(fw2 != null){ |
---|
| 519 | + fw2.write(formatResult(testCase.getTestName(), testCase.getResult(), |
---|
| 520 | + testCase.getDetail()) + "\n"); |
---|
| 521 | + } |
---|
| 522 | + } |
---|
| 523 | + fw.close(); |
---|
| 524 | + if(fw2!=null){ |
---|
| 525 | + fw2.close(); |
---|
| 526 | + } |
---|
| 527 | + SystemUtil.execScriptCmd("cat " + tempSavePath + ">" + saveFilePath, |
---|
| 528 | + TEMP_FILE_PATH, true); |
---|
| 529 | + |
---|
| 530 | + ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream( |
---|
| 531 | + SAVE_DATA_PATH)); |
---|
| 532 | + oos.writeObject(mTestCases); |
---|
| 533 | + oos.close(); |
---|
| 534 | + } |
---|
| 535 | + |
---|
| 536 | + protected void testGroup(String selectGroup) { |
---|
| 537 | + mCurrentCaseGroup = xmldoc.mCaseGroups.get(selectGroup); |
---|
| 538 | + int pos = 0; |
---|
| 539 | + if (pos < mCurrentCaseGroup.size()) { |
---|
| 540 | + while(!mCurrentCaseGroup.get(pos).getneedtest()){ |
---|
| 541 | + pos ++; |
---|
| 542 | + if(pos >= mCurrentCaseGroup.size()){ |
---|
| 543 | + return; |
---|
| 544 | + } |
---|
| 545 | + } |
---|
| 546 | + } |
---|
| 547 | + Intent intent = new Intent(); |
---|
| 548 | + if (mCurrentCaseGroup != null && mCurrentCaseGroup.get(pos) != null) { |
---|
| 549 | + try { |
---|
| 550 | + String strClsPath = "com.DeviceTest." |
---|
| 551 | + + mCurrentCaseGroup.get(pos).getClassName(); |
---|
| 552 | + intent.setClass(DeviceTest.this, Class.forName(strClsPath) |
---|
| 553 | + .newInstance().getClass()); |
---|
| 554 | + intent.putExtra(EXTRA_TEST_PROGRESS, |
---|
| 555 | + pos+"/" + mCurrentCaseGroup.size()); |
---|
| 556 | + // we use nagtiv value to keep the sequence number when |
---|
| 557 | + // do a all test. |
---|
| 558 | + startActivityForResult(intent,pos + DEVICE_TEST_MAX_NUM); |
---|
| 559 | + } catch (ClassNotFoundException e) { |
---|
| 560 | + e.printStackTrace(); |
---|
| 561 | + } catch (IllegalAccessException e) { |
---|
| 562 | + e.printStackTrace(); |
---|
| 563 | + } catch (InstantiationException e) { |
---|
| 564 | + e.printStackTrace(); |
---|
| 565 | + } |
---|
| 566 | + } |
---|
| 567 | + } |
---|
| 568 | + |
---|
| 569 | + |
---|
| 570 | + private void uninstallPackage(String packageName) { |
---|
| 571 | + String cmd = "mount -o remount,rw /system /system\n" |
---|
| 572 | + + "rm -r /data/data/*DeviceTest*\n" |
---|
| 573 | + + "rm /data/app/*DeviceTest*\n" |
---|
| 574 | + + "rm /system/app/*DeviceTest*\n"; |
---|
| 575 | + SystemUtil.execScriptCmd(cmd, TEMP_FILE_PATH, true); |
---|
| 576 | + |
---|
| 577 | + Uri uninstallUri = Uri.parse("package:" + packageName); |
---|
| 578 | + Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, uninstallUri); |
---|
| 579 | + startActivity(uninstallIntent); |
---|
| 580 | + } |
---|
| 581 | + |
---|
| 582 | + protected void onActivityResult(int requestCode, int resultCode, |
---|
| 583 | + Intent paramIntent) { |
---|
| 584 | + super.onActivityResult(requestCode, resultCode, paramIntent); |
---|
| 585 | + Log.i("Jeffy", " -------------------- onResult---request:" + requestCode + ",result:" |
---|
| 586 | + + resultCode); |
---|
| 587 | + if(resultCode == RESULT_OK) return; |
---|
| 588 | + |
---|
| 589 | + if(mCurrentCaseGroup != null && (requestCode - DEVICE_TEST_MAX_NUM) >= mCurrentCaseGroup.size()) |
---|
| 590 | + return; |
---|
| 591 | + |
---|
| 592 | + int pos = requestCode; |
---|
| 593 | + boolean ignore = (resultCode == RESULT.UNDEF.ordinal()); |
---|
| 594 | + |
---|
| 595 | + if (requestCode >= DEVICE_TEST_MAX_NUM) { |
---|
| 596 | + if(mCurrentCaseGroup == null){ |
---|
| 597 | + Log.d(TAG, " _________________ mCurrentCaseGroup == null~~~~!!!!!"); |
---|
| 598 | + }else{ |
---|
| 599 | + // test auto judged. |
---|
| 600 | + TestCase tmpTestCase = mCurrentCaseGroup.get(requestCode - DEVICE_TEST_MAX_NUM); |
---|
| 601 | + |
---|
| 602 | + if(tmpTestCase == null){ |
---|
| 603 | + Log.d(TAG, " _________________ tmpTestCase == null~~~~!!!!!"); |
---|
| 604 | + }else{ |
---|
| 605 | + pos = tmpTestCase.getTestNo(); |
---|
| 606 | + Log.d(TAG, " _________________ tmpTestCas-----------~~~~!!!!!"+pos); |
---|
| 607 | + } |
---|
| 608 | + } |
---|
| 609 | + } |
---|
| 610 | + |
---|
| 611 | + if (!ignore && pos < mTestCases.size()) { |
---|
| 612 | + MyItemView itemView = (MyItemView) myGridView.getChildAt(pos); |
---|
| 613 | + RESULT result = RESULT.values()[resultCode]; |
---|
| 614 | + itemView.setResult(result); |
---|
| 615 | + mTestCases.get(pos).setResult(result); |
---|
| 616 | + mTestCases.get(pos).setShowResult(true); |
---|
| 617 | + try { |
---|
| 618 | + String detail = paramIntent |
---|
| 619 | + .getStringExtra(EXTRA_TEST_RESULT_INFO); |
---|
| 620 | + mTestCases.get(pos).setDetail(detail); |
---|
| 621 | + Log.d(TAG, " _________________ tmpTestCas---------detail--~~~~!!!!!"+detail); |
---|
| 622 | + } catch (Exception e) { |
---|
| 623 | + e.printStackTrace(); |
---|
| 624 | + } |
---|
| 625 | + |
---|
| 626 | + try { |
---|
| 627 | + save(SAVE_FILE_PATH); |
---|
| 628 | + } catch (IOException e1) { |
---|
| 629 | + e1.printStackTrace(); |
---|
| 630 | + } |
---|
| 631 | + } |
---|
| 632 | + |
---|
| 633 | + if (requestCode >= DEVICE_TEST_MAX_NUM) { |
---|
| 634 | + // test next autojuaged. |
---|
| 635 | + pos = requestCode - DEVICE_TEST_MAX_NUM; |
---|
| 636 | + if(!ignore) |
---|
| 637 | + pos++; |
---|
| 638 | + else |
---|
| 639 | + pos --; |
---|
| 640 | + if(pos < 0 || pos >= mCurrentCaseGroup.size()) return; |
---|
| 641 | + Log.d(TAG, " _________________ tmpTestCas---------pos--1~~~~!!!!!"+pos); |
---|
| 642 | + Intent intent = new Intent(); |
---|
| 643 | + if ( pos >= 0 && pos < mCurrentCaseGroup.size()) { |
---|
| 644 | + while(!ignore && !mCurrentCaseGroup.get(pos).getneedtest()){ |
---|
| 645 | + pos ++; |
---|
| 646 | + if(pos >= mCurrentCaseGroup.size()){ |
---|
| 647 | + return; |
---|
| 648 | + } |
---|
| 649 | + } |
---|
| 650 | + while(ignore && !mCurrentCaseGroup.get(pos).getneedtest()){ |
---|
| 651 | + pos --; |
---|
| 652 | + if(pos < 0 ){ |
---|
| 653 | + return; |
---|
| 654 | + } |
---|
| 655 | + } |
---|
| 656 | + } |
---|
| 657 | + Log.d(TAG, " _________________ tmpTestCas---------pos--2~~~~!!!!!"+pos); |
---|
| 658 | + try { |
---|
| 659 | + String strClsPath = "com.DeviceTest." |
---|
| 660 | + + mCurrentCaseGroup.get(pos).getClassName(); |
---|
| 661 | + intent.setClass(DeviceTest.this, Class.forName(strClsPath) |
---|
| 662 | + .newInstance().getClass()); |
---|
| 663 | + |
---|
| 664 | + intent.putExtra(EXTRA_TEST_PROGRESS, pos + "/" |
---|
| 665 | + + mCurrentCaseGroup.size()); |
---|
| 666 | + |
---|
| 667 | + // we use nagtiv value to keep the sequence number when |
---|
| 668 | + // do a all test. |
---|
| 669 | + startActivityForResult(intent, pos + DEVICE_TEST_MAX_NUM); |
---|
| 670 | + } catch (ClassNotFoundException e) { |
---|
| 671 | + e.printStackTrace(); |
---|
| 672 | + } catch (IllegalAccessException e) { |
---|
| 673 | + e.printStackTrace(); |
---|
| 674 | + } catch (InstantiationException e) { |
---|
| 675 | + e.printStackTrace(); |
---|
| 676 | + } |
---|
| 677 | + |
---|
| 678 | + } |
---|
| 679 | + |
---|
| 680 | + } |
---|
| 681 | + |
---|
| 682 | + private boolean InitTestData(InputStream is) { |
---|
| 683 | + if (is == null) { |
---|
| 684 | + return false; |
---|
| 685 | + } |
---|
| 686 | + try { |
---|
| 687 | + xmldoc = new XmlDeal(is); |
---|
| 688 | + } catch (Exception e) { |
---|
| 689 | + Log.e(TAG, "parse the xmlfile is fail"); |
---|
| 690 | + return false; |
---|
| 691 | + } |
---|
| 692 | + return true; |
---|
| 693 | + |
---|
| 694 | + } |
---|
| 695 | + |
---|
| 696 | + private boolean InitTestData() { |
---|
| 697 | + InputStream is = null; |
---|
| 698 | + try { |
---|
| 699 | + if(Resources.getSystem().getConfiguration().locale.getCountry().equals("CN")){ |
---|
| 700 | + File configFile = new File(EXTRA_CONFIG_FILE_NAME_CN); |
---|
| 701 | + if (configFile.exists()) { |
---|
| 702 | + Log.i("Jeffy", "Use extra config file:" |
---|
| 703 | + + EXTRA_CONFIG_FILE_NAME_CN); |
---|
| 704 | + if (InitTestData(new FileInputStream(configFile))) { |
---|
| 705 | + return true; |
---|
| 706 | + } |
---|
| 707 | + } |
---|
| 708 | + |
---|
| 709 | + // is = this.openFileInput(strXmlPath); |
---|
| 710 | + is = getAssets().open(CONFIG_FILE_NAME_CN); |
---|
| 711 | + }else{ |
---|
| 712 | + File configFile = new File(EXTRA_CONFIG_FILE_NAME); |
---|
| 713 | + if (configFile.exists()) { |
---|
| 714 | + Log.i("Jeffy", "Use extra config file:" |
---|
| 715 | + + EXTRA_CONFIG_FILE_NAME); |
---|
| 716 | + if (InitTestData(new FileInputStream(configFile))) { |
---|
| 717 | + return true; |
---|
| 718 | + } |
---|
| 719 | + } |
---|
| 720 | + // is = this.openFileInput(strXmlPath); |
---|
| 721 | + is = getAssets().open(CONFIG_FILE_NAME); |
---|
| 722 | + } |
---|
| 723 | + try { |
---|
| 724 | + xmldoc = new XmlDeal(is); |
---|
| 725 | + } catch (Exception e) { |
---|
| 726 | + Log.e(TAG, "parse the xmlfile is fail"); |
---|
| 727 | + return false; |
---|
| 728 | + } |
---|
| 729 | + } catch (IOException e) { |
---|
| 730 | + |
---|
| 731 | + e.printStackTrace(); |
---|
| 732 | + Log.e(TAG, "read the xmlfile is fail" + e.getMessage()); |
---|
| 733 | + // ForwardErrorActive(); |
---|
| 734 | + return false; |
---|
| 735 | + } |
---|
| 736 | + |
---|
| 737 | + if (is != null) { |
---|
| 738 | + try { |
---|
| 739 | + is.close(); |
---|
| 740 | + } catch (IOException e) { |
---|
| 741 | + e.printStackTrace(); |
---|
| 742 | + } |
---|
| 743 | + } |
---|
| 744 | + return true; |
---|
| 745 | + |
---|
| 746 | + } |
---|
| 747 | + |
---|
| 748 | + private String mAkeEnumToString(RESULT r) |
---|
| 749 | + { |
---|
| 750 | + |
---|
| 751 | + if (r == RESULT.OK) |
---|
| 752 | + { |
---|
| 753 | + return "OK"; |
---|
| 754 | + } else if (r == RESULT.NG) |
---|
| 755 | + { |
---|
| 756 | + return "NG"; |
---|
| 757 | + } else if (r == RESULT.SKIP) |
---|
| 758 | + { |
---|
| 759 | + return "SKIP"; |
---|
| 760 | + } else |
---|
| 761 | + { |
---|
| 762 | + return "UNDEF"; |
---|
| 763 | + } |
---|
| 764 | + |
---|
| 765 | + } |
---|
| 766 | + |
---|
| 767 | + |
---|
| 768 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import android.app.ActivityManager;
|
---|
| 4 | +import android.content.Context;
|
---|
| 5 | +
|
---|
| 6 | +import android.content.BroadcastReceiver;
|
---|
| 7 | +import android.content.ComponentName;
|
---|
| 8 | +import android.content.SharedPreferences;
|
---|
| 9 | +import android.content.SharedPreferences.Editor;
|
---|
| 10 | +import android.content.pm.PackageManager;
|
---|
| 11 | +import android.graphics.Path;
|
---|
| 12 | +import android.net.Uri;
|
---|
| 13 | +import android.content.Intent;
|
---|
| 14 | +import android.os.Build;
|
---|
| 15 | +import android.os.Environment;
|
---|
| 16 | +import android.os.Bundle;
|
---|
| 17 | +import android.util.Log;
|
---|
| 18 | +import java.io.File;
|
---|
| 19 | +import java.io.IOException;
|
---|
| 20 | +import java.io.RandomAccessFile;
|
---|
| 21 | +import java.util.ArrayList;
|
---|
| 22 | +
|
---|
| 23 | +
|
---|
| 24 | +
|
---|
| 25 | +
|
---|
| 26 | +public class EnableAppReceiver extends BroadcastReceiver
|
---|
| 27 | +{
|
---|
| 28 | + private final static String TAG = "EnableAppReceiver";
|
---|
| 29 | + public static final String PACKAGENAME = "packageName";
|
---|
| 30 | + public static final String CLASSNAME = "className";
|
---|
| 31 | + public static final String STATE = "state";
|
---|
| 32 | + private final static String ACTION_APP_STATE_CHANGE ="android.rockchip.devicetest.action.APP_STATE_CHANGE";
|
---|
| 33 | + @Override
|
---|
| 34 | + public void onReceive(Context context, Intent intent) {
|
---|
| 35 | + String action = intent.getAction();
|
---|
| 36 | + Uri uri = intent.getData();
|
---|
| 37 | + Log.d(TAG,"action ================================= "+action);
|
---|
| 38 | + Bundle extras = intent.getExtras();
|
---|
| 39 | + String packageName = extras.getString(PACKAGENAME);
|
---|
| 40 | + String className = extras.getString(CLASSNAME);
|
---|
| 41 | + int state = extras.getInt(STATE);
|
---|
| 42 | + if(packageName == null || className == null || state < 0) {
|
---|
| 43 | + return;
|
---|
| 44 | + }
|
---|
| 45 | + PackageManager pm = context.getPackageManager();
|
---|
| 46 | + if (pm == null) {
|
---|
| 47 | + return;
|
---|
| 48 | + }
|
---|
| 49 | + // check that device test app package is known to the PackageManager
|
---|
| 50 | + ComponentName cName = new ComponentName(packageName,
|
---|
| 51 | + className);
|
---|
| 52 | +
|
---|
| 53 | + try {
|
---|
| 54 | + pm.setComponentEnabledSetting(cName, state,
|
---|
| 55 | + PackageManager.DONT_KILL_APP);
|
---|
| 56 | + } catch (Exception e) {
|
---|
| 57 | +
|
---|
| 58 | + }
|
---|
| 59 | + }
|
---|
| 60 | +
|
---|
| 61 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +public class Ethernet2TestActivity extends EthernetTestActivity {
|
---|
| 4 | +
|
---|
| 5 | + @Override
|
---|
| 6 | + protected void preData() {
|
---|
| 7 | + mAssignIfaceName = "eth1";
|
---|
| 8 | + }
|
---|
| 9 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import android.app.Activity;
|
---|
| 4 | +import android.content.BroadcastReceiver;
|
---|
| 5 | +import android.content.Context;
|
---|
| 6 | +import android.content.Intent;
|
---|
| 7 | +import android.content.IntentFilter;
|
---|
| 8 | +import android.net.ConnectivityManager;
|
---|
| 9 | +import android.net.EthernetManager;
|
---|
| 10 | +import android.net.IpConfiguration;
|
---|
| 11 | +import android.net.IpConfiguration.IpAssignment;
|
---|
| 12 | +import android.net.IpConfiguration.ProxySettings;
|
---|
| 13 | +import android.net.StaticIpConfiguration;
|
---|
| 14 | +import android.net.NetworkInfo;
|
---|
| 15 | +import android.net.LinkAddress;
|
---|
| 16 | +import android.net.LinkProperties;
|
---|
| 17 | +import android.os.Build;
|
---|
| 18 | +import android.os.Bundle;
|
---|
| 19 | +import android.os.Handler;
|
---|
| 20 | +import android.os.Message;
|
---|
| 21 | +import android.os.SystemProperties;
|
---|
| 22 | +import android.text.TextUtils;
|
---|
| 23 | +import android.util.Log;
|
---|
| 24 | +import android.view.KeyEvent;
|
---|
| 25 | +import android.view.View;
|
---|
| 26 | +import android.widget.ProgressBar;
|
---|
| 27 | +import android.widget.TextView;
|
---|
| 28 | +
|
---|
| 29 | +import com.DeviceTest.helper.ConfigUtil;
|
---|
| 30 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 31 | +
|
---|
| 32 | +import java.io.BufferedReader;
|
---|
| 33 | +import java.io.IOException;
|
---|
| 34 | +import java.io.InputStream;
|
---|
| 35 | +import java.io.InputStreamReader;
|
---|
| 36 | +import java.lang.reflect.Method;
|
---|
| 37 | +import java.net.HttpURLConnection;
|
---|
| 38 | +import java.net.InetAddress;
|
---|
| 39 | +import java.net.MalformedURLException;
|
---|
| 40 | +import java.net.URL;
|
---|
| 41 | +import java.net.URLConnection;
|
---|
| 42 | +import java.util.ArrayList;
|
---|
| 43 | +
|
---|
| 44 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 45 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 46 | +
|
---|
| 47 | +public class EthernetTestActivity extends Activity {
|
---|
| 48 | + private static final String TAG = EthernetTestActivity.class.getSimpleName();
|
---|
| 49 | +
|
---|
| 50 | + public enum ETHERNET_STATE {
|
---|
| 51 | + ETHER_STATE_DISCONNECTED,
|
---|
| 52 | + ETHER_STATE_CONNECTING,
|
---|
| 53 | + ETHER_STATE_CONNECTED
|
---|
| 54 | + }
|
---|
| 55 | +
|
---|
| 56 | + private static final String HTTP_TEST_URL = "https://www.baidu.com/";
|
---|
| 57 | + private static final String nullIpInfo = "0.0.0.0";
|
---|
| 58 | + private static final String gettingIpInfo = "gettings...";
|
---|
| 59 | + private static final int TEST_GET_INFO_TIMEOUT_DELAY = 5000;
|
---|
| 60 | + private static final int TEST_FINISH_DELAY = 1500;
|
---|
| 61 | +
|
---|
| 62 | + private static final int MSG_GET_ETHERNET_STATE = 1;
|
---|
| 63 | + private static final int MSG_GET_ETHERNET_TIMEOUT = 2;
|
---|
| 64 | + private static final int MSG_HTTP_TEST = 3;
|
---|
| 65 | + private static final int MSG_TEST_FAILED = 4;
|
---|
| 66 | + private static final int MSG_TEST_SUCCESS = 5;
|
---|
| 67 | +
|
---|
| 68 | + private TextView txt_ethInfo;
|
---|
| 69 | + private TextView txt_result;
|
---|
| 70 | + private ProgressBar progressBar;
|
---|
| 71 | + private boolean mReadyToGetEthInfo;
|
---|
| 72 | + private boolean mStop;
|
---|
| 73 | +
|
---|
| 74 | + private EthernetManager mEthManager;
|
---|
| 75 | + private BroadcastReceiver mReceiver;
|
---|
| 76 | + private String mIfaceName;
|
---|
| 77 | + private String mEthIpAddress = null;
|
---|
| 78 | + private String mEthNetmask = null;
|
---|
| 79 | + private String mEthGateway = null;
|
---|
| 80 | + private String mEthdns1 = null;
|
---|
| 81 | + private String mEthdns2 = null;
|
---|
| 82 | +
|
---|
| 83 | + protected String mAssignIfaceName;
|
---|
| 84 | +
|
---|
| 85 | + protected void preData() {
|
---|
| 86 | + }
|
---|
| 87 | +
|
---|
| 88 | + private Handler mHandler = new Handler() {
|
---|
| 89 | + @Override
|
---|
| 90 | + public void handleMessage(Message msg) {
|
---|
| 91 | + if (mStop) {
|
---|
| 92 | + return;
|
---|
| 93 | + }
|
---|
| 94 | + switch (msg.what) {
|
---|
| 95 | + case MSG_GET_ETHERNET_STATE:
|
---|
| 96 | + Log.v(TAG, "MSG_GET_ETHERNET_STATE");
|
---|
| 97 | + if (mReadyToGetEthInfo) {
|
---|
| 98 | + handleEtherStateChange((ETHERNET_STATE) msg.obj);
|
---|
| 99 | + }
|
---|
| 100 | + break;
|
---|
| 101 | + case MSG_GET_ETHERNET_TIMEOUT:
|
---|
| 102 | + if (mReadyToGetEthInfo) {
|
---|
| 103 | + mReadyToGetEthInfo = false;
|
---|
| 104 | + Log.e(TAG, "MSG_GET_ETHERNET_TIMEOUT");
|
---|
| 105 | + mHandler.removeMessages(MSG_GET_ETHERNET_TIMEOUT);
|
---|
| 106 | + progressBar.setVisibility(View.GONE);
|
---|
| 107 | + txt_result.setText(R.string.EthernetGetInfoTimeoutFail);
|
---|
| 108 | + mHandler.sendEmptyMessageDelayed(MSG_TEST_FAILED, TEST_FINISH_DELAY);
|
---|
| 109 | + }
|
---|
| 110 | + break;
|
---|
| 111 | + case MSG_HTTP_TEST:
|
---|
| 112 | + Log.v(TAG, "MSG_HTTP_TEST");
|
---|
| 113 | + txt_result.setText("waiting test connect:\n" + HTTP_TEST_URL);
|
---|
| 114 | + progressBar.setVisibility(View.VISIBLE);
|
---|
| 115 | + new Thread(new Runnable() {
|
---|
| 116 | + @Override
|
---|
| 117 | + public void run() {
|
---|
| 118 | + mHandler.sendEmptyMessageDelayed(httpUrlTest() ? MSG_TEST_SUCCESS
|
---|
| 119 | + : MSG_TEST_FAILED, TEST_FINISH_DELAY);
|
---|
| 120 | + }
|
---|
| 121 | + }).start();
|
---|
| 122 | + break;
|
---|
| 123 | + case MSG_TEST_SUCCESS:
|
---|
| 124 | + Log.v(TAG, "MSG_TEST_SUCCESS");
|
---|
| 125 | + mHandler.removeMessages(MSG_TEST_SUCCESS);
|
---|
| 126 | + mStop = true;
|
---|
| 127 | + findViewById(R.id.btn_Pass).performClick();
|
---|
| 128 | + break;
|
---|
| 129 | + case MSG_TEST_FAILED:
|
---|
| 130 | + Log.v(TAG, "MSG_TEST_FAILED");
|
---|
| 131 | + mHandler.removeMessages(MSG_TEST_FAILED);
|
---|
| 132 | + mStop = true;
|
---|
| 133 | + findViewById(R.id.btn_Fail).performClick();
|
---|
| 134 | + break;
|
---|
| 135 | + default:
|
---|
| 136 | + break;
|
---|
| 137 | + }
|
---|
| 138 | + }
|
---|
| 139 | + };
|
---|
| 140 | +
|
---|
| 141 | + protected void onCreate(Bundle savedInstanceState) {
|
---|
| 142 | + super.onCreate(savedInstanceState);
|
---|
| 143 | + // requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 144 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 145 | + setContentView(R.layout.ethernettest);
|
---|
| 146 | +
|
---|
| 147 | + preData();
|
---|
| 148 | + txt_ethInfo = (TextView) findViewById(R.id.txt_ethInfo);
|
---|
| 149 | + txt_result = (TextView) findViewById(R.id.txt_result);
|
---|
| 150 | + progressBar = (ProgressBar) findViewById(R.id.progress);
|
---|
| 151 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 152 | + findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 153 | + findViewById(R.id.btn_Fail).setVisibility(View.INVISIBLE);
|
---|
| 154 | +
|
---|
| 155 | + mEthManager = (EthernetManager) getSystemService(Context.ETHERNET_SERVICE);
|
---|
| 156 | + if (null == mEthManager) {
|
---|
| 157 | + Log.e(TAG, "get ethernet manager failed");
|
---|
| 158 | + txt_result.setText(R.string.EthernetManagerFail);
|
---|
| 159 | + mHandler.sendEmptyMessageDelayed(MSG_TEST_FAILED, TEST_FINISH_DELAY);
|
---|
| 160 | + return;
|
---|
| 161 | + }
|
---|
| 162 | + String[] ifaces = new String[]{"eth0"};
|
---|
| 163 | + if (Build.VERSION.SDK_INT >= ConfigUtil.ANDROID_SDK_VERSION_P) {
|
---|
| 164 | + try {
|
---|
| 165 | + Method m = EthernetManager.class.getMethod("getAvailableInterfaces", null);
|
---|
| 166 | + ifaces = (String[]) m.invoke(mEthManager, null);
|
---|
| 167 | + } catch (Exception e) {
|
---|
| 168 | + e.printStackTrace();
|
---|
| 169 | + ifaces = null;
|
---|
| 170 | + }
|
---|
| 171 | + }
|
---|
| 172 | + if (ifaces.length > 0) {
|
---|
| 173 | + if (ConfigUtil.isSpecialEvb() && TextUtils.isEmpty(mAssignIfaceName)) {
|
---|
| 174 | + mAssignIfaceName = "eth0";
|
---|
| 175 | + }
|
---|
| 176 | + if (TextUtils.isEmpty(mAssignIfaceName)) {
|
---|
| 177 | + mIfaceName = ifaces[0];//"eth0";
|
---|
| 178 | + } else {
|
---|
| 179 | + for (String iface : ifaces) {
|
---|
| 180 | + if (null != iface && iface.equals(mAssignIfaceName)) {
|
---|
| 181 | + mIfaceName = iface;
|
---|
| 182 | + break;
|
---|
| 183 | + }
|
---|
| 184 | + }
|
---|
| 185 | + }
|
---|
| 186 | + }
|
---|
| 187 | +
|
---|
| 188 | + Log.v(TAG, "mIfaceName=" + mIfaceName);
|
---|
| 189 | + if (null == mIfaceName) {
|
---|
| 190 | + Log.e(TAG, "get ethernet ifaceName failed");
|
---|
| 191 | + txt_result.setText(R.string.EthernetInterfacesFail);
|
---|
| 192 | + mHandler.sendEmptyMessageDelayed(MSG_TEST_FAILED, TEST_FINISH_DELAY);
|
---|
| 193 | + return;
|
---|
| 194 | + }
|
---|
| 195 | + mReadyToGetEthInfo = true;
|
---|
| 196 | + progressBar.setVisibility(View.VISIBLE);
|
---|
| 197 | + mReceiver = new MyBroadcastReceiver();
|
---|
| 198 | + mHandler.sendEmptyMessageDelayed(MSG_GET_ETHERNET_TIMEOUT, TEST_GET_INFO_TIMEOUT_DELAY);
|
---|
| 199 | + }
|
---|
| 200 | +
|
---|
| 201 | + protected void onResume() {
|
---|
| 202 | + super.onResume();
|
---|
| 203 | +
|
---|
| 204 | + if (null != mReceiver) {
|
---|
| 205 | + IntentFilter localIntentFilter = new IntentFilter();
|
---|
| 206 | + localIntentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
---|
| 207 | + registerReceiver(mReceiver, localIntentFilter);
|
---|
| 208 | + }
|
---|
| 209 | + }
|
---|
| 210 | +
|
---|
| 211 | + public void onPause() {
|
---|
| 212 | + super.onPause();
|
---|
| 213 | +
|
---|
| 214 | + if (null != mReceiver) {
|
---|
| 215 | + unregisterReceiver(mReceiver);
|
---|
| 216 | + }
|
---|
| 217 | + }
|
---|
| 218 | +
|
---|
| 219 | + @Override
|
---|
| 220 | + protected void onDestroy() {
|
---|
| 221 | + super.onDestroy();
|
---|
| 222 | + mReadyToGetEthInfo = false;
|
---|
| 223 | + mStop = false;
|
---|
| 224 | + mHandler.removeMessages(MSG_GET_ETHERNET_STATE);
|
---|
| 225 | + mHandler.removeMessages(MSG_GET_ETHERNET_TIMEOUT);
|
---|
| 226 | + mHandler.removeMessages(MSG_TEST_FAILED);
|
---|
| 227 | + mHandler.removeMessages(MSG_TEST_SUCCESS);
|
---|
| 228 | + }
|
---|
| 229 | +
|
---|
| 230 | + private void getEthInfo() throws Exception {
|
---|
| 231 | + /*
|
---|
| 232 | + mEthHwAddress = mEthManager.getEthernetHwaddr(mEthManager.getEthernetIfaceName());
|
---|
| 233 | + if (mEthHwAddress == null) mEthHwAddress = nullIpInfo;
|
---|
| 234 | + */
|
---|
| 235 | + IpConfiguration ipConfiguration = null;
|
---|
| 236 | + if (Build.VERSION.SDK_INT >= ConfigUtil.ANDROID_SDK_VERSION_P) {
|
---|
| 237 | + Method m = EthernetManager.class.getMethod("getConfiguration", String.class);
|
---|
| 238 | + ipConfiguration = (IpConfiguration) m.invoke(mEthManager, mIfaceName);
|
---|
| 239 | + } else {
|
---|
| 240 | + Method m = EthernetManager.class.getMethod("getConfiguration", null);
|
---|
| 241 | + ipConfiguration = (IpConfiguration) m.invoke(mEthManager, null);
|
---|
| 242 | + }
|
---|
| 243 | + IpAssignment mode = ipConfiguration.getIpAssignment();
|
---|
| 244 | + if (mode == IpAssignment.DHCP || mode == IpAssignment.UNASSIGNED) {
|
---|
| 245 | + getEthInfoFromDhcp();
|
---|
| 246 | + } else if (mode == IpAssignment.STATIC) {
|
---|
| 247 | + getEthInfoFromStaticIp();
|
---|
| 248 | + }
|
---|
| 249 | + }
|
---|
| 250 | +
|
---|
| 251 | + public void getEthInfoFromDhcp() throws Exception {
|
---|
| 252 | + boolean isSdkAfterO = Build.VERSION.SDK_INT >= ConfigUtil.ANDROID_SDK_VERSION_P;
|
---|
| 253 | + String tempIpInfo;
|
---|
| 254 | + if (isSdkAfterO) {
|
---|
| 255 | + Method m = EthernetManager.class.getMethod("getIpAddress", String.class);
|
---|
| 256 | + tempIpInfo = (String) m.invoke(mEthManager, mIfaceName);
|
---|
| 257 | + } else {
|
---|
| 258 | + Method m = EthernetManager.class.getMethod("getIpAddress", null);
|
---|
| 259 | + tempIpInfo = (String) m.invoke(mEthManager, null);
|
---|
| 260 | + }
|
---|
| 261 | +
|
---|
| 262 | + if ((tempIpInfo != null) && (!tempIpInfo.equals(""))) {
|
---|
| 263 | + mEthIpAddress = tempIpInfo;
|
---|
| 264 | + } else {
|
---|
| 265 | + mEthIpAddress = nullIpInfo;
|
---|
| 266 | + }
|
---|
| 267 | +
|
---|
| 268 | + if (isSdkAfterO) {
|
---|
| 269 | + Method m = EthernetManager.class.getMethod("getNetmask", String.class);
|
---|
| 270 | + tempIpInfo = (String) m.invoke(mEthManager, mIfaceName);
|
---|
| 271 | + } else {
|
---|
| 272 | + Method m = EthernetManager.class.getMethod("getNetmask", null);
|
---|
| 273 | + tempIpInfo = (String) m.invoke(mEthManager, null);
|
---|
| 274 | + }
|
---|
| 275 | +
|
---|
| 276 | + if ((tempIpInfo != null) && (!tempIpInfo.equals(""))) {
|
---|
| 277 | + mEthNetmask = tempIpInfo;
|
---|
| 278 | + } else {
|
---|
| 279 | + mEthNetmask = nullIpInfo;
|
---|
| 280 | + }
|
---|
| 281 | +
|
---|
| 282 | + if (isSdkAfterO) {
|
---|
| 283 | + Method m = EthernetManager.class.getMethod("getGateway", String.class);
|
---|
| 284 | + tempIpInfo = (String) m.invoke(mEthManager, mIfaceName);
|
---|
| 285 | + } else {
|
---|
| 286 | + Method m = EthernetManager.class.getMethod("getGateway", null);
|
---|
| 287 | + tempIpInfo = (String) m.invoke(mEthManager, null);
|
---|
| 288 | + }
|
---|
| 289 | + if ((tempIpInfo != null) && (!tempIpInfo.equals(""))) {
|
---|
| 290 | + mEthGateway = tempIpInfo;
|
---|
| 291 | + } else {
|
---|
| 292 | + mEthGateway = nullIpInfo;
|
---|
| 293 | + }
|
---|
| 294 | +
|
---|
| 295 | + if (isSdkAfterO) {
|
---|
| 296 | + Method m = EthernetManager.class.getMethod("getDns", String.class);
|
---|
| 297 | + tempIpInfo = (String) m.invoke(mEthManager, mIfaceName);
|
---|
| 298 | + } else {
|
---|
| 299 | + Method m = EthernetManager.class.getMethod("getDns", null);
|
---|
| 300 | + tempIpInfo = (String) m.invoke(mEthManager, null);
|
---|
| 301 | + }
|
---|
| 302 | + if ((tempIpInfo != null) && (!tempIpInfo.equals(""))) {
|
---|
| 303 | + String data[] = tempIpInfo.split(",");
|
---|
| 304 | + mEthdns1 = data[0];
|
---|
| 305 | + if (data.length <= 1) {
|
---|
| 306 | + mEthdns2 = nullIpInfo;
|
---|
| 307 | + } else {
|
---|
| 308 | + mEthdns2 = data[1];
|
---|
| 309 | + }
|
---|
| 310 | + } else {
|
---|
| 311 | + mEthdns1 = nullIpInfo;
|
---|
| 312 | + }
|
---|
| 313 | + }
|
---|
| 314 | +
|
---|
| 315 | + public void getEthInfoFromStaticIp() throws Exception {
|
---|
| 316 | + IpConfiguration ipConfiguration = null;
|
---|
| 317 | + if (Build.VERSION.SDK_INT >= ConfigUtil.ANDROID_SDK_VERSION_P) {
|
---|
| 318 | + Method m = EthernetManager.class.getMethod("getConfiguration", String.class);
|
---|
| 319 | + ipConfiguration = (IpConfiguration) m.invoke(mEthManager, mIfaceName);
|
---|
| 320 | + } else {
|
---|
| 321 | + Method m = EthernetManager.class.getMethod("getConfiguration", null);
|
---|
| 322 | + ipConfiguration = (IpConfiguration) m.invoke(mEthManager, null);
|
---|
| 323 | + }
|
---|
| 324 | + StaticIpConfiguration staticIpConfiguration = ipConfiguration.getStaticIpConfiguration();
|
---|
| 325 | +
|
---|
| 326 | + if (staticIpConfiguration == null) {
|
---|
| 327 | + return;
|
---|
| 328 | + }
|
---|
| 329 | + /*
|
---|
| 330 | + LinkAddress ipAddress = staticIpConfiguration.ipAddress;
|
---|
| 331 | + InetAddress gateway = staticIpConfiguration.gateway;
|
---|
| 332 | + ArrayList<InetAddress> dnsServers = staticIpConfiguration.dnsServers;
|
---|
| 333 | +
|
---|
| 334 | + if (ipAddress != null) {
|
---|
| 335 | + mEthIpAddress = ipAddress.getAddress().getHostAddress();
|
---|
| 336 | + mEthNetmask = interMask2String(ipAddress.getPrefixLength());
|
---|
| 337 | + }
|
---|
| 338 | + if (gateway != null) {
|
---|
| 339 | + mEthGateway = gateway.getHostAddress();
|
---|
| 340 | + }
|
---|
| 341 | + mEthdns1 = dnsServers.get(0).getHostAddress();
|
---|
| 342 | +
|
---|
| 343 | + if (dnsServers.size() > 1) { // 只保留两个
|
---|
| 344 | + mEthdns2 = dnsServers.get(1).getHostAddress();
|
---|
| 345 | + }
|
---|
| 346 | + */
|
---|
| 347 | + }
|
---|
| 348 | +
|
---|
| 349 | + private void handleEtherStateChange(ETHERNET_STATE EtherState, long delayMillis) {
|
---|
| 350 | + mHandler.removeMessages(MSG_GET_ETHERNET_STATE);
|
---|
| 351 | + if (delayMillis > 0) {
|
---|
| 352 | + Message msg = new Message();
|
---|
| 353 | + msg.what = MSG_GET_ETHERNET_STATE;
|
---|
| 354 | + msg.obj = EtherState;
|
---|
| 355 | + mHandler.sendMessageDelayed(msg, delayMillis);
|
---|
| 356 | + } else {
|
---|
| 357 | + handleEtherStateChange(EtherState);
|
---|
| 358 | + }
|
---|
| 359 | + }
|
---|
| 360 | +
|
---|
| 361 | + private void handleEtherStateChange(ETHERNET_STATE EtherState) {
|
---|
| 362 | + Log.v(TAG, "curEtherState" + EtherState);
|
---|
| 363 | + progressBar.setVisibility(View.VISIBLE);
|
---|
| 364 | + switch (EtherState) {
|
---|
| 365 | + case ETHER_STATE_DISCONNECTED:
|
---|
| 366 | + /*mEthIpAddress = nullIpInfo;
|
---|
| 367 | + mEthNetmask = nullIpInfo;
|
---|
| 368 | + mEthGateway = nullIpInfo;
|
---|
| 369 | + mEthdns1 = nullIpInfo;
|
---|
| 370 | + mEthdns2 = nullIpInfo;
|
---|
| 371 | + refreshUI();
|
---|
| 372 | + break;*/
|
---|
| 373 | + case ETHER_STATE_CONNECTING:
|
---|
| 374 | + mEthIpAddress = gettingIpInfo;
|
---|
| 375 | + mEthNetmask = gettingIpInfo;
|
---|
| 376 | + mEthGateway = gettingIpInfo;
|
---|
| 377 | + mEthdns1 = gettingIpInfo;
|
---|
| 378 | + mEthdns2 = gettingIpInfo;
|
---|
| 379 | + txt_ethInfo.setText(gettingIpInfo);
|
---|
| 380 | + break;
|
---|
| 381 | + case ETHER_STATE_CONNECTED:
|
---|
| 382 | + try {
|
---|
| 383 | + getEthInfo();
|
---|
| 384 | + refreshUI();
|
---|
| 385 | + } catch (Exception e) {
|
---|
| 386 | + e.printStackTrace();
|
---|
| 387 | + }
|
---|
| 388 | + break;
|
---|
| 389 | + default:
|
---|
| 390 | + break;
|
---|
| 391 | + }
|
---|
| 392 | + }
|
---|
| 393 | +
|
---|
| 394 | + private void refreshUI() {
|
---|
| 395 | + StringBuilder sb = new StringBuilder();
|
---|
| 396 | + sb.append(mIfaceName + "\n");
|
---|
| 397 | + sb.append("ip: " + mEthIpAddress + "\n");
|
---|
| 398 | + sb.append("netmask: " + mEthNetmask + "\n");
|
---|
| 399 | + sb.append("gateway: " + mEthGateway + "\n");
|
---|
| 400 | + sb.append("dns1: " + mEthdns1 + "\n");
|
---|
| 401 | + sb.append("dns2: " + mEthdns2 + "\n");
|
---|
| 402 | + Log.v(TAG, sb.toString());
|
---|
| 403 | + txt_ethInfo.setText(sb.toString());
|
---|
| 404 | + progressBar.setVisibility(View.GONE);
|
---|
| 405 | + if (null == mEthIpAddress || mEthIpAddress.equals(nullIpInfo) || mEthIpAddress.equals(gettingIpInfo)
|
---|
| 406 | + || null == mEthNetmask || mEthNetmask.equals(nullIpInfo) || mEthNetmask.equals(gettingIpInfo)
|
---|
| 407 | + || null == mEthGateway || mEthGateway.equals(nullIpInfo) || mEthGateway.equals(gettingIpInfo)
|
---|
| 408 | + || null == mEthdns1 || mEthdns1.equals(nullIpInfo) || mEthdns1.equals(gettingIpInfo)
|
---|
| 409 | + /*|| null == mEthdns2 || mEthdns2.equals(nullIpInfo) || mEthdns2.equals(gettingIpInfo)*/) {
|
---|
| 410 | +
|
---|
| 411 | + } else if (mReadyToGetEthInfo) {
|
---|
| 412 | + mReadyToGetEthInfo = false;
|
---|
| 413 | + mHandler.removeMessages(MSG_GET_ETHERNET_TIMEOUT);
|
---|
| 414 | + mHandler.sendEmptyMessage(MSG_HTTP_TEST);
|
---|
| 415 | + }
|
---|
| 416 | + }
|
---|
| 417 | +
|
---|
| 418 | + //将子网掩码转换成ip子网掩码形式,比如输入32输出为255.255.255.255
|
---|
| 419 | + public String interMask2String(int prefixLength) {
|
---|
| 420 | + String netMask = null;
|
---|
| 421 | + int inetMask = prefixLength;
|
---|
| 422 | +
|
---|
| 423 | + int part = inetMask / 8;
|
---|
| 424 | + int remainder = inetMask % 8;
|
---|
| 425 | + int sum = 0;
|
---|
| 426 | +
|
---|
| 427 | + for (int i = 8; i > 8 - remainder; i--) {
|
---|
| 428 | + sum = sum + (int) Math.pow(2, i - 1);
|
---|
| 429 | + }
|
---|
| 430 | +
|
---|
| 431 | + if (part == 0) {
|
---|
| 432 | + netMask = sum + ".0.0.0";
|
---|
| 433 | + } else if (part == 1) {
|
---|
| 434 | + netMask = "255." + sum + ".0.0";
|
---|
| 435 | + } else if (part == 2) {
|
---|
| 436 | + netMask = "255.255." + sum + ".0";
|
---|
| 437 | + } else if (part == 3) {
|
---|
| 438 | + netMask = "255.255.255." + sum;
|
---|
| 439 | + } else if (part == 4) {
|
---|
| 440 | + netMask = "255.255.255.255";
|
---|
| 441 | + }
|
---|
| 442 | +
|
---|
| 443 | + return netMask;
|
---|
| 444 | + }
|
---|
| 445 | +
|
---|
| 446 | + private boolean httpUrlTest() {
|
---|
| 447 | + HttpURLConnection conn = null;
|
---|
| 448 | + InputStream is = null;
|
---|
| 449 | + String resultData = "";
|
---|
| 450 | + try {
|
---|
| 451 | + URL url = new URL(HTTP_TEST_URL);
|
---|
| 452 | + conn = (HttpURLConnection) url.openConnection();
|
---|
| 453 | + conn.setDoInput(true);
|
---|
| 454 | + conn.setDoOutput(true);
|
---|
| 455 | + conn.setUseCaches(false);
|
---|
| 456 | + conn.setRequestMethod("GET");
|
---|
| 457 | + conn.setConnectTimeout(10000);
|
---|
| 458 | + conn.setReadTimeout(1000);
|
---|
| 459 | + if (HttpURLConnection.HTTP_OK == conn.getResponseCode()) {
|
---|
| 460 | + is = conn.getInputStream();
|
---|
| 461 | + InputStreamReader isr = new InputStreamReader(is);
|
---|
| 462 | + BufferedReader bufferReader = new BufferedReader(isr);
|
---|
| 463 | + String inputLine = "";
|
---|
| 464 | + while ((inputLine = bufferReader.readLine()) != null) {
|
---|
| 465 | + resultData += inputLine + "\n";
|
---|
| 466 | + }
|
---|
| 467 | + Log.v(TAG, "http respond:" + resultData);
|
---|
| 468 | + return resultData.length() > 20;
|
---|
| 469 | + } else {
|
---|
| 470 | + Log.e(TAG, "==========error code:" + conn.getResponseCode());
|
---|
| 471 | + }
|
---|
| 472 | + } catch (MalformedURLException e) {
|
---|
| 473 | + e.printStackTrace();
|
---|
| 474 | + } catch (IOException e) {
|
---|
| 475 | + e.printStackTrace();
|
---|
| 476 | + } catch (Exception e) {
|
---|
| 477 | + e.printStackTrace();
|
---|
| 478 | + } finally {
|
---|
| 479 | + if (is != null) {
|
---|
| 480 | + try {
|
---|
| 481 | + is.close();
|
---|
| 482 | + } catch (IOException e) {
|
---|
| 483 | + // TODO Auto-generated catch block
|
---|
| 484 | + e.printStackTrace();
|
---|
| 485 | + }
|
---|
| 486 | + }
|
---|
| 487 | + if (conn != null) {
|
---|
| 488 | + conn.disconnect();
|
---|
| 489 | + }
|
---|
| 490 | + }
|
---|
| 491 | + return false;
|
---|
| 492 | + }
|
---|
| 493 | +
|
---|
| 494 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 495 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 496 | + return false;
|
---|
| 497 | + }
|
---|
| 498 | + return super.dispatchKeyEvent(event);
|
---|
| 499 | + }
|
---|
| 500 | +
|
---|
| 501 | + class MyBroadcastReceiver extends BroadcastReceiver {
|
---|
| 502 | +
|
---|
| 503 | + public void onReceive(Context context, Intent intent) {
|
---|
| 504 | + if (!mReadyToGetEthInfo || mStop) {
|
---|
| 505 | + return;
|
---|
| 506 | + }
|
---|
| 507 | + String action = intent.getAction();
|
---|
| 508 | + Log.v(TAG, "action:" + action);
|
---|
| 509 | + if (ConnectivityManager.CONNECTIVITY_ACTION.equals(action)) {
|
---|
| 510 | + NetworkInfo info = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
|
---|
| 511 | + Log.v(TAG, "===" + info.toString());
|
---|
| 512 | + if (null != info && ConnectivityManager.TYPE_ETHERNET == info.getType()) {
|
---|
| 513 | + if (NetworkInfo.State.CONNECTED == info.getState()) {
|
---|
| 514 | + handleEtherStateChange(ETHERNET_STATE.ETHER_STATE_CONNECTED, 0);
|
---|
| 515 | + } else if (NetworkInfo.State.DISCONNECTED == info.getState()) {
|
---|
| 516 | + handleEtherStateChange(ETHERNET_STATE.ETHER_STATE_DISCONNECTED, 0);
|
---|
| 517 | + }
|
---|
| 518 | + }
|
---|
| 519 | + }
|
---|
| 520 | + }
|
---|
| 521 | + }
|
---|
| 522 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 7 | +
|
---|
| 8 | +import android.app.Activity;
|
---|
| 9 | +import android.content.Intent;
|
---|
| 10 | +import android.os.Bundle;
|
---|
| 11 | +
|
---|
| 12 | +import android.view.KeyEvent;
|
---|
| 13 | +import android.view.MotionEvent;
|
---|
| 14 | +import android.view.View;
|
---|
| 15 | +import android.view.Window;
|
---|
| 16 | +import android.widget.TextView;
|
---|
| 17 | +import android.util.Log;
|
---|
| 18 | +
|
---|
| 19 | +public class FMRadioTestActivity extends Activity {
|
---|
| 20 | + private static final int REQUEST_START_FM_RADIO = 1001;
|
---|
| 21 | + private static final int KEY_BACK = 4;
|
---|
| 22 | + TextView mResult;
|
---|
| 23 | +
|
---|
| 24 | +
|
---|
| 25 | + protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
---|
| 26 | + super.onActivityResult(requestCode, resultCode, data);
|
---|
| 27 | + if (requestCode == REQUEST_START_FM_RADIO)
|
---|
| 28 | + mResult.setVisibility(View.VISIBLE);
|
---|
| 29 | + }
|
---|
| 30 | +
|
---|
| 31 | +
|
---|
| 32 | + public void onCreate(Bundle paramBundle) {
|
---|
| 33 | + super.onCreate(paramBundle);
|
---|
| 34 | +
|
---|
| 35 | + setTitle(getTitle() + "----("
|
---|
| 36 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")");
|
---|
| 37 | + //requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 38 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 39 | +
|
---|
| 40 | + setContentView(R.layout.fmradiotest);
|
---|
| 41 | +
|
---|
| 42 | + mResult = (TextView) findViewById(R.id.FMRadioTestResult);
|
---|
| 43 | +
|
---|
| 44 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 45 | + }
|
---|
| 46 | +
|
---|
| 47 | +
|
---|
| 48 | + public boolean onKeyDown(int keyCode, KeyEvent keyEvent) {
|
---|
| 49 | + if (keyCode == KEY_BACK)
|
---|
| 50 | + setResult(KEY_BACK);
|
---|
| 51 | + return super.onKeyDown(keyCode, keyEvent);
|
---|
| 52 | + }
|
---|
| 53 | +
|
---|
| 54 | +
|
---|
| 55 | + public boolean onTouchEvent(MotionEvent event) {
|
---|
| 56 | + if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
---|
| 57 | + Intent intent = new Intent("com.rk.FMRadio");
|
---|
| 58 | + startActivityIfNeeded(intent, REQUEST_START_FM_RADIO);
|
---|
| 59 | + }
|
---|
| 60 | + return super.onTouchEvent(event);
|
---|
| 61 | + }
|
---|
| 62 | +
|
---|
| 63 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 64 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 65 | + return false;
|
---|
| 66 | + }
|
---|
| 67 | + return super.dispatchKeyEvent(event);
|
---|
| 68 | + }
|
---|
| 69 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import java.io.BufferedReader;
|
---|
| 7 | +import java.io.File;
|
---|
| 8 | +import java.io.FileInputStream;
|
---|
| 9 | +import java.io.FileOutputStream;
|
---|
| 10 | +import java.io.IOException;
|
---|
| 11 | +import java.io.InputStreamReader;
|
---|
| 12 | +import java.io.OutputStreamWriter;
|
---|
| 13 | +import java.util.Collections;
|
---|
| 14 | +import java.util.Comparator;
|
---|
| 15 | +import java.util.List;
|
---|
| 16 | +
|
---|
| 17 | +import com.DeviceTest.WifiTestActivity.MyBroadcastReceiver;
|
---|
| 18 | +import com.DeviceTest.helper.Recorder;
|
---|
| 19 | +import com.DeviceTest.helper.SystemUtil;
|
---|
| 20 | +import com.DeviceTest.helper.VUMeter;
|
---|
| 21 | +import com.DeviceTest.view.GsensorBall;
|
---|
| 22 | +import com.DeviceTest.view.KeyTestView;
|
---|
| 23 | +import com.DeviceTest.view.TestView;
|
---|
| 24 | +
|
---|
| 25 | +import android.app.Activity;
|
---|
| 26 | +import android.app.Dialog;
|
---|
| 27 | +import android.app.KeyguardManager;
|
---|
| 28 | +import android.app.KeyguardManager.KeyguardLock;
|
---|
| 29 | +import android.content.BroadcastReceiver;
|
---|
| 30 | +import android.content.ContentProviderClient;
|
---|
| 31 | +import android.content.Context;
|
---|
| 32 | +import android.content.Intent;
|
---|
| 33 | +import android.content.IntentFilter;
|
---|
| 34 | +import android.content.res.Resources;
|
---|
| 35 | +import android.graphics.PixelFormat;
|
---|
| 36 | +import android.hardware.Camera;
|
---|
| 37 | +import android.hardware.Sensor;
|
---|
| 38 | +import android.hardware.SensorEvent;
|
---|
| 39 | +import android.hardware.SensorEventListener;
|
---|
| 40 | +import android.hardware.SensorManager;
|
---|
| 41 | +import android.media.AudioManager;
|
---|
| 42 | +import android.net.wifi.ScanResult;
|
---|
| 43 | +import android.net.wifi.WifiManager;
|
---|
| 44 | +import android.os.BatteryManager;
|
---|
| 45 | +import android.os.Build;
|
---|
| 46 | +import android.os.Bundle;
|
---|
| 47 | +import android.os.Environment;
|
---|
| 48 | +import android.os.Handler;
|
---|
| 49 | +import android.os.Message;
|
---|
| 50 | +import android.os.StatFs;
|
---|
| 51 | +import android.os.storage.StorageManager;
|
---|
| 52 | +import android.os.storage.StorageVolume;
|
---|
| 53 | +import android.os.storage.StorageEventListener;
|
---|
| 54 | +import android.os.SystemProperties;
|
---|
| 55 | +import android.text.format.Formatter;
|
---|
| 56 | +import android.util.Log;
|
---|
| 57 | +import android.view.Gravity;
|
---|
| 58 | +import android.view.KeyEvent;
|
---|
| 59 | +import android.view.LayoutInflater;
|
---|
| 60 | +import android.view.SurfaceHolder;
|
---|
| 61 | +import android.view.SurfaceView;
|
---|
| 62 | +import android.view.View;
|
---|
| 63 | +import android.view.View.OnKeyListener;
|
---|
| 64 | +import android.view.Window;
|
---|
| 65 | +import android.view.WindowManager;
|
---|
| 66 | +import android.view.View.OnClickListener;
|
---|
| 67 | +import android.widget.Button;
|
---|
| 68 | +import android.widget.ProgressBar;
|
---|
| 69 | +import android.widget.TextView;
|
---|
| 70 | +
|
---|
| 71 | +import android.os.ServiceManager;
|
---|
| 72 | +import java.lang.reflect.Array;
|
---|
| 73 | +import java.lang.reflect.InvocationTargetException;
|
---|
| 74 | +import java.lang.reflect.Method;
|
---|
| 75 | +
|
---|
| 76 | +
|
---|
| 77 | +public class FirstRun extends Activity implements SurfaceHolder.Callback{
|
---|
| 78 | + private static final String TAG = "FirstRun";
|
---|
| 79 | +
|
---|
| 80 | + public enum TEST_STATUS{
|
---|
| 81 | + WAITING,
|
---|
| 82 | + TESTING,
|
---|
| 83 | + FAILED,
|
---|
| 84 | + SUCCEED,
|
---|
| 85 | + }
|
---|
| 86 | + private TEST_STATUS wifi_test_status = TEST_STATUS.WAITING;
|
---|
| 87 | + private TEST_STATUS sdcard_test_status = TEST_STATUS.WAITING;
|
---|
| 88 | + private TEST_STATUS otg_test_status = TEST_STATUS.WAITING;
|
---|
| 89 | +
|
---|
| 90 | + private View v = null;
|
---|
| 91 | + private WindowManager wm = null;
|
---|
| 92 | + KeyguardLock kl = null;
|
---|
| 93 | +
|
---|
| 94 | + private Resources mRes;
|
---|
| 95 | + private StorageManager mStorageManager = null;
|
---|
| 96 | +
|
---|
| 97 | + private int testszie = 21;
|
---|
| 98 | + private TextView productname = null;
|
---|
| 99 | + private TextView productversion = null;
|
---|
| 100 | + private TextView nandstorage = null;
|
---|
| 101 | + private TextView availablenandstorage = null;
|
---|
| 102 | +
|
---|
| 103 | + private TestView mSDcardTestView = null;
|
---|
| 104 | + private TestView mUsbHostTestView = null;
|
---|
| 105 | + private TestView mWifiTestView = null;
|
---|
| 106 | + private WifiManager mWifiManager;
|
---|
| 107 | + private BroadcastReceiver mWifiReceiver;
|
---|
| 108 | + private Handler mWifiHandler;
|
---|
| 109 | + private boolean mReadyToTest = false;
|
---|
| 110 | + private final static int WIFI_MSG_SCAN = 0;
|
---|
| 111 | +
|
---|
| 112 | + private SensorManager sensorManager;
|
---|
| 113 | + private SensorEventListener lsn = null;
|
---|
| 114 | + private GsensorBall mGsensorBall;
|
---|
| 115 | + private TextView gsensortext = null;
|
---|
| 116 | +
|
---|
| 117 | + private Camera mCameraDevice;
|
---|
| 118 | + private View nocamera;
|
---|
| 119 | + private boolean hasCamera = false;
|
---|
| 120 | + private ContentProviderClient mMediaProviderClient;
|
---|
| 121 | + private SurfaceView mSurfaceView;
|
---|
| 122 | + private Button mSwitchBut;
|
---|
| 123 | + private SurfaceHolder mSurfaceHolder = null;
|
---|
| 124 | + private int mNumberOfCameras = 0;
|
---|
| 125 | + private int mCurrentCameraId = 0;
|
---|
| 126 | +
|
---|
| 127 | + private final static int MAXIMUM_BRIGHTNESS = 255;
|
---|
| 128 | + private final static int MINIMUM_BRIGHTNESS = 2;
|
---|
| 129 | + private final static int ONE_STAGE = 5;
|
---|
| 130 | +
|
---|
| 131 | + private ProgressBar progressBar;
|
---|
| 132 | + private Button brightnessbut;
|
---|
| 133 | + private boolean isTestBrightness = false;
|
---|
| 134 | + private BrightnessHandler mBrightnessHandler = new BrightnessHandler();
|
---|
| 135 | + private static final int BRIGHTNESS_MSG = 0;
|
---|
| 136 | +
|
---|
| 137 | + private VUMeter mVUMeter;
|
---|
| 138 | + private Button recordtestbutton;
|
---|
| 139 | + private TextView recordtext;
|
---|
| 140 | + private Recorder mRecorder;
|
---|
| 141 | + private AudioManager mAudioManager;
|
---|
| 142 | + private int mOldVolume;
|
---|
| 143 | + private boolean mSpeakerOn = false;
|
---|
| 144 | + private RecordHandler mRecordHandler = new RecordHandler();
|
---|
| 145 | + private final static int RECORD_TIME = 5;
|
---|
| 146 | +
|
---|
| 147 | + private static final String CURRENT_PATH = "/sys/class/power_supply/battery/capacity";
|
---|
| 148 | + PowerBroadcastReceiver mPowerBroadcastReceiver = new PowerBroadcastReceiver();
|
---|
| 149 | + private TextView mChargeStatus;
|
---|
| 150 | + private TextView mVoltage;
|
---|
| 151 | + private TextView mCurrent;
|
---|
| 152 | + private TextView mCapacity;
|
---|
| 153 | + private TextView mPlug;
|
---|
| 154 | +
|
---|
| 155 | + private KeyTestView mKeyTestView;
|
---|
| 156 | + private String mKeyNames[] = { "HOME",
|
---|
| 157 | + "MENU",
|
---|
| 158 | + "VOLUME+",
|
---|
| 159 | + "VOLUME-",
|
---|
| 160 | + "BACK",
|
---|
| 161 | + "SEARCH"};
|
---|
| 162 | + private int mKeyCodes[] = { KeyEvent.KEYCODE_HOME,
|
---|
| 163 | + KeyEvent.KEYCODE_MENU,
|
---|
| 164 | + KeyEvent.KEYCODE_VOLUME_UP,
|
---|
| 165 | + KeyEvent.KEYCODE_VOLUME_DOWN,
|
---|
| 166 | + KeyEvent.KEYCODE_BACK,
|
---|
| 167 | + KeyEvent.KEYCODE_SEARCH};
|
---|
| 168 | +
|
---|
| 169 | + private Button mSingletestBut;
|
---|
| 170 | + private Button mClosefirstrunBut;
|
---|
| 171 | +
|
---|
| 172 | + public static String flash_path = null;
|
---|
| 173 | + public static String sdcard_path = null;
|
---|
| 174 | + public static String usb_path = null;
|
---|
| 175 | + private int flash_pit = 0;
|
---|
| 176 | + private int sdcard_pit = 1;
|
---|
| 177 | + private int usb_pit = 2;
|
---|
| 178 | + private StorageVolume[] storageVolumes = null;
|
---|
| 179 | + @Override
|
---|
| 180 | + protected void onCreate(Bundle savedInstanceState) {
|
---|
| 181 | + super.onCreate(savedInstanceState);
|
---|
| 182 | +// requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 183 | + getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
|
---|
| 184 | + setContentView(R.layout.firstrun_layout);
|
---|
| 185 | + initView();
|
---|
| 186 | + InitStorage();
|
---|
| 187 | + flash_path = getStoragePath(this, false);//storageVolumes[flash_pit].getPath();
|
---|
| 188 | + sdcard_path = getStoragePath(this, true);
|
---|
| 189 | + GetDevieInformation();
|
---|
| 190 | + }
|
---|
| 191 | + private void initView(){
|
---|
| 192 | + v = new View(FirstRun.this);
|
---|
| 193 | + wm = (WindowManager)FirstRun.this.getSystemService(WINDOW_SERVICE);
|
---|
| 194 | +
|
---|
| 195 | + KeyguardManager km= (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
|
---|
| 196 | + kl = km.newKeyguardLock("unLock");
|
---|
| 197 | +
|
---|
| 198 | + mRes = getResources();
|
---|
| 199 | + productname = (TextView)findViewById(R.id.product_name);
|
---|
| 200 | + productversion = (TextView)findViewById(R.id.product_version);
|
---|
| 201 | + nandstorage = (TextView)findViewById(R.id.nand_storage);
|
---|
| 202 | + availablenandstorage = (TextView)findViewById(R.id.available_nand_storage);
|
---|
| 203 | + productname.setTextSize(testszie + 2);
|
---|
| 204 | + productversion.setTextSize(testszie);
|
---|
| 205 | + nandstorage.setTextSize(testszie);
|
---|
| 206 | + availablenandstorage.setTextSize(testszie);
|
---|
| 207 | +
|
---|
| 208 | + mWifiTestView = (TestView)findViewById(R.id.wifitestview);
|
---|
| 209 | + mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
---|
| 210 | + mWifiReceiver = new MyBroadcastReceiver();
|
---|
| 211 | + mWifiHandler = new WifiHandler();
|
---|
| 212 | +
|
---|
| 213 | + mSDcardTestView = (TestView)findViewById(R.id.sdcardtestview);
|
---|
| 214 | + mUsbHostTestView = (TestView)findViewById(R.id.usbhosttestview);
|
---|
| 215 | +
|
---|
| 216 | + sensorManager = (SensorManager) this.getSystemService(SENSOR_SERVICE);
|
---|
| 217 | + mGsensorBall = (GsensorBall)findViewById(R.id.gsensorball);
|
---|
| 218 | + gsensortext = (TextView)findViewById(R.id.gsensortext);
|
---|
| 219 | + lsn = new SensorEventListener() {
|
---|
| 220 | + public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
---|
| 221 | + }
|
---|
| 222 | + public void onSensorChanged(SensorEvent e) {
|
---|
| 223 | + float x = e.values[0];
|
---|
| 224 | + float y = e.values[1];
|
---|
| 225 | + float z = e.values[2];
|
---|
| 226 | + mGsensorBall.setXYZ(x, y, z);
|
---|
| 227 | + gsensortext.setText(mRes.getString(R.string.GsensorTest) + "\nX: " + x + "\nY: " + y + "\nZ: " + z);
|
---|
| 228 | + }
|
---|
| 229 | + };
|
---|
| 230 | +
|
---|
| 231 | + nocamera = findViewById(R.id.nocamera);
|
---|
| 232 | + mSurfaceView = (SurfaceView)findViewById(R.id.camera_preview);
|
---|
| 233 | + mSwitchBut = (Button)findViewById(R.id.camera_switch_btu);
|
---|
| 234 | + mSwitchBut.setOnClickListener(mOnClickListener);
|
---|
| 235 | + mNumberOfCameras = Camera.getNumberOfCameras();
|
---|
| 236 | + if(mNumberOfCameras <= 1)
|
---|
| 237 | + mSwitchBut.setVisibility(View.GONE);
|
---|
| 238 | +
|
---|
| 239 | + progressBar = (ProgressBar) findViewById(R.id.brightnessBar);
|
---|
| 240 | + progressBar.setClickable(false);
|
---|
| 241 | + progressBar.setMax(MAXIMUM_BRIGHTNESS);
|
---|
| 242 | + brightnessbut = (Button)findViewById(R.id.brightnesstestbut);
|
---|
| 243 | + brightnessbut.setOnClickListener(mOnClickListener);
|
---|
| 244 | +
|
---|
| 245 | + mVUMeter = (VUMeter) findViewById(R.id.uvMeter);
|
---|
| 246 | + mRecorder = new Recorder();
|
---|
| 247 | + mVUMeter.setRecorder(mRecorder);
|
---|
| 248 | + mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
---|
| 249 | + mOldVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
|
---|
| 250 | + recordtestbutton = (Button)findViewById(R.id.recordtestbutton);
|
---|
| 251 | + recordtestbutton.setOnClickListener(mOnClickListener);
|
---|
| 252 | + recordtext = (TextView)findViewById(R.id.recordtext);
|
---|
| 253 | +
|
---|
| 254 | + mChargeStatus = (TextView) findViewById(R.id.chargeStatusText);
|
---|
| 255 | + mVoltage = (TextView) findViewById(R.id.voltageText);
|
---|
| 256 | + mCurrent = (TextView) findViewById(R.id.currentText);
|
---|
| 257 | + mCapacity = (TextView) findViewById(R.id.capacityText);
|
---|
| 258 | + mPlug = (TextView) findViewById(R.id.plugText);
|
---|
| 259 | +
|
---|
| 260 | + mKeyTestView = (KeyTestView)findViewById(R.id.keytestview);
|
---|
| 261 | + if(mKeyNames.length == mKeyCodes.length){
|
---|
| 262 | + for(int i = 0; i < mKeyNames.length; i ++){
|
---|
| 263 | + mKeyTestView.addKey(mKeyNames[i], mKeyCodes[i]);
|
---|
| 264 | + }
|
---|
| 265 | + }
|
---|
| 266 | + mSingletestBut = (Button)findViewById(R.id.singletest);
|
---|
| 267 | + mSingletestBut.setOnClickListener(mOnClickListener);
|
---|
| 268 | + mClosefirstrunBut = (Button)findViewById(R.id.closefirstrun);
|
---|
| 269 | + mClosefirstrunBut.setOnClickListener(mOnClickListener);
|
---|
| 270 | + }
|
---|
| 271 | + @Override
|
---|
| 272 | + protected void onResume() {
|
---|
| 273 | + super.onResume();
|
---|
| 274 | + updateMemoryStatus(flash_path);
|
---|
| 275 | + kl.disableKeyguard();
|
---|
| 276 | +// addWindow();
|
---|
| 277 | + IntentFilter localIntentFilter = new IntentFilter();
|
---|
| 278 | + localIntentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
|
---|
| 279 | + localIntentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
|
---|
| 280 | + localIntentFilter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
|
---|
| 281 | + registerReceiver(mWifiReceiver, localIntentFilter);
|
---|
| 282 | + Log.i("Jeffy-------", "try to enable wifi");
|
---|
| 283 | + mWifiTestView.setStatus(TEST_STATUS.TESTING);
|
---|
| 284 | + mWifiManager.setWifiEnabled(true);
|
---|
| 285 | +
|
---|
| 286 | + mSDcardTestView.setStatus(TEST_STATUS.TESTING);
|
---|
| 287 | + if(testSdcard()){
|
---|
| 288 | + mSDcardTestView.setStatus(TEST_STATUS.SUCCEED);
|
---|
| 289 | + }else{
|
---|
| 290 | + mSDcardTestView.setStatus(TEST_STATUS.FAILED);
|
---|
| 291 | + }
|
---|
| 292 | +
|
---|
| 293 | + mUsbHostTestView.setStatus(TEST_STATUS.TESTING);
|
---|
| 294 | + if(testUSBHost()){
|
---|
| 295 | + mUsbHostTestView.setStatus(TEST_STATUS.SUCCEED);
|
---|
| 296 | + }else{
|
---|
| 297 | + mUsbHostTestView.setStatus(TEST_STATUS.FAILED);
|
---|
| 298 | + }
|
---|
| 299 | +
|
---|
| 300 | + Sensor sensors = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
---|
| 301 | + sensorManager.registerListener(lsn, sensors, SensorManager.SENSOR_DELAY_NORMAL);
|
---|
| 302 | +
|
---|
| 303 | + SurfaceHolder holder = mSurfaceView.getHolder();
|
---|
| 304 | + holder.addCallback(this);
|
---|
| 305 | + holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
|
---|
| 306 | +
|
---|
| 307 | + registerReceiver(mPowerBroadcastReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
---|
| 308 | + }
|
---|
| 309 | + @Override
|
---|
| 310 | + protected void onPause() {
|
---|
| 311 | + super.onPause();
|
---|
| 312 | + // removeWindow();
|
---|
| 313 | + kl.reenableKeyguard();
|
---|
| 314 | + unregisterReceiver(mWifiReceiver);
|
---|
| 315 | + unregisterReceiver(mPowerBroadcastReceiver);
|
---|
| 316 | + sensorManager.unregisterListener(lsn);
|
---|
| 317 | + mWifiHandler.removeMessages(WIFI_MSG_SCAN);
|
---|
| 318 | + Log.d(TAG, " __________________---------- oldBrightness = " + oldBrightness);
|
---|
| 319 | +
|
---|
| 320 | + switch (mRecorder.state()) {
|
---|
| 321 | + case Recorder.IDLE_STATE:
|
---|
| 322 | + mRecorder.delete();
|
---|
| 323 | + break;
|
---|
| 324 | + case Recorder.PLAYING_STATE:
|
---|
| 325 | + mRecorder.stop();
|
---|
| 326 | + mRecorder.delete();
|
---|
| 327 | + break;
|
---|
| 328 | + case Recorder.RECORDING_STATE:
|
---|
| 329 | + mRecorder.stop();
|
---|
| 330 | + mRecorder.clear();
|
---|
| 331 | + break;
|
---|
| 332 | + }
|
---|
| 333 | + mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, mOldVolume, 0);
|
---|
| 334 | + if (mSpeakerOn) {
|
---|
| 335 | + mAudioManager.setSpeakerphoneOn(false);
|
---|
| 336 | + }
|
---|
| 337 | +// unregisterReceiver(mPowerBroadcastReceiver);
|
---|
| 338 | + }
|
---|
| 339 | +
|
---|
| 340 | + @Override
|
---|
| 341 | + protected void onDestroy() {
|
---|
| 342 | + if (mStorageManager != null && mStorageListener != null) {
|
---|
| 343 | + mStorageManager.unregisterListener(mStorageListener);
|
---|
| 344 | + }
|
---|
| 345 | + if(mCameraDevice != null)
|
---|
| 346 | + mCameraDevice.release();
|
---|
| 347 | + super.onDestroy();
|
---|
| 348 | + }
|
---|
| 349 | +
|
---|
| 350 | + /******************************************************************
|
---|
| 351 | + * about DeviceInfo
|
---|
| 352 | + */
|
---|
| 353 | + private void GetDevieInformation(){
|
---|
| 354 | + productname.setText(Build.DEVICE);
|
---|
| 355 | + productversion.setText(mRes.getString(R.string.Firmwareversion) + Build.DISPLAY);
|
---|
| 356 | + }
|
---|
| 357 | +
|
---|
| 358 | + /******************************************************************
|
---|
| 359 | + * about DeviceStorage()
|
---|
| 360 | + */
|
---|
| 361 | + private void InitStorage(){
|
---|
| 362 | + if (mStorageManager == null) {
|
---|
| 363 | + mStorageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE);
|
---|
| 364 | + mStorageManager.registerListener(mStorageListener);
|
---|
| 365 | + storageVolumes = mStorageManager.getVolumeList();
|
---|
| 366 | + if(storageVolumes.length >= 3){
|
---|
| 367 | + flash_path = storageVolumes[flash_pit].getPath();
|
---|
| 368 | + sdcard_path = storageVolumes[sdcard_pit].getPath();
|
---|
| 369 | + usb_path = storageVolumes[usb_pit].getPath();
|
---|
| 370 | + Log.d(TAG, " _____ " + flash_path + " " + sdcard_path + " " + usb_path);
|
---|
| 371 | + }else{
|
---|
| 372 | + flash_path = getStoragePath(this, false);
|
---|
| 373 | + sdcard_path = getStoragePath(this, true);
|
---|
| 374 | + usb_path= "/mnt/usb_storage";
|
---|
| 375 | +
|
---|
| 376 | + }
|
---|
| 377 | +
|
---|
| 378 | + /*flash_path = "/mnt/internal_sd";
|
---|
| 379 | + sdcard_path = "/mnt/external_sd";
|
---|
| 380 | + usb_path = "/mnt/usb_storage";*/
|
---|
| 381 | + }
|
---|
| 382 | + }
|
---|
| 383 | + private void updateMemoryStatus(String path) {
|
---|
| 384 | + String status = mStorageManager.getVolumeState(path);
|
---|
| 385 | + if (path.equals(flash_path)) {
|
---|
| 386 | + status = mStorageManager.getVolumeState(flash_path);
|
---|
| 387 | + }
|
---|
| 388 | + String readOnly = "";
|
---|
| 389 | + if (status.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
|
---|
| 390 | + status = Environment.MEDIA_MOUNTED;
|
---|
| 391 | + readOnly = mRes.getString(R.string.read_only);
|
---|
| 392 | + }
|
---|
| 393 | +
|
---|
| 394 | + if (status.equals(Environment.MEDIA_MOUNTED)) {
|
---|
| 395 | + try {
|
---|
| 396 | + //File path = Environment.getExternalStorageDirectory();
|
---|
| 397 | + StatFs stat = new StatFs(path);
|
---|
| 398 | + long blockSize = stat.getBlockSize();
|
---|
| 399 | + long totalBlocks = stat.getBlockCount();
|
---|
| 400 | + long availableBlocks = stat.getAvailableBlocks();
|
---|
| 401 | +
|
---|
| 402 | + if (path.equals(flash_path)) {
|
---|
| 403 | + nandstorage.setText(mRes.getString(R.string.total_space) + " : " + formatSize(totalBlocks * blockSize));
|
---|
| 404 | + availablenandstorage.setText(mRes.getString(R.string.available_space) + " : " + formatSize(availableBlocks * blockSize) + readOnly);
|
---|
| 405 | + }
|
---|
| 406 | + } catch (IllegalArgumentException e) {
|
---|
| 407 | + status = Environment.MEDIA_REMOVED;
|
---|
| 408 | + }
|
---|
| 409 | + } else {
|
---|
| 410 | + if (path.equals(flash_path)) {
|
---|
| 411 | + nandstorage.setText(mRes.getString(R.string.nand_unavailable));
|
---|
| 412 | + availablenandstorage.setText(mRes.getString(R.string.nand_unavailable));
|
---|
| 413 | + }
|
---|
| 414 | + }
|
---|
| 415 | + }
|
---|
| 416 | + private String formatSize(long size) {
|
---|
| 417 | + return Formatter.formatFileSize(this, size);
|
---|
| 418 | + }
|
---|
| 419 | + StorageEventListener mStorageListener = new StorageEventListener() {
|
---|
| 420 | + @Override
|
---|
| 421 | + public void onStorageStateChanged(String path, String oldState, String newState) {
|
---|
| 422 | + Log.d(TAG, "--------------->>>>> Received storage state changed, path = " +
|
---|
| 423 | + path + ", changed state from " + oldState +
|
---|
| 424 | + " to " + newState);
|
---|
| 425 | + if (path.equals(flash_path)
|
---|
| 426 | + && !newState.equals(Environment.MEDIA_MOUNTED)) {
|
---|
| 427 | + } else {
|
---|
| 428 | + updateMemoryStatus(flash_path);
|
---|
| 429 | + }
|
---|
| 430 | + if(path.equals(sdcard_path)){
|
---|
| 431 | + if(testSdcard()){
|
---|
| 432 | + mSDcardTestView.setStatus(TEST_STATUS.SUCCEED);
|
---|
| 433 | + }else{
|
---|
| 434 | + mSDcardTestView.setStatus(TEST_STATUS.FAILED);
|
---|
| 435 | + }
|
---|
| 436 | + }else if(path.equals(usb_path)){
|
---|
| 437 | + if(testUSBHost()){
|
---|
| 438 | + mUsbHostTestView.setStatus(TEST_STATUS.SUCCEED);
|
---|
| 439 | + }else{
|
---|
| 440 | + mUsbHostTestView.setStatus(TEST_STATUS.FAILED);
|
---|
| 441 | + }
|
---|
| 442 | + }
|
---|
| 443 | + }
|
---|
| 444 | + };
|
---|
| 445 | +
|
---|
| 446 | +
|
---|
| 447 | + /******************************************************************
|
---|
| 448 | + * about WiFitest
|
---|
| 449 | + */
|
---|
| 450 | + class WifiHandler extends Handler {
|
---|
| 451 | + public void handleMessage(Message msg) {
|
---|
| 452 | + switch(msg.what){
|
---|
| 453 | + case WIFI_MSG_SCAN:
|
---|
| 454 | + removeMessages(WIFI_MSG_SCAN);
|
---|
| 455 | + mWifiManager.startScan();
|
---|
| 456 | + break;
|
---|
| 457 | + }
|
---|
| 458 | + }
|
---|
| 459 | + }
|
---|
| 460 | + class MyBroadcastReceiver extends BroadcastReceiver {
|
---|
| 461 | + public void onReceive(Context context, Intent intent) {
|
---|
| 462 | + String action = intent.getAction();
|
---|
| 463 | + Log.i("Jeffy", "action:" + action);
|
---|
| 464 | + if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
|
---|
| 465 | + int state = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
|
---|
| 466 | + WifiManager.WIFI_STATE_UNKNOWN);
|
---|
| 467 | + if (state == WifiManager.WIFI_STATE_ENABLED) {
|
---|
| 468 | + mWifiHandler.sendEmptyMessage(WIFI_MSG_SCAN);
|
---|
| 469 | + }
|
---|
| 470 | + }
|
---|
| 471 | +
|
---|
| 472 | + if (WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION.equals(action)) {
|
---|
| 473 | + boolean connected = intent.getBooleanExtra(
|
---|
| 474 | + WifiManager.EXTRA_SUPPLICANT_CONNECTED, false);
|
---|
| 475 | + if (connected && mReadyToTest) {
|
---|
| 476 | + Log.d("Jeffy===", "already connect to:" + mWifiManager.getConnectionInfo().getSSID());
|
---|
| 477 | +// mHandler.sendEmptyMessageDelayed(MSG_FINISH_TEST, 1000);
|
---|
| 478 | + mWifiTestView.setStatus(TEST_STATUS.SUCCEED);
|
---|
| 479 | + }
|
---|
| 480 | + }
|
---|
| 481 | + if (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION.equals(action)) {
|
---|
| 482 | + List<ScanResult> resultList = mWifiManager.getScanResults();
|
---|
| 483 | + if ((resultList != null) && (!resultList.isEmpty())) {
|
---|
| 484 | + mReadyToTest = true;
|
---|
| 485 | + Log.d("Jeffy===", " ____________-------- resultList.size() = " + resultList.size());
|
---|
| 486 | + mWifiTestView.setStatus(TEST_STATUS.SUCCEED);
|
---|
| 487 | + }
|
---|
| 488 | + }
|
---|
| 489 | +
|
---|
| 490 | + }
|
---|
| 491 | + }
|
---|
| 492 | +
|
---|
| 493 | + /******************************************************************
|
---|
| 494 | + * about SDcard
|
---|
| 495 | + */
|
---|
| 496 | + private static final String TEST_STRING = "Rockchip UsbHostTest File";
|
---|
| 497 | + public boolean testSdcard() {
|
---|
| 498 | + try {
|
---|
| 499 | + String externalVolumeState = mStorageManager.getVolumeState(sdcard_path);
|
---|
| 500 | +
|
---|
| 501 | + Log.d(TAG, " __________----------- testSdcard(), externalVolumeState = " + externalVolumeState);
|
---|
| 502 | + if (!externalVolumeState.equals(Environment.MEDIA_MOUNTED)) {
|
---|
| 503 | + return false;
|
---|
| 504 | + }
|
---|
| 505 | + } catch (Exception rex) {
|
---|
| 506 | + rex.printStackTrace();
|
---|
| 507 | + //test sdcard fail
|
---|
| 508 | + return false;
|
---|
| 509 | + }
|
---|
| 510 | + Log.d(TAG, " __________----------- testSdcard() __ begin test read and write");
|
---|
| 511 | + return testReadAndWrite(sdcard_path + "/test");
|
---|
| 512 | + }
|
---|
| 513 | + public boolean testReadAndWrite(String directoryName) {
|
---|
| 514 | + return dotestReadAndWrite(directoryName);
|
---|
| 515 | + }
|
---|
| 516 | + private boolean dotestReadAndWrite(String directoryName) {
|
---|
| 517 | + File directory = new File(directoryName);
|
---|
| 518 | + Log.d(TAG, " _______-------- dotestReadAndWrite()0, directoryName = " + directoryName);
|
---|
| 519 | + if (!directory.isDirectory()) {
|
---|
| 520 | + if (!directory.mkdirs()) {
|
---|
| 521 | + Log.d(TAG, " _______-------- dotestReadAndWrite()0 1, directoryName = " + directoryName);
|
---|
| 522 | + return false;
|
---|
| 523 | + }
|
---|
| 524 | + }
|
---|
| 525 | + File f = new File(directoryName, "storagetest.txt");
|
---|
| 526 | + try {
|
---|
| 527 | + if (f.exists()) {
|
---|
| 528 | + f.delete();
|
---|
| 529 | + }
|
---|
| 530 | + if (!f.createNewFile()) {
|
---|
| 531 | + return false;
|
---|
| 532 | + } else {
|
---|
| 533 | + doWriteFile(f.getAbsoluteFile().toString());
|
---|
| 534 | + if (!doReadFile(f.getAbsoluteFile().toString()).equals(TEST_STRING)) {
|
---|
| 535 | + return false;
|
---|
| 536 | + }
|
---|
| 537 | + }
|
---|
| 538 | + f.delete();
|
---|
| 539 | + return true;
|
---|
| 540 | + } catch (IOException ex) {
|
---|
| 541 | + Log.e(TAG, "isWritable : false (IOException)!");
|
---|
| 542 | + return false;
|
---|
| 543 | + }
|
---|
| 544 | + }
|
---|
| 545 | +
|
---|
| 546 | + public void doWriteFile(String filename) {
|
---|
| 547 | + try {
|
---|
| 548 | + OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(filename));
|
---|
| 549 | + osw.write(TEST_STRING, 0, TEST_STRING.length());
|
---|
| 550 | + osw.flush();
|
---|
| 551 | + osw.close();
|
---|
| 552 | + } catch (IOException e) {
|
---|
| 553 | + e.printStackTrace();
|
---|
| 554 | + }
|
---|
| 555 | + }
|
---|
| 556 | + public String doReadFile(String filename) {
|
---|
| 557 | + try {
|
---|
| 558 | + BufferedReader br = new BufferedReader(new InputStreamReader
|
---|
| 559 | + (new FileInputStream(filename)));
|
---|
| 560 | + String data = null;
|
---|
| 561 | + StringBuilder temp = new StringBuilder();
|
---|
| 562 | + while ((data = br.readLine()) != null) {
|
---|
| 563 | + temp.append(data);
|
---|
| 564 | + }
|
---|
| 565 | + br.close();
|
---|
| 566 | + Log.e(TAG, "Readfile " + temp.toString());
|
---|
| 567 | + return temp.toString();
|
---|
| 568 | + } catch (Exception e) {
|
---|
| 569 | + e.printStackTrace();
|
---|
| 570 | + return null;
|
---|
| 571 | + }
|
---|
| 572 | + }
|
---|
| 573 | +
|
---|
| 574 | + /******************************************************************
|
---|
| 575 | + * about USBHost
|
---|
| 576 | + */
|
---|
| 577 | + public boolean testUSBHost() {
|
---|
| 578 | + try {
|
---|
| 579 | + String externalVolumeState = mStorageManager.getVolumeState(usb_path).toString();
|
---|
| 580 | +
|
---|
| 581 | + Log.d(TAG, " __________----------- testUSBHost(), externalVolumeState = " + externalVolumeState);
|
---|
| 582 | + if (!externalVolumeState.equals(Environment.MEDIA_MOUNTED) && !externalVolumeState.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
|
---|
| 583 | + return false;
|
---|
| 584 | + }
|
---|
| 585 | + } catch (Exception rex) {
|
---|
| 586 | + rex.printStackTrace();
|
---|
| 587 | + return false;
|
---|
| 588 | + }
|
---|
| 589 | + Log.d(TAG, " __________----------- testUSBHost() __ begin test read and write");
|
---|
| 590 | + return testReadAndWrite(usb_path + "/test");
|
---|
| 591 | + }
|
---|
| 592 | +
|
---|
| 593 | + /******************************************************************
|
---|
| 594 | + * about Camera
|
---|
| 595 | + */
|
---|
| 596 | + public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
---|
| 597 | + Log.d(TAG, "---->>>>>>>>>> surfaceChanged()");
|
---|
| 598 | + if (holder.getSurface() == null) {
|
---|
| 599 | + Log.d(TAG, "---- surfaceChanged(), holder.getSurface() == null");
|
---|
| 600 | + return;
|
---|
| 601 | + }
|
---|
| 602 | + mSurfaceHolder = holder;
|
---|
| 603 | + try{
|
---|
| 604 | + hasCamera = true;
|
---|
| 605 | + nocamera.setVisibility(View.GONE);
|
---|
| 606 | + mCameraDevice = Camera.open(mCurrentCameraId);
|
---|
| 607 | + }catch(Exception e){
|
---|
| 608 | + hasCamera = false;
|
---|
| 609 | + nocamera.setVisibility(View.VISIBLE);
|
---|
| 610 | + mSwitchBut.setVisibility(View.GONE);
|
---|
| 611 | + Log.e(TAG, " ____________- camera error");
|
---|
| 612 | + return;
|
---|
| 613 | + }
|
---|
| 614 | + try{
|
---|
| 615 | + mCameraDevice.setPreviewDisplay(mSurfaceHolder);
|
---|
| 616 | + }catch(IOException e){
|
---|
| 617 | + e.printStackTrace();
|
---|
| 618 | + }
|
---|
| 619 | + mCameraDevice.startPreview();
|
---|
| 620 | + }
|
---|
| 621 | + public void surfaceCreated(SurfaceHolder holder) {
|
---|
| 622 | + }
|
---|
| 623 | + public void surfaceDestroyed(SurfaceHolder holder) {
|
---|
| 624 | + if(mCameraDevice != null){
|
---|
| 625 | + mCameraDevice.stopPreview();
|
---|
| 626 | + mCameraDevice.release();
|
---|
| 627 | + }
|
---|
| 628 | + mSurfaceHolder = null;
|
---|
| 629 | + }
|
---|
| 630 | + OnClickListener mOnClickListener = new OnClickListener(){
|
---|
| 631 | + public void onClick(View arg0) {
|
---|
| 632 | + switch(arg0.getId()){
|
---|
| 633 | + case R.id.camera_switch_btu:
|
---|
| 634 | + mCameraDevice.stopPreview();
|
---|
| 635 | + mCameraDevice.release();
|
---|
| 636 | + mCameraDevice = null;
|
---|
| 637 | + mCurrentCameraId = (mCurrentCameraId + 1) % mNumberOfCameras;
|
---|
| 638 | + mCameraDevice = Camera.open(mCurrentCameraId);
|
---|
| 639 | + mSurfaceHolder = null;
|
---|
| 640 | + mSurfaceView.setVisibility(View.GONE);
|
---|
| 641 | + mSurfaceView.setVisibility(View.VISIBLE);
|
---|
| 642 | + break;
|
---|
| 643 | + case R.id.brightnesstestbut:
|
---|
| 644 | + if(isTestBrightness){
|
---|
| 645 | + mBrightnessHandler.removeMessages(0);
|
---|
| 646 | + setBrightness(oldBrightness);
|
---|
| 647 | + brightnessbut.setText(R.string.BrightnessTitle);
|
---|
| 648 | + }else{
|
---|
| 649 | + mBrightnessHandler.sendEmptyMessage(0);
|
---|
| 650 | + brightnessbut.setText(R.string.BrightnessTitleStop);
|
---|
| 651 | + }
|
---|
| 652 | + isTestBrightness = !isTestBrightness;
|
---|
| 653 | + break;
|
---|
| 654 | + case R.id.recordtestbutton:
|
---|
| 655 | + mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC,
|
---|
| 656 | + mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC), 0);
|
---|
| 657 | + mSpeakerOn = mAudioManager.isSpeakerphoneOn();
|
---|
| 658 | + if (!mSpeakerOn) {
|
---|
| 659 | + mAudioManager.setSpeakerphoneOn(true);
|
---|
| 660 | + }
|
---|
| 661 | + mRecordHandler.sendEmptyMessage(MSG_TEST_MIC_START);
|
---|
| 662 | + recordtestbutton.setEnabled(false);
|
---|
| 663 | + break;
|
---|
| 664 | + case R.id.singletest:
|
---|
| 665 | + Intent tmp = new Intent(FirstRun.this, DeviceTest.class);
|
---|
| 666 | + FirstRun.this.startActivity(tmp);
|
---|
| 667 | + break;
|
---|
| 668 | + case R.id.closefirstrun:
|
---|
| 669 | + FirstRun.this.finish();
|
---|
| 670 | + break;
|
---|
| 671 | + default:
|
---|
| 672 | + break;
|
---|
| 673 | + }
|
---|
| 674 | + }
|
---|
| 675 | + };
|
---|
| 676 | +
|
---|
| 677 | + /******************************************************************
|
---|
| 678 | + * about brightness
|
---|
| 679 | + */
|
---|
| 680 | + int mBrightness = 30;
|
---|
| 681 | + int oldBrightness = 200;
|
---|
| 682 | + boolean increase = true;
|
---|
| 683 | + private void setBrightness(int paramInt) {
|
---|
| 684 | + WindowManager.LayoutParams lp = getWindow().getAttributes();
|
---|
| 685 | + float brightness = (float) paramInt / MAXIMUM_BRIGHTNESS;
|
---|
| 686 | + lp.screenBrightness = brightness;
|
---|
| 687 | + getWindow().setAttributes(lp);
|
---|
| 688 | + }
|
---|
| 689 | + class BrightnessHandler extends Handler {
|
---|
| 690 | + public void handleMessage(Message msg) {
|
---|
| 691 | + super.handleMessage(msg);
|
---|
| 692 | + int delay = 25;
|
---|
| 693 | + if (increase) {
|
---|
| 694 | + mBrightness += ONE_STAGE;
|
---|
| 695 | + if (mBrightness >= MAXIMUM_BRIGHTNESS) {
|
---|
| 696 | + mBrightness = MAXIMUM_BRIGHTNESS;
|
---|
| 697 | + increase = false;
|
---|
| 698 | + delay = 200;
|
---|
| 699 | + }
|
---|
| 700 | + } else {
|
---|
| 701 | + mBrightness -= ONE_STAGE;
|
---|
| 702 | + if (mBrightness <= MINIMUM_BRIGHTNESS) {
|
---|
| 703 | + mBrightness = MINIMUM_BRIGHTNESS;
|
---|
| 704 | + increase = true;
|
---|
| 705 | + delay = 200;
|
---|
| 706 | + }
|
---|
| 707 | + }
|
---|
| 708 | + progressBar.setProgress(mBrightness);
|
---|
| 709 | + setBrightness(mBrightness);
|
---|
| 710 | + sendEmptyMessageDelayed(0, delay);
|
---|
| 711 | + }
|
---|
| 712 | + }
|
---|
| 713 | +
|
---|
| 714 | + /******************************************************************
|
---|
| 715 | + * about mic
|
---|
| 716 | + */
|
---|
| 717 | + int mTimes;
|
---|
| 718 | + private static final int MSG_TEST_MIC_ING = 0;
|
---|
| 719 | + private static final int MSG_TEST_MIC_OVER = 1;
|
---|
| 720 | + private static final int MSG_TEST_MIC_START = 2;
|
---|
| 721 | + class RecordHandler extends Handler {
|
---|
| 722 | + @Override
|
---|
| 723 | + public void handleMessage(Message msg) {
|
---|
| 724 | + switch (msg.what) {
|
---|
| 725 | + default:
|
---|
| 726 | + case MSG_TEST_MIC_START:
|
---|
| 727 | + removeMessages(MSG_TEST_MIC_START);
|
---|
| 728 | + mTimes = RECORD_TIME;
|
---|
| 729 | + recordtext.setText(" "+mTimes+" ");
|
---|
| 730 | + mRecorder.startRecording(3, ".amr");
|
---|
| 731 | + sendEmptyMessageDelayed(MSG_TEST_MIC_ING, 1000L);
|
---|
| 732 | + break;
|
---|
| 733 | + case MSG_TEST_MIC_ING:
|
---|
| 734 | + if (mTimes > 0) {
|
---|
| 735 | + recordtext.setText(" "+mTimes+" ");
|
---|
| 736 | + mTimes--;
|
---|
| 737 | + Log.i(TAG, "mTimes=" + mTimes);
|
---|
| 738 | + sendEmptyMessageDelayed(MSG_TEST_MIC_ING, 1000L);
|
---|
| 739 | + } else {
|
---|
| 740 | + removeMessages(MSG_TEST_MIC_ING);
|
---|
| 741 | + sendEmptyMessage(MSG_TEST_MIC_OVER);
|
---|
| 742 | +
|
---|
| 743 | + }
|
---|
| 744 | + break;
|
---|
| 745 | + case MSG_TEST_MIC_OVER:
|
---|
| 746 | + removeMessages(MSG_TEST_MIC_OVER);
|
---|
| 747 | + mRecorder.stopRecording();
|
---|
| 748 | + if (mRecorder.sampleLength() > 0) {
|
---|
| 749 | + recordtext.setText(R.string.HeadsetRecodrSuccess);
|
---|
| 750 | + mRecorder.startPlayback();
|
---|
| 751 | + } else {
|
---|
| 752 | + recordtext.setText(R.string.RecordError);
|
---|
| 753 | + }
|
---|
| 754 | + recordtestbutton.setEnabled(true);
|
---|
| 755 | + break;
|
---|
| 756 | + }
|
---|
| 757 | + mVUMeter.invalidate();
|
---|
| 758 | + }
|
---|
| 759 | + }
|
---|
| 760 | +
|
---|
| 761 | + /******************************************************************
|
---|
| 762 | + * about Power
|
---|
| 763 | + */
|
---|
| 764 | + class PowerBroadcastReceiver extends BroadcastReceiver {
|
---|
| 765 | + public void onReceive(Context paramContext, Intent intent) {
|
---|
| 766 | + String action = intent.getAction();
|
---|
| 767 | + if (!Intent.ACTION_BATTERY_CHANGED.equals(action)) {
|
---|
| 768 | + return;
|
---|
| 769 | + }
|
---|
| 770 | + int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, 0);
|
---|
| 771 | + int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
---|
| 772 | + int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, 100);
|
---|
| 773 | + int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
|
---|
| 774 | + int voltage = intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, 0);
|
---|
| 775 | + Log.e("Jeffy", "plugged:" + plugged);
|
---|
| 776 | + int current = -1;
|
---|
| 777 | + try {
|
---|
| 778 | + String currentStr = SystemUtil.execScriptCmd("cat "
|
---|
| 779 | + + CURRENT_PATH, DeviceTest.TEMP_FILE_PATH, true);
|
---|
| 780 | + if (currentStr.length() > 0) {
|
---|
| 781 | + current = Integer.parseInt(currentStr);
|
---|
| 782 | + }
|
---|
| 783 | + } catch (Exception e) {
|
---|
| 784 | + e.printStackTrace();
|
---|
| 785 | + }
|
---|
| 786 | + String statusString = "";
|
---|
| 787 | + switch (status) {
|
---|
| 788 | + case BatteryManager.BATTERY_STATUS_UNKNOWN:
|
---|
| 789 | + statusString = "Unknown";
|
---|
| 790 | + break;
|
---|
| 791 | + case BatteryManager.BATTERY_STATUS_CHARGING:
|
---|
| 792 | + statusString = "Charging";
|
---|
| 793 | + break;
|
---|
| 794 | + case BatteryManager.BATTERY_STATUS_DISCHARGING:
|
---|
| 795 | + statusString = "Discharging";
|
---|
| 796 | + break;
|
---|
| 797 | + case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
|
---|
| 798 | + statusString = "Not Charging";
|
---|
| 799 | + break;
|
---|
| 800 | + case BatteryManager.BATTERY_STATUS_FULL:
|
---|
| 801 | + statusString = "Full";
|
---|
| 802 | + break;
|
---|
| 803 | + }
|
---|
| 804 | + mChargeStatus.setText(getString(R.string.ChargeState) + statusString);
|
---|
| 805 | + mVoltage.setText(getString(R.string.Voltage) + voltage + "mV");
|
---|
| 806 | + if (current != -1) {
|
---|
| 807 | + mCurrent.setText("Current:" + (current / 1000) + "mA");
|
---|
| 808 | + } else {
|
---|
| 809 | + mCurrent.setVisibility(View.GONE);
|
---|
| 810 | + }
|
---|
| 811 | + mCapacity.setText(getString(R.string.Capacity) + (level * 100 / scale) + "%");
|
---|
| 812 | + boolean acPlugin = false;
|
---|
| 813 | + String pluggedStr = "";
|
---|
| 814 | + switch (plugged) {
|
---|
| 815 | + case BatteryManager.BATTERY_PLUGGED_AC:
|
---|
| 816 | + acPlugin = true;
|
---|
| 817 | + pluggedStr = "AC";
|
---|
| 818 | + break;
|
---|
| 819 | + case BatteryManager.BATTERY_PLUGGED_USB:
|
---|
| 820 | + pluggedStr = "USB";
|
---|
| 821 | + break;
|
---|
| 822 | + default:
|
---|
| 823 | + pluggedStr = "Unplugged";
|
---|
| 824 | + break;
|
---|
| 825 | + }
|
---|
| 826 | + mPlug.setText(getString(R.string.Plug) + pluggedStr);
|
---|
| 827 | + }
|
---|
| 828 | + }
|
---|
| 829 | +
|
---|
| 830 | +
|
---|
| 831 | + /******************************************************************
|
---|
| 832 | + * about Key
|
---|
| 833 | + */
|
---|
| 834 | + @Override
|
---|
| 835 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 836 | + Log.d(TAG, " _____________---- dispatchKeyEvent(), " + event.getKeyCode());
|
---|
| 837 | + switch(event.getAction()){
|
---|
| 838 | + case KeyEvent.ACTION_DOWN:
|
---|
| 839 | + mKeyTestView.setKeyDown(event.getKeyCode());
|
---|
| 840 | + break;
|
---|
| 841 | + case KeyEvent.ACTION_UP:
|
---|
| 842 | + mKeyTestView.setKeyUp(event.getKeyCode());
|
---|
| 843 | + mKeyTestView.requestFocus();
|
---|
| 844 | + mKeyTestView.requestFocusFromTouch();
|
---|
| 845 | + if(event.getKeyCode()== KeyEvent.KEYCODE_HOME){
|
---|
| 846 | + Log.d(TAG,getWindow().getAttributes().type+ " _____________---- onKeyEEEE(), " + event.getKeyCode());
|
---|
| 847 | + return true;
|
---|
| 848 | + }else if(event.getKeyCode()== KeyEvent.KEYCODE_BACK){
|
---|
| 849 | + Log.d(TAG,getWindow().getAttributes().type+ " _____________---- onKeyEEEE(), " + event.getKeyCode());
|
---|
| 850 | + return true;
|
---|
| 851 | + }else if(event.getKeyCode()== KeyEvent.KEYCODE_MENU){
|
---|
| 852 | + Log.d(TAG,getWindow().getAttributes().type+ " _____________---- onKeyEEEE(), " + event.getKeyCode());
|
---|
| 853 | + mKeyTestView.setFocusable(true);
|
---|
| 854 | + mKeyTestView.setFocusableInTouchMode(true);
|
---|
| 855 | + mKeyTestView.requestFocus();
|
---|
| 856 | +
|
---|
| 857 | + return true;
|
---|
| 858 | + }
|
---|
| 859 | + break;
|
---|
| 860 | + }
|
---|
| 861 | + return super.dispatchKeyEvent(event);
|
---|
| 862 | +
|
---|
| 863 | + }
|
---|
| 864 | + @Override
|
---|
| 865 | + public void onAttachedToWindow() {
|
---|
| 866 | + Log.d(TAG, "onAttachedToWindow");
|
---|
| 867 | + Log.d(TAG, "____________________________ ____________ onAttachedToWindow type: " + getWindow().getAttributes().type);
|
---|
| 868 | +// getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
|
---|
| 869 | +//// getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 870 | +// getWindow().addFlags(FLAG_KEEP_SCREEN_ON);
|
---|
| 871 | + super.onAttachedToWindow();
|
---|
| 872 | + }
|
---|
| 873 | + private void addWindow(){
|
---|
| 874 | + WindowManager.LayoutParams params = new WindowManager.LayoutParams();
|
---|
| 875 | + params.type = WindowManager.LayoutParams.TYPE_KEYGUARD;
|
---|
| 876 | +// params.type = WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
|
---|
| 877 | +// params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
---|
| 878 | +// | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
|
---|
| 879 | +// params.flags = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
|
---|
| 880 | +// | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
---|
| 881 | + params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
---|
| 882 | + | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD;
|
---|
| 883 | + params.width = 0;//WindowManager.LayoutParams.FILL_PARENT;
|
---|
| 884 | + params.height = 0;//WindowManager.LayoutParams.FILL_PARENT;
|
---|
| 885 | + params.format=PixelFormat.TRANSLUCENT;
|
---|
| 886 | + params.gravity=Gravity.LEFT|Gravity.TOP;
|
---|
| 887 | + //����Ļ���Ͻ�Ϊԭ�㣬����x��y��ʼֵ
|
---|
| 888 | + params.x = 0;
|
---|
| 889 | + params.y = 0;
|
---|
| 890 | +
|
---|
| 891 | + wm.addView(v, params);
|
---|
| 892 | + v.requestFocus();
|
---|
| 893 | + v.setOnKeyListener(new OnKeyListener(){
|
---|
| 894 | + public boolean onKey(View v, int keyCode, KeyEvent event) {
|
---|
| 895 | + switch(event.getAction()){
|
---|
| 896 | + case KeyEvent.ACTION_DOWN:
|
---|
| 897 | + mKeyTestView.setKeyDown(event.getKeyCode());
|
---|
| 898 | + break;
|
---|
| 899 | + case KeyEvent.ACTION_UP:
|
---|
| 900 | + mKeyTestView.setKeyUp(event.getKeyCode());
|
---|
| 901 | + if(keyCode== KeyEvent.KEYCODE_HOME){
|
---|
| 902 | + Log.d(TAG,getWindow().getAttributes().type+ " _____________---- onKeyEEEE(), " + event.getKeyCode());
|
---|
| 903 | + return true;
|
---|
| 904 | + }
|
---|
| 905 | +
|
---|
| 906 | + break;
|
---|
| 907 | +
|
---|
| 908 | + }
|
---|
| 909 | + return false;
|
---|
| 910 | + }
|
---|
| 911 | + });
|
---|
| 912 | + }
|
---|
| 913 | + private void removeWindow(){
|
---|
| 914 | + wm.removeView(v);
|
---|
| 915 | + }
|
---|
| 916 | + private static String getStoragePath(Context mContext, boolean is_removale) {
|
---|
| 917 | +
|
---|
| 918 | + StorageManager mStorageManager = (StorageManager) mContext.getSystemService(Context.STORAGE_SERVICE);
|
---|
| 919 | + Class<?> storageVolumeClazz = null;
|
---|
| 920 | + try {
|
---|
| 921 | + storageVolumeClazz = Class.forName("android.os.storage.StorageVolume");
|
---|
| 922 | + Method getVolumeList = mStorageManager.getClass().getMethod("getVolumeList");
|
---|
| 923 | + Method getPath = storageVolumeClazz.getMethod("getPath");
|
---|
| 924 | + Method isRemovable = storageVolumeClazz.getMethod("isRemovable");
|
---|
| 925 | + Object result = getVolumeList.invoke(mStorageManager);
|
---|
| 926 | + final int length = Array.getLength(result);
|
---|
| 927 | + for (int i = 0; i < length; i++) {
|
---|
| 928 | + Object storageVolumeElement = Array.get(result, i);
|
---|
| 929 | + String path = (String) getPath.invoke(storageVolumeElement);
|
---|
| 930 | + boolean removable = (Boolean) isRemovable.invoke(storageVolumeElement);
|
---|
| 931 | + if (is_removale == removable) {
|
---|
| 932 | + return path;
|
---|
| 933 | + }
|
---|
| 934 | + }
|
---|
| 935 | + } catch (ClassNotFoundException e) {
|
---|
| 936 | + e.printStackTrace();
|
---|
| 937 | + } catch (InvocationTargetException e) {
|
---|
| 938 | + e.printStackTrace();
|
---|
| 939 | + } catch (NoSuchMethodException e) {
|
---|
| 940 | + e.printStackTrace();
|
---|
| 941 | + } catch (IllegalAccessException e) {
|
---|
| 942 | + e.printStackTrace();
|
---|
| 943 | + }
|
---|
| 944 | + return null;
|
---|
| 945 | + }
|
---|
| 946 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import java.util.Iterator;
|
---|
| 7 | +
|
---|
| 8 | +import com.DeviceTest.GpsTestActivity.MystatusListener;
|
---|
| 9 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 10 | +import com.DeviceTest.helper.SystemUtil;
|
---|
| 11 | +
|
---|
| 12 | +import android.app.Activity;
|
---|
| 13 | +import android.app.PendingIntent;
|
---|
| 14 | +import android.app.PendingIntent.CanceledException;
|
---|
| 15 | +import android.bluetooth.BluetoothAdapter;
|
---|
| 16 | +import android.content.ComponentName;
|
---|
| 17 | +import android.content.Context;
|
---|
| 18 | +import android.content.Intent;
|
---|
| 19 | +import android.location.Criteria;
|
---|
| 20 | +import android.location.GpsSatellite;
|
---|
| 21 | +import android.location.GpsStatus;
|
---|
| 22 | +import android.location.Location;
|
---|
| 23 | +import android.location.LocationListener;
|
---|
| 24 | +import android.location.LocationManager;
|
---|
| 25 | +import android.net.Uri;
|
---|
| 26 | +import android.net.wifi.WifiManager;
|
---|
| 27 | +import android.os.Bundle;
|
---|
| 28 | +import android.os.Handler;
|
---|
| 29 | +import android.os.Message;
|
---|
| 30 | +import android.os.SystemClock;
|
---|
| 31 | +import android.provider.Settings;
|
---|
| 32 | +import android.util.Log;
|
---|
| 33 | +import android.view.Gravity;
|
---|
| 34 | +import android.view.KeyEvent;
|
---|
| 35 | +import android.view.MotionEvent;
|
---|
| 36 | +import android.view.View;
|
---|
| 37 | +import android.view.ViewGroup;
|
---|
| 38 | +import android.view.Window;
|
---|
| 39 | +import android.widget.Button;
|
---|
| 40 | +import android.widget.TextView;
|
---|
| 41 | +
|
---|
| 42 | +public class GpsLocationTestActivity extends Activity {
|
---|
| 43 | + private static final String TAG = GpsLocationTestActivity.class
|
---|
| 44 | + .getSimpleName();
|
---|
| 45 | + LocationManager mLocatManager;
|
---|
| 46 | + LocationListener mLocationListener = new LocationListener() {
|
---|
| 47 | + public void onLocationChanged(Location location) {
|
---|
| 48 | + // mLocatManager.getGpsStatus(gpsStatus);
|
---|
| 49 | + // mResult.setText("Debug:get location data...");
|
---|
| 50 | + // Log.e("Jeffy", "!!!!!!!!!!!!!!!!Debug:get location data...");
|
---|
| 51 | + // if (gpsStatus != null && gpsStatus.getTimeToFirstFix() != 0) {
|
---|
| 52 | + // mResult.setText("Debug:TTFF: " + gpsStatus.getTimeToFirstFix());
|
---|
| 53 | + // Log.e("Jeffy", "!!!!!!!!!!!!!!!!Debug:TTFF:" +
|
---|
| 54 | + // gpsStatus.getTimeToFirstFix());
|
---|
| 55 | + // return;
|
---|
| 56 | + // }
|
---|
| 57 | + }
|
---|
| 58 | +
|
---|
| 59 | + public void onProviderDisabled(String provider) {
|
---|
| 60 | + }
|
---|
| 61 | +
|
---|
| 62 | + public void onProviderEnabled(String provider) {
|
---|
| 63 | + }
|
---|
| 64 | +
|
---|
| 65 | + public void onStatusChanged(String provider, int status, Bundle extras) {
|
---|
| 66 | + }
|
---|
| 67 | + };
|
---|
| 68 | + TextView mResult;
|
---|
| 69 | + TextView mText;
|
---|
| 70 | + TextView mTitle;
|
---|
| 71 | +
|
---|
| 72 | + private GpsStatus.Listener statusListener = new MystatusListener();
|
---|
| 73 | + private static final int step = 1000; // msecs
|
---|
| 74 | + private static final int MSG_RUN = 0;
|
---|
| 75 | +
|
---|
| 76 | + boolean stop = false;
|
---|
| 77 | + Handler mHandler = new Handler() {
|
---|
| 78 | + public void handleMessage(Message msg) {
|
---|
| 79 | + removeMessages(MSG_RUN);
|
---|
| 80 | + switch (msg.what) {
|
---|
| 81 | + case MSG_RUN:
|
---|
| 82 | + ((Runnable) msg.obj).run();
|
---|
| 83 | + break;
|
---|
| 84 | + default:
|
---|
| 85 | + break;
|
---|
| 86 | + }
|
---|
| 87 | + }
|
---|
| 88 | + };
|
---|
| 89 | + Runnable mFailedRunnable = new Runnable() {
|
---|
| 90 | +
|
---|
| 91 | + public void run() {
|
---|
| 92 | + if (stop) {
|
---|
| 93 | + return;
|
---|
| 94 | + }
|
---|
| 95 | + findViewById(R.id.btn_Fail).performClick();
|
---|
| 96 | + }
|
---|
| 97 | + };
|
---|
| 98 | + Runnable mSkipRunnable = new Runnable() {
|
---|
| 99 | +
|
---|
| 100 | + public void run() {
|
---|
| 101 | + if (stop) {
|
---|
| 102 | + return;
|
---|
| 103 | + }
|
---|
| 104 | + findViewById(R.id.btn_Skip).performClick();
|
---|
| 105 | + }
|
---|
| 106 | + };
|
---|
| 107 | +
|
---|
| 108 | + Runnable mPassRunnable = new Runnable() {
|
---|
| 109 | +
|
---|
| 110 | + public void run() {
|
---|
| 111 | + if (stop) {
|
---|
| 112 | + return;
|
---|
| 113 | + }
|
---|
| 114 | + findViewById(R.id.btn_Pass).performClick();
|
---|
| 115 | + }
|
---|
| 116 | + };
|
---|
| 117 | +
|
---|
| 118 | + protected void onCreate(Bundle savedInstanceState) {
|
---|
| 119 | +
|
---|
| 120 | + super.onCreate(savedInstanceState);
|
---|
| 121 | +
|
---|
| 122 | + setTitle(getTitle() + "----("
|
---|
| 123 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS)
|
---|
| 124 | + + ")");
|
---|
| 125 | + // requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 126 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 127 | +
|
---|
| 128 | + setContentView(R.layout.gpslocationtest);
|
---|
| 129 | +
|
---|
| 130 | + this.mResult = (TextView) findViewById(R.id.gpslocationresultText);
|
---|
| 131 | + this.mResult.setVisibility(View.VISIBLE);
|
---|
| 132 | + this.mResult.setGravity(Gravity.CENTER);
|
---|
| 133 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 134 | + this.mResult.setText("Wait for location data...");
|
---|
| 135 | +
|
---|
| 136 | + //findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 137 | +
|
---|
| 138 | + this.mLocatManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
---|
| 139 | +
|
---|
| 140 | + // mLocatManager.getGpsStatus(gpsStatus);
|
---|
| 141 | + // if(gpsStatus != null && gpsStatus.getTimeToFirstFix() != 0) {
|
---|
| 142 | + // mResult.setText("TTFF already been set, please turn off & turn on GPS..");
|
---|
| 143 | + //
|
---|
| 144 | + // mHandler.postDelayed(mSkipRunnable, 5000);
|
---|
| 145 | + // return;
|
---|
| 146 | + // }
|
---|
| 147 | +
|
---|
| 148 | + WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
---|
| 149 | + wifiManager.setWifiEnabled(false);
|
---|
| 150 | + if(BluetoothAdapter.getDefaultAdapter() != null){
|
---|
| 151 | + BluetoothAdapter.getDefaultAdapter().disable();
|
---|
| 152 | + }
|
---|
| 153 | +
|
---|
| 154 | + /*Settings.Secure.setLocationProviderEnabled(getContentResolver(),
|
---|
| 155 | + LocationManager.GPS_PROVIDER, true);*/
|
---|
| 156 | +
|
---|
| 157 | + if (!mLocatManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
---|
| 158 | + this.mResult.setText("Gps off,gps location was not enabled!");
|
---|
| 159 | + //mHandler.postDelayed(mSkipRunnable, 5000);
|
---|
| 160 | + //return;
|
---|
| 161 | + }else{
|
---|
| 162 | +
|
---|
| 163 | + TextView nmeaView = (TextView) findViewById(R.id.nmealocationresultText);
|
---|
| 164 | + nmeaView.setText("Wait for NMEA information");
|
---|
| 165 | +
|
---|
| 166 | + mLocatManager.addGpsStatusListener(this.statusListener);
|
---|
| 167 | + mLocatManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
|
---|
| 168 | + step, 0, mLocationListener);
|
---|
| 169 | + mLocatManager.addNmeaListener(nmeaListener);
|
---|
| 170 | + stop = true;
|
---|
| 171 | + mHandler.postDelayed(new Runnable() {
|
---|
| 172 | +
|
---|
| 173 | + public void run() {
|
---|
| 174 | + SystemUtil.execRootCmd(DeviceTest.GPS_COLD_START_PATH);
|
---|
| 175 | + SystemUtil.execRootCmd(DeviceTest.GPS_COLD_START_PATH);
|
---|
| 176 | + }
|
---|
| 177 | + }, 2000);
|
---|
| 178 | + stop = false;
|
---|
| 179 | + mHandler.postDelayed(mFailedRunnable, 120 * 1000);
|
---|
| 180 | + }
|
---|
| 181 | + }
|
---|
| 182 | + public boolean onTouchEvent(MotionEvent paramMotionEvent) {
|
---|
| 183 | + if (paramMotionEvent.getAction() == MotionEvent.ACTION_DOWN) {
|
---|
| 184 | + if (!mLocatManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
---|
| 185 | + Intent intent = new Intent();
|
---|
| 186 | + intent .setAction("android.settings.LOCATION_SOURCE_SETTINGS");
|
---|
| 187 | + intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$LocationSettingsActivity"));
|
---|
| 188 | + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
---|
| 189 | + startActivity(intent);
|
---|
| 190 | + }
|
---|
| 191 | + }
|
---|
| 192 | + return super.onTouchEvent(paramMotionEvent);
|
---|
| 193 | + }
|
---|
| 194 | + protected void onStop() {
|
---|
| 195 | + super.onStop();
|
---|
| 196 | + this.mLocatManager.removeGpsStatusListener(this.statusListener);
|
---|
| 197 | + this.mLocatManager.removeUpdates(this.mLocationListener);
|
---|
| 198 | + stop = true;
|
---|
| 199 | + }
|
---|
| 200 | +
|
---|
| 201 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 202 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 203 | + return false;
|
---|
| 204 | + }
|
---|
| 205 | + return super.dispatchKeyEvent(event);
|
---|
| 206 | + }
|
---|
| 207 | +
|
---|
| 208 | + GpsStatus gpsStatus;
|
---|
| 209 | +
|
---|
| 210 | + private void updateNmeaStatus(String nmea) {
|
---|
| 211 | + TextView nmeaView = (TextView) findViewById(R.id.nmealocationresultText);
|
---|
| 212 | + nmeaView.setText(nmea);
|
---|
| 213 | + }
|
---|
| 214 | +
|
---|
| 215 | + private final GpsStatus.NmeaListener nmeaListener = new GpsStatus.NmeaListener() {
|
---|
| 216 | + public void onNmeaReceived(long timestamp, String nmea) {
|
---|
| 217 | +
|
---|
| 218 | + updateNmeaStatus(nmea);
|
---|
| 219 | + }
|
---|
| 220 | + };
|
---|
| 221 | +
|
---|
| 222 | +
|
---|
| 223 | + class MystatusListener implements GpsStatus.Listener {
|
---|
| 224 | +
|
---|
| 225 | + public void onGpsStatusChanged(int event) {
|
---|
| 226 | + gpsStatus = mLocatManager.getGpsStatus(null);
|
---|
| 227 | + if(stop) {
|
---|
| 228 | + return;
|
---|
| 229 | + }
|
---|
| 230 | + switch (event) {
|
---|
| 231 | + case GpsStatus.GPS_EVENT_FIRST_FIX:
|
---|
| 232 | +
|
---|
| 233 | + Log.e("Jeffy",
|
---|
| 234 | + "GPS_EVENT_FIRST_FIX:" + gpsStatus.getTimeToFirstFix());
|
---|
| 235 | + String ttff = ((int) (gpsStatus.getTimeToFirstFix() / 100)) / 10.0 + "s";
|
---|
| 236 | + mResult.setText("TTFF: "
|
---|
| 237 | + + ttff);
|
---|
| 238 | + ControlButtonUtil.setResult(DeviceTest.RESULT_INFO_HEAD
|
---|
| 239 | + + ttff);
|
---|
| 240 | + mHandler.removeMessages(MSG_RUN);
|
---|
| 241 | + if(gpsStatus.getTimeToFirstFix() > 90 * 1000 ) {
|
---|
| 242 | + mHandler.postDelayed(mFailedRunnable, 2 * 1000);
|
---|
| 243 | + } else {
|
---|
| 244 | + mHandler.postDelayed(mPassRunnable, 2 * 1000);
|
---|
| 245 | + }
|
---|
| 246 | + findViewById(R.id.btn_Pass).setVisibility(View.VISIBLE);
|
---|
| 247 | + findViewById(R.id.btn_Fail).setVisibility(View.INVISIBLE);
|
---|
| 248 | + break;
|
---|
| 249 | + default:
|
---|
| 250 | + break;
|
---|
| 251 | + }
|
---|
| 252 | + }
|
---|
| 253 | +
|
---|
| 254 | + }
|
---|
| 255 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import java.util.ArrayList;
|
---|
| 7 | +import java.util.HashMap;
|
---|
| 8 | +import java.util.Iterator;
|
---|
| 9 | +
|
---|
| 10 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 11 | +import com.DeviceTest.helper.SystemUtil;
|
---|
| 12 | +import com.DeviceTest.helper.TestCase;
|
---|
| 13 | +import com.DeviceTest.helper.TestCase.RESULT;
|
---|
| 14 | +
|
---|
| 15 | +import android.app.Activity;
|
---|
| 16 | +import android.app.PendingIntent;
|
---|
| 17 | +import android.app.PendingIntent.CanceledException;
|
---|
| 18 | +import android.bluetooth.BluetoothAdapter;
|
---|
| 19 | +import android.content.Context;
|
---|
| 20 | +import android.content.Intent;
|
---|
| 21 | +import android.location.Criteria;
|
---|
| 22 | +import android.location.GpsSatellite;
|
---|
| 23 | +import android.location.GpsStatus;
|
---|
| 24 | +import android.location.Location;
|
---|
| 25 | +import android.location.LocationListener;
|
---|
| 26 | +import android.location.LocationManager;
|
---|
| 27 | +import android.net.Uri;
|
---|
| 28 | +import android.net.wifi.WifiManager;
|
---|
| 29 | +import android.os.Bundle;
|
---|
| 30 | +import android.os.Handler;
|
---|
| 31 | +import android.os.Message;
|
---|
| 32 | +import android.os.SystemClock;
|
---|
| 33 | +import android.provider.Settings;
|
---|
| 34 | +import android.util.Log;
|
---|
| 35 | +import android.view.Gravity;
|
---|
| 36 | +import android.view.KeyEvent;
|
---|
| 37 | +import android.view.View;
|
---|
| 38 | +import android.view.View.OnClickListener;
|
---|
| 39 | +import android.view.Window;
|
---|
| 40 | +import android.widget.AdapterView;
|
---|
| 41 | +import android.widget.ArrayAdapter;
|
---|
| 42 | +import android.widget.Button;
|
---|
| 43 | +import android.widget.Spinner;
|
---|
| 44 | +import android.widget.TextView;
|
---|
| 45 | +import android.widget.AdapterView.OnItemSelectedListener;
|
---|
| 46 | +
|
---|
| 47 | +public class GpsTestActivity extends Activity {
|
---|
| 48 | + private static final String TAG = GpsTestActivity.class.getSimpleName();
|
---|
| 49 | + LocationManager mLocatManager;
|
---|
| 50 | +
|
---|
| 51 | + private GpsStatus.Listener statusListener = new MystatusListener();
|
---|
| 52 | + HashMap<Integer, Integer> passSatellites = new HashMap<Integer, Integer>();
|
---|
| 53 | + HashMap<Integer, Integer> Satellites = new HashMap<Integer, Integer>();
|
---|
| 54 | +
|
---|
| 55 | + TextView ttffView, cnView, timerView, satellitesView;
|
---|
| 56 | + int ttff = 0;
|
---|
| 57 | + static final int CN_PASS = 38;
|
---|
| 58 | + static final int CN_PASS_NO = 4;
|
---|
| 59 | + static final int TTFF_PASS = 90;
|
---|
| 60 | + static final int TIMEOUT = 120 * 1000;
|
---|
| 61 | + TestCase.RESULT ttffResult = TestCase.RESULT.UNDEF;
|
---|
| 62 | + TestCase.RESULT cnResult = TestCase.RESULT.UNDEF;
|
---|
| 63 | + boolean ttffPass = false;
|
---|
| 64 | + boolean cnPass = false;
|
---|
| 65 | + boolean stop = false;
|
---|
| 66 | + Handler mHandler = new Handler();
|
---|
| 67 | + Runnable timerRunnable = new Runnable() {
|
---|
| 68 | + int time = 0;
|
---|
| 69 | +
|
---|
| 70 | + public void run() {
|
---|
| 71 | + if (stop) {
|
---|
| 72 | + return;
|
---|
| 73 | + }
|
---|
| 74 | + time++;
|
---|
| 75 | + timerView.setText("Time:" + time);
|
---|
| 76 | + String ttffText = "Wait for TTFF";
|
---|
| 77 | + int count = time % 3;
|
---|
| 78 | + switch (count) {
|
---|
| 79 | + case 0:
|
---|
| 80 | + ttffText += ".";
|
---|
| 81 | + break;
|
---|
| 82 | + case 1:
|
---|
| 83 | + ttffText += "..";
|
---|
| 84 | + break;
|
---|
| 85 | + case 2:
|
---|
| 86 | + ttffText += "...";
|
---|
| 87 | + break;
|
---|
| 88 | + default:
|
---|
| 89 | + break;
|
---|
| 90 | + }
|
---|
| 91 | + if (!ttffPass) {
|
---|
| 92 | + ttffView.setText(ttffText);
|
---|
| 93 | + }
|
---|
| 94 | + if (!ttffPass || !cnPass)
|
---|
| 95 | + mHandler.postDelayed(this, 1000);
|
---|
| 96 | + }
|
---|
| 97 | + };
|
---|
| 98 | +
|
---|
| 99 | + protected void onCreate(Bundle savedInstanceState) {
|
---|
| 100 | +
|
---|
| 101 | + super.onCreate(savedInstanceState);
|
---|
| 102 | +
|
---|
| 103 | + setTitle(getTitle() + "----("
|
---|
| 104 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS)
|
---|
| 105 | + + ")");
|
---|
| 106 | + // requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 107 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 108 | +
|
---|
| 109 | + setContentView(R.layout.gpstest);
|
---|
| 110 | +
|
---|
| 111 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 112 | +
|
---|
| 113 | + findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 114 | + findViewById(R.id.btn_Fail).setVisibility(View.INVISIBLE);
|
---|
| 115 | +
|
---|
| 116 | + this.mLocatManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
---|
| 117 | +
|
---|
| 118 | + WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
---|
| 119 | + wifiManager.setWifiEnabled(false);
|
---|
| 120 | + BluetoothAdapter.getDefaultAdapter().disable();
|
---|
| 121 | + try {
|
---|
| 122 | + Settings.Secure.setLocationProviderEnabled(getContentResolver(),
|
---|
| 123 | + LocationManager.GPS_PROVIDER, true);
|
---|
| 124 | + } catch (Exception e) {
|
---|
| 125 | + // TODO: handle exception
|
---|
| 126 | + }
|
---|
| 127 | + Criteria criteria = new Criteria();
|
---|
| 128 | + criteria.setAccuracy(Criteria.ACCURACY_FINE); // 高精度
|
---|
| 129 | + criteria.setAltitudeRequired(false);
|
---|
| 130 | + criteria.setBearingRequired(false);
|
---|
| 131 | + criteria.setCostAllowed(true);
|
---|
| 132 | + criteria.setPowerRequirement(Criteria.POWER_LOW); // 低功耗
|
---|
| 133 | +
|
---|
| 134 | + String provider = mLocatManager.getBestProvider(criteria, true); // 获取GPS信息
|
---|
| 135 | + Location location = mLocatManager.getLastKnownLocation(provider); // 通过GPS获取位置
|
---|
| 136 | + updateToNewLocation(location);
|
---|
| 137 | + // 设置监听器,自动更新的最小时间为间隔N秒(1秒为1*1000,这样写主要为了方便)或最小位移变化超过N米
|
---|
| 138 | + mLocatManager.requestLocationUpdates(provider, 100 * 1000, 500,
|
---|
| 139 | + locationListener);
|
---|
| 140 | + mLocatManager.addGpsStatusListener(this.statusListener);
|
---|
| 141 | + //mLocatManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
|
---|
| 142 | + // 1000, 0, locationListener);
|
---|
| 143 | +
|
---|
| 144 | + ttffView = (TextView) findViewById(R.id.gpsTTFF);
|
---|
| 145 | + cnView = (TextView) findViewById(R.id.gpsCN);
|
---|
| 146 | + timerView = (TextView) findViewById(R.id.gpsTimer);
|
---|
| 147 | + satellitesView = (TextView) findViewById(R.id.gpsSatellite);
|
---|
| 148 | + satellitesView.setText("Satellites:\n");
|
---|
| 149 | + cnView.setText("Passed Satellites:0");
|
---|
| 150 | +
|
---|
| 151 | + stop = true;
|
---|
| 152 | + mHandler.postDelayed(new Runnable() {
|
---|
| 153 | +
|
---|
| 154 | + public void run() {
|
---|
| 155 | + SystemUtil.execRootCmd(DeviceTest.GPS_COLD_START_PATH);
|
---|
| 156 | +
|
---|
| 157 | + mHandler.postDelayed(new Runnable() {
|
---|
| 158 | + public void run() {
|
---|
| 159 | + if (stop) {
|
---|
| 160 | + return;
|
---|
| 161 | + }
|
---|
| 162 | + Log.e("Jeffy",
|
---|
| 163 | + "Test Timeout, ttffPass:" + ttffPass
|
---|
| 164 | + + ", cnPass:" + cnPass + ", time:"
|
---|
| 165 | + + timerView.getText());
|
---|
| 166 | +
|
---|
| 167 | + cnPass = true;
|
---|
| 168 | + ttffPass = true;
|
---|
| 169 | + over();
|
---|
| 170 | + }
|
---|
| 171 | + }, TIMEOUT);
|
---|
| 172 | + mHandler.post(timerRunnable);
|
---|
| 173 | + stop = false;
|
---|
| 174 | + }
|
---|
| 175 | + }, 2000);
|
---|
| 176 | +
|
---|
| 177 | + }
|
---|
| 178 | +private void updateToNewLocation(Location location) {
|
---|
| 179 | +
|
---|
| 180 | + //TextView tv1;
|
---|
| 181 | + // tv1 = (TextView) this.findViewById(R.id.tv1);
|
---|
| 182 | + if (location != null) {
|
---|
| 183 | + double latitude = location.getLatitude();
|
---|
| 184 | + double longitude= location.getLongitude();
|
---|
| 185 | + Log.e("----------","维度:" + latitude+ "\n经度" + longitude);
|
---|
| 186 | + } else {
|
---|
| 187 | + Log.e("----------","无法获取地理信息");
|
---|
| 188 | + }
|
---|
| 189 | +
|
---|
| 190 | +}
|
---|
| 191 | + LocationListener locationListener = new LocationListener() {
|
---|
| 192 | +
|
---|
| 193 | + public void onStatusChanged(String provider, int status, Bundle extras) {
|
---|
| 194 | + }
|
---|
| 195 | +
|
---|
| 196 | + public void onProviderEnabled(String provider) {
|
---|
| 197 | + }
|
---|
| 198 | +
|
---|
| 199 | + public void onProviderDisabled(String provider) {
|
---|
| 200 | + }
|
---|
| 201 | +
|
---|
| 202 | + public void onLocationChanged(Location location) {
|
---|
| 203 | + }
|
---|
| 204 | +
|
---|
| 205 | + };
|
---|
| 206 | +
|
---|
| 207 | + protected void onStop() {
|
---|
| 208 | +
|
---|
| 209 | + super.onStop();
|
---|
| 210 | +
|
---|
| 211 | + this.mLocatManager.removeGpsStatusListener(this.statusListener);
|
---|
| 212 | + mLocatManager.removeUpdates(locationListener);
|
---|
| 213 | + stop = true;
|
---|
| 214 | + }
|
---|
| 215 | +
|
---|
| 216 | + GpsStatus gpsStatus;
|
---|
| 217 | +
|
---|
| 218 | + class MystatusListener implements GpsStatus.Listener {
|
---|
| 219 | +
|
---|
| 220 | + public void onGpsStatusChanged(int event) {
|
---|
| 221 | + if (stop) {
|
---|
| 222 | + return;
|
---|
| 223 | + }
|
---|
| 224 | + gpsStatus = mLocatManager.getGpsStatus(null);
|
---|
| 225 | +
|
---|
| 226 | + switch (event) {
|
---|
| 227 | + case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
|
---|
| 228 | + Iterable<GpsSatellite> allSatellites = gpsStatus
|
---|
| 229 | + .getSatellites();
|
---|
| 230 | + Iterator<GpsSatellite> iterator = allSatellites.iterator();
|
---|
| 231 | + String msg = "Satellites:\n";
|
---|
| 232 | +
|
---|
| 233 | + while (iterator.hasNext()) {
|
---|
| 234 | + GpsSatellite gpsSatellite = iterator.next();
|
---|
| 235 | + int snr = (int) gpsSatellite.getSnr();
|
---|
| 236 | + int prn = gpsSatellite.getPrn();
|
---|
| 237 | + if (snr < 0) {
|
---|
| 238 | + continue;
|
---|
| 239 | + }
|
---|
| 240 | + msg += "" + prn + "(" + snr + ")\n";
|
---|
| 241 | + Integer oldSnr = Satellites.get(prn);
|
---|
| 242 | + if (oldSnr == null || snr > oldSnr) {
|
---|
| 243 | + Satellites.put(prn, snr);
|
---|
| 244 | + if (snr >= CN_PASS) {
|
---|
| 245 | + passSatellites.put(prn, snr);
|
---|
| 246 | + }
|
---|
| 247 | + }
|
---|
| 248 | + }
|
---|
| 249 | + satellitesView.setText(msg);
|
---|
| 250 | +
|
---|
| 251 | + int passCount = passSatellites.size();
|
---|
| 252 | + msg = "Passed Satellites:" + passCount;
|
---|
| 253 | + if (passCount >= CN_PASS_NO) {
|
---|
| 254 | + Log.e("Jeffy",
|
---|
| 255 | + "Get 4 CN > 38, ttffPass:" + ttffPass + ", cnPass:"
|
---|
| 256 | + + cnPass + ", time:" + timerView.getText());
|
---|
| 257 | + msg += "(Pass)";
|
---|
| 258 | + cnPass = true;
|
---|
| 259 | + over();
|
---|
| 260 | + }
|
---|
| 261 | + cnView.setText(msg);
|
---|
| 262 | + break;
|
---|
| 263 | + case GpsStatus.GPS_EVENT_FIRST_FIX:
|
---|
| 264 | + ttffPass = true;
|
---|
| 265 | + ttff = gpsStatus.getTimeToFirstFix() / 1000;
|
---|
| 266 | + msg = "TTFF:" + ttff;
|
---|
| 267 | +
|
---|
| 268 | + Log.e("Jeffy", "Get TTFF, ttffPass:" + ttffPass + ", cnPass:"
|
---|
| 269 | + + cnPass + ", time:" + timerView.getText());
|
---|
| 270 | +
|
---|
| 271 | + if (ttff <= TTFF_PASS) {
|
---|
| 272 | + msg += "(Pass)";
|
---|
| 273 | + } else {
|
---|
| 274 | + msg += "(Failed)";
|
---|
| 275 | + }
|
---|
| 276 | +
|
---|
| 277 | + over();
|
---|
| 278 | + ttffView.setText(msg);
|
---|
| 279 | + break;
|
---|
| 280 | + default:
|
---|
| 281 | + break;
|
---|
| 282 | + }
|
---|
| 283 | + }
|
---|
| 284 | + }
|
---|
| 285 | +
|
---|
| 286 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 287 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 288 | + return false;
|
---|
| 289 | + }
|
---|
| 290 | + return super.dispatchKeyEvent(event);
|
---|
| 291 | + }
|
---|
| 292 | +
|
---|
| 293 | + private String getCNs() {
|
---|
| 294 | + if (Satellites.size() == 0) {
|
---|
| 295 | + return "";
|
---|
| 296 | + }
|
---|
| 297 | + String msg = "";
|
---|
| 298 | + for (int i = 0; i < 255; i++) {
|
---|
| 299 | + if (Satellites.get(i) != null) {
|
---|
| 300 | + msg += "" + i + "-" + Satellites.get(i) + ",";
|
---|
| 301 | + }
|
---|
| 302 | + }
|
---|
| 303 | + return msg.substring(0, msg.length() - 1);
|
---|
| 304 | + }
|
---|
| 305 | +
|
---|
| 306 | + public String getResult() {
|
---|
| 307 | + String result = DeviceTest.RESULT_INFO_HEAD_JUST_INFO;
|
---|
| 308 | + result += DeviceTest.formatResult("GPS C/No", cnResult,
|
---|
| 309 | + DeviceTest.RESULT_INFO_HEAD + getCNs()) + "\n";
|
---|
| 310 | + result += DeviceTest.formatResult("GPS Location", ttffResult,
|
---|
| 311 | + DeviceTest.RESULT_INFO_HEAD + ttff);
|
---|
| 312 | +
|
---|
| 313 | + return result;
|
---|
| 314 | + }
|
---|
| 315 | +
|
---|
| 316 | + public void over() {
|
---|
| 317 | + if (!cnPass || !ttffPass) {
|
---|
| 318 | + return;
|
---|
| 319 | + }
|
---|
| 320 | + stop = true;
|
---|
| 321 | + Log.e("Jeffy", "Test Over, ttffPass:" + ttffPass + ", cnPass:" + cnPass
|
---|
| 322 | + + ", time:" + timerView.getText());
|
---|
| 323 | +
|
---|
| 324 | + if (passSatellites.size() >= CN_PASS_NO) {
|
---|
| 325 | + cnResult = TestCase.RESULT.OK;
|
---|
| 326 | + } else {
|
---|
| 327 | + cnResult = TestCase.RESULT.NG;
|
---|
| 328 | + }
|
---|
| 329 | +
|
---|
| 330 | + if (ttff <= TTFF_PASS) {
|
---|
| 331 | + ttffResult = TestCase.RESULT.OK;
|
---|
| 332 | + } else {
|
---|
| 333 | + ttffResult = TestCase.RESULT.NG;
|
---|
| 334 | + }
|
---|
| 335 | + ControlButtonUtil.setResult(getResult());
|
---|
| 336 | + mHandler.postDelayed(new Runnable() {
|
---|
| 337 | +
|
---|
| 338 | + public void run() {
|
---|
| 339 | + if (cnResult == ttffResult && cnResult == TestCase.RESULT.OK) {
|
---|
| 340 | + findViewById(R.id.btn_Pass).performClick();
|
---|
| 341 | + } else {
|
---|
| 342 | + findViewById(R.id.btn_Fail).performClick();
|
---|
| 343 | + }
|
---|
| 344 | + }
|
---|
| 345 | + }, 3000);
|
---|
| 346 | + }
|
---|
| 347 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | + |
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN; |
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; |
---|
| 5 | + |
---|
| 6 | +import java.io.File; |
---|
| 7 | +import java.io.FileOutputStream; |
---|
| 8 | +import java.io.FileNotFoundException; |
---|
| 9 | +import java.io.IOException; |
---|
| 10 | +import java.util.List; |
---|
| 11 | + |
---|
| 12 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 13 | +import com.DeviceTest.view.GsensorBall; |
---|
| 14 | + |
---|
| 15 | +import android.app.Activity; |
---|
| 16 | +import android.graphics.Color; |
---|
| 17 | +import android.hardware.Sensor; |
---|
| 18 | +import android.hardware.SensorEvent; |
---|
| 19 | +import android.hardware.SensorEventListener; |
---|
| 20 | +import android.hardware.SensorManager; |
---|
| 21 | +import android.os.Bundle; |
---|
| 22 | +import android.util.Log; |
---|
| 23 | +import android.view.KeyEvent; |
---|
| 24 | +import android.view.View; |
---|
| 25 | +import android.view.View.OnClickListener; |
---|
| 26 | +import android.widget.Button; |
---|
| 27 | +import android.widget.TextView; |
---|
| 28 | +import android.widget.Toast; |
---|
| 29 | + |
---|
| 30 | +/** |
---|
| 31 | + * @author LanBinYuan |
---|
| 32 | + * @date 2011-06-11 |
---|
| 33 | + * |
---|
| 34 | + */ |
---|
| 35 | + |
---|
| 36 | +public class GsensorTestActivity extends Activity { |
---|
| 37 | + /** Called when the activity is first created. */ |
---|
| 38 | + private final static int MAX_NUM = 8; |
---|
| 39 | + private SensorManager sensorManager; |
---|
| 40 | + private SensorEventListener lsn = null; |
---|
| 41 | + boolean stop = false; |
---|
| 42 | + |
---|
| 43 | + private static enum TEST_AXIS { |
---|
| 44 | + X, Y, Z, D |
---|
| 45 | + }; |
---|
| 46 | + |
---|
| 47 | + private TEST_AXIS testAxis; |
---|
| 48 | + private GsensorBall mGsensorBall; |
---|
| 49 | + private Button save_btn; |
---|
| 50 | + private double x_offset=0; |
---|
| 51 | + private double y_offset=0; |
---|
| 52 | + private double z_offset=0; |
---|
| 53 | + |
---|
| 54 | + protected void onCreate(Bundle paramBundle) { |
---|
| 55 | + super.onCreate(paramBundle); |
---|
| 56 | + setContentView(R.layout.gsensortest); |
---|
| 57 | + stop = false; |
---|
| 58 | + setTitle(getTitle() + "----(" |
---|
| 59 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")"); |
---|
| 60 | + // requestWindowFeature(Window.FEATURE_NO_TITLE); |
---|
| 61 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON); |
---|
| 62 | + |
---|
| 63 | + ControlButtonUtil.initControlButtonView(this); |
---|
| 64 | + sensorManager = (SensorManager) this.getSystemService(SENSOR_SERVICE); |
---|
| 65 | + //mGsensorBall = (GsensorBall)findViewById(R.id.gsensorball); |
---|
| 66 | + setTestAxis(TEST_AXIS.X); |
---|
| 67 | +// findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE); |
---|
| 68 | + save_btn = (Button) findViewById(R.id.save_calibration_button); |
---|
| 69 | + } |
---|
| 70 | + |
---|
| 71 | + TextView X_textView, Y_textView, Z_textView; |
---|
| 72 | + |
---|
| 73 | + |
---|
| 74 | + protected void onResume() { |
---|
| 75 | + super.onResume(); |
---|
| 76 | + |
---|
| 77 | + stop = false; |
---|
| 78 | + final TextView subTitle = (TextView) findViewById(R.id.Accelerometer); |
---|
| 79 | + subTitle.setTextColor(Color.rgb(255, 0, 0)); |
---|
| 80 | + |
---|
| 81 | + X_textView = (TextView) findViewById(R.id.gsensorTestX); |
---|
| 82 | + X_textView.setTextColor(android.graphics.Color.GREEN); |
---|
| 83 | + |
---|
| 84 | + Y_textView = (TextView) findViewById(R.id.gsensorTestY); |
---|
| 85 | + Y_textView.setTextColor(android.graphics.Color.GREEN); |
---|
| 86 | + |
---|
| 87 | + Z_textView = (TextView) findViewById(R.id.gsensorTestZ); |
---|
| 88 | + Z_textView.setTextColor(android.graphics.Color.GREEN); |
---|
| 89 | + |
---|
| 90 | + |
---|
| 91 | + lsn = new SensorEventListener() { |
---|
| 92 | + public void onAccuracyChanged(Sensor sensor, int accuracy) { |
---|
| 93 | + |
---|
| 94 | + } |
---|
| 95 | + |
---|
| 96 | + public void onSensorChanged(SensorEvent e) { |
---|
| 97 | + if(stop) { |
---|
| 98 | + return; |
---|
| 99 | + } |
---|
| 100 | + subTitle.setText("x:" + (double) e.values[0] + ", \ny:" |
---|
| 101 | + + (double) e.values[1] + ",\nz:" + (double) e.values[2]); |
---|
| 102 | + x_offset=e.values[0]-0; |
---|
| 103 | + y_offset=e.values[1]-0; |
---|
| 104 | + z_offset=e.values[2]-9.8; |
---|
| 105 | + doTest(e); |
---|
| 106 | + //mGsensorBall.setXYZ(e.values[0], e.values[1], e.values[2]); |
---|
| 107 | + } |
---|
| 108 | + |
---|
| 109 | + }; |
---|
| 110 | + |
---|
| 111 | + Sensor sensors = sensorManager |
---|
| 112 | + .getDefaultSensor(Sensor.TYPE_ACCELEROMETER); |
---|
| 113 | + |
---|
| 114 | + sensorManager.registerListener(lsn, sensors, |
---|
| 115 | + SensorManager.SENSOR_DELAY_NORMAL); |
---|
| 116 | + |
---|
| 117 | + save_btn.setOnClickListener(new OnClickListener() |
---|
| 118 | + { |
---|
| 119 | + |
---|
| 120 | + @Override |
---|
| 121 | + public void onClick(View v) |
---|
| 122 | + { |
---|
| 123 | + // TODO Auto-generated method stub |
---|
| 124 | + File savefile = new File("/cache/Gsensor.txt"); |
---|
| 125 | + if (savefile.exists()) { |
---|
| 126 | + savefile.delete(); |
---|
| 127 | + } |
---|
| 128 | + if (!savefile.exists()) |
---|
| 129 | + { |
---|
| 130 | + try |
---|
| 131 | + { |
---|
| 132 | + savefile.createNewFile(); |
---|
| 133 | + } catch (IOException e) |
---|
| 134 | + { |
---|
| 135 | + // TODO Auto-generated catch block |
---|
| 136 | + e.printStackTrace(); |
---|
| 137 | + } |
---|
| 138 | + } |
---|
| 139 | + StringBuilder sb = new StringBuilder(); |
---|
| 140 | + sb.append("x_offset:" + x_offset).append("\n").append("y_offset:" + y_offset).append("\n").append("z_offset:" + x_offset); |
---|
| 141 | + String sbStirng = sb.toString(); |
---|
| 142 | + FileOutputStream fos = null; |
---|
| 143 | + try |
---|
| 144 | + { |
---|
| 145 | + fos = new FileOutputStream(savefile, false); |
---|
| 146 | + fos.write(sbStirng.getBytes()); |
---|
| 147 | + fos.close(); |
---|
| 148 | + } catch (FileNotFoundException e) |
---|
| 149 | + { |
---|
| 150 | + // TODO Auto-generated catch block |
---|
| 151 | + e.printStackTrace(); |
---|
| 152 | + } catch (IOException e) |
---|
| 153 | + { |
---|
| 154 | + // TODO Auto-generated catch block |
---|
| 155 | + e.printStackTrace(); |
---|
| 156 | + } finally |
---|
| 157 | + { |
---|
| 158 | + if (fos != null) |
---|
| 159 | + { |
---|
| 160 | + try |
---|
| 161 | + { |
---|
| 162 | + fos.close(); |
---|
| 163 | + } catch (IOException e) |
---|
| 164 | + { |
---|
| 165 | + e.printStackTrace(); |
---|
| 166 | + } |
---|
| 167 | + } |
---|
| 168 | + } |
---|
| 169 | + Toast.makeText(getApplicationContext(), getString(R.string.save_isok), Toast.LENGTH_SHORT).show(); |
---|
| 170 | + } |
---|
| 171 | + }); |
---|
| 172 | + } |
---|
| 173 | + |
---|
| 174 | + private void doTest(SensorEvent e) { |
---|
| 175 | + switch (testAxis) { |
---|
| 176 | + case X: |
---|
| 177 | + if ((int) e.values[0] >= MAX_NUM && (int) e.values[1] == 0 |
---|
| 178 | + && (int) e.values[2] == 0) { |
---|
| 179 | + setTestAxis(TEST_AXIS.Y); |
---|
| 180 | + X_textView.setText(X_textView.getText() + ":Pass"); |
---|
| 181 | + } |
---|
| 182 | + break; |
---|
| 183 | + case Y: |
---|
| 184 | + if ((int) e.values[0] == 0 && (int) e.values[1] >= MAX_NUM |
---|
| 185 | + && (int) e.values[2] == 0) { |
---|
| 186 | + setTestAxis(TEST_AXIS.Z); |
---|
| 187 | + Y_textView.setText(Y_textView.getText() + ":Pass"); |
---|
| 188 | + } |
---|
| 189 | + break; |
---|
| 190 | + case Z: |
---|
| 191 | + if ((int) e.values[0] == 0 && (int) e.values[1] == 0 |
---|
| 192 | + && (int) e.values[2] >= MAX_NUM) { |
---|
| 193 | + setTestAxis(TEST_AXIS.D); |
---|
| 194 | + Z_textView.setText(Z_textView.getText() + ":Pass"); |
---|
| 195 | +// findViewById(R.id.btn_Pass).performClick(); |
---|
| 196 | + } |
---|
| 197 | + break; |
---|
| 198 | + default: |
---|
| 199 | + break; |
---|
| 200 | + } |
---|
| 201 | + } |
---|
| 202 | + |
---|
| 203 | + private void setTestAxis(TEST_AXIS testAxis) { |
---|
| 204 | + this.testAxis = testAxis; |
---|
| 205 | + switch (testAxis) { |
---|
| 206 | + case X: |
---|
| 207 | + findViewById(R.id.gsensorTestX).setVisibility(View.VISIBLE); |
---|
| 208 | + break; |
---|
| 209 | + case Y: |
---|
| 210 | + findViewById(R.id.gsensorTestY).setVisibility(View.VISIBLE); |
---|
| 211 | + break; |
---|
| 212 | + case Z: |
---|
| 213 | + findViewById(R.id.gsensorTestZ).setVisibility(View.VISIBLE); |
---|
| 214 | + break; |
---|
| 215 | + default: |
---|
| 216 | + break; |
---|
| 217 | + } |
---|
| 218 | + } |
---|
| 219 | + |
---|
| 220 | + // |
---|
| 221 | + |
---|
| 222 | + protected void onPause() { |
---|
| 223 | + super.onPause(); |
---|
| 224 | + sensorManager.unregisterListener(lsn); |
---|
| 225 | + stop = true; |
---|
| 226 | + } |
---|
| 227 | + |
---|
| 228 | + public boolean dispatchKeyEvent(KeyEvent event) { |
---|
| 229 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
---|
| 230 | + return false; |
---|
| 231 | + } |
---|
| 232 | + return super.dispatchKeyEvent(event); |
---|
| 233 | + } |
---|
| 234 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | + |
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN; |
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; |
---|
| 5 | + |
---|
| 6 | +import java.util.List; |
---|
| 7 | +import java.io.File; |
---|
| 8 | +import java.io.FileOutputStream; |
---|
| 9 | +import java.io.FileNotFoundException; |
---|
| 10 | +import java.io.IOException; |
---|
| 11 | + |
---|
| 12 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 13 | + |
---|
| 14 | +import android.app.Activity; |
---|
| 15 | +import android.graphics.Color; |
---|
| 16 | +import android.hardware.Sensor; |
---|
| 17 | +import android.hardware.SensorEvent; |
---|
| 18 | +import android.hardware.SensorEventListener; |
---|
| 19 | +import android.hardware.SensorManager; |
---|
| 20 | +import android.os.Bundle; |
---|
| 21 | +import android.util.Log; |
---|
| 22 | +import android.view.Gravity; |
---|
| 23 | +import android.view.KeyEvent; |
---|
| 24 | +import android.view.LayoutInflater; |
---|
| 25 | +import android.view.View; |
---|
| 26 | +import android.widget.ImageView; |
---|
| 27 | +import android.widget.RelativeLayout; |
---|
| 28 | +import android.widget.TextView; |
---|
| 29 | +import com.DeviceTest.view.*; |
---|
| 30 | +import android.view.View.OnClickListener; |
---|
| 31 | +import android.widget.Button; |
---|
| 32 | +import android.widget.Toast; |
---|
| 33 | +/** |
---|
| 34 | + * @author LanBinYuan |
---|
| 35 | + * @date 2011-06-11 |
---|
| 36 | + * |
---|
| 37 | + */ |
---|
| 38 | + |
---|
| 39 | +public class GyroscopeTestActivity extends Activity { |
---|
| 40 | + /** Called when the activity is first created. */ |
---|
| 41 | + private SensorManager sensorManager; |
---|
| 42 | + private SensorEventListener lsn = null; |
---|
| 43 | + private TouchSurfaceView mGLSurfaceView; |
---|
| 44 | + private Button save_btn; |
---|
| 45 | + private double x_offset=0; |
---|
| 46 | + private double y_offset=0; |
---|
| 47 | + private double z_offset=0; |
---|
| 48 | + |
---|
| 49 | + private float x; |
---|
| 50 | + private float y; |
---|
| 51 | + private float z = 0.0F; |
---|
| 52 | + int i = 0; |
---|
| 53 | + protected void onCreate(Bundle paramBundle) { |
---|
| 54 | + super.onCreate(paramBundle); |
---|
| 55 | + |
---|
| 56 | + |
---|
| 57 | + setTitle(getTitle() + "----(" |
---|
| 58 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")"); |
---|
| 59 | + //requestWindowFeature(Window.FEATURE_NO_TITLE); |
---|
| 60 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON); |
---|
| 61 | + |
---|
| 62 | + setContentView(R.layout.gyroscopetest); |
---|
| 63 | + ControlButtonUtil.initControlButtonView(this); |
---|
| 64 | + sensorManager = (SensorManager) this.getSystemService(SENSOR_SERVICE); |
---|
| 65 | + this.mGLSurfaceView = new TouchSurfaceView(this); |
---|
| 66 | + //setContentView(this.mGLSurfaceView); |
---|
| 67 | + |
---|
| 68 | + // AdView localAdView = new AdView(this); |
---|
| 69 | + //localAdView.setVerticalGravity(80); |
---|
| 70 | + // localRelativeLayout.addView(localAdView, localLayoutParams); |
---|
| 71 | +// addContentView(localRelativeLayout, new WindowManager.LayoutParams(-1, -2)); |
---|
| 72 | + RelativeLayout layout2 = (RelativeLayout)findViewById(R.id.relativeLayout2); |
---|
| 73 | + RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams( |
---|
| 74 | + RelativeLayout.LayoutParams.WRAP_CONTENT, |
---|
| 75 | + RelativeLayout.LayoutParams.WRAP_CONTENT); |
---|
| 76 | + params2.addRule(RelativeLayout.CENTER_HORIZONTAL); |
---|
| 77 | + layout2.setGravity(Gravity.BOTTOM); |
---|
| 78 | + layout2.addView(mGLSurfaceView, params2); |
---|
| 79 | + // LayoutInflater.from(this).inflate(R.xml.control_buttons, get); |
---|
| 80 | + this.mGLSurfaceView.requestFocus(); |
---|
| 81 | + this.mGLSurfaceView.setFocusableInTouchMode(true); |
---|
| 82 | + save_btn = (Button) findViewById(R.id.save_calibration_button); |
---|
| 83 | + } |
---|
| 84 | + |
---|
| 85 | + |
---|
| 86 | + @Override |
---|
| 87 | + protected void onPause() { |
---|
| 88 | + // Ideally a game should implement onResume() and onPause() |
---|
| 89 | + // to take appropriate action when the activity looses focus |
---|
| 90 | + super.onPause(); |
---|
| 91 | + mGLSurfaceView.onPause(); |
---|
| 92 | + this.sensorManager.unregisterListener(lsn); |
---|
| 93 | + } |
---|
| 94 | + |
---|
| 95 | + |
---|
| 96 | + protected void onResume() { |
---|
| 97 | + super.onResume(); |
---|
| 98 | + |
---|
| 99 | + lsn = new SensorEventListener() { |
---|
| 100 | + public void onAccuracyChanged(Sensor sensor, int accuracy) { |
---|
| 101 | + // TODO Auto-generated method stub |
---|
| 102 | + |
---|
| 103 | + } |
---|
| 104 | + |
---|
| 105 | + public void onSensorChanged(SensorEvent e) { |
---|
| 106 | + TextView subTitle = (TextView) findViewById(R.id.Gyroscope); |
---|
| 107 | + subTitle.setTextColor(Color.rgb(255, 0, 0)); |
---|
| 108 | + |
---|
| 109 | + String info = " name:" + String.valueOf(e.sensor.getName()); |
---|
| 110 | + info += "\n"; |
---|
| 111 | + |
---|
| 112 | + info += " vendor:" + String.valueOf(e.sensor.getVendor()); |
---|
| 113 | + info += "\n"; |
---|
| 114 | + info += " version:" + String.valueOf(e.sensor.getVersion()); |
---|
| 115 | + info += "\n"; |
---|
| 116 | + info += " maxRange:" |
---|
| 117 | + + String.valueOf(e.sensor.getMaximumRange()); |
---|
| 118 | + info += "\n"; |
---|
| 119 | + info += " resolution:" |
---|
| 120 | + + String.valueOf(e.sensor.getResolution()); |
---|
| 121 | + info += "\n"; |
---|
| 122 | + info += " power:" + String.valueOf(e.sensor.getPower()); |
---|
| 123 | + |
---|
| 124 | + TextView infoView = (TextView) findViewById(R.id.magnetic_info); |
---|
| 125 | + infoView.setText(info); |
---|
| 126 | + // -------------- |
---|
| 127 | + |
---|
| 128 | + TextView text = (TextView) findViewById(R.id.magnetic_x); |
---|
| 129 | + text.setText(" x:" |
---|
| 130 | + + String.valueOf(e.values[SensorManager.DATA_X])); |
---|
| 131 | + text.setTextColor(android.graphics.Color.GREEN); |
---|
| 132 | + |
---|
| 133 | + TextView text2 = (TextView) findViewById(R.id.magnetic_y); |
---|
| 134 | + text2.setText(" y:" |
---|
| 135 | + + String.valueOf(e.values[SensorManager.DATA_Y])); |
---|
| 136 | + text2.setTextColor(android.graphics.Color.GREEN); |
---|
| 137 | + |
---|
| 138 | + TextView text3 = (TextView) findViewById(R.id.magnetic_z); |
---|
| 139 | + text3.setText(" z:" |
---|
| 140 | + + String.valueOf(e.values[SensorManager.DATA_Z])); |
---|
| 141 | + text3.setTextColor(android.graphics.Color.GREEN); |
---|
| 142 | + |
---|
| 143 | + x += e.values[0]; |
---|
| 144 | + y += e.values[1]; |
---|
| 145 | + z += e.values[2]; |
---|
| 146 | + mGLSurfaceView.updateGyro(x, y, z); |
---|
| 147 | + |
---|
| 148 | + int j = i; |
---|
| 149 | + i = (j + 1); |
---|
| 150 | + if (j % 50 != 0) |
---|
| 151 | + return; |
---|
| 152 | + Log.i("gyro", "x=" + e.values[0] + " y=" +e.values[1] + " z=" + e.values[2]); |
---|
| 153 | + x_offset=e.values[0]-0; |
---|
| 154 | + y_offset=e.values[1]-0; |
---|
| 155 | + z_offset=e.values[2]-0; |
---|
| 156 | + } |
---|
| 157 | + |
---|
| 158 | + }; |
---|
| 159 | + |
---|
| 160 | + Sensor sensors = sensorManager |
---|
| 161 | + .getDefaultSensor(Sensor.TYPE_GYROSCOPE); |
---|
| 162 | + |
---|
| 163 | + sensorManager.registerListener(lsn, sensors, |
---|
| 164 | + SensorManager.SENSOR_DELAY_NORMAL); |
---|
| 165 | + this.mGLSurfaceView.onResume(); |
---|
| 166 | +save_btn.setOnClickListener(new OnClickListener() |
---|
| 167 | + { |
---|
| 168 | + |
---|
| 169 | + @Override |
---|
| 170 | + public void onClick(View v) |
---|
| 171 | + { |
---|
| 172 | + // TODO Auto-generated method stub |
---|
| 173 | + File savefile = new File("/cache/Gyroscope.txt"); |
---|
| 174 | + if (savefile.exists()) { |
---|
| 175 | + savefile.delete(); |
---|
| 176 | + } |
---|
| 177 | + if (!savefile.exists()) |
---|
| 178 | + { |
---|
| 179 | + try |
---|
| 180 | + { |
---|
| 181 | + savefile.createNewFile(); |
---|
| 182 | + } catch (IOException e) |
---|
| 183 | + { |
---|
| 184 | + // TODO Auto-generated catch block |
---|
| 185 | + e.printStackTrace(); |
---|
| 186 | + } |
---|
| 187 | + } |
---|
| 188 | + StringBuilder sb = new StringBuilder(); |
---|
| 189 | + sb.append("x_offset:" + x_offset).append("\n").append("y_offset:" + y_offset).append("\n").append("z_offset:" + x_offset); |
---|
| 190 | + String sbStirng = sb.toString(); |
---|
| 191 | + FileOutputStream fos = null; |
---|
| 192 | + try |
---|
| 193 | + { |
---|
| 194 | + fos = new FileOutputStream(savefile, false); |
---|
| 195 | + fos.write(sbStirng.getBytes()); |
---|
| 196 | + fos.close(); |
---|
| 197 | + } catch (FileNotFoundException e) |
---|
| 198 | + { |
---|
| 199 | + // TODO Auto-generated catch block |
---|
| 200 | + e.printStackTrace(); |
---|
| 201 | + } catch (IOException e) |
---|
| 202 | + { |
---|
| 203 | + // TODO Auto-generated catch block |
---|
| 204 | + e.printStackTrace(); |
---|
| 205 | + } finally |
---|
| 206 | + { |
---|
| 207 | + if (fos != null) |
---|
| 208 | + { |
---|
| 209 | + try |
---|
| 210 | + { |
---|
| 211 | + fos.close(); |
---|
| 212 | + } catch (IOException e) |
---|
| 213 | + { |
---|
| 214 | + e.printStackTrace(); |
---|
| 215 | + } |
---|
| 216 | + } |
---|
| 217 | + } |
---|
| 218 | + Toast.makeText(getApplicationContext(), getString(R.string.save_isok), Toast.LENGTH_SHORT).show(); |
---|
| 219 | + } |
---|
| 220 | + }); |
---|
| 221 | + |
---|
| 222 | + } |
---|
| 223 | + |
---|
| 224 | + // |
---|
| 225 | + |
---|
| 226 | + protected void onStop() { |
---|
| 227 | + super.onStop(); |
---|
| 228 | + sensorManager.unregisterListener(lsn); |
---|
| 229 | + } |
---|
| 230 | + |
---|
| 231 | + public boolean dispatchKeyEvent(KeyEvent event) { |
---|
| 232 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
---|
| 233 | + return false; |
---|
| 234 | + } |
---|
| 235 | + return super.dispatchKeyEvent(event); |
---|
| 236 | + } |
---|
| 237 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import java.io.BufferedInputStream;
|
---|
| 7 | +import java.io.BufferedOutputStream;
|
---|
| 8 | +import java.io.File;
|
---|
| 9 | +import java.io.FileInputStream;
|
---|
| 10 | +import java.io.FileOutputStream;
|
---|
| 11 | +import java.io.IOException;
|
---|
| 12 | +import java.io.InputStream;
|
---|
| 13 | +import java.security.Permission;
|
---|
| 14 | +import java.util.ArrayList;
|
---|
| 15 | +import java.util.Arrays;
|
---|
| 16 | +
|
---|
| 17 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 18 | +import com.DeviceTest.helper.SystemUtil;
|
---|
| 19 | +import com.DeviceTest.helper.TestCase.RESULT;
|
---|
| 20 | +import com.rockchip.dmi.DmiUtil;
|
---|
| 21 | +
|
---|
| 22 | +import android.app.Activity;
|
---|
| 23 | +import android.bluetooth.BluetoothAdapter;
|
---|
| 24 | +import android.bluetooth.BluetoothDevice;
|
---|
| 25 | +import android.content.BroadcastReceiver;
|
---|
| 26 | +import android.content.Context;
|
---|
| 27 | +import android.content.Intent;
|
---|
| 28 | +import android.content.IntentFilter;
|
---|
| 29 | +import android.content.pm.PermissionInfo;
|
---|
| 30 | +import android.os.Bundle;
|
---|
| 31 | +import android.os.Environment;
|
---|
| 32 | +import android.os.Handler;
|
---|
| 33 | +import android.os.Message;
|
---|
| 34 | +import android.util.Log;
|
---|
| 35 | +import android.view.KeyEvent;
|
---|
| 36 | +import android.view.View;
|
---|
| 37 | +import android.view.View.OnClickListener;
|
---|
| 38 | +import android.view.Window;
|
---|
| 39 | +import android.widget.Button;
|
---|
| 40 | +import android.widget.ProgressBar;
|
---|
| 41 | +import android.widget.TextView;
|
---|
| 42 | +
|
---|
| 43 | +public class HardwareInfoTestActivity extends Activity implements
|
---|
| 44 | + OnClickListener {
|
---|
| 45 | + private TextView currentView = null;
|
---|
| 46 | + private TextView cpuInfoTextView = null;
|
---|
| 47 | + private TextView memInfoTextView = null;
|
---|
| 48 | + private TextView dmiInfoTextView = null;
|
---|
| 49 | + boolean stop = false;
|
---|
| 50 | +
|
---|
| 51 | +
|
---|
| 52 | + protected void onCreate(Bundle savedInstanceState) {
|
---|
| 53 | +
|
---|
| 54 | + super.onCreate(savedInstanceState);
|
---|
| 55 | +
|
---|
| 56 | + setTitle(getTitle() + "----("
|
---|
| 57 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")");
|
---|
| 58 | + // requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 59 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 60 | +
|
---|
| 61 | + setContentView(R.layout.hardwareinfotest);
|
---|
| 62 | + Button cpuInfoButton = (Button) findViewById(R.id.btn_cpu);
|
---|
| 63 | + Button memInfoButton = (Button) findViewById(R.id.btn_mem);
|
---|
| 64 | + Button dmiInfoButton = (Button) findViewById(R.id.btn_dmi);
|
---|
| 65 | +
|
---|
| 66 | + cpuInfoTextView = (TextView) findViewById(R.id.cpu_info);
|
---|
| 67 | + memInfoTextView = (TextView) findViewById(R.id.mem_info);
|
---|
| 68 | + dmiInfoTextView = (TextView) findViewById(R.id.dmi_info);
|
---|
| 69 | +
|
---|
| 70 | + String cpuInfo = SystemUtil.execShellCmd("cat /proc/cpuinfo");
|
---|
| 71 | + String dmiInfo = DmiUtil.getDmiInfo(this, false).toString();
|
---|
| 72 | +
|
---|
| 73 | + cpuInfoTextView.setText("CPU INFO\n" + cpuInfo);
|
---|
| 74 | + memInfoTextView.setText("MEM INFO\n"
|
---|
| 75 | + + SystemUtil.execShellCmd("cat /proc/meminfo"));
|
---|
| 76 | + dmiInfoTextView.setText("DMI INFO\n" + dmiInfo);
|
---|
| 77 | +
|
---|
| 78 | + cpuInfoButton.setTag(cpuInfoTextView);
|
---|
| 79 | + memInfoButton.setTag(memInfoTextView);
|
---|
| 80 | + dmiInfoButton.setTag(dmiInfoTextView);
|
---|
| 81 | +
|
---|
| 82 | + cpuInfoButton.setOnClickListener(this);
|
---|
| 83 | + memInfoButton.setOnClickListener(this);
|
---|
| 84 | + dmiInfoButton.setOnClickListener(this);
|
---|
| 85 | +
|
---|
| 86 | + currentView = cpuInfoTextView;
|
---|
| 87 | + cpuInfoTextView.setVisibility(View.VISIBLE);
|
---|
| 88 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 89 | + findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 90 | +
|
---|
| 91 | + boolean pass = true;
|
---|
| 92 | + String infoText = "";
|
---|
| 93 | + if (!cpuInfo.contains("Processor\t: ARMv7 Processor rev 2 (v7l)")) {
|
---|
| 94 | + infoText = "cpu - Processor;";
|
---|
| 95 | + pass = false;
|
---|
| 96 | + }
|
---|
| 97 | + if (!cpuInfo.contains("CPU architecture: 7")) {
|
---|
| 98 | + infoText += "cpu - CPU architecture;";
|
---|
| 99 | + pass = false;
|
---|
| 100 | + }
|
---|
| 101 | + if (!cpuInfo.contains("CPU revision\t: 2")) {
|
---|
| 102 | + infoText += "cpu - CPU revision;";
|
---|
| 103 | + pass = false;
|
---|
| 104 | + }
|
---|
| 105 | +
|
---|
| 106 | + if (!cpuInfo.contains("Hardware\t: RK29board")) {
|
---|
| 107 | + infoText += "cpu - Hardware;";
|
---|
| 108 | + pass = false;
|
---|
| 109 | + }
|
---|
| 110 | +
|
---|
| 111 | + if (!dmiInfo.contains("Manufacture:TOSHIBA")) {
|
---|
| 112 | + infoText += "dmi - Manufacture;";
|
---|
| 113 | + if (pass) {
|
---|
| 114 | + dmiInfoButton.performClick();
|
---|
| 115 | + }
|
---|
| 116 | + pass = false;
|
---|
| 117 | + }
|
---|
| 118 | +
|
---|
| 119 | + if (pass) {
|
---|
| 120 | + findViewById(R.id.btn_Pass).performClick();
|
---|
| 121 | + } else {
|
---|
| 122 | +
|
---|
| 123 | + TextView infoView = (TextView) findViewById(R.id.hwinfoText);
|
---|
| 124 | + infoView.setText("Failed:\n" + infoText);
|
---|
| 125 | + mHandler.postDelayed(mFailedRunnable, DeviceTest.TEST_FAILED_DELAY);
|
---|
| 126 | + }
|
---|
| 127 | + }
|
---|
| 128 | +
|
---|
| 129 | + Handler mHandler = new Handler();
|
---|
| 130 | + Runnable mFailedRunnable = new Runnable() {
|
---|
| 131 | +
|
---|
| 132 | +
|
---|
| 133 | + public void run() {
|
---|
| 134 | + if(stop) {
|
---|
| 135 | + return;
|
---|
| 136 | + }
|
---|
| 137 | + mHandler.removeCallbacks(mFailedRunnable);
|
---|
| 138 | + findViewById(R.id.btn_Fail).performClick();
|
---|
| 139 | + }
|
---|
| 140 | + };
|
---|
| 141 | +
|
---|
| 142 | +
|
---|
| 143 | + public void onStop() {
|
---|
| 144 | + super.onStop();
|
---|
| 145 | + stop = true;
|
---|
| 146 | + mHandler.removeCallbacks(mFailedRunnable);
|
---|
| 147 | + }
|
---|
| 148 | +
|
---|
| 149 | + // if (device != null && progressBar.isShown()) {
|
---|
| 150 | + // progressBar.setVisibility(View.GONE);
|
---|
| 151 | + // mResult.setText("Find equipment....\n Pass!");
|
---|
| 152 | +
|
---|
| 153 | +
|
---|
| 154 | + public void onClick(View v) {
|
---|
| 155 | + TextView infoView = (TextView) v.getTag();
|
---|
| 156 | + if (currentView != null && currentView != infoView) {
|
---|
| 157 | + currentView.setVisibility(View.GONE);
|
---|
| 158 | + }
|
---|
| 159 | + infoView.setVisibility(View.VISIBLE);
|
---|
| 160 | + currentView = infoView;
|
---|
| 161 | + }
|
---|
| 162 | +
|
---|
| 163 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 164 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 165 | + return false;
|
---|
| 166 | + }
|
---|
| 167 | + return super.dispatchKeyEvent(event);
|
---|
| 168 | + }
|
---|
| 169 | +
|
---|
| 170 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | + |
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN; |
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; |
---|
| 5 | + |
---|
| 6 | +import java.io.BufferedReader; |
---|
| 7 | +import java.io.File; |
---|
| 8 | +import java.io.FileReader; |
---|
| 9 | +import java.io.IOException; |
---|
| 10 | +import java.io.RandomAccessFile; |
---|
| 11 | +import java.util.Timer; |
---|
| 12 | +import java.util.TimerTask; |
---|
| 13 | + |
---|
| 14 | +import android.app.Activity; |
---|
| 15 | +import android.content.Context; |
---|
| 16 | +import android.content.Intent; |
---|
| 17 | +import android.content.SharedPreferences; |
---|
| 18 | +import android.graphics.Color; |
---|
| 19 | +import android.os.Bundle; |
---|
| 20 | +import android.os.CountDownTimer; |
---|
| 21 | +import android.os.Handler; |
---|
| 22 | +import android.os.SystemProperties; |
---|
| 23 | +import android.util.Log; |
---|
| 24 | +import android.view.KeyEvent; |
---|
| 25 | +import android.view.MotionEvent; |
---|
| 26 | +import android.view.View; |
---|
| 27 | +import android.view.Window; |
---|
| 28 | +import android.widget.Button; |
---|
| 29 | +import android.widget.TextView; |
---|
| 30 | + |
---|
| 31 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 32 | +import com.DeviceTest.view.LcdTestView; |
---|
| 33 | +import android.os.UEventObserver; |
---|
| 34 | + |
---|
| 35 | +public class HdmiTestActivity extends Activity { |
---|
| 36 | + private final static String TAG = "HDMITEST"; |
---|
| 37 | + |
---|
| 38 | + private final static int CHANGE_COLOR = 1; |
---|
| 39 | + private final static int HDMI_SCAN = 2; |
---|
| 40 | + private int[] TestColor = {Color.RED, Color.GREEN, Color.BLUE }; |
---|
| 41 | + private LcdTestView mTestView; |
---|
| 42 | + private TextView mTitle; |
---|
| 43 | + private TextView mResult; |
---|
| 44 | + private TextView mShowTime; |
---|
| 45 | + private int mTestNo; |
---|
| 46 | + private boolean isStart = false; |
---|
| 47 | + private File HdmiFile = null; |
---|
| 48 | + private File HdmiState = null; |
---|
| 49 | + private File HdmiDisplayEnable=null; |
---|
| 50 | + private File HdmiDisplayMode=null; |
---|
| 51 | + private File HdmiDisplayConnect=null; |
---|
| 52 | + @Override |
---|
| 53 | + public void onCreate(Bundle savedInstanceState) { |
---|
| 54 | + super.onCreate(savedInstanceState); |
---|
| 55 | + requestWindowFeature(Window.FEATURE_NO_TITLE); |
---|
| 56 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON); |
---|
| 57 | + setContentView(R.layout.hdmitest); |
---|
| 58 | + |
---|
| 59 | + mTestView = (LcdTestView) findViewById(R.id.lcdtestview); |
---|
| 60 | + mResult = (TextView) findViewById(R.id.result); |
---|
| 61 | + mShowTime = (TextView) findViewById(R.id.TimeShow); |
---|
| 62 | + mTestNo = 0; |
---|
| 63 | + |
---|
| 64 | + HdmiFile = new File("/sys/class/hdmi/hdmi-0/enable"); |
---|
| 65 | + HdmiState = new File("/sys/devices/platform/display-subsystem/drm/card0/card0-HDMI-A-1/status"); |
---|
| 66 | + HdmiDisplayEnable=new File("/sys/class/display/HDMI/enable"); |
---|
| 67 | + //HdmiDisplayMode=new File("/sys/class/display/HDMI/mode"); |
---|
| 68 | + HdmiDisplayConnect=new File("sys/class/display/HDMI/connect"); |
---|
| 69 | + ControlButtonUtil.initControlButtonView(this); |
---|
| 70 | + ((Button) findViewById(R.id.btn_Pass)).setVisibility(View.INVISIBLE); |
---|
| 71 | + } |
---|
| 72 | + |
---|
| 73 | + @Override |
---|
| 74 | + public void onResume() { |
---|
| 75 | + super.onResume(); |
---|
| 76 | + mHandler.sendEmptyMessageDelayed(HDMI_SCAN, 500); |
---|
| 77 | + } |
---|
| 78 | + |
---|
| 79 | + @Override |
---|
| 80 | + public void onPause() { |
---|
| 81 | + super.onPause(); |
---|
| 82 | + mHandler.removeMessages(HDMI_SCAN); |
---|
| 83 | + mHandler.removeMessages(CHANGE_COLOR); |
---|
| 84 | + } |
---|
| 85 | + |
---|
| 86 | + private Handler mHandler = new Handler() { |
---|
| 87 | + public void handleMessage(android.os.Message msg) { |
---|
| 88 | + switch (msg.what) { |
---|
| 89 | + case CHANGE_COLOR: |
---|
| 90 | + if (mTestNo > TestColor.length - 1) { |
---|
| 91 | + finishHdmiTest(); |
---|
| 92 | + return; |
---|
| 93 | + } |
---|
| 94 | + ControlButtonUtil.Hide(); |
---|
| 95 | + mShowTime.setVisibility(View.VISIBLE); |
---|
| 96 | + mTestView.setVisibility(View.VISIBLE); |
---|
| 97 | + mResult.setText(R.string.HdmiStart); |
---|
| 98 | + mTestView.setBackgroundColor(TestColor[mTestNo++]); |
---|
| 99 | + sendEmptyMessageDelayed(CHANGE_COLOR, 1500); |
---|
| 100 | + break; |
---|
| 101 | + case HDMI_SCAN: |
---|
| 102 | + this.removeMessages(HDMI_SCAN); |
---|
| 103 | + if (startHdmiTest()) { |
---|
| 104 | + mResult.setText(R.string.HdmiPrepare); |
---|
| 105 | + //setHdmiConfig(HdmiFile, true); |
---|
| 106 | + mTestNo = 0; |
---|
| 107 | + sendEmptyMessageDelayed(CHANGE_COLOR, 4000); |
---|
| 108 | + }else{ |
---|
| 109 | + sendEmptyMessageDelayed(HDMI_SCAN, 500); |
---|
| 110 | + } |
---|
| 111 | + break; |
---|
| 112 | + default: |
---|
| 113 | + break; |
---|
| 114 | + } |
---|
| 115 | + } |
---|
| 116 | + }; |
---|
| 117 | + |
---|
| 118 | + public boolean startHdmiTest() { |
---|
| 119 | + if (!isStart && isHdmiConnected()) { |
---|
| 120 | + mResult.setText(R.string.HdmiPrepare); |
---|
| 121 | + setHdmiConfig(HdmiFile, true); |
---|
| 122 | + mTestNo = 0; |
---|
| 123 | + isStart = true; |
---|
| 124 | + return true; |
---|
| 125 | + } |
---|
| 126 | + mResult.setText(R.string.HdmiNoInsert); |
---|
| 127 | + Log.i(TAG, "Hdmi no insert"); |
---|
| 128 | + return false; |
---|
| 129 | + } |
---|
| 130 | + |
---|
| 131 | + public void finishHdmiTest() { |
---|
| 132 | + ((Button) findViewById(R.id.btn_Pass)).setVisibility(View.VISIBLE); |
---|
| 133 | + ControlButtonUtil.Show(); |
---|
| 134 | + isStart = false; |
---|
| 135 | + mShowTime.setVisibility(View.GONE); |
---|
| 136 | + mTestView.setVisibility(View.GONE); |
---|
| 137 | + mResult.setText(R.string.HdmiResult); |
---|
| 138 | +// setHdmiConfig(HdmiFile, false); |
---|
| 139 | + } |
---|
| 140 | + |
---|
| 141 | + protected boolean isHdmiConnected() { |
---|
| 142 | + File file = HdmiState; |
---|
| 143 | + boolean isConnected = false; |
---|
| 144 | + if (file.exists()) { |
---|
| 145 | + try { |
---|
| 146 | + FileReader fread = new FileReader(file); |
---|
| 147 | + BufferedReader buffer = new BufferedReader(fread); |
---|
| 148 | + String strPlug = "plug=1"; |
---|
| 149 | + String str = null; |
---|
| 150 | + |
---|
| 151 | + while ((str = buffer.readLine()) != null) { |
---|
| 152 | + int length = str.length(); |
---|
| 153 | + //if ((length == 6) && (str.equals(strPlug))) { |
---|
| 154 | + if(str.equals("connected")){ |
---|
| 155 | + isConnected = true; |
---|
| 156 | + break; |
---|
| 157 | + } else { |
---|
| 158 | + isConnected = false; |
---|
| 159 | + } |
---|
| 160 | + } |
---|
| 161 | + } catch (IOException e) { |
---|
| 162 | + Log.e(TAG, "IO Exception"); |
---|
| 163 | + } |
---|
| 164 | + } else { |
---|
| 165 | + Log.e(TAG, file + "isHdmiConnected : file no exist"); |
---|
| 166 | + } |
---|
| 167 | + return isConnected; |
---|
| 168 | + } |
---|
| 169 | + |
---|
| 170 | + protected void setHdmiConfig(File file, boolean enable) { |
---|
| 171 | + if (SystemProperties.get("ro.board.platform", "none").equals("rk29xx")){ |
---|
| 172 | + if (file.exists()) { |
---|
| 173 | + try { |
---|
| 174 | + String strDouble = "2"; |
---|
| 175 | + String strChecked = "1"; |
---|
| 176 | + String strUnChecked = "0"; |
---|
| 177 | + RandomAccessFile rdf = null; |
---|
| 178 | + rdf = new RandomAccessFile(file, "rw"); |
---|
| 179 | + |
---|
| 180 | + if (enable) { |
---|
| 181 | + rdf.writeBytes(strChecked); |
---|
| 182 | + } else { |
---|
| 183 | + rdf.writeBytes(strUnChecked); |
---|
| 184 | + |
---|
| 185 | + } |
---|
| 186 | + |
---|
| 187 | + } catch (IOException re) { |
---|
| 188 | + Log.e(TAG, "IO Exception"); |
---|
| 189 | + } |
---|
| 190 | + } else { |
---|
| 191 | + Log.i(TAG, "The File " + file + " is not exists"); |
---|
| 192 | + } |
---|
| 193 | + } else{ |
---|
| 194 | + if (file.exists()) { |
---|
| 195 | + try { |
---|
| 196 | + Log.d(TAG, "setHdmiConfig"); |
---|
| 197 | + String strChecked = "1"; |
---|
| 198 | + String strUnChecked = "0"; |
---|
| 199 | + |
---|
| 200 | + RandomAccessFile rdf = null; |
---|
| 201 | + rdf = new RandomAccessFile(file, "rw"); |
---|
| 202 | + if (enable) { |
---|
| 203 | + rdf.writeBytes(strChecked); |
---|
| 204 | + } else { |
---|
| 205 | + rdf.writeBytes(strUnChecked); |
---|
| 206 | + } |
---|
| 207 | + } catch (IOException re) { |
---|
| 208 | + Log.e(TAG, "IO Exception"); |
---|
| 209 | + re.printStackTrace(); |
---|
| 210 | + } |
---|
| 211 | + } else { |
---|
| 212 | + Log.i(TAG, "The File " + file + " is not exists"); |
---|
| 213 | + } |
---|
| 214 | + } |
---|
| 215 | + } |
---|
| 216 | + |
---|
| 217 | + public boolean dispatchKeyEvent(KeyEvent event) { |
---|
| 218 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
---|
| 219 | + return false; |
---|
| 220 | + } |
---|
| 221 | + return super.dispatchKeyEvent(event); |
---|
| 222 | + } |
---|
| 223 | + |
---|
| 224 | + public boolean onTouchEvent(MotionEvent paramMotionEvent) { |
---|
| 225 | + if (paramMotionEvent.getAction() == MotionEvent.ACTION_DOWN && !isStart) { |
---|
| 226 | + mHandler.sendEmptyMessageDelayed(HDMI_SCAN, 500); |
---|
| 227 | + } |
---|
| 228 | + return super.onTouchEvent(paramMotionEvent); |
---|
| 229 | + } |
---|
| 230 | + |
---|
| 231 | + |
---|
| 232 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import java.io.File;
|
---|
| 7 | +
|
---|
| 8 | +import android.app.Activity;
|
---|
| 9 | +import android.content.BroadcastReceiver;
|
---|
| 10 | +import android.content.Context;
|
---|
| 11 | +import android.content.Intent;
|
---|
| 12 | +import android.content.IntentFilter;
|
---|
| 13 | +import android.media.AudioManager;
|
---|
| 14 | +import android.os.Bundle;
|
---|
| 15 | +import android.os.Environment;
|
---|
| 16 | +import android.os.Handler;
|
---|
| 17 | +import android.os.Message;
|
---|
| 18 | +import android.os.StatFs;
|
---|
| 19 | +import android.util.Log;
|
---|
| 20 | +import android.view.KeyEvent;
|
---|
| 21 | +import android.view.View;
|
---|
| 22 | +import android.view.Window;
|
---|
| 23 | +import android.widget.TextView;
|
---|
| 24 | +
|
---|
| 25 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 26 | +import com.DeviceTest.helper.Recorder;
|
---|
| 27 | +
|
---|
| 28 | +public class HeadsetMicTestActivity extends Activity {
|
---|
| 29 | +
|
---|
| 30 | + private static final String TAG = HeadsetMicTestActivity.class
|
---|
| 31 | + .getSimpleName();
|
---|
| 32 | +
|
---|
| 33 | + private final static String ERRMSG = "Record error";
|
---|
| 34 | +
|
---|
| 35 | + private static final int MSG_TEST_MIC_ING = 8738;
|
---|
| 36 | + private static final int MSG_TEST_MIC_OVER = 13107;
|
---|
| 37 | + private static final int MSG_TEST_MIC_START = 4369;
|
---|
| 38 | + boolean isSDcardTestOk = false;
|
---|
| 39 | + boolean isTestStart = false;
|
---|
| 40 | + AudioManager mAudioManager;
|
---|
| 41 | + private Handler mHandler;
|
---|
| 42 | + boolean mHeadSetOn = false;
|
---|
| 43 | + private BroadcastReceiver mHeadsetReceiver;
|
---|
| 44 | + boolean mIsTesting = false;
|
---|
| 45 | + int mOldVolume;
|
---|
| 46 | + Recorder mRecorder;
|
---|
| 47 | + TextView mResult;
|
---|
| 48 | + TextView mText;
|
---|
| 49 | + int mTimes = 0;
|
---|
| 50 | + TextView mTitle;
|
---|
| 51 | +
|
---|
| 52 | + public HeadsetMicTestActivity() {
|
---|
| 53 | +
|
---|
| 54 | + this.mHeadsetReceiver = new MBroadcastReceiver();
|
---|
| 55 | +
|
---|
| 56 | + this.mHandler = new MyHandler();
|
---|
| 57 | + }
|
---|
| 58 | +
|
---|
| 59 | +
|
---|
| 60 | + protected void onCreate(Bundle savedInstanceState) {
|
---|
| 61 | +
|
---|
| 62 | + super.onCreate(savedInstanceState);
|
---|
| 63 | +
|
---|
| 64 | + setTitle(getTitle() + "----("
|
---|
| 65 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")");
|
---|
| 66 | + //requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 67 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 68 | +
|
---|
| 69 | + setContentView(R.layout.headsetmictest);
|
---|
| 70 | +
|
---|
| 71 | + this.mResult = (TextView) findViewById(R.id.headsetresultText);
|
---|
| 72 | +
|
---|
| 73 | + this.mResult.setVisibility(View.VISIBLE);
|
---|
| 74 | + this.mResult.setGravity(17);
|
---|
| 75 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 76 | + this.mRecorder = new Recorder();
|
---|
| 77 | +
|
---|
| 78 | + this.mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
---|
| 79 | +
|
---|
| 80 | + }
|
---|
| 81 | +
|
---|
| 82 | +
|
---|
| 83 | + protected void onResume() {
|
---|
| 84 | +
|
---|
| 85 | + super.onResume();
|
---|
| 86 | + this.isSDcardTestOk = false;
|
---|
| 87 | + if (!Environment.getExternalStorageState().equals(
|
---|
| 88 | + Environment.MEDIA_MOUNTED)) {
|
---|
| 89 | + this.mResult.setText("Please insert sdcard");
|
---|
| 90 | + return;
|
---|
| 91 | + }
|
---|
| 92 | +
|
---|
| 93 | + if (!isSDcardHasSpace()) {
|
---|
| 94 | +
|
---|
| 95 | + this.mResult.setText("sdcard has no space");
|
---|
| 96 | + stopMediaPlayBack();
|
---|
| 97 | + return;
|
---|
| 98 | +
|
---|
| 99 | + }
|
---|
| 100 | + stopMediaPlayBack();
|
---|
| 101 | + this.isSDcardTestOk = true;
|
---|
| 102 | + this.mOldVolume = this.mAudioManager
|
---|
| 103 | + .getStreamVolume(AudioManager.STREAM_MUSIC);
|
---|
| 104 | + int maxVolume = this.mAudioManager
|
---|
| 105 | + .getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
---|
| 106 | + this.mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC,
|
---|
| 107 | + maxVolume, 0);
|
---|
| 108 | +
|
---|
| 109 | + this.mHeadSetOn = this.mAudioManager.isWiredHeadsetOn();
|
---|
| 110 | +
|
---|
| 111 | + if (!this.mHeadSetOn) {
|
---|
| 112 | + this.mResult.setText("Please insert earphone!");
|
---|
| 113 | + return;
|
---|
| 114 | + }
|
---|
| 115 | +
|
---|
| 116 | + IntentFilter localIntentFilter = new IntentFilter(
|
---|
| 117 | + "android.intent.action.HEADSET_PLUG");
|
---|
| 118 | +
|
---|
| 119 | + registerReceiver(this.mHeadsetReceiver, localIntentFilter);
|
---|
| 120 | +
|
---|
| 121 | + this.mIsTesting = true;
|
---|
| 122 | + this.mHandler.sendEmptyMessage(MSG_TEST_MIC_START);
|
---|
| 123 | +
|
---|
| 124 | + }
|
---|
| 125 | +
|
---|
| 126 | +
|
---|
| 127 | + protected void onPause() {
|
---|
| 128 | + super.onPause();
|
---|
| 129 | +
|
---|
| 130 | +
|
---|
| 131 | + if (!mHeadSetOn) {
|
---|
| 132 | + return;
|
---|
| 133 | +
|
---|
| 134 | + }
|
---|
| 135 | +
|
---|
| 136 | +
|
---|
| 137 | + if (this.isSDcardTestOk)
|
---|
| 138 | + {
|
---|
| 139 | +
|
---|
| 140 | + switch (this.mRecorder.state()) {
|
---|
| 141 | +
|
---|
| 142 | + case Recorder.IDLE_STATE:
|
---|
| 143 | + this.mRecorder.delete();
|
---|
| 144 | + break;
|
---|
| 145 | + case Recorder.PLAYING_STATE:
|
---|
| 146 | + this.mRecorder.stop();
|
---|
| 147 | + this.mRecorder.delete();
|
---|
| 148 | + break;
|
---|
| 149 | + case Recorder.RECORDING_STATE:
|
---|
| 150 | + this.mRecorder.stop();
|
---|
| 151 | + this.mRecorder.clear();
|
---|
| 152 | + break;
|
---|
| 153 | + }
|
---|
| 154 | +
|
---|
| 155 | + unregisterReceiver(mHeadsetReceiver);
|
---|
| 156 | + mAudioManager.setStreamVolume(3, mOldVolume, 0);
|
---|
| 157 | + }
|
---|
| 158 | +
|
---|
| 159 | + }
|
---|
| 160 | +
|
---|
| 161 | + public boolean isSDcardHasSpace() {
|
---|
| 162 | + File pathFile = android.os.Environment.getExternalStorageDirectory();
|
---|
| 163 | +
|
---|
| 164 | + StatFs statfs = new StatFs(pathFile.getPath());
|
---|
| 165 | +
|
---|
| 166 | + if (statfs.getAvailableBlocks() > 1) {
|
---|
| 167 | +
|
---|
| 168 | + return true;
|
---|
| 169 | +
|
---|
| 170 | + }
|
---|
| 171 | +
|
---|
| 172 | + return false;
|
---|
| 173 | +
|
---|
| 174 | + }
|
---|
| 175 | +
|
---|
| 176 | + public void stopMediaPlayBack() {
|
---|
| 177 | + Intent localIntent = new Intent("com.android.music.musicservicecommand");
|
---|
| 178 | + localIntent.putExtra("command", "pause");
|
---|
| 179 | + sendBroadcast(localIntent);
|
---|
| 180 | + }
|
---|
| 181 | +
|
---|
| 182 | + class MyHandler extends Handler {
|
---|
| 183 | + MyHandler() {
|
---|
| 184 | +
|
---|
| 185 | + }
|
---|
| 186 | +
|
---|
| 187 | +
|
---|
| 188 | + public void handleMessage(Message msg) {
|
---|
| 189 | +
|
---|
| 190 | + super.handleMessage(msg);
|
---|
| 191 | +
|
---|
| 192 | + switch (msg.what) {
|
---|
| 193 | +
|
---|
| 194 | + case MSG_TEST_MIC_START:
|
---|
| 195 | + isTestStart = true;
|
---|
| 196 | + removeMessages(MSG_TEST_MIC_START);
|
---|
| 197 | + mTimes = 10;
|
---|
| 198 | + mResult.setText(" " + mTimes + " ");
|
---|
| 199 | + mRecorder.startRecording(3, ".amr");
|
---|
| 200 | + sendEmptyMessageDelayed(MSG_TEST_MIC_ING, 1000L);
|
---|
| 201 | + break;
|
---|
| 202 | + case MSG_TEST_MIC_ING:
|
---|
| 203 | + removeMessages(MSG_TEST_MIC_ING);
|
---|
| 204 | + if (mTimes > 0) {
|
---|
| 205 | +
|
---|
| 206 | + mResult.setText(" " + mTimes + " ");
|
---|
| 207 | + mTimes--;
|
---|
| 208 | +
|
---|
| 209 | + Log.i(TAG, "mTimes=" + mTimes);
|
---|
| 210 | +
|
---|
| 211 | + sendEmptyMessageDelayed(MSG_TEST_MIC_ING, 1000L);
|
---|
| 212 | + } else {
|
---|
| 213 | + sendEmptyMessage(MSG_TEST_MIC_OVER);
|
---|
| 214 | + }
|
---|
| 215 | + break;
|
---|
| 216 | + case MSG_TEST_MIC_OVER:
|
---|
| 217 | + removeMessages(MSG_TEST_MIC_OVER);
|
---|
| 218 | +
|
---|
| 219 | + mRecorder.stopRecording();
|
---|
| 220 | +
|
---|
| 221 | + if (isTestStart) {
|
---|
| 222 | + isTestStart = false;
|
---|
| 223 | + if (mRecorder.sampleLength() > 0) {
|
---|
| 224 | + mResult.setText("record successs!start Play back");
|
---|
| 225 | + mRecorder.startPlayback();
|
---|
| 226 | + } else {
|
---|
| 227 | + mResult.setText(ERRMSG);
|
---|
| 228 | + }
|
---|
| 229 | +
|
---|
| 230 | + }
|
---|
| 231 | +
|
---|
| 232 | + break;
|
---|
| 233 | + }
|
---|
| 234 | +
|
---|
| 235 | + }
|
---|
| 236 | +
|
---|
| 237 | + }
|
---|
| 238 | +
|
---|
| 239 | + class MBroadcastReceiver extends BroadcastReceiver {
|
---|
| 240 | + public void onReceive(Context paramContext, Intent paramIntent) {
|
---|
| 241 | +
|
---|
| 242 | + String action = paramIntent.getAction();
|
---|
| 243 | + Log.i(TAG, "action");
|
---|
| 244 | + if ("android.intent.action.HEADSET_PLUG".equals(action)) {
|
---|
| 245 | + if (paramIntent.getIntExtra("state", 0) != 1) {
|
---|
| 246 | +
|
---|
| 247 | + Log.i(TAG, "HEADSET has bean removed");
|
---|
| 248 | + mIsTesting = false;
|
---|
| 249 | + mHandler.sendEmptyMessage(MSG_TEST_MIC_OVER);
|
---|
| 250 | +
|
---|
| 251 | + return;
|
---|
| 252 | + }
|
---|
| 253 | +
|
---|
| 254 | + if (!mIsTesting) {
|
---|
| 255 | + Log.i(TAG, "HEADSET has bean inserted");
|
---|
| 256 | + mIsTesting = true;
|
---|
| 257 | + mHandler.sendEmptyMessage(MSG_TEST_MIC_START);
|
---|
| 258 | + }
|
---|
| 259 | + }
|
---|
| 260 | +
|
---|
| 261 | + }
|
---|
| 262 | + }
|
---|
| 263 | +
|
---|
| 264 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 265 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 266 | + return false;
|
---|
| 267 | + }
|
---|
| 268 | + return super.dispatchKeyEvent(event);
|
---|
| 269 | + }
|
---|
| 270 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +import java.io.File;
|
---|
| 3 | +
|
---|
| 4 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 5 | +import com.DeviceTest.helper.SystemInfoUtil;
|
---|
| 6 | +
|
---|
| 7 | +import android.app.Activity;
|
---|
| 8 | +import android.content.Context;
|
---|
| 9 | +import android.content.DialogInterface;
|
---|
| 10 | +import android.os.Bundle;
|
---|
| 11 | +import android.os.Environment;
|
---|
| 12 | +import android.os.Handler;
|
---|
| 13 | +import android.os.Message;
|
---|
| 14 | +import android.os.StatFs;
|
---|
| 15 | +import android.os.storage.StorageManager;
|
---|
| 16 | +import android.os.storage.StorageVolume;
|
---|
| 17 | +import android.os.SystemProperties;
|
---|
| 18 | +import android.os.storage.StorageEventListener;
|
---|
| 19 | +import android.text.format.Formatter;
|
---|
| 20 | +import android.util.Log;
|
---|
| 21 | +import android.widget.Button;
|
---|
| 22 | +import android.widget.TextView;
|
---|
| 23 | +import java.io.FileReader;
|
---|
| 24 | +import java.io.BufferedReader;
|
---|
| 25 | +import java.io.FileNotFoundException;
|
---|
| 26 | +import java.io.IOException;
|
---|
| 27 | +
|
---|
| 28 | +public class InfomationActivity extends Activity {
|
---|
| 29 | + private final static String TAG = "InfomationActivity";
|
---|
| 30 | +
|
---|
| 31 | + private TextView mCPUInfoTV;
|
---|
| 32 | + private TextView mMemoryInfoTV;
|
---|
| 33 | + //private TextView mNandFlashTotalTV;
|
---|
| 34 | + //private TextView mNandFlashAvailTV;
|
---|
| 35 | + private TextView mInternalAvailTV;
|
---|
| 36 | + private TextView mInternalAvailSizeTV;
|
---|
| 37 | +
|
---|
| 38 | + public String flash_path = null;
|
---|
| 39 | + public String sdcard_path = null;
|
---|
| 40 | + public String usb_path = null;
|
---|
| 41 | + private int flash_pit = 0;
|
---|
| 42 | + private int sdcard_pit = 1;
|
---|
| 43 | + private int usb_pit = 2;
|
---|
| 44 | + private StorageVolume[] storageVolumes = null;
|
---|
| 45 | + private StorageManager mStorageManager = null;
|
---|
| 46 | + private final static int MSG_OK=0;
|
---|
| 47 | +
|
---|
| 48 | + public void onCreate(Bundle savedInstanceState) {
|
---|
| 49 | + super.onCreate(savedInstanceState);
|
---|
| 50 | + setContentView(R.layout.infomation);
|
---|
| 51 | + InitStorage();
|
---|
| 52 | + initRes();
|
---|
| 53 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 54 | + //Cancel automatically passing test.
|
---|
| 55 | + //handler.sendEmptyMessageDelayed(MSG_OK, 2500);
|
---|
| 56 | + }
|
---|
| 57 | +
|
---|
| 58 | + private Handler handler=new Handler(){
|
---|
| 59 | + @Override
|
---|
| 60 | + public void handleMessage(Message msg) {
|
---|
| 61 | + switch(msg.what){
|
---|
| 62 | + case MSG_OK:
|
---|
| 63 | + ((Button) findViewById(R.id.btn_Pass)).performClick();
|
---|
| 64 | + }
|
---|
| 65 | + }
|
---|
| 66 | + };
|
---|
| 67 | +
|
---|
| 68 | + @Override
|
---|
| 69 | + protected void onResume() {
|
---|
| 70 | + super.onResume();
|
---|
| 71 | + updateView();
|
---|
| 72 | + }
|
---|
| 73 | +
|
---|
| 74 | + private void initRes() {
|
---|
| 75 | + mCPUInfoTV = (TextView) findViewById(R.id.cpuinfo_tv);
|
---|
| 76 | + mMemoryInfoTV = (TextView) findViewById(R.id.meminfo_tv);
|
---|
| 77 | + //mNandFlashTotalTV = (TextView) findViewById(R.id.nand_total_tv);
|
---|
| 78 | + //mNandFlashAvailTV = (TextView) findViewById(R.id.nand_avail_tv);
|
---|
| 79 | + mInternalAvailTV = (TextView) findViewById(R.id.internal_avail_tv);
|
---|
| 80 | + mInternalAvailSizeTV = (TextView) findViewById(R.id.internal_avail_size_tv);
|
---|
| 81 | + }
|
---|
| 82 | +
|
---|
| 83 | + private String getCpuInfoString() {
|
---|
| 84 | + StringBuilder cpuInfoSB = new StringBuilder();
|
---|
| 85 | + /*cpuInfoSB.append("processor : ");*/
|
---|
| 86 | + /*cpuInfoSB.append(SystemInfoUtil.getCpuName()).append(" ").append("\n");*/
|
---|
| 87 | + cpuInfoSB.append(SystemInfoUtil.getNumCores()+"").append("").append(" * ").append(""+SystemInfoUtil.getMaxCpuFreq()+" Hz");
|
---|
| 88 | + return cpuInfoSB.toString();
|
---|
| 89 | + }
|
---|
| 90 | +
|
---|
| 91 | + private long getEMMC() {
|
---|
| 92 | + try {
|
---|
| 93 | +
|
---|
| 94 | + int blockNum = 0;
|
---|
| 95 | + for(int i=0;i<5;i++) {
|
---|
| 96 | + String path=String.format("/sys/block/mmcblk%dboot0", i);
|
---|
| 97 | + if(new File(path).exists()) {
|
---|
| 98 | + blockNum = i;
|
---|
| 99 | + }
|
---|
| 100 | + }
|
---|
| 101 | +
|
---|
| 102 | + File targetFile = null;
|
---|
| 103 | +
|
---|
| 104 | + if ( blockNum == 0 ) {
|
---|
| 105 | + File File0 = new File("/sys/block/mmcblk0/size");
|
---|
| 106 | + if(File0.exists()) {
|
---|
| 107 | + targetFile = File0;
|
---|
| 108 | + }
|
---|
| 109 | + }
|
---|
| 110 | +
|
---|
| 111 | +
|
---|
| 112 | + if ( blockNum == 1 ) {
|
---|
| 113 | + File File1 = new File("/sys/block/mmcblk1/size");
|
---|
| 114 | + if(File1.exists()){
|
---|
| 115 | + targetFile = File1;
|
---|
| 116 | + }
|
---|
| 117 | +
|
---|
| 118 | + }
|
---|
| 119 | +
|
---|
| 120 | + if ( blockNum == 2) {
|
---|
| 121 | + File File2 = new File("/sys/block/mmcblk2/size");
|
---|
| 122 | + if(File2.exists()){
|
---|
| 123 | + targetFile = File2;
|
---|
| 124 | + }
|
---|
| 125 | + }
|
---|
| 126 | +
|
---|
| 127 | + //Log.d(TAG, "tanzh------" + targetFile.getPath());
|
---|
| 128 | +
|
---|
| 129 | +
|
---|
| 130 | + FileReader fr = new FileReader(targetFile.getPath());
|
---|
| 131 | + BufferedReader br = new BufferedReader(fr);
|
---|
| 132 | + String text = br.readLine();
|
---|
| 133 | + long result = Long.valueOf(text) / 2000000;
|
---|
| 134 | + int temp = 0;
|
---|
| 135 | + if (result > 54 && result < 66) {
|
---|
| 136 | + temp = 64;
|
---|
| 137 | + } else if (result > 24 && result < 34) {
|
---|
| 138 | + temp = 32;
|
---|
| 139 | + } else if (result > 12 && result < 18) {
|
---|
| 140 | + temp = 16;
|
---|
| 141 | + } else if (result > 6 && result < 10) {
|
---|
| 142 | + temp = 8;
|
---|
| 143 | + }
|
---|
| 144 | + return temp;
|
---|
| 145 | + } catch(FileNotFoundException e){
|
---|
| 146 | + e.printStackTrace();
|
---|
| 147 | + } catch(IOException e){
|
---|
| 148 | + e.printStackTrace();
|
---|
| 149 | + }
|
---|
| 150 | + return -1;
|
---|
| 151 | + }
|
---|
| 152 | +
|
---|
| 153 | +
|
---|
| 154 | + private void updateView() {
|
---|
| 155 | + mCPUInfoTV.setText(getCpuInfoString());
|
---|
| 156 | + mMemoryInfoTV.setText(SystemInfoUtil.GetMemInfo1(this));
|
---|
| 157 | + //updateMemoryStatus(flash_path);
|
---|
| 158 | + File dataPath = Environment.getDataDirectory();
|
---|
| 159 | + StatFs stat = new StatFs(dataPath.getPath());
|
---|
| 160 | + long blockSize = stat.getBlockSize();
|
---|
| 161 | + long blockCount = stat.getBlockCount();
|
---|
| 162 | +
|
---|
| 163 | +
|
---|
| 164 | +
|
---|
| 165 | + // long availableBlocks = stat.getAvailableBlocks();
|
---|
| 166 | + //mInternalAvailSizeTV.setText(formatSize(blockCount * blockSize));
|
---|
| 167 | + mInternalAvailSizeTV.setText(getEMMC() + "GB");
|
---|
| 168 | +
|
---|
| 169 | + //Log.d(TAG,"formatSize(availableBlocks * blockSize)="+formatSize(availableBlocks * blockSize));
|
---|
| 170 | + }
|
---|
| 171 | +
|
---|
| 172 | +
|
---|
| 173 | + private void updateMemoryStatus(String path) {
|
---|
| 174 | + String status = SystemProperties.get("EXTERNAL_STORAGE_STATE","unmounted");
|
---|
| 175 | + if (flash_path!=null&&path.equals(flash_path)) {
|
---|
| 176 | + status = mStorageManager.getVolumeState(path);
|
---|
| 177 | + }
|
---|
| 178 | + String readOnly = "";
|
---|
| 179 | + if (status.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
|
---|
| 180 | + status = Environment.MEDIA_MOUNTED;
|
---|
| 181 | + readOnly = getString(R.string.read_only);
|
---|
| 182 | + }
|
---|
| 183 | +
|
---|
| 184 | + if (status.equals(Environment.MEDIA_MOUNTED)) {
|
---|
| 185 | + try {
|
---|
| 186 | + //File path = Environment.getExternalStorageDirectory();
|
---|
| 187 | + StatFs stat = new StatFs(path);
|
---|
| 188 | + long blockSize = stat.getBlockSize();
|
---|
| 189 | + long totalBlocks = stat.getBlockCount();
|
---|
| 190 | + long availableBlocks = stat.getAvailableBlocks();
|
---|
| 191 | +
|
---|
| 192 | + /*if (path.equals(flash_path)){
|
---|
| 193 | + mNandFlashTotalTV.setText(getString(R.string.total_space)+":"+formatSize(totalBlocks * blockSize));
|
---|
| 194 | + mNandFlashAvailTV.setText(getString(R.string.available_space)+":"+formatSize(availableBlocks * blockSize) + readOnly);
|
---|
| 195 | + }*/
|
---|
| 196 | + } catch (IllegalArgumentException e) {
|
---|
| 197 | + // this can occur if the SD card is removed, but we haven't received the
|
---|
| 198 | + // ACTION_MEDIA_REMOVED Intent yet.
|
---|
| 199 | + status = Environment.MEDIA_REMOVED;
|
---|
| 200 | + }
|
---|
| 201 | +
|
---|
| 202 | + } else {
|
---|
| 203 | + if (flash_path!=null&&path.equals(flash_path)){
|
---|
| 204 | + /*mNandFlashTotalTV.setText(getString(R.string.nand_unavailable));
|
---|
| 205 | + mNandFlashAvailTV.setText(getString(R.string.nand_unavailable));*/
|
---|
| 206 | + if (status.equals(Environment.MEDIA_UNMOUNTED) ||
|
---|
| 207 | + status.equals(Environment.MEDIA_NOFS) ||
|
---|
| 208 | + status.equals(Environment.MEDIA_UNMOUNTABLE) ) {
|
---|
| 209 | + }
|
---|
| 210 | + }
|
---|
| 211 | + }
|
---|
| 212 | +
|
---|
| 213 | + File dataPath = Environment.getDataDirectory();
|
---|
| 214 | + StatFs stat = new StatFs(dataPath.getPath());
|
---|
| 215 | + long blockSize = stat.getBlockSize();
|
---|
| 216 | + long availableBlocks = stat.getAvailableBlocks();
|
---|
| 217 | + mInternalAvailTV.setText(getString(R.string.available_space)+":"+formatSize(availableBlocks * blockSize));
|
---|
| 218 | + Log.d(TAG,"formatSize(availableBlocks * blockSize)="+formatSize(availableBlocks * blockSize));
|
---|
| 219 | + }
|
---|
| 220 | +
|
---|
| 221 | + private String formatSize(long size) {
|
---|
| 222 | + return Formatter.formatFileSize(this, size);
|
---|
| 223 | + }
|
---|
| 224 | +
|
---|
| 225 | + public void onCancel(DialogInterface dialog) {
|
---|
| 226 | + finish();
|
---|
| 227 | + }
|
---|
| 228 | +
|
---|
| 229 | + private void InitStorage(){
|
---|
| 230 | + if (mStorageManager == null) {
|
---|
| 231 | + mStorageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE);
|
---|
| 232 | + mStorageManager.registerListener(mStorageListener);
|
---|
| 233 | + storageVolumes = mStorageManager.getVolumeList();
|
---|
| 234 | + Log.e(TAG,"storageVolumes.length:"+storageVolumes.length);
|
---|
| 235 | + if(storageVolumes.length >= 3){
|
---|
| 236 | + flash_path = storageVolumes[flash_pit].getPath();
|
---|
| 237 | + sdcard_path = storageVolumes[sdcard_pit].getPath();
|
---|
| 238 | + usb_path = storageVolumes[usb_pit].getPath();
|
---|
| 239 | + Log.d(TAG, " _____ " + flash_path + " " + sdcard_path + " " + usb_path);
|
---|
| 240 | + }
|
---|
| 241 | + }
|
---|
| 242 | + }
|
---|
| 243 | +
|
---|
| 244 | + StorageEventListener mStorageListener = new StorageEventListener() {
|
---|
| 245 | +
|
---|
| 246 | + @Override
|
---|
| 247 | + public void onStorageStateChanged(String path, String oldState, String newState) {
|
---|
| 248 | + Log.d(TAG, "Received storage state changed notification that " +
|
---|
| 249 | + path + " changed state from " + oldState +
|
---|
| 250 | + " to " + newState);
|
---|
| 251 | + if (path.equals(sdcard_path) && !newState.equals(Environment.MEDIA_MOUNTED)) {
|
---|
| 252 | + } else {
|
---|
| 253 | + updateMemoryStatus(flash_path);
|
---|
| 254 | + }
|
---|
| 255 | + }
|
---|
| 256 | + };
|
---|
| 257 | +
|
---|
| 258 | +
|
---|
| 259 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import java.io.BufferedInputStream;
|
---|
| 7 | +import java.io.BufferedOutputStream;
|
---|
| 8 | +import java.io.File;
|
---|
| 9 | +import java.io.FileInputStream;
|
---|
| 10 | +import java.io.FileOutputStream;
|
---|
| 11 | +import java.io.IOException;
|
---|
| 12 | +import java.io.InputStream;
|
---|
| 13 | +import java.io.OutputStream;
|
---|
| 14 | +import java.security.Permission;
|
---|
| 15 | +import java.util.ArrayList;
|
---|
| 16 | +import java.util.Arrays;
|
---|
| 17 | +
|
---|
| 18 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 19 | +import com.DeviceTest.helper.SystemUtil;
|
---|
| 20 | +import com.rockchip.dmi.DmiInfo;
|
---|
| 21 | +import com.rockchip.dmi.DmiUtil;
|
---|
| 22 | +
|
---|
| 23 | +import android.app.Activity;
|
---|
| 24 | +import android.bluetooth.BluetoothAdapter;
|
---|
| 25 | +import android.bluetooth.BluetoothDevice;
|
---|
| 26 | +import android.content.BroadcastReceiver;
|
---|
| 27 | +import android.content.Context;
|
---|
| 28 | +import android.content.Intent;
|
---|
| 29 | +import android.content.IntentFilter;
|
---|
| 30 | +import android.content.pm.PermissionInfo;
|
---|
| 31 | +import android.os.Bundle;
|
---|
| 32 | +import android.os.Environment;
|
---|
| 33 | +import android.os.Handler;
|
---|
| 34 | +import android.os.Handler.Callback;
|
---|
| 35 | +import android.os.Looper;
|
---|
| 36 | +import android.os.Message;
|
---|
| 37 | +import android.os.Process;
|
---|
| 38 | +import android.util.Log;
|
---|
| 39 | +import android.view.KeyEvent;
|
---|
| 40 | +import android.view.View;
|
---|
| 41 | +import android.view.View.OnClickListener;
|
---|
| 42 | +import android.view.Window;
|
---|
| 43 | +import android.widget.Button;
|
---|
| 44 | +import android.widget.ProgressBar;
|
---|
| 45 | +import android.widget.TextView;
|
---|
| 46 | +
|
---|
| 47 | +public class IrdaTestActivity extends Activity implements OnClickListener {
|
---|
| 48 | + private Button sirSend = null;
|
---|
| 49 | + private Button sirReceive = null;
|
---|
| 50 | + private Button firSend = null;
|
---|
| 51 | + private Button firReceive = null;
|
---|
| 52 | + private ProgressBar progressBar = null;
|
---|
| 53 | +
|
---|
| 54 | + Handler handler, myHandler;
|
---|
| 55 | + private static final int TEST_SIR_SEND = 0;
|
---|
| 56 | + private static final int TEST_SIR_RECEIVE = 1;
|
---|
| 57 | + private static final int TEST_FIR_SEND = 2;
|
---|
| 58 | + private static final int TEST_FIR_RECEIVE = 3;
|
---|
| 59 | + boolean sirSendPass = false;
|
---|
| 60 | + boolean sirReceivePass = false;
|
---|
| 61 | + boolean firSendPass = false;
|
---|
| 62 | + boolean firReceivePass = false;
|
---|
| 63 | +
|
---|
| 64 | + private final static String TEST_IRDA_PATH = DeviceTest.DATA_PATH
|
---|
| 65 | + + "irda_test";
|
---|
| 66 | + File testIrdaFile = new File(TEST_IRDA_PATH);
|
---|
| 67 | +
|
---|
| 68 | + protected void onCreate(Bundle savedInstanceState) {
|
---|
| 69 | +
|
---|
| 70 | + super.onCreate(savedInstanceState);
|
---|
| 71 | +
|
---|
| 72 | + setTitle(getTitle() + "----("
|
---|
| 73 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")");
|
---|
| 74 | + // requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 75 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 76 | +
|
---|
| 77 | + setContentView(R.layout.irdatest);
|
---|
| 78 | +
|
---|
| 79 | + sirSend = (Button) findViewById(R.id.sir_send);
|
---|
| 80 | + sirReceive = (Button) findViewById(R.id.sir_receive);
|
---|
| 81 | + firSend = (Button) findViewById(R.id.fir_send);
|
---|
| 82 | + firReceive = (Button) findViewById(R.id.fir_receive);
|
---|
| 83 | +
|
---|
| 84 | + sirSend.setTag(sirSend.getText());
|
---|
| 85 | + sirReceive.setTag(sirReceive.getText());
|
---|
| 86 | + firSend.setTag(firSend.getText());
|
---|
| 87 | + firReceive.setTag(firReceive.getText());
|
---|
| 88 | +
|
---|
| 89 | + sirSend.setOnClickListener(this);
|
---|
| 90 | + sirReceive.setOnClickListener(this);
|
---|
| 91 | + firSend.setOnClickListener(this);
|
---|
| 92 | + firReceive.setOnClickListener(this);
|
---|
| 93 | +
|
---|
| 94 | + progressBar = (ProgressBar) findViewById(R.id.irda_progress);
|
---|
| 95 | +
|
---|
| 96 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 97 | + findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 98 | +
|
---|
| 99 | +
|
---|
| 100 | + InputStream is = null;
|
---|
| 101 | + OutputStream os = null;
|
---|
| 102 | + try {
|
---|
| 103 | + is = getAssets().open("irda_test");
|
---|
| 104 | + os = new FileOutputStream(testIrdaFile);
|
---|
| 105 | + int data = 0;
|
---|
| 106 | + while (true) {
|
---|
| 107 | + data = is.read();
|
---|
| 108 | + if (data < 0) {
|
---|
| 109 | + break;
|
---|
| 110 | + }
|
---|
| 111 | + os.write(data);
|
---|
| 112 | + }
|
---|
| 113 | + } catch (Exception e) {
|
---|
| 114 | + e.printStackTrace();
|
---|
| 115 | + } finally {
|
---|
| 116 | + try {
|
---|
| 117 | + if (is != null) {
|
---|
| 118 | + is.close();
|
---|
| 119 | + }
|
---|
| 120 | + if (os != null) {
|
---|
| 121 | + os.close();
|
---|
| 122 | + }
|
---|
| 123 | + if (testIrdaFile.exists()) {
|
---|
| 124 | + SystemUtil.execRootCmd("chmod 777 " + testIrdaFile);
|
---|
| 125 | + }
|
---|
| 126 | + } catch (Exception e) {
|
---|
| 127 | + }
|
---|
| 128 | + }
|
---|
| 129 | +
|
---|
| 130 | +
|
---|
| 131 | +
|
---|
| 132 | + myHandler = new Handler();
|
---|
| 133 | +
|
---|
| 134 | + new Thread(new Runnable() {
|
---|
| 135 | +
|
---|
| 136 | + public void run() {
|
---|
| 137 | + Looper.prepare();
|
---|
| 138 | + handler = new Handler() {
|
---|
| 139 | +
|
---|
| 140 | + public void handleMessage(Message msg) {
|
---|
| 141 | + myHandler.post(new Runnable() {
|
---|
| 142 | +
|
---|
| 143 | + public void run() {
|
---|
| 144 | + sirSend.setEnabled(false);
|
---|
| 145 | + sirReceive.setEnabled(false);
|
---|
| 146 | + firSend.setEnabled(false);
|
---|
| 147 | + firReceive.setEnabled(false);
|
---|
| 148 | + }
|
---|
| 149 | + });
|
---|
| 150 | +
|
---|
| 151 | + final boolean result;
|
---|
| 152 | + final TextView resultView;
|
---|
| 153 | + switch (msg.arg1) {
|
---|
| 154 | + case TEST_SIR_SEND:
|
---|
| 155 | + result = SystemUtil.execShellCmdForStatue(TEST_IRDA_PATH + " --sir-send") == 0;
|
---|
| 156 | + resultView = sirSend;
|
---|
| 157 | + if (result) {
|
---|
| 158 | + sirSendPass = true;
|
---|
| 159 | + }
|
---|
| 160 | + break;
|
---|
| 161 | + case TEST_SIR_RECEIVE:
|
---|
| 162 | + result = SystemUtil.execShellCmdForStatue(TEST_IRDA_PATH + " --sir-receive") == 0;
|
---|
| 163 | + resultView = sirReceive;
|
---|
| 164 | + if (result) {
|
---|
| 165 | + sirReceivePass = true;
|
---|
| 166 | + }
|
---|
| 167 | + break;
|
---|
| 168 | + case TEST_FIR_SEND:
|
---|
| 169 | + result = SystemUtil.execShellCmdForStatue(TEST_IRDA_PATH + " --fir-send") == 0;
|
---|
| 170 | + resultView = firSend;
|
---|
| 171 | + if (result) {
|
---|
| 172 | + firSendPass = true;
|
---|
| 173 | + }
|
---|
| 174 | + break;
|
---|
| 175 | + case TEST_FIR_RECEIVE:
|
---|
| 176 | + result = SystemUtil.execShellCmdForStatue(TEST_IRDA_PATH + " --fir-receive") == 0;
|
---|
| 177 | + resultView = firReceive;
|
---|
| 178 | + if (result) {
|
---|
| 179 | + firReceivePass = true;
|
---|
| 180 | + }
|
---|
| 181 | + break;
|
---|
| 182 | +
|
---|
| 183 | + default:
|
---|
| 184 | + result = false;
|
---|
| 185 | + resultView = null;
|
---|
| 186 | + break;
|
---|
| 187 | + }
|
---|
| 188 | +
|
---|
| 189 | + myHandler.post(new Runnable() {
|
---|
| 190 | +
|
---|
| 191 | + public void run() {
|
---|
| 192 | +
|
---|
| 193 | + sirSend.setEnabled(true);
|
---|
| 194 | + sirReceive.setEnabled(true);
|
---|
| 195 | + firSend.setEnabled(true);
|
---|
| 196 | + firReceive.setEnabled(true);
|
---|
| 197 | +
|
---|
| 198 | + progressBar.setVisibility(View.INVISIBLE);
|
---|
| 199 | + resultView.setText(resultView.getTag()
|
---|
| 200 | + .toString()
|
---|
| 201 | + + ":"
|
---|
| 202 | + + (result ? "Success" : "Failed"));
|
---|
| 203 | + if (sirSendPass && sirReceivePass
|
---|
| 204 | + && firSendPass && firReceivePass) {
|
---|
| 205 | + findViewById(R.id.btn_Pass).performClick();
|
---|
| 206 | + }
|
---|
| 207 | + }
|
---|
| 208 | + });
|
---|
| 209 | + }
|
---|
| 210 | + };
|
---|
| 211 | +
|
---|
| 212 | + Looper.loop();
|
---|
| 213 | + }
|
---|
| 214 | + }).start();
|
---|
| 215 | +
|
---|
| 216 | +
|
---|
| 217 | +
|
---|
| 218 | + }
|
---|
| 219 | +
|
---|
| 220 | + protected void onStop() {
|
---|
| 221 | + super.onStop();
|
---|
| 222 | +
|
---|
| 223 | + SystemUtil.killProcessByPath(TEST_IRDA_PATH);
|
---|
| 224 | +
|
---|
| 225 | + if (testIrdaFile.exists()) {
|
---|
| 226 | + testIrdaFile.delete();
|
---|
| 227 | + }
|
---|
| 228 | + }
|
---|
| 229 | +
|
---|
| 230 | + protected void onResume() {
|
---|
| 231 | + super.onResume();
|
---|
| 232 | + }
|
---|
| 233 | +
|
---|
| 234 | + public void onPause() {
|
---|
| 235 | + super.onPause();
|
---|
| 236 | + }
|
---|
| 237 | +
|
---|
| 238 | + public void onClick(View v) {
|
---|
| 239 | + progressBar.setVisibility(View.VISIBLE);
|
---|
| 240 | +
|
---|
| 241 | + Message message = handler.obtainMessage();
|
---|
| 242 | + if (v == sirSend || v == sirReceive) {
|
---|
| 243 | + if (v == sirSend) {
|
---|
| 244 | + message.arg1 = TEST_SIR_SEND;
|
---|
| 245 | + } else {
|
---|
| 246 | + message.arg1 = TEST_SIR_RECEIVE;
|
---|
| 247 | + }
|
---|
| 248 | + } else {
|
---|
| 249 | + if (v == firSend) {
|
---|
| 250 | + message.arg1 = TEST_FIR_SEND;
|
---|
| 251 | + } else {
|
---|
| 252 | + message.arg1 = TEST_FIR_RECEIVE;
|
---|
| 253 | + }
|
---|
| 254 | + }
|
---|
| 255 | + ((TextView) v).setText(v.getTag().toString() + ":Testing");
|
---|
| 256 | +
|
---|
| 257 | + handler.sendMessage(message);
|
---|
| 258 | + }
|
---|
| 259 | +
|
---|
| 260 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 261 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 262 | + return false;
|
---|
| 263 | + }
|
---|
| 264 | + return super.dispatchKeyEvent(event);
|
---|
| 265 | + }
|
---|
| 266 | +
|
---|
| 267 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +import android.app.Activity;
|
---|
| 6 | +import android.app.KeyguardManager;
|
---|
| 7 | +import android.app.KeyguardManager.KeyguardLock;
|
---|
| 8 | +import android.content.Context;
|
---|
| 9 | +import android.graphics.Color;
|
---|
| 10 | +import android.graphics.PixelFormat;
|
---|
| 11 | +import android.os.Build;
|
---|
| 12 | +import android.os.Bundle;
|
---|
| 13 | +import android.os.RemoteException;
|
---|
| 14 | +//import android.view.IWindowManager;
|
---|
| 15 | +//import android.view.IWindowManager.Stub;
|
---|
| 16 | +import android.view.Gravity;
|
---|
| 17 | +import android.view.KeyEvent;
|
---|
| 18 | +import android.view.View;
|
---|
| 19 | +import android.view.Window;
|
---|
| 20 | +import android.view.WindowManager;
|
---|
| 21 | +import android.view.View.OnKeyListener;
|
---|
| 22 | +import android.widget.TextView;
|
---|
| 23 | +import java.util.HashMap;
|
---|
| 24 | +
|
---|
| 25 | +import com.DeviceTest.helper.ConfigUtil;
|
---|
| 26 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 27 | +
|
---|
| 28 | +import android.util.Log;
|
---|
| 29 | +
|
---|
| 30 | +public class KeyboardTestActivity extends Activity {
|
---|
| 31 | + static final int Key_Status_Down = 1;
|
---|
| 32 | + static final int Key_Status_Null = 0;
|
---|
| 33 | + static final int Key_Status_Up = 2;
|
---|
| 34 | +
|
---|
| 35 | + static final String TAG = "KeyboardTestActivity";
|
---|
| 36 | +
|
---|
| 37 | + private int[] mButtonIds;
|
---|
| 38 | + private HashMap<Integer, Integer> mButtonMaps = new HashMap();
|
---|
| 39 | + private HashMap<Integer, Integer> mButtonStatus = new HashMap();
|
---|
| 40 | + private int[] mKeyCodes;
|
---|
| 41 | + private View v = null;
|
---|
| 42 | + private WindowManager wm = null;
|
---|
| 43 | + KeyguardLock kl = null;
|
---|
| 44 | + public void onCreate(Bundle paramBundle) {
|
---|
| 45 | + super.onCreate(paramBundle);
|
---|
| 46 | + setContentView(R.layout.keyboadtest);
|
---|
| 47 | +
|
---|
| 48 | + setTitle(getTitle() + "----("
|
---|
| 49 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS)
|
---|
| 50 | + + ")");
|
---|
| 51 | + // requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 52 | + getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
|
---|
| 53 | + //(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 54 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 55 | + initButtonsMaps();
|
---|
| 56 | +
|
---|
| 57 | + v = new View(KeyboardTestActivity.this);
|
---|
| 58 | + wm = (WindowManager)KeyboardTestActivity.this.getSystemService(WINDOW_SERVICE);
|
---|
| 59 | + KeyguardManager km= (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
|
---|
| 60 | + if (Build.VERSION.SDK_INT < ConfigUtil.ANDROID_SDK_VERSION_P) {
|
---|
| 61 | + kl = km.newKeyguardLock("unLock");
|
---|
| 62 | + }
|
---|
| 63 | +// findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 64 | + }
|
---|
| 65 | +
|
---|
| 66 | + public boolean onKeyDown(int keyCode, KeyEvent event) {
|
---|
| 67 | + Log.d(TAG, "=============onKeyDown==========");
|
---|
| 68 | + return super.onKeyDown(keyCode, event);
|
---|
| 69 | + }
|
---|
| 70 | +
|
---|
| 71 | + protected void onResume() {
|
---|
| 72 | + super.onResume();
|
---|
| 73 | +
|
---|
| 74 | + if (Build.VERSION.SDK_INT < ConfigUtil.ANDROID_SDK_VERSION_P) {
|
---|
| 75 | + kl.disableKeyguard();
|
---|
| 76 | + }
|
---|
| 77 | + //addWindow();
|
---|
| 78 | + }
|
---|
| 79 | + @Override
|
---|
| 80 | + protected void onPause() {
|
---|
| 81 | + super.onPause();
|
---|
| 82 | + //removeWindow();
|
---|
| 83 | + if (Build.VERSION.SDK_INT < ConfigUtil.ANDROID_SDK_VERSION_P) {
|
---|
| 84 | + kl.reenableKeyguard();
|
---|
| 85 | + }
|
---|
| 86 | + }
|
---|
| 87 | + private void initButtonsMaps() {
|
---|
| 88 | + Log.d(TAG, "===========initButtonsMaps======");
|
---|
| 89 | + int[] resId = { R.id.bt_sounddown, R.id.bt_soundup, R.id.bt_home,
|
---|
| 90 | + R.id.bt_menu, R.id.bt_back };
|
---|
| 91 | + mButtonIds = resId;
|
---|
| 92 | + int[] keycode = { 25, 24, 3, 82, 4 };
|
---|
| 93 | + mKeyCodes = keycode;
|
---|
| 94 | +
|
---|
| 95 | + int i = 0;
|
---|
| 96 | + int j = mButtonIds.length;
|
---|
| 97 | +
|
---|
| 98 | + Log.d(TAG, "I=" + i + " j = " + j);
|
---|
| 99 | +
|
---|
| 100 | + for (i = 0; i < j; i++) {
|
---|
| 101 | + Integer key = Integer.valueOf(mKeyCodes[i]);
|
---|
| 102 | + Integer value = Integer.valueOf(mButtonIds[i]);
|
---|
| 103 | + mButtonMaps.put(key, value);
|
---|
| 104 | + }
|
---|
| 105 | + resetButtonBackground();
|
---|
| 106 | + }
|
---|
| 107 | +
|
---|
| 108 | + private boolean isTestKey(int keycode) {
|
---|
| 109 | + int j = mKeyCodes.length;
|
---|
| 110 | + int i = 0;
|
---|
| 111 | + while (i < j) {
|
---|
| 112 | + if (keycode == mKeyCodes[i]) {
|
---|
| 113 | + return true;
|
---|
| 114 | + } else {
|
---|
| 115 | + i++;
|
---|
| 116 | + }
|
---|
| 117 | + }
|
---|
| 118 | + return false;
|
---|
| 119 | + }
|
---|
| 120 | +
|
---|
| 121 | + private void resetButtonBackground() {
|
---|
| 122 | + Log.d(TAG, "resetButtonBackground()... ...");
|
---|
| 123 | + int i = mButtonIds.length;
|
---|
| 124 | + int j = 0;
|
---|
| 125 | + while (true) {
|
---|
| 126 | + if (j >= i)
|
---|
| 127 | + return;
|
---|
| 128 | + int k = mButtonIds[j];
|
---|
| 129 | + findViewById(k).setBackgroundColor(Color.rgb(255, 255, 255));
|
---|
| 130 | + ((TextView)findViewById(k)).setTextColor(Color.BLACK);
|
---|
| 131 | + j += 1;
|
---|
| 132 | + }
|
---|
| 133 | + }
|
---|
| 134 | +
|
---|
| 135 | + private void setButtonBackgroundDown(int resId) {
|
---|
| 136 | + Log.d(TAG, "=====613========setButtonBackgroundDown");
|
---|
| 137 | + findViewById(resId).setBackgroundColor(Color.BLUE);
|
---|
| 138 | + }
|
---|
| 139 | +
|
---|
| 140 | + private void setButtonBackgroundUp(int resId) {
|
---|
| 141 | + Log.d(TAG, "======setButtonBackgroundUp");
|
---|
| 142 | + findViewById(resId).setBackgroundColor(Color.GREEN);
|
---|
| 143 | + }
|
---|
| 144 | +
|
---|
| 145 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 146 | + int keyCode = event.getKeyCode();
|
---|
| 147 | + int actionCode = event.getAction();
|
---|
| 148 | + Log.d(TAG, "KeyCode = " + keyCode);
|
---|
| 149 | + Log.d(TAG, "actionCode = " + actionCode);
|
---|
| 150 | + if (!isTestKey(keyCode))
|
---|
| 151 | + return super.dispatchKeyEvent(event);
|
---|
| 152 | + int value = 0;
|
---|
| 153 | + Integer key = Integer.valueOf(keyCode);
|
---|
| 154 | + value = mButtonMaps.get(key).intValue();
|
---|
| 155 | + Log.d(TAG, "================== value = " + value);
|
---|
| 156 | + switch (actionCode) {
|
---|
| 157 | +
|
---|
| 158 | + case 0:
|
---|
| 159 | + setButtonBackgroundDown(value);
|
---|
| 160 | + mButtonStatus.put(key, Integer.valueOf(1));
|
---|
| 161 | + break;
|
---|
| 162 | +
|
---|
| 163 | + case 1:
|
---|
| 164 | + setButtonBackgroundUp(value);
|
---|
| 165 | + mButtonStatus.put(key, Integer.valueOf(1));
|
---|
| 166 | + if(event.getKeyCode()== KeyEvent.KEYCODE_HOME){
|
---|
| 167 | + Log.d(TAG,getWindow().getAttributes().type+ " _____________---- onKeyEEEE(), " + event.getKeyCode());
|
---|
| 168 | + return true;
|
---|
| 169 | + }else if(event.getKeyCode()== KeyEvent.KEYCODE_BACK){
|
---|
| 170 | + Log.d(TAG,getWindow().getAttributes().type+ " _____________---- onKeyEEEE(), " + event.getKeyCode());
|
---|
| 171 | + return true;
|
---|
| 172 | + }
|
---|
| 173 | + break;
|
---|
| 174 | +
|
---|
| 175 | + default:
|
---|
| 176 | + break;
|
---|
| 177 | + }
|
---|
| 178 | +
|
---|
| 179 | +// if (mButtonStatus.size() == mButtonIds.length) {
|
---|
| 180 | +// findViewById(R.id.btn_Pass).performClick();
|
---|
| 181 | +// }
|
---|
| 182 | + return true;
|
---|
| 183 | + }
|
---|
| 184 | +
|
---|
| 185 | + private void addWindow(){
|
---|
| 186 | + WindowManager.LayoutParams params = new WindowManager.LayoutParams();
|
---|
| 187 | + params.type = WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
|
---|
| 188 | +// params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
|
---|
| 189 | +// params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
---|
| 190 | +// | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
|
---|
| 191 | +// params.flags = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
|
---|
| 192 | +// | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
---|
| 193 | + params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
|
---|
| 194 | + params.width = 1;//WindowManager.LayoutParams.FILL_PARENT;
|
---|
| 195 | + params.height = 1;//WindowManager.LayoutParams.FILL_PARENT;
|
---|
| 196 | + params.format=PixelFormat.TRANSLUCENT;
|
---|
| 197 | + params.gravity=Gravity.LEFT|Gravity.TOP;
|
---|
| 198 | + //����Ļ���Ͻ�Ϊԭ�㣬����x��y��ʼֵ
|
---|
| 199 | + params.x = 0;
|
---|
| 200 | + params.y = 0;
|
---|
| 201 | + wm.addView(v, params);
|
---|
| 202 | + v.requestFocus();
|
---|
| 203 | + v.setOnKeyListener(new OnKeyListener(){
|
---|
| 204 | + public boolean onKey(View v, int keyCodee, KeyEvent event) {
|
---|
| 205 | + Log.d(TAG, " _____________---- onKey(), " + event.getKeyCode());
|
---|
| 206 | + int keyCode = event.getKeyCode();
|
---|
| 207 | + int actionCode = event.getAction();
|
---|
| 208 | + Log.d(TAG, "KeyCode = " + keyCode);
|
---|
| 209 | + Log.d(TAG, "actionCode = " + actionCode);
|
---|
| 210 | + if (!isTestKey(keyCode))
|
---|
| 211 | + return false;
|
---|
| 212 | + int value = 0;
|
---|
| 213 | + Integer key = Integer.valueOf(keyCode);
|
---|
| 214 | + value = mButtonMaps.get(key).intValue();
|
---|
| 215 | + Log.d(TAG, "================== value = " + value);
|
---|
| 216 | + switch (actionCode) {
|
---|
| 217 | + case 0:
|
---|
| 218 | + setButtonBackgroundDown(value);
|
---|
| 219 | + mButtonStatus.put(key, Integer.valueOf(1));
|
---|
| 220 | + break;
|
---|
| 221 | +
|
---|
| 222 | + case 1:
|
---|
| 223 | + setButtonBackgroundUp(value);
|
---|
| 224 | + mButtonStatus.put(key, Integer.valueOf(1));
|
---|
| 225 | + break;
|
---|
| 226 | + default:
|
---|
| 227 | + break;
|
---|
| 228 | + }
|
---|
| 229 | + return true;
|
---|
| 230 | +
|
---|
| 231 | + }
|
---|
| 232 | + });
|
---|
| 233 | + }
|
---|
| 234 | + private void removeWindow(){
|
---|
| 235 | + wm.removeView(v);
|
---|
| 236 | + }
|
---|
| 237 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 7 | +import com.DeviceTest.view.LcdTestView;
|
---|
| 8 | +
|
---|
| 9 | +import android.R.color;
|
---|
| 10 | +import android.app.Activity;
|
---|
| 11 | +import android.graphics.BitmapFactory;
|
---|
| 12 | +import android.graphics.Canvas;
|
---|
| 13 | +import android.graphics.Color;
|
---|
| 14 | +import android.graphics.Paint;
|
---|
| 15 | +import android.graphics.drawable.BitmapDrawable;
|
---|
| 16 | +import android.os.Bundle;
|
---|
| 17 | +import android.os.Handler;
|
---|
| 18 | +import android.os.Message;
|
---|
| 19 | +import android.view.KeyEvent;
|
---|
| 20 | +import android.view.MotionEvent;
|
---|
| 21 | +import android.view.View;
|
---|
| 22 | +import android.view.ViewGroup;
|
---|
| 23 | +import android.view.Window;
|
---|
| 24 | +import android.view.WindowManager;
|
---|
| 25 | +import android.widget.TextView;
|
---|
| 26 | +import android.util.Log;
|
---|
| 27 | +
|
---|
| 28 | +public class LcdTestActivity extends Activity {
|
---|
| 29 | + public static final int MSG_LCD_TESTING = 2;
|
---|
| 30 | + public static final int MSG_LCD_TEST_START = 1;
|
---|
| 31 | + public static final int MSG_LCD_TES_END = 3;
|
---|
| 32 | +
|
---|
| 33 | + LcdTestView mLcdView;
|
---|
| 34 | + boolean mTestOn;
|
---|
| 35 | + TextView mText;
|
---|
| 36 | + TextView mTitle;
|
---|
| 37 | + int mTestCount = 0;
|
---|
| 38 | + private static final int TEST_COLOR_COUNT = 5;
|
---|
| 39 | + private static final int TEST_COLORS[] = new int[TEST_COLOR_COUNT];
|
---|
| 40 | +
|
---|
| 41 | + private Canvas mCanvas = new Canvas();
|
---|
| 42 | + private Paint mPaint = new Paint();
|
---|
| 43 | +
|
---|
| 44 | +
|
---|
| 45 | + public void onCreate(Bundle paramBundle) {
|
---|
| 46 | + super.onCreate(paramBundle);
|
---|
| 47 | + TEST_COLORS[0] = Color.WHITE;
|
---|
| 48 | + TEST_COLORS[1] = Color.BLACK;
|
---|
| 49 | + TEST_COLORS[2] = Color.RED;
|
---|
| 50 | + TEST_COLORS[3] = Color.GREEN;
|
---|
| 51 | + TEST_COLORS[4] = Color.BLUE;
|
---|
| 52 | +
|
---|
| 53 | + setTitle(getTitle() + "----("
|
---|
| 54 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")");
|
---|
| 55 | + requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 56 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 57 | + //getWindow().getDecorView().setSystemUiVisibility(4);
|
---|
| 58 | + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
|
---|
| 59 | +
|
---|
| 60 | + setContentView(R.layout.lcdtest);
|
---|
| 61 | + mTitle = (TextView) findViewById(R.id.lcdtextTitle);
|
---|
| 62 | + mText = (TextView) findViewById(R.id.lcdtestresult);
|
---|
| 63 | + mLcdView = (LcdTestView)findViewById(R.id.lcdtestview);
|
---|
| 64 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 65 | + ControlButtonUtil.Hide();
|
---|
| 66 | + }
|
---|
| 67 | +
|
---|
| 68 | +
|
---|
| 69 | + protected void onPause() {
|
---|
| 70 | + super.onPause();
|
---|
| 71 | + }
|
---|
| 72 | +
|
---|
| 73 | +
|
---|
| 74 | + protected void onResume() {
|
---|
| 75 | + super.onResume();
|
---|
| 76 | + }
|
---|
| 77 | +
|
---|
| 78 | +
|
---|
| 79 | + public boolean onTouchEvent(MotionEvent paramMotionEvent) {
|
---|
| 80 | + if (paramMotionEvent.getAction() == MotionEvent.ACTION_DOWN) {
|
---|
| 81 | + mTestCount++;
|
---|
| 82 | +
|
---|
| 83 | + if(mTestCount >= 1 && mTestCount <= TEST_COLOR_COUNT) {
|
---|
| 84 | + mLcdView.setBackgroundColor(TEST_COLORS[mTestCount - 1]);
|
---|
| 85 | + }
|
---|
| 86 | +
|
---|
| 87 | + switch (mTestCount) {
|
---|
| 88 | + case 1:
|
---|
| 89 | + mTitle.setVisibility(View.GONE);
|
---|
| 90 | + mText.setVisibility(View.GONE);
|
---|
| 91 | + ControlButtonUtil.Hide();
|
---|
| 92 | + mLcdView.setVisibility(View.VISIBLE);
|
---|
| 93 | + break;
|
---|
| 94 | + case TEST_COLOR_COUNT +1:
|
---|
| 95 | + mLcdView.grayScale(true);
|
---|
| 96 | + mLcdView.paneBorder(false);
|
---|
| 97 | + mLcdView.postInvalidate();
|
---|
| 98 | + break;
|
---|
| 99 | + case TEST_COLOR_COUNT +2:
|
---|
| 100 | + mLcdView.paneBorder(true);
|
---|
| 101 | + mLcdView.grayScale(false);
|
---|
| 102 | + mLcdView.postInvalidate();
|
---|
| 103 | + break;
|
---|
| 104 | + case TEST_COLOR_COUNT + 3:
|
---|
| 105 | + mLcdView.paneBorder(false);
|
---|
| 106 | + mLcdView.grayScale(false);
|
---|
| 107 | + mTestCount = 0;
|
---|
| 108 | + mLcdView.setVisibility(View.GONE);
|
---|
| 109 | + mTitle.setVisibility(View.VISIBLE);
|
---|
| 110 | + ControlButtonUtil.Show();
|
---|
| 111 | + break;
|
---|
| 112 | + default:
|
---|
| 113 | + break;
|
---|
| 114 | + }
|
---|
| 115 | + }
|
---|
| 116 | + return super.onTouchEvent(paramMotionEvent);
|
---|
| 117 | + }
|
---|
| 118 | +
|
---|
| 119 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 120 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 121 | + return false;
|
---|
| 122 | + }else if(event.getAction() == KeyEvent.ACTION_DOWN&&( event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP ||event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN)){
|
---|
| 123 | + mTestCount++;
|
---|
| 124 | +
|
---|
| 125 | + if(mTestCount >= 1 && mTestCount <= TEST_COLOR_COUNT) {
|
---|
| 126 | + mLcdView.setBackgroundColor(TEST_COLORS[mTestCount - 1]);
|
---|
| 127 | + }
|
---|
| 128 | + switch (mTestCount) {
|
---|
| 129 | + case 1:
|
---|
| 130 | + mTitle.setVisibility(View.GONE);
|
---|
| 131 | + mText.setVisibility(View.GONE);
|
---|
| 132 | + ControlButtonUtil.Hide();
|
---|
| 133 | + mLcdView.setVisibility(View.VISIBLE);
|
---|
| 134 | + break;
|
---|
| 135 | + case TEST_COLOR_COUNT +1:
|
---|
| 136 | + mLcdView.grayScale(true);
|
---|
| 137 | + mLcdView.paneBorder(false);
|
---|
| 138 | + mLcdView.postInvalidate();
|
---|
| 139 | + break;
|
---|
| 140 | + case TEST_COLOR_COUNT +2:
|
---|
| 141 | + mLcdView.paneBorder(true);
|
---|
| 142 | + mLcdView.grayScale(false);
|
---|
| 143 | + mLcdView.postInvalidate();
|
---|
| 144 | + break;
|
---|
| 145 | + case TEST_COLOR_COUNT + 3:
|
---|
| 146 | + mLcdView.paneBorder(false);
|
---|
| 147 | + mLcdView.grayScale(false);
|
---|
| 148 | + mTestCount = 0;
|
---|
| 149 | + mLcdView.setVisibility(View.GONE);
|
---|
| 150 | + mTitle.setVisibility(View.VISIBLE);
|
---|
| 151 | + ControlButtonUtil.Show();
|
---|
| 152 | + break;
|
---|
| 153 | + default:
|
---|
| 154 | + break;
|
---|
| 155 | + }
|
---|
| 156 | + }
|
---|
| 157 | + return super.dispatchKeyEvent(event);
|
---|
| 158 | + }
|
---|
| 159 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import java.io.BufferedInputStream;
|
---|
| 7 | +import java.io.BufferedOutputStream;
|
---|
| 8 | +import java.io.BufferedWriter;
|
---|
| 9 | +import java.io.File;
|
---|
| 10 | +import java.io.FileInputStream;
|
---|
| 11 | +import java.io.FileNotFoundException;
|
---|
| 12 | +import java.io.FileOutputStream;
|
---|
| 13 | +import java.io.IOException;
|
---|
| 14 | +import java.io.InputStream;
|
---|
| 15 | +import java.io.OutputStreamWriter;
|
---|
| 16 | +import java.lang.reflect.Field;
|
---|
| 17 | +import java.lang.reflect.InvocationTargetException;
|
---|
| 18 | +import java.lang.reflect.Method;
|
---|
| 19 | +import java.security.Permission;
|
---|
| 20 | +import java.util.ArrayList;
|
---|
| 21 | +import java.util.Arrays;
|
---|
| 22 | +
|
---|
| 23 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 24 | +import com.DeviceTest.helper.SystemUtil;
|
---|
| 25 | +import com.rockchip.newton.UserModeManager;
|
---|
| 26 | +
|
---|
| 27 | +import android.app.Activity;
|
---|
| 28 | +import android.app.Notification;
|
---|
| 29 | +import android.app.NotificationManager;
|
---|
| 30 | +import android.bluetooth.BluetoothAdapter;
|
---|
| 31 | +import android.bluetooth.BluetoothDevice;
|
---|
| 32 | +import android.content.BroadcastReceiver;
|
---|
| 33 | +import android.content.Context;
|
---|
| 34 | +import android.content.Intent;
|
---|
| 35 | +import android.content.IntentFilter;
|
---|
| 36 | +import android.content.pm.PermissionInfo;
|
---|
| 37 | +import android.graphics.Color;
|
---|
| 38 | +import android.os.Bundle;
|
---|
| 39 | +import android.os.Environment;
|
---|
| 40 | +import android.os.Handler;
|
---|
| 41 | +import android.os.Message;
|
---|
| 42 | +import android.os.PowerManager;
|
---|
| 43 | +import android.os.SystemClock;
|
---|
| 44 | +import android.util.Log;
|
---|
| 45 | +import android.view.KeyEvent;
|
---|
| 46 | +import android.view.View;
|
---|
| 47 | +import android.view.View.OnClickListener;
|
---|
| 48 | +import android.view.Window;
|
---|
| 49 | +import android.view.WindowManager;
|
---|
| 50 | +import android.widget.Button;
|
---|
| 51 | +import android.widget.ProgressBar;
|
---|
| 52 | +import android.widget.TextView;
|
---|
| 53 | +
|
---|
| 54 | +public class LedTestActivity extends Activity implements OnClickListener {
|
---|
| 55 | + NotificationManager notificationManager;
|
---|
| 56 | + private static final int NOTIFY_ID = 1000;
|
---|
| 57 | +//
|
---|
| 58 | +// private static final String POWER_LED_PATH = "/sys/class/leds/power_led/";
|
---|
| 59 | +// private static final String POWER_LED_BRIGHT = POWER_LED_PATH
|
---|
| 60 | +// + "brightness";
|
---|
| 61 | +// // private static final String POWER_LED_FREQ = POWER_LED_PATH + "freq";
|
---|
| 62 | +// private static final String POWER_LED_PERIOD = POWER_LED_PATH + "period";
|
---|
| 63 | +
|
---|
| 64 | +
|
---|
| 65 | +
|
---|
| 66 | + protected void onCreate(Bundle savedInstanceState) {
|
---|
| 67 | +
|
---|
| 68 | + super.onCreate(savedInstanceState);
|
---|
| 69 | + setTitle(getTitle() + "----("
|
---|
| 70 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")");
|
---|
| 71 | + // requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 72 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 73 | + getWindow().getDecorView().setSystemUiVisibility(
|
---|
| 74 | + View.SYSTEM_UI_FLAG_FULLSCREEN);
|
---|
| 75 | + setContentView(R.layout.ledtest);
|
---|
| 76 | +
|
---|
| 77 | + notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
---|
| 78 | +
|
---|
| 79 | + Button redButton = (Button) findViewById(R.id.red_btn);
|
---|
| 80 | + Button yellowButton = (Button) findViewById(R.id.green_btn);
|
---|
| 81 | + Button blueButton = (Button) findViewById(R.id.blue_btn);
|
---|
| 82 | +// final Button powerButton = (Button) findViewById(R.id.power_btn);
|
---|
| 83 | +//
|
---|
| 84 | +// powerButton.setText("PowerLed");
|
---|
| 85 | +// powerButton.setOnClickListener(new OnClickListener() {
|
---|
| 86 | +//
|
---|
| 87 | +//
|
---|
| 88 | +// public void onClick(View v) {
|
---|
| 89 | +// String cmd = "echo 255 > " + POWER_LED_BRIGHT + "\necho 255 > "
|
---|
| 90 | +// + POWER_LED_PERIOD;
|
---|
| 91 | +// SystemUtil.execScriptCmd(cmd,
|
---|
| 92 | +// DeviceTest.TEMP_FILE_PATH, true);
|
---|
| 93 | +// powerButton.setEnabled(false);
|
---|
| 94 | +// }
|
---|
| 95 | +// });
|
---|
| 96 | +
|
---|
| 97 | + redButton.setOnClickListener(this);
|
---|
| 98 | + yellowButton.setOnClickListener(this);
|
---|
| 99 | + blueButton.setOnClickListener(this);
|
---|
| 100 | +
|
---|
| 101 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 102 | +
|
---|
| 103 | + Notification notification;
|
---|
| 104 | +
|
---|
| 105 | + notification = new Notification();
|
---|
| 106 | + notification.flags |= Notification.FLAG_SHOW_LIGHTS;
|
---|
| 107 | + notification.ledARGB = Color.RED;
|
---|
| 108 | + notification.ledOffMS = 0;
|
---|
| 109 | + notification.ledOnMS = 1;
|
---|
| 110 | + redButton.setTag(notification);
|
---|
| 111 | +
|
---|
| 112 | + notification = new Notification();
|
---|
| 113 | + notification.flags |= Notification.FLAG_SHOW_LIGHTS;
|
---|
| 114 | + notification.ledARGB = Color.GREEN;
|
---|
| 115 | + notification.ledOffMS = 0;
|
---|
| 116 | + notification.ledOnMS = 1;
|
---|
| 117 | + yellowButton.setTag(notification);
|
---|
| 118 | +
|
---|
| 119 | + notification = new Notification();
|
---|
| 120 | + notification.flags |= Notification.FLAG_SHOW_LIGHTS;
|
---|
| 121 | + notification.ledARGB = Color.BLUE;
|
---|
| 122 | + notification.ledOffMS = 0;
|
---|
| 123 | + notification.ledOnMS = 1;
|
---|
| 124 | + blueButton.setTag(notification);
|
---|
| 125 | +
|
---|
| 126 | + }
|
---|
| 127 | +
|
---|
| 128 | +
|
---|
| 129 | + protected void onStop() {
|
---|
| 130 | + super.onStop();
|
---|
| 131 | + notificationManager.cancel(NOTIFY_ID);
|
---|
| 132 | +// SystemUtil.execScriptCmd("echo 0 > " + POWER_LED_PERIOD,
|
---|
| 133 | +// DeviceTest.TEMP_FILE_PATH, true);
|
---|
| 134 | + }
|
---|
| 135 | +
|
---|
| 136 | +
|
---|
| 137 | + protected void onResume() {
|
---|
| 138 | + super.onResume();
|
---|
| 139 | + }
|
---|
| 140 | +
|
---|
| 141 | +
|
---|
| 142 | + public void onPause() {
|
---|
| 143 | + super.onPause();
|
---|
| 144 | + }
|
---|
| 145 | +
|
---|
| 146 | +
|
---|
| 147 | + public void onClick(View v) {
|
---|
| 148 | + notificationManager.notify(NOTIFY_ID, (Notification) v.getTag());
|
---|
| 149 | + }
|
---|
| 150 | +
|
---|
| 151 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 152 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 153 | + return false;
|
---|
| 154 | + }
|
---|
| 155 | + return super.dispatchKeyEvent(event);
|
---|
| 156 | + }
|
---|
| 157 | +
|
---|
| 158 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 7 | +import com.DeviceTest.view.LevelView;
|
---|
| 8 | +
|
---|
| 9 | +import android.R.color;
|
---|
| 10 | +import android.app.Activity;
|
---|
| 11 | +import android.content.Context;
|
---|
| 12 | +import android.graphics.Color;
|
---|
| 13 | +import android.hardware.SensorListener;
|
---|
| 14 | +import android.hardware.SensorManager;
|
---|
| 15 | +import android.os.Bundle;
|
---|
| 16 | +import android.os.Handler;
|
---|
| 17 | +import android.os.Message;
|
---|
| 18 | +import android.view.KeyEvent;
|
---|
| 19 | +import android.view.MotionEvent;
|
---|
| 20 | +import android.view.View;
|
---|
| 21 | +import android.view.Window;
|
---|
| 22 | +import android.widget.TextView;
|
---|
| 23 | +import android.util.Log;
|
---|
| 24 | +
|
---|
| 25 | +public class LevelTestActivity extends Activity {
|
---|
| 26 | +
|
---|
| 27 | + private LevelView levelView;
|
---|
| 28 | +
|
---|
| 29 | +
|
---|
| 30 | + public void onCreate(Bundle paramBundle) {
|
---|
| 31 | + super.onCreate(paramBundle);
|
---|
| 32 | +
|
---|
| 33 | +
|
---|
| 34 | +
|
---|
| 35 | + setTitle(getTitle() + "----("
|
---|
| 36 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")");
|
---|
| 37 | + //requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 38 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 39 | +
|
---|
| 40 | + setContentView(R.layout.leveltest);
|
---|
| 41 | + levelView = (LevelView) findViewById(R.id.leveltestview);
|
---|
| 42 | +
|
---|
| 43 | + SensorManager sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
|
---|
| 44 | +
|
---|
| 45 | + sensorManager.registerListener(new SensorListener() {
|
---|
| 46 | +
|
---|
| 47 | +
|
---|
| 48 | + public void onSensorChanged(int sensor, float[] values) {
|
---|
| 49 | + levelView.update(values[0], values[1]);
|
---|
| 50 | + }
|
---|
| 51 | +
|
---|
| 52 | +
|
---|
| 53 | + public void onAccuracyChanged(int sensor, int accuracy) {
|
---|
| 54 | + }
|
---|
| 55 | + }, SensorManager.SENSOR_ACCELEROMETER);
|
---|
| 56 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 57 | + }
|
---|
| 58 | +
|
---|
| 59 | +
|
---|
| 60 | + protected void onPause() {
|
---|
| 61 | + super.onPause();
|
---|
| 62 | + }
|
---|
| 63 | +
|
---|
| 64 | +
|
---|
| 65 | + protected void onResume() {
|
---|
| 66 | + super.onResume();
|
---|
| 67 | + }
|
---|
| 68 | +
|
---|
| 69 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 70 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 71 | + return false;
|
---|
| 72 | + }
|
---|
| 73 | + return super.dispatchKeyEvent(event);
|
---|
| 74 | + }
|
---|
| 75 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | + |
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN; |
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; |
---|
| 5 | + |
---|
| 6 | +import java.util.List; |
---|
| 7 | + |
---|
| 8 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 9 | + |
---|
| 10 | +import android.app.Activity; |
---|
| 11 | +import android.hardware.Sensor; |
---|
| 12 | +import android.hardware.SensorEvent; |
---|
| 13 | +import android.hardware.SensorEventListener; |
---|
| 14 | +import android.hardware.SensorManager; |
---|
| 15 | +import android.os.Bundle; |
---|
| 16 | +import android.util.Log; |
---|
| 17 | +import android.view.KeyEvent; |
---|
| 18 | +import android.widget.TextView; |
---|
| 19 | + |
---|
| 20 | +/** |
---|
| 21 | + * @author LanBinYuan |
---|
| 22 | + * @date 2011-06-11 |
---|
| 23 | + * |
---|
| 24 | + */ |
---|
| 25 | + |
---|
| 26 | +public class LightsensorTestActivity extends Activity |
---|
| 27 | + implements SensorEventListener { |
---|
| 28 | + private static final String TAG = "LightsensorTestActivity"; |
---|
| 29 | + |
---|
| 30 | + private TextView txt_Light; |
---|
| 31 | + private TextView txt_sensor_info; |
---|
| 32 | + private TextView txt_sensor_event; |
---|
| 33 | + |
---|
| 34 | + /** Called when the activity is first created. */ |
---|
| 35 | + private SensorManager sensorManager; |
---|
| 36 | + |
---|
| 37 | + protected void onCreate(Bundle paramBundle) { |
---|
| 38 | + super.onCreate(paramBundle); |
---|
| 39 | + |
---|
| 40 | + setTitle(getTitle() + "----(" |
---|
| 41 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")"); |
---|
| 42 | + //requestWindowFeature(Window.FEATURE_NO_TITLE); |
---|
| 43 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON); |
---|
| 44 | + |
---|
| 45 | + setContentView(R.layout.lightsensortest); |
---|
| 46 | + initView(); |
---|
| 47 | + ControlButtonUtil.initControlButtonView(this); |
---|
| 48 | + sensorManager = (SensorManager) this.getSystemService(SENSOR_SERVICE); |
---|
| 49 | + |
---|
| 50 | + } |
---|
| 51 | + |
---|
| 52 | + private void initView() { |
---|
| 53 | + txt_Light = (TextView) findViewById(R.id.Light); |
---|
| 54 | + txt_Light.setTextColor(android.graphics.Color.RED); |
---|
| 55 | + txt_sensor_info = (TextView) findViewById(R.id.txt_sensor_info); |
---|
| 56 | + txt_sensor_event = (TextView) findViewById(R.id.txt_sensor_event); |
---|
| 57 | + txt_sensor_event.setTextColor(android.graphics.Color.GREEN); |
---|
| 58 | + } |
---|
| 59 | + |
---|
| 60 | + protected void onResume() { |
---|
| 61 | + super.onResume(); |
---|
| 62 | + |
---|
| 63 | + List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_LIGHT); |
---|
| 64 | + if (null != sensors) { |
---|
| 65 | + for (Sensor s : sensors) { |
---|
| 66 | + Log.v(TAG, "registerListener " + s.getName()); |
---|
| 67 | + //updateSensorInfoText(s); |
---|
| 68 | + sensorManager.registerListener(this, s, |
---|
| 69 | + SensorManager.SENSOR_DELAY_NORMAL); |
---|
| 70 | + break; |
---|
| 71 | + } |
---|
| 72 | + } |
---|
| 73 | + } |
---|
| 74 | + |
---|
| 75 | + // |
---|
| 76 | + |
---|
| 77 | + protected void onStop() { |
---|
| 78 | + super.onStop(); |
---|
| 79 | + Log.v(TAG, "unregisterListener"); |
---|
| 80 | + sensorManager.unregisterListener(this); |
---|
| 81 | + } |
---|
| 82 | + |
---|
| 83 | + public boolean dispatchKeyEvent(KeyEvent event) { |
---|
| 84 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
---|
| 85 | + return false; |
---|
| 86 | + } |
---|
| 87 | + return super.dispatchKeyEvent(event); |
---|
| 88 | + } |
---|
| 89 | + |
---|
| 90 | + private void updateSensorInfoText(Sensor sensor) { |
---|
| 91 | + StringBuilder sb = new StringBuilder(); |
---|
| 92 | + sb.append("name:" + sensor.getName() + "\n"); |
---|
| 93 | + sb.append("vendor:" + sensor.getVendor() + "\n"); |
---|
| 94 | + sb.append("version:" + sensor.getVersion() + "\n"); |
---|
| 95 | + sb.append("maxRange:" + sensor.getMaximumRange() + "\n"); |
---|
| 96 | + sb.append("resolution:" + sensor.getResolution() + "\n"); |
---|
| 97 | + sb.append("power:" + sensor.getPower() + "\n"); |
---|
| 98 | + txt_sensor_info.setText(sb.toString()); |
---|
| 99 | + } |
---|
| 100 | + |
---|
| 101 | + @Override |
---|
| 102 | + public void onSensorChanged(SensorEvent e) { |
---|
| 103 | + Sensor sensor = e.sensor; |
---|
| 104 | + switch (sensor.getType()) { |
---|
| 105 | + case Sensor.TYPE_LIGHT: { |
---|
| 106 | + updateSensorInfoText(sensor); |
---|
| 107 | + String event = "Light:" + e.values[SensorManager.DATA_X]; |
---|
| 108 | + //Log.v(TAG, "onSensorChanged" + event); |
---|
| 109 | + txt_sensor_event.setText(event); |
---|
| 110 | + } |
---|
| 111 | + default: |
---|
| 112 | + break; |
---|
| 113 | + } |
---|
| 114 | + } |
---|
| 115 | + |
---|
| 116 | + @Override |
---|
| 117 | + public void onAccuracyChanged(Sensor sensor, int i) { |
---|
| 118 | + } |
---|
| 119 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | +import java.io.File; |
---|
| 3 | +import java.io.FilenameFilter; |
---|
| 4 | + |
---|
| 5 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 6 | +import com.DeviceTest.helper.SystemInfoUtil; |
---|
| 7 | +import android.view.View; |
---|
| 8 | +import android.app.Activity; |
---|
| 9 | +import android.content.Context; |
---|
| 10 | +import android.content.DialogInterface; |
---|
| 11 | +import android.os.Bundle; |
---|
| 12 | +import android.os.Environment; |
---|
| 13 | +import android.os.Handler; |
---|
| 14 | +import android.os.Message; |
---|
| 15 | +import android.os.StatFs; |
---|
| 16 | +import android.os.storage.StorageManager; |
---|
| 17 | +import android.os.storage.StorageVolume; |
---|
| 18 | +import android.os.SystemProperties; |
---|
| 19 | +import android.os.storage.StorageEventListener; |
---|
| 20 | +import android.text.format.Formatter; |
---|
| 21 | +import android.util.Log; |
---|
| 22 | +import android.widget.Button; |
---|
| 23 | +import android.widget.TextView; |
---|
| 24 | +import android.view.KeyEvent; |
---|
| 25 | +import android.telephony.TelephonyManager; |
---|
| 26 | + |
---|
| 27 | +public class MobileNetTestActivity extends Activity { |
---|
| 28 | + private final static String TAG = "MobileNetTestActivity"; |
---|
| 29 | + private final static int MSG_OK=0; |
---|
| 30 | + private final static int MSG_FAIL=1; |
---|
| 31 | + |
---|
| 32 | + public void onCreate(Bundle paramBundle) { |
---|
| 33 | + super.onCreate(paramBundle); |
---|
| 34 | + setContentView(R.layout.mobilenettest); |
---|
| 35 | + int simTestResult = 0; |
---|
| 36 | + int moduleTestResult = 0; |
---|
| 37 | + |
---|
| 38 | + TextView simView = (TextView) findViewById(R.id.simView); |
---|
| 39 | + TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); |
---|
| 40 | + String imsi = mTelephonyMgr.getSubscriberId(); |
---|
| 41 | + |
---|
| 42 | + if (imsi == null) { |
---|
| 43 | + simView.setText("Cann't get IMSI!"); |
---|
| 44 | + |
---|
| 45 | + } else { |
---|
| 46 | + simView.setText("IMSI:" + imsi); |
---|
| 47 | + simTestResult = 1; |
---|
| 48 | + } |
---|
| 49 | + |
---|
| 50 | + TextView moduleView = (TextView) findViewById(R.id.moduleView); |
---|
| 51 | + |
---|
| 52 | + String directoryPath = "/dev"; |
---|
| 53 | + File directory = new File(directoryPath); |
---|
| 54 | + File[] ttyUSBFiles = directory.listFiles(new FilenameFilter() { |
---|
| 55 | + @Override |
---|
| 56 | + public boolean accept(File dir, String name) { |
---|
| 57 | + return name.startsWith("ttyUSB"); |
---|
| 58 | + } |
---|
| 59 | + }); |
---|
| 60 | + |
---|
| 61 | + if (ttyUSBFiles != null) { |
---|
| 62 | + int count = ttyUSBFiles.length; |
---|
| 63 | + if (count < 2){ |
---|
| 64 | + moduleView.setText("4G Module check fail"); |
---|
| 65 | + }else { |
---|
| 66 | + moduleView.setText("4G Module check OK"); |
---|
| 67 | + moduleTestResult = 1; |
---|
| 68 | + } |
---|
| 69 | + } else { |
---|
| 70 | + moduleView.setText("4G Module check fail"); |
---|
| 71 | + } |
---|
| 72 | + |
---|
| 73 | + ControlButtonUtil.initControlButtonView(this); |
---|
| 74 | + findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE); |
---|
| 75 | + //if (simTestResult == 1 && moduleTestResult == 1) { |
---|
| 76 | + // only check 4G module |
---|
| 77 | + if (moduleTestResult == 1) { |
---|
| 78 | + handler.sendEmptyMessageDelayed(MSG_OK, 2000); |
---|
| 79 | + } else { |
---|
| 80 | + handler.sendEmptyMessageDelayed(MSG_FAIL, 2000); |
---|
| 81 | + } |
---|
| 82 | + } |
---|
| 83 | + |
---|
| 84 | + private Handler handler=new Handler(){ |
---|
| 85 | + @Override |
---|
| 86 | + public void handleMessage(Message msg) { |
---|
| 87 | + switch(msg.what){ |
---|
| 88 | + case MSG_OK: |
---|
| 89 | + ((Button) findViewById(R.id.btn_Pass)).performClick(); |
---|
| 90 | + |
---|
| 91 | + case MSG_FAIL: |
---|
| 92 | + ((Button) findViewById(R.id.btn_Fail)).performClick(); |
---|
| 93 | + } |
---|
| 94 | + } |
---|
| 95 | + }; |
---|
| 96 | + |
---|
| 97 | + @Override |
---|
| 98 | + protected void onResume() { |
---|
| 99 | + super.onResume(); |
---|
| 100 | + } |
---|
| 101 | + |
---|
| 102 | + public void onCancel(DialogInterface dialog) { |
---|
| 103 | + finish(); |
---|
| 104 | + } |
---|
| 105 | + |
---|
| 106 | + |
---|
| 107 | + public boolean dispatchKeyEvent(KeyEvent event) { |
---|
| 108 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
---|
| 109 | + return false; |
---|
| 110 | + } |
---|
| 111 | + return super.dispatchKeyEvent(event); |
---|
| 112 | + } |
---|
| 113 | + |
---|
| 114 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 7 | +
|
---|
| 8 | +import android.app.Activity;
|
---|
| 9 | +import android.content.BroadcastReceiver;
|
---|
| 10 | +import android.content.Context;
|
---|
| 11 | +import android.content.Intent;
|
---|
| 12 | +import android.content.IntentFilter;
|
---|
| 13 | +import android.os.BatteryManager;
|
---|
| 14 | +import android.os.Bundle;
|
---|
| 15 | +import android.view.KeyEvent;
|
---|
| 16 | +import android.view.View;
|
---|
| 17 | +import android.view.Window;
|
---|
| 18 | +import android.widget.TextView;
|
---|
| 19 | +import android.os.Environment;
|
---|
| 20 | +//import android.hardware.Usb;
|
---|
| 21 | +import android.util.Log;
|
---|
| 22 | +
|
---|
| 23 | +public class MrioUSBTestActivity extends Activity {
|
---|
| 24 | + private static final String TAG = "USBConnectPCTestActivity";
|
---|
| 25 | + private BroadcastReceiver mUsbStateReceiver;
|
---|
| 26 | + TextView mUsbPluginText;
|
---|
| 27 | + TextView mUsbUnplugText;
|
---|
| 28 | + boolean pluginPass = false;
|
---|
| 29 | + boolean unplugPass = false;
|
---|
| 30 | + boolean stop = false;
|
---|
| 31 | +
|
---|
| 32 | +
|
---|
| 33 | + protected void onCreate(Bundle savedInstanceState) {
|
---|
| 34 | + Log.d(TAG, "=========onCreate============");
|
---|
| 35 | + super.onCreate(savedInstanceState);
|
---|
| 36 | +
|
---|
| 37 | + setTitle(getTitle() + "----("
|
---|
| 38 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")");
|
---|
| 39 | + // requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 40 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 41 | +
|
---|
| 42 | + setContentView(R.layout.mriousbtest);
|
---|
| 43 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 44 | +
|
---|
| 45 | + mUsbStateReceiver = new UsbConnectedBroadcastReceiver();
|
---|
| 46 | +
|
---|
| 47 | + mUsbPluginText = (TextView) findViewById(R.id.pluginTest);
|
---|
| 48 | +
|
---|
| 49 | + mUsbUnplugText = (TextView) findViewById(R.id.unplugTest);
|
---|
| 50 | + findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 51 | + }
|
---|
| 52 | +
|
---|
| 53 | +
|
---|
| 54 | + protected void onResume() {
|
---|
| 55 | + super.onResume();
|
---|
| 56 | + stop = false;
|
---|
| 57 | + IntentFilter intentFilter = new IntentFilter(
|
---|
| 58 | + Intent.ACTION_UMS_CONNECTED);
|
---|
| 59 | + intentFilter.addAction(Intent.ACTION_UMS_DISCONNECTED);
|
---|
| 60 | + registerReceiver(mUsbStateReceiver, intentFilter);
|
---|
| 61 | + }
|
---|
| 62 | +
|
---|
| 63 | +
|
---|
| 64 | + public void onPause() {
|
---|
| 65 | + super.onPause();
|
---|
| 66 | + stop = true;
|
---|
| 67 | + unregisterReceiver(mUsbStateReceiver);
|
---|
| 68 | + }
|
---|
| 69 | +
|
---|
| 70 | + class UsbConnectedBroadcastReceiver extends BroadcastReceiver {
|
---|
| 71 | +
|
---|
| 72 | + public void onReceive(Context context, Intent intent) {
|
---|
| 73 | + if(stop) {
|
---|
| 74 | + return;
|
---|
| 75 | + }
|
---|
| 76 | + if (intent.getAction().equals(Intent.ACTION_UMS_CONNECTED)) {
|
---|
| 77 | + if(!pluginPass) {
|
---|
| 78 | + pluginPass = true;
|
---|
| 79 | + mUsbPluginText.setText(mUsbPluginText.getText() + "Pass");
|
---|
| 80 | + }
|
---|
| 81 | + } else if (intent.getAction()
|
---|
| 82 | + .equals(Intent.ACTION_UMS_DISCONNECTED)) {
|
---|
| 83 | + if(!unplugPass) {
|
---|
| 84 | + unplugPass = true;
|
---|
| 85 | + mUsbUnplugText.setText(mUsbUnplugText.getText() + "Pass");
|
---|
| 86 | + }
|
---|
| 87 | + }
|
---|
| 88 | + if (pluginPass && unplugPass) {
|
---|
| 89 | + findViewById(R.id.btn_Pass).performClick();
|
---|
| 90 | + }
|
---|
| 91 | + }
|
---|
| 92 | + };
|
---|
| 93 | +
|
---|
| 94 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 95 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 96 | + return false;
|
---|
| 97 | + }
|
---|
| 98 | + return super.dispatchKeyEvent(event);
|
---|
| 99 | + }
|
---|
| 100 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | + |
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN; |
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; |
---|
| 5 | + |
---|
| 6 | +import java.util.List; |
---|
| 7 | + |
---|
| 8 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 9 | + |
---|
| 10 | +import android.app.Activity; |
---|
| 11 | +import android.graphics.Color; |
---|
| 12 | +import android.hardware.Sensor; |
---|
| 13 | +import android.hardware.SensorEvent; |
---|
| 14 | +import android.hardware.SensorEventListener; |
---|
| 15 | +import android.hardware.SensorManager; |
---|
| 16 | +import android.os.Bundle; |
---|
| 17 | +import android.util.Log; |
---|
| 18 | +import android.view.KeyEvent; |
---|
| 19 | +import android.widget.TextView; |
---|
| 20 | + |
---|
| 21 | +/** |
---|
| 22 | + * @author LanBinYuan |
---|
| 23 | + * @date 2011-06-11 |
---|
| 24 | + * |
---|
| 25 | + */ |
---|
| 26 | + |
---|
| 27 | +public class MsensorTestActivity extends Activity { |
---|
| 28 | + /** Called when the activity is first created. */ |
---|
| 29 | + private SensorManager sensorManager; |
---|
| 30 | + private SensorEventListener lsn = null; |
---|
| 31 | + |
---|
| 32 | + |
---|
| 33 | + protected void onCreate(Bundle paramBundle) { |
---|
| 34 | + super.onCreate(paramBundle); |
---|
| 35 | + |
---|
| 36 | + |
---|
| 37 | + setTitle(getTitle() + "----(" |
---|
| 38 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")"); |
---|
| 39 | + //requestWindowFeature(Window.FEATURE_NO_TITLE); |
---|
| 40 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON); |
---|
| 41 | + |
---|
| 42 | + setContentView(R.layout.msensortest); |
---|
| 43 | + ControlButtonUtil.initControlButtonView(this); |
---|
| 44 | + sensorManager = (SensorManager) this.getSystemService(SENSOR_SERVICE); |
---|
| 45 | + |
---|
| 46 | + } |
---|
| 47 | + |
---|
| 48 | + |
---|
| 49 | + protected void onResume() { |
---|
| 50 | + super.onResume(); |
---|
| 51 | + |
---|
| 52 | + lsn = new SensorEventListener() { |
---|
| 53 | + public void onAccuracyChanged(Sensor sensor, int accuracy) { |
---|
| 54 | + // TODO Auto-generated method stub |
---|
| 55 | + |
---|
| 56 | + } |
---|
| 57 | + |
---|
| 58 | + public void onSensorChanged(SensorEvent e) { |
---|
| 59 | + TextView subTitle = (TextView) findViewById(R.id.Magnetic); |
---|
| 60 | + subTitle.setTextColor(Color.rgb(255, 0, 0)); |
---|
| 61 | + |
---|
| 62 | + String info = " name:" + String.valueOf(e.sensor.getName()); |
---|
| 63 | + info += "\n"; |
---|
| 64 | + |
---|
| 65 | + info += " vendor:" + String.valueOf(e.sensor.getVendor()); |
---|
| 66 | + info += "\n"; |
---|
| 67 | + info += " version:" + String.valueOf(e.sensor.getVersion()); |
---|
| 68 | + info += "\n"; |
---|
| 69 | + info += " maxRange:" |
---|
| 70 | + + String.valueOf(e.sensor.getMaximumRange()); |
---|
| 71 | + info += "\n"; |
---|
| 72 | + info += " resolution:" |
---|
| 73 | + + String.valueOf(e.sensor.getResolution()); |
---|
| 74 | + info += "\n"; |
---|
| 75 | + info += " power:" + String.valueOf(e.sensor.getPower()); |
---|
| 76 | + |
---|
| 77 | + TextView infoView = (TextView) findViewById(R.id.magnetic_info); |
---|
| 78 | + infoView.setText(info); |
---|
| 79 | + // -------------- |
---|
| 80 | + |
---|
| 81 | + TextView x = (TextView) findViewById(R.id.magnetic_x); |
---|
| 82 | + x.setText(" x:" |
---|
| 83 | + + String.valueOf(e.values[SensorManager.DATA_X])); |
---|
| 84 | + x.setTextColor(android.graphics.Color.GREEN); |
---|
| 85 | + |
---|
| 86 | + TextView y = (TextView) findViewById(R.id.magnetic_y); |
---|
| 87 | + y.setText(" y:" |
---|
| 88 | + + String.valueOf(e.values[SensorManager.DATA_Y])); |
---|
| 89 | + y.setTextColor(android.graphics.Color.GREEN); |
---|
| 90 | + |
---|
| 91 | + TextView z = (TextView) findViewById(R.id.magnetic_z); |
---|
| 92 | + z.setText(" z:" |
---|
| 93 | + + String.valueOf(e.values[SensorManager.DATA_Z])); |
---|
| 94 | + z.setTextColor(android.graphics.Color.GREEN); |
---|
| 95 | + |
---|
| 96 | + } |
---|
| 97 | + |
---|
| 98 | + }; |
---|
| 99 | + |
---|
| 100 | + Sensor sensors = sensorManager |
---|
| 101 | + .getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); |
---|
| 102 | + |
---|
| 103 | + sensorManager.registerListener(lsn, sensors, |
---|
| 104 | + SensorManager.SENSOR_DELAY_NORMAL); |
---|
| 105 | + } |
---|
| 106 | + |
---|
| 107 | + // |
---|
| 108 | + |
---|
| 109 | + protected void onStop() { |
---|
| 110 | + super.onStop(); |
---|
| 111 | + sensorManager.unregisterListener(lsn); |
---|
| 112 | + } |
---|
| 113 | + |
---|
| 114 | + public boolean dispatchKeyEvent(KeyEvent event) { |
---|
| 115 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
---|
| 116 | + return false; |
---|
| 117 | + } |
---|
| 118 | + return super.dispatchKeyEvent(event); |
---|
| 119 | + } |
---|
| 120 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | + |
---|
| 3 | +import android.os.Message; |
---|
| 4 | +import android.os.SystemService; |
---|
| 5 | +import android.util.Log; |
---|
| 6 | +import android.view.View; |
---|
| 7 | + |
---|
| 8 | +import com.DeviceTest.helper.PCIEInfo; |
---|
| 9 | + |
---|
| 10 | +import java.io.BufferedReader; |
---|
| 11 | +import java.io.File; |
---|
| 12 | +import java.io.FileReader; |
---|
| 13 | +import java.io.IOException; |
---|
| 14 | +import java.util.ArrayList; |
---|
| 15 | +import java.util.List; |
---|
| 16 | + |
---|
| 17 | +public class PCIETestActivity extends UsbHostTestActivity { |
---|
| 18 | + private static final String TAG = "PCIETestActivity"; |
---|
| 19 | + private static final int MSG_CHECK_PCIE_INFO_FILE = 11; |
---|
| 20 | + |
---|
| 21 | + private boolean mStop; |
---|
| 22 | + private String mPCIEInfoPath; |
---|
| 23 | + private String mStrStorageResult; |
---|
| 24 | + |
---|
| 25 | + @Override |
---|
| 26 | + protected void preData() { |
---|
| 27 | + mStorageType = STORAGE_TYPE.PCIE; |
---|
| 28 | + } |
---|
| 29 | + |
---|
| 30 | + @Override |
---|
| 31 | + protected void dealMessage(Message msg) { |
---|
| 32 | + if (mStop) { |
---|
| 33 | + return; |
---|
| 34 | + } |
---|
| 35 | + switch (msg.what) { |
---|
| 36 | + case MSG_CHECK_PCIE_INFO_FILE: |
---|
| 37 | + testPcieInfo(); |
---|
| 38 | + break; |
---|
| 39 | + default: |
---|
| 40 | + break; |
---|
| 41 | + } |
---|
| 42 | + } |
---|
| 43 | + |
---|
| 44 | + private void testPcieInfo() { |
---|
| 45 | + String staFlag = "LnkSta:"; |
---|
| 46 | + List<String> list = readPcieInfoTxt(mPCIEInfoPath, new String[]{staFlag}, "\t"); |
---|
| 47 | + if (list.size() < 1 /*|| list.size() % 2 == 1*/) { |
---|
| 48 | + appendResultText("pcieInfo file txt err"); |
---|
| 49 | + mHandler.sendEmptyMessageDelayed(R_PASS, BACK_TIME); |
---|
| 50 | + return; |
---|
| 51 | + } |
---|
| 52 | + StringBuilder sb = new StringBuilder(); |
---|
| 53 | + for (String temp : list) { |
---|
| 54 | + sb.append(temp + "\n"); |
---|
| 55 | + } |
---|
| 56 | + Log.v(TAG, sb.toString()); |
---|
| 57 | + appendResultText(sb.toString()); |
---|
| 58 | + |
---|
| 59 | + List<PCIEInfo> lnkModelList = fillPcieInfoTxt(list, staFlag); |
---|
| 60 | + if (lnkModelList.size() < 1/* || lnkModelList.size() % 2 == 1*/) { |
---|
| 61 | + sb.append("\npcieInfo lnk txt err"); |
---|
| 62 | + appendResultText(sb.toString()); |
---|
| 63 | + mHandler.sendEmptyMessageDelayed(R_FAIL, BACK_TIME); |
---|
| 64 | + return; |
---|
| 65 | + } |
---|
| 66 | + |
---|
| 67 | + sb = new StringBuilder(); |
---|
| 68 | + for (PCIEInfo lnk : lnkModelList) { |
---|
| 69 | + sb.append("\n"); |
---|
| 70 | + sb.append(lnk.toString()); |
---|
| 71 | + } |
---|
| 72 | + appendResultText(sb.toString()); |
---|
| 73 | + findViewById(R.id.btn_Pass).setVisibility(View.VISIBLE); |
---|
| 74 | + findViewById(R.id.btn_Pass).setClickable(true); |
---|
| 75 | + findViewById(R.id.btn_Fail).setVisibility(View.VISIBLE); |
---|
| 76 | + findViewById(R.id.btn_Fail).setClickable(true); |
---|
| 77 | + } |
---|
| 78 | + |
---|
| 79 | + private List<String> readPcieInfoTxt(String path, String[] containWords, String replace) { |
---|
| 80 | + List<String> list = new ArrayList<String>(); |
---|
| 81 | + BufferedReader br = null; |
---|
| 82 | + FileReader fr = null; |
---|
| 83 | + try { |
---|
| 84 | + File file = new File(path); |
---|
| 85 | + if (!file.exists()) { |
---|
| 86 | + Log.e(TAG, path + " not exists"); |
---|
| 87 | + return list; |
---|
| 88 | + } |
---|
| 89 | + fr = new FileReader(file); |
---|
| 90 | + br = new BufferedReader(fr); |
---|
| 91 | + String lineText; |
---|
| 92 | + while ((lineText = br.readLine()) != null) { |
---|
| 93 | + lineText = lineText.replaceAll("\t", ""); |
---|
| 94 | + for (String containWord : containWords) { |
---|
| 95 | + if (lineText.contains(containWord)) { |
---|
| 96 | + list.add(lineText); |
---|
| 97 | + } |
---|
| 98 | + } |
---|
| 99 | + } |
---|
| 100 | + } catch (Exception ex) { |
---|
| 101 | + ex.printStackTrace(); |
---|
| 102 | + } finally { |
---|
| 103 | + if (null != fr) { |
---|
| 104 | + try { |
---|
| 105 | + fr.close(); |
---|
| 106 | + } catch (IOException e) { |
---|
| 107 | + e.printStackTrace(); |
---|
| 108 | + } |
---|
| 109 | + } |
---|
| 110 | + if (null != br) { |
---|
| 111 | + try { |
---|
| 112 | + br.close(); |
---|
| 113 | + } catch (IOException e) { |
---|
| 114 | + e.printStackTrace(); |
---|
| 115 | + } |
---|
| 116 | + } |
---|
| 117 | + } |
---|
| 118 | + return list; |
---|
| 119 | + } |
---|
| 120 | + |
---|
| 121 | + private List<PCIEInfo> fillPcieInfoTxt(List<String> vvInfoList, String staFlag) { |
---|
| 122 | + List<PCIEInfo> lnks = new ArrayList<PCIEInfo>(); |
---|
| 123 | + for (String vvInfo : vvInfoList) { |
---|
| 124 | + if (vvInfo.startsWith(staFlag)) { |
---|
| 125 | + PCIEInfo tempLnk = new PCIEInfo(); |
---|
| 126 | + String[] temps = vvInfo.replace(staFlag, "").split(", "); |
---|
| 127 | + for (String temp : temps) { |
---|
| 128 | + if (temp.startsWith("Speed ")) { |
---|
| 129 | + tempLnk.setStaSpeed(temp.replace("Speed ", "")); |
---|
| 130 | + } else if (temp.startsWith("Width ")) { |
---|
| 131 | + tempLnk.setStaWidth(temp.replace("Width ", "")); |
---|
| 132 | + } |
---|
| 133 | + } |
---|
| 134 | + lnks.add(tempLnk); |
---|
| 135 | + } |
---|
| 136 | + } |
---|
| 137 | + return lnks; |
---|
| 138 | + } |
---|
| 139 | + |
---|
| 140 | + private void appendResultText(String ss) { |
---|
| 141 | + mResult.setText(mStrStorageResult + "\n\n" + ss); |
---|
| 142 | + } |
---|
| 143 | + |
---|
| 144 | + @Override |
---|
| 145 | + protected void childTest() { |
---|
| 146 | + Log.v(TAG, "test PCIE info"); |
---|
| 147 | + if (null != mResult.getText() && null != mResult.getText().toString()) { |
---|
| 148 | + mStrStorageResult = mResult.getText().toString(); |
---|
| 149 | + } |
---|
| 150 | + appendResultText("waiting PCIE info test..."); |
---|
| 151 | + mPCIEInfoPath = "/mnt/sdcard/pcieInfo.tmp"; |
---|
| 152 | + File file = new File(mPCIEInfoPath); |
---|
| 153 | + if (null != file && file.exists()) { |
---|
| 154 | + file.delete(); |
---|
| 155 | + } |
---|
| 156 | + try { |
---|
| 157 | + SystemService.start("read_pcie_info"); |
---|
| 158 | + mHandler.sendEmptyMessageDelayed(MSG_CHECK_PCIE_INFO_FILE, 2000); |
---|
| 159 | + } catch (Exception e) { |
---|
| 160 | + appendResultText("err " + e.getMessage()); |
---|
| 161 | + mHandler.sendEmptyMessageDelayed(R_FAIL, BACK_TIME); |
---|
| 162 | + } |
---|
| 163 | + } |
---|
| 164 | + |
---|
| 165 | + @Override |
---|
| 166 | + protected void onDestroy() { |
---|
| 167 | + super.onDestroy(); |
---|
| 168 | + mStop = true; |
---|
| 169 | + mHandler.removeMessages(MSG_CHECK_PCIE_INFO_FILE); |
---|
| 170 | + } |
---|
| 171 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import java.io.File;
|
---|
| 4 | +
|
---|
| 5 | +import android.app.Activity;
|
---|
| 6 | +import android.content.Context;
|
---|
| 7 | +import android.content.Intent;
|
---|
| 8 | +import android.media.AudioManager;
|
---|
| 9 | +import android.os.Bundle;
|
---|
| 10 | +import android.os.Environment;
|
---|
| 11 | +import android.os.Handler;
|
---|
| 12 | +import android.os.Message;
|
---|
| 13 | +import android.os.StatFs;
|
---|
| 14 | +import android.util.Log;
|
---|
| 15 | +import android.view.KeyEvent;
|
---|
| 16 | +import android.view.View;
|
---|
| 17 | +import android.view.Window;
|
---|
| 18 | +import android.view.View.OnClickListener;
|
---|
| 19 | +import android.widget.Button;
|
---|
| 20 | +import android.widget.TextView;
|
---|
| 21 | +
|
---|
| 22 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 23 | +import com.DeviceTest.helper.Recorder;
|
---|
| 24 | +import com.DeviceTest.helper.VUMeter;
|
---|
| 25 | +
|
---|
| 26 | +public class PhoneMicTestActivity extends Activity implements OnClickListener{
|
---|
| 27 | + private static final String TAG = PhoneMicTestActivity.class
|
---|
| 28 | + .getSimpleName();
|
---|
| 29 | +
|
---|
| 30 | + private final static String ERRMSG = "Record error";
|
---|
| 31 | + private final static int RECORD_TIME = 3;
|
---|
| 32 | + private static final int MSG_TEST_MIC_ING = 8738;
|
---|
| 33 | + private static final int MSG_TEST_MIC_OVER = 13107;
|
---|
| 34 | + private static final int MSG_TEST_MIC_START = 4369;
|
---|
| 35 | + private boolean isSDcardTestOk = false;
|
---|
| 36 | + private AudioManager mAudioManager;
|
---|
| 37 | + private Handler mHandler;
|
---|
| 38 | + private int mOldVolume;
|
---|
| 39 | + private Recorder mRecorder;
|
---|
| 40 | + private TextView mResult;
|
---|
| 41 | + boolean mSpeakerOn = false;
|
---|
| 42 | + private TextView mText;
|
---|
| 43 | + int mTimes;
|
---|
| 44 | + TextView mTitle;
|
---|
| 45 | + private Button mBtnRetest;
|
---|
| 46 | + private VUMeter mVUMeter;
|
---|
| 47 | +
|
---|
| 48 | + public PhoneMicTestActivity() {
|
---|
| 49 | + this.mHandler = new MyHandler();
|
---|
| 50 | + }
|
---|
| 51 | +
|
---|
| 52 | + @Override
|
---|
| 53 | + protected void onCreate(Bundle savedInstanceState) {
|
---|
| 54 | +
|
---|
| 55 | + super.onCreate(savedInstanceState);
|
---|
| 56 | +
|
---|
| 57 | + requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 58 | +
|
---|
| 59 | + getWindow().addFlags(1152);
|
---|
| 60 | + setContentView(R.layout.phonemictest);
|
---|
| 61 | +
|
---|
| 62 | + mVUMeter = (VUMeter) findViewById(R.id.uvMeter);
|
---|
| 63 | + this.mResult = (TextView) findViewById(R.id.phoneresultText);
|
---|
| 64 | + this.mResult.setVisibility(View.VISIBLE);
|
---|
| 65 | + this.mResult.setGravity(17);
|
---|
| 66 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 67 | + mBtnRetest = (Button)findViewById(R.id.btn_retest);
|
---|
| 68 | + mBtnRetest.setOnClickListener(this);
|
---|
| 69 | + mBtnRetest.setEnabled(false);
|
---|
| 70 | + this.mRecorder = new Recorder();
|
---|
| 71 | + this.mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
---|
| 72 | + mVUMeter.setRecorder(mRecorder);
|
---|
| 73 | + }
|
---|
| 74 | +
|
---|
| 75 | + @Override
|
---|
| 76 | + protected void onResume() {
|
---|
| 77 | +
|
---|
| 78 | + super.onResume();
|
---|
| 79 | +
|
---|
| 80 | + this.isSDcardTestOk = false;
|
---|
| 81 | + if (!Environment.getExternalStorageState().equals(
|
---|
| 82 | + Environment.MEDIA_MOUNTED)) {
|
---|
| 83 | + this.mResult.setText(R.string.InsertSdCard);
|
---|
| 84 | + return;
|
---|
| 85 | + }
|
---|
| 86 | +
|
---|
| 87 | + if (!isSDcardHasSpace()) {
|
---|
| 88 | + this.mResult.setText(R.string.SdCardNospace);
|
---|
| 89 | + stopMediaPlayBack();
|
---|
| 90 | + return;
|
---|
| 91 | + }
|
---|
| 92 | + stopMediaPlayBack();
|
---|
| 93 | + this.isSDcardTestOk = true;
|
---|
| 94 | +
|
---|
| 95 | + this.mOldVolume = this.mAudioManager
|
---|
| 96 | + .getStreamVolume(AudioManager.STREAM_MUSIC);
|
---|
| 97 | + int maxVolume = this.mAudioManager
|
---|
| 98 | + .getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
---|
| 99 | + this.mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC,
|
---|
| 100 | + maxVolume, 0);
|
---|
| 101 | +
|
---|
| 102 | + this.mSpeakerOn = mAudioManager.isSpeakerphoneOn();
|
---|
| 103 | +
|
---|
| 104 | + if (!this.mSpeakerOn) {
|
---|
| 105 | + this.mAudioManager.setSpeakerphoneOn(true);
|
---|
| 106 | + }
|
---|
| 107 | + this.mHandler.sendEmptyMessage(MSG_TEST_MIC_START);
|
---|
| 108 | +
|
---|
| 109 | + }
|
---|
| 110 | +
|
---|
| 111 | + @Override
|
---|
| 112 | + protected void onPause() {
|
---|
| 113 | +
|
---|
| 114 | + super.onPause();
|
---|
| 115 | +
|
---|
| 116 | + if (this.isSDcardTestOk) {
|
---|
| 117 | +
|
---|
| 118 | + switch (this.mRecorder.state()) {
|
---|
| 119 | +
|
---|
| 120 | + case Recorder.IDLE_STATE:
|
---|
| 121 | + this.mRecorder.delete();
|
---|
| 122 | + break;
|
---|
| 123 | + case Recorder.PLAYING_STATE:
|
---|
| 124 | + this.mRecorder.stop();
|
---|
| 125 | + this.mRecorder.delete();
|
---|
| 126 | + break;
|
---|
| 127 | + case Recorder.RECORDING_STATE:
|
---|
| 128 | + this.mRecorder.stop();
|
---|
| 129 | + this.mRecorder.clear();
|
---|
| 130 | + break;
|
---|
| 131 | + }
|
---|
| 132 | +
|
---|
| 133 | +
|
---|
| 134 | + mAudioManager.setStreamVolume(3, mOldVolume, 0);
|
---|
| 135 | +
|
---|
| 136 | + if (mSpeakerOn) {
|
---|
| 137 | + mAudioManager.setSpeakerphoneOn(false);
|
---|
| 138 | +
|
---|
| 139 | + }
|
---|
| 140 | + }
|
---|
| 141 | +
|
---|
| 142 | + }
|
---|
| 143 | +
|
---|
| 144 | + public void stopMediaPlayBack() {
|
---|
| 145 | + Intent localIntent = new Intent("com.android.music.musicservicecommand");
|
---|
| 146 | + localIntent.putExtra("command", "pause");
|
---|
| 147 | + sendBroadcast(localIntent);
|
---|
| 148 | + }
|
---|
| 149 | +
|
---|
| 150 | + public boolean isSDcardHasSpace() {
|
---|
| 151 | + File pathFile = android.os.Environment.getExternalStorageDirectory();
|
---|
| 152 | +
|
---|
| 153 | + StatFs statfs = new StatFs(pathFile.getPath());
|
---|
| 154 | +
|
---|
| 155 | + if (statfs.getAvailableBlocks() > 1) {
|
---|
| 156 | +
|
---|
| 157 | + return true;
|
---|
| 158 | +
|
---|
| 159 | + }
|
---|
| 160 | +
|
---|
| 161 | + return false;
|
---|
| 162 | +
|
---|
| 163 | + }
|
---|
| 164 | +
|
---|
| 165 | + class MyHandler extends Handler {
|
---|
| 166 | + MyHandler() {
|
---|
| 167 | + }
|
---|
| 168 | +
|
---|
| 169 | + @Override
|
---|
| 170 | + public void handleMessage(Message msg) {
|
---|
| 171 | +
|
---|
| 172 | +
|
---|
| 173 | + switch (msg.what) {
|
---|
| 174 | + default:
|
---|
| 175 | + case MSG_TEST_MIC_START:
|
---|
| 176 | +
|
---|
| 177 | + removeMessages(MSG_TEST_MIC_START);
|
---|
| 178 | + mTimes = RECORD_TIME;
|
---|
| 179 | +
|
---|
| 180 | + mResult.setText(" "+mTimes+" ");
|
---|
| 181 | + mRecorder.startRecording(3, ".amr");
|
---|
| 182 | + sendEmptyMessageDelayed(MSG_TEST_MIC_ING, 1000L);
|
---|
| 183 | + break;
|
---|
| 184 | + case MSG_TEST_MIC_ING:
|
---|
| 185 | +
|
---|
| 186 | +
|
---|
| 187 | +
|
---|
| 188 | + if (mTimes > 0) {
|
---|
| 189 | +
|
---|
| 190 | + mResult.setText(" "+mTimes+" ");
|
---|
| 191 | + mTimes--;
|
---|
| 192 | + Log.i(TAG, "mTimes=" + mTimes);
|
---|
| 193 | + sendEmptyMessageDelayed(MSG_TEST_MIC_ING, 1000L);
|
---|
| 194 | + } else {
|
---|
| 195 | + removeMessages(MSG_TEST_MIC_ING);
|
---|
| 196 | + sendEmptyMessage(MSG_TEST_MIC_OVER);
|
---|
| 197 | +
|
---|
| 198 | + }
|
---|
| 199 | +
|
---|
| 200 | + break;
|
---|
| 201 | + case MSG_TEST_MIC_OVER:
|
---|
| 202 | + removeMessages(MSG_TEST_MIC_OVER);
|
---|
| 203 | + mRecorder.stopRecording();
|
---|
| 204 | + if (mRecorder.sampleLength() > 0) {
|
---|
| 205 | + mResult.setText(R.string.HeadsetRecodrSuccess);
|
---|
| 206 | + mRecorder.startPlayback();
|
---|
| 207 | + } else {
|
---|
| 208 | + mResult.setText(R.string.RecordError);
|
---|
| 209 | + }
|
---|
| 210 | + mBtnRetest.setEnabled(true);
|
---|
| 211 | + break;
|
---|
| 212 | + }
|
---|
| 213 | +
|
---|
| 214 | + mVUMeter.invalidate();
|
---|
| 215 | + }
|
---|
| 216 | +
|
---|
| 217 | + }
|
---|
| 218 | +
|
---|
| 219 | + public void onClick(View v) {
|
---|
| 220 | + switch (this.mRecorder.state()) {
|
---|
| 221 | +
|
---|
| 222 | + case Recorder.IDLE_STATE:
|
---|
| 223 | + this.mRecorder.delete();
|
---|
| 224 | + break;
|
---|
| 225 | + case Recorder.PLAYING_STATE:
|
---|
| 226 | + this.mRecorder.stop();
|
---|
| 227 | + this.mRecorder.delete();
|
---|
| 228 | + break;
|
---|
| 229 | + }
|
---|
| 230 | + mRecorder.stopPlayback();
|
---|
| 231 | + mBtnRetest.setEnabled(false);
|
---|
| 232 | + this.mHandler.sendEmptyMessage(MSG_TEST_MIC_START);
|
---|
| 233 | +
|
---|
| 234 | + }
|
---|
| 235 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 236 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 237 | + return false;
|
---|
| 238 | + }
|
---|
| 239 | + return super.dispatchKeyEvent(event);
|
---|
| 240 | + }
|
---|
| 241 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import java.io.BufferedOutputStream;
|
---|
| 7 | +import java.io.BufferedWriter;
|
---|
| 8 | +import java.io.DataInputStream;
|
---|
| 9 | +import java.io.File;
|
---|
| 10 | +import java.io.FileInputStream;
|
---|
| 11 | +import java.io.FileNotFoundException;
|
---|
| 12 | +import java.io.FileOutputStream;
|
---|
| 13 | +import java.io.FileReader;
|
---|
| 14 | +import java.io.IOException;
|
---|
| 15 | +import java.io.OutputStreamWriter;
|
---|
| 16 | +
|
---|
| 17 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 18 | +import com.DeviceTest.helper.SystemUtil;
|
---|
| 19 | +import com.rockchip.newton.UserModeManager;
|
---|
| 20 | +
|
---|
| 21 | +import android.R.integer;
|
---|
| 22 | +import android.app.Activity;
|
---|
| 23 | +import android.content.BroadcastReceiver;
|
---|
| 24 | +import android.content.Context;
|
---|
| 25 | +import android.content.Intent;
|
---|
| 26 | +import android.content.IntentFilter;
|
---|
| 27 | +import android.os.BatteryManager;
|
---|
| 28 | +import android.os.Bundle;
|
---|
| 29 | +import android.os.PowerManager;
|
---|
| 30 | +import android.util.Log;
|
---|
| 31 | +import android.view.KeyEvent;
|
---|
| 32 | +import android.view.View;
|
---|
| 33 | +import android.view.Window;
|
---|
| 34 | +import android.widget.TextView;
|
---|
| 35 | +
|
---|
| 36 | +public class PowerTestActivity extends Activity {
|
---|
| 37 | + TextView mBattery;
|
---|
| 38 | + private BroadcastReceiver mBatteryInfoReceiver;
|
---|
| 39 | + TextView mChargeStatus;
|
---|
| 40 | + TextView mVoltage;
|
---|
| 41 | + TextView mCurrent;
|
---|
| 42 | + TextView mCapacity;
|
---|
| 43 | + TextView mPlug;
|
---|
| 44 | + private static final String CURRENT_PATH = "/sys/class/power_supply/*battery/current_now";
|
---|
| 45 | +
|
---|
| 46 | + boolean stop = false;
|
---|
| 47 | +
|
---|
| 48 | + int mLastVoltage = -1;
|
---|
| 49 | +
|
---|
| 50 | + TextView pluginView;
|
---|
| 51 | + TextView unplugView;
|
---|
| 52 | + boolean pluginPass = false;
|
---|
| 53 | + boolean unplugPass = false;
|
---|
| 54 | +
|
---|
| 55 | + public PowerTestActivity() {
|
---|
| 56 | +
|
---|
| 57 | + this.mBatteryInfoReceiver = new MyBroadcastReceiver();
|
---|
| 58 | +
|
---|
| 59 | + }
|
---|
| 60 | +
|
---|
| 61 | +
|
---|
| 62 | + protected void onCreate(Bundle savedInstanceState) {
|
---|
| 63 | +
|
---|
| 64 | + super.onCreate(savedInstanceState);
|
---|
| 65 | +
|
---|
| 66 | + setTitle(getTitle() + "----("
|
---|
| 67 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")");
|
---|
| 68 | + // requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 69 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 70 | +
|
---|
| 71 | + setContentView(R.layout.powertest);
|
---|
| 72 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 73 | +
|
---|
| 74 | + this.mChargeStatus = (TextView) findViewById(R.id.chargeStatusText);
|
---|
| 75 | + this.mVoltage = (TextView) findViewById(R.id.voltageText);
|
---|
| 76 | + this.mCurrent = (TextView) findViewById(R.id.currentText);
|
---|
| 77 | + this.mCapacity = (TextView) findViewById(R.id.capacityText);
|
---|
| 78 | + this.mPlug = (TextView) findViewById(R.id.plugText);
|
---|
| 79 | +
|
---|
| 80 | +// findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 81 | + pluginView = (TextView) findViewById(R.id.pluginTest);
|
---|
| 82 | + unplugView = (TextView) findViewById(R.id.unplugTest);
|
---|
| 83 | + }
|
---|
| 84 | +
|
---|
| 85 | +
|
---|
| 86 | + protected void onResume() {
|
---|
| 87 | + super.onResume();
|
---|
| 88 | + stop = false;
|
---|
| 89 | + IntentFilter localIntentFilter = new IntentFilter(
|
---|
| 90 | + Intent.ACTION_BATTERY_CHANGED);
|
---|
| 91 | + registerReceiver(this.mBatteryInfoReceiver, localIntentFilter);
|
---|
| 92 | + }
|
---|
| 93 | +
|
---|
| 94 | +
|
---|
| 95 | + public void onPause() {
|
---|
| 96 | + super.onPause();
|
---|
| 97 | + stop = true;
|
---|
| 98 | + BroadcastReceiver localBroadcastReceiver = this.mBatteryInfoReceiver;
|
---|
| 99 | + unregisterReceiver(localBroadcastReceiver);
|
---|
| 100 | +
|
---|
| 101 | + }
|
---|
| 102 | +
|
---|
| 103 | + class MyBroadcastReceiver extends BroadcastReceiver {
|
---|
| 104 | + public void onReceive(Context paramContext, Intent intent) {
|
---|
| 105 | + if (stop) {
|
---|
| 106 | + return;
|
---|
| 107 | + }
|
---|
| 108 | + String action = intent.getAction();
|
---|
| 109 | +
|
---|
| 110 | + if (!Intent.ACTION_BATTERY_CHANGED.equals(action)) {
|
---|
| 111 | + return;
|
---|
| 112 | +
|
---|
| 113 | + }
|
---|
| 114 | +
|
---|
| 115 | + int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, 0);
|
---|
| 116 | +
|
---|
| 117 | + int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
---|
| 118 | + int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, 100);
|
---|
| 119 | +
|
---|
| 120 | + int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
|
---|
| 121 | + int voltage = intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, 0);
|
---|
| 122 | + Log.e("Jeffy", "plugged:" + plugged);
|
---|
| 123 | + // int current = -1;
|
---|
| 124 | + // try {
|
---|
| 125 | + // DataInputStream dis = new DataInputStream(new FileInputStream(
|
---|
| 126 | + // CURRENT_PATH));
|
---|
| 127 | + // current = Integer.parseInt(dis.readLine());
|
---|
| 128 | + // dis.close();
|
---|
| 129 | + // } catch (FileNotFoundException e) {
|
---|
| 130 | + // e.printStackTrace();
|
---|
| 131 | + // } catch (IOException e) {
|
---|
| 132 | + // e.printStackTrace();
|
---|
| 133 | + // }
|
---|
| 134 | + int current = -1;
|
---|
| 135 | + try {
|
---|
| 136 | + String currentStr = SystemUtil.execScriptCmd("cat "
|
---|
| 137 | + + CURRENT_PATH, DeviceTest.TEMP_FILE_PATH, true);
|
---|
| 138 | + if (currentStr.length() > 0) {
|
---|
| 139 | + current = Integer.parseInt(currentStr);
|
---|
| 140 | + }
|
---|
| 141 | + } catch (Exception e) {
|
---|
| 142 | + e.printStackTrace();
|
---|
| 143 | + }
|
---|
| 144 | +
|
---|
| 145 | + String statusString = "";
|
---|
| 146 | +
|
---|
| 147 | + switch (status) {
|
---|
| 148 | + case BatteryManager.BATTERY_STATUS_UNKNOWN:
|
---|
| 149 | + statusString = "Unknown";
|
---|
| 150 | + break;
|
---|
| 151 | + case BatteryManager.BATTERY_STATUS_CHARGING:
|
---|
| 152 | + statusString = "Charging";
|
---|
| 153 | +
|
---|
| 154 | + break;
|
---|
| 155 | + case BatteryManager.BATTERY_STATUS_DISCHARGING:
|
---|
| 156 | + statusString = "Discharging";
|
---|
| 157 | + break;
|
---|
| 158 | + case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
|
---|
| 159 | + statusString = "Not Charging";
|
---|
| 160 | + break;
|
---|
| 161 | + case BatteryManager.BATTERY_STATUS_FULL:
|
---|
| 162 | + statusString = "Full";
|
---|
| 163 | + break;
|
---|
| 164 | + }
|
---|
| 165 | + mChargeStatus.setText(getString(R.string.ChargeState) + statusString);
|
---|
| 166 | +
|
---|
| 167 | + mVoltage.setText(getString(R.string.Voltage) + voltage + "mV");
|
---|
| 168 | +
|
---|
| 169 | + if (current != -1) {
|
---|
| 170 | + mCurrent.setText("Current:" + (current / 1000) + "mA");
|
---|
| 171 | + } else {
|
---|
| 172 | + mCurrent.setVisibility(View.GONE);
|
---|
| 173 | + }
|
---|
| 174 | +
|
---|
| 175 | + mCapacity.setText(getString(R.string.Capacity) + (level * 100 / scale) + "%");
|
---|
| 176 | +
|
---|
| 177 | + boolean acPlugin = false;
|
---|
| 178 | + String pluggedStr = "";
|
---|
| 179 | + switch (plugged) {
|
---|
| 180 | + case BatteryManager.BATTERY_PLUGGED_AC:
|
---|
| 181 | + acPlugin = true;
|
---|
| 182 | + pluggedStr = "AC";
|
---|
| 183 | + break;
|
---|
| 184 | + case BatteryManager.BATTERY_PLUGGED_USB:
|
---|
| 185 | + pluggedStr = "USB";
|
---|
| 186 | + break;
|
---|
| 187 | +
|
---|
| 188 | + default:
|
---|
| 189 | + pluggedStr = "Unplugged";
|
---|
| 190 | + break;
|
---|
| 191 | + }
|
---|
| 192 | + mPlug.setText(getString(R.string.Plug) + pluggedStr);
|
---|
| 193 | +
|
---|
| 194 | +// if (mLastVoltage > 0) {
|
---|
| 195 | +// if (acPlugin) {
|
---|
| 196 | +// if (voltage > mLastVoltage) {
|
---|
| 197 | +// if (!pluginPass) {
|
---|
| 198 | +// pluginPass = true;
|
---|
| 199 | +// pluginView.setText(pluginView.getText() + "Pass");
|
---|
| 200 | +// }
|
---|
| 201 | +// }
|
---|
| 202 | +// } else {
|
---|
| 203 | +// if (voltage < mLastVoltage) {
|
---|
| 204 | +// if (!unplugPass) {
|
---|
| 205 | +// unplugPass = true;
|
---|
| 206 | +// unplugView.setText(unplugView.getText() + "Pass");
|
---|
| 207 | +// }
|
---|
| 208 | +// }
|
---|
| 209 | +// }
|
---|
| 210 | +// }
|
---|
| 211 | +//
|
---|
| 212 | +// if (pluginPass && unplugPass) {
|
---|
| 213 | +// findViewById(R.id.btn_Pass).performClick();
|
---|
| 214 | +// }
|
---|
| 215 | +
|
---|
| 216 | +// mLastVoltage = voltage;
|
---|
| 217 | + }
|
---|
| 218 | + }
|
---|
| 219 | +
|
---|
| 220 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 221 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 222 | + return false;
|
---|
| 223 | + }
|
---|
| 224 | + return super.dispatchKeyEvent(event);
|
---|
| 225 | + }
|
---|
| 226 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | +import java.io.File; |
---|
| 3 | + |
---|
| 4 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 5 | +import com.DeviceTest.helper.SystemInfoUtil; |
---|
| 6 | +import android.view.View; |
---|
| 7 | +import android.app.Activity; |
---|
| 8 | +import android.content.Context; |
---|
| 9 | +import android.content.DialogInterface; |
---|
| 10 | +import android.os.Bundle; |
---|
| 11 | +import android.os.Environment; |
---|
| 12 | +import android.os.Handler; |
---|
| 13 | +import android.os.Message; |
---|
| 14 | +import android.os.StatFs; |
---|
| 15 | +import android.os.storage.StorageManager; |
---|
| 16 | +import android.os.storage.StorageVolume; |
---|
| 17 | +import android.os.SystemProperties; |
---|
| 18 | +import android.os.storage.StorageEventListener; |
---|
| 19 | +import android.text.format.Formatter; |
---|
| 20 | +import android.util.Log; |
---|
| 21 | +import android.widget.Button; |
---|
| 22 | +import android.widget.TextView; |
---|
| 23 | +import android.view.KeyEvent; |
---|
| 24 | + |
---|
| 25 | +import java.io.File; |
---|
| 26 | + |
---|
| 27 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 28 | +import com.DeviceTest.helper.SystemInfoUtil; |
---|
| 29 | + |
---|
| 30 | +import android.app.Activity; |
---|
| 31 | +import android.content.Context; |
---|
| 32 | +import android.content.DialogInterface; |
---|
| 33 | +import android.os.Bundle; |
---|
| 34 | +import android.os.Environment; |
---|
| 35 | +import android.os.Handler; |
---|
| 36 | +import android.os.Message; |
---|
| 37 | +import android.os.StatFs; |
---|
| 38 | +import android.os.storage.StorageManager; |
---|
| 39 | +import android.os.storage.StorageVolume; |
---|
| 40 | +import android.os.SystemProperties; |
---|
| 41 | +import android.os.storage.StorageEventListener; |
---|
| 42 | +import android.text.format.Formatter; |
---|
| 43 | +import android.util.Log; |
---|
| 44 | +import android.widget.Button; |
---|
| 45 | +import android.widget.TextView; |
---|
| 46 | +import android.hardware.usb.UsbDevice; |
---|
| 47 | +import android.hardware.usb.UsbManager; |
---|
| 48 | +import java.util.Iterator; |
---|
| 49 | +import java.util.HashMap; |
---|
| 50 | +import java.io.FileReader; |
---|
| 51 | + |
---|
| 52 | + |
---|
| 53 | + |
---|
| 54 | +public class RTCTestActivity extends Activity { |
---|
| 55 | + private final static String TAG = "RTCTestActivity"; |
---|
| 56 | + private final static int MSG_OK=0; |
---|
| 57 | + private final static int MSG_FAIL=1; |
---|
| 58 | + |
---|
| 59 | + public void onCreate(Bundle paramBundle) { |
---|
| 60 | + super.onCreate(paramBundle); |
---|
| 61 | + setContentView(R.layout.rtctest); |
---|
| 62 | + |
---|
| 63 | + int count = 0; |
---|
| 64 | + String str = null; |
---|
| 65 | + File rtcFile = new File("/sys/class/rtc/"); |
---|
| 66 | + File[] list = rtcFile.listFiles(); |
---|
| 67 | + |
---|
| 68 | + String rtcStr = ""; |
---|
| 69 | + |
---|
| 70 | + |
---|
| 71 | + for (File f: list){ |
---|
| 72 | + count ++; |
---|
| 73 | + Log.d("RRRRRRR", "rtc file:" + f.getName()); |
---|
| 74 | + char[] buffer = new char[32]; |
---|
| 75 | + try { |
---|
| 76 | + FileReader mReader = new FileReader(new File(f.getPath() + "/name")); |
---|
| 77 | + mReader.read(buffer, 0, 32); |
---|
| 78 | + mReader.close(); |
---|
| 79 | + } catch (Exception e) { |
---|
| 80 | + e.printStackTrace(); |
---|
| 81 | + } |
---|
| 82 | + |
---|
| 83 | + str = new String(buffer).trim(); |
---|
| 84 | + if (str.equals("aml_vrtc")){ |
---|
| 85 | + //skip |
---|
| 86 | + } else if (str.equals("rk808-rtc rk808-rtc")){ |
---|
| 87 | + //skip |
---|
| 88 | + //((TextView) findViewById(R.id.RTCResult)).setText("检测到内部RTC: " + str + "\n" + "请务必确认板子是否有外置RTC芯片!!"); |
---|
| 89 | + rtcStr += f.getName() + " :" + str + "\n"; |
---|
| 90 | + } else { |
---|
| 91 | + // count++; |
---|
| 92 | + // if (count > 0) { |
---|
| 93 | + // ((TextView) findViewById(R.id.RTCResult)).setText("RTC设备数: " + count + ", RTC型号:" + str); |
---|
| 94 | + // // handler.sendEmptyMessageDelayed(MSG_OK, 1000); |
---|
| 95 | + // } else { |
---|
| 96 | + // ((TextView) findViewById(R.id.RTCResult)).setText("没有找到RTC设备."); |
---|
| 97 | + // // handler.sendEmptyMessageDelayed(MSG_FAIL, 1000); |
---|
| 98 | + //} |
---|
| 99 | + rtcStr += f.getName() + " :" + str + "\n"; |
---|
| 100 | + } |
---|
| 101 | + } |
---|
| 102 | + rtcStr = "RTC 设备数量:" + count + "\n" + rtcStr; |
---|
| 103 | + ((TextView) findViewById(R.id.RTCResult)).setText(rtcStr); |
---|
| 104 | + |
---|
| 105 | + ControlButtonUtil.initControlButtonView(this); |
---|
| 106 | + // findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE); //屏蔽确认按键 |
---|
| 107 | + } |
---|
| 108 | + |
---|
| 109 | + private Handler handler=new Handler(){ |
---|
| 110 | + @Override |
---|
| 111 | + public void handleMessage(Message msg) { |
---|
| 112 | + switch(msg.what){ |
---|
| 113 | + case MSG_OK: |
---|
| 114 | + ((Button) findViewById(R.id.btn_Pass)).performClick(); |
---|
| 115 | + case MSG_FAIL: |
---|
| 116 | + ((Button) findViewById(R.id.btn_Fail)).performClick(); |
---|
| 117 | + } |
---|
| 118 | + } |
---|
| 119 | + }; |
---|
| 120 | + |
---|
| 121 | + |
---|
| 122 | + @Override |
---|
| 123 | + protected void onResume() { |
---|
| 124 | + super.onResume(); |
---|
| 125 | + } |
---|
| 126 | + |
---|
| 127 | + public void onCancel(DialogInterface dialog) { |
---|
| 128 | + finish(); |
---|
| 129 | + } |
---|
| 130 | + |
---|
| 131 | + public boolean dispatchKeyEvent(KeyEvent event) { |
---|
| 132 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
---|
| 133 | + return false; |
---|
| 134 | + } |
---|
| 135 | + return super.dispatchKeyEvent(event); |
---|
| 136 | + } |
---|
| 137 | + |
---|
| 138 | +} |
---|
| 139 | + |
---|
.. | .. |
---|
| 1 | +/*
|
---|
| 2 | + * Copyright (C) 2009 The Rockchip Android MID 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.DeviceTest;
|
---|
| 18 | +
|
---|
| 19 | +
|
---|
| 20 | +import java.io.File;
|
---|
| 21 | +
|
---|
| 22 | +import android.app.Dialog;
|
---|
| 23 | +import android.app.ListActivity;
|
---|
| 24 | +import android.app.ProgressDialog;
|
---|
| 25 | +import android.content.AsyncQueryHandler;
|
---|
| 26 | +import android.content.BroadcastReceiver;
|
---|
| 27 | +import android.content.ContentResolver;
|
---|
| 28 | +import android.content.ContentUris;
|
---|
| 29 | +import android.content.Context;
|
---|
| 30 | +import android.content.Intent;
|
---|
| 31 | +import android.content.IntentFilter;
|
---|
| 32 | +import android.database.Cursor;
|
---|
| 33 | +import android.net.Uri;
|
---|
| 34 | +import android.os.Bundle;
|
---|
| 35 | +import android.os.Handler;
|
---|
| 36 | +import android.os.Message;
|
---|
| 37 | +import android.provider.MediaStore;
|
---|
| 38 | +import android.util.Log;
|
---|
| 39 | +import android.view.KeyEvent;
|
---|
| 40 | +import android.view.View;
|
---|
| 41 | +import android.widget.Button;
|
---|
| 42 | +import android.widget.ListView;
|
---|
| 43 | +import android.widget.Toast;
|
---|
| 44 | +
|
---|
| 45 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 46 | +import com.DeviceTest.helper.VideoListAdapter;
|
---|
| 47 | +import com.DeviceTest.helper.TestCase.RESULT;
|
---|
| 48 | +
|
---|
| 49 | +public class RockVideoPlayer extends ListActivity
|
---|
| 50 | + implements View.OnCreateContextMenuListener{
|
---|
| 51 | + private static final String TAG = "RockVideoPlayer";
|
---|
| 52 | + private static final boolean DEBUG = true;
|
---|
| 53 | + public static void LOG(String msg)
|
---|
| 54 | + {
|
---|
| 55 | + if(DEBUG)
|
---|
| 56 | + {
|
---|
| 57 | + Log.d(TAG,msg);
|
---|
| 58 | + }
|
---|
| 59 | + }
|
---|
| 60 | + //private ArrayList<VideoItem> VideoSet;
|
---|
| 61 | + private String[] mCols = new String[] {
|
---|
| 62 | + MediaStore.Video.Media._ID,
|
---|
| 63 | + MediaStore.Video.Media.TITLE,
|
---|
| 64 | + MediaStore.Video.Media.DISPLAY_NAME,
|
---|
| 65 | + MediaStore.Video.Media.DURATION,
|
---|
| 66 | + MediaStore.Video.Media.MIME_TYPE,
|
---|
| 67 | + MediaStore.Video.Media.SIZE,
|
---|
| 68 | + MediaStore.Video.Media.BOOKMARK,
|
---|
| 69 | + MediaStore.Video.Media.DATA
|
---|
| 70 | + };
|
---|
| 71 | + /*���Ե�cursor,�������������� */
|
---|
| 72 | + public Cursor mVideoCursor;
|
---|
| 73 | + private String mSortOrder;
|
---|
| 74 | + private VideoListAdapter mVideoListAdapter;
|
---|
| 75 | + private Uri mCurrentVideoUri;
|
---|
| 76 | + private String mCurrentVideoFilename;
|
---|
| 77 | + private View MainView;
|
---|
| 78 | + private View sNoFileView;
|
---|
| 79 | + static final int DIALOG_DELETE_CHOICE = 1;
|
---|
| 80 | + static final int DIALOG_DELETE_CONFIRM = 2;
|
---|
| 81 | + private static final int PlayDone = 1;
|
---|
| 82 | + private int mLastPosition = 0;
|
---|
| 83 | + int timeoutmode;
|
---|
| 84 | + int screenOn;
|
---|
| 85 | + int mOldBrightness;
|
---|
| 86 | + boolean mForbidenClick = false;
|
---|
| 87 | + private Dialog mMediaScanningDialog;
|
---|
| 88 | + private ProgressDialog pd;
|
---|
| 89 | + private BroadcastReceiver mReceiver;
|
---|
| 90 | + private ListView mVideoList;
|
---|
| 91 | + private Uri mUri;
|
---|
| 92 | + public RockVideoPlayer(){
|
---|
| 93 | + }
|
---|
| 94 | + @Override
|
---|
| 95 | + public void onCreate(Bundle savedInstanceState)
|
---|
| 96 | + {
|
---|
| 97 | + super.onCreate(savedInstanceState);
|
---|
| 98 | +
|
---|
| 99 | + setContentView(R.layout.main_display_land);
|
---|
| 100 | + MainView = findViewById(R.id.main_layout);
|
---|
| 101 | + sNoFileView = findViewById(R.id.novideofile);
|
---|
| 102 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 103 | + }
|
---|
| 104 | + public void VideoDisplayVisible()
|
---|
| 105 | + {
|
---|
| 106 | + LOG("Begin to setListAdapter");
|
---|
| 107 | + VideoDisplay();
|
---|
| 108 | + mForbidenClick = false;
|
---|
| 109 | + //RockVideoPlayer.this.getListView().setSelection(mLastPosition);
|
---|
| 110 | + }
|
---|
| 111 | + public void VideoDisplayVInVisible()
|
---|
| 112 | + {
|
---|
| 113 | + sNoFileView.setVisibility(View.VISIBLE);
|
---|
| 114 | + }
|
---|
| 115 | +
|
---|
| 116 | + @Override
|
---|
| 117 | + public void onResume() {
|
---|
| 118 | + LOG("Enter onResume()");
|
---|
| 119 | + super.onResume();
|
---|
| 120 | + String Dilog_tile = getResources().getString(R.string.load_title);
|
---|
| 121 | + String Dilog_wait = getResources().getString(R.string.wait);
|
---|
| 122 | + pd = ProgressDialog.show(this, Dilog_tile,Dilog_wait, true, false);
|
---|
| 123 | + IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_MOUNTED);
|
---|
| 124 | + intentFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
|
---|
| 125 | + intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED);
|
---|
| 126 | + intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
|
---|
| 127 | + intentFilter.addAction(Intent.ACTION_MEDIA_EJECT);
|
---|
| 128 | + intentFilter.addDataScheme("file");
|
---|
| 129 | + mReceiver = new BroadcastReceiver() {
|
---|
| 130 | + @Override
|
---|
| 131 | + public void onReceive(Context context, Intent intent) {
|
---|
| 132 | +
|
---|
| 133 | + String action = intent.getAction();
|
---|
| 134 | + LOG("action = " + action);
|
---|
| 135 | + if (action.equals(Intent.ACTION_MEDIA_MOUNTED)) {
|
---|
| 136 | + } else if (action.equals(Intent.ACTION_MEDIA_EJECT)
|
---|
| 137 | + ||action.equals(Intent.ACTION_MEDIA_UNMOUNTED)){
|
---|
| 138 | + finish();
|
---|
| 139 | + return;
|
---|
| 140 | + } else if (action.equals(Intent.ACTION_MEDIA_SCANNER_STARTED)
|
---|
| 141 | + ||action.equals(Intent.ACTION_MEDIA_SCANNER_FINISHED)) {
|
---|
| 142 | + mReScanHandler.sendEmptyMessage(0);
|
---|
| 143 | + }
|
---|
| 144 | + }
|
---|
| 145 | + };
|
---|
| 146 | + registerReceiver(mReceiver, new IntentFilter(intentFilter));
|
---|
| 147 | + VideoDisplayVisible();
|
---|
| 148 | + }
|
---|
| 149 | + public void updataAdapter()
|
---|
| 150 | + {
|
---|
| 151 | + LOG("Enter updataAdapter()");
|
---|
| 152 | + LOG("mVideoListAdapter = " + mVideoListAdapter);
|
---|
| 153 | + setListAdapter(mVideoListAdapter);
|
---|
| 154 | + setVideoDisplayViewBackground();
|
---|
| 155 | +
|
---|
| 156 | + }
|
---|
| 157 | + public void setVideoDisplayViewBackground()
|
---|
| 158 | + {
|
---|
| 159 | + LOG("Enter setVideoDisplayViewBackground() ");
|
---|
| 160 | +
|
---|
| 161 | + if (mVideoListAdapter == null)
|
---|
| 162 | + //MainView.setBackgroundResource(R.drawable.novideofile);
|
---|
| 163 | + sNoFileView.setVisibility(View.VISIBLE);
|
---|
| 164 | + else{
|
---|
| 165 | + if(mVideoCursor == null){
|
---|
| 166 | + //MainView.setBackgroundResource(R.drawable.novideofile);
|
---|
| 167 | + sNoFileView.setVisibility(View.VISIBLE);
|
---|
| 168 | + }else if(mVideoCursor.moveToFirst() == false){
|
---|
| 169 | + //MainView.setBackgroundResource(R.drawable.novideofile);
|
---|
| 170 | + sNoFileView.setVisibility(View.VISIBLE);
|
---|
| 171 | + }
|
---|
| 172 | + else if( mVideoCursor.moveToFirst() != false && mVideoCursor.getCount()!= 0){
|
---|
| 173 | + //MainView.setBackgroundColor(R.color.black);
|
---|
| 174 | + {
|
---|
| 175 | + sNoFileView.setVisibility(View.GONE);
|
---|
| 176 | + // RockVideoPlayer.this.getListView().setSelection(mLastPosition);
|
---|
| 177 | + }
|
---|
| 178 | + }else{
|
---|
| 179 | + sNoFileView.setVisibility(View.VISIBLE);
|
---|
| 180 | + }
|
---|
| 181 | + }
|
---|
| 182 | + }
|
---|
| 183 | + @Override
|
---|
| 184 | + public void onRestart()
|
---|
| 185 | + {
|
---|
| 186 | + LOG("Enter onRestart()");
|
---|
| 187 | + super.onRestart();
|
---|
| 188 | + //RockVideoPlayer.this.getListView().setSelection(mLastPosition);
|
---|
| 189 | + }
|
---|
| 190 | + @Override
|
---|
| 191 | + public void onPause() {
|
---|
| 192 | + LOG("Enter onPause()");
|
---|
| 193 | + super.onPause();
|
---|
| 194 | + Uri uri = mUri;
|
---|
| 195 | + mReScanHandler.removeCallbacksAndMessages(null);
|
---|
| 196 | + unregisterReceiverSafe(mReceiver);
|
---|
| 197 | + System.gc();
|
---|
| 198 | + }
|
---|
| 199 | + @Override
|
---|
| 200 | + public void onDestroy() {
|
---|
| 201 | + LOG("Enter onDestroy()");
|
---|
| 202 | + unregisterReceiverSafe(mReceiver);
|
---|
| 203 | + super.onDestroy();
|
---|
| 204 | + }
|
---|
| 205 | + private void unregisterReceiverSafe(BroadcastReceiver receiver) {
|
---|
| 206 | + try {
|
---|
| 207 | + unregisterReceiver(receiver);
|
---|
| 208 | + } catch (IllegalArgumentException e) {
|
---|
| 209 | + // ignore
|
---|
| 210 | + }
|
---|
| 211 | + }
|
---|
| 212 | + public void VideoDisplay()
|
---|
| 213 | + {
|
---|
| 214 | + LOG("Enter VideoDisplay()");
|
---|
| 215 | + mVideoList = getListView();
|
---|
| 216 | + if (mVideoListAdapter == null){
|
---|
| 217 | + mVideoListAdapter = new VideoListAdapter(
|
---|
| 218 | + RockVideoPlayer.this, // need to use application context to avoid leaks
|
---|
| 219 | + this,
|
---|
| 220 | + R.layout.video_item_land,
|
---|
| 221 | + null, // cursor
|
---|
| 222 | + new String[] {},
|
---|
| 223 | + new int[] {}
|
---|
| 224 | + );
|
---|
| 225 | + LOG("mVideoListAdapter = " + mVideoListAdapter);
|
---|
| 226 | + mVideoListAdapter.setActivity(this);
|
---|
| 227 | + setListAdapter(mVideoListAdapter);
|
---|
| 228 | + getVideoCursor(mVideoListAdapter.getQueryHandler());
|
---|
| 229 | +
|
---|
| 230 | + }else{
|
---|
| 231 | + mVideoListAdapter.setActivity(this);
|
---|
| 232 | + mVideoCursor = mVideoListAdapter.getCursor();
|
---|
| 233 | + LOG("mVideoCursor = " + mVideoCursor);
|
---|
| 234 | + if (mVideoCursor != null) {
|
---|
| 235 | + initVideoCursor(mVideoCursor);
|
---|
| 236 | + } else {
|
---|
| 237 | + getVideoCursor(mVideoListAdapter.getQueryHandler());
|
---|
| 238 | + }
|
---|
| 239 | + LOG("mVideoCursor2 = " + mVideoCursor);
|
---|
| 240 | + setListAdapter(mVideoListAdapter);
|
---|
| 241 | + setVideoDisplayViewBackground();
|
---|
| 242 | + }
|
---|
| 243 | + }
|
---|
| 244 | + @Override
|
---|
| 245 | + protected void onListItemClick(ListView l, View v, int position, long id)
|
---|
| 246 | + {
|
---|
| 247 | + LOG("onListItemClick:mForbidenClick = " + mForbidenClick);
|
---|
| 248 | +
|
---|
| 249 | + mLastPosition = position;
|
---|
| 250 | + String videoid = Long.valueOf(id).toString();
|
---|
| 251 | + Uri uri = Uri.withAppendedPath(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
|
---|
| 252 | + videoid);
|
---|
| 253 | + if(uri == null){
|
---|
| 254 | + return;
|
---|
| 255 | + }
|
---|
| 256 | + Cursor cur = getCurrentCursor(this,uri);
|
---|
| 257 | + if(cur == null)
|
---|
| 258 | + return;
|
---|
| 259 | + String tepMimetype = cur.getString(cur.getColumnIndexOrThrow(MediaStore.Video.Media.MIME_TYPE));
|
---|
| 260 | + if(checkVideoAvailable(this, cur)){
|
---|
| 261 | + /* Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
---|
| 262 | + intent.putExtra(name, value);
|
---|
| 263 | + intent.setClass(this, VideoPlayActivity.class);
|
---|
| 264 | + intent.putExtra("mediaTypes", tepMimetype);
|
---|
| 265 | + startActivityForResult(intent,PlayDone);*/
|
---|
| 266 | + // Intent intent = new Intent("com.rk.app.mediafloat.CUSTOM_ACTION");
|
---|
| 267 | + Intent intent = new Intent(Intent.ACTION_VIEW);
|
---|
| 268 | + intent.setDataAndType(uri, tepMimetype);
|
---|
| 269 | +
|
---|
| 270 | + // intent.putExtra("URI", uri.toString());
|
---|
| 271 | + //intent.putExtra("POSITION", 0);
|
---|
| 272 | + startActivity(intent);
|
---|
| 273 | + // ControlButtonUtil. setIntent("com.rk.app.mediafloat.CUSTOM_ACTION");
|
---|
| 274 | + mForbidenClick = true;
|
---|
| 275 | + }
|
---|
| 276 | +
|
---|
| 277 | + }
|
---|
| 278 | + public Cursor getCurrentCursor(Context context,Uri currenturi)
|
---|
| 279 | + {
|
---|
| 280 | + Uri uri = MediaStore.Video.Media.getContentUri("external");
|
---|
| 281 | + Cursor cur = getContentResolver().query(uri, mCols, null, null, null);
|
---|
| 282 | + if(cur != null)
|
---|
| 283 | + {
|
---|
| 284 | + if(cur.moveToFirst())
|
---|
| 285 | + {
|
---|
| 286 | + while(!cur.isAfterLast())
|
---|
| 287 | + {
|
---|
| 288 | + if(currenturi.equals(ContentUris.withAppendedId(uri,cur.getInt(cur.getColumnIndexOrThrow(MediaStore.Video.Media._ID)))))
|
---|
| 289 | + return cur;
|
---|
| 290 | + else
|
---|
| 291 | + cur.moveToNext();
|
---|
| 292 | + }
|
---|
| 293 | + }
|
---|
| 294 | + }
|
---|
| 295 | + return null;
|
---|
| 296 | + }
|
---|
| 297 | + public static boolean checkVideoAvailable(Context context,Cursor cur){
|
---|
| 298 | + String videofile = cur.getString(cur.getColumnIndexOrThrow(MediaStore.Video.Media.DATA));
|
---|
| 299 | + File file = new File(videofile);
|
---|
| 300 | + if (file.exists()){
|
---|
| 301 | + return true;
|
---|
| 302 | + }else
|
---|
| 303 | + return false;
|
---|
| 304 | + }
|
---|
| 305 | + Handler mHandler = new Handler();
|
---|
| 306 | + public Cursor query(Uri uri, String[] projection,
|
---|
| 307 | + String selection, String[] selectionArgs, String sortOrder) {
|
---|
| 308 | + LOG("Enter query()");
|
---|
| 309 | + try {
|
---|
| 310 | + ContentResolver resolver = getContentResolver();
|
---|
| 311 | + if (resolver == null) {
|
---|
| 312 | + return null;
|
---|
| 313 | + }
|
---|
| 314 | + return resolver.query(uri, projection, selection, selectionArgs, sortOrder);
|
---|
| 315 | + } catch (UnsupportedOperationException ex) {
|
---|
| 316 | + return null;
|
---|
| 317 | + }
|
---|
| 318 | + }
|
---|
| 319 | + public Cursor getVideoCursor(AsyncQueryHandler async){
|
---|
| 320 | + LOG("Enter getVideoCursor()");
|
---|
| 321 | + Cursor ret = null;
|
---|
| 322 | + mSortOrder = MediaStore.Video.Media._ID;
|
---|
| 323 | + StringBuilder where = new StringBuilder();
|
---|
| 324 | + where.append(MediaStore.Video.Media._ID + " != ''");
|
---|
| 325 | + if (async != null) {
|
---|
| 326 | + LOG("getVideoCursor:startQuery()");
|
---|
| 327 | + async.startQuery(0, null,
|
---|
| 328 | + MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
|
---|
| 329 | + mCols,
|
---|
| 330 | + where.toString(), null, mSortOrder);
|
---|
| 331 | + } else {
|
---|
| 332 | + ret = query(
|
---|
| 333 | + MediaStore.Video.Media.EXTERNAL_CONTENT_URI, mCols,
|
---|
| 334 | + where.toString(), null,mSortOrder);
|
---|
| 335 | + }
|
---|
| 336 | + LOG("ret/async = " + ret + "/" + async);
|
---|
| 337 | + if (ret != null && async != null) {
|
---|
| 338 | + LOG("getVideoCursor:initVideoCursor()");
|
---|
| 339 | + initVideoCursor(ret);
|
---|
| 340 | + }
|
---|
| 341 | + return ret;
|
---|
| 342 | + }
|
---|
| 343 | + public void initVideoCursor(Cursor newCursor){
|
---|
| 344 | + LOG("Enter initVideoCursor() and newCursor = " + newCursor);
|
---|
| 345 | + mVideoListAdapter.changeCursor(newCursor);
|
---|
| 346 | + LOG("mVideoCursor = " + mVideoCursor + "newCursor = " + newCursor);
|
---|
| 347 | + if (mVideoCursor == null){
|
---|
| 348 | + pd.dismiss();
|
---|
| 349 | + VideoDisplayVInVisible();
|
---|
| 350 | + mReScanHandler.sendEmptyMessageDelayed(0, 1000);//1000);
|
---|
| 351 | + return;
|
---|
| 352 | + }
|
---|
| 353 | + LOG("mVideoCursor.moveToFirst() = and mVideoCursor.getCount() = "
|
---|
| 354 | + + mVideoCursor.moveToFirst() + mVideoCursor.getCount());
|
---|
| 355 | + if(mVideoCursor.moveToFirst() == false || mVideoCursor.getCount() == 0){
|
---|
| 356 | + if(pd != null)
|
---|
| 357 | + pd.dismiss();
|
---|
| 358 | + VideoDisplayVInVisible();
|
---|
| 359 | + HintNoVideo();
|
---|
| 360 | + }else if (mVideoCursor.getCount() != 0){
|
---|
| 361 | + if(pd != null)
|
---|
| 362 | + pd.dismiss();
|
---|
| 363 | + //MainView.setBackgroundResource(R.drawable.textlistbak);
|
---|
| 364 | + sNoFileView.setVisibility(View.GONE);
|
---|
| 365 | + //RockVideoPlayer.this.getListView().setSelection(mLastPosition);
|
---|
| 366 | + }
|
---|
| 367 | + pd.dismiss();
|
---|
| 368 | + }
|
---|
| 369 | + public void HintNoVideo()
|
---|
| 370 | + {
|
---|
| 371 | + Toast.makeText(this, R.string.no_mediafiles, 1500).show();
|
---|
| 372 | + }
|
---|
| 373 | + private Handler mReScanHandler = new Handler() {
|
---|
| 374 | + @Override
|
---|
| 375 | + public void handleMessage(Message msg) {
|
---|
| 376 | + LOG("mReScanHandler mTrackCursor / mVideoListAdapter = " + mVideoCursor + " / " + mVideoListAdapter);
|
---|
| 377 | + getVideoCursor(mVideoListAdapter.getQueryHandler());
|
---|
| 378 | + }
|
---|
| 379 | + };
|
---|
| 380 | +
|
---|
| 381 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 382 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 383 | + return false;
|
---|
| 384 | + }
|
---|
| 385 | + return super.dispatchKeyEvent(event);
|
---|
| 386 | + }
|
---|
| 387 | + @Override
|
---|
| 388 | + protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
---|
| 389 | + if ((resultCode == RESULT_OK)
|
---|
| 390 | + && (data != null)) {
|
---|
| 391 | + mUri = data.getData();
|
---|
| 392 | + LOG("onActivityResult:mUri = " + mUri);
|
---|
| 393 | + }
|
---|
| 394 | + /*int result = DBUtils.FindPosition(this,mUri);
|
---|
| 395 | + if(result >= 0)
|
---|
| 396 | + mLastPosition = result;*/
|
---|
| 397 | + }
|
---|
| 398 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import java.io.BufferedWriter;
|
---|
| 7 | +import java.io.File;
|
---|
| 8 | +import java.io.FileOutputStream;
|
---|
| 9 | +import java.io.FileWriter;
|
---|
| 10 | +import java.io.IOException;
|
---|
| 11 | +import java.io.InputStream;
|
---|
| 12 | +import java.io.OutputStream;
|
---|
| 13 | +import java.util.Date;
|
---|
| 14 | +
|
---|
| 15 | +import android.R.integer;
|
---|
| 16 | +import android.app.Activity;
|
---|
| 17 | +import android.app.ActivityManager;
|
---|
| 18 | +import android.app.AlarmManager;
|
---|
| 19 | +import android.app.KeyguardManager;
|
---|
| 20 | +import android.app.PendingIntent;
|
---|
| 21 | +import android.app.KeyguardManager.KeyguardLock;
|
---|
| 22 | +import android.content.BroadcastReceiver;
|
---|
| 23 | +import android.content.Context;
|
---|
| 24 | +import android.content.Intent;
|
---|
| 25 | +import android.content.IntentFilter;
|
---|
| 26 | +import android.content.pm.ActivityInfo;
|
---|
| 27 | +import android.content.res.Configuration;
|
---|
| 28 | +import android.database.DataSetObserver;
|
---|
| 29 | +import android.media.MediaPlayer;
|
---|
| 30 | +import android.media.MediaPlayer.OnCompletionListener;
|
---|
| 31 | +import android.os.Bundle;
|
---|
| 32 | +import android.os.Handler;
|
---|
| 33 | +import android.os.Message;
|
---|
| 34 | +import android.os.PowerManager;
|
---|
| 35 | +import android.os.PowerManager.WakeLock;
|
---|
| 36 | +import android.os.SystemClock;
|
---|
| 37 | +import android.util.Log;
|
---|
| 38 | +import android.view.KeyEvent;
|
---|
| 39 | +import android.view.Surface;
|
---|
| 40 | +import android.view.View;
|
---|
| 41 | +import android.view.ViewGroup;
|
---|
| 42 | +import android.view.Window;
|
---|
| 43 | +import android.view.WindowManager;
|
---|
| 44 | +import android.widget.AdapterView;
|
---|
| 45 | +import android.widget.AdapterView.OnItemSelectedListener;
|
---|
| 46 | +import android.widget.ArrayAdapter;
|
---|
| 47 | +import android.widget.Button;
|
---|
| 48 | +import android.widget.MediaController;
|
---|
| 49 | +import android.widget.ProgressBar;
|
---|
| 50 | +import android.widget.Spinner;
|
---|
| 51 | +import android.widget.SpinnerAdapter;
|
---|
| 52 | +import android.widget.TextView;
|
---|
| 53 | +import android.widget.Toast;
|
---|
| 54 | +import android.widget.VideoView;
|
---|
| 55 | +
|
---|
| 56 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 57 | +import com.DeviceTest.helper.SystemUtil;
|
---|
| 58 | +import com.DeviceTest.helper.TestCase.RESULT;
|
---|
| 59 | +
|
---|
| 60 | +public class RuninTestActivity extends Activity {
|
---|
| 61 | +
|
---|
| 62 | + private static final String BATTERY_TEMP_PATH = "/sys/class/power_supply/*battery/temp";
|
---|
| 63 | + private static final String VIDEO_PATH = DeviceTest.EXTRA_PATH
|
---|
| 64 | + + "Earth.mp4";
|
---|
| 65 | +
|
---|
| 66 | + private static final int MSG_DO_TEST = 0;
|
---|
| 67 | + private static final int MSG_TEST_FAILED = 1;
|
---|
| 68 | + private static final int MSG_TEST_PASS = 2;
|
---|
| 69 | + private static final int MSG_STOP = 3;
|
---|
| 70 | + private static final int MSG_SLEEP_WAKE = 5;
|
---|
| 71 | +
|
---|
| 72 | + private static final int SLEEP_WAKE_COUNT = 10;
|
---|
| 73 | + private static final long VIDEO_TEST_TIME = 0;
|
---|
| 74 | + private static final int MEM_TEST_SIZE = 200;
|
---|
| 75 | +
|
---|
| 76 | + private static final int SLEEP_WAKE_DIST = 5 * 1000;
|
---|
| 77 | +
|
---|
| 78 | + private String sleepWakeCountString;
|
---|
| 79 | + private String videoTimeString;
|
---|
| 80 | + private String memSizeString;
|
---|
| 81 | +
|
---|
| 82 | + int sleepWakeCount = 0;
|
---|
| 83 | + long videoTime = 0;
|
---|
| 84 | +
|
---|
| 85 | + VideoView videoView;
|
---|
| 86 | + long videoStart = 0;
|
---|
| 87 | +
|
---|
| 88 | + private enum TEST_STEP {
|
---|
| 89 | + SLEEP_WAKE_TEST, MEM_TEST, VIDEO_TEST, BATTERY_TEMP_TEST
|
---|
| 90 | + }
|
---|
| 91 | +
|
---|
| 92 | + String memTestResult;
|
---|
| 93 | + private int mTestStep = 0;
|
---|
| 94 | + float batteryTemp = 0;
|
---|
| 95 | +
|
---|
| 96 | + private RESULT[] mTestResult;
|
---|
| 97 | + TextView[] mTextViews;
|
---|
| 98 | +
|
---|
| 99 | + Spinner sleepWakeCountSpinner, videoTimeSpinner, memSizeSpinner;
|
---|
| 100 | + String[] sleepWakeCountVal = { "Def(10)", "0", "1", "2", "5", "10", "20", };
|
---|
| 101 | + String[] memSizeVal = { "Def(200M)", "0", "1", "10", "100", "200", "250", };
|
---|
| 102 | + String[] videoTimeVal = { "Def(--m)", "0", "1", "10", "30", "60", "90",
|
---|
| 103 | + "120", "--" };
|
---|
| 104 | +
|
---|
| 105 | + PowerManager powerManager;
|
---|
| 106 | +
|
---|
| 107 | + ProgressBar progressBar;
|
---|
| 108 | + KeyguardManager keyguardManager;
|
---|
| 109 | + KeyguardLock keyguardLock;
|
---|
| 110 | + Button stopVideo;
|
---|
| 111 | +
|
---|
| 112 | + final String SLEEP_WAKE = "Sleep:";
|
---|
| 113 | +
|
---|
| 114 | + boolean videoStoped = false;
|
---|
| 115 | + protected WakeLock wakeLock;
|
---|
| 116 | + final String ACTION = "sleep_wake_action";
|
---|
| 117 | + AlarmManager alarmManager;
|
---|
| 118 | + PendingIntent pendingIntent;
|
---|
| 119 | + BroadcastReceiver receiver;
|
---|
| 120 | +
|
---|
| 121 | + public RuninTestActivity() {
|
---|
| 122 | + mTestResult = new RESULT[] { RESULT.UNDEF, RESULT.UNDEF, RESULT.UNDEF,
|
---|
| 123 | + RESULT.UNDEF, };
|
---|
| 124 | + mTextViews = new TextView[mTestResult.length];
|
---|
| 125 | + }
|
---|
| 126 | +
|
---|
| 127 | + protected void onCreate(Bundle paramBundle) {
|
---|
| 128 | + super.onCreate(paramBundle);
|
---|
| 129 | +
|
---|
| 130 | + setTitle(getTitle() + "----("
|
---|
| 131 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS)
|
---|
| 132 | + + ")");
|
---|
| 133 | + requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 134 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 135 | +
|
---|
| 136 | + setContentView(R.layout.runintest);
|
---|
| 137 | + mTextViews[0] = (TextView) findViewById(R.id.SleepWakeText);
|
---|
| 138 | + mTextViews[0].setText(SLEEP_WAKE);
|
---|
| 139 | + mTextViews[1] = (TextView) findViewById(R.id.MemText);
|
---|
| 140 | + mTextViews[1].setText("Mem:");
|
---|
| 141 | + mTextViews[2] = (TextView) findViewById(R.id.VideoText);
|
---|
| 142 | + mTextViews[2].setText("Video:");
|
---|
| 143 | + mTextViews[3] = (TextView) findViewById(R.id.BatteryTempText);
|
---|
| 144 | + mTextViews[3].setText("Temp:");
|
---|
| 145 | +
|
---|
| 146 | + progressBar = (ProgressBar) findViewById(R.id.progress);
|
---|
| 147 | + stopVideo = (Button) findViewById(R.id.StopVideo);
|
---|
| 148 | + stopVideo.setText("stop");
|
---|
| 149 | +
|
---|
| 150 | + videoView = (VideoView) findViewById(R.id.VideoView);
|
---|
| 151 | + videoView.setVideoPath(VIDEO_PATH);
|
---|
| 152 | + // videoView.setMediaController(new MediaController(this));
|
---|
| 153 | + videoView.setOnCompletionListener(new OnCompletionListener() {
|
---|
| 154 | +
|
---|
| 155 | + public void onCompletion(MediaPlayer mp) {
|
---|
| 156 | + videoView.setVideoPath(VIDEO_PATH);
|
---|
| 157 | + videoView.start();
|
---|
| 158 | + }
|
---|
| 159 | + });
|
---|
| 160 | +
|
---|
| 161 | + sleepWakeCountSpinner = (Spinner) findViewById(R.id.SleepWakeTimesSpinner);
|
---|
| 162 | + memSizeSpinner = (Spinner) findViewById(R.id.MemSizeSpinner);
|
---|
| 163 | + videoTimeSpinner = (Spinner) findViewById(R.id.VideoLengthSpinner);
|
---|
| 164 | +
|
---|
| 165 | + sleepWakeCountSpinner.setAdapter(new ArrayAdapter<String>(this,
|
---|
| 166 | + android.R.layout.simple_spinner_dropdown_item,
|
---|
| 167 | + sleepWakeCountVal));
|
---|
| 168 | + memSizeSpinner.setAdapter(new ArrayAdapter<String>(this,
|
---|
| 169 | + android.R.layout.simple_spinner_dropdown_item, memSizeVal));
|
---|
| 170 | + videoTimeSpinner.setAdapter(new ArrayAdapter<String>(this,
|
---|
| 171 | + android.R.layout.simple_spinner_dropdown_item, videoTimeVal));
|
---|
| 172 | +
|
---|
| 173 | + sleepWakeCountSpinner
|
---|
| 174 | + .setOnItemSelectedListener(new OnItemSelectedListener() {
|
---|
| 175 | +
|
---|
| 176 | + public void onItemSelected(AdapterView<?> parent,
|
---|
| 177 | + View view, int position, long id) {
|
---|
| 178 | + sleepWakeCountString = parent.getItemAtPosition(
|
---|
| 179 | + position).toString();
|
---|
| 180 | + }
|
---|
| 181 | +
|
---|
| 182 | + public void onNothingSelected(AdapterView<?> parent) {
|
---|
| 183 | +
|
---|
| 184 | + }
|
---|
| 185 | + });
|
---|
| 186 | + videoTimeSpinner
|
---|
| 187 | + .setOnItemSelectedListener(new OnItemSelectedListener() {
|
---|
| 188 | +
|
---|
| 189 | + public void onItemSelected(AdapterView<?> parent,
|
---|
| 190 | + View view, int position, long id) {
|
---|
| 191 | + videoTimeString = parent.getItemAtPosition(position)
|
---|
| 192 | + .toString();
|
---|
| 193 | + }
|
---|
| 194 | +
|
---|
| 195 | + public void onNothingSelected(AdapterView<?> parent) {
|
---|
| 196 | +
|
---|
| 197 | + }
|
---|
| 198 | + });
|
---|
| 199 | + memSizeSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
|
---|
| 200 | +
|
---|
| 201 | + public void onItemSelected(AdapterView<?> parent, View view,
|
---|
| 202 | + int position, long id) {
|
---|
| 203 | + memSizeString = parent.getItemAtPosition(position).toString();
|
---|
| 204 | + }
|
---|
| 205 | +
|
---|
| 206 | + public void onNothingSelected(AdapterView<?> parent) {
|
---|
| 207 | +
|
---|
| 208 | + }
|
---|
| 209 | + });
|
---|
| 210 | + final Button startButton = (Button) findViewById(R.id.TestStart);
|
---|
| 211 | + startButton.setText("Start Test");
|
---|
| 212 | + startButton.setOnClickListener(new View.OnClickListener() {
|
---|
| 213 | +
|
---|
| 214 | + public void onClick(View v) {
|
---|
| 215 | + if (startButton.getVisibility() != View.VISIBLE) {
|
---|
| 216 | + return;
|
---|
| 217 | + }
|
---|
| 218 | + mHandler.sendEmptyMessage(MSG_DO_TEST);
|
---|
| 219 | + startButton.setVisibility(View.GONE);
|
---|
| 220 | + sleepWakeCountSpinner.setEnabled(false);
|
---|
| 221 | + videoTimeSpinner.setEnabled(false);
|
---|
| 222 | + memSizeSpinner.setEnabled(false);
|
---|
| 223 | + }
|
---|
| 224 | + });
|
---|
| 225 | +
|
---|
| 226 | + stopVideo.setOnClickListener(new View.OnClickListener() {
|
---|
| 227 | +
|
---|
| 228 | + public void onClick(View v) {
|
---|
| 229 | + if (stopVideo.getVisibility() == View.INVISIBLE) {
|
---|
| 230 | + return;
|
---|
| 231 | + }
|
---|
| 232 | + stopVideo.setVisibility(View.INVISIBLE);
|
---|
| 233 | + videoStoped = true;
|
---|
| 234 | + videoTime = SystemClock.uptimeMillis() - videoStart;
|
---|
| 235 | + mHandler.sendEmptyMessage(MSG_STOP);
|
---|
| 236 | + }
|
---|
| 237 | + });
|
---|
| 238 | +
|
---|
| 239 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 240 | + findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 241 | + saveResult();
|
---|
| 242 | +
|
---|
| 243 | + powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
---|
| 244 | + wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK
|
---|
| 245 | + | PowerManager.ACQUIRE_CAUSES_WAKEUP
|
---|
| 246 | + | PowerManager.ON_AFTER_RELEASE, "jeffy_sleep_lock");
|
---|
| 247 | +
|
---|
| 248 | + keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
|
---|
| 249 | + keyguardLock = keyguardManager.newKeyguardLock("");
|
---|
| 250 | + keyguardLock.disableKeyguard();
|
---|
| 251 | +
|
---|
| 252 | + alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
|
---|
| 253 | + pendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION),
|
---|
| 254 | + PendingIntent.FLAG_CANCEL_CURRENT);
|
---|
| 255 | +
|
---|
| 256 | + receiver = new BroadcastReceiver() {
|
---|
| 257 | + boolean sleep = false;
|
---|
| 258 | + int count = 0;
|
---|
| 259 | +
|
---|
| 260 | + @Override
|
---|
| 261 | + public void onReceive(Context context, Intent intent) {
|
---|
| 262 | + if (!sleep) {
|
---|
| 263 | + // goto Sleep
|
---|
| 264 | +
|
---|
| 265 | + Log.i("Jeffy", "Sleep");
|
---|
| 266 | + if (wakeLock.isHeld()) {
|
---|
| 267 | + wakeLock.release();
|
---|
| 268 | + }
|
---|
| 269 | + powerManager.goToSleep(SystemClock.uptimeMillis());
|
---|
| 270 | + } else {
|
---|
| 271 | + // wake up
|
---|
| 272 | +
|
---|
| 273 | + count++;
|
---|
| 274 | + Log.i("Jeffy", "wake");
|
---|
| 275 | + if (!wakeLock.isHeld()) {
|
---|
| 276 | + wakeLock.acquire();
|
---|
| 277 | + } else {
|
---|
| 278 | + Log.e("Jeffy", "Run in, wake lock statue error");
|
---|
| 279 | + mTextViews[TEST_STEP.SLEEP_WAKE_TEST.ordinal()]
|
---|
| 280 | + .setText(SLEEP_WAKE);
|
---|
| 281 | + mHandler.sendEmptyMessage(MSG_TEST_FAILED);
|
---|
| 282 | + }
|
---|
| 283 | + if (sleepWakeCount > count) {
|
---|
| 284 | + mTextViews[TEST_STEP.SLEEP_WAKE_TEST.ordinal()]
|
---|
| 285 | + .setText(SLEEP_WAKE + count);
|
---|
| 286 | + } else {
|
---|
| 287 | + mTextViews[TEST_STEP.SLEEP_WAKE_TEST.ordinal()]
|
---|
| 288 | + .setText(SLEEP_WAKE);
|
---|
| 289 | + mHandler.sendEmptyMessage(MSG_TEST_PASS);
|
---|
| 290 | + return;
|
---|
| 291 | + }
|
---|
| 292 | + }
|
---|
| 293 | + sleep = !sleep;
|
---|
| 294 | +
|
---|
| 295 | + alarmManager.set(AlarmManager.RTC_WAKEUP,
|
---|
| 296 | + System.currentTimeMillis() + SLEEP_WAKE_DIST,
|
---|
| 297 | + pendingIntent);
|
---|
| 298 | + }
|
---|
| 299 | + };
|
---|
| 300 | +
|
---|
| 301 | + registerReceiver(receiver, new IntentFilter(ACTION));
|
---|
| 302 | + }
|
---|
| 303 | +
|
---|
| 304 | + Handler mHandler = new Handler() {
|
---|
| 305 | +
|
---|
| 306 | + public void handleMessage(Message msg) {
|
---|
| 307 | + mHandler.removeMessages(msg.what);
|
---|
| 308 | + boolean pass = false;
|
---|
| 309 | +
|
---|
| 310 | + switch (msg.what) {
|
---|
| 311 | + case MSG_DO_TEST:
|
---|
| 312 | + saveResult();
|
---|
| 313 | + if (mTestStep < TEST_STEP.values().length) {
|
---|
| 314 | + doTest();
|
---|
| 315 | + } else {
|
---|
| 316 | + endAllTest();
|
---|
| 317 | + }
|
---|
| 318 | + break;
|
---|
| 319 | + case MSG_STOP:
|
---|
| 320 | + stopTest();
|
---|
| 321 | + break;
|
---|
| 322 | + case MSG_TEST_PASS:
|
---|
| 323 | + case MSG_TEST_FAILED:
|
---|
| 324 | + if (mTestStep >= TEST_STEP.values().length) {
|
---|
| 325 | + return;
|
---|
| 326 | + }
|
---|
| 327 | + pass = msg.what == MSG_TEST_PASS;
|
---|
| 328 | + mTestResult[mTestStep] = pass ? RESULT.OK : RESULT.NG;
|
---|
| 329 | + String result = (pass ? "Pass" : "Failed");
|
---|
| 330 | + if (msg.obj != null) {
|
---|
| 331 | + result += "(" + msg.obj.toString() + ")";
|
---|
| 332 | + }
|
---|
| 333 | + mTextViews[mTestStep].setText(mTextViews[mTestStep].getText()
|
---|
| 334 | + + result);
|
---|
| 335 | + if (!isFinishing()) {
|
---|
| 336 | + mTestStep++;
|
---|
| 337 | + sendEmptyMessage(MSG_DO_TEST);
|
---|
| 338 | + }
|
---|
| 339 | + break;
|
---|
| 340 | +
|
---|
| 341 | + case MSG_SLEEP_WAKE:
|
---|
| 342 | + Runnable runnable = (Runnable) msg.obj;
|
---|
| 343 | + runnable.run();
|
---|
| 344 | + break;
|
---|
| 345 | + default:
|
---|
| 346 | + break;
|
---|
| 347 | + }
|
---|
| 348 | + }
|
---|
| 349 | + };
|
---|
| 350 | +
|
---|
| 351 | + private void doTest() {
|
---|
| 352 | + TEST_STEP step = TEST_STEP.values()[mTestStep];
|
---|
| 353 | + switch (step) {
|
---|
| 354 | + case SLEEP_WAKE_TEST:
|
---|
| 355 | + doSleepWakeTest();
|
---|
| 356 | + // mHandler.sendEmptyMessage(MSG_TEST_FAILED);
|
---|
| 357 | + break;
|
---|
| 358 | + case MEM_TEST:
|
---|
| 359 | + doMemTest();
|
---|
| 360 | + // mHandler.sendEmptyMessage(MSG_TEST_PASS);
|
---|
| 361 | + break;
|
---|
| 362 | + case VIDEO_TEST:
|
---|
| 363 | + doVideoTest();
|
---|
| 364 | + // mHandler.sendEmptyMessage(MSG_TEST_FAILED);
|
---|
| 365 | + break;
|
---|
| 366 | + case BATTERY_TEMP_TEST:
|
---|
| 367 | + doBatteryTempTest();
|
---|
| 368 | + default:
|
---|
| 369 | + break;
|
---|
| 370 | + }
|
---|
| 371 | + }
|
---|
| 372 | +
|
---|
| 373 | + private void doBatteryTempTest() {
|
---|
| 374 | + String temp = SystemUtil.execScriptCmd("cat " + BATTERY_TEMP_PATH,
|
---|
| 375 | + DeviceTest.TEMP_FILE_PATH, true);
|
---|
| 376 | +
|
---|
| 377 | + batteryTemp = Integer.parseInt(temp);
|
---|
| 378 | + batteryTemp /= 10;
|
---|
| 379 | + mHandler.sendMessage(mHandler.obtainMessage(
|
---|
| 380 | + batteryTemp < 40 ? MSG_TEST_PASS : MSG_TEST_FAILED, batteryTemp
|
---|
| 381 | + + "C"));
|
---|
| 382 | + }
|
---|
| 383 | +
|
---|
| 384 | + private void doSleepWakeTest() {
|
---|
| 385 | + sleepWakeCount = SLEEP_WAKE_COUNT;
|
---|
| 386 | + if (sleepWakeCountString != null) {
|
---|
| 387 | + try {
|
---|
| 388 | + sleepWakeCount = Integer.parseInt(sleepWakeCountString);
|
---|
| 389 | + } catch (Exception e) {
|
---|
| 390 | + }
|
---|
| 391 | + }
|
---|
| 392 | +
|
---|
| 393 | + if (sleepWakeCount == 0) {
|
---|
| 394 | + mHandler.sendEmptyMessage(MSG_TEST_PASS);
|
---|
| 395 | + return;
|
---|
| 396 | + }
|
---|
| 397 | + alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(),
|
---|
| 398 | + pendingIntent);
|
---|
| 399 | + }
|
---|
| 400 | +
|
---|
| 401 | + private void doVideoTest() {
|
---|
| 402 | + videoTime = VIDEO_TEST_TIME;
|
---|
| 403 | + if (this.videoTimeString != null) {
|
---|
| 404 | + try {
|
---|
| 405 | + videoTime = Integer.parseInt(this.videoTimeString) * 60 * 1000;
|
---|
| 406 | + if (videoTime == 0) {
|
---|
| 407 | + mHandler.sendEmptyMessage(MSG_TEST_PASS);
|
---|
| 408 | + return;
|
---|
| 409 | + }
|
---|
| 410 | + } catch (Exception e) {
|
---|
| 411 | + }
|
---|
| 412 | + }
|
---|
| 413 | +
|
---|
| 414 | + File file = new File(VIDEO_PATH);
|
---|
| 415 | + if (!file.exists() || !file.canRead()) {
|
---|
| 416 | + mHandler.sendEmptyMessage(MSG_TEST_FAILED);
|
---|
| 417 | + return;
|
---|
| 418 | + }
|
---|
| 419 | +
|
---|
| 420 | + ControlButtonUtil.Hide();
|
---|
| 421 | + stopVideo.setVisibility(View.VISIBLE);
|
---|
| 422 | + videoView.setVisibility(View.VISIBLE);
|
---|
| 423 | + videoView.bringToFront();
|
---|
| 424 | + videoView.start();
|
---|
| 425 | + videoStart = SystemClock.uptimeMillis();
|
---|
| 426 | + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
---|
| 427 | +
|
---|
| 428 | + if (videoTimeString.indexOf("--") < 0) {
|
---|
| 429 | + mHandler.sendEmptyMessageDelayed(MSG_STOP, videoTime);
|
---|
| 430 | + }
|
---|
| 431 | + }
|
---|
| 432 | +
|
---|
| 433 | + protected void endAllTest() {
|
---|
| 434 | + boolean pass = true;
|
---|
| 435 | + for (RESULT result : mTestResult) {
|
---|
| 436 | + if (result == RESULT.NG) {
|
---|
| 437 | + pass = false;
|
---|
| 438 | + break;
|
---|
| 439 | + }
|
---|
| 440 | + }
|
---|
| 441 | + // saveResult();
|
---|
| 442 | + if (pass) {
|
---|
| 443 | + // findViewById(R.id.btn_Pass).setVisibility(View.VISIBLE);
|
---|
| 444 | + findViewById(R.id.btn_Pass).performClick();
|
---|
| 445 | + // } else {
|
---|
| 446 | + // // findViewById(R.id.btn_Fail).performClick();
|
---|
| 447 | + // } else {
|
---|
| 448 | + // mHandler.postDelayed(new Runnable() {
|
---|
| 449 | + //
|
---|
| 450 | + // public void run() {
|
---|
| 451 | + // if (!isFinishing()) {
|
---|
| 452 | + // findViewById(R.id.btn_Fail).performClick();
|
---|
| 453 | + // }
|
---|
| 454 | + // }
|
---|
| 455 | + // }, DeviceTest.TEST_FAILED_DELAY);
|
---|
| 456 | + }
|
---|
| 457 | + }
|
---|
| 458 | +
|
---|
| 459 | + private void doMemTest() {
|
---|
| 460 | + if (! new File(DeviceTest.MEMTESTER_PATH).exists()) {
|
---|
| 461 | + mHandler.sendEmptyMessage(MSG_TEST_FAILED);
|
---|
| 462 | + return;
|
---|
| 463 | + }
|
---|
| 464 | + progressBar.setVisibility(View.VISIBLE);
|
---|
| 465 | + new Thread(new Runnable() {
|
---|
| 466 | +
|
---|
| 467 | + public void run() {
|
---|
| 468 | + String result = null;
|
---|
| 469 | + int memSize = MEM_TEST_SIZE;
|
---|
| 470 | +
|
---|
| 471 | + if (RuninTestActivity.this.memSizeString != null) {
|
---|
| 472 | + try {
|
---|
| 473 | + memSize = Integer
|
---|
| 474 | + .parseInt(RuninTestActivity.this.memSizeString);
|
---|
| 475 | + } catch (Exception e) {
|
---|
| 476 | + }
|
---|
| 477 | + }
|
---|
| 478 | +
|
---|
| 479 | + if (memSize == 0) {
|
---|
| 480 | + mHandler.post(new Runnable() {
|
---|
| 481 | + public void run() {
|
---|
| 482 | + progressBar.setVisibility(View.GONE);
|
---|
| 483 | + }
|
---|
| 484 | + });
|
---|
| 485 | + mHandler.sendEmptyMessage(MSG_TEST_PASS);
|
---|
| 486 | + return;
|
---|
| 487 | + }
|
---|
| 488 | + try {
|
---|
| 489 | + result = SystemUtil.execRootCmd(DeviceTest.MEMTESTER_PATH + " "
|
---|
| 490 | + + memSize + "M 1");
|
---|
| 491 | + mHandler.post(new Runnable() {
|
---|
| 492 | +
|
---|
| 493 | + public void run() {
|
---|
| 494 | + progressBar.setVisibility(View.GONE);
|
---|
| 495 | + }
|
---|
| 496 | + });
|
---|
| 497 | + result = "---------------------------\n"
|
---|
| 498 | + + result.substring(result.indexOf("want"));
|
---|
| 499 | +
|
---|
| 500 | + memTestResult = result;
|
---|
| 501 | + boolean pass = memTestResult.endsWith("Pass.");
|
---|
| 502 | + if (pass) {
|
---|
| 503 | + mHandler.sendEmptyMessage(MSG_TEST_PASS);
|
---|
| 504 | + } else {
|
---|
| 505 | + mHandler.sendEmptyMessage(MSG_TEST_FAILED);
|
---|
| 506 | + }
|
---|
| 507 | + } catch (Exception e) {
|
---|
| 508 | + mHandler.sendMessage(mHandler.obtainMessage(
|
---|
| 509 | + MSG_TEST_FAILED, e.getMessage()));
|
---|
| 510 | + }
|
---|
| 511 | + }
|
---|
| 512 | + }).start();
|
---|
| 513 | + }
|
---|
| 514 | +
|
---|
| 515 | + protected void stopTest() {
|
---|
| 516 | + if (mTestStep >= TEST_STEP.values().length) {
|
---|
| 517 | + return;
|
---|
| 518 | + }
|
---|
| 519 | + mTestResult[mTestStep] = RESULT.NG;
|
---|
| 520 | + TEST_STEP step = TEST_STEP.values()[mTestStep];
|
---|
| 521 | + switch (step) {
|
---|
| 522 | + case SLEEP_WAKE_TEST:
|
---|
| 523 | + stopSleepWakeTest();
|
---|
| 524 | + break;
|
---|
| 525 | + case MEM_TEST:
|
---|
| 526 | + stopMemTest();
|
---|
| 527 | + break;
|
---|
| 528 | + case VIDEO_TEST:
|
---|
| 529 | + stopVideoTest();
|
---|
| 530 | + break;
|
---|
| 531 | +
|
---|
| 532 | + default:
|
---|
| 533 | + break;
|
---|
| 534 | + }
|
---|
| 535 | + }
|
---|
| 536 | +
|
---|
| 537 | + private void stopSleepWakeTest() {
|
---|
| 538 | + mHandler.removeMessages(MSG_SLEEP_WAKE);
|
---|
| 539 | + mHandler.sendEmptyMessage(MSG_TEST_FAILED);
|
---|
| 540 | +
|
---|
| 541 | + alarmManager.cancel(pendingIntent);
|
---|
| 542 | + }
|
---|
| 543 | +
|
---|
| 544 | + private void stopVideoTest() {
|
---|
| 545 | + videoView.stopPlayback();
|
---|
| 546 | + ControlButtonUtil.Show();
|
---|
| 547 | + findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 548 | + stopVideo.setVisibility(View.GONE);
|
---|
| 549 | + videoView.setVisibility(View.GONE);
|
---|
| 550 | + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
---|
| 551 | + boolean pass = (SystemClock.uptimeMillis() - videoStart) >= this.videoTime;
|
---|
| 552 | +
|
---|
| 553 | + mHandler.sendEmptyMessage(pass ? MSG_TEST_PASS : MSG_TEST_FAILED);
|
---|
| 554 | + }
|
---|
| 555 | +
|
---|
| 556 | + //
|
---|
| 557 | + // public void onConfigurationChanged(Configuration newConfig) {
|
---|
| 558 | + // super.onConfigurationChanged(newConfig);
|
---|
| 559 | + // }
|
---|
| 560 | +
|
---|
| 561 | + private void stopMemTest() {
|
---|
| 562 | + SystemUtil.killProcessByPath(DeviceTest.MEMTESTER_PATH);
|
---|
| 563 | + }
|
---|
| 564 | +
|
---|
| 565 | + protected void onStop() {
|
---|
| 566 | + super.onStop();
|
---|
| 567 | + stopTest();
|
---|
| 568 | + keyguardLock.reenableKeyguard();
|
---|
| 569 | + unregisterReceiver(receiver);
|
---|
| 570 | + }
|
---|
| 571 | +
|
---|
| 572 | + public String getResult() {
|
---|
| 573 | +
|
---|
| 574 | + String result = DeviceTest.RESULT_INFO_HEAD_JUST_INFO;
|
---|
| 575 | + result += DeviceTest.formatResult("SleepWakeTest", mTestResult[0],
|
---|
| 576 | + DeviceTest.RESULT_INFO_HEAD + sleepWakeCount) + "\n";
|
---|
| 577 | + result += DeviceTest.formatResult("MemTest", mTestResult[1], null)
|
---|
| 578 | + + "\n";
|
---|
| 579 | + result += DeviceTest.formatResult("VideoTest", mTestResult[2],
|
---|
| 580 | + DeviceTest.RESULT_INFO_HEAD + (videoTime / 1000 / 60) + "Min")
|
---|
| 581 | + + "\n";
|
---|
| 582 | + result += DeviceTest.formatResult("BatteryTemp", mTestResult[3],
|
---|
| 583 | + DeviceTest.RESULT_INFO_HEAD + batteryTemp + "C") + "\n";
|
---|
| 584 | +
|
---|
| 585 | + return result;
|
---|
| 586 | + }
|
---|
| 587 | +
|
---|
| 588 | + private void saveResult() {
|
---|
| 589 | + ControlButtonUtil.setResult(getResult());
|
---|
| 590 | + }
|
---|
| 591 | +
|
---|
| 592 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 593 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 594 | + return false;
|
---|
| 595 | + }
|
---|
| 596 | + return super.dispatchKeyEvent(event);
|
---|
| 597 | + }
|
---|
| 598 | +
|
---|
| 599 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | + |
---|
| 3 | +public class SATATestActivity extends UsbHostTestActivity { |
---|
| 4 | + |
---|
| 5 | + @Override |
---|
| 6 | + protected void preData() { |
---|
| 7 | + mStorageType = STORAGE_TYPE.SATA; |
---|
| 8 | + } |
---|
| 9 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | + |
---|
| 3 | +import java.io.BufferedReader; |
---|
| 4 | +import java.io.File; |
---|
| 5 | +import java.io.FileInputStream; |
---|
| 6 | +import java.io.FileOutputStream; |
---|
| 7 | +import java.io.IOException; |
---|
| 8 | +import java.io.InputStreamReader; |
---|
| 9 | +import java.io.OutputStreamWriter; |
---|
| 10 | +import java.math.BigInteger; |
---|
| 11 | + |
---|
| 12 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 13 | + |
---|
| 14 | +import android.app.Activity; |
---|
| 15 | +import android.content.BroadcastReceiver; |
---|
| 16 | +import android.content.Context; |
---|
| 17 | +import android.content.Intent; |
---|
| 18 | +import android.content.IntentFilter; |
---|
| 19 | +import android.os.Bundle; |
---|
| 20 | +import android.os.Environment; |
---|
| 21 | +import android.os.Handler; |
---|
| 22 | +import android.os.ServiceManager; |
---|
| 23 | +import android.os.StatFs; |
---|
| 24 | +import android.view.View; |
---|
| 25 | +import android.view.Window; |
---|
| 26 | +import android.widget.Button; |
---|
| 27 | +import android.widget.TextView; |
---|
| 28 | +import android.os.SystemProperties; |
---|
| 29 | +import android.text.format.Formatter; |
---|
| 30 | +import android.util.Log; |
---|
| 31 | +//import android.os.storage.IMountService; |
---|
| 32 | +import android.os.storage.StorageManager; |
---|
| 33 | +import android.os.storage.StorageVolume; |
---|
| 34 | +import android.os.storage.StorageEventListener; |
---|
| 35 | +import java.lang.reflect.Array; |
---|
| 36 | +import java.lang.reflect.InvocationTargetException; |
---|
| 37 | +import java.lang.reflect.Method; |
---|
| 38 | +import android.os.storage.VolumeInfo; |
---|
| 39 | +import java.util.Collections; |
---|
| 40 | +import android.os.storage.DiskInfo; |
---|
| 41 | +import java.util.List; |
---|
| 42 | + |
---|
| 43 | + |
---|
| 44 | +public class SdCardTestActivity extends Activity { |
---|
| 45 | + private static final String TAG = "SdCardTestActivity"; |
---|
| 46 | + private static final String TEST_STRING = "Rockchip UsbHostTest File"; |
---|
| 47 | + private static String SDCARD_PATH ; |
---|
| 48 | +// private static final String SDCARD_PATH = "/mnt/external_sd"; |
---|
| 49 | +// private final static String SDCARD_PATH = "/storage/sdcard1"; |
---|
| 50 | + private static final int BACK_TIME = 2000; |
---|
| 51 | + private static final int SEND_REND_WRITE_SD = 3; |
---|
| 52 | + private static final int R_PASS = 1; |
---|
| 53 | + private static final int R_FAIL = 2; |
---|
| 54 | + private String sdcard_path = null; |
---|
| 55 | + private StringBuilder sBuilder; |
---|
| 56 | + // private SdcardReceiver sdcardReceiver = null; |
---|
| 57 | + public String SUCCESS; |
---|
| 58 | + public String FAIL; |
---|
| 59 | + private boolean isFindSd = false; |
---|
| 60 | + private static StorageManager mStorageManager = null; |
---|
| 61 | + private static boolean is_Usb=false; |
---|
| 62 | + TextView mResult; |
---|
| 63 | + private static boolean isSDFirstTest =true; |
---|
| 64 | + public static String flash_dir = Environment.getExternalStorageDirectory().getPath(); |
---|
| 65 | + private static String sdcard_dir; |
---|
| 66 | + |
---|
| 67 | + @Override |
---|
| 68 | + protected void onCreate(Bundle savedInstanceState) { |
---|
| 69 | + |
---|
| 70 | + super.onCreate(savedInstanceState); |
---|
| 71 | + |
---|
| 72 | + // requestWindowFeature(Window.FEATURE_NO_TITLE); |
---|
| 73 | + // getWindow().addFlags(1152); |
---|
| 74 | + setContentView(R.layout.sdcardtest); |
---|
| 75 | + isSDFirstTest =true; |
---|
| 76 | + if (mStorageManager == null) { |
---|
| 77 | + mStorageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE); |
---|
| 78 | + } |
---|
| 79 | + this.mResult = (TextView) findViewById(R.id.sdresultText); |
---|
| 80 | + this.mResult.setVisibility(View.VISIBLE); |
---|
| 81 | + this.mResult.setGravity(17); |
---|
| 82 | + |
---|
| 83 | + ControlButtonUtil.initControlButtonView(this); |
---|
| 84 | + findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE); |
---|
| 85 | + findViewById(R.id.btn_Fail).setVisibility(View.INVISIBLE); |
---|
| 86 | + SUCCESS = getString(R.string.success); |
---|
| 87 | + FAIL = getString(R.string.fail); |
---|
| 88 | + |
---|
| 89 | + } |
---|
| 90 | + |
---|
| 91 | + @Override |
---|
| 92 | + protected void onResume() { |
---|
| 93 | + super.onResume(); |
---|
| 94 | + init_StoragePath(this); |
---|
| 95 | + // mStorageManager.registerListener(mStorageListener); |
---|
| 96 | + StorageVolume[] storageVolumes = mStorageManager.getVolumeList(); |
---|
| 97 | + Log.d(TAG, " storageVolumes.length= " + storageVolumes.length); |
---|
| 98 | + for(int i=0;i< storageVolumes.length;i++) |
---|
| 99 | + { |
---|
| 100 | + Log.d(TAG, " storageVolumes["+i+"].getPath()=" +storageVolumes[i].getPath()); |
---|
| 101 | + } |
---|
| 102 | + /*if(storageVolumes.length >= 2){ |
---|
| 103 | + sdcard_path = storageVolumes[1].getPath();*/ |
---|
| 104 | + |
---|
| 105 | + //SDCARD_PATH=sdcard_path; |
---|
| 106 | + //Log.d(TAG, " storageVolumes[1].getPath()= " + SDCARD_PATH + " "+","+ Environment.getExternalStorageDirectory()); |
---|
| 107 | + //Log.d(TAG, " storageVolumes[0].getPath()= " + storageVolumes[0].getPath()); |
---|
| 108 | + //} |
---|
| 109 | + sBuilder = new StringBuilder(); |
---|
| 110 | + //String sdState = getSdCardState(); |
---|
| 111 | + if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { |
---|
| 112 | + isFindSd=true; |
---|
| 113 | + |
---|
| 114 | + mResult.setText(getString(R.string.resume_findSD)); |
---|
| 115 | + mHandler.sendEmptyMessageDelayed(SEND_REND_WRITE_SD, 1000); |
---|
| 116 | + } |
---|
| 117 | + } |
---|
| 118 | + |
---|
| 119 | + @Override |
---|
| 120 | + protected void onPause() { |
---|
| 121 | + super.onPause(); |
---|
| 122 | + if (mStorageManager != null) { |
---|
| 123 | + // mStorageManager.unregisterListener(mStorageListener); |
---|
| 124 | + } |
---|
| 125 | + } |
---|
| 126 | + |
---|
| 127 | + |
---|
| 128 | + public void testSdcard() { |
---|
| 129 | + try { |
---|
| 130 | + if (SDCARD_PATH==null) |
---|
| 131 | + { |
---|
| 132 | + sBuilder.append(getString(R.string.SdCardFail)).append("\n"); |
---|
| 133 | + mResult.setText(sBuilder.toString()); |
---|
| 134 | + mHandler.sendEmptyMessageDelayed(R_FAIL, 3000); |
---|
| 135 | + isFindSd = false; |
---|
| 136 | + return; |
---|
| 137 | + } |
---|
| 138 | + // String externalVolumeState = mStorageManager.getVolumeState(SDCARD_PATH); |
---|
| 139 | + //if (!externalVolumeState.equals(Environment.MEDIA_MOUNTED)) { |
---|
| 140 | + // sBuilder.append(getString(R.string.SdCardFail)).append("\n"); |
---|
| 141 | + //mResult.setText(sBuilder.toString()); |
---|
| 142 | + //mHandler.sendEmptyMessageDelayed(R_FAIL, 3000); |
---|
| 143 | + //isFindSd = false; |
---|
| 144 | + //return; |
---|
| 145 | + // } |
---|
| 146 | + } catch (Exception rex) { |
---|
| 147 | + |
---|
| 148 | + rex.printStackTrace(); |
---|
| 149 | + isFindSd = false; |
---|
| 150 | + mHandler.sendEmptyMessageDelayed(R_FAIL, 3000); |
---|
| 151 | + return; |
---|
| 152 | + } |
---|
| 153 | + |
---|
| 154 | + File pathFile = new File(SDCARD_PATH); |
---|
| 155 | + Log.d(TAG, "pathFile = " + pathFile.toString()); |
---|
| 156 | + if (!pathFile.exists()) { |
---|
| 157 | + sBuilder.append(getString(R.string.SdCardFail)).append("\n"); |
---|
| 158 | + mResult.setText(sBuilder.toString()); |
---|
| 159 | + mHandler.sendEmptyMessageDelayed(R_FAIL, 3000); |
---|
| 160 | + isFindSd = false; |
---|
| 161 | + return; |
---|
| 162 | + } |
---|
| 163 | + StatFs stat = new StatFs(pathFile.getPath()); |
---|
| 164 | + Log.d(TAG, "StatFs "); |
---|
| 165 | + long blockSize = stat.getBlockSize(); |
---|
| 166 | + long totalBlocks = stat.getBlockCount(); |
---|
| 167 | + String totalSize = Formatter.formatFileSize(this, totalBlocks |
---|
| 168 | + * blockSize); |
---|
| 169 | + if ("0.00 B".equals(totalSize)) { |
---|
| 170 | + sBuilder.append(getString(R.string.SdCardFail)).append("\n"); |
---|
| 171 | + mResult.setText(sBuilder.toString()); |
---|
| 172 | + mHandler.sendEmptyMessageDelayed(R_FAIL, 3000); |
---|
| 173 | + isFindSd = false; |
---|
| 174 | + return; |
---|
| 175 | + } |
---|
| 176 | + String prix = getString(R.string.SdCardFind); |
---|
| 177 | + sBuilder.append(prix + totalSize).append("\n"); |
---|
| 178 | + try { |
---|
| 179 | + Thread.sleep(2000); |
---|
| 180 | + } catch (InterruptedException e) { |
---|
| 181 | + e.printStackTrace(); |
---|
| 182 | + } |
---|
| 183 | + Log.d(TAG, "testReadAndWrite " + isFindSd); |
---|
| 184 | + testReadAndWrite(); |
---|
| 185 | + |
---|
| 186 | + } |
---|
| 187 | + |
---|
| 188 | + public void testReadAndWrite() { |
---|
| 189 | + if (isFindSd && dotestReadAndWrite()) { |
---|
| 190 | + sBuilder.append(getString(R.string.SdCardTitle) + SUCCESS); |
---|
| 191 | + ((Button)findViewById(R.id.btn_Skip)).setClickable(false); |
---|
| 192 | + //((Button)findViewById(R.id.btn_Pass)).setClickable(false); |
---|
| 193 | + ((Button)findViewById(R.id.btn_Fail)).setClickable(false); |
---|
| 194 | + mHandler.sendEmptyMessageDelayed(R_PASS, BACK_TIME); |
---|
| 195 | + } else { |
---|
| 196 | + sBuilder.append(getString(R.string.SdCardTitle) + FAIL); |
---|
| 197 | + ((Button)findViewById(R.id.btn_Skip)).setClickable(false); |
---|
| 198 | + ((Button)findViewById(R.id.btn_Pass)).setClickable(false); |
---|
| 199 | + //((Button)findViewById(R.id.btn_Fail)).setClickable(false); |
---|
| 200 | + mHandler.sendEmptyMessageDelayed(R_FAIL, BACK_TIME); |
---|
| 201 | + } |
---|
| 202 | + |
---|
| 203 | + mResult.setText(sBuilder.toString()); |
---|
| 204 | + } |
---|
| 205 | + |
---|
| 206 | + private boolean dotestReadAndWrite() { |
---|
| 207 | + // String directoryName = Environment.getExternalStorageDirectory().toString()+ "/test"; |
---|
| 208 | + String directoryName = SDCARD_PATH+ "/test"; |
---|
| 209 | + Log.d(TAG, "dotestReadAndWrite: " + directoryName); |
---|
| 210 | + File directory = new File(directoryName); |
---|
| 211 | + if (!directory.isDirectory()) { |
---|
| 212 | + if (!directory.mkdirs()) { |
---|
| 213 | + sBuilder.append(getString(R.string.MakeDir) + FAIL).append("\n"); |
---|
| 214 | + return false; |
---|
| 215 | + } else { |
---|
| 216 | + sBuilder.append(getString(R.string.MakeDir) + SUCCESS).append( |
---|
| 217 | + "\n"); |
---|
| 218 | + } |
---|
| 219 | + } |
---|
| 220 | + File f = new File(directoryName, "SDCard.txt"); |
---|
| 221 | + try { |
---|
| 222 | + // Remove stale file if any |
---|
| 223 | + if (f.exists()) { |
---|
| 224 | + f.delete(); |
---|
| 225 | + } |
---|
| 226 | + if (!f.createNewFile()) { |
---|
| 227 | + sBuilder.append(getString(R.string.CreateFile) + FAIL).append( |
---|
| 228 | + "\n"); |
---|
| 229 | + return false; |
---|
| 230 | + } else { |
---|
| 231 | + sBuilder.append(getString(R.string.CreateFile) + SUCCESS).append( |
---|
| 232 | + "\n"); |
---|
| 233 | + |
---|
| 234 | + doWriteFile(f.getAbsoluteFile().toString()); |
---|
| 235 | + |
---|
| 236 | + if (doReadFile(f.getAbsoluteFile().toString()).equals( |
---|
| 237 | + TEST_STRING)) { |
---|
| 238 | + sBuilder.append(getString(R.string.Compare)).append(SUCCESS).append( |
---|
| 239 | + "\n"); |
---|
| 240 | + } else { |
---|
| 241 | + sBuilder.append(getString(R.string.Compare)).append(FAIL).append( |
---|
| 242 | + "\n"); |
---|
| 243 | + return false; |
---|
| 244 | + } |
---|
| 245 | + } |
---|
| 246 | + |
---|
| 247 | + sBuilder.append(getString(R.string.FileDel)).append( |
---|
| 248 | + (f.delete() ? SUCCESS : FAIL)).append("\n"); |
---|
| 249 | + sBuilder.append(getString(R.string.DirDel)).append( |
---|
| 250 | + (directory.delete() ? SUCCESS : FAIL)).append("\n"); |
---|
| 251 | + return true; |
---|
| 252 | + } catch (IOException ex) { |
---|
| 253 | + Log.e(TAG, "isWritable : false (IOException)!"); |
---|
| 254 | + return false; |
---|
| 255 | + } |
---|
| 256 | + } |
---|
| 257 | + |
---|
| 258 | + public void doWriteFile(String filename) { |
---|
| 259 | + try { |
---|
| 260 | + sBuilder.append(getString(R.string.WriteData)).append("\n"); |
---|
| 261 | + OutputStreamWriter osw = new OutputStreamWriter( |
---|
| 262 | + new FileOutputStream( |
---|
| 263 | + filename)); |
---|
| 264 | + osw.write(TEST_STRING, 0, TEST_STRING.length()); |
---|
| 265 | + osw.flush(); |
---|
| 266 | + osw.close(); |
---|
| 267 | + } catch (IOException e) { |
---|
| 268 | + e.printStackTrace(); |
---|
| 269 | + } |
---|
| 270 | + } |
---|
| 271 | + |
---|
| 272 | + public String doReadFile(String filename) { |
---|
| 273 | + try { |
---|
| 274 | + BufferedReader br = new BufferedReader(new InputStreamReader |
---|
| 275 | + (new FileInputStream(filename))); |
---|
| 276 | + String data = null; |
---|
| 277 | + StringBuilder temp = new StringBuilder(); |
---|
| 278 | + sBuilder.append(getString(R.string.ReadData)).append("\n"); |
---|
| 279 | + while ((data = br.readLine()) != null) { |
---|
| 280 | + temp.append(data); |
---|
| 281 | + } |
---|
| 282 | + br.close(); |
---|
| 283 | + Log.e(TAG, "Readfile " + temp.toString()); |
---|
| 284 | + return temp.toString(); |
---|
| 285 | + } catch (Exception e) { |
---|
| 286 | + e.printStackTrace(); |
---|
| 287 | + return null; |
---|
| 288 | + } |
---|
| 289 | + } |
---|
| 290 | + |
---|
| 291 | + /* |
---|
| 292 | + public class SdcardReceiver extends BroadcastReceiver { |
---|
| 293 | + @Override |
---|
| 294 | + public void onReceive(Context context, Intent intent) { |
---|
| 295 | + Log.e(TAG, "onReveive ..... " + intent.getAction()); |
---|
| 296 | + if (intent.getAction().equals(Intent.ACTION_MEDIA_MOUNTED)) { |
---|
| 297 | + Log.e(TAG, "239 ..... " + intent.getAction()); |
---|
| 298 | + testSdcard(); |
---|
| 299 | + testReadAndWrite(); |
---|
| 300 | + } |
---|
| 301 | + } |
---|
| 302 | + } |
---|
| 303 | + */ |
---|
| 304 | +/*StorageEventListener mStorageListener = new StorageEventListener() { |
---|
| 305 | + @Override |
---|
| 306 | + public void onStorageStateChanged(String path, String oldState, String newState) { |
---|
| 307 | + Log.d("xxxxxxxxxxxxxxxxxxxxxxxxxxxx","yyyyyyyyyyyyyyyyyyyyyyyyyyyy"); |
---|
| 308 | + if (path.equals(SDCARD_PATH) && newState.equals(Environment.MEDIA_MOUNTED)) { |
---|
| 309 | + isFindSd=true; |
---|
| 310 | + |
---|
| 311 | + mResult.setText(getString(R.string.resume_findSD)); |
---|
| 312 | + mHandler.sendEmptyMessageDelayed(SEND_REND_WRITE_SD, 100); |
---|
| 313 | + testReadAndWrite(); |
---|
| 314 | + } |
---|
| 315 | + } |
---|
| 316 | + };*/ |
---|
| 317 | + |
---|
| 318 | + public void TestResult(int result) { |
---|
| 319 | + if (result == R_PASS) { |
---|
| 320 | + if(isSDFirstTest){ |
---|
| 321 | + isSDFirstTest=false; |
---|
| 322 | + ((Button) findViewById(R.id.btn_Pass)).performClick(); |
---|
| 323 | + isFindSd = false; |
---|
| 324 | + } |
---|
| 325 | + |
---|
| 326 | + } else if (result == R_FAIL) { |
---|
| 327 | + if(isSDFirstTest){ |
---|
| 328 | + isSDFirstTest=false; |
---|
| 329 | + ((Button) findViewById(R.id.btn_Fail)).performClick(); |
---|
| 330 | + isFindSd = false; |
---|
| 331 | + } |
---|
| 332 | + } |
---|
| 333 | + } |
---|
| 334 | + |
---|
| 335 | + Handler mHandler = new Handler() { |
---|
| 336 | + public void handleMessage(android.os.Message msg) { |
---|
| 337 | + switch (msg.what) { |
---|
| 338 | + case R_PASS: |
---|
| 339 | + TestResult(R_PASS); |
---|
| 340 | + break; |
---|
| 341 | + case R_FAIL: |
---|
| 342 | + TestResult(R_FAIL); |
---|
| 343 | + break; |
---|
| 344 | + |
---|
| 345 | + case SEND_REND_WRITE_SD: |
---|
| 346 | + |
---|
| 347 | + testSdcard(); |
---|
| 348 | + break; |
---|
| 349 | + |
---|
| 350 | + } |
---|
| 351 | + }; |
---|
| 352 | + }; |
---|
| 353 | + /* |
---|
| 354 | + public static String getSdCardState() { |
---|
| 355 | + try { |
---|
| 356 | + IMountService mMntSvc = null; |
---|
| 357 | + if (mMntSvc == null) { |
---|
| 358 | + mMntSvc = IMountService.Stub.asInterface(ServiceManager |
---|
| 359 | + .getService("mount")); |
---|
| 360 | + } |
---|
| 361 | + return mMntSvc.getVolumeState(SDCARD_PATH); |
---|
| 362 | + } catch (Exception rex) { |
---|
| 363 | + return Environment.MEDIA_REMOVED; |
---|
| 364 | + } |
---|
| 365 | + |
---|
| 366 | + }*/ |
---|
| 367 | + //获取外置sd卡路径 |
---|
| 368 | + private static String getStoragePath(Context mContext, boolean is_removale) { |
---|
| 369 | + |
---|
| 370 | + mStorageManager = (StorageManager) mContext.getSystemService(Context.STORAGE_SERVICE); |
---|
| 371 | + Class<?> storageVolumeClazz = null; |
---|
| 372 | + try { |
---|
| 373 | + storageVolumeClazz = Class.forName("android.os.storage.StorageVolume"); |
---|
| 374 | + Method getVolumeList = mStorageManager.getClass().getMethod("getVolumeList"); |
---|
| 375 | + Method getPath = storageVolumeClazz.getMethod("getPath"); |
---|
| 376 | + Method isRemovable = storageVolumeClazz.getMethod("isRemovable"); |
---|
| 377 | + Object result = getVolumeList.invoke(mStorageManager); |
---|
| 378 | + final int length = Array.getLength(result); |
---|
| 379 | + for (int i = 0; i < length; i++) { |
---|
| 380 | + Object storageVolumeElement = Array.get(result, i); |
---|
| 381 | + String path = (String) getPath.invoke(storageVolumeElement); |
---|
| 382 | + boolean removable = (Boolean) isRemovable.invoke(storageVolumeElement); |
---|
| 383 | + if (is_removale == removable) { |
---|
| 384 | + return path; |
---|
| 385 | + } |
---|
| 386 | + } |
---|
| 387 | + } catch (ClassNotFoundException e) { |
---|
| 388 | + e.printStackTrace(); |
---|
| 389 | + } catch (InvocationTargetException e) { |
---|
| 390 | + e.printStackTrace(); |
---|
| 391 | + } catch (NoSuchMethodException e) { |
---|
| 392 | + e.printStackTrace(); |
---|
| 393 | + } catch (IllegalAccessException e) { |
---|
| 394 | + e.printStackTrace(); |
---|
| 395 | + } |
---|
| 396 | + return null; |
---|
| 397 | + } |
---|
| 398 | + public void init_StoragePath(Context context) { |
---|
| 399 | + // flash dir |
---|
| 400 | + |
---|
| 401 | + mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE); |
---|
| 402 | + flash_dir = Environment.getExternalStorageDirectory().getPath(); |
---|
| 403 | + final List<VolumeInfo> volumes = mStorageManager.getVolumes(); |
---|
| 404 | + Collections.sort(volumes, VolumeInfo.getDescriptionComparator()); |
---|
| 405 | + for (VolumeInfo vol : volumes) { |
---|
| 406 | + if (vol.getType() == VolumeInfo.TYPE_PUBLIC) { |
---|
| 407 | + Log.d(TAG, "Volume path:" + vol.getPath()); |
---|
| 408 | + DiskInfo disk = vol.getDisk(); |
---|
| 409 | + if (disk != null) { |
---|
| 410 | + if (disk.isSd()) { |
---|
| 411 | + // sdcard dir |
---|
| 412 | + StorageVolume sv = vol.buildStorageVolume(context, |
---|
| 413 | + context.getUserId(), false); |
---|
| 414 | + sdcard_dir = sv.getPath(); |
---|
| 415 | + } else if (disk.isUsb()) { |
---|
| 416 | + // usb dir |
---|
| 417 | + } |
---|
| 418 | + } |
---|
| 419 | + } |
---|
| 420 | + } |
---|
| 421 | + |
---|
| 422 | + SDCARD_PATH = sdcard_dir; |
---|
| 423 | + Log.d(TAG, "sdcard_dir: " + sdcard_dir); |
---|
| 424 | + } |
---|
| 425 | +//判断sd卡是否挂载 |
---|
| 426 | +private boolean isSDMounted() { |
---|
| 427 | + boolean isMounted = false; |
---|
| 428 | + StorageManager sm = (StorageManager) getSystemService(Context.STORAGE_SERVICE); |
---|
| 429 | + |
---|
| 430 | + try { |
---|
| 431 | + Method getVolumList = StorageManager.class.getMethod("getVolumeList", null); |
---|
| 432 | + getVolumList.setAccessible(true); |
---|
| 433 | + Object[] results = (Object[])getVolumList.invoke(sm, null); |
---|
| 434 | + if (results != null) { |
---|
| 435 | + for (Object result : results) { |
---|
| 436 | + Method mRemoveable = result.getClass().getMethod("isRemovable", null); |
---|
| 437 | + Boolean isRemovable = (Boolean) mRemoveable.invoke(result, null); |
---|
| 438 | + if (isRemovable) { |
---|
| 439 | + Method getPath = result.getClass().getMethod("getPath", null); |
---|
| 440 | + String path = (String) mRemoveable.invoke(result, null); |
---|
| 441 | + Method getState = sm.getClass().getMethod("getVolumeState", String.class); |
---|
| 442 | + String state = (String)getState.invoke(sm, path); |
---|
| 443 | + if (state.equals(Environment.MEDIA_MOUNTED)) { |
---|
| 444 | + isMounted = true; |
---|
| 445 | + break; |
---|
| 446 | + } |
---|
| 447 | + } |
---|
| 448 | + } |
---|
| 449 | + } |
---|
| 450 | + } catch (NoSuchMethodException e){ |
---|
| 451 | + e.printStackTrace(); |
---|
| 452 | + } catch (IllegalAccessException e){ |
---|
| 453 | + e.printStackTrace(); |
---|
| 454 | + } catch (InvocationTargetException e) { |
---|
| 455 | + e.printStackTrace(); |
---|
| 456 | + } |
---|
| 457 | + |
---|
| 458 | + return isMounted; |
---|
| 459 | + } |
---|
| 460 | + |
---|
| 461 | + |
---|
| 462 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import java.io.File;
|
---|
| 7 | +import java.math.BigInteger;
|
---|
| 8 | +
|
---|
| 9 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 10 | +
|
---|
| 11 | +import android.app.Activity;
|
---|
| 12 | +import android.content.Context;
|
---|
| 13 | +import android.os.Bundle;
|
---|
| 14 | +import android.os.Environment;
|
---|
| 15 | +import android.os.StatFs;
|
---|
| 16 | +import android.view.KeyEvent;
|
---|
| 17 | +import android.view.View;
|
---|
| 18 | +import android.view.Window;
|
---|
| 19 | +import android.widget.TextView;
|
---|
| 20 | +
|
---|
| 21 | +import android.telephony.TelephonyManager;
|
---|
| 22 | +import android.util.Log;
|
---|
| 23 | +
|
---|
| 24 | +public class SimCardTestActivity extends Activity {
|
---|
| 25 | + private static final String TAG = "SdCardTestActivity";
|
---|
| 26 | +
|
---|
| 27 | + TextView mResult;
|
---|
| 28 | +
|
---|
| 29 | +
|
---|
| 30 | + protected void onCreate(Bundle savedInstanceState) {
|
---|
| 31 | +
|
---|
| 32 | + super.onCreate(savedInstanceState);
|
---|
| 33 | +
|
---|
| 34 | +
|
---|
| 35 | + setTitle(getTitle() + "----("
|
---|
| 36 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")");
|
---|
| 37 | + //requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 38 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 39 | +
|
---|
| 40 | + setContentView(R.layout.simcardtest);
|
---|
| 41 | +
|
---|
| 42 | + this.mResult = (TextView) findViewById(R.id.text);
|
---|
| 43 | + this.mResult.setVisibility(View.VISIBLE);
|
---|
| 44 | + this.mResult.setGravity(17);
|
---|
| 45 | +
|
---|
| 46 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 47 | + }
|
---|
| 48 | +
|
---|
| 49 | +
|
---|
| 50 | + protected void onResume() {
|
---|
| 51 | + super.onResume();
|
---|
| 52 | + TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
---|
| 53 | + String imsi = mTelephonyMgr.getSubscriberId();
|
---|
| 54 | +
|
---|
| 55 | + if (imsi == null) {
|
---|
| 56 | + mResult.setText("Cann't get IMSI!");
|
---|
| 57 | + } else {
|
---|
| 58 | + mResult.setText("IMSI:" + imsi);
|
---|
| 59 | + }
|
---|
| 60 | + }
|
---|
| 61 | +
|
---|
| 62 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 63 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 64 | + return false;
|
---|
| 65 | + }
|
---|
| 66 | + return super.dispatchKeyEvent(event);
|
---|
| 67 | + }
|
---|
| 68 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | + |
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN; |
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; |
---|
| 5 | + |
---|
| 6 | +import java.io.FileDescriptor; |
---|
| 7 | +import java.io.IOException; |
---|
| 8 | + |
---|
| 9 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 10 | + |
---|
| 11 | +import android.app.Activity; |
---|
| 12 | +import android.content.Intent; |
---|
| 13 | +import android.content.res.AssetFileDescriptor; |
---|
| 14 | +import android.media.AudioManager; |
---|
| 15 | +import android.media.MediaPlayer; |
---|
| 16 | +import android.media.MediaRecorder; |
---|
| 17 | +import android.os.Bundle; |
---|
| 18 | +import android.os.Handler; |
---|
| 19 | +import android.os.Vibrator; |
---|
| 20 | +import android.view.KeyEvent; |
---|
| 21 | +import android.view.View; |
---|
| 22 | +import android.view.View.OnClickListener; |
---|
| 23 | +import android.widget.Button; |
---|
| 24 | +import android.widget.TextView; |
---|
| 25 | + |
---|
| 26 | +public class SpeakerTestActivity extends Activity { |
---|
| 27 | + private AudioManager mAudioManager; |
---|
| 28 | + private MediaPlayer mPlayer; |
---|
| 29 | + private int mOldVolume; |
---|
| 30 | + private boolean mSpeakerOn; |
---|
| 31 | + |
---|
| 32 | + private Button leftButton; |
---|
| 33 | + private Button rightButton; |
---|
| 34 | + |
---|
| 35 | + private boolean leftEnable = true; |
---|
| 36 | + private boolean rightEnable = true; |
---|
| 37 | + |
---|
| 38 | + |
---|
| 39 | + protected void onCreate(Bundle paramBundle) { |
---|
| 40 | + super.onCreate(paramBundle); |
---|
| 41 | + |
---|
| 42 | + |
---|
| 43 | + setTitle(getTitle() + "----(" |
---|
| 44 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")"); |
---|
| 45 | + //requestWindowFeature(Window.FEATURE_NO_TITLE); |
---|
| 46 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON); |
---|
| 47 | + |
---|
| 48 | + setContentView(R.layout.speakertest); |
---|
| 49 | + TextView txtTitle = (TextView) findViewById(R.id.txtTitle); |
---|
| 50 | + TextView txtContent = (TextView) findViewById(R.id.txtContent); |
---|
| 51 | + txtTitle.setText(R.string.SpeakerTitle); |
---|
| 52 | + txtContent.setText(getString(R.string.SpeakerTip)); |
---|
| 53 | + |
---|
| 54 | + mAudioManager = (AudioManager) getSystemService("audio"); |
---|
| 55 | + mPlayer = new MediaPlayer(); |
---|
| 56 | + try { |
---|
| 57 | + // mPlayer.setDataSource("/system/media/audio/ringtones/CrazyDream.ogg"); |
---|
| 58 | + AssetFileDescriptor fd = getAssets().openFd("test_music.mp3"); |
---|
| 59 | + mPlayer.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), |
---|
| 60 | + fd.getDeclaredLength()); |
---|
| 61 | + |
---|
| 62 | + mPlayer.prepare(); |
---|
| 63 | + mPlayer.setLooping(true); |
---|
| 64 | + } catch (IllegalArgumentException e) { |
---|
| 65 | + // TODO Auto-generated catch block |
---|
| 66 | + e.printStackTrace(); |
---|
| 67 | + } catch (IllegalStateException e) { |
---|
| 68 | + // TODO Auto-generated catch block |
---|
| 69 | + e.printStackTrace(); |
---|
| 70 | + } catch (IOException e) { |
---|
| 71 | + // TODO Auto-generated catch block |
---|
| 72 | + e.printStackTrace(); |
---|
| 73 | + } |
---|
| 74 | + leftButton = (Button) findViewById(R.id.spk_btn_left); |
---|
| 75 | + leftButton.setOnClickListener(new OnClickListener() { |
---|
| 76 | + |
---|
| 77 | + |
---|
| 78 | + public void onClick(View v) { |
---|
| 79 | + leftEnable = !leftEnable; |
---|
| 80 | + updateButtons(); |
---|
| 81 | + } |
---|
| 82 | + }); |
---|
| 83 | + |
---|
| 84 | + rightButton = (Button) findViewById(R.id.spk_btn_right); |
---|
| 85 | + rightButton.setOnClickListener(new OnClickListener() { |
---|
| 86 | + |
---|
| 87 | + |
---|
| 88 | + public void onClick(View v) { |
---|
| 89 | + rightEnable = !rightEnable; |
---|
| 90 | + updateButtons(); |
---|
| 91 | + } |
---|
| 92 | + }); |
---|
| 93 | + updateButtons(); |
---|
| 94 | + |
---|
| 95 | + ControlButtonUtil.initControlButtonView(this); |
---|
| 96 | + |
---|
| 97 | + } |
---|
| 98 | + |
---|
| 99 | + protected void updateButtons() { |
---|
| 100 | + leftButton.setText("left " + (leftEnable ? "enabled" : "disabled")); |
---|
| 101 | + rightButton.setText("right " + (rightEnable ? "enabled" : "disabled")); |
---|
| 102 | + |
---|
| 103 | + mPlayer.setVolume(leftEnable ? 1 : 0, rightEnable ? 1 : 0); |
---|
| 104 | + } |
---|
| 105 | + |
---|
| 106 | + protected void onDestroy() { |
---|
| 107 | + super.onDestroy(); |
---|
| 108 | + mPlayer.stop(); |
---|
| 109 | + if (this.mPlayer == null) { |
---|
| 110 | + return; |
---|
| 111 | + } |
---|
| 112 | + this.mPlayer.release(); |
---|
| 113 | + this.mPlayer = null; |
---|
| 114 | + } |
---|
| 115 | + |
---|
| 116 | + protected void onPause() { |
---|
| 117 | + super.onPause(); |
---|
| 118 | + this.mAudioManager.setStreamSolo(AudioManager.STREAM_MUSIC, false); |
---|
| 119 | + this.mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, |
---|
| 120 | + this.mOldVolume, 0); |
---|
| 121 | + if (this.mSpeakerOn) |
---|
| 122 | + return; |
---|
| 123 | + this.mAudioManager.setSpeakerphoneOn(false); |
---|
| 124 | + |
---|
| 125 | + } |
---|
| 126 | + |
---|
| 127 | + protected void onResume() { |
---|
| 128 | + super.onResume(); |
---|
| 129 | + stopMediaPlayBack(); |
---|
| 130 | + this.mAudioManager.setStreamSolo(AudioManager.STREAM_MUSIC, true); |
---|
| 131 | + int i = this.mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); |
---|
| 132 | + mOldVolume = i; |
---|
| 133 | + int j = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); |
---|
| 134 | + mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, j, 0); |
---|
| 135 | + this.mSpeakerOn = this.mAudioManager.isSpeakerphoneOn(); |
---|
| 136 | + if (!this.mSpeakerOn) { |
---|
| 137 | + this.mAudioManager.setSpeakerphoneOn(true); |
---|
| 138 | + } |
---|
| 139 | + this.mPlayer.start(); |
---|
| 140 | + |
---|
| 141 | + } |
---|
| 142 | + |
---|
| 143 | + private void stopMediaPlayBack() { |
---|
| 144 | + Intent i = new Intent("com.android.music.musicservicecommand"); |
---|
| 145 | + i.putExtra("command", "pause"); |
---|
| 146 | + sendBroadcast(i); |
---|
| 147 | + |
---|
| 148 | + } |
---|
| 149 | + |
---|
| 150 | + public boolean dispatchKeyEvent(KeyEvent event) { |
---|
| 151 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
---|
| 152 | + return false; |
---|
| 153 | + } |
---|
| 154 | + return super.dispatchKeyEvent(event); |
---|
| 155 | + } |
---|
| 156 | +} |
---|
.. | .. |
---|
| 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 com.DeviceTest; |
---|
| 18 | + |
---|
| 19 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN; |
---|
| 20 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; |
---|
| 21 | +import android.app.Activity; |
---|
| 22 | +import android.app.ActivityManager; |
---|
| 23 | +import android.app.AlertDialog; |
---|
| 24 | +import android.app.Dialog; |
---|
| 25 | +import android.content.BroadcastReceiver; |
---|
| 26 | +import android.content.Context; |
---|
| 27 | +import android.content.DialogInterface; |
---|
| 28 | +import android.content.Intent; |
---|
| 29 | +import android.content.IntentFilter; |
---|
| 30 | +import android.content.DialogInterface.OnCancelListener; |
---|
| 31 | +import android.content.pm.ApplicationInfo; |
---|
| 32 | +import android.content.res.Resources; |
---|
| 33 | +import android.os.Bundle; |
---|
| 34 | +import android.os.IBinder; |
---|
| 35 | +import android.os.RemoteException; |
---|
| 36 | +import android.os.Environment; |
---|
| 37 | +import android.os.ServiceManager; |
---|
| 38 | +import android.os.StatFs; |
---|
| 39 | +import android.os.storage.StorageManager; |
---|
| 40 | +import android.os.storage.StorageEventListener; |
---|
| 41 | +import android.preference.Preference; |
---|
| 42 | +import android.preference.PreferenceActivity; |
---|
| 43 | +import android.preference.PreferenceGroup; |
---|
| 44 | +import android.preference.PreferenceScreen; |
---|
| 45 | +import android.text.format.Formatter; |
---|
| 46 | +import android.util.Log; |
---|
| 47 | +import android.view.KeyEvent; |
---|
| 48 | +import android.widget.TextView; |
---|
| 49 | +import android.widget.Toast; |
---|
| 50 | +import android.os.SystemProperties; |
---|
| 51 | +import java.lang.reflect.Array; |
---|
| 52 | +import java.lang.reflect.InvocationTargetException; |
---|
| 53 | +import java.lang.reflect.Method; |
---|
| 54 | + |
---|
| 55 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 56 | + |
---|
| 57 | +import java.io.File; |
---|
| 58 | +import java.util.List; |
---|
| 59 | + |
---|
| 60 | +public class StorageActivity extends Activity implements OnCancelListener { |
---|
| 61 | + private static final String TAG = "Memory"; |
---|
| 62 | + private static final boolean localLOGV = false; |
---|
| 63 | + |
---|
| 64 | + private Resources mRes; |
---|
| 65 | + |
---|
| 66 | + private TextView mNandSize; |
---|
| 67 | + private TextView mNandAvail; |
---|
| 68 | + private TextView mDataAvail; |
---|
| 69 | + |
---|
| 70 | + boolean mSdMountToggleAdded = true; |
---|
| 71 | + boolean mNandMountToggleAdded = true; |
---|
| 72 | + |
---|
| 73 | + private StorageManager mStorageManager = null; |
---|
| 74 | + |
---|
| 75 | + @Override |
---|
| 76 | + protected void onCreate(Bundle icicle) { |
---|
| 77 | + super.onCreate(icicle); |
---|
| 78 | + |
---|
| 79 | + if (mStorageManager == null) { |
---|
| 80 | + mStorageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE); |
---|
| 81 | + mStorageManager.registerListener(mStorageListener); |
---|
| 82 | + } |
---|
| 83 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON); |
---|
| 84 | + |
---|
| 85 | + setContentView(R.layout.storageactivitytest); |
---|
| 86 | + |
---|
| 87 | + mRes = getResources(); |
---|
| 88 | + mNandSize = (TextView)findViewById(R.id.nand_total_space); |
---|
| 89 | + mNandAvail = (TextView)findViewById(R.id.nand_available_space); |
---|
| 90 | + mDataAvail = (TextView)findViewById(R.id.data_available_space); |
---|
| 91 | + |
---|
| 92 | + ControlButtonUtil.initControlButtonView(this); |
---|
| 93 | + } |
---|
| 94 | + |
---|
| 95 | + @Override |
---|
| 96 | + protected void onResume() { |
---|
| 97 | + super.onResume(); |
---|
| 98 | + |
---|
| 99 | + IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_SCANNER_STARTED); |
---|
| 100 | + intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED); |
---|
| 101 | + intentFilter.addDataScheme("file"); |
---|
| 102 | + registerReceiver(mReceiver, intentFilter); |
---|
| 103 | + if (getStoragePath(this,false)==null) { |
---|
| 104 | + finish(); |
---|
| 105 | + } |
---|
| 106 | + updateMemoryStatus(getStoragePath(this,false)); |
---|
| 107 | + } |
---|
| 108 | + |
---|
| 109 | + StorageEventListener mStorageListener = new StorageEventListener() { |
---|
| 110 | + |
---|
| 111 | + @Override |
---|
| 112 | + public void onStorageStateChanged(String path, String oldState, String newState) { |
---|
| 113 | + Log.d(TAG, "Received storage state changed notification that " + |
---|
| 114 | + path + " changed state from " + oldState + |
---|
| 115 | + " to " + newState); |
---|
| 116 | + if (path.equals(FirstRun.sdcard_path) && !newState.equals(Environment.MEDIA_MOUNTED)) { |
---|
| 117 | + } else { |
---|
| 118 | + updateMemoryStatus(getStoragePath(getApplication(),false)); |
---|
| 119 | + } |
---|
| 120 | + } |
---|
| 121 | + }; |
---|
| 122 | + |
---|
| 123 | + @Override |
---|
| 124 | + protected void onPause() { |
---|
| 125 | + super.onPause(); |
---|
| 126 | + unregisterReceiver(mReceiver); |
---|
| 127 | + } |
---|
| 128 | + |
---|
| 129 | + @Override |
---|
| 130 | + protected void onDestroy() { |
---|
| 131 | + if (mStorageManager != null && mStorageListener != null) { |
---|
| 132 | + mStorageManager.unregisterListener(mStorageListener); |
---|
| 133 | + } |
---|
| 134 | + super.onDestroy(); |
---|
| 135 | + } |
---|
| 136 | + |
---|
| 137 | + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { |
---|
| 138 | + @Override |
---|
| 139 | + public void onReceive(Context context, Intent intent) { |
---|
| 140 | + updateMemoryStatus(getStoragePath(getApplication(),false)); |
---|
| 141 | + //updateMemoryStatus(Environment.getExternalStorageDirectory().getPath()); |
---|
| 142 | + } |
---|
| 143 | + }; |
---|
| 144 | + |
---|
| 145 | + private void updateMemoryStatus(String path) { |
---|
| 146 | + String status = SystemProperties.get("EXTERNAL_STORAGE_STATE","unmounted"); |
---|
| 147 | + if (path.equals(getStoragePath(this,false))) { |
---|
| 148 | + status = mStorageManager.getVolumeState(path); |
---|
| 149 | + } |
---|
| 150 | + String readOnly = ""; |
---|
| 151 | + if (status.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) { |
---|
| 152 | + status = Environment.MEDIA_MOUNTED; |
---|
| 153 | + readOnly = mRes.getString(R.string.read_only); |
---|
| 154 | + } |
---|
| 155 | + |
---|
| 156 | + if (status.equals(Environment.MEDIA_MOUNTED)) { |
---|
| 157 | + try { |
---|
| 158 | + //File path = Environment.getExternalStorageDirectory(); |
---|
| 159 | + StatFs stat = new StatFs(path); |
---|
| 160 | + long blockSize = stat.getBlockSize(); |
---|
| 161 | + long totalBlocks = stat.getBlockCount(); |
---|
| 162 | + long availableBlocks = stat.getAvailableBlocks(); |
---|
| 163 | + |
---|
| 164 | + if (path.equals(getStoragePath(this,false))){ |
---|
| 165 | + mNandSize.setText(formatSize(totalBlocks * blockSize)); |
---|
| 166 | + mNandAvail.setText(formatSize(availableBlocks * blockSize) + readOnly); |
---|
| 167 | + } |
---|
| 168 | + } catch (IllegalArgumentException e) { |
---|
| 169 | + // this can occur if the SD card is removed, but we haven't received the |
---|
| 170 | + // ACTION_MEDIA_REMOVED Intent yet. |
---|
| 171 | + status = Environment.MEDIA_REMOVED; |
---|
| 172 | + } |
---|
| 173 | + |
---|
| 174 | + } else { |
---|
| 175 | + if (path.equals(getStoragePath(this,false))){ |
---|
| 176 | + mNandSize.setText(mRes.getString(R.string.nand_unavailable)); |
---|
| 177 | + mNandAvail.setText(mRes.getString(R.string.nand_unavailable)); |
---|
| 178 | + if (status.equals(Environment.MEDIA_UNMOUNTED) || |
---|
| 179 | + status.equals(Environment.MEDIA_NOFS) || |
---|
| 180 | + status.equals(Environment.MEDIA_UNMOUNTABLE) ) { |
---|
| 181 | + } |
---|
| 182 | + } |
---|
| 183 | + } |
---|
| 184 | + |
---|
| 185 | + File dataPath = Environment.getDataDirectory(); |
---|
| 186 | + StatFs stat = new StatFs(dataPath.getPath()); |
---|
| 187 | + long blockSize = stat.getBlockSize(); |
---|
| 188 | + long availableBlocks = stat.getAvailableBlocks(); |
---|
| 189 | + mDataAvail.setText(formatSize(availableBlocks * blockSize)); |
---|
| 190 | + } |
---|
| 191 | + |
---|
| 192 | + private String formatSize(long size) { |
---|
| 193 | + return Formatter.formatFileSize(this, size); |
---|
| 194 | + } |
---|
| 195 | + |
---|
| 196 | + public void onCancel(DialogInterface dialog) { |
---|
| 197 | + finish(); |
---|
| 198 | + } |
---|
| 199 | + public boolean dispatchKeyEvent(KeyEvent event) { |
---|
| 200 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
---|
| 201 | + return false; |
---|
| 202 | + } |
---|
| 203 | + return super.dispatchKeyEvent(event); |
---|
| 204 | + } |
---|
| 205 | +private static String getStoragePath(Context mContext, boolean is_removale) { |
---|
| 206 | + |
---|
| 207 | + StorageManager mStorageManager = (StorageManager) mContext.getSystemService(Context.STORAGE_SERVICE); |
---|
| 208 | + Class<?> storageVolumeClazz = null; |
---|
| 209 | + try { |
---|
| 210 | + storageVolumeClazz = Class.forName("android.os.storage.StorageVolume"); |
---|
| 211 | + Method getVolumeList = mStorageManager.getClass().getMethod("getVolumeList"); |
---|
| 212 | + Method getPath = storageVolumeClazz.getMethod("getPath"); |
---|
| 213 | + Method isRemovable = storageVolumeClazz.getMethod("isRemovable"); |
---|
| 214 | + Object result = getVolumeList.invoke(mStorageManager); |
---|
| 215 | + final int length = Array.getLength(result); |
---|
| 216 | + for (int i = 0; i < length; i++) { |
---|
| 217 | + Object storageVolumeElement = Array.get(result, i); |
---|
| 218 | + String path = (String) getPath.invoke(storageVolumeElement); |
---|
| 219 | + boolean removable = (Boolean) isRemovable.invoke(storageVolumeElement); |
---|
| 220 | + if (is_removale == removable) { |
---|
| 221 | + return path; |
---|
| 222 | + } |
---|
| 223 | + } |
---|
| 224 | + } catch (ClassNotFoundException e) { |
---|
| 225 | + e.printStackTrace(); |
---|
| 226 | + } catch (InvocationTargetException e) { |
---|
| 227 | + e.printStackTrace(); |
---|
| 228 | + } catch (NoSuchMethodException e) { |
---|
| 229 | + e.printStackTrace(); |
---|
| 230 | + } catch (IllegalAccessException e) { |
---|
| 231 | + e.printStackTrace(); |
---|
| 232 | + } |
---|
| 233 | + return null; |
---|
| 234 | + } |
---|
| 235 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import java.io.BufferedInputStream;
|
---|
| 7 | +import java.io.BufferedOutputStream;
|
---|
| 8 | +import java.io.File;
|
---|
| 9 | +import java.io.FileInputStream;
|
---|
| 10 | +import java.io.FileOutputStream;
|
---|
| 11 | +import java.io.IOException;
|
---|
| 12 | +import java.io.InputStream;
|
---|
| 13 | +import java.security.Permission;
|
---|
| 14 | +import java.util.ArrayList;
|
---|
| 15 | +import java.util.Arrays;
|
---|
| 16 | +
|
---|
| 17 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 18 | +import com.DeviceTest.helper.SystemUtil;
|
---|
| 19 | +import com.DeviceTest.helper.TestCase.RESULT;
|
---|
| 20 | +
|
---|
| 21 | +import android.app.Activity;
|
---|
| 22 | +import android.bluetooth.BluetoothAdapter;
|
---|
| 23 | +import android.bluetooth.BluetoothDevice;
|
---|
| 24 | +import android.content.BroadcastReceiver;
|
---|
| 25 | +import android.content.Context;
|
---|
| 26 | +import android.content.Intent;
|
---|
| 27 | +import android.content.IntentFilter;
|
---|
| 28 | +import android.content.pm.PermissionInfo;
|
---|
| 29 | +import android.net.Uri;
|
---|
| 30 | +import android.os.Bundle;
|
---|
| 31 | +import android.os.Environment;
|
---|
| 32 | +import android.os.Handler;
|
---|
| 33 | +import android.os.Message;
|
---|
| 34 | +import android.util.Log;
|
---|
| 35 | +import android.view.KeyEvent;
|
---|
| 36 | +import android.view.View;
|
---|
| 37 | +import android.view.Window;
|
---|
| 38 | +import android.widget.ProgressBar;
|
---|
| 39 | +import android.widget.TextView;
|
---|
| 40 | +import android.os.Environment;
|
---|
| 41 | +
|
---|
| 42 | +public class StorageTestActivity extends Activity {
|
---|
| 43 | + private final static String TAG = "StorageTest";
|
---|
| 44 | + private TextView mResult;
|
---|
| 45 | +
|
---|
| 46 | + boolean stop = false;
|
---|
| 47 | + private static final String TEST_FILE_PATH = "/system/bin/logcat";
|
---|
| 48 | + private static final String TEMP_FILE_PATH = DeviceTest.TEMP_FILE_PATH
|
---|
| 49 | + + "_test";
|
---|
| 50 | +
|
---|
| 51 | +
|
---|
| 52 | + protected void onCreate(Bundle savedInstanceState) {
|
---|
| 53 | +
|
---|
| 54 | + super.onCreate(savedInstanceState);
|
---|
| 55 | +
|
---|
| 56 | + setTitle(getTitle() + "----("
|
---|
| 57 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")");
|
---|
| 58 | + // requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 59 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 60 | +
|
---|
| 61 | + setContentView(R.layout.storagetest);
|
---|
| 62 | +
|
---|
| 63 | + boolean pass = true;
|
---|
| 64 | +
|
---|
| 65 | + mResult = (TextView) findViewById(R.id.resultText);
|
---|
| 66 | + String result = "";
|
---|
| 67 | +// String sdPath = System.getenv("EXTERNAL_STORAGE");
|
---|
| 68 | + String sdPath = Environment.getExternalStorageDirectory().toString();
|
---|
| 69 | + Log.e(TAG, "EXTERNAL_STORAGE path :"+sdPath);
|
---|
| 70 | + if (sdPath == null) {
|
---|
| 71 | + result += getString(R.string.StorageSDNoFind);
|
---|
| 72 | + pass = false;
|
---|
| 73 | + } else {
|
---|
| 74 | + if (!testCopy(sdPath)) {
|
---|
| 75 | + pass = false;
|
---|
| 76 | + result += getString(R.string.StorageSDCopyF);
|
---|
| 77 | + } else {
|
---|
| 78 | + result += getString(R.string.StorageSDCopyS);
|
---|
| 79 | + }
|
---|
| 80 | + }
|
---|
| 81 | +
|
---|
| 82 | + String usbPath = System.getenv("EXTERNAL_HOST_USB");
|
---|
| 83 | + if (null == usbPath) {
|
---|
| 84 | + result += getString(R.string.StorageUsbNoFind);
|
---|
| 85 | + pass = false;
|
---|
| 86 | + } else {
|
---|
| 87 | + if (!testCopy(usbPath)) {
|
---|
| 88 | + pass = false;
|
---|
| 89 | + result += getString(R.string.StorageUsbCopyF);
|
---|
| 90 | + } else {
|
---|
| 91 | + result += getString(R.string.StorageUsbCopyS);
|
---|
| 92 | + }
|
---|
| 93 | + }
|
---|
| 94 | +
|
---|
| 95 | + result += pass ? "Pass!" : "Failed";
|
---|
| 96 | + mResult.setText(result);
|
---|
| 97 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 98 | + findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 99 | + if (pass) {
|
---|
| 100 | + findViewById(R.id.btn_Pass).performClick();
|
---|
| 101 | + } else {
|
---|
| 102 | + mHandler.postDelayed(mFailedRunnable, DeviceTest.TEST_FAILED_DELAY);
|
---|
| 103 | + }
|
---|
| 104 | + }
|
---|
| 105 | +
|
---|
| 106 | + Handler mHandler = new Handler();
|
---|
| 107 | + Runnable mFailedRunnable = new Runnable() {
|
---|
| 108 | +
|
---|
| 109 | +
|
---|
| 110 | + public void run() {
|
---|
| 111 | + if (stop) {
|
---|
| 112 | + return;
|
---|
| 113 | + }
|
---|
| 114 | + mHandler.removeCallbacks(mFailedRunnable);
|
---|
| 115 | + findViewById(R.id.btn_Fail).performClick();
|
---|
| 116 | + }
|
---|
| 117 | + };
|
---|
| 118 | +
|
---|
| 119 | + private boolean testCopy(String dstPath) {
|
---|
| 120 | + SystemUtil.execScriptCmd("cat " + TEST_FILE_PATH + " > "
|
---|
| 121 | + + dstPath + "/test", DeviceTest.TEMP_FILE_PATH, true);
|
---|
| 122 | + SystemUtil.execScriptCmd("cat " + dstPath + "/test"
|
---|
| 123 | + + " > " + TEMP_FILE_PATH + "\nrm " + dstPath + "/test",
|
---|
| 124 | + DeviceTest.TEMP_FILE_PATH, true);
|
---|
| 125 | +
|
---|
| 126 | + byte[] buffer1 = new byte[1024];
|
---|
| 127 | + byte[] buffer2 = new byte[1024];
|
---|
| 128 | + int length = 0;
|
---|
| 129 | + try {
|
---|
| 130 | + BufferedInputStream bisSrc = new BufferedInputStream(
|
---|
| 131 | + new FileInputStream(TEST_FILE_PATH));
|
---|
| 132 | + BufferedInputStream bisDst = new BufferedInputStream(
|
---|
| 133 | + new FileInputStream(TEMP_FILE_PATH));
|
---|
| 134 | + Arrays.fill(buffer1, (byte) 0);
|
---|
| 135 | + Arrays.fill(buffer2, (byte) 0);
|
---|
| 136 | + while ((length = bisSrc.read(buffer1)) > 0) {
|
---|
| 137 | + if (length != bisDst.read(buffer2)) {
|
---|
| 138 | + Log.e(TAG, "length not equals : failed");
|
---|
| 139 | + return false;
|
---|
| 140 | + }
|
---|
| 141 | + if (!Arrays.equals(buffer1, buffer2)) {
|
---|
| 142 | + Log.e(TAG, "data not equals : failed");
|
---|
| 143 | + return false;
|
---|
| 144 | + }
|
---|
| 145 | + }
|
---|
| 146 | + bisSrc.close();
|
---|
| 147 | + bisDst.close();
|
---|
| 148 | + } catch (IOException e) {
|
---|
| 149 | + e.printStackTrace();
|
---|
| 150 | + return false;
|
---|
| 151 | + } finally {
|
---|
| 152 | + File file = new File(TEMP_FILE_PATH);
|
---|
| 153 | + if (file.exists()) {
|
---|
| 154 | + file.delete();
|
---|
| 155 | + }
|
---|
| 156 | + }
|
---|
| 157 | + return true;
|
---|
| 158 | + }
|
---|
| 159 | +
|
---|
| 160 | +
|
---|
| 161 | +
|
---|
| 162 | + public void onStop() {
|
---|
| 163 | + super.onStop();
|
---|
| 164 | + mHandler.removeCallbacks(mFailedRunnable);
|
---|
| 165 | + stop = true;
|
---|
| 166 | + }
|
---|
| 167 | +
|
---|
| 168 | + // if (device != null && progressBar.isShown()) {
|
---|
| 169 | + // progressBar.setVisibility(View.GONE);
|
---|
| 170 | + // mResult.setText("Find equipment....\n Pass!");
|
---|
| 171 | +
|
---|
| 172 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 173 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 174 | + return false;
|
---|
| 175 | + }
|
---|
| 176 | + return super.dispatchKeyEvent(event);
|
---|
| 177 | + }
|
---|
| 178 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.*;
|
---|
| 4 | +
|
---|
| 5 | +import java.io.File;
|
---|
| 6 | +
|
---|
| 7 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 8 | +import com.DeviceTest.view.PointerLocationView;
|
---|
| 9 | +import com.DeviceTest.view.PointerLocationView.OnPointCountChangeListener;
|
---|
| 10 | +
|
---|
| 11 | +import android.app.Activity;
|
---|
| 12 | +import android.graphics.Color;
|
---|
| 13 | +import android.os.Bundle;
|
---|
| 14 | +import android.view.KeyEvent;
|
---|
| 15 | +import android.view.MotionEvent;
|
---|
| 16 | +import android.view.View;
|
---|
| 17 | +import android.view.ViewGroup;
|
---|
| 18 | +import android.view.View.OnTouchListener;
|
---|
| 19 | +import android.view.Window;
|
---|
| 20 | +import android.widget.Button;
|
---|
| 21 | +import android.widget.TextView;
|
---|
| 22 | +import android.util.Log;
|
---|
| 23 | +
|
---|
| 24 | +public class TouchTestActivity extends Activity {
|
---|
| 25 | + TextView mText;
|
---|
| 26 | + TextView mTitle;
|
---|
| 27 | + PointerLocationView mPointerView;
|
---|
| 28 | + private Button passButton;
|
---|
| 29 | +
|
---|
| 30 | +
|
---|
| 31 | + public void onCreate(Bundle paramBundle) {
|
---|
| 32 | + super.onCreate(paramBundle);
|
---|
| 33 | +
|
---|
| 34 | + setTitle(getTitle() + "----("
|
---|
| 35 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")");
|
---|
| 36 | + requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 37 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 38 | +
|
---|
| 39 | + setContentView(R.layout.touchtest);
|
---|
| 40 | + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
|
---|
| 41 | +
|
---|
| 42 | + mPointerView = (PointerLocationView) findViewById(R.id.pointerview);
|
---|
| 43 | + mPointerView.setBackgroundColor(Color.TRANSPARENT);
|
---|
| 44 | +
|
---|
| 45 | + mPointerView
|
---|
| 46 | + .setOnPointCountChangeListener(new OnPointCountChangeListener() {
|
---|
| 47 | +
|
---|
| 48 | +
|
---|
| 49 | + public void onPointCountChange(int newPointCount) {
|
---|
| 50 | + Log.i("Jeffy", "Count:" + newPointCount);
|
---|
| 51 | + if (newPointCount >= 20) {
|
---|
| 52 | +// passButton.setVisibility(View.VISIBLE);
|
---|
| 53 | + passButton.performClick();
|
---|
| 54 | + }
|
---|
| 55 | + }
|
---|
| 56 | + });
|
---|
| 57 | +
|
---|
| 58 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 59 | +// passButton = (Button) findViewById(R.id.btn_Pass);
|
---|
| 60 | +// passButton.setVisibility(View.INVISIBLE);
|
---|
| 61 | + }
|
---|
| 62 | +
|
---|
| 63 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 64 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 65 | + return false;
|
---|
| 66 | + }
|
---|
| 67 | + return super.dispatchKeyEvent(event);
|
---|
| 68 | + }
|
---|
| 69 | +
|
---|
| 70 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | +import java.io.File; |
---|
| 3 | + |
---|
| 4 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 5 | +import com.DeviceTest.helper.SystemInfoUtil; |
---|
| 6 | + |
---|
| 7 | +import android.app.Activity; |
---|
| 8 | +import android.content.Context; |
---|
| 9 | +import android.content.DialogInterface; |
---|
| 10 | +import android.os.Bundle; |
---|
| 11 | +import android.os.Environment; |
---|
| 12 | +import android.os.Handler; |
---|
| 13 | +import android.os.Message; |
---|
| 14 | +import android.os.StatFs; |
---|
| 15 | +import android.os.storage.StorageManager; |
---|
| 16 | +import android.os.storage.StorageVolume; |
---|
| 17 | +import android.os.SystemProperties; |
---|
| 18 | +import android.os.storage.StorageEventListener; |
---|
| 19 | +import android.text.format.Formatter; |
---|
| 20 | +import android.util.Log; |
---|
| 21 | +import android.widget.Button; |
---|
| 22 | +import android.widget.TextView; |
---|
| 23 | +import android.view.KeyEvent; |
---|
| 24 | +import android.view.View; |
---|
| 25 | +import android.hardware.input.InputManager; |
---|
| 26 | +import android.view.MotionEvent; |
---|
| 27 | +import android.view.InputDevice; |
---|
| 28 | +import java.io.File; |
---|
| 29 | +import android.content.ComponentName; |
---|
| 30 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 31 | +import com.DeviceTest.helper.SystemInfoUtil; |
---|
| 32 | +import android.os.Build; |
---|
| 33 | +import android.app.Activity; |
---|
| 34 | +import android.content.Context; |
---|
| 35 | +import android.content.DialogInterface; |
---|
| 36 | +import android.os.Bundle; |
---|
| 37 | +import android.os.Environment; |
---|
| 38 | +import android.os.Handler; |
---|
| 39 | +import android.os.Message; |
---|
| 40 | +import android.os.StatFs; |
---|
| 41 | +import android.os.storage.StorageManager; |
---|
| 42 | +import android.os.storage.StorageVolume; |
---|
| 43 | +import android.os.SystemProperties; |
---|
| 44 | +import android.os.storage.StorageEventListener; |
---|
| 45 | +import android.text.format.Formatter; |
---|
| 46 | +import android.util.Log; |
---|
| 47 | +import android.widget.Button; |
---|
| 48 | +import android.widget.TextView; |
---|
| 49 | +import android.hardware.usb.UsbDevice; |
---|
| 50 | +import android.hardware.usb.UsbManager; |
---|
| 51 | +import java.util.Iterator; |
---|
| 52 | +import java.util.HashMap; |
---|
| 53 | +import android.content.Intent; |
---|
| 54 | +import android.content.pm.PackageManager; |
---|
| 55 | +import android.widget.Toast; |
---|
| 56 | + |
---|
| 57 | +public class USBDeviceTestActivity extends Activity { |
---|
| 58 | + private final static String TAG = "USBDeviceTestActivity"; |
---|
| 59 | + private final static int MSG_OK=0; |
---|
| 60 | + |
---|
| 61 | + // 创建定时器循环 |
---|
| 62 | + public Handler USBhandler; |
---|
| 63 | + |
---|
| 64 | + public void onCreate(Bundle paramBundle) { |
---|
| 65 | + super.onCreate(paramBundle); |
---|
| 66 | + setContentView(R.layout.usbdevicetest); |
---|
| 67 | + |
---|
| 68 | + System.out.println("rpdzkj usb test"); |
---|
| 69 | + |
---|
| 70 | + // 创建定时器循环 |
---|
| 71 | + USBhandler=new Handler(); |
---|
| 72 | + USBhandler.postDelayed(runnable, 500); |
---|
| 73 | + |
---|
| 74 | + |
---|
| 75 | + ControlButtonUtil.initControlButtonView(this); |
---|
| 76 | + // 自动通过测试 |
---|
| 77 | + //handler.sendEmptyMessageDelayed(MSG_OK, 2500); |
---|
| 78 | + } |
---|
| 79 | + |
---|
| 80 | + private Handler handler=new Handler(){ |
---|
| 81 | + @Override |
---|
| 82 | + public void handleMessage(Message msg) { |
---|
| 83 | + switch(msg.what){ |
---|
| 84 | + case MSG_OK: |
---|
| 85 | + ((Button) findViewById(R.id.btn_Pass)).performClick(); |
---|
| 86 | + } |
---|
| 87 | + } |
---|
| 88 | + }; |
---|
| 89 | + |
---|
| 90 | + // 定时器循环代码 |
---|
| 91 | + Runnable runnable=new Runnable(){ |
---|
| 92 | + public void run() { |
---|
| 93 | + TextView usbHostView = (TextView) findViewById(R.id.USBNum); |
---|
| 94 | + usbHostView.setText("USB设备数量 : " + USBhostDeviceCheck()); |
---|
| 95 | + USBhandler.postDelayed(this, 1000);// 每1000毫秒循环一次 |
---|
| 96 | + } |
---|
| 97 | + }; |
---|
| 98 | + |
---|
| 99 | + |
---|
| 100 | + // 获取当前USB设备数量 |
---|
| 101 | + public int USBhostDeviceCheck(){ |
---|
| 102 | + int usbNum = 0; |
---|
| 103 | + UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE); |
---|
| 104 | + HashMap<String, UsbDevice> devs; |
---|
| 105 | + devs = usbManager.getDeviceList(); |
---|
| 106 | + StringBuilder sb = new StringBuilder(); |
---|
| 107 | + if(!devs.isEmpty()){ |
---|
| 108 | + Iterator<UsbDevice> usbs = devs.values().iterator(); |
---|
| 109 | + while(usbs.hasNext()){ |
---|
| 110 | + UsbDevice dev = usbs.next(); |
---|
| 111 | + int vid = dev.getVendorId(); |
---|
| 112 | + int pid = dev.getProductId(); |
---|
| 113 | + if (vid == 1507 && pid == 1544) { |
---|
| 114 | + // skip usb hub gl850g |
---|
| 115 | + } else if (vid == 3034 && pid == 46880) { |
---|
| 116 | + // skip usb wifi rtl |
---|
| 117 | + } else if (vid == 4292 && pid == 60000) { |
---|
| 118 | + // skip usb wifi rtl |
---|
| 119 | + } else if (vid == 11388 && pid == 293) { |
---|
| 120 | + // skip EC20 |
---|
| 121 | + } else if (vid == 11388 && pid == 24578) { |
---|
| 122 | + // skip EC200s |
---|
| 123 | + } else if (vid == 0x2c7c && pid == 0x0801) { |
---|
| 124 | + // RM520N |
---|
| 125 | + } else if (vid == 0x2c7c && pid == 0x0800) { |
---|
| 126 | + // RM500Q |
---|
| 127 | + } else if (vid == 0x2c7c && pid == 0x0900) { |
---|
| 128 | + // RM500U |
---|
| 129 | + } else { |
---|
| 130 | + usbNum++; |
---|
| 131 | + } |
---|
| 132 | + String name = dev.getDeviceName(); |
---|
| 133 | + sb.append("-----------------------------------"+"\n"); |
---|
| 134 | + sb.append("vid = "+Integer.toHexString(vid)+ " ,pid = "+ Integer.toHexString(pid) + "\n"); |
---|
| 135 | + sb.append("name = "+name+"\n"); |
---|
| 136 | + android.util.Log.d("RRRRRRRR", sb.toString()); |
---|
| 137 | + } |
---|
| 138 | + } |
---|
| 139 | + |
---|
| 140 | + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O_MR1) return usbNum; |
---|
| 141 | + |
---|
| 142 | + InputManager inputManager = (InputManager) getSystemService(Context.INPUT_SERVICE); |
---|
| 143 | + int[] deviceIds = inputManager.getInputDeviceIds(); |
---|
| 144 | + for (int deviceId : deviceIds) { |
---|
| 145 | + InputDevice device = inputManager.getInputDevice(deviceId); |
---|
| 146 | + if (device != null) { |
---|
| 147 | + int srcid = device.getSources(); |
---|
| 148 | + if ((srcid & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) { |
---|
| 149 | + usbNum ++; |
---|
| 150 | + } |
---|
| 151 | + } |
---|
| 152 | + } |
---|
| 153 | + |
---|
| 154 | + |
---|
| 155 | + return usbNum; |
---|
| 156 | + } |
---|
| 157 | + |
---|
| 158 | + public void onGoOtgModeSetBtnClick(View view) { |
---|
| 159 | + goOTGModeSetting(); |
---|
| 160 | + } |
---|
| 161 | + |
---|
| 162 | + public void goOTGModeSetting() { |
---|
| 163 | + Intent intent = new Intent(); |
---|
| 164 | + intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$UsbHostDeviceSettingsActivity")); |
---|
| 165 | + if (intent.resolveActivityInfo(getPackageManager(), PackageManager.MATCH_DEFAULT_ONLY) != null) { |
---|
| 166 | + startActivity(intent); |
---|
| 167 | + } |
---|
| 168 | + } |
---|
| 169 | + |
---|
| 170 | + @Override |
---|
| 171 | + protected void onResume() { |
---|
| 172 | + super.onResume(); |
---|
| 173 | + } |
---|
| 174 | + |
---|
| 175 | + public void onCancel(DialogInterface dialog) { |
---|
| 176 | + finish(); |
---|
| 177 | + } |
---|
| 178 | + |
---|
| 179 | + public boolean dispatchKeyEvent(KeyEvent event) { |
---|
| 180 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
---|
| 181 | + return false; |
---|
| 182 | + } |
---|
| 183 | + return super.dispatchKeyEvent(event); |
---|
| 184 | + } |
---|
| 185 | + |
---|
| 186 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | + |
---|
| 3 | +import java.io.BufferedReader; |
---|
| 4 | +import java.io.File; |
---|
| 5 | +import java.io.FileInputStream; |
---|
| 6 | +import java.io.FileOutputStream; |
---|
| 7 | +import java.io.IOException; |
---|
| 8 | +import java.io.InputStreamReader; |
---|
| 9 | +import java.io.OutputStreamWriter; |
---|
| 10 | +import java.math.BigInteger; |
---|
| 11 | + |
---|
| 12 | +import com.DeviceTest.helper.ConfigUtil; |
---|
| 13 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 14 | +import com.DeviceTest.helper.StorageInfo; |
---|
| 15 | +import com.DeviceTest.helper.SystemInfoUtil; |
---|
| 16 | +import com.DeviceTest.helper.SystemUtil; |
---|
| 17 | + |
---|
| 18 | +import android.app.Activity; |
---|
| 19 | +import android.content.BroadcastReceiver; |
---|
| 20 | +import android.content.Context; |
---|
| 21 | +import android.content.Intent; |
---|
| 22 | +import android.content.IntentFilter; |
---|
| 23 | +import android.os.Build; |
---|
| 24 | +import android.os.Bundle; |
---|
| 25 | +import android.os.Environment; |
---|
| 26 | +import android.os.Handler; |
---|
| 27 | +import android.os.Message; |
---|
| 28 | +import android.os.ServiceManager; |
---|
| 29 | +import android.os.StatFs; |
---|
| 30 | +import android.view.View; |
---|
| 31 | +import android.view.Window; |
---|
| 32 | +import android.view.WindowManager; |
---|
| 33 | +import android.widget.Button; |
---|
| 34 | +import android.widget.TextView; |
---|
| 35 | +import android.os.SystemProperties; |
---|
| 36 | +import android.text.format.Formatter; |
---|
| 37 | +import android.util.Log; |
---|
| 38 | +import android.os.storage.StorageManager; |
---|
| 39 | +import android.os.storage.StorageVolume; |
---|
| 40 | +import android.os.storage.StorageEventListener; |
---|
| 41 | +import java.lang.reflect.Array; |
---|
| 42 | +import java.lang.reflect.InvocationTargetException; |
---|
| 43 | +import java.lang.reflect.Method; |
---|
| 44 | +import android.os.storage.VolumeInfo; |
---|
| 45 | +import java.util.Collections; |
---|
| 46 | +import android.os.storage.DiskInfo; |
---|
| 47 | +import java.util.List; |
---|
| 48 | +import java.util.regex.Matcher; |
---|
| 49 | +import java.util.regex.Pattern; |
---|
| 50 | + |
---|
| 51 | + |
---|
| 52 | +public class UsbHostTestActivity extends Activity { |
---|
| 53 | + private static final String TAG = "UsbHostTestActivity"; |
---|
| 54 | + private static final String TEST_STRING = "Rockchip UsbHostTest File"; |
---|
| 55 | +// private static final String SDCARD_PATH = "/mnt/external_sd"; |
---|
| 56 | +// private final static String SDCARD_PATH = "/storage/sdcard1"; |
---|
| 57 | + protected static final int BACK_TIME = 2000; |
---|
| 58 | + private static final int SEND_REND_WRITE_SD = 3; |
---|
| 59 | + protected static final int R_PASS = 1; |
---|
| 60 | + protected static final int R_FAIL = 2; |
---|
| 61 | + private String sdcard_path = null; |
---|
| 62 | + private StringBuilder sBuilder; |
---|
| 63 | + // private SdcardReceiver sdcardReceiver = null; |
---|
| 64 | + public String SUCCESS; |
---|
| 65 | + public String FAIL; |
---|
| 66 | + private boolean isFindSd = false; |
---|
| 67 | + private static StorageManager mStorageManager = null; |
---|
| 68 | + private static boolean is_Usb=false; |
---|
| 69 | + TextView mResult; |
---|
| 70 | + private static boolean isSDFirstTest =true; |
---|
| 71 | + public static String flash_dir = Environment.getExternalStorageDirectory().getPath(); |
---|
| 72 | + private static StatFs stat=null; |
---|
| 73 | + private StorageInfo mTestStorage; |
---|
| 74 | + protected STORAGE_TYPE mStorageType = STORAGE_TYPE.USB_HOST; |
---|
| 75 | + |
---|
| 76 | + public enum STORAGE_TYPE { |
---|
| 77 | + USB_HOST, |
---|
| 78 | + PCIE, |
---|
| 79 | + SATA, |
---|
| 80 | + } |
---|
| 81 | + |
---|
| 82 | + protected void preData() { |
---|
| 83 | + |
---|
| 84 | + } |
---|
| 85 | + |
---|
| 86 | + protected void childTest(){} |
---|
| 87 | + protected void dealMessage(Message msg) {} |
---|
| 88 | + |
---|
| 89 | + @Override |
---|
| 90 | + protected void onCreate(Bundle savedInstanceState) { |
---|
| 91 | + |
---|
| 92 | + super.onCreate(savedInstanceState); |
---|
| 93 | + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); |
---|
| 94 | + |
---|
| 95 | + // requestWindowFeature(Window.FEATURE_NO_TITLE); |
---|
| 96 | + // getWindow().addFlags(1152); |
---|
| 97 | + setContentView(R.layout.usbhosttest); |
---|
| 98 | + preData(); |
---|
| 99 | + isSDFirstTest =true; |
---|
| 100 | + if (mStorageManager == null) { |
---|
| 101 | + mStorageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE); |
---|
| 102 | + } |
---|
| 103 | + this.mResult = (TextView) findViewById(R.id.sdresultText); |
---|
| 104 | + this.mResult.setVisibility(View.VISIBLE); |
---|
| 105 | + this.mResult.setGravity(17); |
---|
| 106 | + TextView textTitle = (TextView) findViewById(R.id.textTitle); |
---|
| 107 | + textTitle.setText(getTestTitle()); |
---|
| 108 | + |
---|
| 109 | + ControlButtonUtil.initControlButtonView(this); |
---|
| 110 | + SUCCESS = getString(R.string.success); |
---|
| 111 | + FAIL = getString(R.string.fail); |
---|
| 112 | + |
---|
| 113 | + } |
---|
| 114 | + |
---|
| 115 | + @Override |
---|
| 116 | + protected void onResume() { |
---|
| 117 | + super.onResume(); |
---|
| 118 | + findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE); |
---|
| 119 | + findViewById(R.id.btn_Fail).setVisibility(View.INVISIBLE); |
---|
| 120 | + init_StoragePath(this); |
---|
| 121 | + // mStorageManager.registerListener(mStorageListener); |
---|
| 122 | + StorageVolume[] storageVolumes = mStorageManager.getVolumeList(); |
---|
| 123 | + Log.d(TAG, " storageVolumes.length= " + storageVolumes.length); |
---|
| 124 | + for(int i=0;i< storageVolumes.length;i++) |
---|
| 125 | + { |
---|
| 126 | + Log.d(TAG, " storageVolumes["+i+"].getPath()=" +storageVolumes[i].getPath()); |
---|
| 127 | + } |
---|
| 128 | + /*if(storageVolumes.length >= 2){ |
---|
| 129 | + sdcard_path = storageVolumes[1].getPath();*/ |
---|
| 130 | + |
---|
| 131 | + //SDCARD_PATH=sdcard_path; |
---|
| 132 | + //Log.d(TAG, " storageVolumes[1].getPath()= " + SDCARD_PATH + " "+","+ Environment.getExternalStorageDirectory()); |
---|
| 133 | + //Log.d(TAG, " storageVolumes[0].getPath()= " + storageVolumes[0].getPath()); |
---|
| 134 | + //} |
---|
| 135 | + sBuilder = new StringBuilder(); |
---|
| 136 | + //String sdState = getSdCardState(); |
---|
| 137 | + if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { |
---|
| 138 | + isFindSd=true; |
---|
| 139 | + |
---|
| 140 | + mResult.setText(getString(R.string.resume_findSD)); |
---|
| 141 | + mHandler.sendEmptyMessageDelayed(SEND_REND_WRITE_SD, 1000); |
---|
| 142 | + } |
---|
| 143 | + } |
---|
| 144 | + |
---|
| 145 | + @Override |
---|
| 146 | + protected void onPause() { |
---|
| 147 | + super.onPause(); |
---|
| 148 | + if (mStorageManager != null) { |
---|
| 149 | + // mStorageManager.unregisterListener(mStorageListener); |
---|
| 150 | + } |
---|
| 151 | + } |
---|
| 152 | + |
---|
| 153 | + |
---|
| 154 | + public void testSdcard() { |
---|
| 155 | + try { |
---|
| 156 | + if (null == mTestStorage || null == mTestStorage.getPath()) { |
---|
| 157 | + sBuilder.append(getNotStoragePathFailTxt()).append("\n"); |
---|
| 158 | + mResult.setText(sBuilder.toString()); |
---|
| 159 | + mHandler.sendEmptyMessageDelayed(R_FAIL, 3000); |
---|
| 160 | + isFindSd = false; |
---|
| 161 | + return; |
---|
| 162 | + } |
---|
| 163 | + // String externalVolumeState = mStorageManager.getVolumeState(SDCARD_PATH); |
---|
| 164 | + //if (!externalVolumeState.equals(Environment.MEDIA_MOUNTED)) { |
---|
| 165 | + // sBuilder.append(getString(R.string.SdCardFail)).append("\n"); |
---|
| 166 | + //mResult.setText(sBuilder.toString()); |
---|
| 167 | + //mHandler.sendEmptyMessageDelayed(R_FAIL, 3000); |
---|
| 168 | + //isFindSd = false; |
---|
| 169 | + //return; |
---|
| 170 | + // } |
---|
| 171 | + } catch (Exception rex) { |
---|
| 172 | + |
---|
| 173 | + rex.printStackTrace(); |
---|
| 174 | + isFindSd = false; |
---|
| 175 | + mHandler.sendEmptyMessageDelayed(R_FAIL, 3000); |
---|
| 176 | + return; |
---|
| 177 | + } |
---|
| 178 | + |
---|
| 179 | + File pathFile = new File(mTestStorage.getPath()); |
---|
| 180 | + Log.d(TAG, "pathFile = " + pathFile.toString()); |
---|
| 181 | + if (!pathFile.exists()) { |
---|
| 182 | + sBuilder.append(getNotStoragePathFailTxt()).append("\n"); |
---|
| 183 | + mResult.setText(sBuilder.toString()); |
---|
| 184 | + mHandler.sendEmptyMessageDelayed(R_FAIL, 3000); |
---|
| 185 | + isFindSd = false; |
---|
| 186 | + return; |
---|
| 187 | + } |
---|
| 188 | + try { |
---|
| 189 | + stat = new StatFs(pathFile.getPath()); |
---|
| 190 | + } catch (Exception e) { |
---|
| 191 | + e.printStackTrace(); |
---|
| 192 | + sBuilder.append(getNotStoragePathFailTxt()).append("\n"); |
---|
| 193 | + mResult.setText(sBuilder.toString()); |
---|
| 194 | + mHandler.sendEmptyMessageDelayed(R_FAIL, 3000); |
---|
| 195 | + isFindSd = false; |
---|
| 196 | + return; |
---|
| 197 | + } |
---|
| 198 | + |
---|
| 199 | + long blockSize = stat.getBlockSize(); |
---|
| 200 | + long totalBlocks = stat.getBlockCount(); |
---|
| 201 | + String totalSize = Formatter.formatFileSize(this, totalBlocks |
---|
| 202 | + * blockSize); |
---|
| 203 | + if ("0.00 B".equals(totalSize)) { |
---|
| 204 | + sBuilder.append(getNotStoragePathFailTxt()).append("\n"); |
---|
| 205 | + mResult.setText(sBuilder.toString()); |
---|
| 206 | + mHandler.sendEmptyMessageDelayed(R_FAIL, 3000); |
---|
| 207 | + isFindSd = false; |
---|
| 208 | + return; |
---|
| 209 | + } |
---|
| 210 | + String prix = ""; |
---|
| 211 | + if (STORAGE_TYPE.PCIE == mStorageType) { |
---|
| 212 | + prix = getString(R.string.PCIEFind); |
---|
| 213 | + } else if (STORAGE_TYPE.SATA == mStorageType) { |
---|
| 214 | + prix = getString(R.string.SATAFind); |
---|
| 215 | + } else if (STORAGE_TYPE.USB_HOST == mStorageType) { |
---|
| 216 | + prix = getString(R.string.UsbFind); |
---|
| 217 | + } |
---|
| 218 | + sBuilder.append(prix + totalSize).append("\n"); |
---|
| 219 | + try { |
---|
| 220 | + Thread.sleep(2000); |
---|
| 221 | + } catch (InterruptedException e) { |
---|
| 222 | + e.printStackTrace(); |
---|
| 223 | + } |
---|
| 224 | + testReadAndWrite(); |
---|
| 225 | + |
---|
| 226 | + } |
---|
| 227 | + |
---|
| 228 | + private String getTestTitle() { |
---|
| 229 | + if (STORAGE_TYPE.PCIE == mStorageType) { |
---|
| 230 | + return getString(R.string.PCIETestTitle); |
---|
| 231 | + } else if (STORAGE_TYPE.SATA == mStorageType) { |
---|
| 232 | + return getString(R.string.SATATestTitle); |
---|
| 233 | + } else if (STORAGE_TYPE.USB_HOST == mStorageType) { |
---|
| 234 | + return getString(R.string.UsbHostTestTitle); |
---|
| 235 | + } |
---|
| 236 | + return ""; |
---|
| 237 | + } |
---|
| 238 | + |
---|
| 239 | + private String getNotStoragePathFailTxt() { |
---|
| 240 | + if (STORAGE_TYPE.PCIE == mStorageType) { |
---|
| 241 | + return getString(R.string.PCIETestFail); |
---|
| 242 | + } else if (STORAGE_TYPE.SATA == mStorageType) { |
---|
| 243 | + return getString(R.string.SATATestFail); |
---|
| 244 | + } else if (STORAGE_TYPE.USB_HOST == mStorageType) { |
---|
| 245 | + return getString(R.string.UsbHostTestFail); |
---|
| 246 | + } |
---|
| 247 | + return ""; |
---|
| 248 | + } |
---|
| 249 | + |
---|
| 250 | + public void testReadAndWrite() { |
---|
| 251 | + if (isFindSd && dotestReadAndWrite()) { |
---|
| 252 | + sBuilder.append(getTestTitle() + SUCCESS); |
---|
| 253 | + mResult.setText(sBuilder.toString()); |
---|
| 254 | + ((Button)findViewById(R.id.btn_Skip)).setClickable(false); |
---|
| 255 | + //((Button)findViewById(R.id.btn_Pass)).setClickable(false); |
---|
| 256 | + ((Button)findViewById(R.id.btn_Fail)).setClickable(false); |
---|
| 257 | + if (STORAGE_TYPE.PCIE == mStorageType) { |
---|
| 258 | + childTest(); |
---|
| 259 | + } else if (STORAGE_TYPE.USB_HOST == mStorageType |
---|
| 260 | + && Build.VERSION.SDK_INT == ConfigUtil.ANDROID_SDK_VERSION_R) { |
---|
| 261 | + dotestHostSpeed(mTestStorage.getSysPath()); |
---|
| 262 | + } else { |
---|
| 263 | + mHandler.sendEmptyMessageDelayed(R_PASS, BACK_TIME); |
---|
| 264 | + } |
---|
| 265 | + } else { |
---|
| 266 | + sBuilder.append(getTestTitle() + FAIL); |
---|
| 267 | + mResult.setText(sBuilder.toString()); |
---|
| 268 | + ((Button)findViewById(R.id.btn_Skip)).setClickable(false); |
---|
| 269 | + ((Button)findViewById(R.id.btn_Pass)).setClickable(false); |
---|
| 270 | + //((Button)findViewById(R.id.btn_Fail)).setClickable(false); |
---|
| 271 | + mHandler.sendEmptyMessageDelayed(R_FAIL, BACK_TIME); |
---|
| 272 | + } |
---|
| 273 | + } |
---|
| 274 | + |
---|
| 275 | + private void dotestHostSpeed(String sysPath) { |
---|
| 276 | + //String test = "/sys//devices/platform/usbhost/fd000000.dwc3/xhci-hcd.0.auto/usb60/6-1/6-1:1.0/host1/target1:0:0/1:0:0:0/block/sda'}"; |
---|
| 277 | + Pattern pattern = Pattern.compile(".*/(usb)(\\d+)/\\d-\\d/"); |
---|
| 278 | + Matcher matcher = pattern.matcher(sysPath); |
---|
| 279 | + String lastStorageResult = ""; |
---|
| 280 | + if (null != mResult.getText() && null != mResult.getText().toString()) { |
---|
| 281 | + lastStorageResult = mResult.getText().toString(); |
---|
| 282 | + } |
---|
| 283 | + if (matcher.find()) { |
---|
| 284 | + String strSpeed = SystemUtil.execShellCmd( |
---|
| 285 | + "cat " + matcher.group() + "speed"); |
---|
| 286 | + if ("5000".equals(strSpeed)) { |
---|
| 287 | + mResult.setText(lastStorageResult + "\n\nusb3.0"); |
---|
| 288 | + } else if("480".equals(strSpeed)) { |
---|
| 289 | + mResult.setText(lastStorageResult + "\n\nusb2.0"); |
---|
| 290 | + } else if ("12".equals(strSpeed)) { |
---|
| 291 | + mResult.setText(lastStorageResult + "\n\nusb1.1"); |
---|
| 292 | + } else { |
---|
| 293 | + mResult.setText(lastStorageResult + "\n\n" + strSpeed + ", unknown usb type"); |
---|
| 294 | + } |
---|
| 295 | + findViewById(R.id.btn_Pass).setVisibility(View.VISIBLE); |
---|
| 296 | + findViewById(R.id.btn_Pass).setClickable(true); |
---|
| 297 | + findViewById(R.id.btn_Fail).setVisibility(View.VISIBLE); |
---|
| 298 | + findViewById(R.id.btn_Fail).setClickable(true); |
---|
| 299 | + } else { |
---|
| 300 | + mResult.setText(lastStorageResult + "\n\n" + sysPath); |
---|
| 301 | + mHandler.sendEmptyMessageDelayed(R_FAIL, BACK_TIME); |
---|
| 302 | + } |
---|
| 303 | + } |
---|
| 304 | + |
---|
| 305 | + private boolean dotestReadAndWrite() { |
---|
| 306 | + // String directoryName = Environment.getExternalStorageDirectory().toString()+ "/test"; |
---|
| 307 | + String directoryName = mTestStorage.getPath() + "/test"; |
---|
| 308 | + File directory = new File(directoryName); |
---|
| 309 | + if (!directory.isDirectory()) { |
---|
| 310 | + if (!directory.mkdirs()) { |
---|
| 311 | + sBuilder.append(getString(R.string.MakeDir) + FAIL).append("\n"); |
---|
| 312 | + return false; |
---|
| 313 | + } else { |
---|
| 314 | + sBuilder.append(getString(R.string.MakeDir) + SUCCESS).append( |
---|
| 315 | + "\n"); |
---|
| 316 | + } |
---|
| 317 | + } |
---|
| 318 | + File f = new File(directoryName, "SDCard.txt"); |
---|
| 319 | + try { |
---|
| 320 | + // Remove stale file if any |
---|
| 321 | + if (f.exists()) { |
---|
| 322 | + f.delete(); |
---|
| 323 | + } |
---|
| 324 | + if (!f.createNewFile()) { |
---|
| 325 | + sBuilder.append(getString(R.string.CreateFile) + FAIL).append( |
---|
| 326 | + "\n"); |
---|
| 327 | + return false; |
---|
| 328 | + } else { |
---|
| 329 | + sBuilder.append(getString(R.string.CreateFile) + SUCCESS).append( |
---|
| 330 | + "\n"); |
---|
| 331 | + |
---|
| 332 | + doWriteFile(f.getAbsoluteFile().toString()); |
---|
| 333 | + |
---|
| 334 | + if (doReadFile(f.getAbsoluteFile().toString()).equals( |
---|
| 335 | + TEST_STRING)) { |
---|
| 336 | + sBuilder.append(getString(R.string.Compare)).append(SUCCESS).append( |
---|
| 337 | + "\n"); |
---|
| 338 | + } else { |
---|
| 339 | + sBuilder.append(getString(R.string.Compare)).append(FAIL).append( |
---|
| 340 | + "\n"); |
---|
| 341 | + return false; |
---|
| 342 | + } |
---|
| 343 | + } |
---|
| 344 | + |
---|
| 345 | + sBuilder.append(getString(R.string.FileDel)).append( |
---|
| 346 | + (f.delete() ? SUCCESS : FAIL)).append("\n"); |
---|
| 347 | + sBuilder.append(getString(R.string.DirDel)).append( |
---|
| 348 | + (directory.delete() ? SUCCESS : FAIL)).append("\n"); |
---|
| 349 | + return true; |
---|
| 350 | + } catch (IOException ex) { |
---|
| 351 | + Log.e(TAG, "isWritable : false (IOException)!"); |
---|
| 352 | + return false; |
---|
| 353 | + } |
---|
| 354 | + } |
---|
| 355 | + |
---|
| 356 | + public void doWriteFile(String filename) { |
---|
| 357 | + try { |
---|
| 358 | + sBuilder.append(getString(R.string.WriteData)).append("\n"); |
---|
| 359 | + OutputStreamWriter osw = new OutputStreamWriter( |
---|
| 360 | + new FileOutputStream( |
---|
| 361 | + filename)); |
---|
| 362 | + osw.write(TEST_STRING, 0, TEST_STRING.length()); |
---|
| 363 | + osw.flush(); |
---|
| 364 | + osw.close(); |
---|
| 365 | + } catch (IOException e) { |
---|
| 366 | + e.printStackTrace(); |
---|
| 367 | + } |
---|
| 368 | + } |
---|
| 369 | + |
---|
| 370 | + public String doReadFile(String filename) { |
---|
| 371 | + try { |
---|
| 372 | + BufferedReader br = new BufferedReader(new InputStreamReader |
---|
| 373 | + (new FileInputStream(filename))); |
---|
| 374 | + String data = null; |
---|
| 375 | + StringBuilder temp = new StringBuilder(); |
---|
| 376 | + sBuilder.append(getString(R.string.ReadData)).append("\n"); |
---|
| 377 | + while ((data = br.readLine()) != null) { |
---|
| 378 | + temp.append(data); |
---|
| 379 | + } |
---|
| 380 | + br.close(); |
---|
| 381 | + Log.e(TAG, "Readfile " + temp.toString()); |
---|
| 382 | + return temp.toString(); |
---|
| 383 | + } catch (Exception e) { |
---|
| 384 | + e.printStackTrace(); |
---|
| 385 | + return null; |
---|
| 386 | + } |
---|
| 387 | + } |
---|
| 388 | + |
---|
| 389 | + /* |
---|
| 390 | + public class SdcardReceiver extends BroadcastReceiver { |
---|
| 391 | + @Override |
---|
| 392 | + public void onReceive(Context context, Intent intent) { |
---|
| 393 | + Log.e(TAG, "onReveive ..... " + intent.getAction()); |
---|
| 394 | + if (intent.getAction().equals(Intent.ACTION_MEDIA_MOUNTED)) { |
---|
| 395 | + Log.e(TAG, "239 ..... " + intent.getAction()); |
---|
| 396 | + testSdcard(); |
---|
| 397 | + testReadAndWrite(); |
---|
| 398 | + } |
---|
| 399 | + } |
---|
| 400 | + } |
---|
| 401 | + */ |
---|
| 402 | +/*StorageEventListener mStorageListener = new StorageEventListener() { |
---|
| 403 | + @Override |
---|
| 404 | + public void onStorageStateChanged(String path, String oldState, String newState) { |
---|
| 405 | + Log.d("xxxxxxxxxxxxxxxxxxxxxxxxxxxx","yyyyyyyyyyyyyyyyyyyyyyyyyyyy"); |
---|
| 406 | + if (path.equals(SDCARD_PATH) && newState.equals(Environment.MEDIA_MOUNTED)) { |
---|
| 407 | + isFindSd=true; |
---|
| 408 | + |
---|
| 409 | + mResult.setText(getString(R.string.resume_findSD)); |
---|
| 410 | + mHandler.sendEmptyMessageDelayed(SEND_REND_WRITE_SD, 100); |
---|
| 411 | + testReadAndWrite(); |
---|
| 412 | + } |
---|
| 413 | + } |
---|
| 414 | + };*/ |
---|
| 415 | + |
---|
| 416 | + public void TestResult(int result) { |
---|
| 417 | + if (result == R_PASS) { |
---|
| 418 | + if(isSDFirstTest){ |
---|
| 419 | + isSDFirstTest=false; |
---|
| 420 | + ((Button) findViewById(R.id.btn_Pass)).performClick(); |
---|
| 421 | + isFindSd = false; |
---|
| 422 | + } |
---|
| 423 | + |
---|
| 424 | + } else if (result == R_FAIL) { |
---|
| 425 | + if(isSDFirstTest){ |
---|
| 426 | + isSDFirstTest=false; |
---|
| 427 | + ((Button) findViewById(R.id.btn_Fail)).performClick(); |
---|
| 428 | + isFindSd = false; |
---|
| 429 | + } |
---|
| 430 | + } |
---|
| 431 | + } |
---|
| 432 | + |
---|
| 433 | + Handler mHandler = new Handler() { |
---|
| 434 | + public void handleMessage(android.os.Message msg) { |
---|
| 435 | + switch (msg.what) { |
---|
| 436 | + case R_PASS: |
---|
| 437 | + TestResult(R_PASS); |
---|
| 438 | + break; |
---|
| 439 | + case R_FAIL: |
---|
| 440 | + TestResult(R_FAIL); |
---|
| 441 | + break; |
---|
| 442 | + |
---|
| 443 | + case SEND_REND_WRITE_SD: |
---|
| 444 | + |
---|
| 445 | + testSdcard(); |
---|
| 446 | + break; |
---|
| 447 | + default: |
---|
| 448 | + dealMessage(msg); |
---|
| 449 | + break; |
---|
| 450 | + } |
---|
| 451 | + }; |
---|
| 452 | + }; |
---|
| 453 | + /* |
---|
| 454 | + public static String getSdCardState() { |
---|
| 455 | + try { |
---|
| 456 | + IMountService mMntSvc = null; |
---|
| 457 | + if (mMntSvc == null) { |
---|
| 458 | + mMntSvc = IMountService.Stub.asInterface(ServiceManager |
---|
| 459 | + .getService("mount")); |
---|
| 460 | + } |
---|
| 461 | + return mMntSvc.getVolumeState(USB_PATH); |
---|
| 462 | + } catch (Exception rex) { |
---|
| 463 | + return Environment.MEDIA_REMOVED; |
---|
| 464 | + } |
---|
| 465 | + |
---|
| 466 | + } |
---|
| 467 | + */ |
---|
| 468 | + //获取外置sd卡路径 |
---|
| 469 | + private static String getStoragePath(Context mContext, boolean is_removale) { |
---|
| 470 | + |
---|
| 471 | + mStorageManager = (StorageManager) mContext.getSystemService(Context.STORAGE_SERVICE); |
---|
| 472 | + Class<?> storageVolumeClazz = null; |
---|
| 473 | + try { |
---|
| 474 | + storageVolumeClazz = Class.forName("android.os.storage.StorageVolume"); |
---|
| 475 | + Method getVolumeList = mStorageManager.getClass().getMethod("getVolumeList"); |
---|
| 476 | + Method getPath = storageVolumeClazz.getMethod("getPath"); |
---|
| 477 | + Method isRemovable = storageVolumeClazz.getMethod("isRemovable"); |
---|
| 478 | + Object result = getVolumeList.invoke(mStorageManager); |
---|
| 479 | + final int length = Array.getLength(result); |
---|
| 480 | + for (int i = 0; i < length; i++) { |
---|
| 481 | + Object storageVolumeElement = Array.get(result, i); |
---|
| 482 | + String path = (String) getPath.invoke(storageVolumeElement); |
---|
| 483 | + boolean removable = (Boolean) isRemovable.invoke(storageVolumeElement); |
---|
| 484 | + if (is_removale == removable) { |
---|
| 485 | + return path; |
---|
| 486 | + } |
---|
| 487 | + } |
---|
| 488 | + } catch (ClassNotFoundException e) { |
---|
| 489 | + e.printStackTrace(); |
---|
| 490 | + } catch (InvocationTargetException e) { |
---|
| 491 | + e.printStackTrace(); |
---|
| 492 | + } catch (NoSuchMethodException e) { |
---|
| 493 | + e.printStackTrace(); |
---|
| 494 | + } catch (IllegalAccessException e) { |
---|
| 495 | + e.printStackTrace(); |
---|
| 496 | + } |
---|
| 497 | + return null; |
---|
| 498 | + } |
---|
| 499 | + |
---|
| 500 | + public void init_StoragePath(Context context) { |
---|
| 501 | + mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE); |
---|
| 502 | + flash_dir = Environment.getExternalStorageDirectory().getPath(); |
---|
| 503 | + final List<VolumeInfo> volumes = mStorageManager.getVolumes(); |
---|
| 504 | + Collections.sort(volumes, VolumeInfo.getDescriptionComparator()); |
---|
| 505 | + for (VolumeInfo vol : volumes) { |
---|
| 506 | + if (vol.getType() != VolumeInfo.TYPE_PUBLIC) { |
---|
| 507 | + continue; |
---|
| 508 | + } |
---|
| 509 | + Log.d(TAG, "Volume path:" + vol.getPath()); |
---|
| 510 | + DiskInfo disk = vol.getDisk(); |
---|
| 511 | + if (null == disk) { |
---|
| 512 | + continue; |
---|
| 513 | + } |
---|
| 514 | + if (STORAGE_TYPE.PCIE == mStorageType) { |
---|
| 515 | + if (null != disk.sysPath && disk.sysPath.contains(".pcie/")) { |
---|
| 516 | + StorageVolume sv = vol.buildStorageVolume(context, |
---|
| 517 | + context.getUserId(), false); |
---|
| 518 | + mTestStorage = new StorageInfo(sv.getPath(), disk.sysPath); |
---|
| 519 | + break; |
---|
| 520 | + } |
---|
| 521 | + } else if (STORAGE_TYPE.SATA == mStorageType) { |
---|
| 522 | + if (null != disk.sysPath && disk.sysPath.contains(".sata/")) { |
---|
| 523 | + StorageVolume sv = vol.buildStorageVolume(context, |
---|
| 524 | + context.getUserId(), false); |
---|
| 525 | + mTestStorage = new StorageInfo(sv.getPath(), disk.sysPath); |
---|
| 526 | + break; |
---|
| 527 | + } |
---|
| 528 | + } else if (STORAGE_TYPE.USB_HOST == mStorageType) { |
---|
| 529 | + if (disk.isUsb() && null != disk.sysPath |
---|
| 530 | + && !disk.sysPath.contains(".pcie/") |
---|
| 531 | + && !disk.sysPath.contains(".sata/")) { |
---|
| 532 | + StorageVolume sv = vol.buildStorageVolume(context, |
---|
| 533 | + context.getUserId(), false); |
---|
| 534 | + mTestStorage = new StorageInfo(sv.getPath(), disk.sysPath); |
---|
| 535 | + break; |
---|
| 536 | + } |
---|
| 537 | + } else if (disk.isSd()) { |
---|
| 538 | + |
---|
| 539 | + } |
---|
| 540 | + } |
---|
| 541 | + Log.d(TAG, "mTestStorageInfo: " + mTestStorage); |
---|
| 542 | + } |
---|
| 543 | +//判断sd卡是否挂载 |
---|
| 544 | +private boolean isSDMounted() { |
---|
| 545 | + boolean isMounted = false; |
---|
| 546 | + StorageManager sm = (StorageManager) getSystemService(Context.STORAGE_SERVICE); |
---|
| 547 | + |
---|
| 548 | + try { |
---|
| 549 | + Method getVolumList = StorageManager.class.getMethod("getVolumeList", null); |
---|
| 550 | + getVolumList.setAccessible(true); |
---|
| 551 | + Object[] results = (Object[])getVolumList.invoke(sm, null); |
---|
| 552 | + if (results != null) { |
---|
| 553 | + for (Object result : results) { |
---|
| 554 | + Method mRemoveable = result.getClass().getMethod("isRemovable", null); |
---|
| 555 | + Boolean isRemovable = (Boolean) mRemoveable.invoke(result, null); |
---|
| 556 | + if (isRemovable) { |
---|
| 557 | + Method getPath = result.getClass().getMethod("getPath", null); |
---|
| 558 | + String path = (String) mRemoveable.invoke(result, null); |
---|
| 559 | + Method getState = sm.getClass().getMethod("getVolumeState", String.class); |
---|
| 560 | + String state = (String)getState.invoke(sm, path); |
---|
| 561 | + if (state.equals(Environment.MEDIA_MOUNTED)) { |
---|
| 562 | + isMounted = true; |
---|
| 563 | + break; |
---|
| 564 | + } |
---|
| 565 | + } |
---|
| 566 | + } |
---|
| 567 | + } |
---|
| 568 | + } catch (NoSuchMethodException e){ |
---|
| 569 | + e.printStackTrace(); |
---|
| 570 | + } catch (IllegalAccessException e){ |
---|
| 571 | + e.printStackTrace(); |
---|
| 572 | + } catch (InvocationTargetException e) { |
---|
| 573 | + e.printStackTrace(); |
---|
| 574 | + } |
---|
| 575 | + |
---|
| 576 | + return isMounted; |
---|
| 577 | + } |
---|
| 578 | + |
---|
| 579 | + @Override |
---|
| 580 | + protected void onDestroy() { |
---|
| 581 | + super.onDestroy(); |
---|
| 582 | + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); |
---|
| 583 | + } |
---|
| 584 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | + |
---|
| 3 | +import android.app.Activity; |
---|
| 4 | +import android.content.Context; |
---|
| 5 | +import android.os.Build; |
---|
| 6 | +import android.os.Bundle; |
---|
| 7 | +import android.os.Environment; |
---|
| 8 | +import android.os.StatFs; |
---|
| 9 | +import android.os.SystemProperties; |
---|
| 10 | +import android.view.KeyEvent; |
---|
| 11 | +import android.widget.TextView; |
---|
| 12 | + |
---|
| 13 | +import java.io.BufferedReader; |
---|
| 14 | +import java.io.File; |
---|
| 15 | +import java.io.FileReader; |
---|
| 16 | +import java.io.IOException; |
---|
| 17 | + |
---|
| 18 | + |
---|
| 19 | +import java.util.regex.Matcher; |
---|
| 20 | +import java.util.regex.Pattern; |
---|
| 21 | + |
---|
| 22 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 23 | + |
---|
| 24 | +public class VersionTestActivity extends Activity |
---|
| 25 | +{ |
---|
| 26 | + private String getFormattedKernelVersion() { |
---|
| 27 | + String procVersionStr; |
---|
| 28 | + |
---|
| 29 | + try { |
---|
| 30 | + BufferedReader reader = new BufferedReader(new FileReader("/proc/version"), 256); |
---|
| 31 | + try { |
---|
| 32 | + procVersionStr = reader.readLine(); |
---|
| 33 | + } finally { |
---|
| 34 | + reader.close(); |
---|
| 35 | + } |
---|
| 36 | + |
---|
| 37 | + final String PROC_VERSION_REGEX = |
---|
| 38 | + "\\w+\\s+" + /* ignore: Linux */ |
---|
| 39 | + "\\w+\\s+" + /* ignore: version */ |
---|
| 40 | + "([^\\s]+)\\s+" + /* group 1: 2.6.22-omap1 */ |
---|
| 41 | + "\\(([^\\s@]+(?:@[^\\s.]+)?)[^)]*\\)\\s+" + /* group 2: (xxxxxx@xxxxx.constant) */ |
---|
| 42 | + "\\((?:[^(]*\\([^)]*\\))?[^)]*\\)\\s+" + /* ignore: (gcc ..) */ |
---|
| 43 | + "([^\\s]+)\\s+" + /* group 3: #26 */ |
---|
| 44 | + "(?:PREEMPT\\s+)?" + /* ignore: PREEMPT (optional) */ |
---|
| 45 | + "(.+)"; /* group 4: date */ |
---|
| 46 | + |
---|
| 47 | + Pattern p = Pattern.compile(PROC_VERSION_REGEX); |
---|
| 48 | + Matcher m = p.matcher(procVersionStr); |
---|
| 49 | + |
---|
| 50 | + if (!m.matches()) { |
---|
| 51 | + |
---|
| 52 | + return "Unavailable"; |
---|
| 53 | + } else if (m.groupCount() < 4) { |
---|
| 54 | + |
---|
| 55 | + return "Unavailable"; |
---|
| 56 | + } else { |
---|
| 57 | + return (new StringBuilder(m.group(1)).append("\n").append( |
---|
| 58 | + m.group(2)).append(" ").append(m.group(3)).append("\n") |
---|
| 59 | + .append(m.group(4))).toString(); |
---|
| 60 | + } |
---|
| 61 | + } catch (IOException e) { |
---|
| 62 | + |
---|
| 63 | + |
---|
| 64 | + return "Unavailable"; |
---|
| 65 | + } |
---|
| 66 | + } |
---|
| 67 | + @Override |
---|
| 68 | + protected void onCreate(Bundle paramBundle) |
---|
| 69 | + { |
---|
| 70 | + super.onCreate(paramBundle); |
---|
| 71 | + |
---|
| 72 | + |
---|
| 73 | + setContentView(R.layout.versiontest); |
---|
| 74 | + |
---|
| 75 | + |
---|
| 76 | + |
---|
| 77 | + TextView firmwareTextView = (TextView)findViewById(R.id.TextFirmwareversion); |
---|
| 78 | + firmwareTextView.setText(Build.VERSION.RELEASE); |
---|
| 79 | + |
---|
| 80 | + TextView kernelTextView = (TextView)findViewById(R.id.TextKernelversion); |
---|
| 81 | + kernelTextView.setText(getFormattedKernelVersion()); |
---|
| 82 | + |
---|
| 83 | + |
---|
| 84 | + |
---|
| 85 | + TextView buildTextView = (TextView)findViewById(R.id.TextBuildversion); |
---|
| 86 | + buildTextView.setText(Build.DISPLAY); |
---|
| 87 | + |
---|
| 88 | + TextView localTextView5 = (TextView)findViewById(R.id.TextBasebandversion); |
---|
| 89 | + String str4 = SystemProperties.get("gsm.version.baseband", "Unavailable"); |
---|
| 90 | + localTextView5.setText(str4); |
---|
| 91 | + |
---|
| 92 | +// checkFlashSize(); |
---|
| 93 | + |
---|
| 94 | + ControlButtonUtil.initControlButtonView(this); |
---|
| 95 | + } |
---|
| 96 | + public boolean dispatchKeyEvent(KeyEvent event) { |
---|
| 97 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
---|
| 98 | + return false; |
---|
| 99 | + } |
---|
| 100 | + return super.dispatchKeyEvent(event); |
---|
| 101 | + } |
---|
| 102 | + |
---|
| 103 | + |
---|
| 104 | +/* Flash test Used for mid |
---|
| 105 | + * |
---|
| 106 | + public void checkFlashSize() { |
---|
| 107 | + TextView flashsizeView = (TextView)findViewById(R.id.FlashSize); |
---|
| 108 | + |
---|
| 109 | + String path = getDirectory("FLASH_STORAGE", "/flash").getPath(); |
---|
| 110 | + StatFs stat = new StatFs(path); |
---|
| 111 | + long blockSize = stat.getBlockSize(); |
---|
| 112 | + long availableBlocks = stat.getAvailableBlocks(); |
---|
| 113 | + long availableSize = (availableBlocks * blockSize)/(1024 * 1024); //MBtye |
---|
| 114 | + long freeBlocks = stat.getFreeBlocks(); |
---|
| 115 | + long freeSize = (freeBlocks * blockSize)/(1024 * 1024); //MBtye |
---|
| 116 | + |
---|
| 117 | + flashsizeView.setText(String.valueOf(availableSize)+" MB"); |
---|
| 118 | + } |
---|
| 119 | + |
---|
| 120 | + static File getDirectory(String variableName, String defaultPath) { |
---|
| 121 | + String path = System.getenv(variableName); |
---|
| 122 | + return path == null ? new File(defaultPath) : new File(path); |
---|
| 123 | + } |
---|
| 124 | + |
---|
| 125 | + */ |
---|
| 126 | + |
---|
| 127 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest; |
---|
| 2 | + |
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN; |
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; |
---|
| 5 | + |
---|
| 6 | +import com.DeviceTest.helper.ControlButtonUtil; |
---|
| 7 | + |
---|
| 8 | +import android.app.Activity; |
---|
| 9 | +import android.os.Bundle; |
---|
| 10 | +import android.os.Vibrator; |
---|
| 11 | +import android.view.KeyEvent; |
---|
| 12 | +import android.widget.TextView; |
---|
| 13 | + |
---|
| 14 | +public class VibrationTestActivity extends Activity { |
---|
| 15 | + |
---|
| 16 | + private Vibrator mVibrator; |
---|
| 17 | + |
---|
| 18 | + |
---|
| 19 | + protected void onCreate(Bundle paramBundle) { |
---|
| 20 | + super.onCreate(paramBundle); |
---|
| 21 | + |
---|
| 22 | + |
---|
| 23 | + setTitle(getTitle() + "----(" |
---|
| 24 | + + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")"); |
---|
| 25 | + //requestWindowFeature(Window.FEATURE_NO_TITLE); |
---|
| 26 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON); |
---|
| 27 | + |
---|
| 28 | + setContentView(R.layout.vibrationtest); |
---|
| 29 | + |
---|
| 30 | + TextView txtTitle = (TextView) findViewById(R.id.txtTitle); |
---|
| 31 | + TextView txtContent = (TextView) findViewById(R.id.txtContent); |
---|
| 32 | + txtTitle.setText(R.string.VibrationTitle); |
---|
| 33 | + txtContent.setText(R.string.VibrationContent); |
---|
| 34 | + this.mVibrator = (Vibrator) getSystemService("vibrator"); |
---|
| 35 | + ControlButtonUtil.initControlButtonView(this); |
---|
| 36 | + |
---|
| 37 | + } |
---|
| 38 | + |
---|
| 39 | + protected void onPause() { |
---|
| 40 | + super.onPause(); |
---|
| 41 | + this.mVibrator.cancel(); |
---|
| 42 | + } |
---|
| 43 | + |
---|
| 44 | + protected void onResume() { |
---|
| 45 | + super.onResume(); |
---|
| 46 | + long pattern[] = { 500L, 500L }; |
---|
| 47 | + this.mVibrator.vibrate(pattern, 0); |
---|
| 48 | + |
---|
| 49 | + } |
---|
| 50 | + |
---|
| 51 | + public boolean dispatchKeyEvent(KeyEvent event) { |
---|
| 52 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
---|
| 53 | + return false; |
---|
| 54 | + } |
---|
| 55 | + return super.dispatchKeyEvent(event); |
---|
| 56 | + } |
---|
| 57 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest;
|
---|
| 2 | +
|
---|
| 3 | +import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
---|
| 4 | +import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
---|
| 5 | +
|
---|
| 6 | +import java.io.IOException;
|
---|
| 7 | +import java.io.InputStream;
|
---|
| 8 | +import java.net.HttpURLConnection;
|
---|
| 9 | +import java.net.MalformedURLException;
|
---|
| 10 | +import java.net.URL;
|
---|
| 11 | +import java.net.URLConnection;
|
---|
| 12 | +import java.util.ArrayList;
|
---|
| 13 | +import java.util.Arrays;
|
---|
| 14 | +import java.util.Collection;
|
---|
| 15 | +import java.util.Collections;
|
---|
| 16 | +import java.util.Comparator;
|
---|
| 17 | +import java.util.List;
|
---|
| 18 | +
|
---|
| 19 | +import org.apache.http.HttpClientConnection;
|
---|
| 20 | +import org.apache.http.HttpConnection;
|
---|
| 21 | +import org.apache.http.HttpResponse;
|
---|
| 22 | +import org.apache.http.client.HttpClient;
|
---|
| 23 | +import org.apache.http.client.methods.HttpGet;
|
---|
| 24 | +import org.apache.http.impl.client.DefaultHttpClient;
|
---|
| 25 | +
|
---|
| 26 | +import com.DeviceTest.helper.ControlButtonUtil;
|
---|
| 27 | +import com.DeviceTest.helper.SystemUtil;
|
---|
| 28 | +
|
---|
| 29 | +import android.app.Activity;
|
---|
| 30 | +import android.content.BroadcastReceiver;
|
---|
| 31 | +import android.content.Context;
|
---|
| 32 | +import android.content.Intent;
|
---|
| 33 | +import android.content.IntentFilter;
|
---|
| 34 | +import android.net.ConnectivityManager;
|
---|
| 35 | +import android.net.NetworkInfo;
|
---|
| 36 | +import android.net.Uri;
|
---|
| 37 | +import android.net.wifi.ScanResult;
|
---|
| 38 | +import android.net.wifi.WifiConfiguration;
|
---|
| 39 | +import android.net.wifi.WifiInfo;
|
---|
| 40 | +import android.net.wifi.WifiManager;
|
---|
| 41 | +import android.os.Bundle;
|
---|
| 42 | +import android.os.Handler;
|
---|
| 43 | +import android.os.Looper;
|
---|
| 44 | +import android.os.Message;
|
---|
| 45 | +import android.os.Parcelable;
|
---|
| 46 | +import android.util.Log;
|
---|
| 47 | +import android.view.KeyEvent;
|
---|
| 48 | +import android.view.View;
|
---|
| 49 | +import android.view.Window;
|
---|
| 50 | +//import android.webkit.WebView;
|
---|
| 51 | +import android.widget.ProgressBar;
|
---|
| 52 | +import android.widget.RemoteViews;
|
---|
| 53 | +import android.widget.TextView;
|
---|
| 54 | +
|
---|
| 55 | +public class WifiTestActivity extends Activity {
|
---|
| 56 | +
|
---|
| 57 | + private static final String TAG = WifiTestActivity.class.getSimpleName();
|
---|
| 58 | + private static final String HTTP_TEST_URL = "http://172.16.9.1/";
|
---|
| 59 | + private static final String PING_TEST_ADDR = "172.16.9.1";
|
---|
| 60 | + private static final int TEST_FAILED_DELAY = 5000;
|
---|
| 61 | + private static final int MSG_ERROR = 1;
|
---|
| 62 | + private static final int MSG_HTTP_TEST = 2;
|
---|
| 63 | + private static final int MSG_SCAN = 3;
|
---|
| 64 | + private static final int MSG_HTTP_TEST_PASS = 4;
|
---|
| 65 | + private static final int MSG_HTTP_TEST_FAILED = 5;
|
---|
| 66 | + private static final int MSG_FAIL = 6;
|
---|
| 67 | + private static final int MSG_PING_TEST_PASS = 7;
|
---|
| 68 | + private static final int MSG_PING_TEST_FAILED = 8;
|
---|
| 69 | + private static final int MSG_PING_TEST = 9;
|
---|
| 70 | + private static final int MSG_FINISH_TEST = 10;
|
---|
| 71 | + private Handler mHandler;
|
---|
| 72 | + private BroadcastReceiver mReceiver;
|
---|
| 73 | + TextView mResult;
|
---|
| 74 | + TextView mInfoText;
|
---|
| 75 | + boolean stop = false;
|
---|
| 76 | + private boolean mReadyToTest = false;
|
---|
| 77 | + TextView mText;
|
---|
| 78 | + TextView mTitle;
|
---|
| 79 | + ProgressBar wifiProgressBar;
|
---|
| 80 | +
|
---|
| 81 | + private List<String> mWifiList;
|
---|
| 82 | + private WifiManager mWifiManager;
|
---|
| 83 | +
|
---|
| 84 | + private final static String ERRMSG = "Wifi test failed!";
|
---|
| 85 | +
|
---|
| 86 | + NetworkInfo mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0, "WIFI", "");
|
---|
| 87 | +
|
---|
| 88 | + public WifiTestActivity() {
|
---|
| 89 | +
|
---|
| 90 | + this.mWifiList = new ArrayList<String>();
|
---|
| 91 | +
|
---|
| 92 | + this.mReceiver = new MyBroadcastReceiver();
|
---|
| 93 | +
|
---|
| 94 | + mHandler = new MyHandler();
|
---|
| 95 | + }
|
---|
| 96 | +
|
---|
| 97 | + //
|
---|
| 98 | + protected void onCreate(Bundle savedInstanceState) {
|
---|
| 99 | +
|
---|
| 100 | + super.onCreate(savedInstanceState);
|
---|
| 101 | + // requestWindowFeature(Window.FEATURE_NO_TITLE);
|
---|
| 102 | + getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
|
---|
| 103 | + setContentView(R.layout.wifitest);
|
---|
| 104 | +
|
---|
| 105 | + this.mResult = (TextView) findViewById(R.id.wifiresultText);
|
---|
| 106 | + this.mResult.setVisibility(View.VISIBLE);
|
---|
| 107 | + // this.mResult.setGravity(17);
|
---|
| 108 | + mInfoText = (TextView) findViewById(R.id.wifiInfoText);
|
---|
| 109 | +
|
---|
| 110 | + wifiProgressBar = (ProgressBar) findViewById(R.id.wifiprogress);
|
---|
| 111 | + wifiProgressBar.setVisibility(View.VISIBLE);
|
---|
| 112 | + ControlButtonUtil.initControlButtonView(this);
|
---|
| 113 | +
|
---|
| 114 | + this.mWifiManager = (WifiManager) getSystemService("wifi");
|
---|
| 115 | + findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
|
---|
| 116 | + }
|
---|
| 117 | +
|
---|
| 118 | + protected void onResume() {
|
---|
| 119 | + super.onResume();
|
---|
| 120 | + IntentFilter localIntentFilter = new IntentFilter();
|
---|
| 121 | + localIntentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
|
---|
| 122 | + localIntentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
|
---|
| 123 | + localIntentFilter
|
---|
| 124 | + .addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
|
---|
| 125 | + localIntentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
---|
| 126 | + registerReceiver(mReceiver, localIntentFilter);
|
---|
| 127 | + this.mWifiList.clear();
|
---|
| 128 | +
|
---|
| 129 | + stop = false;
|
---|
| 130 | + Log.i("Jeffy", "try to enable wifi");
|
---|
| 131 | + mWifiManager.setWifiEnabled(true);
|
---|
| 132 | + mHandler.sendEmptyMessage(MSG_SCAN);
|
---|
| 133 | +
|
---|
| 134 | + Log.i("Jeffy", "start test");
|
---|
| 135 | + }
|
---|
| 136 | +
|
---|
| 137 | + public void onPause() {
|
---|
| 138 | + stop = true;
|
---|
| 139 | + super.onPause();
|
---|
| 140 | + if (this.mWifiManager == null) {
|
---|
| 141 | + return;
|
---|
| 142 | + }
|
---|
| 143 | +
|
---|
| 144 | + Log.i("Jeffy", "end test");
|
---|
| 145 | + this.mHandler.removeMessages(MSG_SCAN);
|
---|
| 146 | + this.mHandler.removeMessages(MSG_ERROR);
|
---|
| 147 | +
|
---|
| 148 | + unregisterReceiver(mReceiver);
|
---|
| 149 | + // mWifiManager.setWifiEnabled(false);
|
---|
| 150 | + mHandler.removeMessages(MSG_FAIL);
|
---|
| 151 | + }
|
---|
| 152 | +
|
---|
| 153 | + class MyHandler extends Handler {
|
---|
| 154 | +
|
---|
| 155 | + public void handleMessage(Message msg) {
|
---|
| 156 | + if (stop) {
|
---|
| 157 | + return;
|
---|
| 158 | + }
|
---|
| 159 | + switch (msg.what) {
|
---|
| 160 | +
|
---|
| 161 | + case MSG_SCAN:
|
---|
| 162 | + Log.i(TAG, "try to scan");
|
---|
| 163 | + removeMessages(MSG_SCAN);
|
---|
| 164 | + mWifiManager.startScan();
|
---|
| 165 | + break;
|
---|
| 166 | +
|
---|
| 167 | + case MSG_HTTP_TEST:
|
---|
| 168 | + removeMessages(MSG_HTTP_TEST);
|
---|
| 169 | + if (mReadyToTest) {
|
---|
| 170 | + Log.i("Jeffy", "do http test:" + HTTP_TEST_URL);
|
---|
| 171 | + mInfoText.setText(mInfoText.getText() + "\ntesting "
|
---|
| 172 | + + HTTP_TEST_URL);
|
---|
| 173 | + new Thread(new Runnable() {
|
---|
| 174 | +
|
---|
| 175 | + public void run() {
|
---|
| 176 | +
|
---|
| 177 | + mHandler.sendEmptyMessage(httpClientTest() ? MSG_HTTP_TEST_PASS
|
---|
| 178 | + : MSG_HTTP_TEST_FAILED);
|
---|
| 179 | + }
|
---|
| 180 | + }).start();
|
---|
| 181 | + }
|
---|
| 182 | + break;
|
---|
| 183 | +
|
---|
| 184 | + case MSG_PING_TEST:
|
---|
| 185 | + removeMessages(MSG_PING_TEST);
|
---|
| 186 | + if (mReadyToTest) {
|
---|
| 187 | + Log.i("Jeffy", "do ping test:" + PING_TEST_ADDR);
|
---|
| 188 | + mInfoText.setText(mInfoText.getText() + "\ntesting "
|
---|
| 189 | + + PING_TEST_ADDR);
|
---|
| 190 | + new Thread(new Runnable() {
|
---|
| 191 | +
|
---|
| 192 | + public void run() {
|
---|
| 193 | +
|
---|
| 194 | + mHandler.sendEmptyMessage(pingTest() ? MSG_PING_TEST_PASS
|
---|
| 195 | + : MSG_PING_TEST_FAILED);
|
---|
| 196 | + }
|
---|
| 197 | + }).start();
|
---|
| 198 | + }
|
---|
| 199 | + break;
|
---|
| 200 | + case MSG_PING_TEST_PASS: {
|
---|
| 201 | + mInfoText.setText(mInfoText.getText() + "\n" + getString(R.string.WifiPing)+getString(R.string.btnPassText));
|
---|
| 202 | + wifiProgressBar.setVisibility(View.GONE);
|
---|
| 203 | + mHandler.sendEmptyMessageDelayed(MSG_FINISH_TEST, 2000);
|
---|
| 204 | + findViewById(R.id.btn_Pass).performClick();
|
---|
| 205 | + break;
|
---|
| 206 | + }
|
---|
| 207 | + case MSG_PING_TEST_FAILED: {
|
---|
| 208 | + mInfoText.setText(mInfoText.getText() + "\n" + getString(R.string.WifiPing)+getString(R.string.btnFailText));
|
---|
| 209 | + wifiProgressBar.setVisibility(View.GONE);
|
---|
| 210 | + mHandler.sendEmptyMessageDelayed(MSG_FAIL,
|
---|
| 211 | + TEST_FAILED_DELAY);
|
---|
| 212 | + break;
|
---|
| 213 | + }
|
---|
| 214 | + case MSG_HTTP_TEST_PASS: {
|
---|
| 215 | + mInfoText.setText(mInfoText.getText() + "\n" + getString(R.string.WifiHttp)+getString(R.string.btnPassText));
|
---|
| 216 | + wifiProgressBar.setVisibility(View.GONE);
|
---|
| 217 | + findViewById(R.id.btn_Pass).performClick();
|
---|
| 218 | + break;
|
---|
| 219 | + }
|
---|
| 220 | +
|
---|
| 221 | + case MSG_HTTP_TEST_FAILED: {
|
---|
| 222 | + mInfoText.setText(getString(R.string.WifiHttp)+getString(R.string.btnFailText));
|
---|
| 223 | + wifiProgressBar.setVisibility(View.GONE);
|
---|
| 224 | + mHandler.sendEmptyMessageDelayed(MSG_FAIL,
|
---|
| 225 | + TEST_FAILED_DELAY);
|
---|
| 226 | + break;
|
---|
| 227 | + }
|
---|
| 228 | +
|
---|
| 229 | + case MSG_ERROR:
|
---|
| 230 | +
|
---|
| 231 | + removeMessages(MSG_ERROR);
|
---|
| 232 | + wifiProgressBar.setVisibility(View.GONE);
|
---|
| 233 | + mResult.setText(getString(R.string.WifiError));
|
---|
| 234 | + mHandler.sendEmptyMessageDelayed(MSG_FAIL,
|
---|
| 235 | + TEST_FAILED_DELAY);
|
---|
| 236 | + break;
|
---|
| 237 | + case MSG_FAIL:
|
---|
| 238 | + removeMessages(MSG_FAIL);
|
---|
| 239 | + wifiProgressBar.setVisibility(View.GONE);
|
---|
| 240 | + findViewById(R.id.btn_Fail).performClick();
|
---|
| 241 | + break;
|
---|
| 242 | + case MSG_FINISH_TEST:
|
---|
| 243 | + wifiProgressBar.setVisibility(View.GONE);
|
---|
| 244 | + findViewById(R.id.btn_Pass).performClick();
|
---|
| 245 | + break;
|
---|
| 246 | + }
|
---|
| 247 | + }
|
---|
| 248 | + }
|
---|
| 249 | +
|
---|
| 250 | + class MyBroadcastReceiver extends BroadcastReceiver {
|
---|
| 251 | +
|
---|
| 252 | + public void onReceive(Context context, Intent intent) {
|
---|
| 253 | + if (stop) {
|
---|
| 254 | + return;
|
---|
| 255 | + }
|
---|
| 256 | + String action = intent.getAction();
|
---|
| 257 | +
|
---|
| 258 | + Log.i("Jeffy", "action:" + action);
|
---|
| 259 | +
|
---|
| 260 | + if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
|
---|
| 261 | + int state = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
|
---|
| 262 | + WifiManager.WIFI_STATE_UNKNOWN);
|
---|
| 263 | + if (state == WifiManager.WIFI_STATE_ENABLED) {
|
---|
| 264 | + mHandler.sendEmptyMessage(MSG_SCAN);
|
---|
| 265 | + }
|
---|
| 266 | + }
|
---|
| 267 | +
|
---|
| 268 | + if (WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION.equals(action)) {
|
---|
| 269 | + boolean connected = intent.getBooleanExtra(
|
---|
| 270 | + WifiManager.EXTRA_SUPPLICANT_CONNECTED, false);
|
---|
| 271 | + if (connected && mReadyToTest) {
|
---|
| 272 | + Log.i("Jeffy", "already connect to:"
|
---|
| 273 | + + mWifiManager.getConnectionInfo().getSSID());
|
---|
| 274 | + mInfoText.setText("connect to "
|
---|
| 275 | + + mWifiManager.getConnectionInfo().getSSID());
|
---|
| 276 | +// mHandler.sendEmptyMessage(MSG_PING_TEST); //change no pingtest
|
---|
| 277 | + mHandler.sendEmptyMessageDelayed(MSG_FINISH_TEST, 3000);
|
---|
| 278 | + }
|
---|
| 279 | + }
|
---|
| 280 | +
|
---|
| 281 | + if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) {
|
---|
| 282 | + mNetworkInfo = (NetworkInfo) intent.getParcelableExtra(
|
---|
| 283 | + WifiManager.EXTRA_NETWORK_INFO);
|
---|
| 284 | + // reset & clear notification on a network connect & disconnect
|
---|
| 285 | + switch(mNetworkInfo.getDetailedState()) {
|
---|
| 286 | + case CONNECTED:
|
---|
| 287 | + Log.i("Jeffy", "connect to:"
|
---|
| 288 | + + mWifiManager.getConnectionInfo().getSSID());
|
---|
| 289 | + mInfoText.setText("Connected to "
|
---|
| 290 | + + mWifiManager.getConnectionInfo().getSSID());
|
---|
| 291 | + mHandler.sendEmptyMessageDelayed(MSG_FINISH_TEST, 3000);
|
---|
| 292 | + break;
|
---|
| 293 | + }
|
---|
| 294 | + }
|
---|
| 295 | +
|
---|
| 296 | + if (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION.equals(action)) {
|
---|
| 297 | + List<ScanResult> resultList = mWifiManager.getScanResults();
|
---|
| 298 | + Collections.sort(resultList, new Comparator<ScanResult>() {
|
---|
| 299 | +
|
---|
| 300 | + public int compare(ScanResult s1, ScanResult s2) {
|
---|
| 301 | + return s2.level - s1.level;
|
---|
| 302 | + }
|
---|
| 303 | + });
|
---|
| 304 | +
|
---|
| 305 | + if ((resultList != null) && (!resultList.isEmpty())) {
|
---|
| 306 | +
|
---|
| 307 | + String str3 = getString(R.string.wififindtest);
|
---|
| 308 | + StringBuilder sb = new StringBuilder().append(str3).append(
|
---|
| 309 | + "\n");
|
---|
| 310 | + ScanResult selectAp = null;
|
---|
| 311 | + for (ScanResult scanResult : resultList) {
|
---|
| 312 | + sb.append(
|
---|
| 313 | + scanResult.SSID
|
---|
| 314 | + + "\t- "
|
---|
| 315 | + + scanResult.capabilities
|
---|
| 316 | + + "\t- level:"
|
---|
| 317 | + + WifiManager.calculateSignalLevel(
|
---|
| 318 | + scanResult.level, 4)).append(
|
---|
| 319 | + "\n");
|
---|
| 320 | + if (scanResult.capabilities.length() < 6) {
|
---|
| 321 | + if (null == selectAp
|
---|
| 322 | + || selectAp.level < scanResult.level) {
|
---|
| 323 | + selectAp = scanResult;
|
---|
| 324 | + }
|
---|
| 325 | + }
|
---|
| 326 | + }
|
---|
| 327 | + mResult.setText(sb.toString());
|
---|
| 328 | +
|
---|
| 329 | + mReadyToTest = true;
|
---|
| 330 | +
|
---|
| 331 | + if (mWifiManager.getConnectionInfo().getIpAddress() != 0) {
|
---|
| 332 | + Log.i("Jeffy", "--already connect to:"
|
---|
| 333 | + + mWifiManager.getConnectionInfo().getSSID());
|
---|
| 334 | + mInfoText.setText(getString(R.string.WifiConnect)
|
---|
| 335 | + + mWifiManager.getConnectionInfo().getSSID());
|
---|
| 336 | +// mHandler.sendEmptyMessage(MSG_PING_TEST); //change no pingtest
|
---|
| 337 | + mHandler.sendEmptyMessageDelayed(MSG_FINISH_TEST, 3000);
|
---|
| 338 | + return;
|
---|
| 339 | + }
|
---|
| 340 | + Log.i("Jeffy", "--selected ap:" + selectAp);
|
---|
| 341 | + if (null == selectAp) {
|
---|
| 342 | + mInfoText.setText(getString(R.string.WifiConnectErr));
|
---|
| 343 | + wifiProgressBar.setVisibility(View.GONE);
|
---|
| 344 | + //mHandler.sendEmptyMessageDelayed(MSG_FAIL,
|
---|
| 345 | + // TEST_FAILED_DELAY);
|
---|
| 346 | +
|
---|
| 347 | + mHandler.sendEmptyMessageDelayed(MSG_PING_TEST_PASS, 500);
|
---|
| 348 | + return;
|
---|
| 349 | + }
|
---|
| 350 | +
|
---|
| 351 | + int networkId = getNetworkId(selectAp.BSSID, selectAp.SSID);
|
---|
| 352 | + mInfoText.setText(getString(R.string.WifiTry) + " " + selectAp.SSID);
|
---|
| 353 | + Log.i("Jeffy", "--try connect to ap:" + selectAp.SSID);
|
---|
| 354 | + mWifiManager.enableNetwork(networkId, true);
|
---|
| 355 | +
|
---|
| 356 | + //
|
---|
| 357 | + // wifiProgressBar.setVisibility(View.GONE);
|
---|
| 358 | + // isTestFinish = true;
|
---|
| 359 | + // mResult.setText("Find wifi network...\n Pass!");
|
---|
| 360 | +
|
---|
| 361 | + mHandler.sendEmptyMessageDelayed(MSG_PING_TEST_PASS, 500);
|
---|
| 362 | + }
|
---|
| 363 | + }
|
---|
| 364 | +
|
---|
| 365 | + }
|
---|
| 366 | + }
|
---|
| 367 | +
|
---|
| 368 | + private int getNetworkId(String BSSID, String SSID) {
|
---|
| 369 | + for (WifiConfiguration wifiConfiguration : mWifiManager
|
---|
| 370 | + .getConfiguredNetworks()) {
|
---|
| 371 | + if (BSSID.equals(wifiConfiguration.BSSID)) {
|
---|
| 372 | + Log.i("Jeffy", "--get existed config:" + wifiConfiguration.SSID);
|
---|
| 373 | + return wifiConfiguration.networkId;
|
---|
| 374 | + }
|
---|
| 375 | + }
|
---|
| 376 | +
|
---|
| 377 | + WifiConfiguration wc = new WifiConfiguration();
|
---|
| 378 | + wc.BSSID = BSSID;
|
---|
| 379 | + wc.SSID = "\"" + SSID + "\"";
|
---|
| 380 | + wc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
|
---|
| 381 | + wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
|
---|
| 382 | + wc.status = WifiConfiguration.Status.ENABLED;
|
---|
| 383 | + wc.networkId = mWifiManager.addNetwork(wc);
|
---|
| 384 | + Log.i("Jeffy", "--new config:" + wc.SSID);
|
---|
| 385 | + return wc.networkId;
|
---|
| 386 | + }
|
---|
| 387 | +
|
---|
| 388 | + private boolean httpClientTest() {
|
---|
| 389 | + HttpClient client = new DefaultHttpClient();
|
---|
| 390 | + try {
|
---|
| 391 | + // TODO: Hardcoded for now, make it UI configurable
|
---|
| 392 | + HttpGet request = new HttpGet(HTTP_TEST_URL);
|
---|
| 393 | + HttpResponse response = client.execute(request);
|
---|
| 394 | + Log.i("Jeffy", "http result code:"
|
---|
| 395 | + + response.getStatusLine().getStatusCode());
|
---|
| 396 | + if (response.getStatusLine().getStatusCode() == 401) {
|
---|
| 397 | + request.abort();
|
---|
| 398 | + return true;
|
---|
| 399 | + } else {
|
---|
| 400 | + request.abort();
|
---|
| 401 | + return false;
|
---|
| 402 | + }
|
---|
| 403 | + } catch (IOException e) {
|
---|
| 404 | + Log.i("Jeffy", "http exception");
|
---|
| 405 | + e.printStackTrace();
|
---|
| 406 | + return false;
|
---|
| 407 | + } finally {
|
---|
| 408 | + }
|
---|
| 409 | + }
|
---|
| 410 | +
|
---|
| 411 | + private boolean pingTest() {
|
---|
| 412 | +// int status = SystemUtil.execShellCmdForStatue("ping -c 1 -w 5 "
|
---|
| 413 | +// + PING_TEST_ADDR);
|
---|
| 414 | +// return (status == 0);
|
---|
| 415 | + boolean ret = false;
|
---|
| 416 | + URL serverURL;
|
---|
| 417 | + try {
|
---|
| 418 | + serverURL = new URL("http://www.baidu.com");
|
---|
| 419 | + Log.d(TAG, " __________________-------- serverURL = " + serverURL.toString());
|
---|
| 420 | + // connect to server
|
---|
| 421 | + URLConnection uc2 = serverURL.openConnection();
|
---|
| 422 | + HttpURLConnection conn = (HttpURLConnection) uc2;
|
---|
| 423 | + Log.d(TAG, " __________________--------00 serverURL = " + serverURL.toString());
|
---|
| 424 | + uc2.setAllowUserInteraction(true);
|
---|
| 425 | + uc2.setConnectTimeout(55000);
|
---|
| 426 | + uc2.setDoInput(true);
|
---|
| 427 | + uc2.setDoOutput(true);
|
---|
| 428 | +// conn.setConnectTimeout(1000);
|
---|
| 429 | + conn.setReadTimeout(1000);
|
---|
| 430 | + int numBytesRead = 0;
|
---|
| 431 | + int allBytesRead = 0;
|
---|
| 432 | + Log.d(TAG, " __________________--------11 conn.getContentLength() = " + conn.getContentLength());
|
---|
| 433 | + InputStream in = conn.getInputStream();
|
---|
| 434 | + byte[] buffer = new byte[4096];
|
---|
| 435 | + do {
|
---|
| 436 | + numBytesRead = in.read(buffer);
|
---|
| 437 | + allBytesRead = allBytesRead + numBytesRead;
|
---|
| 438 | + } while (numBytesRead > 0);
|
---|
| 439 | + Log.d(TAG, " __________________-------- allBytesRead = " + allBytesRead + " " + conn.getContentLength());
|
---|
| 440 | + if(allBytesRead > 10)
|
---|
| 441 | + ret = true;
|
---|
| 442 | + } catch (MalformedURLException e) {
|
---|
| 443 | + // TODO Auto-generated catch block
|
---|
| 444 | + e.printStackTrace();
|
---|
| 445 | + } catch (IOException e) {
|
---|
| 446 | + // TODO Auto-generated catch block
|
---|
| 447 | + e.printStackTrace();
|
---|
| 448 | + }
|
---|
| 449 | + return ret;
|
---|
| 450 | + }
|
---|
| 451 | +
|
---|
| 452 | + public boolean dispatchKeyEvent(KeyEvent event) {
|
---|
| 453 | + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
---|
| 454 | + return false;
|
---|
| 455 | + }
|
---|
| 456 | + return super.dispatchKeyEvent(event);
|
---|
| 457 | + }
|
---|
| 458 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.helper;
|
---|
| 2 | +
|
---|
| 3 | +import android.os.SystemProperties;
|
---|
| 4 | +import android.text.TextUtils;
|
---|
| 5 | +
|
---|
| 6 | +public class ConfigUtil {
|
---|
| 7 | + public static int ANDROID_SDK_VERSION_P = 28;
|
---|
| 8 | + public static int ANDROID_SDK_VERSION_R = 30;
|
---|
| 9 | + public static int ANDROID_SDK_VERSION_S = 31;
|
---|
| 10 | +
|
---|
| 11 | + private static String mProductModel;
|
---|
| 12 | +
|
---|
| 13 | + public static boolean isSpecialEvb() {
|
---|
| 14 | + String platform = SystemProperties.get("ro.board.platform");
|
---|
| 15 | + if ("rk356x".equals(platform)) {
|
---|
| 16 | + if (TextUtils.isEmpty(mProductModel)) {
|
---|
| 17 | + mProductModel = SystemUtil.execShellCmd(
|
---|
| 18 | + "cat /sys/firmware/devicetree/base/model");
|
---|
| 19 | + }
|
---|
| 20 | + if (null != mProductModel) {
|
---|
| 21 | + return mProductModel.contains("EVB");
|
---|
| 22 | + }
|
---|
| 23 | + }
|
---|
| 24 | + return false;
|
---|
| 25 | + }
|
---|
| 26 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.helper;
|
---|
| 2 | +
|
---|
| 3 | +import com.DeviceTest.DeviceTest;
|
---|
| 4 | +import com.DeviceTest.R;
|
---|
| 5 | +import com.DeviceTest.R.id;
|
---|
| 6 | +import com.DeviceTest.helper.TestCase.RESULT;
|
---|
| 7 | +
|
---|
| 8 | +import android.app.Activity;
|
---|
| 9 | +import android.app.NotificationManager;
|
---|
| 10 | +import android.content.Intent;
|
---|
| 11 | +
|
---|
| 12 | +import android.util.Log;
|
---|
| 13 | +import android.view.View;
|
---|
| 14 | +
|
---|
| 15 | +import android.widget.Button;
|
---|
| 16 | +
|
---|
| 17 | +public class ControlButtonUtil {
|
---|
| 18 | + static Activity mActivity;
|
---|
| 19 | + static ControlButtonUtil mControlButtonView;
|
---|
| 20 | + static NotificationManager mNotificationManager;
|
---|
| 21 | + static Intent resultIntent = new Intent();
|
---|
| 22 | + private static String mAction;
|
---|
| 23 | + public ControlButtonUtil(Activity paramActivity) {
|
---|
| 24 | + resultIntent.removeExtra(DeviceTest.EXTRA_TEST_RESULT_INFO);
|
---|
| 25 | + mActivity = paramActivity;
|
---|
| 26 | +
|
---|
| 27 | + Button returnButton = (Button) mActivity.findViewById(R.id.btn_return);
|
---|
| 28 | +
|
---|
| 29 | + returnButton.setOnClickListener(new Button.OnClickListener() {
|
---|
| 30 | + public void onClick(View v) {
|
---|
| 31 | + ControlButtonUtil.mActivity.setResult(mActivity.RESULT_OK,
|
---|
| 32 | + resultIntent);
|
---|
| 33 | + if (ControlButtonUtil.mNotificationManager != null)
|
---|
| 34 | + ControlButtonUtil.mNotificationManager.cancelAll();
|
---|
| 35 | + stopService();
|
---|
| 36 | + ControlButtonUtil.mActivity.finish();
|
---|
| 37 | + }
|
---|
| 38 | + });
|
---|
| 39 | +
|
---|
| 40 | + Button passButton = (Button) mActivity.findViewById(R.id.btn_Pass);
|
---|
| 41 | +
|
---|
| 42 | + passButton.setOnClickListener(new Button.OnClickListener() {
|
---|
| 43 | + public void onClick(View v) {
|
---|
| 44 | + ControlButtonUtil.mActivity.setResult(RESULT.OK.ordinal(),
|
---|
| 45 | + resultIntent);
|
---|
| 46 | + if (ControlButtonUtil.mNotificationManager != null)
|
---|
| 47 | + ControlButtonUtil.mNotificationManager.cancelAll();
|
---|
| 48 | + stopService();
|
---|
| 49 | + ControlButtonUtil.mActivity.finish();
|
---|
| 50 | + }
|
---|
| 51 | + });
|
---|
| 52 | +
|
---|
| 53 | + Button failedButton = (Button) mActivity.findViewById(R.id.btn_Fail);
|
---|
| 54 | +
|
---|
| 55 | + failedButton.setOnClickListener(new Button.OnClickListener() {
|
---|
| 56 | + public void onClick(View v) {
|
---|
| 57 | + ControlButtonUtil.mActivity.setResult(RESULT.NG.ordinal(),
|
---|
| 58 | + resultIntent);
|
---|
| 59 | + if (ControlButtonUtil.mNotificationManager != null)
|
---|
| 60 | + ControlButtonUtil.mNotificationManager.cancelAll();
|
---|
| 61 | + stopService();
|
---|
| 62 | + ControlButtonUtil.mActivity.finish();
|
---|
| 63 | +
|
---|
| 64 | + }
|
---|
| 65 | + });
|
---|
| 66 | +
|
---|
| 67 | + Button skipButton = (Button) mActivity.findViewById(R.id.btn_Skip);
|
---|
| 68 | +
|
---|
| 69 | + skipButton.setOnClickListener(new Button.OnClickListener() {
|
---|
| 70 | + public void onClick(View v) {
|
---|
| 71 | +// ControlButtonUtil.mActivity.setResult(RESULT.SKIP.ordinal(),
|
---|
| 72 | +// resultIntent);
|
---|
| 73 | +// if (ControlButtonUtil.mNotificationManager != null)
|
---|
| 74 | +// ControlButtonUtil.mNotificationManager.cancelAll();
|
---|
| 75 | +// ControlButtonUtil.mActivity.finish();
|
---|
| 76 | +
|
---|
| 77 | + ControlButtonUtil.mActivity.setResult(RESULT.UNDEF.ordinal(),
|
---|
| 78 | + resultIntent);
|
---|
| 79 | + if (ControlButtonUtil.mNotificationManager != null)
|
---|
| 80 | + ControlButtonUtil.mNotificationManager.cancelAll();
|
---|
| 81 | + stopService();
|
---|
| 82 | + ControlButtonUtil.mActivity.finish();
|
---|
| 83 | + }
|
---|
| 84 | + });
|
---|
| 85 | +
|
---|
| 86 | + }
|
---|
| 87 | +//
|
---|
| 88 | +// public static void back() {
|
---|
| 89 | +// }
|
---|
| 90 | + private void stopService(){
|
---|
| 91 | + if(mAction != null){
|
---|
| 92 | + Intent intent = new Intent(mAction);
|
---|
| 93 | + ControlButtonUtil.mActivity.stopService(intent);
|
---|
| 94 | + }
|
---|
| 95 | + }
|
---|
| 96 | + public static void setIntent(String result) {
|
---|
| 97 | + mAction = result;
|
---|
| 98 | +
|
---|
| 99 | + }
|
---|
| 100 | + public static void setResult(String result) {
|
---|
| 101 | + resultIntent.putExtra(DeviceTest.EXTRA_TEST_RESULT_INFO, result);
|
---|
| 102 | + }
|
---|
| 103 | +
|
---|
| 104 | + public static void Hide() {
|
---|
| 105 | + mActivity.findViewById(R.id.btn_Pass).setVisibility(View.GONE);
|
---|
| 106 | + mActivity.findViewById(R.id.btn_Fail).setVisibility(View.GONE);
|
---|
| 107 | + mActivity.findViewById(R.id.btn_Skip).setVisibility(View.GONE);
|
---|
| 108 | + mActivity.findViewById(R.id.btn_return).setVisibility(View.GONE);
|
---|
| 109 | + }
|
---|
| 110 | +
|
---|
| 111 | + public static void Show() {
|
---|
| 112 | + mActivity.findViewById(R.id.btn_Pass).setVisibility(View.VISIBLE);
|
---|
| 113 | + mActivity.findViewById(R.id.btn_Pass).requestFocus();
|
---|
| 114 | + mActivity.findViewById(R.id.btn_Fail).setVisibility(View.VISIBLE);
|
---|
| 115 | + mActivity.findViewById(R.id.btn_Fail).requestFocus();
|
---|
| 116 | + mActivity.findViewById(R.id.btn_Skip).setVisibility(View.VISIBLE);
|
---|
| 117 | + mActivity.findViewById(R.id.btn_Skip).requestFocus();
|
---|
| 118 | +
|
---|
| 119 | + mActivity.findViewById(R.id.btn_return).setVisibility(View.VISIBLE);
|
---|
| 120 | + mActivity.findViewById(R.id.btn_return).requestFocus();
|
---|
| 121 | + }
|
---|
| 122 | +
|
---|
| 123 | + public static void initControlButtonView(Activity paramActivity) {
|
---|
| 124 | + mControlButtonView = new ControlButtonUtil(paramActivity);
|
---|
| 125 | + }
|
---|
| 126 | +
|
---|
| 127 | + static void setNotification(NotificationManager paramNotificationManager) {
|
---|
| 128 | + mNotificationManager = paramNotificationManager;
|
---|
| 129 | + }
|
---|
| 130 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.helper;
|
---|
| 2 | +
|
---|
| 3 | +public class PCIEInfo {
|
---|
| 4 | + private String staSpeed;
|
---|
| 5 | + private String staWidth;
|
---|
| 6 | +
|
---|
| 7 | + public String getStaSpeed() {
|
---|
| 8 | + return staSpeed;
|
---|
| 9 | + }
|
---|
| 10 | +
|
---|
| 11 | + public void setStaSpeed(String staSpeed) {
|
---|
| 12 | + this.staSpeed = staSpeed;
|
---|
| 13 | + }
|
---|
| 14 | +
|
---|
| 15 | + public String getStaWidth() {
|
---|
| 16 | + return staWidth;
|
---|
| 17 | + }
|
---|
| 18 | +
|
---|
| 19 | + public void setStaWidth(String staWidth) {
|
---|
| 20 | + this.staWidth = staWidth;
|
---|
| 21 | + }
|
---|
| 22 | +
|
---|
| 23 | + @Override
|
---|
| 24 | + public String toString() {
|
---|
| 25 | + String gen = staSpeed;
|
---|
| 26 | + if ("2.5GT/s".equals(staSpeed)) {
|
---|
| 27 | + gen = "gen1";
|
---|
| 28 | + } else if ("5GT/s".equals(staSpeed)) {
|
---|
| 29 | + gen = "gen2";
|
---|
| 30 | + } else if ("8GT/s".equals(staSpeed)) {
|
---|
| 31 | + gen = "gen3";
|
---|
| 32 | + }
|
---|
| 33 | + String lane = staWidth;
|
---|
| 34 | + if ("x1".equals(staWidth)) {
|
---|
| 35 | + lane = "1Lane";
|
---|
| 36 | + } else if ("x2".equals(staWidth)) {
|
---|
| 37 | + lane = "2Lanes";
|
---|
| 38 | + } else if ("x4".equals(staWidth)) {
|
---|
| 39 | + lane = "4Lanes";
|
---|
| 40 | + }
|
---|
| 41 | + return "gen='" + gen + '\'' +
|
---|
| 42 | + ", lane='" + lane + '\'';
|
---|
| 43 | + }
|
---|
| 44 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.helper;
|
---|
| 2 | +
|
---|
| 3 | +import java.io.File;
|
---|
| 4 | +import java.io.FileDescriptor;
|
---|
| 5 | +import java.io.FileInputStream;
|
---|
| 6 | +
|
---|
| 7 | +import com.DeviceTest.DeviceTest;
|
---|
| 8 | +
|
---|
| 9 | +import android.media.MediaPlayer;
|
---|
| 10 | +import android.media.MediaRecorder;
|
---|
| 11 | +import android.os.Bundle;
|
---|
| 12 | +import android.os.Environment;
|
---|
| 13 | +import android.util.Log;
|
---|
| 14 | +
|
---|
| 15 | +public class Recorder implements MediaPlayer.OnCompletionListener,
|
---|
| 16 | + MediaPlayer.OnErrorListener {
|
---|
| 17 | + public static final int IDLE_STATE = 0;
|
---|
| 18 | + public static final int INTERNAL_ERROR = 2;
|
---|
| 19 | + public static final int NO_ERROR = 0;
|
---|
| 20 | + public static final int PLAYING_STATE = 2;
|
---|
| 21 | + public static final int RECORDING_STATE = 1;
|
---|
| 22 | + static final String SAMPLE_LENGTH_KEY = "sample_length";
|
---|
| 23 | + static final String SAMPLE_PATH_KEY = "sample_path";
|
---|
| 24 | + static final String SAMPLE_PREFIX = "recording";
|
---|
| 25 | + private static final String TEST_FILE_PATH = DeviceTest.DATA_PATH + "test";
|
---|
| 26 | + public static final int SDCARD_ACCESS_ERROR = 1;
|
---|
| 27 | + OnStateChangedListener mOnStateChangedListener = null;
|
---|
| 28 | + MediaPlayer mPlayer = null;
|
---|
| 29 | + MediaRecorder mRecorder = null;
|
---|
| 30 | + File mSampleFile = null;
|
---|
| 31 | + int mSampleLength;
|
---|
| 32 | + long mSampleStart = 0L;
|
---|
| 33 | + int mState;
|
---|
| 34 | +
|
---|
| 35 | + private void setError(int paramInt) {
|
---|
| 36 | + if (this.mOnStateChangedListener == null) {
|
---|
| 37 | + return;
|
---|
| 38 | + }
|
---|
| 39 | +
|
---|
| 40 | + this.mOnStateChangedListener.onError(paramInt);
|
---|
| 41 | + }
|
---|
| 42 | +
|
---|
| 43 | + private void setState(int state) {
|
---|
| 44 | + if (this.state() == state) {
|
---|
| 45 | + return;
|
---|
| 46 | +
|
---|
| 47 | + }
|
---|
| 48 | +
|
---|
| 49 | + this.mState = state;
|
---|
| 50 | +
|
---|
| 51 | + signalStateChanged(this.mState);
|
---|
| 52 | +
|
---|
| 53 | + }
|
---|
| 54 | +
|
---|
| 55 | + private void signalStateChanged(int paramInt) {
|
---|
| 56 | + if (this.mOnStateChangedListener == null)
|
---|
| 57 | + return;
|
---|
| 58 | + this.mOnStateChangedListener.onStateChanged(paramInt);
|
---|
| 59 | + }
|
---|
| 60 | +
|
---|
| 61 | + public void clear() {
|
---|
| 62 | + stop();
|
---|
| 63 | + this.mSampleLength = 0;
|
---|
| 64 | + signalStateChanged(0);
|
---|
| 65 | + }
|
---|
| 66 | +
|
---|
| 67 | + public void delete() {
|
---|
| 68 | + int i = 0;
|
---|
| 69 | + stop();
|
---|
| 70 | + if (this.mSampleFile != null)
|
---|
| 71 | + this.mSampleFile.delete();
|
---|
| 72 | + this.mSampleFile = null;
|
---|
| 73 | + this.mSampleLength = i;
|
---|
| 74 | + signalStateChanged(i);
|
---|
| 75 | + }
|
---|
| 76 | +
|
---|
| 77 | +
|
---|
| 78 | + public int getMaxAmplitude()
|
---|
| 79 | + {
|
---|
| 80 | + if (this.mState == Recorder.RECORDING_STATE) {
|
---|
| 81 | + return this.mRecorder.getMaxAmplitude();
|
---|
| 82 | + }
|
---|
| 83 | + return 0;
|
---|
| 84 | + }
|
---|
| 85 | +
|
---|
| 86 | + public void onCompletion(MediaPlayer paramMediaPlayer) {
|
---|
| 87 | + stop();
|
---|
| 88 | + }
|
---|
| 89 | +
|
---|
| 90 | + public boolean onError(MediaPlayer paramMediaPlayer, int paramInt1,
|
---|
| 91 | + int paramInt2) {
|
---|
| 92 | + stop();
|
---|
| 93 | + setError(1);
|
---|
| 94 | + return true;
|
---|
| 95 | + }
|
---|
| 96 | +
|
---|
| 97 | + public int progress() {
|
---|
| 98 | + if (this.state() != Recorder.PLAYING_STATE) {
|
---|
| 99 | + return 0;
|
---|
| 100 | + }
|
---|
| 101 | + long currentTime = System.currentTimeMillis();
|
---|
| 102 | +
|
---|
| 103 | + return (int) ((currentTime - this.mSampleStart) / 1000L);
|
---|
| 104 | +
|
---|
| 105 | + }
|
---|
| 106 | +
|
---|
| 107 | + public File sampleFile() {
|
---|
| 108 | + return this.mSampleFile;
|
---|
| 109 | + }
|
---|
| 110 | +
|
---|
| 111 | + public int sampleLength() {
|
---|
| 112 | + return this.mSampleLength;
|
---|
| 113 | + }
|
---|
| 114 | +
|
---|
| 115 | + public void setOnStateChangedListener(
|
---|
| 116 | + OnStateChangedListener paramOnStateChangedListener) {
|
---|
| 117 | + this.mOnStateChangedListener = paramOnStateChangedListener;
|
---|
| 118 | + }
|
---|
| 119 | +
|
---|
| 120 | + public void startPlayback() {
|
---|
| 121 | +
|
---|
| 122 | + stop();
|
---|
| 123 | +
|
---|
| 124 | + this.mPlayer = new MediaPlayer();
|
---|
| 125 | + try {
|
---|
| 126 | + FileInputStream fis = new FileInputStream(mSampleFile);
|
---|
| 127 | + this.mPlayer.setDataSource(fis.getFD());
|
---|
| 128 | + this.mPlayer.setOnCompletionListener(this);
|
---|
| 129 | + this.mPlayer.setOnErrorListener(this);
|
---|
| 130 | + this.mPlayer.prepare();
|
---|
| 131 | + this.mPlayer.start();
|
---|
| 132 | +
|
---|
| 133 | + this.mSampleStart = System.currentTimeMillis();
|
---|
| 134 | + setState(Recorder.PLAYING_STATE);
|
---|
| 135 | +
|
---|
| 136 | + } catch (Exception e) {
|
---|
| 137 | + setError(Recorder.PLAYING_STATE);
|
---|
| 138 | + setState(Recorder.IDLE_STATE);
|
---|
| 139 | +
|
---|
| 140 | + }
|
---|
| 141 | + }
|
---|
| 142 | +
|
---|
| 143 | + public void startRecording(int paramInt, String paramString) {
|
---|
| 144 | +
|
---|
| 145 | + stop();
|
---|
| 146 | + try {
|
---|
| 147 | + Log.i("Jeffy","Create new file:" + TEST_FILE_PATH);
|
---|
| 148 | + this.mSampleFile = new File(TEST_FILE_PATH);
|
---|
| 149 | + this.mSampleFile.createNewFile();
|
---|
| 150 | + Log.i("Jeffy","new file created,now create recorder");
|
---|
| 151 | + this.mRecorder = new MediaRecorder();
|
---|
| 152 | + this.mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
|
---|
| 153 | + this.mRecorder.setOutputFormat(paramInt);
|
---|
| 154 | + this.mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
|
---|
| 155 | +
|
---|
| 156 | + String str = this.mSampleFile.getAbsolutePath();
|
---|
| 157 | + mRecorder.setOutputFile(str);
|
---|
| 158 | + Log.i("Jeffy","start to record");
|
---|
| 159 | +
|
---|
| 160 | + this.mRecorder.prepare();
|
---|
| 161 | + this.mRecorder.start();
|
---|
| 162 | +
|
---|
| 163 | + this.mSampleStart = System.currentTimeMillis();
|
---|
| 164 | + setState(Recorder.RECORDING_STATE);
|
---|
| 165 | + } catch (Exception e) {
|
---|
| 166 | + e.printStackTrace();
|
---|
| 167 | + setError(Recorder.IDLE_STATE);
|
---|
| 168 | + if(mRecorder != null) {
|
---|
| 169 | + this.mRecorder.reset();
|
---|
| 170 | + this.mRecorder.release();
|
---|
| 171 | + this.mRecorder = null;
|
---|
| 172 | + }
|
---|
| 173 | +
|
---|
| 174 | + }
|
---|
| 175 | +
|
---|
| 176 | + }
|
---|
| 177 | +
|
---|
| 178 | + public int state() {
|
---|
| 179 | + return this.mState;
|
---|
| 180 | + }
|
---|
| 181 | +
|
---|
| 182 | + public void stop() {
|
---|
| 183 | + stopRecording();
|
---|
| 184 | + stopPlayback();
|
---|
| 185 | + }
|
---|
| 186 | +
|
---|
| 187 | + public void stopPlayback() {
|
---|
| 188 | + if (this.mPlayer == null) {
|
---|
| 189 | + return;
|
---|
| 190 | + }
|
---|
| 191 | + this.mPlayer.stop();
|
---|
| 192 | + this.mPlayer.release();
|
---|
| 193 | + this.mPlayer = null;
|
---|
| 194 | + setState(Recorder.IDLE_STATE);
|
---|
| 195 | +
|
---|
| 196 | + }
|
---|
| 197 | +
|
---|
| 198 | + public void stopRecording() {
|
---|
| 199 | + if (this.mRecorder == null) {
|
---|
| 200 | + return;
|
---|
| 201 | + }
|
---|
| 202 | + this.mRecorder.stop();
|
---|
| 203 | + this.mRecorder.release();
|
---|
| 204 | + this.mRecorder = null;
|
---|
| 205 | +
|
---|
| 206 | + this.mSampleLength = (int) ((System.currentTimeMillis() - mSampleStart) / 1000L);
|
---|
| 207 | + setState(Recorder.IDLE_STATE);
|
---|
| 208 | + }
|
---|
| 209 | +}
|
---|
| 210 | +
|
---|
| 211 | +abstract interface OnStateChangedListener {
|
---|
| 212 | + public abstract void onError(int paramInt);
|
---|
| 213 | +
|
---|
| 214 | + public abstract void onStateChanged(int paramInt);
|
---|
| 215 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.helper;
|
---|
| 2 | +
|
---|
| 3 | +public class StorageInfo {
|
---|
| 4 | + private String path;
|
---|
| 5 | + private String sysPath;
|
---|
| 6 | +
|
---|
| 7 | + public StorageInfo(String path, String sysPath) {
|
---|
| 8 | + this.path = path;
|
---|
| 9 | + this.sysPath = sysPath;
|
---|
| 10 | + }
|
---|
| 11 | +
|
---|
| 12 | + public String getPath() {
|
---|
| 13 | + return path;
|
---|
| 14 | + }
|
---|
| 15 | +
|
---|
| 16 | + public void setPath(String path) {
|
---|
| 17 | + this.path = path;
|
---|
| 18 | + }
|
---|
| 19 | +
|
---|
| 20 | + public String getSysPath() {
|
---|
| 21 | + return sysPath;
|
---|
| 22 | + }
|
---|
| 23 | +
|
---|
| 24 | + public void setSysPath(String sysPath) {
|
---|
| 25 | + this.sysPath = sysPath;
|
---|
| 26 | + }
|
---|
| 27 | +
|
---|
| 28 | + @Override
|
---|
| 29 | + public String toString() {
|
---|
| 30 | + return "StorageInfo{" +
|
---|
| 31 | + "path='" + path + '\'' +
|
---|
| 32 | + ", sysPath='" + sysPath + '\'' +
|
---|
| 33 | + '}';
|
---|
| 34 | + }
|
---|
| 35 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.helper; |
---|
| 2 | + |
---|
| 3 | +import java.io.BufferedReader; |
---|
| 4 | +import java.io.File; |
---|
| 5 | +import java.io.FileFilter; |
---|
| 6 | +import java.io.FileNotFoundException; |
---|
| 7 | +import java.io.FileReader; |
---|
| 8 | +import java.io.IOException; |
---|
| 9 | +import java.io.InputStream; |
---|
| 10 | +import java.io.InputStreamReader; |
---|
| 11 | +import java.util.ArrayList; |
---|
| 12 | +import java.util.List; |
---|
| 13 | +import java.util.Properties; |
---|
| 14 | +import java.util.regex.Matcher; |
---|
| 15 | +import java.util.regex.Pattern; |
---|
| 16 | + |
---|
| 17 | +import javax.security.auth.PrivateCredentialPermission; |
---|
| 18 | + |
---|
| 19 | +import android.R.integer; |
---|
| 20 | +import android.R.string; |
---|
| 21 | +import android.app.ActivityManager; |
---|
| 22 | +import android.bluetooth.BluetoothAdapter; |
---|
| 23 | +import android.content.Context; |
---|
| 24 | +import android.graphics.Camera; |
---|
| 25 | +import android.hardware.Camera.CameraInfo; |
---|
| 26 | +import android.hardware.Camera.Parameters; |
---|
| 27 | +import android.hardware.Camera.Size; |
---|
| 28 | +import android.net.wifi.WifiInfo; |
---|
| 29 | +import android.net.wifi.WifiManager; |
---|
| 30 | +import android.os.Build; |
---|
| 31 | +import android.os.Environment; |
---|
| 32 | +import android.os.RemoteException; |
---|
| 33 | +import android.os.StatFs; |
---|
| 34 | +//import android.os.IECService; |
---|
| 35 | +import android.os.ServiceManager; |
---|
| 36 | +import android.os.SystemProperties; |
---|
| 37 | +import android.text.format.Formatter; |
---|
| 38 | +import android.util.Log; |
---|
| 39 | + |
---|
| 40 | +/* |
---|
| 41 | + * TODO:获取系统相关信息 |
---|
| 42 | + * |
---|
| 43 | + * Data:2013-04-24 |
---|
| 44 | + */ |
---|
| 45 | + |
---|
| 46 | +public class SystemInfoUtil { |
---|
| 47 | + private static final String TAG = "SystemInfoUtil"; |
---|
| 48 | + |
---|
| 49 | + // 获取sdcard 的大小 |
---|
| 50 | + private static void getSdcardStorageSize() { |
---|
| 51 | + String state = Environment.getExternalStorageState(); |
---|
| 52 | + if (Environment.MEDIA_MOUNTED.equals(state)) { |
---|
| 53 | + File sdcardDir = Environment.getExternalStorageDirectory(); |
---|
| 54 | + StatFs sf = new StatFs(sdcardDir.getPath()); |
---|
| 55 | + long blockSize = sf.getBlockSize(); |
---|
| 56 | + long blockCount = sf.getBlockCount(); |
---|
| 57 | + long availCount = sf.getAvailableBlocks(); |
---|
| 58 | + Log.d("cghs", "block大小:" + blockSize + ",block数目:" + blockCount |
---|
| 59 | + + ",总大小:" + blockSize * blockCount / 1024 + "KB"); |
---|
| 60 | + Log.d("cghs", "可用的block数目::" + availCount + ",剩余空间:" + availCount |
---|
| 61 | + * blockSize / 1024 + "KB"); |
---|
| 62 | + } |
---|
| 63 | + } |
---|
| 64 | + |
---|
| 65 | + // 获取系统分区的大小 |
---|
| 66 | + private static void getSystemStorageSize() { |
---|
| 67 | + File root = Environment.getRootDirectory(); |
---|
| 68 | + StatFs sf = new StatFs(root.getPath()); |
---|
| 69 | + long blockSize = sf.getBlockSize(); |
---|
| 70 | + long blockCount = sf.getBlockCount(); |
---|
| 71 | + long availCount = sf.getAvailableBlocks(); |
---|
| 72 | + Log.d("cghs", "block大小:" + blockSize + ",block数目:" + blockCount |
---|
| 73 | + + ",总大小:" + blockSize * blockCount / 1024 + "KB"); |
---|
| 74 | + Log.d("cghs", "可用的block数目::" + availCount + ",可用大小:" + availCount |
---|
| 75 | + * blockSize / 1024 + "KB"); |
---|
| 76 | + } |
---|
| 77 | + |
---|
| 78 | + // 获得内存信息 方法1 |
---|
| 79 | + public static String GetMemInfo1(Context mContext) { |
---|
| 80 | + long MEM_UNUSED; |
---|
| 81 | + long MEM_TOTAL; |
---|
| 82 | + // 得到ActivityManager |
---|
| 83 | + ActivityManager am = (ActivityManager) mContext |
---|
| 84 | + .getSystemService(Context.ACTIVITY_SERVICE); |
---|
| 85 | + // 创建ActivityManager.MemoryInfo对象 |
---|
| 86 | + ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); |
---|
| 87 | + am.getMemoryInfo(mi); |
---|
| 88 | + |
---|
| 89 | + // 取得剩余的内存空间 |
---|
| 90 | + MEM_UNUSED = mi.availMem / (1024*1024); |
---|
| 91 | + MEM_TOTAL = mi.totalMem / (1024*1024); |
---|
| 92 | + Log.d("cghs", "MEN_UNUSER: " + MEM_UNUSED + " MEM_TOTAL:" + MEM_TOTAL); |
---|
| 93 | + String memStr = MEM_TOTAL + " MB"; |
---|
| 94 | + return memStr; |
---|
| 95 | + |
---|
| 96 | + } |
---|
| 97 | + |
---|
| 98 | + // 获得内存信息 方法2 |
---|
| 99 | + public static void GetMemInfo2() { |
---|
| 100 | + List<String> contents = new ArrayList<String>(); |
---|
| 101 | + long mTotal; |
---|
| 102 | + // /proc/meminfo读出的内核信息进行解释 |
---|
| 103 | + String path = "/proc/meminfo"; |
---|
| 104 | + BufferedReader br = null; |
---|
| 105 | + try { |
---|
| 106 | + br = new BufferedReader(new FileReader(path), 8); |
---|
| 107 | + String line; |
---|
| 108 | + if ((line = br.readLine()) != null) { |
---|
| 109 | + contents.add(line); |
---|
| 110 | + } |
---|
| 111 | + |
---|
| 112 | + if ((line = br.readLine()) != null) { |
---|
| 113 | + contents.add(line); |
---|
| 114 | + } |
---|
| 115 | + |
---|
| 116 | + } catch (FileNotFoundException e) { |
---|
| 117 | + e.printStackTrace(); |
---|
| 118 | + } catch (IOException e) { |
---|
| 119 | + e.printStackTrace(); |
---|
| 120 | + } finally { |
---|
| 121 | + if (br != null) { |
---|
| 122 | + try { |
---|
| 123 | + br.close(); |
---|
| 124 | + } catch (IOException e) { |
---|
| 125 | + e.printStackTrace(); |
---|
| 126 | + } |
---|
| 127 | + } |
---|
| 128 | + } |
---|
| 129 | + |
---|
| 130 | + String total = contents.get(0); |
---|
| 131 | + String rest = contents.get(1); |
---|
| 132 | + // beginIndex |
---|
| 133 | + int begin = total.indexOf(':'); |
---|
| 134 | + // endIndex |
---|
| 135 | + int end = total.indexOf('k'); |
---|
| 136 | + // 截取字符串信息 |
---|
| 137 | + |
---|
| 138 | + total = total.substring(begin + 1, end).trim(); |
---|
| 139 | + mTotal = Integer.parseInt(total); |
---|
| 140 | + Log.d("cghs", "mTotal: " + mTotal); |
---|
| 141 | + Log.d("cghs", "" + rest); |
---|
| 142 | + } |
---|
| 143 | + |
---|
| 144 | + // -------------------------CPU INFO------------------------- |
---|
| 145 | + |
---|
| 146 | + // 获取CPU名字 |
---|
| 147 | + public static String getCpuName() { |
---|
| 148 | + try { |
---|
| 149 | + FileReader fr = new FileReader("/proc/cpuinfo"); |
---|
| 150 | + BufferedReader br = new BufferedReader(fr); |
---|
| 151 | + String text = br.readLine(); |
---|
| 152 | + String[] array = text.split(":\\s+", 2); |
---|
| 153 | + for (int i = 0; i < array.length; i++) { |
---|
| 154 | + } |
---|
| 155 | + return array[1]; |
---|
| 156 | + } catch (FileNotFoundException e) { |
---|
| 157 | + e.printStackTrace(); |
---|
| 158 | + } catch (IOException e) { |
---|
| 159 | + e.printStackTrace(); |
---|
| 160 | + } |
---|
| 161 | + return null; |
---|
| 162 | + } |
---|
| 163 | + |
---|
| 164 | + public static String getCpuNameByProp() { |
---|
| 165 | + String name = null; |
---|
| 166 | + name = SystemProperties.get("ro.rk.cpu", "rk3188"); |
---|
| 167 | + return name; |
---|
| 168 | + } |
---|
| 169 | + |
---|
| 170 | + // 获取CPU最大频率(单位KHZ) |
---|
| 171 | + // "/system/bin/cat" 命令行 |
---|
| 172 | + // "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq" 存储最大频率的文件的路径 |
---|
| 173 | + public static String getMaxCpuFreq() { |
---|
| 174 | + String result = "N/A"; |
---|
| 175 | + try { |
---|
| 176 | + FileReader fr = new FileReader( |
---|
| 177 | + "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"); |
---|
| 178 | + BufferedReader br = new BufferedReader(fr); |
---|
| 179 | + String text = br.readLine(); |
---|
| 180 | + result = text.trim(); |
---|
| 181 | + } catch (FileNotFoundException e) { |
---|
| 182 | + e.printStackTrace(); |
---|
| 183 | + } catch (IOException e) { |
---|
| 184 | + e.printStackTrace(); |
---|
| 185 | + } |
---|
| 186 | + return result; |
---|
| 187 | + } |
---|
| 188 | + |
---|
| 189 | + // 获取CPU最小频率(单位KHZ) |
---|
| 190 | + public static String getMinCpuFreq() { |
---|
| 191 | + String result = ""; |
---|
| 192 | + ProcessBuilder cmd; |
---|
| 193 | + try { |
---|
| 194 | + String[] args = { "/system/bin/cat", |
---|
| 195 | + "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq" }; |
---|
| 196 | + cmd = new ProcessBuilder(args); |
---|
| 197 | + Process process = cmd.start(); |
---|
| 198 | + InputStream in = process.getInputStream(); |
---|
| 199 | + byte[] re = new byte[24]; |
---|
| 200 | + while (in.read(re) != -1) { |
---|
| 201 | + result = result + new String(re); |
---|
| 202 | + } |
---|
| 203 | + in.close(); |
---|
| 204 | + } catch (IOException ex) { |
---|
| 205 | + ex.printStackTrace(); |
---|
| 206 | + result = "N/A"; |
---|
| 207 | + } |
---|
| 208 | + return result.trim(); |
---|
| 209 | + } |
---|
| 210 | + |
---|
| 211 | + // 实时获取CPU当前频率(单位KHZ) |
---|
| 212 | + public static String getCurCpuFreq() { |
---|
| 213 | + String result = "N/A"; |
---|
| 214 | + try { |
---|
| 215 | + FileReader fr = new FileReader( |
---|
| 216 | + "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"); |
---|
| 217 | + BufferedReader br = new BufferedReader(fr); |
---|
| 218 | + String text = br.readLine(); |
---|
| 219 | + result = text.trim(); |
---|
| 220 | + } catch (FileNotFoundException e) { |
---|
| 221 | + e.printStackTrace(); |
---|
| 222 | + } catch (IOException e) { |
---|
| 223 | + e.printStackTrace(); |
---|
| 224 | + } |
---|
| 225 | + return result; |
---|
| 226 | + } |
---|
| 227 | + |
---|
| 228 | + // 获取 cpu 核数 |
---|
| 229 | + public static int getNumCores() { |
---|
| 230 | + // Private Class to display only CPU devices in the directory listing |
---|
| 231 | + class CpuFilter implements FileFilter { |
---|
| 232 | + @Override |
---|
| 233 | + public boolean accept(File pathname) { |
---|
| 234 | + // Check if filename is "cpu", followed by a single digit number |
---|
| 235 | + if (Pattern.matches("cpu[0-9]", pathname.getName())) { |
---|
| 236 | + return true; |
---|
| 237 | + } |
---|
| 238 | + return false; |
---|
| 239 | + } |
---|
| 240 | + } |
---|
| 241 | + |
---|
| 242 | + try { |
---|
| 243 | + // Get directory containing CPU info |
---|
| 244 | + File dir = new File("/sys/devices/system/cpu/"); |
---|
| 245 | + // Filter to only list the devices we care about |
---|
| 246 | + File[] files = dir.listFiles(new CpuFilter()); |
---|
| 247 | + // Return the number of cores (virtual CPU devices) |
---|
| 248 | + return files.length; |
---|
| 249 | + } catch (Exception e) { |
---|
| 250 | + e.printStackTrace(); |
---|
| 251 | + // Default to return 1 core |
---|
| 252 | + return 1; |
---|
| 253 | + } |
---|
| 254 | + } |
---|
| 255 | + |
---|
| 256 | + /** |
---|
| 257 | + * 获取 HDD 大小 |
---|
| 258 | + * |
---|
| 259 | + */ |
---|
| 260 | + /* |
---|
| 261 | + public static String getHDDSize(Context context) { |
---|
| 262 | + int trytime = 0; |
---|
| 263 | + String flash_path = "/mnt/sdcard"; |
---|
| 264 | + while(!getSdCardState(flash_path).equals(Environment.MEDIA_MOUNTED)) { |
---|
| 265 | + try { |
---|
| 266 | + Thread.sleep(500); |
---|
| 267 | + } catch (Exception e) { |
---|
| 268 | + |
---|
| 269 | + } |
---|
| 270 | + trytime ++; |
---|
| 271 | + if (trytime >= 8) { |
---|
| 272 | + Log.e(TAG, "getHDDSize(): flash unmount"); |
---|
| 273 | + return "err!"; |
---|
| 274 | + } |
---|
| 275 | + } |
---|
| 276 | + |
---|
| 277 | + |
---|
| 278 | + StatFs stat = new StatFs(flash_path); |
---|
| 279 | + long blockSize = stat.getBlockSize(); |
---|
| 280 | + long totalBlocks = stat.getBlockCount(); |
---|
| 281 | + long availableBlocks = stat.getAvailableBlocks(); |
---|
| 282 | + float size = (blockSize * totalBlocks)/(1024*1024); |
---|
| 283 | + float sizeInGB = size / 1024; |
---|
| 284 | + if (sizeInGB > 11.00f && sizeInGB < 20.00f) { |
---|
| 285 | + return "16.00 GB"; |
---|
| 286 | + } else if (sizeInGB > 20.00f) { |
---|
| 287 | + return "32.00 GB"; |
---|
| 288 | + } |
---|
| 289 | + return Formatter.formatFileSize(context, blockSize * totalBlocks); |
---|
| 290 | + |
---|
| 291 | + } |
---|
| 292 | + */ |
---|
| 293 | + |
---|
| 294 | + /** |
---|
| 295 | + * 获取当前路径下硬盘是否挂载。 |
---|
| 296 | + */ |
---|
| 297 | + /*public static String getSdCardState(String path) { |
---|
| 298 | + try { |
---|
| 299 | + IMountService mMntSvc = null; |
---|
| 300 | + if (mMntSvc == null) { |
---|
| 301 | + mMntSvc = IMountService.Stub.asInterface(ServiceManager |
---|
| 302 | + .getService("mount")); |
---|
| 303 | + } |
---|
| 304 | + return mMntSvc.getVolumeState(path); |
---|
| 305 | + } catch (Exception rex) { |
---|
| 306 | + return Environment.MEDIA_REMOVED; |
---|
| 307 | + } |
---|
| 308 | + |
---|
| 309 | + } |
---|
| 310 | +*/ |
---|
| 311 | + /* |
---|
| 312 | + * 获取wifi MAC need permission: <uses-permission |
---|
| 313 | + * android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission |
---|
| 314 | + * android:name="android.permission.INTERNET"/> |
---|
| 315 | + */ |
---|
| 316 | + public static String getLocalMacAddress(Context context) { |
---|
| 317 | + WifiManager wifi = (WifiManager) context |
---|
| 318 | + .getSystemService(Context.WIFI_SERVICE); |
---|
| 319 | + if (!wifi.isWifiEnabled()) { |
---|
| 320 | + // wifi.setWifiEnabled(true); |
---|
| 321 | + } |
---|
| 322 | + WifiInfo info = wifi.getConnectionInfo(); |
---|
| 323 | + String mac = info.getMacAddress(); |
---|
| 324 | + wifi.setWifiEnabled(false); |
---|
| 325 | + return mac; |
---|
| 326 | + |
---|
| 327 | + } |
---|
| 328 | + |
---|
| 329 | + public static String getAndroidVersion() { |
---|
| 330 | + return Build.VERSION.RELEASE; |
---|
| 331 | + } |
---|
| 332 | + |
---|
| 333 | + /** |
---|
| 334 | + * 获取kernel 版本 |
---|
| 335 | + */ |
---|
| 336 | + public static String getFormattedKernelVersion() { |
---|
| 337 | + String procVersionStr; |
---|
| 338 | + |
---|
| 339 | + try { |
---|
| 340 | + BufferedReader reader = new BufferedReader(new FileReader( |
---|
| 341 | + "/proc/version"), 256); |
---|
| 342 | + try { |
---|
| 343 | + procVersionStr = reader.readLine(); |
---|
| 344 | + } finally { |
---|
| 345 | + reader.close(); |
---|
| 346 | + } |
---|
| 347 | + |
---|
| 348 | + final String PROC_VERSION_REGEX = "\\w+\\s+" + /* ignore: Linux */ |
---|
| 349 | + "\\w+\\s+" + /* ignore: version */ |
---|
| 350 | + "([^\\s]+)\\s+" + /* group 1: 2.6.22-omap1 */ |
---|
| 351 | + "\\(([^\\s@]+(?:@[^\\s.]+)?)[^)]*\\)\\s+" + /* |
---|
| 352 | + * group 2: |
---|
| 353 | + * (xxxxxx@xxxxx |
---|
| 354 | + * .constant) |
---|
| 355 | + */ |
---|
| 356 | + "\\((?:[^(]*\\([^)]*\\))?[^)]*\\)\\s+" + /* ignore: (gcc ..) */ |
---|
| 357 | + "([^\\s]+)\\s+" + /* group 3: #26 */ |
---|
| 358 | + "(?:PREEMPT\\s+)?" + /* ignore: PREEMPT (optional) */ |
---|
| 359 | + "(.+)"; /* group 4: date */ |
---|
| 360 | + |
---|
| 361 | + Pattern p = Pattern.compile(PROC_VERSION_REGEX); |
---|
| 362 | + Matcher m = p.matcher(procVersionStr); |
---|
| 363 | + |
---|
| 364 | + if (!m.matches()) { |
---|
| 365 | + |
---|
| 366 | + return "Unavailable"; |
---|
| 367 | + } else if (m.groupCount() < 4) { |
---|
| 368 | + |
---|
| 369 | + return "Unavailable"; |
---|
| 370 | + } else { |
---|
| 371 | + return (new StringBuilder(m.group(1)).append("\n") |
---|
| 372 | + .append(m.group(2)).append(" ").append(m.group(3)) |
---|
| 373 | + .append("\n").append(m.group(4))).toString(); |
---|
| 374 | + } |
---|
| 375 | + } catch (IOException e) { |
---|
| 376 | + |
---|
| 377 | + return "Unavailable"; |
---|
| 378 | + } |
---|
| 379 | + } |
---|
| 380 | + |
---|
| 381 | + /** |
---|
| 382 | + * 获取product 名字 |
---|
| 383 | + */ |
---|
| 384 | + public static String getProductName() { |
---|
| 385 | + return Build.PRODUCT; |
---|
| 386 | + } |
---|
| 387 | + |
---|
| 388 | +/* public static String getFormattedECVersion() { |
---|
| 389 | + IECService ecService; |
---|
| 390 | + byte[] vv = new byte[2]; |
---|
| 391 | + int ecVersion; |
---|
| 392 | + try { |
---|
| 393 | + ecService = IECService.Stub.asInterface(ServiceManager |
---|
| 394 | + .getService("ECServiceinfo")); |
---|
| 395 | + if (ecService == null) { |
---|
| 396 | + Log.e(TAG, "Unable to create the ECService instance!"); |
---|
| 397 | + return "Unavailable"; |
---|
| 398 | + } |
---|
| 399 | + |
---|
| 400 | + ecVersion = ecService.getVersion(); |
---|
| 401 | + |
---|
| 402 | + vv[0] = (byte) (ecVersion & 0x000000FF); |
---|
| 403 | + vv[1] = (byte) ((ecVersion >> 8) & 0x000000FF); |
---|
| 404 | + |
---|
| 405 | + return String.format("%02x %02x", vv[1], vv[0]); |
---|
| 406 | + |
---|
| 407 | + } catch (RemoteException e) { |
---|
| 408 | + // TODO Auto-generated catch block |
---|
| 409 | + Log.e(TAG, |
---|
| 410 | + "IO Exception when getting ec version for Device Info screen", |
---|
| 411 | + e); |
---|
| 412 | + return "Unavailable"; |
---|
| 413 | + } |
---|
| 414 | + } |
---|
| 415 | +*/ |
---|
| 416 | + public static String getCameraId() { |
---|
| 417 | + String pidcmd = "/system/bin/cat /sys/bus/usb/devices/3-1/idProduct"; |
---|
| 418 | + String vidcmd = "/system/bin/cat /sys/bus/usb/devices/3-1/idVendor"; |
---|
| 419 | + String pid = runCmd(pidcmd); |
---|
| 420 | + String vid = runCmd(vidcmd); |
---|
| 421 | + return pid+"&"+vid; |
---|
| 422 | + |
---|
| 423 | + } |
---|
| 424 | + |
---|
| 425 | + public static String getWlanId(Context c) { |
---|
| 426 | + int trytime = 0; |
---|
| 427 | + WifiManager mWifiManager = (WifiManager) c.getSystemService(Context.WIFI_SERVICE); |
---|
| 428 | + /* mWifiManager.setWifiEnabled(true); |
---|
| 429 | + while (!mWifiManager.isWifiEnabled()) { |
---|
| 430 | + try { |
---|
| 431 | + Thread.sleep(500); |
---|
| 432 | + trytime ++; |
---|
| 433 | + if (trytime >= 8) { |
---|
| 434 | + Log.e(TAG, "getWlanId(): open wifi timeout!"); |
---|
| 435 | + mWifiManager.setWifiEnabled(false); |
---|
| 436 | + return "err!"; |
---|
| 437 | + } |
---|
| 438 | + } catch (Exception e) { |
---|
| 439 | + } |
---|
| 440 | + }*/ |
---|
| 441 | +// String id = runCmd("/system/bin/iwpriv wlan0 read 1,fc"); |
---|
| 442 | +//// mWifiManager.setWifiEnabled(false); |
---|
| 443 | +// if (id == null) return "err!"; |
---|
| 444 | +// String[] ids = id.split(":"); |
---|
| 445 | +// if (ids.length > 1) { |
---|
| 446 | +// return ids[1]; |
---|
| 447 | +// } |
---|
| 448 | +// return "err!"; |
---|
| 449 | + WifiInfo info = mWifiManager.getConnectionInfo(); |
---|
| 450 | + return info.getMacAddress(); |
---|
| 451 | + |
---|
| 452 | + } |
---|
| 453 | + |
---|
| 454 | +/* public static String getTouchpadId(){ |
---|
| 455 | + String touchpadId=null; |
---|
| 456 | + try { |
---|
| 457 | + IECService ecService; |
---|
| 458 | + ecService=IECService.Stub.asInterface(ServiceManager.getService("ECServiceinfo")); |
---|
| 459 | + if(ecService==null){ |
---|
| 460 | + Log.e(TAG,"Unable to create the ECService instance!"); |
---|
| 461 | + return "Unavailable"; |
---|
| 462 | + } |
---|
| 463 | + int padid=ecService.DeviceCtrl(16,0); |
---|
| 464 | + if(padid==0)touchpadId="Elan"; |
---|
| 465 | + else{ |
---|
| 466 | + if(padid==1)touchpadId="Synaptics"; |
---|
| 467 | + else touchpadId="Unknow"; |
---|
| 468 | + } |
---|
| 469 | + }catch (RemoteException e) { |
---|
| 470 | + // TODO Auto-generated catch block |
---|
| 471 | + Log.e(TAG,"IO Exception when getting touchpadId ",e); |
---|
| 472 | + return "Unavailable"; |
---|
| 473 | + } |
---|
| 474 | + return touchpadId; |
---|
| 475 | + } |
---|
| 476 | + |
---|
| 477 | + public static String getBatteryCell(){ |
---|
| 478 | + String batteryCell=null; |
---|
| 479 | + try { |
---|
| 480 | + IECService ecService; |
---|
| 481 | + ecService=IECService.Stub.asInterface(ServiceManager.getService("ECServiceinfo")); |
---|
| 482 | + if(ecService==null){ |
---|
| 483 | + Log.e(TAG,"Unable to create the ECService instance!"); |
---|
| 484 | + return "Unavailable"; |
---|
| 485 | + } |
---|
| 486 | + int batid=ecService.DeviceCtrl(17,0); |
---|
| 487 | + if(batid==0)batteryCell="Other"; |
---|
| 488 | + else{ |
---|
| 489 | + if(batid==1)batteryCell="Simplo"; |
---|
| 490 | + else batteryCell="Unknow"; |
---|
| 491 | + } |
---|
| 492 | + }catch (RemoteException e) { |
---|
| 493 | + // TODO Auto-generated catch block |
---|
| 494 | + Log.e(TAG,"IO Exception when getting batteryCell ",e); |
---|
| 495 | + return "Unavailable"; |
---|
| 496 | + } |
---|
| 497 | + return batteryCell; |
---|
| 498 | + } |
---|
| 499 | + |
---|
| 500 | + public static String getTouchpanelId(){ |
---|
| 501 | + String touchpanelId=null; |
---|
| 502 | + try { |
---|
| 503 | + IECService ecService; |
---|
| 504 | + ecService=IECService.Stub.asInterface(ServiceManager.getService("ECServiceinfo")); |
---|
| 505 | + if(ecService==null){ |
---|
| 506 | + Log.e(TAG,"Unable to create the ECService instance!"); |
---|
| 507 | + return "Unavailable"; |
---|
| 508 | + } |
---|
| 509 | + int padid=ecService.DeviceCtrl(18,0); |
---|
| 510 | + if(padid==0)touchpanelId="Ofilm"; |
---|
| 511 | + else{ |
---|
| 512 | + if(padid==1)touchpanelId="Mutto"; |
---|
| 513 | + else touchpanelId="Unknow"; |
---|
| 514 | + } |
---|
| 515 | + } catch (RemoteException e) { |
---|
| 516 | + // TODO Auto-generated catch block |
---|
| 517 | + Log.e(TAG,"IO Exception when getting Touchpanel id ",e); |
---|
| 518 | + return "Unavailable"; |
---|
| 519 | + } |
---|
| 520 | + return touchpanelId; |
---|
| 521 | + } |
---|
| 522 | +*/ |
---|
| 523 | + public static String runCmd(String cmd) { |
---|
| 524 | + Process process = null; |
---|
| 525 | + InputStreamReader mISR; |
---|
| 526 | + StringBuilder sBuilder = new StringBuilder(); |
---|
| 527 | + String temp; |
---|
| 528 | + try { |
---|
| 529 | + process = Runtime.getRuntime().exec(cmd); |
---|
| 530 | + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); |
---|
| 531 | +// while ((temp = reader.readLine()) != null) { |
---|
| 532 | +// Log.e("cghs", "temp:"+temp); |
---|
| 533 | +// } |
---|
| 534 | + temp = reader.readLine(); |
---|
| 535 | + process.destroy(); |
---|
| 536 | + reader.close(); |
---|
| 537 | + return temp; |
---|
| 538 | + } catch (IOException e) { |
---|
| 539 | + // TODO Auto-generated catch block |
---|
| 540 | + e.printStackTrace(); |
---|
| 541 | + } |
---|
| 542 | + return null; |
---|
| 543 | + } |
---|
| 544 | + |
---|
| 545 | + |
---|
| 546 | + public static String getBuildNumber() { |
---|
| 547 | + |
---|
| 548 | + String mBuildNum=null; |
---|
| 549 | + String aa=null; |
---|
| 550 | + String Build_number=null; |
---|
| 551 | + mBuildNum=Build.DISPLAY; |
---|
| 552 | + |
---|
| 553 | + int key=mBuildNum.indexOf("A10_S"); |
---|
| 554 | + if(key>0){ |
---|
| 555 | + aa=mBuildNum.substring(key); |
---|
| 556 | + if(aa!=null&&aa.length()>=15) |
---|
| 557 | + Build_number=mBuildNum.substring(key, key+15); |
---|
| 558 | + } |
---|
| 559 | + return Build_number; |
---|
| 560 | + } |
---|
| 561 | + |
---|
| 562 | + //get BTMAC by mw |
---|
| 563 | + public static String getBTMAC() { |
---|
| 564 | + BluetoothAdapter mAdapter = BluetoothAdapter.getDefaultAdapter(); |
---|
| 565 | + // mAdapter.enable(); |
---|
| 566 | + return mAdapter.getAddress(); |
---|
| 567 | + } |
---|
| 568 | + |
---|
| 569 | + //get EMMC by mw |
---|
| 570 | + public static String getEMMC(Context c) { |
---|
| 571 | + File dataPath = Environment.getDataDirectory(); |
---|
| 572 | + StatFs stat = new StatFs(dataPath.getPath()); |
---|
| 573 | + long blockSize = stat.getBlockSize(); |
---|
| 574 | + long availableBlocks = stat.getAvailableBlocks(); |
---|
| 575 | + return Formatter.formatFileSize(c, availableBlocks * blockSize); |
---|
| 576 | + } |
---|
| 577 | + |
---|
| 578 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.helper;
|
---|
| 2 | +
|
---|
| 3 | +import java.io.BufferedReader;
|
---|
| 4 | +import java.io.BufferedWriter;
|
---|
| 5 | +import java.io.DataInputStream;
|
---|
| 6 | +import java.io.DataOutputStream;
|
---|
| 7 | +import java.io.File;
|
---|
| 8 | +import java.io.FileNotFoundException;
|
---|
| 9 | +import java.io.FileOutputStream;
|
---|
| 10 | +import java.io.IOException;
|
---|
| 11 | +import java.io.InputStreamReader;
|
---|
| 12 | +import java.io.OutputStreamWriter;
|
---|
| 13 | +
|
---|
| 14 | +import com.rockchip.newton.UserModeManager;
|
---|
| 15 | +
|
---|
| 16 | +import android.content.pm.PackageManager;
|
---|
| 17 | +import android.graphics.Picture;
|
---|
| 18 | +import android.util.Log;
|
---|
| 19 | +
|
---|
| 20 | +public class SystemUtil {
|
---|
| 21 | + private static final String TAG = "SystemUtil";
|
---|
| 22 | + public static int execShellCmdForStatue(String command) {
|
---|
| 23 | + int status = -1;
|
---|
| 24 | + try {
|
---|
| 25 | + Process p = Runtime.getRuntime().exec(command);
|
---|
| 26 | + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
---|
| 27 | + String s = "";
|
---|
| 28 | + while((s = bufferedReader.readLine()) != null){
|
---|
| 29 | + Log.d(TAG, " >>>> " + s);
|
---|
| 30 | + }
|
---|
| 31 | + status = p.waitFor();
|
---|
| 32 | + Log.d(TAG, " ________________----------- command: " + command + " status = " + status);
|
---|
| 33 | + } catch (Exception e) {
|
---|
| 34 | + e.printStackTrace();
|
---|
| 35 | + }
|
---|
| 36 | + return status;
|
---|
| 37 | +
|
---|
| 38 | + }
|
---|
| 39 | +
|
---|
| 40 | + public static String execShellCmd(String command) {
|
---|
| 41 | + String result = "";
|
---|
| 42 | + Log.i("execShellCmd", command);
|
---|
| 43 | + try {
|
---|
| 44 | + Process process = Runtime.getRuntime().exec(command + "\n");
|
---|
| 45 | + DataOutputStream stdin = new DataOutputStream(
|
---|
| 46 | + process.getOutputStream());
|
---|
| 47 | + DataInputStream stdout = new DataInputStream(
|
---|
| 48 | + process.getInputStream());
|
---|
| 49 | + DataInputStream stderr = new DataInputStream(
|
---|
| 50 | + process.getErrorStream());
|
---|
| 51 | + String line;
|
---|
| 52 | + while ((line = stdout.readLine()) != null) {
|
---|
| 53 | + result += line + "\n";
|
---|
| 54 | + }
|
---|
| 55 | + if (result.length() > 0) {
|
---|
| 56 | + result = result.substring(0, result.length() - 1);
|
---|
| 57 | + }
|
---|
| 58 | + while ((line = stderr.readLine()) != null) {
|
---|
| 59 | + Log.e("EXEC", line);
|
---|
| 60 | + }
|
---|
| 61 | + process.waitFor();
|
---|
| 62 | + } catch (Exception e) {
|
---|
| 63 | + e.getMessage();
|
---|
| 64 | + }
|
---|
| 65 | + return result;
|
---|
| 66 | + }
|
---|
| 67 | +
|
---|
| 68 | + public static String execRootCmd(String command) {
|
---|
| 69 | + int userMode = UserModeManager.getCurrentUserMode();
|
---|
| 70 | + UserModeManager.switchToUserMode(UserModeManager.SUPER_USER_MODE);
|
---|
| 71 | +
|
---|
| 72 | + String result = execShellCmd("su root " + command + "\n");
|
---|
| 73 | +
|
---|
| 74 | + UserModeManager.switchToUserMode(userMode);
|
---|
| 75 | +
|
---|
| 76 | + return result;
|
---|
| 77 | + }
|
---|
| 78 | +
|
---|
| 79 | + public static String execScriptCmd(String command, String path, boolean root) {
|
---|
| 80 | + int userMode = UserModeManager.getCurrentUserMode();
|
---|
| 81 | + UserModeManager.switchToUserMode(UserModeManager.SUPER_USER_MODE);
|
---|
| 82 | + File tempFile = null;
|
---|
| 83 | + String result = "";
|
---|
| 84 | + Log.i("execScriptCmd", command);
|
---|
| 85 | + try {
|
---|
| 86 | + tempFile = new File(path);
|
---|
| 87 | + tempFile.deleteOnExit();
|
---|
| 88 | + BufferedWriter br = new BufferedWriter(new OutputStreamWriter(
|
---|
| 89 | + new FileOutputStream(tempFile)));
|
---|
| 90 | + br.write("#!/system/bin/sh\n");
|
---|
| 91 | + br.write(command);
|
---|
| 92 | + br.close();
|
---|
| 93 | + SystemUtil.execShellCmd("su root chmod 777 "
|
---|
| 94 | + + tempFile.getAbsolutePath());
|
---|
| 95 | + result = SystemUtil.execShellCmd((root ? "su root " : "")
|
---|
| 96 | + + tempFile.getAbsolutePath());
|
---|
| 97 | + } catch (FileNotFoundException e) {
|
---|
| 98 | + e.printStackTrace();
|
---|
| 99 | + } catch (IOException e) {
|
---|
| 100 | + e.printStackTrace();
|
---|
| 101 | + } finally {
|
---|
| 102 | + if (tempFile != null && tempFile.exists()) {
|
---|
| 103 | + tempFile.delete();
|
---|
| 104 | + }
|
---|
| 105 | + }
|
---|
| 106 | + UserModeManager.switchToUserMode(userMode);
|
---|
| 107 | + return result;
|
---|
| 108 | + }
|
---|
| 109 | +
|
---|
| 110 | + public static boolean killProcessByPath(String exePath) {
|
---|
| 111 | + File dir = new File("/proc/");
|
---|
| 112 | + String[] files = dir.list();
|
---|
| 113 | + int pid = -1;
|
---|
| 114 | + for (String path : files) {
|
---|
| 115 | + File file = new File("/proc/" + path + "/cmdline");
|
---|
| 116 | + if (file.exists()) {
|
---|
| 117 | + String cmdline = execShellCmd("cat " + file.getAbsolutePath());
|
---|
| 118 | + if (cmdline.startsWith(exePath)) {
|
---|
| 119 | + try {
|
---|
| 120 | + pid = Integer.parseInt(path);
|
---|
| 121 | + break;
|
---|
| 122 | + } catch (Exception e) {
|
---|
| 123 | + break;
|
---|
| 124 | + }
|
---|
| 125 | + }
|
---|
| 126 | + }
|
---|
| 127 | + }
|
---|
| 128 | +
|
---|
| 129 | + if (pid >= 0) {
|
---|
| 130 | + int userMode = UserModeManager.getCurrentUserMode();
|
---|
| 131 | + UserModeManager.switchToUserMode(UserModeManager.SUPER_USER_MODE);
|
---|
| 132 | + execShellCmd("su root kill " + pid);
|
---|
| 133 | + UserModeManager.switchToUserMode(userMode);
|
---|
| 134 | + return true;
|
---|
| 135 | + }
|
---|
| 136 | + return false;
|
---|
| 137 | + }
|
---|
| 138 | +
|
---|
| 139 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.helper;
|
---|
| 2 | +
|
---|
| 3 | +import java.io.IOException;
|
---|
| 4 | +import java.io.Serializable;
|
---|
| 5 | +
|
---|
| 6 | +public class TestCase implements Serializable {
|
---|
| 7 | + public static enum RESULT {
|
---|
| 8 | + NG, OK, SKIP, UNDEF,
|
---|
| 9 | + }
|
---|
| 10 | +
|
---|
| 11 | + private int testNo;
|
---|
| 12 | + private boolean needtest;
|
---|
| 13 | + private String testName;
|
---|
| 14 | + private String className;
|
---|
| 15 | + private RESULT result = RESULT.UNDEF;
|
---|
| 16 | + private String detail;
|
---|
| 17 | + private boolean showResult;
|
---|
| 18 | +
|
---|
| 19 | + public boolean isShowResult() {
|
---|
| 20 | + return showResult;
|
---|
| 21 | + }
|
---|
| 22 | +
|
---|
| 23 | + public void setShowResult(boolean showResult) {
|
---|
| 24 | + this.showResult = showResult;
|
---|
| 25 | + }
|
---|
| 26 | +
|
---|
| 27 | + public String getDetail() {
|
---|
| 28 | + return detail;
|
---|
| 29 | + }
|
---|
| 30 | +
|
---|
| 31 | + public void setDetail(String detail) {
|
---|
| 32 | + this.detail = detail;
|
---|
| 33 | + }
|
---|
| 34 | +
|
---|
| 35 | + public TestCase(int testNo, String testName, String className) {
|
---|
| 36 | + this.testNo = testNo;
|
---|
| 37 | + this.testName = testName;
|
---|
| 38 | + this.className = className;
|
---|
| 39 | + this.needtest = true;
|
---|
| 40 | + showResult = true;
|
---|
| 41 | + }
|
---|
| 42 | + public boolean getneedtest(){
|
---|
| 43 | + return this.needtest;
|
---|
| 44 | + }
|
---|
| 45 | + public void setneedtest(boolean tmp){
|
---|
| 46 | + this.needtest = tmp;
|
---|
| 47 | + }
|
---|
| 48 | + public String getClassName() {
|
---|
| 49 | + return className;
|
---|
| 50 | + }
|
---|
| 51 | +
|
---|
| 52 | + public RESULT getResult() {
|
---|
| 53 | + return result;
|
---|
| 54 | + }
|
---|
| 55 | +
|
---|
| 56 | + public String getTestName() {
|
---|
| 57 | + return testName;
|
---|
| 58 | + }
|
---|
| 59 | +
|
---|
| 60 | + public int getTestNo() {
|
---|
| 61 | + return testNo;
|
---|
| 62 | + }
|
---|
| 63 | +
|
---|
| 64 | + public void setResult(RESULT result) {
|
---|
| 65 | + this.result = result;
|
---|
| 66 | + }
|
---|
| 67 | +
|
---|
| 68 | + private void writeObject(java.io.ObjectOutputStream out) throws IOException {
|
---|
| 69 | + out.writeObject(className);
|
---|
| 70 | + out.writeInt(result.ordinal());
|
---|
| 71 | + out.writeObject(detail);
|
---|
| 72 | + out.writeBoolean(showResult);
|
---|
| 73 | + }
|
---|
| 74 | +
|
---|
| 75 | + private void readObject(java.io.ObjectInputStream in) throws IOException,
|
---|
| 76 | + ClassNotFoundException {
|
---|
| 77 | + Object object = in.readObject();
|
---|
| 78 | + if (null != object) {
|
---|
| 79 | + className = object.toString();
|
---|
| 80 | + }
|
---|
| 81 | + result = RESULT.values()[in.readInt()];
|
---|
| 82 | + object = in.readObject();
|
---|
| 83 | + if (null != object) {
|
---|
| 84 | + detail = object.toString();
|
---|
| 85 | + }
|
---|
| 86 | + showResult = in.readBoolean();
|
---|
| 87 | + }
|
---|
| 88 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.helper; |
---|
| 2 | + |
---|
| 3 | +import java.util.Map; |
---|
| 4 | + |
---|
| 5 | +import android.content.Context; |
---|
| 6 | +import android.graphics.Canvas; |
---|
| 7 | +import android.graphics.Color; |
---|
| 8 | +import android.graphics.Paint; |
---|
| 9 | +import android.graphics.drawable.Drawable; |
---|
| 10 | +import android.util.AttributeSet; |
---|
| 11 | +import android.view.View; |
---|
| 12 | + |
---|
| 13 | +public class VUMeter extends View { |
---|
| 14 | + static final float PIVOT_RADIUS = 3.5f; |
---|
| 15 | + static final float PIVOT_Y_OFFSET = 10f; |
---|
| 16 | + static final float SHADOW_OFFSET = 2.0f; |
---|
| 17 | + static final float DROPOFF_STEP = 0.18f; |
---|
| 18 | + static final float SURGE_STEP = 0.35f; |
---|
| 19 | + static final long ANIMATION_INTERVAL = 70; |
---|
| 20 | + |
---|
| 21 | + Paint mPaint, mShadow; |
---|
| 22 | + float mCurrentAngle; |
---|
| 23 | + |
---|
| 24 | + Recorder mRecorder; |
---|
| 25 | + |
---|
| 26 | + public VUMeter(Context context) { |
---|
| 27 | + super(context); |
---|
| 28 | + init(context); |
---|
| 29 | + } |
---|
| 30 | + |
---|
| 31 | + public VUMeter(Context context, AttributeSet attrs) { |
---|
| 32 | + super(context, attrs); |
---|
| 33 | + init(context); |
---|
| 34 | + } |
---|
| 35 | + |
---|
| 36 | + void init(Context context) { |
---|
| 37 | +// Drawable background = getResources().getDrawable(R.drawable.vumeter); |
---|
| 38 | +// setBackgroundDrawable(background); |
---|
| 39 | + |
---|
| 40 | + mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); |
---|
| 41 | + mPaint.setColor(Color.WHITE); |
---|
| 42 | + mShadow = new Paint(Paint.ANTI_ALIAS_FLAG); |
---|
| 43 | + mShadow.setColor(Color.argb(60, 0, 0, 0)); |
---|
| 44 | + |
---|
| 45 | + mRecorder = null; |
---|
| 46 | + |
---|
| 47 | + mCurrentAngle = 0; |
---|
| 48 | + } |
---|
| 49 | + |
---|
| 50 | + public void setRecorder(Recorder recorder) { |
---|
| 51 | + mRecorder = recorder; |
---|
| 52 | + invalidate(); |
---|
| 53 | + } |
---|
| 54 | + |
---|
| 55 | + @Override |
---|
| 56 | + protected void onDraw(Canvas canvas) { |
---|
| 57 | + super.onDraw(canvas); |
---|
| 58 | + |
---|
| 59 | + final float minAngle = (float)Math.PI/8; |
---|
| 60 | + final float maxAngle = (float)Math.PI*7/8; |
---|
| 61 | + |
---|
| 62 | + float angle = minAngle; |
---|
| 63 | + if (mRecorder != null) |
---|
| 64 | + angle += (float)(maxAngle - minAngle)*mRecorder.getMaxAmplitude()/32768; |
---|
| 65 | + |
---|
| 66 | + if (angle > mCurrentAngle) |
---|
| 67 | + mCurrentAngle = angle; |
---|
| 68 | + else |
---|
| 69 | + mCurrentAngle = Math.max(angle, mCurrentAngle - DROPOFF_STEP); |
---|
| 70 | + |
---|
| 71 | + mCurrentAngle = Math.min(maxAngle, mCurrentAngle); |
---|
| 72 | + |
---|
| 73 | + float w = getWidth(); |
---|
| 74 | + float h = getHeight(); |
---|
| 75 | + float pivotX = w/2; |
---|
| 76 | + float pivotY = h - PIVOT_RADIUS - PIVOT_Y_OFFSET; |
---|
| 77 | + float l = h*4/5; |
---|
| 78 | + float sin = (float) Math.sin(mCurrentAngle); |
---|
| 79 | + float cos = (float) Math.cos(mCurrentAngle); |
---|
| 80 | + float x0 = pivotX - l*cos; |
---|
| 81 | + float y0 = pivotY - l*sin; |
---|
| 82 | + canvas.drawLine(x0 + SHADOW_OFFSET, y0 + SHADOW_OFFSET, pivotX + SHADOW_OFFSET, pivotY + SHADOW_OFFSET, mShadow); |
---|
| 83 | + canvas.drawCircle(pivotX + SHADOW_OFFSET, pivotY + SHADOW_OFFSET, PIVOT_RADIUS, mShadow); |
---|
| 84 | + canvas.drawLine(x0, y0, pivotX, pivotY, mPaint); |
---|
| 85 | + canvas.drawCircle(pivotX, pivotY, PIVOT_RADIUS, mPaint); |
---|
| 86 | + |
---|
| 87 | + if (mRecorder != null && mRecorder.state() == Recorder.RECORDING_STATE) |
---|
| 88 | + postInvalidateDelayed(ANIMATION_INTERVAL); |
---|
| 89 | + } |
---|
| 90 | +} |
---|
.. | .. |
---|
| 1 | +/*
|
---|
| 2 | + * Copyright (C) 2009 The Rockchip Android MID 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.DeviceTest.helper;
|
---|
| 18 | +
|
---|
| 19 | +import java.util.Formatter;
|
---|
| 20 | +import java.util.List;
|
---|
| 21 | +import java.util.Locale;
|
---|
| 22 | +
|
---|
| 23 | +import android.content.AsyncQueryHandler;
|
---|
| 24 | +import android.content.ContentResolver;
|
---|
| 25 | +import android.content.ContentUris;
|
---|
| 26 | +import android.content.Context;
|
---|
| 27 | +import android.database.CharArrayBuffer;
|
---|
| 28 | +import android.database.Cursor;
|
---|
| 29 | +import android.graphics.Bitmap;
|
---|
| 30 | +import android.graphics.drawable.Drawable;
|
---|
| 31 | +import android.net.Uri;
|
---|
| 32 | +import android.provider.MediaStore;
|
---|
| 33 | +import android.media.MediaMetadataRetriever;
|
---|
| 34 | +import android.util.Log;
|
---|
| 35 | +import android.view.LayoutInflater;
|
---|
| 36 | +import android.view.View;
|
---|
| 37 | +import android.view.ViewGroup;
|
---|
| 38 | +import android.widget.AlphabetIndexer;
|
---|
| 39 | +import android.widget.ArrayAdapter;
|
---|
| 40 | +import android.widget.ImageView;
|
---|
| 41 | +import android.widget.LinearLayout;
|
---|
| 42 | +import android.widget.SectionIndexer;
|
---|
| 43 | +import android.widget.SimpleCursorAdapter;
|
---|
| 44 | +import android.widget.TextView;
|
---|
| 45 | +
|
---|
| 46 | +import com.DeviceTest.R;
|
---|
| 47 | +import com.DeviceTest.RockVideoPlayer;
|
---|
| 48 | +
|
---|
| 49 | +
|
---|
| 50 | +class VideoItem {
|
---|
| 51 | + Drawable bitmap;
|
---|
| 52 | + Uri uri;
|
---|
| 53 | + int Totaltime;
|
---|
| 54 | + int Lasttime;
|
---|
| 55 | + int Currenttime;
|
---|
| 56 | + String videoname;
|
---|
| 57 | + String mimetype;
|
---|
| 58 | + String size;
|
---|
| 59 | + String videopath;
|
---|
| 60 | +}
|
---|
| 61 | +/*
|
---|
| 62 | +class Item implements Comparable<Item>{
|
---|
| 63 | + private static final String TAG = "Item";
|
---|
| 64 | + //private static final boolean DEBUG = true;
|
---|
| 65 | + private static final boolean DEBUG = false;
|
---|
| 66 | + public void LOG(String msg)
|
---|
| 67 | + {
|
---|
| 68 | + if(DEBUG)
|
---|
| 69 | + {
|
---|
| 70 | + Log.d(TAG,msg);
|
---|
| 71 | + }
|
---|
| 72 | + }
|
---|
| 73 | +
|
---|
| 74 | + public int compareTo(Item another) {
|
---|
| 75 | + // TODO Auto-generated method stub
|
---|
| 76 | + return 0;
|
---|
| 77 | + }
|
---|
| 78 | +
|
---|
| 79 | +}
|
---|
| 80 | +*/
|
---|
| 81 | +public class VideoListAdapter extends SimpleCursorAdapter
|
---|
| 82 | +implements SectionIndexer {
|
---|
| 83 | + int resource;
|
---|
| 84 | + //private final LayoutInflater mInflater;
|
---|
| 85 | + private static final String TAG = "VideoListAdapter";
|
---|
| 86 | + private static final boolean DEBUG = true;
|
---|
| 87 | + //private static final boolean DEBUG = false;
|
---|
| 88 | + private RockVideoPlayer mActivity = null;
|
---|
| 89 | + /** @see AlphabetIndexer. */
|
---|
| 90 | + private AlphabetIndexer mIndexer;
|
---|
| 91 | + /** ����Э��ʵ�ֶ� ContentResolver �첽�� query ������ helper ���ʵ��. */
|
---|
| 92 | + private AsyncQueryHandler mQueryHandler;
|
---|
| 93 | + int nameIdx;
|
---|
| 94 | + Uri uriIdx;
|
---|
| 95 | + int idIdx;
|
---|
| 96 | + int mimetypeIdx;
|
---|
| 97 | + int bookmarkIdx;
|
---|
| 98 | + int durationIdx;
|
---|
| 99 | + int sizeIdx;
|
---|
| 100 | + int pahtIdx;
|
---|
| 101 | + private String mConstraint = null;
|
---|
| 102 | + private boolean mConstraintIsValid = false;
|
---|
| 103 | + public void LOG(String msg)
|
---|
| 104 | + {
|
---|
| 105 | + if(DEBUG)
|
---|
| 106 | + {
|
---|
| 107 | + Log.d(TAG,msg);
|
---|
| 108 | + }
|
---|
| 109 | + }
|
---|
| 110 | +
|
---|
| 111 | + public VideoListAdapter(Context context,
|
---|
| 112 | + RockVideoPlayer currentactivity,
|
---|
| 113 | + int layout,
|
---|
| 114 | + Cursor cursor,
|
---|
| 115 | + String[] from,
|
---|
| 116 | + int[] to) {
|
---|
| 117 | + super(context, layout, cursor, from, to);
|
---|
| 118 | + mActivity = currentactivity;
|
---|
| 119 | + getColumnIndices(cursor);
|
---|
| 120 | + mQueryHandler = new QueryHandler(context.getContentResolver()); /* ����ת��. */
|
---|
| 121 | + LOG("Built mQueryHandler = " + mQueryHandler);
|
---|
| 122 | + }
|
---|
| 123 | +
|
---|
| 124 | + public void setActivity(RockVideoPlayer newactivity) {
|
---|
| 125 | + mActivity = newactivity;
|
---|
| 126 | + }
|
---|
| 127 | + class ViewHolder {
|
---|
| 128 | + // ��u21069 list item view �� ��u26469 ��u31034 ��u24212 data item(��u-28212 ��iju20010 ��u23450 ��u27468 ��u30340 ��u24687 ) ��column "TITLE" ��value ��TextView ��u24341 ��
|
---|
| 129 | + ImageView video_icon;
|
---|
| 130 | + TextView video_name;
|
---|
| 131 | + TextView video_time;
|
---|
| 132 | + TextView video_type;
|
---|
| 133 | + TextView video_size;
|
---|
| 134 | + TextView video_path;
|
---|
| 135 | + CharArrayBuffer buffer1;
|
---|
| 136 | + // ��u26469 ��u23384 "ARTIST" ��u20018 .
|
---|
| 137 | + char [] buffer2;
|
---|
| 138 | + }
|
---|
| 139 | + /**
|
---|
| 140 | + * ���Ƶ� AsyncQueryHandler ����.
|
---|
| 141 | + * @see AsyncQueryHandler.
|
---|
| 142 | + * */
|
---|
| 143 | + class QueryHandler extends AsyncQueryHandler {
|
---|
| 144 | + /** Ctor. */
|
---|
| 145 | + QueryHandler(ContentResolver res) {
|
---|
| 146 | + super(res);
|
---|
| 147 | + }
|
---|
| 148 | + @Override
|
---|
| 149 | + protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
|
---|
| 150 | + //LOG("@@@ query complete: " + cursor.getCount() + " ");
|
---|
| 151 | + /* ��ʼ�� ��ǰ activity. */
|
---|
| 152 | + mActivity.initVideoCursor(cursor);
|
---|
| 153 | + }
|
---|
| 154 | + }
|
---|
| 155 | + public AsyncQueryHandler getQueryHandler() {
|
---|
| 156 | + return mQueryHandler;
|
---|
| 157 | + }
|
---|
| 158 | + /**
|
---|
| 159 | + * ��ȡָͬ�� Cursor ʵ����ص� �ض��� column �� index, �������� "this"(��ǰ����ʵ��) ��.
|
---|
| 160 | + * �������� �����и�.
|
---|
| 161 | + */
|
---|
| 162 | + private void getColumnIndices(Cursor cur) {
|
---|
| 163 | +
|
---|
| 164 | + LOG("Enter getColumnIndices() and cur = " + cur);
|
---|
| 165 | + Uri uri = MediaStore.Video.Media.getContentUri("external");
|
---|
| 166 | + if (cur!= null) {
|
---|
| 167 | + cur.moveToFirst();
|
---|
| 168 | + nameIdx = cur.getColumnIndexOrThrow(MediaStore.Video.Media.DISPLAY_NAME);
|
---|
| 169 | + LOG("nameIdx= " + nameIdx);
|
---|
| 170 | + uriIdx = ContentUris.withAppendedId(uri,cur.getColumnIndexOrThrow(MediaStore.Video.Media._ID));
|
---|
| 171 | + LOG("uriIdx= " + uriIdx);
|
---|
| 172 | + idIdx = cur.getColumnIndexOrThrow(MediaStore.Video.Media._ID);
|
---|
| 173 | + mimetypeIdx = cur.getColumnIndexOrThrow(MediaStore.Video.Media.MIME_TYPE);
|
---|
| 174 | + LOG("mimetypeIdx= " + mimetypeIdx);
|
---|
| 175 | + bookmarkIdx = cur.getColumnIndexOrThrow(MediaStore.Video.Media.BOOKMARK);
|
---|
| 176 | + LOG("bookmarkIdx= " + bookmarkIdx);
|
---|
| 177 | + durationIdx = cur.getColumnIndexOrThrow(MediaStore.Video.Media.DURATION);
|
---|
| 178 | + LOG("durationIdx= " + durationIdx);
|
---|
| 179 | + sizeIdx = cur.getColumnIndexOrThrow(MediaStore.Video.Media.SIZE);
|
---|
| 180 | + LOG("sizeIdx= " + sizeIdx);
|
---|
| 181 | + pahtIdx = cur.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
|
---|
| 182 | + LOG("pahtIdx= " + pahtIdx);
|
---|
| 183 | + }
|
---|
| 184 | + }
|
---|
| 185 | + @Override
|
---|
| 186 | + public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
---|
| 187 | + View v = super.newView(context, cursor, parent);
|
---|
| 188 | +
|
---|
| 189 | + ViewHolder vh = new ViewHolder();
|
---|
| 190 | + vh.video_icon = (ImageView)v.findViewById(R.id.video_image);
|
---|
| 191 | + vh.video_name = (TextView)v.findViewById(R.id.video_name);
|
---|
| 192 | + vh.video_time = (TextView)v.findViewById(R.id.time_info);
|
---|
| 193 | + vh.video_type = (TextView)v.findViewById(R.id.type_info);
|
---|
| 194 | + vh.video_size = (TextView)v.findViewById(R.id.size_info);
|
---|
| 195 | + //vh.video_path = (TextView)v.findViewById(R.id.path_info);
|
---|
| 196 | + vh.buffer1 = new CharArrayBuffer(100);
|
---|
| 197 | + vh.buffer2 = new char[200];
|
---|
| 198 | + v.setTag(vh);
|
---|
| 199 | + return v;
|
---|
| 200 | + }
|
---|
| 201 | + @Override
|
---|
| 202 | + public void bindView(View view, Context context, Cursor cursor) {
|
---|
| 203 | + ViewHolder vh = (ViewHolder) view.getTag(); /* ����ض��� list item view, �������� newView() ֮����. ����� ����ת�͵���ȷ��, "����" �ɳ���Ա��֤. */
|
---|
| 204 | + cursor.copyStringToBuffer(nameIdx, vh.buffer1);
|
---|
| 205 | + vh.video_name.setText(vh.buffer1.data, 0, vh.buffer1.sizeCopied);
|
---|
| 206 | + mFormatBuilder = new StringBuilder();
|
---|
| 207 | + mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());
|
---|
| 208 | + vh.video_time.setText(makeTimeString(cursor.getInt(bookmarkIdx),cursor.getInt(durationIdx)));
|
---|
| 209 | + vh.video_type.setText(cursor.getString(mimetypeIdx));
|
---|
| 210 | + vh.video_size.setText(makeSizeString(cursor.getInt(sizeIdx)));
|
---|
| 211 | + //vh.video_path.setText(cursor.getString(pahtIdx));
|
---|
| 212 | + ImageView iv = vh.video_icon;
|
---|
| 213 | + iv.setImageResource(R.drawable.video_icon);
|
---|
| 214 | + //iv.setImageBitmap(getVideoCover(cursor.getString(pahtIdx)));
|
---|
| 215 | + }
|
---|
| 216 | + @Override
|
---|
| 217 | + public void changeCursor(Cursor cursor) {
|
---|
| 218 | + //LOG("Enter changeCursor() get "+ cursor.getCount() + "and cursor = " + cursor);
|
---|
| 219 | +
|
---|
| 220 | + if(cursor != null)
|
---|
| 221 | + cursor.moveToFirst();
|
---|
| 222 | + if (cursor != mActivity.mVideoCursor) {
|
---|
| 223 | + super.changeCursor(cursor);
|
---|
| 224 | + mActivity.mVideoCursor = cursor;
|
---|
| 225 | + getColumnIndices(cursor); /* ��Ϊ "cursor" ʵ��仯, �������е� column ID Ҳ���ܱ仯. �ʸ���֮. */
|
---|
| 226 | + }
|
---|
| 227 | + }
|
---|
| 228 | + @Override
|
---|
| 229 | + public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
|
---|
| 230 | + String s = constraint.toString();
|
---|
| 231 | + if (mConstraintIsValid
|
---|
| 232 | + && ( (s == null && mConstraint == null)
|
---|
| 233 | + || (s != null && s.equals(mConstraint)))) {
|
---|
| 234 | + return getCursor();
|
---|
| 235 | + }
|
---|
| 236 | + Cursor c = mActivity.getVideoCursor(null);
|
---|
| 237 | + mConstraint = s;
|
---|
| 238 | + mConstraintIsValid = true;
|
---|
| 239 | + return c;
|
---|
| 240 | + }
|
---|
| 241 | +
|
---|
| 242 | + StringBuilder mFormatBuilder;
|
---|
| 243 | + Formatter mFormatter;
|
---|
| 244 | +
|
---|
| 245 | + public String stringForTime(int timeMs)
|
---|
| 246 | + {
|
---|
| 247 | + int totalSeconds = timeMs / 1000;
|
---|
| 248 | +
|
---|
| 249 | + int seconds = totalSeconds % 60;
|
---|
| 250 | + int minutes = (totalSeconds / 60) % 60;
|
---|
| 251 | + int hours = totalSeconds / 3600;
|
---|
| 252 | +
|
---|
| 253 | + mFormatBuilder.setLength(0);
|
---|
| 254 | +
|
---|
| 255 | + if(hours > 0)
|
---|
| 256 | + return mFormatter.format("%02d:%02d:%02d", hours, minutes, seconds).toString();
|
---|
| 257 | + else
|
---|
| 258 | + return mFormatter.format("%02d:%02d", minutes, seconds).toString();
|
---|
| 259 | + }
|
---|
| 260 | +
|
---|
| 261 | + public String makeTimeString(int time1,int time2)
|
---|
| 262 | + {
|
---|
| 263 | + StringBuilder time = new StringBuilder();
|
---|
| 264 | + time.append(stringForTime(time1)+'/'+stringForTime(time2));
|
---|
| 265 | + return time.toString();
|
---|
| 266 | + }
|
---|
| 267 | +
|
---|
| 268 | + public String makeSizeString(int size){
|
---|
| 269 | + StringBuilder sizeBuilder = new StringBuilder();
|
---|
| 270 | + if (size <= 0){
|
---|
| 271 | + sizeBuilder.append("0 K");
|
---|
| 272 | + return sizeBuilder.toString();
|
---|
| 273 | + }
|
---|
| 274 | + int sizeK = size/1000;
|
---|
| 275 | + int sizeM = sizeK/1000;
|
---|
| 276 | + if(0 < sizeK && sizeK < 1024){
|
---|
| 277 | + sizeBuilder.append(sizeK);
|
---|
| 278 | + sizeBuilder.append(" K");
|
---|
| 279 | + return sizeBuilder.toString();
|
---|
| 280 | + }else{
|
---|
| 281 | + sizeBuilder.append(sizeM);
|
---|
| 282 | + sizeBuilder.append(" M");
|
---|
| 283 | + return sizeBuilder.toString();
|
---|
| 284 | + }
|
---|
| 285 | + }
|
---|
| 286 | + public int getSectionForPosition(int position) {
|
---|
| 287 | + return 0;
|
---|
| 288 | + }
|
---|
| 289 | +
|
---|
| 290 | + public int getPositionForSection(int section) {
|
---|
| 291 | + int pos = mIndexer.getPositionForSection(section);
|
---|
| 292 | + return pos;
|
---|
| 293 | + }
|
---|
| 294 | +
|
---|
| 295 | + public Object[] getSections() {
|
---|
| 296 | + if (mIndexer != null) {
|
---|
| 297 | + return mIndexer.getSections();
|
---|
| 298 | + } else {
|
---|
| 299 | + return null;
|
---|
| 300 | + }
|
---|
| 301 | + }
|
---|
| 302 | +
|
---|
| 303 | +
|
---|
| 304 | +}
|
---|
| 305 | +
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.helper;
|
---|
| 2 | +
|
---|
| 3 | +import java.io.FileWriter;
|
---|
| 4 | +import java.io.IOException;
|
---|
| 5 | +import java.io.InputStream;
|
---|
| 6 | +
|
---|
| 7 | +import java.util.ArrayList;
|
---|
| 8 | +import java.util.Date;
|
---|
| 9 | +import java.util.HashMap;
|
---|
| 10 | +import java.util.List;
|
---|
| 11 | +import java.util.Map;
|
---|
| 12 | +import android.hardware.Camera;
|
---|
| 13 | +import android.hardware.Camera.CameraInfo;
|
---|
| 14 | +import android.content.res.XmlResourceParser;
|
---|
| 15 | +import android.os.SystemClock;
|
---|
| 16 | +import android.util.Log;
|
---|
| 17 | +import android.util.Xml;
|
---|
| 18 | +
|
---|
| 19 | +import javax.xml.parsers.DocumentBuilder;
|
---|
| 20 | +import javax.xml.parsers.DocumentBuilderFactory;
|
---|
| 21 | +import javax.xml.parsers.ParserConfigurationException;
|
---|
| 22 | +import org.w3c.dom.Document;
|
---|
| 23 | +import org.w3c.dom.Node;
|
---|
| 24 | +import org.w3c.dom.NodeList;
|
---|
| 25 | +import org.xml.sax.SAXException;
|
---|
| 26 | +import org.xmlpull.v1.XmlSerializer;
|
---|
| 27 | +
|
---|
| 28 | +import com.DeviceTest.DeviceTest;
|
---|
| 29 | +import android.content.res.Resources;
|
---|
| 30 | +public class XmlDeal {
|
---|
| 31 | +
|
---|
| 32 | + private static final String TAG = "XmlDeal";
|
---|
| 33 | + /**/
|
---|
| 34 | + private static final String XML_ROOT_TAG = "TestCaseList";
|
---|
| 35 | + private static final String XML_NODE_TAG = "TestCase";
|
---|
| 36 | +
|
---|
| 37 | + private static final String CLASS_NAME_TAG = "class_name";
|
---|
| 38 | + private static final String TEST_NAME_TAG = "test_name";
|
---|
| 39 | + private static final String RESULT_TAG = "result";
|
---|
| 40 | + private static final String TEST_GROUP_TAG = "test_group";
|
---|
| 41 | + private static final String TEST_FIRST = "first_test";
|
---|
| 42 | +
|
---|
| 43 | + public List<TestCase> mTestCases = null;
|
---|
| 44 | + public Map<String, List<TestCase>> mCaseGroups = null;
|
---|
| 45 | +
|
---|
| 46 | + public XmlDeal(InputStream is) {
|
---|
| 47 | + mTestCases = new ArrayList<TestCase>();
|
---|
| 48 | + mCaseGroups = new HashMap<String, List<TestCase>>();
|
---|
| 49 | + if (!ParseXml(is)) {
|
---|
| 50 | + throw new RuntimeException();
|
---|
| 51 | + }
|
---|
| 52 | + }
|
---|
| 53 | +
|
---|
| 54 | + private boolean ParseXml(InputStream is) {
|
---|
| 55 | +
|
---|
| 56 | + DocumentBuilderFactory docBuilderFactory = null;
|
---|
| 57 | + DocumentBuilder docBuilder = null;
|
---|
| 58 | + Document doc = null;
|
---|
| 59 | + try {
|
---|
| 60 | + docBuilderFactory = DocumentBuilderFactory.newInstance();
|
---|
| 61 | + docBuilder = docBuilderFactory.newDocumentBuilder();
|
---|
| 62 | +
|
---|
| 63 | + doc = docBuilder.parse(is);
|
---|
| 64 | + NodeList nodeList = doc.getElementsByTagName(XML_ROOT_TAG);
|
---|
| 65 | +
|
---|
| 66 | + int length = nodeList.getLength();
|
---|
| 67 | + List<TestCase> caseGroup = null;
|
---|
| 68 | + for (int i = 0; i < length; i++) {
|
---|
| 69 | + Node item = nodeList.item(i);
|
---|
| 70 | +
|
---|
| 71 | + int testNo = 0;
|
---|
| 72 | + caseGroup = null;
|
---|
| 73 | + for (Node node = item.getFirstChild(); node != null; node = node
|
---|
| 74 | + .getNextSibling()) {
|
---|
| 75 | + if (node.getNodeType() == Node.ELEMENT_NODE) {
|
---|
| 76 | +
|
---|
| 77 | + String testName = null;
|
---|
| 78 | + String className = null;
|
---|
| 79 | + boolean isfirsttest = false;
|
---|
| 80 | + for (int j = 0; j < node.getAttributes().getLength(); j++) {
|
---|
| 81 | + String attrValue = node.getAttributes().item(j)
|
---|
| 82 | + .getNodeValue();
|
---|
| 83 | + String attrName = node.getAttributes().item(j)
|
---|
| 84 | + .getNodeName();
|
---|
| 85 | + if (attrName.equals(CLASS_NAME_TAG)) {
|
---|
| 86 | + className = attrValue;
|
---|
| 87 | + } else if (attrName.equals(TEST_GROUP_TAG)) {
|
---|
| 88 | + caseGroup = mCaseGroups.get(attrValue);
|
---|
| 89 | + if (caseGroup == null) {
|
---|
| 90 | + caseGroup = new ArrayList<TestCase>();
|
---|
| 91 | + mCaseGroups.put(attrValue, caseGroup);
|
---|
| 92 | + }
|
---|
| 93 | + }else if(attrName.equals(TEST_FIRST)){
|
---|
| 94 | + isfirsttest = true;
|
---|
| 95 | + }
|
---|
| 96 | + }
|
---|
| 97 | +
|
---|
| 98 | +
|
---|
| 99 | + testName = node.getFirstChild().getNodeValue();
|
---|
| 100 | + Log.i(TAG, "-----getTestItemName:" + testName + " isfirsttest = " + isfirsttest);
|
---|
| 101 | +
|
---|
| 102 | +
|
---|
| 103 | + if (hasBackFacingCamera()&&hasFrontFacingCamera()){
|
---|
| 104 | + if (testName.equals("CameraOnly")||testName.equals("单摄像头")) {
|
---|
| 105 | + continue;
|
---|
| 106 | + }
|
---|
| 107 | + }else {
|
---|
| 108 | + if (testName.equals("Camera")||testName.equals("摄像头")) {
|
---|
| 109 | + continue;
|
---|
| 110 | + }
|
---|
| 111 | +
|
---|
| 112 | + }
|
---|
| 113 | + TestCase testCase = new TestCase(testNo, testName,
|
---|
| 114 | + className);
|
---|
| 115 | + //testCase.setneedtest(isfirsttes);
|
---|
| 116 | + mTestCases.add(testCase);
|
---|
| 117 | + if(caseGroup != null) {
|
---|
| 118 | + caseGroup.add(testCase);
|
---|
| 119 | + }
|
---|
| 120 | + testNo++;
|
---|
| 121 | +
|
---|
| 122 | + }
|
---|
| 123 | + }
|
---|
| 124 | + }
|
---|
| 125 | +
|
---|
| 126 | + } catch (Exception e) {
|
---|
| 127 | + Log.e(TAG, e.getMessage());
|
---|
| 128 | + return false;
|
---|
| 129 | + } finally {
|
---|
| 130 | + doc = null;
|
---|
| 131 | + docBuilder = null;
|
---|
| 132 | + docBuilderFactory = null;
|
---|
| 133 | + }
|
---|
| 134 | +
|
---|
| 135 | + if (mTestCases.size() == 0) {
|
---|
| 136 | + return false;
|
---|
| 137 | + }
|
---|
| 138 | +
|
---|
| 139 | + Log.i(TAG, "The cases count is :" + mTestCases.size());
|
---|
| 140 | + return true;
|
---|
| 141 | + }
|
---|
| 142 | +private static boolean checkCameraFacing(final int facing) {
|
---|
| 143 | +
|
---|
| 144 | + final int cameraCount = Camera.getNumberOfCameras();
|
---|
| 145 | + CameraInfo info = new CameraInfo();
|
---|
| 146 | + for (int i = 0; i < cameraCount; i++) {
|
---|
| 147 | + Camera.getCameraInfo(i, info);
|
---|
| 148 | + if (facing == info.facing) {
|
---|
| 149 | + return true;
|
---|
| 150 | + }
|
---|
| 151 | + }
|
---|
| 152 | + return false;
|
---|
| 153 | + }
|
---|
| 154 | + public static boolean hasBackFacingCamera() {
|
---|
| 155 | + final int CAMERA_FACING_BACK = 0;
|
---|
| 156 | + return checkCameraFacing(CAMERA_FACING_BACK);
|
---|
| 157 | + }
|
---|
| 158 | + public static boolean hasFrontFacingCamera() {
|
---|
| 159 | + final int CAMERA_FACING_BACK = 1;
|
---|
| 160 | + return checkCameraFacing(CAMERA_FACING_BACK);
|
---|
| 161 | + }
|
---|
| 162 | + public static int getSdkVersion() {
|
---|
| 163 | + return android.os.Build.VERSION.SDK_INT;
|
---|
| 164 | + }
|
---|
| 165 | +
|
---|
| 166 | +
|
---|
| 167 | +
|
---|
| 168 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.helper;
|
---|
| 2 | +
|
---|
| 3 | +import java.io.FileWriter;
|
---|
| 4 | +import java.io.IOException;
|
---|
| 5 | +import java.io.InputStream;
|
---|
| 6 | +
|
---|
| 7 | +import java.util.ArrayList;
|
---|
| 8 | +import java.util.Date;
|
---|
| 9 | +import java.util.HashMap;
|
---|
| 10 | +import java.util.List;
|
---|
| 11 | +import java.util.Map;
|
---|
| 12 | +
|
---|
| 13 | +import android.content.res.XmlResourceParser;
|
---|
| 14 | +import android.os.SystemClock;
|
---|
| 15 | +import android.util.Log;
|
---|
| 16 | +import android.util.Xml;
|
---|
| 17 | +
|
---|
| 18 | +import javax.xml.parsers.DocumentBuilder;
|
---|
| 19 | +import javax.xml.parsers.DocumentBuilderFactory;
|
---|
| 20 | +import javax.xml.parsers.ParserConfigurationException;
|
---|
| 21 | +import org.w3c.dom.Document;
|
---|
| 22 | +import org.w3c.dom.Node;
|
---|
| 23 | +import org.w3c.dom.NodeList;
|
---|
| 24 | +import org.xml.sax.SAXException;
|
---|
| 25 | +import org.xmlpull.v1.XmlSerializer;
|
---|
| 26 | +
|
---|
| 27 | +import com.DeviceTest.DeviceTest;
|
---|
| 28 | +
|
---|
| 29 | +public class XmlDeal {
|
---|
| 30 | +
|
---|
| 31 | + private static final String TAG = "XmlDeal";
|
---|
| 32 | + /**/
|
---|
| 33 | + private static final String XML_ROOT_TAG = "TestCaseList";
|
---|
| 34 | + private static final String XML_NODE_TAG = "TestCase";
|
---|
| 35 | +
|
---|
| 36 | + private static final String CLASS_NAME_TAG = "class_name";
|
---|
| 37 | + private static final String TEST_NAME_TAG = "test_name";
|
---|
| 38 | + private static final String RESULT_TAG = "result";
|
---|
| 39 | + private static final String TEST_GROUP_TAG = "test_group";
|
---|
| 40 | + private static final String TEST_FIRST = "first_test";
|
---|
| 41 | +
|
---|
| 42 | + public List<TestCase> mTestCases = null;
|
---|
| 43 | + public Map<String, List<TestCase>> mCaseGroups = null;
|
---|
| 44 | +
|
---|
| 45 | + public XmlDeal(InputStream is) {
|
---|
| 46 | + mTestCases = new ArrayList<TestCase>();
|
---|
| 47 | + mCaseGroups = new HashMap<String, List<TestCase>>();
|
---|
| 48 | + if (!ParseXml(is)) {
|
---|
| 49 | + throw new RuntimeException();
|
---|
| 50 | + }
|
---|
| 51 | + }
|
---|
| 52 | +
|
---|
| 53 | + private boolean ParseXml(InputStream is) {
|
---|
| 54 | +
|
---|
| 55 | + DocumentBuilderFactory docBuilderFactory = null;
|
---|
| 56 | + DocumentBuilder docBuilder = null;
|
---|
| 57 | + Document doc = null;
|
---|
| 58 | + try {
|
---|
| 59 | + docBuilderFactory = DocumentBuilderFactory.newInstance();
|
---|
| 60 | + docBuilder = docBuilderFactory.newDocumentBuilder();
|
---|
| 61 | +
|
---|
| 62 | + doc = docBuilder.parse(is);
|
---|
| 63 | + NodeList nodeList = doc.getElementsByTagName(XML_ROOT_TAG);
|
---|
| 64 | +
|
---|
| 65 | + int length = nodeList.getLength();
|
---|
| 66 | + List<TestCase> caseGroup = null;
|
---|
| 67 | + for (int i = 0; i < length; i++) {
|
---|
| 68 | + Node item = nodeList.item(i);
|
---|
| 69 | +
|
---|
| 70 | + int testNo = 0;
|
---|
| 71 | + caseGroup = null;
|
---|
| 72 | + for (Node node = item.getFirstChild(); node != null; node = node
|
---|
| 73 | + .getNextSibling()) {
|
---|
| 74 | + if (node.getNodeType() == Node.ELEMENT_NODE) {
|
---|
| 75 | +
|
---|
| 76 | + String testName = null;
|
---|
| 77 | + String className = null;
|
---|
| 78 | + boolean isfirsttest = false;
|
---|
| 79 | + for (int j = 0; j < node.getAttributes().getLength(); j++) {
|
---|
| 80 | + String attrValue = node.getAttributes().item(j)
|
---|
| 81 | + .getNodeValue();
|
---|
| 82 | + String attrName = node.getAttributes().item(j)
|
---|
| 83 | + .getNodeName();
|
---|
| 84 | + if (attrName.equals(CLASS_NAME_TAG)) {
|
---|
| 85 | + className = attrValue;
|
---|
| 86 | + } else if (attrName.equals(TEST_GROUP_TAG)) {
|
---|
| 87 | + caseGroup = mCaseGroups.get(attrValue);
|
---|
| 88 | + if (caseGroup == null) {
|
---|
| 89 | + caseGroup = new ArrayList<TestCase>();
|
---|
| 90 | + mCaseGroups.put(attrValue, caseGroup);
|
---|
| 91 | + }
|
---|
| 92 | + }else if(attrName.equals(TEST_FIRST)){
|
---|
| 93 | + isfirsttest = true;
|
---|
| 94 | + }
|
---|
| 95 | + }
|
---|
| 96 | + testName = node.getFirstChild().getNodeValue();
|
---|
| 97 | + Log.i(TAG, "-----getTestItemName:" + testName + " isfirsttest = " + isfirsttest);
|
---|
| 98 | +
|
---|
| 99 | + if(getResources().getConfiguration().locale.getCountry().equals("CN"))
|
---|
| 100 | + {
|
---|
| 101 | + if(testName.equals("Version"))
|
---|
| 102 | + {
|
---|
| 103 | + testName = "¿¿";
|
---|
| 104 | + }
|
---|
| 105 | + else if(testName.equals("LCD"))
|
---|
| 106 | + {
|
---|
| 107 | + testName = ;
|
---|
| 108 | + }
|
---|
| 109 | + else if(testName.equals("Touch"))
|
---|
| 110 | + {
|
---|
| 111 | + testName = ;
|
---|
| 112 | + }
|
---|
| 113 | + else if(testName.equals("Camera"))
|
---|
| 114 | + {
|
---|
| 115 | + testName = ;
|
---|
| 116 | + }
|
---|
| 117 | + else if(testName.equals("Speaker"))
|
---|
| 118 | + {
|
---|
| 119 | + testName = ;
|
---|
| 120 | + }
|
---|
| 121 | + else if(testName.equals("Gsensor"))
|
---|
| 122 | + {
|
---|
| 123 | + testName = ;
|
---|
| 124 | + }
|
---|
| 125 | +
|
---|
| 126 | + else if(testName.equals("Bluetooth"))
|
---|
| 127 | + {
|
---|
| 128 | + testName = ;
|
---|
| 129 | + }
|
---|
| 130 | + else if(testName.equals("Wifi"))
|
---|
| 131 | + {
|
---|
| 132 | + testName = ;
|
---|
| 133 | + }
|
---|
| 134 | + else if(testName.equals("MIC"))
|
---|
| 135 | + {
|
---|
| 136 | + testName = ;
|
---|
| 137 | + }else if(testName.equals("Battery"))
|
---|
| 138 | + {
|
---|
| 139 | + testName = ;
|
---|
| 140 | + }
|
---|
| 141 | + else if(testName.equals("SD Card"))
|
---|
| 142 | + {
|
---|
| 143 | + testName = ;
|
---|
| 144 | + }
|
---|
| 145 | + else if(testName.equals("Keyboard"))
|
---|
| 146 | + {
|
---|
| 147 | + testName = ;
|
---|
| 148 | + }
|
---|
| 149 | + else if(testName.equals("Brightness"))
|
---|
| 150 | + {
|
---|
| 151 | + testName = ;
|
---|
| 152 | + }else if(testName.equals("UsbHost"))
|
---|
| 153 | + {
|
---|
| 154 | + //testName = "u"
|
---|
| 155 | + }
|
---|
| 156 | + else if(testName.equals("HDMI"))
|
---|
| 157 | + {
|
---|
| 158 | + //testName = "°æ±¾"
|
---|
| 159 | + }
|
---|
| 160 | + else if(testName.equals("Storage"))
|
---|
| 161 | + {
|
---|
| 162 | + testName = ;
|
---|
| 163 | + }
|
---|
| 164 | +
|
---|
| 165 | + }
|
---|
| 166 | +
|
---|
| 167 | + TestCase testCase = new TestCase(testNo, testName,
|
---|
| 168 | + className);
|
---|
| 169 | + testCase.setneedtest(isfirsttes);
|
---|
| 170 | + mTestCases.add(testCase);
|
---|
| 171 | + if(caseGroup != null) {
|
---|
| 172 | + caseGroup.add(testCase);
|
---|
| 173 | + }
|
---|
| 174 | + testNo++;
|
---|
| 175 | + }
|
---|
| 176 | + }
|
---|
| 177 | + }
|
---|
| 178 | +
|
---|
| 179 | + } catch (Exception e) {
|
---|
| 180 | + Log.e(TAG, e.getMessage());
|
---|
| 181 | + return false;
|
---|
| 182 | + } finally {
|
---|
| 183 | + doc = null;
|
---|
| 184 | + docBuilder = null;
|
---|
| 185 | + docBuilderFactory = null;
|
---|
| 186 | + }
|
---|
| 187 | +
|
---|
| 188 | + if (mTestCases.size() == 0) {
|
---|
| 189 | + return false;
|
---|
| 190 | + }
|
---|
| 191 | +
|
---|
| 192 | + Log.i(TAG, "The cases count is :" + mTestCases.size());
|
---|
| 193 | + return true;
|
---|
| 194 | + }
|
---|
| 195 | +
|
---|
| 196 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.view;
|
---|
| 2 | +
|
---|
| 3 | +import com.DeviceTest.R;
|
---|
| 4 | +import com.DeviceTest.R.drawable;
|
---|
| 5 | +
|
---|
| 6 | +import android.content.Context;
|
---|
| 7 | +import android.graphics.Canvas;
|
---|
| 8 | +import android.graphics.Color;
|
---|
| 9 | +import android.graphics.Paint;
|
---|
| 10 | +import android.graphics.drawable.Drawable;
|
---|
| 11 | +import android.util.AttributeSet;
|
---|
| 12 | +import android.view.View;
|
---|
| 13 | +
|
---|
| 14 | +public class CompassView extends View {
|
---|
| 15 | +
|
---|
| 16 | + private float yaw = 0;
|
---|
| 17 | + private Paint paint;
|
---|
| 18 | + private Drawable compass;
|
---|
| 19 | +
|
---|
| 20 | + public CompassView(Context context) {
|
---|
| 21 | + this(context, null);
|
---|
| 22 | + }
|
---|
| 23 | +
|
---|
| 24 | + public CompassView(Context context, AttributeSet attrs) {
|
---|
| 25 | + this(context, attrs, 0);
|
---|
| 26 | + }
|
---|
| 27 | +
|
---|
| 28 | + public CompassView(Context context, AttributeSet attrs, int defStyle) {
|
---|
| 29 | + super(context, attrs, defStyle);
|
---|
| 30 | + paint = new Paint();
|
---|
| 31 | + paint.setColor(Color.RED);
|
---|
| 32 | + // paint.setStyle(Style.FILL_AND_STROKE);
|
---|
| 33 | + paint.setStrokeWidth(2);
|
---|
| 34 | +
|
---|
| 35 | + compass = getResources().getDrawable(R.drawable.compass);
|
---|
| 36 | +
|
---|
| 37 | + this.setBackgroundColor(Color.WHITE);
|
---|
| 38 | + }
|
---|
| 39 | +
|
---|
| 40 | + public void update(float yaw) {
|
---|
| 41 | + if (Math.abs(this.yaw - yaw) > 1) {
|
---|
| 42 | + this.yaw = yaw;
|
---|
| 43 | + postInvalidate();
|
---|
| 44 | + }
|
---|
| 45 | + }
|
---|
| 46 | +
|
---|
| 47 | + protected void onDraw(Canvas canvas) {
|
---|
| 48 | + int height = getHeight();
|
---|
| 49 | + int width = getWidth();
|
---|
| 50 | + int midX = width / 2;
|
---|
| 51 | + int midY = height / 2;
|
---|
| 52 | + int size = (height > width ? width : height) * 3 / 8;
|
---|
| 53 | + compass.setBounds(midX - size, midY - size, midX + size, midY + size);
|
---|
| 54 | + canvas.save();
|
---|
| 55 | + canvas.rotate(-yaw, midX, midY);
|
---|
| 56 | + compass.draw(canvas);
|
---|
| 57 | + canvas.restore();
|
---|
| 58 | + paint.setTextSize(size / 3);
|
---|
| 59 | + canvas.drawText((int) yaw + "\260", 0, size / 3, paint);
|
---|
| 60 | + }
|
---|
| 61 | +}
|
---|
.. | .. |
---|
| 1 | +/* |
---|
| 2 | + * Copyright (C) 2007 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.DeviceTest.view; |
---|
| 18 | + |
---|
| 19 | +import java.nio.ByteBuffer; |
---|
| 20 | +import java.nio.ByteOrder; |
---|
| 21 | +import java.nio.IntBuffer; |
---|
| 22 | + |
---|
| 23 | +import javax.microedition.khronos.opengles.GL10; |
---|
| 24 | + |
---|
| 25 | +/** |
---|
| 26 | + * A vertex shaded cube. |
---|
| 27 | + */ |
---|
| 28 | +class Cube |
---|
| 29 | +{ |
---|
| 30 | + public Cube() |
---|
| 31 | + { |
---|
| 32 | + int one = 0x10000; |
---|
| 33 | + int vertices[] = { |
---|
| 34 | + -one, -one, -one, |
---|
| 35 | + one, -one, -one, |
---|
| 36 | + one, one, -one, |
---|
| 37 | + -one, one, -one, |
---|
| 38 | + -one, -one, one, |
---|
| 39 | + one, -one, one, |
---|
| 40 | + one, one, one, |
---|
| 41 | + -one, one, one, |
---|
| 42 | + }; |
---|
| 43 | + |
---|
| 44 | + int colors[] = { |
---|
| 45 | + 0, 0, 0, one, |
---|
| 46 | + one, 0, 0, one, |
---|
| 47 | + one, one, 0, one, |
---|
| 48 | + 0, one, 0, one, |
---|
| 49 | + 0, 0, one, one, |
---|
| 50 | + one, 0, one, one, |
---|
| 51 | + one, one, one, one, |
---|
| 52 | + 0, one, one, one, |
---|
| 53 | + }; |
---|
| 54 | + |
---|
| 55 | + byte indices[] = { |
---|
| 56 | + 0, 4, 5, 0, 5, 1, |
---|
| 57 | + 1, 5, 6, 1, 6, 2, |
---|
| 58 | + 2, 6, 7, 2, 7, 3, |
---|
| 59 | + 3, 7, 4, 3, 4, 0, |
---|
| 60 | + 4, 7, 6, 4, 6, 5, |
---|
| 61 | + 3, 0, 1, 3, 1, 2 |
---|
| 62 | + }; |
---|
| 63 | + |
---|
| 64 | + // Buffers to be passed to gl*Pointer() functions |
---|
| 65 | + // must be direct, i.e., they must be placed on the |
---|
| 66 | + // native heap where the garbage collector cannot |
---|
| 67 | + // move them. |
---|
| 68 | + // |
---|
| 69 | + // Buffers with multi-byte datatypes (e.g., short, int, float) |
---|
| 70 | + // must have their byte order set to native order |
---|
| 71 | + |
---|
| 72 | + ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length*4); |
---|
| 73 | + vbb.order(ByteOrder.nativeOrder()); |
---|
| 74 | + mVertexBuffer = vbb.asIntBuffer(); |
---|
| 75 | + mVertexBuffer.put(vertices); |
---|
| 76 | + mVertexBuffer.position(0); |
---|
| 77 | + |
---|
| 78 | + ByteBuffer cbb = ByteBuffer.allocateDirect(colors.length*4); |
---|
| 79 | + cbb.order(ByteOrder.nativeOrder()); |
---|
| 80 | + mColorBuffer = cbb.asIntBuffer(); |
---|
| 81 | + mColorBuffer.put(colors); |
---|
| 82 | + mColorBuffer.position(0); |
---|
| 83 | + |
---|
| 84 | + mIndexBuffer = ByteBuffer.allocateDirect(indices.length); |
---|
| 85 | + mIndexBuffer.put(indices); |
---|
| 86 | + mIndexBuffer.position(0); |
---|
| 87 | + } |
---|
| 88 | + |
---|
| 89 | + public void draw(GL10 gl) |
---|
| 90 | + { |
---|
| 91 | + gl.glFrontFace(GL10.GL_CW); |
---|
| 92 | + gl.glVertexPointer(3, GL10.GL_FIXED, 0, mVertexBuffer); |
---|
| 93 | + gl.glColorPointer(4, GL10.GL_FIXED, 0, mColorBuffer); |
---|
| 94 | + gl.glDrawElements(GL10.GL_TRIANGLES, 36, GL10.GL_UNSIGNED_BYTE, mIndexBuffer); |
---|
| 95 | + } |
---|
| 96 | + |
---|
| 97 | + private IntBuffer mVertexBuffer; |
---|
| 98 | + private IntBuffer mColorBuffer; |
---|
| 99 | + private ByteBuffer mIndexBuffer; |
---|
| 100 | +} |
---|
.. | .. |
---|
| 1 | +
|
---|
| 2 | +package com.DeviceTest.view;
|
---|
| 3 | +
|
---|
| 4 | +import java.util.Calendar;
|
---|
| 5 | +
|
---|
| 6 | +import android.content.Context;
|
---|
| 7 | +import android.graphics.Canvas;
|
---|
| 8 | +import android.graphics.Color;
|
---|
| 9 | +import android.graphics.Paint;
|
---|
| 10 | +import android.graphics.Path;
|
---|
| 11 | +import android.view.View;
|
---|
| 12 | +
|
---|
| 13 | +public class DrawClock extends View {
|
---|
| 14 | +
|
---|
| 15 | + public DrawClock(Context context) {
|
---|
| 16 | + super(context);
|
---|
| 17 | + }
|
---|
| 18 | +
|
---|
| 19 | + public void onDraw(Canvas canvas) {
|
---|
| 20 | +
|
---|
| 21 | + canvas.drawColor(Color.BLACK);
|
---|
| 22 | + Paint paint = new Paint();
|
---|
| 23 | + paint.setAntiAlias(true);
|
---|
| 24 | + paint.setColor(Color.RED);
|
---|
| 25 | + paint.setStyle(Paint.Style.STROKE);
|
---|
| 26 | + paint.setStrokeWidth(2);
|
---|
| 27 | + paint.setTextSize(16);
|
---|
| 28 | + drawClockPandle(canvas, paint); // 画制时钟的底盘
|
---|
| 29 | +
|
---|
| 30 | + drawClockPointer(canvas, paint); // 画制时钟的指针
|
---|
| 31 | + }
|
---|
| 32 | +
|
---|
| 33 | + // ------时钟底盘画制函数--------------
|
---|
| 34 | + void drawClockPandle(Canvas canvas, Paint paint)
|
---|
| 35 | + {
|
---|
| 36 | + int px = getMeasuredWidth();
|
---|
| 37 | + int py = getMeasuredWidth();
|
---|
| 38 | +
|
---|
| 39 | + canvas.drawCircle(px / 2, py / 2, py / 2 - 1, paint);
|
---|
| 40 | + canvas.drawCircle(px / 2, py / 2, py / 40, paint);
|
---|
| 41 | +
|
---|
| 42 | + Path path = new Path();
|
---|
| 43 | + path.moveTo(1, py / 2);
|
---|
| 44 | + path.lineTo(py / 16, py / 2);
|
---|
| 45 | + canvas.drawPath(path, paint);
|
---|
| 46 | + canvas.drawText("11", py / 16, py / 2, paint);
|
---|
| 47 | +
|
---|
| 48 | + path.moveTo(px / 2, 1);
|
---|
| 49 | + path.lineTo(px / 2, py / 16);
|
---|
| 50 | + canvas.drawPath(path, paint);
|
---|
| 51 | + canvas.drawText("12", px / 2,py / 16, paint);
|
---|
| 52 | +
|
---|
| 53 | + path.moveTo(px - 1, py / 2);
|
---|
| 54 | + path.lineTo(px - px / 16, py / 2);
|
---|
| 55 | + canvas.drawPath(path, paint);
|
---|
| 56 | + canvas.drawText("3",px - px / 16, py / 2, paint);
|
---|
| 57 | +
|
---|
| 58 | + path.moveTo(px / 2, py - 1);
|
---|
| 59 | + path.lineTo(px / 2, py - py / 16);
|
---|
| 60 | + canvas.drawPath(path, paint);
|
---|
| 61 | + canvas.drawText("6", px / 2, py - py / 16, paint);
|
---|
| 62 | +
|
---|
| 63 | + canvas.save();
|
---|
| 64 | + canvas.rotate(30, px / 2, py / 2);
|
---|
| 65 | + Path path8 = new Path();
|
---|
| 66 | + path8.moveTo(1, py / 2);
|
---|
| 67 | + path8.lineTo(px / 30, py / 2);
|
---|
| 68 | + canvas.drawPath(path8, paint);
|
---|
| 69 | + canvas.drawText("10",px / 30, py / 2, paint);
|
---|
| 70 | +
|
---|
| 71 | + path8.moveTo(px / 2, 1);
|
---|
| 72 | + path8.lineTo(px / 2, py / 30);
|
---|
| 73 | + canvas.drawPath(path8, paint);
|
---|
| 74 | + canvas.drawText("1",px / 2, py / 30, paint);
|
---|
| 75 | +
|
---|
| 76 | + path8.moveTo(px - 1, py / 2);
|
---|
| 77 | + path8.lineTo(px - px / 30, py / 2);
|
---|
| 78 | + canvas.drawPath(path8, paint);
|
---|
| 79 | + canvas.drawText("4", px - px / 30, py / 2, paint);
|
---|
| 80 | +
|
---|
| 81 | + path8.moveTo(px / 2, py - 1);
|
---|
| 82 | + path8.lineTo(px / 2, py - py / 30);
|
---|
| 83 | + canvas.drawPath(path8, paint);
|
---|
| 84 | + canvas.drawText("7", px / 2, py - py / 30, paint);
|
---|
| 85 | + canvas.restore();
|
---|
| 86 | +
|
---|
| 87 | + canvas.save();
|
---|
| 88 | + canvas.rotate(60, px / 2, py / 2);
|
---|
| 89 | + Path path9 = new Path();
|
---|
| 90 | + path9.moveTo(1, py / 2);
|
---|
| 91 | + path9.lineTo(px / 30, py / 2);
|
---|
| 92 | + canvas.drawPath(path9, paint);
|
---|
| 93 | + canvas.drawText("11", px / 30, py / 2, paint);
|
---|
| 94 | +
|
---|
| 95 | + path9.moveTo(px / 2, 1);
|
---|
| 96 | + path9.lineTo(px / 2, py / 30);
|
---|
| 97 | + canvas.drawPath(path9, paint);
|
---|
| 98 | + canvas.drawText("2",px / 2, py / 30, paint);
|
---|
| 99 | +
|
---|
| 100 | + path9.moveTo(px - 1, py / 2);
|
---|
| 101 | + path9.lineTo(px - px / 30, py / 2);
|
---|
| 102 | + canvas.drawPath(path9, paint);
|
---|
| 103 | + canvas.drawText("5", px - px / 30, py / 2, paint);
|
---|
| 104 | +
|
---|
| 105 | + path9.moveTo(px / 2, py - 1);
|
---|
| 106 | + path9.lineTo(px / 2, py - py / 30);
|
---|
| 107 | + canvas.drawPath(path9, paint);
|
---|
| 108 | + canvas.drawText("8",px / 2,py - py / 30, paint);
|
---|
| 109 | + canvas.restore();
|
---|
| 110 | +
|
---|
| 111 | + }
|
---|
| 112 | +
|
---|
| 113 | + // ---------时钟指针画制函数---------------------
|
---|
| 114 | + void drawClockPointer(Canvas canvas, Paint paint)
|
---|
| 115 | + {
|
---|
| 116 | + int px = getMeasuredWidth();
|
---|
| 117 | + int py = getMeasuredWidth();
|
---|
| 118 | +
|
---|
| 119 | + /*-------------------------获得当前时间小时和分钟数---------------------*/
|
---|
| 120 | + int mHour;
|
---|
| 121 | + int mMinutes;
|
---|
| 122 | + int mSeconds;
|
---|
| 123 | + long time = System.currentTimeMillis();
|
---|
| 124 | + final Calendar mCalendar = Calendar.getInstance();
|
---|
| 125 | + mCalendar.setTimeInMillis(time);
|
---|
| 126 | + mHour = mCalendar.get(Calendar.HOUR);
|
---|
| 127 | + mMinutes = mCalendar.get(Calendar.MINUTE);
|
---|
| 128 | + mSeconds = mCalendar.get(Calendar.SECOND);
|
---|
| 129 | + /*-------------------------获得当前时间---------------------*/
|
---|
| 130 | +
|
---|
| 131 | + float hDegree = ((mHour + (float) mMinutes / 60) / 12) * 360;
|
---|
| 132 | + float mDegree = ((mMinutes + (float) mSeconds / 60) / 60) * 360;
|
---|
| 133 | + float sDegree = ((float) mSeconds / 60) * 360;
|
---|
| 134 | +
|
---|
| 135 | + // 分针-----------
|
---|
| 136 | + paint.setColor(Color.GREEN);
|
---|
| 137 | + canvas.save();
|
---|
| 138 | + canvas.rotate(mDegree, px / 2, py / 2);
|
---|
| 139 | + Path path1 = new Path();
|
---|
| 140 | + path1.moveTo(px / 2, py / 2);
|
---|
| 141 | + path1.lineTo(px / 2, py / 4);
|
---|
| 142 | + canvas.drawPath(path1, paint);
|
---|
| 143 | + canvas.restore();
|
---|
| 144 | +
|
---|
| 145 | + // 时针------------------
|
---|
| 146 | + paint.setColor(Color.WHITE);
|
---|
| 147 | + canvas.save();
|
---|
| 148 | + canvas.rotate(hDegree, px / 2, py / 2);
|
---|
| 149 | + Path path2 = new Path();
|
---|
| 150 | + path2.moveTo(px / 2, py / 2);
|
---|
| 151 | + path2.lineTo(px / 2, py / 3);
|
---|
| 152 | + canvas.drawPath(path2, paint);
|
---|
| 153 | + canvas.restore();
|
---|
| 154 | +
|
---|
| 155 | + // 秒针---------------------
|
---|
| 156 | + paint.setColor(Color.YELLOW);
|
---|
| 157 | + canvas.save();
|
---|
| 158 | + canvas.rotate(sDegree, px / 2, py / 2);
|
---|
| 159 | + Path path3 = new Path();
|
---|
| 160 | + path3.moveTo(px / 2, py / 2);
|
---|
| 161 | + path3.lineTo(px / 2, py / 8);
|
---|
| 162 | + canvas.drawPath(path3, paint);
|
---|
| 163 | + canvas.restore();
|
---|
| 164 | +
|
---|
| 165 | + }
|
---|
| 166 | +
|
---|
| 167 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.view;
|
---|
| 2 | +
|
---|
| 3 | +import android.R.color;
|
---|
| 4 | +import android.content.Context;
|
---|
| 5 | +import android.graphics.Canvas;
|
---|
| 6 | +import android.graphics.Color;
|
---|
| 7 | +import android.graphics.Paint;
|
---|
| 8 | +import android.graphics.Paint.Style;
|
---|
| 9 | +import android.graphics.Rect;
|
---|
| 10 | +import android.util.AttributeSet;
|
---|
| 11 | +import android.util.Log;
|
---|
| 12 | +import android.view.View;
|
---|
| 13 | +
|
---|
| 14 | +public class GsensorBall extends View {
|
---|
| 15 | + private final static String TAG = "GsensorBall";
|
---|
| 16 | + private Paint mPaint = new Paint();
|
---|
| 17 | + private Rect mRect = new Rect();
|
---|
| 18 | +
|
---|
| 19 | + private float center_point_x = 0;
|
---|
| 20 | + private float center_point_y = 0;
|
---|
| 21 | + private float draw_center_point_x = 0;
|
---|
| 22 | + private float draw_center_point_y = 0;
|
---|
| 23 | + private float ball_radius = 0;
|
---|
| 24 | + private final static float SCALE = 14.0f;
|
---|
| 25 | + private static float MOVESCALE = 12.0f;
|
---|
| 26 | + private int currentcolor = Color.RED;
|
---|
| 27 | + public GsensorBall(Context context) {
|
---|
| 28 | + this(context, null, 0);
|
---|
| 29 | + }
|
---|
| 30 | +
|
---|
| 31 | + public GsensorBall(Context context, AttributeSet attrs) {
|
---|
| 32 | + this(context, attrs, 0);
|
---|
| 33 | + }
|
---|
| 34 | +
|
---|
| 35 | + public GsensorBall(Context context, AttributeSet attrs, int defStyle) {
|
---|
| 36 | + super(context, attrs, defStyle);
|
---|
| 37 | + }
|
---|
| 38 | +
|
---|
| 39 | + @Override
|
---|
| 40 | + protected void onLayout(boolean changed, int left, int top, int right,
|
---|
| 41 | + int bottom) {
|
---|
| 42 | + super.onLayout(changed, left, top, right, bottom);
|
---|
| 43 | + center_point_x = this.getWidth()/2.0f;
|
---|
| 44 | + center_point_y = this.getHeight()/2.0f;
|
---|
| 45 | + MOVESCALE = this.getWidth() > this.getHeight() ? this.getHeight()/18.0f : this.getWidth()/18.0f;
|
---|
| 46 | + if(draw_center_point_x == 0){
|
---|
| 47 | + draw_center_point_x = center_point_x;
|
---|
| 48 | + draw_center_point_y = center_point_y;
|
---|
| 49 | + }
|
---|
| 50 | + ball_radius = this.getWidth() > this.getHeight() ? this.getHeight()/SCALE : this.getWidth()/SCALE;
|
---|
| 51 | +
|
---|
| 52 | + mPaint.setColor(Color.RED);
|
---|
| 53 | + mPaint.setStyle(Style.FILL);
|
---|
| 54 | + }
|
---|
| 55 | +
|
---|
| 56 | + public void setXYZ(float x, float y, float z){
|
---|
| 57 | + draw_center_point_x = center_point_x + y * MOVESCALE;
|
---|
| 58 | + draw_center_point_y = center_point_y + x * MOVESCALE;
|
---|
| 59 | + if(draw_center_point_x != 0 || draw_center_point_y != 0){
|
---|
| 60 | + currentcolor = Color.GREEN;
|
---|
| 61 | + }
|
---|
| 62 | +// Log.d(TAG, "__________________-------- setXYZ(), draw_center_point_x = " + draw_center_point_x +
|
---|
| 63 | +// " draw_center_point_y = " + draw_center_point_y);
|
---|
| 64 | + this.invalidate();
|
---|
| 65 | + }
|
---|
| 66 | +
|
---|
| 67 | + public void onDraw(Canvas canvas) {
|
---|
| 68 | + super.onDraw(canvas);
|
---|
| 69 | + //Log.d(TAG, ball_radius+"__________________-------- onDraw(), draw_center_point_x = " + draw_center_point_x +
|
---|
| 70 | + // " draw_center_point_y = " + draw_center_point_y);
|
---|
| 71 | + mPaint.setColor(Color.RED);
|
---|
| 72 | + canvas.drawCircle(center_point_x, center_point_y, ball_radius / 2, mPaint);
|
---|
| 73 | + mPaint.setColor(currentcolor);
|
---|
| 74 | + canvas.drawCircle(draw_center_point_x, draw_center_point_y, ball_radius, mPaint);
|
---|
| 75 | + }
|
---|
| 76 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.view;
|
---|
| 2 | +
|
---|
| 3 | +import java.util.ArrayList;
|
---|
| 4 | +
|
---|
| 5 | +import android.content.Context;
|
---|
| 6 | +import android.graphics.Canvas;
|
---|
| 7 | +import android.graphics.Color;
|
---|
| 8 | +import android.graphics.Paint;
|
---|
| 9 | +import android.graphics.Paint.Style;
|
---|
| 10 | +import android.util.AttributeSet;
|
---|
| 11 | +import android.view.View;
|
---|
| 12 | +
|
---|
| 13 | +public class KeyTestView extends View{
|
---|
| 14 | + private final static String TAG = "KeyTestView";
|
---|
| 15 | +
|
---|
| 16 | + private int COLOR_NOR = Color.GRAY;
|
---|
| 17 | + private int COLOR_DOWN = Color.YELLOW;
|
---|
| 18 | + private int COLOR_PASS = Color.GREEN;
|
---|
| 19 | + private Paint mPaint = null;
|
---|
| 20 | + private Paint mWordPaint = null;
|
---|
| 21 | + private final static int ROW = 3;
|
---|
| 22 | + private final static int LINE = 2;
|
---|
| 23 | + private final static int PER_GAP = 3;
|
---|
| 24 | + private int per_width = 0;
|
---|
| 25 | + private int per_height = 0;
|
---|
| 26 | + ArrayList<KeyStruct> mKeyArray = new ArrayList<KeyStruct>();
|
---|
| 27 | + public KeyTestView(Context context, AttributeSet attrs) {
|
---|
| 28 | + super(context, attrs);
|
---|
| 29 | + mPaint = new Paint();
|
---|
| 30 | + mPaint.setColor(COLOR_NOR);
|
---|
| 31 | + mPaint.setStyle(Style.FILL);
|
---|
| 32 | + mWordPaint = new Paint();
|
---|
| 33 | + mWordPaint.setColor(Color.WHITE);
|
---|
| 34 | + }
|
---|
| 35 | +
|
---|
| 36 | + @Override
|
---|
| 37 | + protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
---|
| 38 | + super.onLayout(changed, left, top, right, bottom);
|
---|
| 39 | + per_width = (this.getWidth() - PER_GAP * (ROW + 1)) / ROW;
|
---|
| 40 | + per_height = (this.getHeight() - PER_GAP * (LINE + 1))/ LINE;
|
---|
| 41 | + }
|
---|
| 42 | +
|
---|
| 43 | + @Override
|
---|
| 44 | + protected void onDraw(Canvas canvas) {
|
---|
| 45 | + super.onDraw(canvas);
|
---|
| 46 | + int current_x = PER_GAP;
|
---|
| 47 | + int current_y = PER_GAP;
|
---|
| 48 | + int i = 0;
|
---|
| 49 | + while(i < mKeyArray.size()){
|
---|
| 50 | + int color = COLOR_NOR;
|
---|
| 51 | + if(mKeyArray.get(i).getIsPass()){
|
---|
| 52 | + color = COLOR_PASS;
|
---|
| 53 | + }
|
---|
| 54 | + if(mKeyArray.get(i).getIsDown()){
|
---|
| 55 | + color = COLOR_DOWN;
|
---|
| 56 | + }
|
---|
| 57 | + mPaint.setColor(color);
|
---|
| 58 | +
|
---|
| 59 | + canvas.drawRect(current_x, current_y, current_x + per_width, current_y + per_height, mPaint);
|
---|
| 60 | + canvas.drawText(mKeyArray.get(i).getKeyName(), current_x, current_y + per_height / 2+5, mWordPaint);
|
---|
| 61 | + i ++;
|
---|
| 62 | + if(i % ROW == 0){
|
---|
| 63 | + current_x = PER_GAP;
|
---|
| 64 | + current_y += (per_height + PER_GAP);
|
---|
| 65 | + }else{
|
---|
| 66 | + current_x += (per_width + PER_GAP);
|
---|
| 67 | + }
|
---|
| 68 | + }
|
---|
| 69 | + }
|
---|
| 70 | +
|
---|
| 71 | + public void addKey(String name, int code){
|
---|
| 72 | + KeyStruct mkey = new KeyStruct(name, code);
|
---|
| 73 | + mKeyArray.add(mkey);
|
---|
| 74 | + }
|
---|
| 75 | + public void setKeyDown(int code){
|
---|
| 76 | + for(KeyStruct key : mKeyArray){
|
---|
| 77 | + if(key.getKeyCode() == code){
|
---|
| 78 | + key.setIsDown(true);
|
---|
| 79 | + break;
|
---|
| 80 | + }
|
---|
| 81 | + }
|
---|
| 82 | + invalidate();
|
---|
| 83 | + }
|
---|
| 84 | + public void setKeyUp(int code){
|
---|
| 85 | + for(KeyStruct key : mKeyArray){
|
---|
| 86 | + if(key.getKeyCode() == code){
|
---|
| 87 | + key.setIsDown(false);
|
---|
| 88 | + break;
|
---|
| 89 | + }
|
---|
| 90 | + }
|
---|
| 91 | + invalidate();
|
---|
| 92 | + }
|
---|
| 93 | +
|
---|
| 94 | + private class KeyStruct{
|
---|
| 95 | + private String keyname;
|
---|
| 96 | + private int keycode;
|
---|
| 97 | + private boolean isdown;
|
---|
| 98 | + private boolean pass;
|
---|
| 99 | + public KeyStruct(String name, int code){
|
---|
| 100 | + this.keyname = name;
|
---|
| 101 | + this.keycode = code;
|
---|
| 102 | + this.isdown = false;
|
---|
| 103 | + this.pass = false;
|
---|
| 104 | + }
|
---|
| 105 | + public void setIsDown(boolean tmp){
|
---|
| 106 | + this.isdown = tmp;
|
---|
| 107 | + if(tmp)
|
---|
| 108 | + this.pass = true;
|
---|
| 109 | + }
|
---|
| 110 | + public boolean getIsDown(){
|
---|
| 111 | + return this.isdown;
|
---|
| 112 | + }
|
---|
| 113 | + public boolean getIsPass(){
|
---|
| 114 | + return this.pass;
|
---|
| 115 | + }
|
---|
| 116 | + public String getKeyName(){
|
---|
| 117 | + return this.keyname;
|
---|
| 118 | + }
|
---|
| 119 | + public int getKeyCode(){
|
---|
| 120 | + return this.keycode;
|
---|
| 121 | + }
|
---|
| 122 | + }
|
---|
| 123 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.view;
|
---|
| 2 | +
|
---|
| 3 | +import android.R.color;
|
---|
| 4 | +import android.content.Context;
|
---|
| 5 | +import android.graphics.Canvas;
|
---|
| 6 | +import android.graphics.Color;
|
---|
| 7 | +import android.graphics.Paint;
|
---|
| 8 | +import android.graphics.Paint.Style;
|
---|
| 9 | +import android.graphics.Rect;
|
---|
| 10 | +import android.util.AttributeSet;
|
---|
| 11 | +import android.view.View;
|
---|
| 12 | +
|
---|
| 13 | +public class LcdTestView extends View {
|
---|
| 14 | +
|
---|
| 15 | + private boolean grayScale = false;
|
---|
| 16 | + private boolean paneBorder = false;
|
---|
| 17 | + private Paint mPaint = new Paint();
|
---|
| 18 | + private Rect mRect = new Rect();
|
---|
| 19 | +
|
---|
| 20 | + public LcdTestView(Context context) {
|
---|
| 21 | + this(context, null, 0);
|
---|
| 22 | + }
|
---|
| 23 | +
|
---|
| 24 | + public LcdTestView(Context context, AttributeSet attrs) {
|
---|
| 25 | + this(context, attrs, 0);
|
---|
| 26 | + }
|
---|
| 27 | +
|
---|
| 28 | + public LcdTestView(Context context, AttributeSet attrs, int defStyle) {
|
---|
| 29 | + super(context, attrs, defStyle);
|
---|
| 30 | + }
|
---|
| 31 | +
|
---|
| 32 | + public void grayScale(boolean enable) {
|
---|
| 33 | + grayScale = enable;
|
---|
| 34 | + }
|
---|
| 35 | +
|
---|
| 36 | + public void paneBorder(boolean enable) {
|
---|
| 37 | + paneBorder = enable;
|
---|
| 38 | + }
|
---|
| 39 | +
|
---|
| 40 | +
|
---|
| 41 | + public void onDraw(Canvas canvas) {
|
---|
| 42 | + super.onDraw(canvas);
|
---|
| 43 | + if (grayScale) {
|
---|
| 44 | + mPaint.setStyle(Style.FILL);
|
---|
| 45 | + getDrawingRect(mRect);
|
---|
| 46 | + final int width = getWidth();
|
---|
| 47 | + final int scale = 16;
|
---|
| 48 | + final int scaleWidth = width / scale;
|
---|
| 49 | + final int left = 0;
|
---|
| 50 | +
|
---|
| 51 | + for (int i = 0; i < scale; i++) {
|
---|
| 52 | + int gray = i * 16;
|
---|
| 53 | + gray = gray > 255 ? 255 : gray;
|
---|
| 54 | + mPaint.setColor(Color.rgb(gray, gray, gray));
|
---|
| 55 | + mRect.left = left + i * scaleWidth;
|
---|
| 56 | + mRect.right = left + (i + 1) * scaleWidth;
|
---|
| 57 | + canvas.drawRect(mRect, mPaint);
|
---|
| 58 | + }
|
---|
| 59 | +
|
---|
| 60 | + canvas.drawRect(mRect, mPaint);
|
---|
| 61 | + }
|
---|
| 62 | + if (paneBorder) {
|
---|
| 63 | + canvas.drawColor(Color.BLACK);
|
---|
| 64 | + mPaint.setColor(Color.WHITE);
|
---|
| 65 | + mPaint.setStyle(Style.STROKE);
|
---|
| 66 | + mPaint.setStrokeWidth(5);
|
---|
| 67 | + getDrawingRect(mRect);
|
---|
| 68 | + canvas.drawRect(mRect, mPaint);
|
---|
| 69 | + }
|
---|
| 70 | +
|
---|
| 71 | + }
|
---|
| 72 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.view;
|
---|
| 2 | +
|
---|
| 3 | +import android.content.Context;
|
---|
| 4 | +import android.graphics.Canvas;
|
---|
| 5 | +import android.graphics.Color;
|
---|
| 6 | +import android.graphics.Paint;
|
---|
| 7 | +import android.graphics.Paint.Style;
|
---|
| 8 | +import android.graphics.Rect;
|
---|
| 9 | +import android.graphics.RectF;
|
---|
| 10 | +import android.util.AttributeSet;
|
---|
| 11 | +import android.view.View;
|
---|
| 12 | +
|
---|
| 13 | +public class LevelView extends View {
|
---|
| 14 | +
|
---|
| 15 | + private float x = 0;
|
---|
| 16 | + private float y = 0;
|
---|
| 17 | + private Paint paint = new Paint();
|
---|
| 18 | + private RectF rectF = new RectF();
|
---|
| 19 | +
|
---|
| 20 | + public LevelView(Context context) {
|
---|
| 21 | + this(context, null);
|
---|
| 22 | + }
|
---|
| 23 | +
|
---|
| 24 | + public LevelView(Context context, AttributeSet attrs) {
|
---|
| 25 | + this(context, attrs, 0);
|
---|
| 26 | + }
|
---|
| 27 | +
|
---|
| 28 | + public LevelView(Context context, AttributeSet attrs, int defStyle) {
|
---|
| 29 | + super(context, attrs, defStyle);
|
---|
| 30 | + this.setBackgroundColor(Color.WHITE);
|
---|
| 31 | + }
|
---|
| 32 | +
|
---|
| 33 | + public void update(float values, float values2) {
|
---|
| 34 | + this.x = values;
|
---|
| 35 | + this.y = values2;
|
---|
| 36 | + postInvalidate();
|
---|
| 37 | + }
|
---|
| 38 | +
|
---|
| 39 | + protected void onDraw(Canvas canvas) {
|
---|
| 40 | + int height = getHeight();
|
---|
| 41 | + int width = getWidth();
|
---|
| 42 | + int size = (height > width ? width : height) * 3 / 8;
|
---|
| 43 | + int midX = width / 2;
|
---|
| 44 | + int midY = height / 2;
|
---|
| 45 | + int radius = size / 6;
|
---|
| 46 | + float scaler = (size - radius) / 10F;
|
---|
| 47 | +
|
---|
| 48 | + paint.reset();
|
---|
| 49 | + paint.setAlpha(150);
|
---|
| 50 | +
|
---|
| 51 | + paint.setColor(Color.RED);
|
---|
| 52 | + paint.setStyle(Style.FILL);
|
---|
| 53 | +
|
---|
| 54 | + canvas.drawCircle(midX - x * scaler, midY + y * scaler, radius, paint);
|
---|
| 55 | + canvas.drawCircle(midX - x * scaler, midY + size + radius, radius,
|
---|
| 56 | + paint);
|
---|
| 57 | + canvas.drawCircle(midX - size - radius, midY + y * scaler, radius,
|
---|
| 58 | + paint);
|
---|
| 59 | +
|
---|
| 60 | + paint.setTextSize(2 * radius);
|
---|
| 61 | + canvas.drawText("x=" + ((int) (-x * 100) / 100F) + ",y="
|
---|
| 62 | + + ((int) (-y * 100) / 100F), 0, 2 * radius, paint);
|
---|
| 63 | +
|
---|
| 64 | + paint.setStyle(Style.STROKE);
|
---|
| 65 | + paint.setStrokeWidth(2);
|
---|
| 66 | + paint.setColor(Color.BLACK);
|
---|
| 67 | +
|
---|
| 68 | + canvas.drawCircle(midX, midY, size, paint);
|
---|
| 69 | + canvas.drawCircle(midX, midY, radius + 1, paint);
|
---|
| 70 | + rectF.set(midX - size - 2 * radius, midY - size, midX - size, midY
|
---|
| 71 | + + size);
|
---|
| 72 | + canvas.drawRoundRect(rectF, radius, radius, paint);
|
---|
| 73 | + rectF.set(midX - size, midY + size, midX + size, midY + size + 2
|
---|
| 74 | + * radius);
|
---|
| 75 | + canvas.drawRoundRect(rectF, radius, radius, paint);
|
---|
| 76 | +
|
---|
| 77 | + canvas.drawLine(midX - radius, midY + size, midX - radius, midY + size
|
---|
| 78 | + + 2 * radius, paint);
|
---|
| 79 | + canvas.drawLine(midX + radius, midY + size, midX + radius, midY + size
|
---|
| 80 | + + 2 * radius, paint);
|
---|
| 81 | +
|
---|
| 82 | + canvas.drawLine(midX - size - 2 * radius, midY - radius, midX - size,
|
---|
| 83 | + midY - radius, paint);
|
---|
| 84 | + canvas.drawLine(midX - size - 2 * radius, midY + radius, midX - size,
|
---|
| 85 | + midY + radius, paint);
|
---|
| 86 | +
|
---|
| 87 | + }
|
---|
| 88 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.view;
|
---|
| 2 | +
|
---|
| 3 | +import android.content.Context;
|
---|
| 4 | +import android.util.AttributeSet;
|
---|
| 5 | +import android.util.Log;
|
---|
| 6 | +import android.view.Gravity;
|
---|
| 7 | +import android.view.MotionEvent;
|
---|
| 8 | +import android.view.View;
|
---|
| 9 | +import android.view.ViewGroup;
|
---|
| 10 | +import android.view.ViewParent;
|
---|
| 11 | +import android.widget.AdapterView.OnItemClickListener;
|
---|
| 12 | +import android.widget.AdapterView;
|
---|
| 13 | +import android.widget.FrameLayout;
|
---|
| 14 | +import android.widget.FrameLayout.LayoutParams;
|
---|
| 15 | +
|
---|
| 16 | +public class MyGridView extends FrameLayout implements View.OnClickListener {
|
---|
| 17 | + private String TAG = "MyGridView";
|
---|
| 18 | + private int mColumn = 1;
|
---|
| 19 | + private OnItemClickListener onItemClickListener;
|
---|
| 20 | +
|
---|
| 21 | + public MyGridView(Context context) {
|
---|
| 22 | + this(context, null, 0);
|
---|
| 23 | + }
|
---|
| 24 | +
|
---|
| 25 | + public MyGridView(Context context, AttributeSet attrs) {
|
---|
| 26 | + this(context, attrs, 0);
|
---|
| 27 | + }
|
---|
| 28 | +
|
---|
| 29 | + public MyGridView(Context context, AttributeSet attrs, int defStyle) {
|
---|
| 30 | + super(context, attrs, defStyle);
|
---|
| 31 | + }
|
---|
| 32 | +
|
---|
| 33 | + public void setColumnCount(int column) {
|
---|
| 34 | + this.mColumn = column;
|
---|
| 35 | + }
|
---|
| 36 | +
|
---|
| 37 | +
|
---|
| 38 | + protected void onLayout(boolean changed, int left, int top, int right,
|
---|
| 39 | + int bottom) {
|
---|
| 40 | + final int childCount = getChildCount();
|
---|
| 41 | + if (0 == childCount) {
|
---|
| 42 | + super.onLayout(changed, left, top, right, bottom);
|
---|
| 43 | + return;
|
---|
| 44 | + }
|
---|
| 45 | + final int width = right - left;
|
---|
| 46 | + final int height = bottom - top;
|
---|
| 47 | + final int column = mColumn;
|
---|
| 48 | + final int row = (childCount - 1) / column + 1;
|
---|
| 49 | + final int childHeight = height / row;
|
---|
| 50 | + final int childWidth = width / column;
|
---|
| 51 | +
|
---|
| 52 | + int childLeft = left;
|
---|
| 53 | + int childTop = top;
|
---|
| 54 | + for (int i = 0; i < childCount; i++) {
|
---|
| 55 | + View child = getChildAt(i);
|
---|
| 56 | + child.layout(childLeft, childTop, childLeft + childWidth, childTop
|
---|
| 57 | + + childHeight);
|
---|
| 58 | + childLeft += childWidth;
|
---|
| 59 | + if (((i + 1) % column) == 0) {
|
---|
| 60 | + childLeft = left;
|
---|
| 61 | + childTop += childHeight;
|
---|
| 62 | + }
|
---|
| 63 | + }
|
---|
| 64 | + }
|
---|
| 65 | +
|
---|
| 66 | + public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
|
---|
| 67 | + this.onItemClickListener = onItemClickListener;
|
---|
| 68 | + }
|
---|
| 69 | +
|
---|
| 70 | + public void addView(View child, int index, ViewGroup.LayoutParams params) {
|
---|
| 71 | + super.addView(child, index, params);
|
---|
| 72 | + child.setOnClickListener(this);
|
---|
| 73 | + }
|
---|
| 74 | +
|
---|
| 75 | + public interface OnItemClickListener {
|
---|
| 76 | + void onItemClick(ViewParent parent, View view, int position);
|
---|
| 77 | + }
|
---|
| 78 | +
|
---|
| 79 | +
|
---|
| 80 | + public void onClick(View v) {
|
---|
| 81 | + if (null == onItemClickListener) {
|
---|
| 82 | + return;
|
---|
| 83 | + }
|
---|
| 84 | + final int childCount = getChildCount();
|
---|
| 85 | + int istouchchildcount = 0;
|
---|
| 86 | + int touchid = -1;
|
---|
| 87 | + for (int i = 0; i < childCount; i++) {
|
---|
| 88 | + if (v == getChildAt(i)) {
|
---|
| 89 | + Log.d(TAG, "__________-----------onClick(), i = " + i);
|
---|
| 90 | + touchid = i;
|
---|
| 91 | + }
|
---|
| 92 | + if(((MyItemView)getChildAt(i)).getIsTouch()){
|
---|
| 93 | + istouchchildcount ++;
|
---|
| 94 | + }
|
---|
| 95 | + }
|
---|
| 96 | + Log.d(TAG, "__________-----------onClick(), touchid = " + touchid + " istouchchildcount = " + istouchchildcount);
|
---|
| 97 | + if(touchid >= 0 && istouchchildcount == 0)
|
---|
| 98 | + onItemClickListener.onItemClick(this, v, touchid);
|
---|
| 99 | + }
|
---|
| 100 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.view;
|
---|
| 2 | +
|
---|
| 3 | +import com.DeviceTest.helper.TestCase.RESULT;
|
---|
| 4 | +
|
---|
| 5 | +import android.content.Context;
|
---|
| 6 | +import android.graphics.Bitmap;
|
---|
| 7 | +import android.graphics.BitmapFactory;
|
---|
| 8 | +import android.graphics.Canvas;
|
---|
| 9 | +import android.graphics.Color;
|
---|
| 10 | +import android.graphics.Paint;
|
---|
| 11 | +import android.graphics.Paint.Style;
|
---|
| 12 | +import android.graphics.Rect;
|
---|
| 13 | +import android.graphics.drawable.Drawable;
|
---|
| 14 | +import android.util.AttributeSet;
|
---|
| 15 | +import android.util.Log;
|
---|
| 16 | +import android.view.Display;
|
---|
| 17 | +import android.view.MotionEvent;
|
---|
| 18 | +import android.view.WindowManager;
|
---|
| 19 | +import android.widget.TextView;
|
---|
| 20 | +import com.DeviceTest.R;
|
---|
| 21 | +public class MyItemView extends TextView {
|
---|
| 22 | + private static final String TAG = "MyItemView";
|
---|
| 23 | +
|
---|
| 24 | + public static final int PASS_COLOR = Color.rgb(0, 255, 0);
|
---|
| 25 | + public static final int FAILED_COLOR = Color.rgb(255, 0, 0);
|
---|
| 26 | + public static final int SKIP_COLOR = Color.rgb(0, 0, 255);
|
---|
| 27 | + public static final int CLICK_COLOR = Color.rgb(0, 255, 255);
|
---|
| 28 | +
|
---|
| 29 | + private RESULT mResult = RESULT.UNDEF;
|
---|
| 30 | + private int current_color = 0x00000000;
|
---|
| 31 | + private Paint mPaint = new Paint();
|
---|
| 32 | + private Rect mRect = new Rect();
|
---|
| 33 | + private Bitmap checkedbitmap = null;
|
---|
| 34 | + private Bitmap uncheckedbitmap = null;
|
---|
| 35 | + private int checkicon_left = 0;
|
---|
| 36 | + private int checkicon_top = 0;
|
---|
| 37 | + private final static int PADDINGLEN = 5;
|
---|
| 38 | + private boolean ischeck = true;
|
---|
| 39 | + private float scale;
|
---|
| 40 | + public MyItemView(Context context) {
|
---|
| 41 | + this(context, null, 0);
|
---|
| 42 | + }
|
---|
| 43 | +
|
---|
| 44 | + public MyItemView(Context context, AttributeSet attrs) {
|
---|
| 45 | + this(context, attrs, 0);
|
---|
| 46 | + }
|
---|
| 47 | +
|
---|
| 48 | + public MyItemView(Context context, AttributeSet attrs, int defStyle) {
|
---|
| 49 | + super(context, attrs, defStyle);
|
---|
| 50 | + WindowManager windowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
|
---|
| 51 | +
|
---|
| 52 | + Display display = windowManager.getDefaultDisplay();
|
---|
| 53 | + int densityDpi = getResources().getDisplayMetrics().densityDpi;
|
---|
| 54 | + scale = densityDpi/120;
|
---|
| 55 | + mPaint.setColor(Color.WHITE);
|
---|
| 56 | + mPaint.setStrokeWidth(2);
|
---|
| 57 | + mPaint.setStyle(Style.STROKE);
|
---|
| 58 | +// Drawable tmp = context.getResources().getDrawable(R.drawable.devicetest_icon);
|
---|
| 59 | + checkedbitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.btn_check_on);
|
---|
| 60 | + uncheckedbitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.btn_check_on_disable);
|
---|
| 61 | + setTextColor(Color.WHITE);
|
---|
| 62 | + setResult(RESULT.UNDEF);
|
---|
| 63 | + setBackgroundResource(R.drawable.itemclickbk);
|
---|
| 64 | + }
|
---|
| 65 | +
|
---|
| 66 | +
|
---|
| 67 | + protected void onLayout(boolean changed, int left, int top, int right,
|
---|
| 68 | + int bottom) {
|
---|
| 69 | + super.onLayout(changed, left, top, right, bottom);
|
---|
| 70 | + setTextSize((bottom - top) * 2 / 4/scale);
|
---|
| 71 | + checkicon_left = this.getWidth() - checkedbitmap.getWidth() - PADDINGLEN * 2;
|
---|
| 72 | + checkicon_top = (this.getHeight() - checkedbitmap.getHeight()) / 2;
|
---|
| 73 | + }
|
---|
| 74 | +
|
---|
| 75 | + public void setResult(RESULT result) {
|
---|
| 76 | + int color;
|
---|
| 77 | + switch (result) {
|
---|
| 78 | + case OK:
|
---|
| 79 | + color = PASS_COLOR;
|
---|
| 80 | + break;
|
---|
| 81 | + case NG:
|
---|
| 82 | + color = FAILED_COLOR;
|
---|
| 83 | + break;
|
---|
| 84 | + case SKIP:
|
---|
| 85 | + color = SKIP_COLOR;
|
---|
| 86 | + break;
|
---|
| 87 | + case UNDEF:
|
---|
| 88 | + color = 0xff101010;
|
---|
| 89 | + break;
|
---|
| 90 | + default:
|
---|
| 91 | + return;
|
---|
| 92 | + }
|
---|
| 93 | +
|
---|
| 94 | + mResult = result;
|
---|
| 95 | + current_color = color;
|
---|
| 96 | + this.setBackgroundColor(color);
|
---|
| 97 | + }
|
---|
| 98 | +
|
---|
| 99 | + public RESULT getResult() {
|
---|
| 100 | + return mResult;
|
---|
| 101 | + }
|
---|
| 102 | + public void setCheck(boolean check){
|
---|
| 103 | + this.ischeck = check;
|
---|
| 104 | + this.invalidate();
|
---|
| 105 | + }
|
---|
| 106 | + public boolean getTemcheckclick(){
|
---|
| 107 | + return tmpcheckclick;
|
---|
| 108 | + }
|
---|
| 109 | + public boolean setCheckClick(){
|
---|
| 110 | + if(tmpcheckclick){
|
---|
| 111 | + if(ischeck)
|
---|
| 112 | + ischeck = false;
|
---|
| 113 | + else
|
---|
| 114 | + ischeck = true;
|
---|
| 115 | + }
|
---|
| 116 | + this.invalidate();
|
---|
| 117 | + return tmpcheckclick;
|
---|
| 118 | + }
|
---|
| 119 | + public boolean getischeck(){
|
---|
| 120 | + return ischeck;
|
---|
| 121 | + }
|
---|
| 122 | + protected void onDraw(Canvas canvas) {
|
---|
| 123 | + super.onDraw(canvas);
|
---|
| 124 | + getDrawingRect(mRect);
|
---|
| 125 | + canvas.drawRect(mRect, mPaint);
|
---|
| 126 | + if(ischeck)
|
---|
| 127 | + canvas.drawBitmap(checkedbitmap, checkicon_left, checkicon_top, null);
|
---|
| 128 | + else
|
---|
| 129 | + canvas.drawBitmap(uncheckedbitmap, checkicon_left, checkicon_top, null);
|
---|
| 130 | + }
|
---|
| 131 | +
|
---|
| 132 | + private boolean tmpcheckclick = false;
|
---|
| 133 | + private boolean istouch = false;
|
---|
| 134 | + @Override
|
---|
| 135 | + public boolean onTouchEvent(MotionEvent event) {
|
---|
| 136 | +// Log.d(TAG, " ________ action = " + event.getAction() + " " + event.getX() + ", " + event.getY() + " w = " + this.getWidth());
|
---|
| 137 | +// Log.d(TAG, "_____________________ onTouchEvent(), " + event.getPointerCount());
|
---|
| 138 | + boolean ret = false;
|
---|
| 139 | + switch(event.getAction()){
|
---|
| 140 | + case MotionEvent.ACTION_DOWN:
|
---|
| 141 | + tmpcheckclick = false;
|
---|
| 142 | + this.setBackgroundColor(CLICK_COLOR);
|
---|
| 143 | + if(event.getX() > checkicon_left){
|
---|
| 144 | + tmpcheckclick = true;
|
---|
| 145 | + }
|
---|
| 146 | + istouch = true;
|
---|
| 147 | + break;
|
---|
| 148 | + case MotionEvent.ACTION_MOVE:
|
---|
| 149 | + if(event.getX()>0 && event.getX() < this.getWidth() && event.getY() > 0 && event.getY() < this.getHeight()){
|
---|
| 150 | + this.setBackgroundColor(CLICK_COLOR);
|
---|
| 151 | + if(tmpcheckclick && event.getX() < checkicon_left){
|
---|
| 152 | + tmpcheckclick = false;
|
---|
| 153 | + }
|
---|
| 154 | + }else{
|
---|
| 155 | + tmpcheckclick = false;
|
---|
| 156 | + this.setBackgroundColor(current_color);
|
---|
| 157 | + }
|
---|
| 158 | + break;
|
---|
| 159 | + case MotionEvent.ACTION_UP:
|
---|
| 160 | + this.setBackgroundColor(current_color);
|
---|
| 161 | + istouch = false;
|
---|
| 162 | + break;
|
---|
| 163 | + }
|
---|
| 164 | + return super.onTouchEvent(event);
|
---|
| 165 | + }
|
---|
| 166 | + public boolean getIsTouch(){
|
---|
| 167 | + return istouch;
|
---|
| 168 | + }
|
---|
| 169 | +}
|
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.view;
|
---|
| 2 | +
|
---|
| 3 | +import android.content.Context;
|
---|
| 4 | +import android.widget.TextView;
|
---|
| 5 | +
|
---|
| 6 | +public class MySpinnerView extends TextView {
|
---|
| 7 | +
|
---|
| 8 | + public MySpinnerView(Context context) {
|
---|
| 9 | + super(context);
|
---|
| 10 | + }
|
---|
| 11 | +
|
---|
| 12 | +
|
---|
| 13 | + protected void onLayout(boolean changed, int left, int top, int right,
|
---|
| 14 | + int bottom) {
|
---|
| 15 | + super.onLayout(changed, left, top, right, bottom);
|
---|
| 16 | + setTextSize((bottom - top) * 3 / 4);
|
---|
| 17 | + }
|
---|
| 18 | +
|
---|
| 19 | +
|
---|
| 20 | +}
|
---|
.. | .. |
---|
| 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.DeviceTest.view; |
---|
| 18 | + |
---|
| 19 | +import android.content.Context; |
---|
| 20 | +import android.graphics.Canvas; |
---|
| 21 | +import android.graphics.Paint; |
---|
| 22 | +import android.graphics.Paint.Align; |
---|
| 23 | +import android.graphics.Paint.FontMetricsInt; |
---|
| 24 | +import android.util.AttributeSet; |
---|
| 25 | +import android.util.Log; |
---|
| 26 | +import android.view.*; |
---|
| 27 | +import android.view.View.OnTouchListener; |
---|
| 28 | +import android.widget.RelativeLayout; |
---|
| 29 | + |
---|
| 30 | +import java.util.ArrayList; |
---|
| 31 | + |
---|
| 32 | +public class PointerLocationView extends View implements OnTouchListener { |
---|
| 33 | + public static class PointerState { |
---|
| 34 | + private final ArrayList<Float> mXs = new ArrayList<Float>(); |
---|
| 35 | + private final ArrayList<Float> mYs = new ArrayList<Float>(); |
---|
| 36 | + private boolean mCurDown; |
---|
| 37 | + private int mCurX; |
---|
| 38 | + private int mCurY; |
---|
| 39 | + private float mCurPressure; |
---|
| 40 | + private float mCurSize; |
---|
| 41 | + private int mCurWidth; |
---|
| 42 | + private VelocityTracker mVelocity; |
---|
| 43 | + } |
---|
| 44 | + |
---|
| 45 | + // private final ViewConfiguration mVC; |
---|
| 46 | + private int NP = 0; |
---|
| 47 | + private final Paint mTextPaint; |
---|
| 48 | + // private final Paint mTextBackgroundPaint; |
---|
| 49 | + // private final Paint mTextLevelPaint; |
---|
| 50 | + private final Paint mPaint; |
---|
| 51 | + private final Paint mTargetPaint; |
---|
| 52 | + private final Paint mPathPaint; |
---|
| 53 | + // private final FontMetricsInt mTextMetrics = new FontMetricsInt(); |
---|
| 54 | + // private int mHeaderBottom; |
---|
| 55 | + private boolean mCurDown; |
---|
| 56 | + private int mCurNumPointers; |
---|
| 57 | + private int mMaxNumPointers; |
---|
| 58 | + private final ArrayList<PointerState> mPointers = new ArrayList<PointerState>(); |
---|
| 59 | + |
---|
| 60 | + private boolean mPrintCoords = true; |
---|
| 61 | + |
---|
| 62 | + public PointerLocationView(Context context, AttributeSet attrs) { |
---|
| 63 | + this(context, attrs, 0); |
---|
| 64 | + } |
---|
| 65 | + |
---|
| 66 | + public PointerLocationView(Context context, AttributeSet attrs, int defStyle) { |
---|
| 67 | + super(context, attrs, defStyle); |
---|
| 68 | + |
---|
| 69 | + setFocusable(true); |
---|
| 70 | + // mVC = ViewConfiguration.get(context); |
---|
| 71 | + mTextPaint = new Paint(); |
---|
| 72 | + mTextPaint.setAntiAlias(true); |
---|
| 73 | + mTextPaint.setTextSize(50 * getResources().getDisplayMetrics().density); |
---|
| 74 | + mTextPaint.setARGB(255, 255, 0, 0); |
---|
| 75 | + mTextPaint.setTextAlign(Align.RIGHT); |
---|
| 76 | + /* |
---|
| 77 | + * mTextBackgroundPaint = new Paint(); |
---|
| 78 | + * mTextBackgroundPaint.setAntiAlias(false); |
---|
| 79 | + * mTextBackgroundPaint.setARGB(128, 255, 255, 255); mTextLevelPaint = |
---|
| 80 | + * new Paint(); mTextLevelPaint.setAntiAlias(false); |
---|
| 81 | + * mTextLevelPaint.setARGB(192, 255, 0, 0); |
---|
| 82 | + */ |
---|
| 83 | + mPaint = new Paint(); |
---|
| 84 | + mPaint.setAntiAlias(true); |
---|
| 85 | + mPaint.setARGB(255, 255, 255, 255); |
---|
| 86 | + mPaint.setStyle(Paint.Style.STROKE); |
---|
| 87 | + mPaint.setStrokeWidth(2); |
---|
| 88 | + mTargetPaint = new Paint(); |
---|
| 89 | + mTargetPaint.setAntiAlias(false); |
---|
| 90 | + mTargetPaint.setARGB(255, 0, 0, 192); |
---|
| 91 | + mPathPaint = new Paint(); |
---|
| 92 | + mPathPaint.setAntiAlias(false); |
---|
| 93 | + mPathPaint.setARGB(255, 0, 96, 255); |
---|
| 94 | + mPaint.setStyle(Paint.Style.STROKE); |
---|
| 95 | + mPaint.setStrokeWidth(1); |
---|
| 96 | + |
---|
| 97 | + PointerState ps = new PointerState(); |
---|
| 98 | + ps.mVelocity = VelocityTracker.obtain(); |
---|
| 99 | + mPointers.add(ps); |
---|
| 100 | + } |
---|
| 101 | + |
---|
| 102 | + public void setPrintCoords(boolean state) { |
---|
| 103 | + mPrintCoords = state; |
---|
| 104 | + } |
---|
| 105 | + |
---|
| 106 | + |
---|
| 107 | + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
---|
| 108 | + super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
---|
| 109 | + /* |
---|
| 110 | + * mTextPaint.getFontMetricsInt(mTextMetrics); mHeaderBottom = |
---|
| 111 | + * -mTextMetrics.ascent+mTextMetrics.descent+2; |
---|
| 112 | + */ |
---|
| 113 | + ((ViewGroup)getParent()).setOnTouchListener(this); |
---|
| 114 | + } |
---|
| 115 | + |
---|
| 116 | + |
---|
| 117 | + protected void onDraw(Canvas canvas) { |
---|
| 118 | + synchronized (mPointers) { |
---|
| 119 | + NP = mPointers.size(); |
---|
| 120 | + |
---|
| 121 | + /* |
---|
| 122 | + * final int w = getWidth(); final int itemW = w/7; final int base = |
---|
| 123 | + * -mTextMetrics.ascent+1; final int bottom = mHeaderBottom; |
---|
| 124 | + * |
---|
| 125 | + * |
---|
| 126 | + * if (NP > 0) { final PointerState ps = mPointers.get(0); |
---|
| 127 | + * canvas.drawRect(0, 0, itemW-1, bottom,mTextBackgroundPaint); |
---|
| 128 | + * canvas.drawText("P: " + mCurNumPointers + " / " + |
---|
| 129 | + * mMaxNumPointers, 1, base, mTextPaint); |
---|
| 130 | + * |
---|
| 131 | + * final int N = ps.mXs.size(); if ((mCurDown && ps.mCurDown) || N |
---|
| 132 | + * == 0) { canvas.drawRect(itemW, 0, (itemW * 2) - 1, bottom, |
---|
| 133 | + * mTextBackgroundPaint); canvas.drawText("X: " + ps.mCurX, 1 + |
---|
| 134 | + * itemW, base, mTextPaint); canvas.drawRect(itemW * 2, 0, (itemW * |
---|
| 135 | + * 3) - 1, bottom, mTextBackgroundPaint); canvas.drawText("Y: " + |
---|
| 136 | + * ps.mCurY, 1 + itemW * 2, base, mTextPaint); } else { float dx = |
---|
| 137 | + * ps.mXs.get(N-1) - ps.mXs.get(0); float dy = ps.mYs.get(N-1) - |
---|
| 138 | + * ps.mYs.get(0); canvas.drawRect(itemW, 0, (itemW * 2) - 1, bottom, |
---|
| 139 | + * Math.abs(dx) < mVC.getScaledTouchSlop() ? mTextBackgroundPaint : |
---|
| 140 | + * mTextLevelPaint); canvas.drawText("dX: " + String.format("%.1f", |
---|
| 141 | + * dx), 1 + itemW, base, mTextPaint); canvas.drawRect(itemW * 2, 0, |
---|
| 142 | + * (itemW * 3) - 1, bottom, Math.abs(dy) < mVC.getScaledTouchSlop() |
---|
| 143 | + * ? mTextBackgroundPaint : mTextLevelPaint); canvas.drawText("dY: " |
---|
| 144 | + * + String.format("%.1f", dy), 1 + itemW * 2, base, mTextPaint); } |
---|
| 145 | + * |
---|
| 146 | + * canvas.drawRect(itemW * 3, 0, (itemW * 4) - 1, bottom, |
---|
| 147 | + * mTextBackgroundPaint); int velocity = ps.mVelocity == null ? 0 : |
---|
| 148 | + * (int) (ps.mVelocity.getXVelocity() * 1000); |
---|
| 149 | + * canvas.drawText("Xv: " + velocity, 1 + itemW * 3, base, |
---|
| 150 | + * mTextPaint); |
---|
| 151 | + * |
---|
| 152 | + * canvas.drawRect(itemW * 4, 0, (itemW * 5) - 1, bottom, |
---|
| 153 | + * mTextBackgroundPaint); velocity = ps.mVelocity == null ? 0 : |
---|
| 154 | + * (int) (ps.mVelocity.getYVelocity() * 1000); |
---|
| 155 | + * canvas.drawText("Yv: " + velocity, 1 + itemW * 4, base, |
---|
| 156 | + * mTextPaint); |
---|
| 157 | + * |
---|
| 158 | + * canvas.drawRect(itemW * 5, 0, (itemW * 6) - 1, bottom, |
---|
| 159 | + * mTextBackgroundPaint); canvas.drawRect(itemW * 5, 0, (itemW * 5) |
---|
| 160 | + * + (ps.mCurPressure * itemW) - 1, bottom, mTextLevelPaint); |
---|
| 161 | + * canvas.drawText("Prs: " + String.format("%.2f", ps.mCurPressure), |
---|
| 162 | + * 1 + itemW * 5, base, mTextPaint); |
---|
| 163 | + * |
---|
| 164 | + * canvas.drawRect(itemW * 6, 0, w, bottom, mTextBackgroundPaint); |
---|
| 165 | + * canvas.drawRect(itemW * 6, 0, (itemW * 6) + (ps.mCurSize * itemW) |
---|
| 166 | + * - 1, bottom, mTextLevelPaint); canvas.drawText("Size: " + |
---|
| 167 | + * String.format("%.2f", ps.mCurSize), 1 + itemW * 6, base, |
---|
| 168 | + * mTextPaint); } |
---|
| 169 | + */ |
---|
| 170 | + |
---|
| 171 | + if (onPointCountChangeListener != null) { |
---|
| 172 | + onPointCountChangeListener.onPointCountChange(mPointers.size()); |
---|
| 173 | + } |
---|
| 174 | + canvas.drawText("Current Point:" + mCurNumPointers, getWidth() / 2, getHeight() / 2, |
---|
| 175 | + mTextPaint); |
---|
| 176 | + |
---|
| 177 | + for (int p = 0; p < NP; p++) { |
---|
| 178 | + final PointerState ps = mPointers.get(p); |
---|
| 179 | + |
---|
| 180 | + if (mCurDown && ps.mCurDown) { |
---|
| 181 | + canvas.drawLine(0, (int) ps.mCurY, getWidth(), |
---|
| 182 | + (int) ps.mCurY, mTargetPaint); |
---|
| 183 | + canvas.drawLine((int) ps.mCurX, 0, (int) ps.mCurX, |
---|
| 184 | + getHeight(), mTargetPaint); |
---|
| 185 | + int pressureLevel = (int) (ps.mCurPressure * 255); |
---|
| 186 | + mPaint.setARGB(255, pressureLevel, 128, 255 - pressureLevel); |
---|
| 187 | + canvas.drawPoint(ps.mCurX, ps.mCurY, mPaint); |
---|
| 188 | + canvas.drawCircle(ps.mCurX, ps.mCurY, ps.mCurWidth, mPaint); |
---|
| 189 | + } |
---|
| 190 | + } |
---|
| 191 | + |
---|
| 192 | + for (int p = 0; p < NP; p++) { |
---|
| 193 | + final PointerState ps = mPointers.get(p); |
---|
| 194 | + |
---|
| 195 | + final int N = ps.mXs.size(); |
---|
| 196 | + float lastX = 0, lastY = 0; |
---|
| 197 | + boolean haveLast = false; |
---|
| 198 | + boolean drawn = false; |
---|
| 199 | + mPaint.setARGB(255, 128, 255, 255); |
---|
| 200 | + for (int i = 0; i < N; i++) { |
---|
| 201 | + float x = ps.mXs.get(i); |
---|
| 202 | + float y = ps.mYs.get(i); |
---|
| 203 | + if (Float.isNaN(x)) { |
---|
| 204 | + haveLast = false; |
---|
| 205 | + continue; |
---|
| 206 | + } |
---|
| 207 | + if (haveLast) { |
---|
| 208 | + canvas.drawLine(lastX, lastY, x, y, mPathPaint); |
---|
| 209 | + canvas.drawPoint(lastX, lastY, mPaint); |
---|
| 210 | + drawn = true; |
---|
| 211 | + } |
---|
| 212 | + lastX = x; |
---|
| 213 | + lastY = y; |
---|
| 214 | + haveLast = true; |
---|
| 215 | + } |
---|
| 216 | + |
---|
| 217 | + if (drawn) { |
---|
| 218 | + if (ps.mVelocity != null) { |
---|
| 219 | + mPaint.setARGB(255, 255, 64, 128); |
---|
| 220 | + float xVel = ps.mVelocity.getXVelocity() * (1000 / 60); |
---|
| 221 | + float yVel = ps.mVelocity.getYVelocity() * (1000 / 60); |
---|
| 222 | + canvas.drawLine(lastX, lastY, lastX + xVel, lastY |
---|
| 223 | + + yVel, mPaint); |
---|
| 224 | + } else { |
---|
| 225 | + canvas.drawPoint(lastX, lastY, mPaint); |
---|
| 226 | + } |
---|
| 227 | + } |
---|
| 228 | + } |
---|
| 229 | + } |
---|
| 230 | + } |
---|
| 231 | + |
---|
| 232 | + public void addTouchEvent(MotionEvent event) { |
---|
| 233 | + synchronized (mPointers) { |
---|
| 234 | + int action = event.getAction(); |
---|
| 235 | + |
---|
| 236 | + NP = mPointers.size(); |
---|
| 237 | + |
---|
| 238 | + if (action == MotionEvent.ACTION_DOWN) { |
---|
| 239 | + for (int p = 0; p < NP; p++) { |
---|
| 240 | + final PointerState ps = mPointers.get(p); |
---|
| 241 | + ps.mXs.clear(); |
---|
| 242 | + ps.mYs.clear(); |
---|
| 243 | + ps.mVelocity = VelocityTracker.obtain(); |
---|
| 244 | + ps.mCurDown = false; |
---|
| 245 | + } |
---|
| 246 | + mPointers.get(0).mCurDown = true; |
---|
| 247 | + mMaxNumPointers = 0; |
---|
| 248 | + if (mPrintCoords) { |
---|
| 249 | + Log.i("Pointer", "Pointer 1: DOWN"); |
---|
| 250 | + } |
---|
| 251 | + } |
---|
| 252 | + |
---|
| 253 | + if ((action & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_DOWN) { |
---|
| 254 | + |
---|
| 255 | + Log.i("Pointer", "action down"); |
---|
| 256 | + final int index = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; |
---|
| 257 | + final int id = event.getPointerId(index); |
---|
| 258 | + while (NP <= id) { |
---|
| 259 | + PointerState ps = new PointerState(); |
---|
| 260 | + ps.mVelocity = VelocityTracker.obtain(); |
---|
| 261 | + mPointers.add(ps); |
---|
| 262 | + NP++; |
---|
| 263 | + } |
---|
| 264 | + final PointerState ps = mPointers.get(id); |
---|
| 265 | + ps.mVelocity = VelocityTracker.obtain(); |
---|
| 266 | + ps.mCurDown = true; |
---|
| 267 | + if (mPrintCoords) { |
---|
| 268 | + Log.i("Pointer", "Pointer " + (id + 1) + ": DOWN"); |
---|
| 269 | + } |
---|
| 270 | + } |
---|
| 271 | + |
---|
| 272 | + final int NI = event.getPointerCount(); |
---|
| 273 | + |
---|
| 274 | + mCurDown = action != MotionEvent.ACTION_UP |
---|
| 275 | + && action != MotionEvent.ACTION_CANCEL; |
---|
| 276 | + mCurNumPointers = mCurDown ? NI : 0; |
---|
| 277 | + if (mMaxNumPointers < mCurNumPointers) { |
---|
| 278 | + mMaxNumPointers = mCurNumPointers; |
---|
| 279 | + } |
---|
| 280 | + |
---|
| 281 | + for (int i = 0; i < NI; i++) { |
---|
| 282 | + final int id = event.getPointerId(i); |
---|
| 283 | + final PointerState ps = mPointers.get(id); |
---|
| 284 | + ps.mVelocity.addMovement(event); |
---|
| 285 | + ps.mVelocity.computeCurrentVelocity(1); |
---|
| 286 | + final int N = event.getHistorySize(); |
---|
| 287 | + for (int j = 0; j < N; j++) { |
---|
| 288 | + if (mPrintCoords) { |
---|
| 289 | + Log.i("Pointer", |
---|
| 290 | + "Pointer " + (id + 1) + ": (" |
---|
| 291 | + + event.getHistoricalX(i, j) + ", " |
---|
| 292 | + + event.getHistoricalY(i, j) + ")" |
---|
| 293 | + + " Prs=" |
---|
| 294 | + + event.getHistoricalPressure(i, j) |
---|
| 295 | + + " Size=" |
---|
| 296 | + + event.getHistoricalSize(i, j)); |
---|
| 297 | + } |
---|
| 298 | + ps.mXs.add(event.getHistoricalX(i, j)); |
---|
| 299 | + ps.mYs.add(event.getHistoricalY(i, j)); |
---|
| 300 | + } |
---|
| 301 | + if (mPrintCoords) { |
---|
| 302 | + Log.i("Pointer", |
---|
| 303 | + "Pointer " + (id + 1) + ": (" + event.getX(i) |
---|
| 304 | + + ", " + event.getY(i) + ")" + " Prs=" |
---|
| 305 | + + event.getPressure(i) + " Size=" |
---|
| 306 | + + event.getSize(i)); |
---|
| 307 | + } |
---|
| 308 | + ps.mXs.add(event.getX(i)); |
---|
| 309 | + ps.mYs.add(event.getY(i)); |
---|
| 310 | + ps.mCurX = (int) event.getX(i); |
---|
| 311 | + ps.mCurY = (int) event.getY(i); |
---|
| 312 | + // Log.i("Pointer", "Pointer #" + p + ": (" + ps.mCurX |
---|
| 313 | + // + "," + ps.mCurY + ")"); |
---|
| 314 | + ps.mCurPressure = event.getPressure(i); |
---|
| 315 | + ps.mCurSize = event.getSize(i); |
---|
| 316 | + ps.mCurWidth = (int) (ps.mCurSize * (getWidth() / 3)); |
---|
| 317 | + } |
---|
| 318 | + |
---|
| 319 | + if ((action & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_UP) { |
---|
| 320 | + |
---|
| 321 | + Log.i("Pointer", "action up"); |
---|
| 322 | + final int index = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; |
---|
| 323 | + final int id = event.getPointerId(index); |
---|
| 324 | + final PointerState ps = mPointers.get(id); |
---|
| 325 | + ps.mXs.add(Float.NaN); |
---|
| 326 | + ps.mYs.add(Float.NaN); |
---|
| 327 | + ps.mCurDown = false; |
---|
| 328 | + if (mPrintCoords) { |
---|
| 329 | + Log.i("Pointer", "Pointer " + (id + 1) + ": UP"); |
---|
| 330 | + } |
---|
| 331 | + } |
---|
| 332 | + |
---|
| 333 | + if (action == MotionEvent.ACTION_UP) { |
---|
| 334 | + for (int i = 0; i < NI; i++) { |
---|
| 335 | + final int id = event.getPointerId(i); |
---|
| 336 | + final PointerState ps = mPointers.get(id); |
---|
| 337 | + if (ps.mCurDown) { |
---|
| 338 | + ps.mCurDown = false; |
---|
| 339 | + if (mPrintCoords) { |
---|
| 340 | + Log.i("Pointer", "Pointer " + (id + 1) + ": UP"); |
---|
| 341 | + } |
---|
| 342 | + } |
---|
| 343 | + } |
---|
| 344 | + } |
---|
| 345 | + |
---|
| 346 | + postInvalidate(); |
---|
| 347 | + } |
---|
| 348 | + } |
---|
| 349 | + |
---|
| 350 | + |
---|
| 351 | + public interface OnPointCountChangeListener { |
---|
| 352 | + public void onPointCountChange(int newPointCount); |
---|
| 353 | + } |
---|
| 354 | + |
---|
| 355 | + private OnPointCountChangeListener onPointCountChangeListener; |
---|
| 356 | + |
---|
| 357 | + public void setOnPointCountChangeListener( |
---|
| 358 | + OnPointCountChangeListener onPointCountChangeListener) { |
---|
| 359 | + this.onPointCountChangeListener = onPointCountChangeListener; |
---|
| 360 | + } |
---|
| 361 | + |
---|
| 362 | + |
---|
| 363 | + public boolean onTouch(View v, MotionEvent event) { |
---|
| 364 | + addTouchEvent(event); |
---|
| 365 | + |
---|
| 366 | + return true; |
---|
| 367 | + } |
---|
| 368 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.view;
|
---|
| 2 | +
|
---|
| 3 | +import com.DeviceTest.FirstRun.TEST_STATUS;
|
---|
| 4 | +import android.content.Context;
|
---|
| 5 | +import android.graphics.Canvas;
|
---|
| 6 | +import android.graphics.Color;
|
---|
| 7 | +import android.graphics.Paint;
|
---|
| 8 | +import android.graphics.Paint.Style;
|
---|
| 9 | +import android.util.AttributeSet;
|
---|
| 10 | +import android.widget.TextView;
|
---|
| 11 | +
|
---|
| 12 | +public class TestView extends TextView{
|
---|
| 13 | + private final static String TAG = "TestView";
|
---|
| 14 | + public static final int SUCC_COLOR = Color.GREEN;
|
---|
| 15 | + public static final int FAIL_COLOR = Color.RED;
|
---|
| 16 | + public static final int TEST_COLOR = Color.YELLOW;
|
---|
| 17 | + public static final int WAIT_COLOR = Color.GRAY;
|
---|
| 18 | +
|
---|
| 19 | + private float center_x = 0;
|
---|
| 20 | + private float center_y = 0;
|
---|
| 21 | + private float ball_radius = 0;
|
---|
| 22 | + private final static float SCALE = 2.0f;
|
---|
| 23 | +
|
---|
| 24 | + private TEST_STATUS currentstatus = TEST_STATUS.WAITING;
|
---|
| 25 | + private Paint mPaint = new Paint();
|
---|
| 26 | + public TestView(Context context, AttributeSet attrs) {
|
---|
| 27 | + super(context, attrs);
|
---|
| 28 | + mPaint.setStyle(Style.FILL);
|
---|
| 29 | + }
|
---|
| 30 | +
|
---|
| 31 | + @Override
|
---|
| 32 | + protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
---|
| 33 | + super.onLayout(changed, left, top, right, bottom);
|
---|
| 34 | + center_x = this.getWidth()/2.0f;
|
---|
| 35 | + center_y = this.getHeight()/2.0f;
|
---|
| 36 | + ball_radius = this.getWidth() > this.getHeight() ? this.getHeight()/SCALE : this.getWidth()/SCALE;
|
---|
| 37 | + }
|
---|
| 38 | +
|
---|
| 39 | + @Override
|
---|
| 40 | + public void draw(Canvas canvas) {
|
---|
| 41 | + int color = WAIT_COLOR;
|
---|
| 42 | + switch(currentstatus){
|
---|
| 43 | + case WAITING:
|
---|
| 44 | + color = WAIT_COLOR;
|
---|
| 45 | + break;
|
---|
| 46 | + case TESTING:
|
---|
| 47 | + color = TEST_COLOR;
|
---|
| 48 | + break;
|
---|
| 49 | + case FAILED:
|
---|
| 50 | + color = FAIL_COLOR;
|
---|
| 51 | + break;
|
---|
| 52 | + case SUCCEED:
|
---|
| 53 | + color = SUCC_COLOR;
|
---|
| 54 | + break;
|
---|
| 55 | + }
|
---|
| 56 | + mPaint.setColor(color);
|
---|
| 57 | + canvas.drawCircle(center_x, center_y, ball_radius / 2, mPaint);
|
---|
| 58 | +
|
---|
| 59 | + super.draw(canvas);
|
---|
| 60 | + }
|
---|
| 61 | + public void setStatus(TEST_STATUS tmp){
|
---|
| 62 | + this.currentstatus = tmp;
|
---|
| 63 | + this.invalidate();
|
---|
| 64 | + }
|
---|
| 65 | +} |
---|
.. | .. |
---|
| 1 | +package com.DeviceTest.view;
|
---|
| 2 | +
|
---|
| 3 | +import android.content.Context;
|
---|
| 4 | +import android.opengl.GLSurfaceView;
|
---|
| 5 | +import android.opengl.GLSurfaceView.Renderer;
|
---|
| 6 | +import android.view.KeyEvent;
|
---|
| 7 | +import android.view.MotionEvent;
|
---|
| 8 | +import javax.microedition.khronos.egl.EGLConfig;
|
---|
| 9 | +import javax.microedition.khronos.opengles.GL10;
|
---|
| 10 | +
|
---|
| 11 | +public class TouchSurfaceView extends GLSurfaceView
|
---|
| 12 | +{
|
---|
| 13 | + private final float TOUCH_SCALE_FACTOR = 0.5625F;
|
---|
| 14 | + private float mPreviousX;
|
---|
| 15 | + private float mPreviousY;
|
---|
| 16 | + private float mPreviousZ;
|
---|
| 17 | + private CubeRenderer mRenderer = new CubeRenderer();
|
---|
| 18 | +
|
---|
| 19 | + public TouchSurfaceView(Context paramContext)
|
---|
| 20 | + {
|
---|
| 21 | + super(paramContext);
|
---|
| 22 | + setRenderer(this.mRenderer);
|
---|
| 23 | + setRenderMode(0);
|
---|
| 24 | + }
|
---|
| 25 | +
|
---|
| 26 | + public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
|
---|
| 27 | + {
|
---|
| 28 | + if (paramInt == 82)
|
---|
| 29 | + {
|
---|
| 30 | + this.mRenderer.mAngleZ = 0.0F;
|
---|
| 31 | + mRenderer.mAngleY = 0.0F;
|
---|
| 32 | + mRenderer.mAngleX = 0.0F;
|
---|
| 33 | + }
|
---|
| 34 | + return super.onKeyDown(paramInt, paramKeyEvent);
|
---|
| 35 | + }
|
---|
| 36 | +
|
---|
| 37 | + public boolean onTouchEvent(MotionEvent paramMotionEvent)
|
---|
| 38 | + {
|
---|
| 39 | + this.mRenderer.mAngleZ = 0.0F;
|
---|
| 40 | + mRenderer.mAngleY = 0.0F;
|
---|
| 41 | + mRenderer.mAngleX = 0.0F;
|
---|
| 42 | + return true;
|
---|
| 43 | + }
|
---|
| 44 | +
|
---|
| 45 | + public void updateGyro(float paramFloat1, float paramFloat2, float paramFloat3)
|
---|
| 46 | + {
|
---|
| 47 | + float f1 = paramFloat1 - this.mPreviousX;
|
---|
| 48 | + float f2 = paramFloat2 - this.mPreviousY;
|
---|
| 49 | + float f3 = paramFloat3 - this.mPreviousZ;
|
---|
| 50 | + CubeRenderer localCubeRenderer1 = this.mRenderer;
|
---|
| 51 | + localCubeRenderer1.mAngleX += f1 * 0.5625F;
|
---|
| 52 | + CubeRenderer localCubeRenderer2 = this.mRenderer;
|
---|
| 53 | + localCubeRenderer2.mAngleY += f2 * 0.5625F;
|
---|
| 54 | + CubeRenderer localCubeRenderer3 = this.mRenderer;
|
---|
| 55 | + localCubeRenderer3.mAngleZ += f3 * 0.5625F;
|
---|
| 56 | + requestRender();
|
---|
| 57 | + this.mPreviousX = paramFloat1;
|
---|
| 58 | + this.mPreviousY = paramFloat2;
|
---|
| 59 | + this.mPreviousZ = paramFloat3;
|
---|
| 60 | + }
|
---|
| 61 | +
|
---|
| 62 | + private class CubeRenderer
|
---|
| 63 | + implements GLSurfaceView.Renderer
|
---|
| 64 | + {
|
---|
| 65 | + public float mAngleX;
|
---|
| 66 | + public float mAngleY;
|
---|
| 67 | + public float mAngleZ;
|
---|
| 68 | + private Cube mCube = new Cube();
|
---|
| 69 | +
|
---|
| 70 | + public CubeRenderer()
|
---|
| 71 | + {
|
---|
| 72 | + }
|
---|
| 73 | +
|
---|
| 74 | + public void onDrawFrame(GL10 gl)
|
---|
| 75 | + {
|
---|
| 76 | + gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
|
---|
| 77 | + gl.glMatrixMode(GL10.GL_MODELVIEW);
|
---|
| 78 | + gl.glLoadIdentity();
|
---|
| 79 | + gl.glTranslatef(0.0F, 0.0F, -6.0F);
|
---|
| 80 | + gl.glRotatef(this.mAngleY, 1.0F, 0.0F, 0.0F);
|
---|
| 81 | + gl.glRotatef(this.mAngleX, 0.0F, 1.0F, 0.0F);
|
---|
| 82 | + gl.glRotatef(this.mAngleZ, 0.0F, 0.0F, 1.0F);
|
---|
| 83 | + gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
|
---|
| 84 | + gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
|
---|
| 85 | + this.mCube.draw(gl);
|
---|
| 86 | + }
|
---|
| 87 | +
|
---|
| 88 | + public void onSurfaceChanged(GL10 gl, int width, int height)
|
---|
| 89 | + {
|
---|
| 90 | + gl.glViewport(0, 0, width, height);
|
---|
| 91 | +
|
---|
| 92 | + /*
|
---|
| 93 | + * Set our projection matrix. This doesn't have to be done
|
---|
| 94 | + * each time we draw, but usually a new projection needs to
|
---|
| 95 | + * be set when the viewport is resized.
|
---|
| 96 | + */
|
---|
| 97 | +
|
---|
| 98 | + float ratio = (float) width / height;
|
---|
| 99 | + gl.glMatrixMode(GL10.GL_PROJECTION);
|
---|
| 100 | + gl.glLoadIdentity();
|
---|
| 101 | + gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);
|
---|
| 102 | + }
|
---|
| 103 | +
|
---|
| 104 | + public void onSurfaceCreated(GL10 gl, EGLConfig paramEGLConfig)
|
---|
| 105 | + {
|
---|
| 106 | + /*
|
---|
| 107 | + * By default, OpenGL enables features that improve quality
|
---|
| 108 | + * but reduce performance. One might want to tweak that
|
---|
| 109 | + * especially on software renderer.
|
---|
| 110 | + */
|
---|
| 111 | + gl.glDisable(GL10.GL_DITHER);
|
---|
| 112 | +
|
---|
| 113 | + /*
|
---|
| 114 | + * Some one-time OpenGL initialization can be made here
|
---|
| 115 | + * probably based on features of this particular context
|
---|
| 116 | + */
|
---|
| 117 | + gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,
|
---|
| 118 | + GL10.GL_FASTEST);
|
---|
| 119 | +
|
---|
| 120 | +
|
---|
| 121 | + gl.glClearColor(1,1,1,1);
|
---|
| 122 | + gl.glEnable(GL10.GL_CULL_FACE);
|
---|
| 123 | + gl.glShadeModel(GL10.GL_SMOOTH);
|
---|
| 124 | + gl.glEnable(GL10.GL_DEPTH_TEST);
|
---|
| 125 | + }
|
---|
| 126 | + }
|
---|
| 127 | +}
|
---|
.. | .. |
---|
| 1 | +package com.rockchip.dmi;
|
---|
| 2 | +
|
---|
| 3 | +public class DmiInfo {
|
---|
| 4 | + private String manufacture;
|
---|
| 5 | + private String productName;
|
---|
| 6 | + private String version;
|
---|
| 7 | + private String serialNumber;
|
---|
| 8 | + private byte[] UUID;
|
---|
| 9 | + private String OEM_Strings;
|
---|
| 10 | + private String terminalID;
|
---|
| 11 | +
|
---|
| 12 | + private static DmiInfo instance;
|
---|
| 13 | +
|
---|
| 14 | + private DmiInfo(Object[] dmiInfo) {
|
---|
| 15 | +
|
---|
| 16 | + manufacture = (String) dmiInfo[0];
|
---|
| 17 | + productName = (String) dmiInfo[1];
|
---|
| 18 | + version = (String) dmiInfo[2];
|
---|
| 19 | + serialNumber = (String) dmiInfo[3];
|
---|
| 20 | +
|
---|
| 21 | + UUID = (byte[]) dmiInfo[4];
|
---|
| 22 | +
|
---|
| 23 | + OEM_Strings = (String) dmiInfo[5];
|
---|
| 24 | + terminalID = (String) dmiInfo[6];
|
---|
| 25 | + }
|
---|
| 26 | +
|
---|
| 27 | + public String toString() {
|
---|
| 28 | + String str = "";
|
---|
| 29 | + str += "Manufacture:" + manufacture + "\n";
|
---|
| 30 | + str += "ProductName:" + productName + "\n";
|
---|
| 31 | + str += "Version:" + version + "\n";
|
---|
| 32 | + str += "SerialNumber:" + serialNumber + "\n";
|
---|
| 33 | +
|
---|
| 34 | + str += "UUID:";
|
---|
| 35 | + for (int i = 0; i < UUID.length; i++) {
|
---|
| 36 | + str += String.format("%02X", UUID[i]);
|
---|
| 37 | + }
|
---|
| 38 | + str += "\n";
|
---|
| 39 | +
|
---|
| 40 | + str += "OEM_Strings:" + OEM_Strings + "\n";
|
---|
| 41 | + str += "TerminalID:" + terminalID + "\n";
|
---|
| 42 | + return str;
|
---|
| 43 | + }
|
---|
| 44 | +
|
---|
| 45 | + protected static DmiInfo getInstance() {
|
---|
| 46 | + return instance;
|
---|
| 47 | + }
|
---|
| 48 | +
|
---|
| 49 | + protected static DmiInfo getInstance(Object[] dmiInfo) {
|
---|
| 50 | + if (dmiInfo == null) {
|
---|
| 51 | + instance = null;
|
---|
| 52 | + } else {
|
---|
| 53 | + try {
|
---|
| 54 | + instance = new DmiInfo(dmiInfo);
|
---|
| 55 | + } catch (Exception e) {
|
---|
| 56 | + instance = null;
|
---|
| 57 | + }
|
---|
| 58 | + }
|
---|
| 59 | + return instance;
|
---|
| 60 | + }
|
---|
| 61 | +
|
---|
| 62 | + public String getManufacture() {
|
---|
| 63 | + return manufacture;
|
---|
| 64 | + }
|
---|
| 65 | +
|
---|
| 66 | + public String getProductName() {
|
---|
| 67 | + return productName;
|
---|
| 68 | + }
|
---|
| 69 | +
|
---|
| 70 | + public String getVersion() {
|
---|
| 71 | + return version;
|
---|
| 72 | + }
|
---|
| 73 | +
|
---|
| 74 | + public String getSerialNumber() {
|
---|
| 75 | + return serialNumber;
|
---|
| 76 | + }
|
---|
| 77 | +
|
---|
| 78 | + public byte[] getUUID() {
|
---|
| 79 | + return UUID;
|
---|
| 80 | + }
|
---|
| 81 | +
|
---|
| 82 | + public String getOEM_Strings() {
|
---|
| 83 | + return OEM_Strings;
|
---|
| 84 | + }
|
---|
| 85 | +
|
---|
| 86 | + public String getTerminalID() {
|
---|
| 87 | + return terminalID;
|
---|
| 88 | + }
|
---|
| 89 | +}
|
---|
.. | .. |
---|
| 1 | +package com.rockchip.dmi;
|
---|
| 2 | +
|
---|
| 3 | +import android.content.Context;
|
---|
| 4 | +import android.net.wifi.WifiManager;
|
---|
| 5 | +import android.os.SystemClock;
|
---|
| 6 | +
|
---|
| 7 | +public class DmiUtil {
|
---|
| 8 | +
|
---|
| 9 | + static {
|
---|
| 10 | + System.loadLibrary("getdmi");
|
---|
| 11 | + }
|
---|
| 12 | +
|
---|
| 13 | + private static native Object[] getdmi();
|
---|
| 14 | +
|
---|
| 15 | + public static DmiInfo getDmiInfo(Context context, boolean regain) {
|
---|
| 16 | + DmiInfo dmiInfo = null;
|
---|
| 17 | +
|
---|
| 18 | + // use the cached infos.
|
---|
| 19 | + if (!regain) {
|
---|
| 20 | + dmiInfo = DmiInfo.getInstance();
|
---|
| 21 | + }
|
---|
| 22 | +
|
---|
| 23 | + // try to get infos.
|
---|
| 24 | + if (null == dmiInfo) {
|
---|
| 25 | + // enable wifi to get the mac addr.
|
---|
| 26 | + WifiManager wifiManager = (WifiManager) context
|
---|
| 27 | + .getSystemService(Context.WIFI_SERVICE);
|
---|
| 28 | + boolean wifiEnabled = wifiManager.isWifiEnabled();
|
---|
| 29 | + if (!wifiEnabled) {
|
---|
| 30 | + wifiManager.setWifiEnabled(true);
|
---|
| 31 | + }
|
---|
| 32 | +
|
---|
| 33 | + SystemClock.sleep(500);
|
---|
| 34 | + dmiInfo = DmiInfo.getInstance(getdmi());
|
---|
| 35 | +
|
---|
| 36 | + if (!wifiEnabled) {
|
---|
| 37 | + wifiManager.setWifiEnabled(false);
|
---|
| 38 | + }
|
---|
| 39 | + }
|
---|
| 40 | + return dmiInfo;
|
---|
| 41 | + }
|
---|
| 42 | +}
|
---|
.. | .. |
---|
| 1 | +package com.rockchip.irda;
|
---|
| 2 | +
|
---|
| 3 | +public class IrdaTestUtil {
|
---|
| 4 | + static {
|
---|
| 5 | + System.loadLibrary("IrdaTest");
|
---|
| 6 | + }
|
---|
| 7 | + private static native boolean native_testSirReceive();
|
---|
| 8 | + private static native boolean native_testSirSend();
|
---|
| 9 | + private static native boolean native_testFirReceive();
|
---|
| 10 | + private static native boolean native_testFirSend();
|
---|
| 11 | +
|
---|
| 12 | + public static boolean testSirReceive() {
|
---|
| 13 | + return native_testSirReceive();
|
---|
| 14 | + }
|
---|
| 15 | + public static boolean testSirSend() {
|
---|
| 16 | + return native_testSirSend();
|
---|
| 17 | + }
|
---|
| 18 | + public static boolean testFirReceive() {
|
---|
| 19 | + return native_testFirReceive();
|
---|
| 20 | + }
|
---|
| 21 | + public static boolean testFirSend() {
|
---|
| 22 | + return native_testFirSend();
|
---|
| 23 | + }
|
---|
| 24 | +}
|
---|
.. | .. |
---|
| 1 | +
|
---|
| 2 | +package jp.co.ntt.east.hardware;
|
---|
| 3 | +
|
---|
| 4 | +import java.io.IOException;
|
---|
| 5 | +import java.util.Timer;
|
---|
| 6 | +import java.util.TimerTask;
|
---|
| 7 | +
|
---|
| 8 | +import android.view.KeyEvent;
|
---|
| 9 | +
|
---|
| 10 | +public class IrRemoteController {
|
---|
| 11 | +
|
---|
| 12 | + static {
|
---|
| 13 | + System.loadLibrary("rk29_cir");
|
---|
| 14 | + }
|
---|
| 15 | +
|
---|
| 16 | + private static final int SEND_WAIT_TIME = 250;
|
---|
| 17 | + private static IrRemoteController instance;
|
---|
| 18 | + private volatile boolean isRunning;
|
---|
| 19 | + private IrRemoteController.Data[] data;
|
---|
| 20 | + private int timeout;
|
---|
| 21 | + private int count;
|
---|
| 22 | + private Timer timer;
|
---|
| 23 | +
|
---|
| 24 | + public static synchronized IrRemoteController getInstance() {
|
---|
| 25 | + if (instance == null) {
|
---|
| 26 | + instance = new IrRemoteController();
|
---|
| 27 | + }
|
---|
| 28 | + return instance;
|
---|
| 29 | + }
|
---|
| 30 | +
|
---|
| 31 | + public void send(IrRemoteController.Data[] data, int timeout) throws IOException {
|
---|
| 32 | + send(data, timeout, -1);
|
---|
| 33 | + }
|
---|
| 34 | +
|
---|
| 35 | + public void send(IrRemoteController.Data[] data, int timeout, int count) throws IOException {
|
---|
| 36 | + if (isRunning) {
|
---|
| 37 | + throw new IllegalStateException("IrRemote is running.");
|
---|
| 38 | + }
|
---|
| 39 | + this.data = data;
|
---|
| 40 | + this.timeout = timeout;
|
---|
| 41 | + this.count = count;
|
---|
| 42 | +
|
---|
| 43 | + isRunning = true;
|
---|
| 44 | + new SendThread().start();
|
---|
| 45 | + timer.schedule(new TimerThread(), (long)timeout * 1000L);
|
---|
| 46 | + }
|
---|
| 47 | +
|
---|
| 48 | + public void stop() throws IOException {
|
---|
| 49 | + isRunning = false;
|
---|
| 50 | + native_hal_stop();
|
---|
| 51 | + timer.cancel();
|
---|
| 52 | + }
|
---|
| 53 | +
|
---|
| 54 | + private IrRemoteController() {
|
---|
| 55 | + timer = new Timer();
|
---|
| 56 | + }
|
---|
| 57 | +
|
---|
| 58 | + private static native int native_hal_init();
|
---|
| 59 | + private static native int native_hal_deinit();
|
---|
| 60 | + private static native int native_hal_send();
|
---|
| 61 | + private static native int native_hal_stop();
|
---|
| 62 | + private static native int native_hal_set_formate(int high, int low, byte[] data,
|
---|
| 63 | + int length, int duration, int startHigh, int startLow, int stopHigh,
|
---|
| 64 | + int data0Pattern, int data0High, int data0Low, int data1Pattern,
|
---|
| 65 | + int data1High, int data1Low, int count);
|
---|
| 66 | +
|
---|
| 67 | + public static class Data {
|
---|
| 68 | + public static final int HIGH_LOW = 1;
|
---|
| 69 | + public static final int INFINITE = 0;
|
---|
| 70 | + public static final int LOW_HIGH = 2;
|
---|
| 71 | +
|
---|
| 72 | + int carry_high;
|
---|
| 73 | + int carry_low;
|
---|
| 74 | + int data0Pattern;
|
---|
| 75 | + int data0High;
|
---|
| 76 | + int data0Low;
|
---|
| 77 | + int data1Pattern;
|
---|
| 78 | + int data1High;
|
---|
| 79 | + int data1Low;
|
---|
| 80 | + int startHigh;
|
---|
| 81 | + int startLow;
|
---|
| 82 | + int stopHigh;
|
---|
| 83 | + byte[] data;
|
---|
| 84 | + int length;
|
---|
| 85 | + int count;
|
---|
| 86 | + int duration;
|
---|
| 87 | +
|
---|
| 88 | + public void setCarrier(int high, int low) {
|
---|
| 89 | + this.carry_high = (int)(high / 10.0);
|
---|
| 90 | + this.carry_low = (int)(low / 10.0);
|
---|
| 91 | + }
|
---|
| 92 | +
|
---|
| 93 | + public void setPulse(int data0Pattern, int data0High, int data0Low,
|
---|
| 94 | + int data1Pattern, int data1High, int data1Low) {
|
---|
| 95 | + this.data0Pattern = (data0Pattern == HIGH_LOW) ? 0 : 1;
|
---|
| 96 | + this.data0High = data0High;
|
---|
| 97 | + this.data0Low = data0Low;
|
---|
| 98 | + this.data1Pattern = (data1Pattern == HIGH_LOW) ? 0 : 1;
|
---|
| 99 | + this.data1High = data1High;
|
---|
| 100 | + this.data1Low = data1Low;
|
---|
| 101 | + }
|
---|
| 102 | +
|
---|
| 103 | + public void setParameter(int startHigh, int startLow, int stopHigh) {
|
---|
| 104 | + this.startHigh = startHigh;
|
---|
| 105 | + this.startLow = startLow;
|
---|
| 106 | + this.stopHigh = stopHigh;
|
---|
| 107 | + }
|
---|
| 108 | +
|
---|
| 109 | + public void setData(byte[] data, int length) {
|
---|
| 110 | + this.data = data;
|
---|
| 111 | + this.length = length;
|
---|
| 112 | + }
|
---|
| 113 | +
|
---|
| 114 | + public void setRepeatCount(int count) {
|
---|
| 115 | + this.count = (count == INFINITE) ? -1 : count;
|
---|
| 116 | + }
|
---|
| 117 | +
|
---|
| 118 | + public void setDuration(int duration) {
|
---|
| 119 | + this.duration = duration;
|
---|
| 120 | + }
|
---|
| 121 | + }
|
---|
| 122 | +
|
---|
| 123 | + private class SendThread extends Thread {
|
---|
| 124 | +
|
---|
| 125 | + public void run() {
|
---|
| 126 | + native_hal_init();
|
---|
| 127 | + for (int i = 0; i < data.length && isRunning; i++) {
|
---|
| 128 | + Data d = data[i];
|
---|
| 129 | + native_hal_set_formate(d.carry_high, d.carry_low, d.data, d.length, d.duration,
|
---|
| 130 | + d.startHigh, d.startLow, d.stopHigh, d.data0Pattern, d.data0High,
|
---|
| 131 | + d.data0Low, d.data1Pattern, d.data1High, d.data1Low, d.count);
|
---|
| 132 | + native_hal_send();
|
---|
| 133 | + }
|
---|
| 134 | +
|
---|
| 135 | + try {
|
---|
| 136 | + Thread.sleep(SEND_WAIT_TIME);
|
---|
| 137 | + }
|
---|
| 138 | + catch (InterruptedException e) {
|
---|
| 139 | + ;
|
---|
| 140 | + }
|
---|
| 141 | + isRunning = false;
|
---|
| 142 | + timer.cancel();
|
---|
| 143 | + native_hal_deinit();
|
---|
| 144 | + }
|
---|
| 145 | + }
|
---|
| 146 | +
|
---|
| 147 | + private class TimerThread extends TimerTask {
|
---|
| 148 | +
|
---|
| 149 | + public void run() {
|
---|
| 150 | + if (isRunning) {
|
---|
| 151 | + isRunning = false;
|
---|
| 152 | + native_hal_stop();
|
---|
| 153 | + }
|
---|
| 154 | + }
|
---|
| 155 | + }
|
---|
| 156 | +}
|
---|
.. | .. |
---|
| 1 | +package jp.co.toshiba.newtion.cir;
|
---|
| 2 | +
|
---|
| 3 | +import java.io.IOException;
|
---|
| 4 | +
|
---|
| 5 | +import jp.co.ntt.east.hardware.IrRemoteController;
|
---|
| 6 | +import jp.co.ntt.east.hardware.IrRemoteController.Data;
|
---|
| 7 | +import android.util.Log;
|
---|
| 8 | +
|
---|
| 9 | +public class RemoteControl {
|
---|
| 10 | + private static final String TAG = "NewtonTest";
|
---|
| 11 | +
|
---|
| 12 | + private static final int SEND_TIMEOUT = 1;
|
---|
| 13 | +
|
---|
| 14 | + private static final int CARRIER_HIGH_TIME = 130;
|
---|
| 15 | +
|
---|
| 16 | + private static final int CARRIER_LOW_TIME = 130;
|
---|
| 17 | +
|
---|
| 18 | + private static final int PULSE_0_HIGH_TIME = 560;
|
---|
| 19 | +
|
---|
| 20 | + private static final int PULSE_0_LOW_TIME = 560;
|
---|
| 21 | +
|
---|
| 22 | + private static final int PULSE_1_HIGH_TIME = 1690;
|
---|
| 23 | +
|
---|
| 24 | + private static final int PULSE_1_LOW_TIME = 560;
|
---|
| 25 | +
|
---|
| 26 | + private static final int START_HIGH_TIME = 9000;
|
---|
| 27 | +
|
---|
| 28 | + private static final int START_LOW_TIME = 4500;
|
---|
| 29 | +
|
---|
| 30 | + private static final int STOP_HIGH_TIME = 560;
|
---|
| 31 | +
|
---|
| 32 | + private static final int REPEAT_HIGH_TIME = 9000;
|
---|
| 33 | +
|
---|
| 34 | + private static final int REPEAT_LOW_TIME = 2250;
|
---|
| 35 | +
|
---|
| 36 | + private static final int DURATION_TIME = 1080;
|
---|
| 37 | +
|
---|
| 38 | + private static final int REPEAT_COUNT = 1;
|
---|
| 39 | +
|
---|
| 40 | + private static final byte CUSTOM_CODE = (byte) 0x40;
|
---|
| 41 | +
|
---|
| 42 | + public static final byte COMMAND_POWER = (byte) 0x12;
|
---|
| 43 | +
|
---|
| 44 | + public static final byte COMMAND_CHANNEL_BASE = (byte) 0x01;
|
---|
| 45 | +
|
---|
| 46 | + public static final byte COMMAND_CHANNEL_UP = (byte) 0x1b;
|
---|
| 47 | +
|
---|
| 48 | + public static final byte COMMAND_CHANNEL_DOWN = (byte) 0x1f;
|
---|
| 49 | +
|
---|
| 50 | + public static final byte COMMAND_VOLUME_UP = (byte) 0x1a;
|
---|
| 51 | +
|
---|
| 52 | + public static final byte COMMAND_VOLUME_DOWN = (byte) 0x1e;
|
---|
| 53 | +
|
---|
| 54 | + public static final byte COMMAND_MUTE = (byte) 0x10;
|
---|
| 55 | +
|
---|
| 56 | + public static final byte COMMAND_INPUT_SWITCH = (byte) 0x0f;
|
---|
| 57 | +
|
---|
| 58 | + public static final int CHANNEL_MIN = 1;
|
---|
| 59 | +
|
---|
| 60 | + public static final int CHANNEL_MAX = 12;
|
---|
| 61 | +
|
---|
| 62 | + public static boolean sendCommand(byte command) {
|
---|
| 63 | + boolean returnValue = false;
|
---|
| 64 | + byte sendData[] = new byte[4];
|
---|
| 65 | +
|
---|
| 66 | + sendData[0] = (byte) (CUSTOM_CODE);
|
---|
| 67 | + sendData[1] = (byte) (~CUSTOM_CODE);
|
---|
| 68 | +
|
---|
| 69 | + sendData[2] = (byte) command;
|
---|
| 70 | + sendData[3] = (byte) (~command);
|
---|
| 71 | +
|
---|
| 72 | + IrRemoteController.Data irData1 = new IrRemoteController.Data();
|
---|
| 73 | + irData1.setCarrier(CARRIER_HIGH_TIME, CARRIER_LOW_TIME);
|
---|
| 74 | + irData1.setPulse(IrRemoteController.Data.HIGH_LOW, PULSE_0_HIGH_TIME,
|
---|
| 75 | + PULSE_0_LOW_TIME, IrRemoteController.Data.HIGH_LOW,
|
---|
| 76 | + PULSE_1_HIGH_TIME, PULSE_1_LOW_TIME);
|
---|
| 77 | + irData1.setParameter(START_HIGH_TIME, START_LOW_TIME, STOP_HIGH_TIME);
|
---|
| 78 | + irData1.setData(sendData, sendData.length * 8);
|
---|
| 79 | + irData1.setDuration(DURATION_TIME);
|
---|
| 80 | + irData1.setRepeatCount(REPEAT_COUNT);
|
---|
| 81 | +
|
---|
| 82 | + IrRemoteController irController = IrRemoteController.getInstance();
|
---|
| 83 | + IrRemoteController.Data irDatas[] = { irData1 };
|
---|
| 84 | +
|
---|
| 85 | + returnValue = true;
|
---|
| 86 | + try {
|
---|
| 87 | + irController.send(irDatas, SEND_TIMEOUT);
|
---|
| 88 | + } catch (IllegalStateException e) {
|
---|
| 89 | + }
|
---|
| 90 | +
|
---|
| 91 | + catch (IOException ex) {
|
---|
| 92 | + returnValue = false;
|
---|
| 93 | + Log.e(TAG, ex.getMessage());
|
---|
| 94 | + }
|
---|
| 95 | +
|
---|
| 96 | + return returnValue;
|
---|
| 97 | + }
|
---|
| 98 | +
|
---|
| 99 | + public static boolean sendChannelCommand(int channel) {
|
---|
| 100 | + boolean returnValue = false;
|
---|
| 101 | +
|
---|
| 102 | + if (CHANNEL_MIN <= channel && channel <= CHANNEL_MAX) {
|
---|
| 103 | + byte commandValue = (byte) (channel - CHANNEL_MIN + COMMAND_CHANNEL_BASE);
|
---|
| 104 | + boolean bResult = sendCommand(commandValue);
|
---|
| 105 | + if (bResult) {
|
---|
| 106 | + returnValue = true;
|
---|
| 107 | + }
|
---|
| 108 | + }
|
---|
| 109 | +
|
---|
| 110 | + return returnValue;
|
---|
| 111 | + }
|
---|
| 112 | +}
|
---|