aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2012-06-04 10:12:03 -0700
committerMichael Wright <michaelwr@google.com>2012-06-05 20:47:45 -0700
commit4516d89950fccbb8f44c957242a822f6af39f702 (patch)
tree1975b63a5ac6578d1e269bf244798e7dcf88bf22 /apps
parent55121851dcb45f8474c2e895eb14cc8974045c86 (diff)
downloadsdk-4516d89950fccbb8f44c957242a822f6af39f702.tar.gz
Added DeviceConfig application
Change-Id: Ibed1430fca56506bcc07dfc07c9494fdbf304e06
Diffstat (limited to 'apps')
-rw-r--r--apps/.gitignore1
-rw-r--r--apps/DeviceConfig/.classpath16
-rw-r--r--apps/DeviceConfig/.project33
-rw-r--r--apps/DeviceConfig/.settings/org.eclipse.jdt.core.prefs5
-rw-r--r--apps/DeviceConfig/AndroidManifest.xml29
-rw-r--r--apps/DeviceConfig/build.xml90
-rw-r--r--apps/DeviceConfig/proguard-project.txt20
-rw-r--r--apps/DeviceConfig/project.properties11
-rw-r--r--apps/DeviceConfig/res/drawable-hdpi/icon.pngbin0 -> 3180 bytes
-rw-r--r--apps/DeviceConfig/res/drawable-ldpi/icon.pngbin0 -> 3180 bytes
-rw-r--r--apps/DeviceConfig/res/drawable-mdpi/icon.pngbin0 -> 3180 bytes
-rw-r--r--apps/DeviceConfig/res/drawable-nodpi/icon.pngbin0 -> 3180 bytes
-rw-r--r--apps/DeviceConfig/res/drawable/icon.pngbin0 -> 3180 bytes
-rw-r--r--apps/DeviceConfig/res/layout/main.xml395
-rw-r--r--apps/DeviceConfig/res/values-12key/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-car/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-desk/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-dpad/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-finger/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-hdpi/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-keysexposed/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-keyshidden/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-keyssoft/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-land/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-large/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-ldpi/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-long/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-mdpi/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-navexposed/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-navhidden/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-night/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-nodpi/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-nokeys/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-nonav/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-normal/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-notlong/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-notnight/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-notouch/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-port/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-qwerty/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-small/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-stylus/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-trackball/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-tvdpi/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-v1/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-v14/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-v2/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-v3/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-v4/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-v5/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-v6/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-v7/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-v8/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-v9/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-wheel/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-xhdpi/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values-xlarge/strings.xml4
-rw-r--r--apps/DeviceConfig/res/values/strings.xml9
-rw-r--r--apps/DeviceConfig/src/com/example/android/deviceconfig/ConfigGenerator.java635
-rw-r--r--apps/DeviceConfig/src/com/example/android/deviceconfig/MyActivity.java133
60 files changed, 1549 insertions, 0 deletions
diff --git a/apps/.gitignore b/apps/.gitignore
index d2107ee99..c3ae4631e 100644
--- a/apps/.gitignore
+++ b/apps/.gitignore
@@ -1,3 +1,4 @@
bin
gen
+local.properties
diff --git a/apps/DeviceConfig/.classpath b/apps/DeviceConfig/.classpath
new file mode 100644
index 000000000..4f8e887d2
--- /dev/null
+++ b/apps/DeviceConfig/.classpath
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="lib" path="/home/michaelwr/android-sdks/platforms/android-15/android.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="file:/home/michaelwr/android-sdks/docs/reference"/>
+ </attributes>
+ <accessrules>
+ <accessrule kind="nonaccessible" pattern="com/android/internal/**"/>
+ </accessrules>
+ </classpathentry>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
diff --git a/apps/DeviceConfig/.project b/apps/DeviceConfig/.project
new file mode 100644
index 000000000..ca720132b
--- /dev/null
+++ b/apps/DeviceConfig/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>DeviceConfig</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/apps/DeviceConfig/.settings/org.eclipse.jdt.core.prefs b/apps/DeviceConfig/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..d9295f626
--- /dev/null
+++ b/apps/DeviceConfig/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+#Tue May 22 15:51:27 PDT 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/apps/DeviceConfig/AndroidManifest.xml b/apps/DeviceConfig/AndroidManifest.xml
new file mode 100644
index 000000000..b81f58ef3
--- /dev/null
+++ b/apps/DeviceConfig/AndroidManifest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.deviceconfig"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-permission android:name="android.permission.CAMERA" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-feature android:name="android.hardware.camera" />
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="15" />
+
+ <application
+ android:icon="@drawable/icon"
+ android:label="@string/app_name" >
+ <activity
+ android:name=".MyActivity"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/apps/DeviceConfig/build.xml b/apps/DeviceConfig/build.xml
new file mode 100644
index 000000000..a48344c2c
--- /dev/null
+++ b/apps/DeviceConfig/build.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="MyActivity" default="help">
+
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The ant.properties file can be created by you. It is only edited by the
+ 'android' tool to add properties to it.
+ This is the place to change some Ant specific build properties.
+ Here are some properties you may want to change/update:
+
+ source.dir
+ The name of the source directory. Default is 'src'.
+ out.dir
+ The name of the output directory. Default is 'bin'.
+
+ For other overridable properties, look at the beginning of the rules
+ files in the SDK, at tools/ant/build.xml
+
+ Properties related to the SDK location or the project target should
+ be updated using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems.
+
+ -->
+ <property file="ant.properties" />
+
+ <!-- The project.properties file is created and updated by the 'android'
+ tool, as well as ADT.
+
+ This contains project specific properties such as project target, and library
+ dependencies. Lower level build properties are stored in ant.properties
+ (or in .classpath for Eclipse projects).
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems. -->
+ <loadproperties srcFile="project.properties" />
+
+ <!-- if sdk.dir was not set from one of the property file, then
+ get it from the ANDROID_HOME env var. -->
+ <property environment="env" />
+ <condition property="sdk.dir" value="${env.ANDROID_HOME}">
+ <isset property="env.ANDROID_HOME" />
+ </condition>
+
+ <!-- quick check on sdk.dir -->
+ <fail
+ message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
+ unless="sdk.dir"
+ />
+
+ <!--
+ Import per project custom build rules if present at the root of the project.
+ This is the place to put custom intermediary targets such as:
+ -pre-build
+ -pre-compile
+ -post-compile (This is typically used for code obfuscation.
+ Compiled code location: ${out.classes.absolute.dir}
+ If this is not done in place, override ${out.dex.input.absolute.dir})
+ -post-package
+ -post-build
+ -pre-clean
+ -->
+ <import file="custom_rules.xml" optional="true" />
+
+ <!-- Import the actual build file.
+
+ To customize existing targets, there are two options:
+ - Customize only one target:
+ - copy/paste the target into this file, *before* the
+ <import> task.
+ - customize it to your needs.
+ - Customize the whole content of build.xml
+ - copy/paste the content of the rules files (minus the top node)
+ into this file, replacing the <import> task.
+ - customize to your needs.
+
+ ***********************
+ ****** IMPORTANT ******
+ ***********************
+ In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+ in order to avoid having your file be overridden by tools such as "android update project"
+ -->
+ <!-- version-tag: 1 -->
+ <import file="${sdk.dir}/tools/ant/build.xml" />
+
+</project>
diff --git a/apps/DeviceConfig/proguard-project.txt b/apps/DeviceConfig/proguard-project.txt
new file mode 100644
index 000000000..f2fe1559a
--- /dev/null
+++ b/apps/DeviceConfig/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/apps/DeviceConfig/project.properties b/apps/DeviceConfig/project.properties
new file mode 100644
index 000000000..8da376af8
--- /dev/null
+++ b/apps/DeviceConfig/project.properties
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-15
diff --git a/apps/DeviceConfig/res/drawable-hdpi/icon.png b/apps/DeviceConfig/res/drawable-hdpi/icon.png
new file mode 100644
index 000000000..75024841d
--- /dev/null
+++ b/apps/DeviceConfig/res/drawable-hdpi/icon.png
Binary files differ
diff --git a/apps/DeviceConfig/res/drawable-ldpi/icon.png b/apps/DeviceConfig/res/drawable-ldpi/icon.png
new file mode 100644
index 000000000..75024841d
--- /dev/null
+++ b/apps/DeviceConfig/res/drawable-ldpi/icon.png
Binary files differ
diff --git a/apps/DeviceConfig/res/drawable-mdpi/icon.png b/apps/DeviceConfig/res/drawable-mdpi/icon.png
new file mode 100644
index 000000000..75024841d
--- /dev/null
+++ b/apps/DeviceConfig/res/drawable-mdpi/icon.png
Binary files differ
diff --git a/apps/DeviceConfig/res/drawable-nodpi/icon.png b/apps/DeviceConfig/res/drawable-nodpi/icon.png
new file mode 100644
index 000000000..75024841d
--- /dev/null
+++ b/apps/DeviceConfig/res/drawable-nodpi/icon.png
Binary files differ
diff --git a/apps/DeviceConfig/res/drawable/icon.png b/apps/DeviceConfig/res/drawable/icon.png
new file mode 100644
index 000000000..75024841d
--- /dev/null
+++ b/apps/DeviceConfig/res/drawable/icon.png
Binary files differ
diff --git a/apps/DeviceConfig/res/layout/main.xml b/apps/DeviceConfig/res/layout/main.xml
new file mode 100644
index 000000000..a30b126aa
--- /dev/null
+++ b/apps/DeviceConfig/res/layout/main.xml
@@ -0,0 +1,395 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent" >
+
+ <LinearLayout
+ android:id="@+id/buttonHolder"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true" >
+
+ <Button
+ android:id="@+id/generateConfigButton"
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/generate_config" />
+ </LinearLayout>
+
+ <ScrollView
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_above="@id/buttonHolder" >
+
+ <TableLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:padding="5dip" >
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:background="#333" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="#333"
+ android:text="Type" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="#333"
+ android:text="Resource" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="API" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Screen Size" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/screen_size" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Screen Ratio" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/screen_long" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Screen Orientation" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/orientation" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Dock" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/dock" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Night" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/night" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Density" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/density" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Touch Type" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/touch" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Keyboard State" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/keyboard_state" >
+ </TextView>
+
+ <TextView
+ android:id="@+id/keyboard_state_api"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="API" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Text Input" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/text_input" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Nav State" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/nav_state" >
+ </TextView>
+
+ <TextView
+ android:id="@+id/nav_state_api"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="API" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Navigation" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/navigation" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Screen Size" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+ </TextView>
+
+ <TextView
+ android:id="@+id/size_api"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="API" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Version" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/version" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="xdpi" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="N/A" >
+ </TextView>
+
+ <TextView
+ android:id="@+id/xdpi"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="xdpi" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="ydpi" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="N/A" >
+ </TextView>
+
+ <TextView
+ android:id="@+id/ydpi"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="ydpi" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="scaledDensity" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="N/A" >
+ </TextView>
+
+ <TextView
+ android:id="@+id/scaled_density"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="scaledDensity" >
+ </TextView>
+ </TableRow>
+
+ <TableRow
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="fontScale" >
+ </TextView>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="N/A" >
+ </TextView>
+
+ <TextView
+ android:id="@+id/font_scale"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="fontScale" >
+ </TextView>
+ </TableRow>
+ </TableLayout>
+ </ScrollView>
+
+</RelativeLayout> \ No newline at end of file
diff --git a/apps/DeviceConfig/res/values-12key/strings.xml b/apps/DeviceConfig/res/values-12key/strings.xml
new file mode 100644
index 000000000..8d1840b46
--- /dev/null
+++ b/apps/DeviceConfig/res/values-12key/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="text_input">12 KEY</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-car/strings.xml b/apps/DeviceConfig/res/values-car/strings.xml
new file mode 100644
index 000000000..0cedbabc4
--- /dev/null
+++ b/apps/DeviceConfig/res/values-car/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="dock">CAR</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-desk/strings.xml b/apps/DeviceConfig/res/values-desk/strings.xml
new file mode 100644
index 000000000..4ea832b5a
--- /dev/null
+++ b/apps/DeviceConfig/res/values-desk/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="dock">DESK</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-dpad/strings.xml b/apps/DeviceConfig/res/values-dpad/strings.xml
new file mode 100644
index 000000000..1a94d25c2
--- /dev/null
+++ b/apps/DeviceConfig/res/values-dpad/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="navigation">D-PAD</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-finger/strings.xml b/apps/DeviceConfig/res/values-finger/strings.xml
new file mode 100644
index 000000000..bc169e745
--- /dev/null
+++ b/apps/DeviceConfig/res/values-finger/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="touch">FINGER</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-hdpi/strings.xml b/apps/DeviceConfig/res/values-hdpi/strings.xml
new file mode 100644
index 000000000..4f85a70f8
--- /dev/null
+++ b/apps/DeviceConfig/res/values-hdpi/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="density">HIGH</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-keysexposed/strings.xml b/apps/DeviceConfig/res/values-keysexposed/strings.xml
new file mode 100644
index 000000000..006e05424
--- /dev/null
+++ b/apps/DeviceConfig/res/values-keysexposed/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="keyboard_state">EXPOSED</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-keyshidden/strings.xml b/apps/DeviceConfig/res/values-keyshidden/strings.xml
new file mode 100644
index 000000000..2463a0211
--- /dev/null
+++ b/apps/DeviceConfig/res/values-keyshidden/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="keyboard_state">HIDDEN</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-keyssoft/strings.xml b/apps/DeviceConfig/res/values-keyssoft/strings.xml
new file mode 100644
index 000000000..262f0e233
--- /dev/null
+++ b/apps/DeviceConfig/res/values-keyssoft/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="keyboard_state">SOFT</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-land/strings.xml b/apps/DeviceConfig/res/values-land/strings.xml
new file mode 100644
index 000000000..0e8e76bef
--- /dev/null
+++ b/apps/DeviceConfig/res/values-land/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="orientation">LANDSCAPE</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-large/strings.xml b/apps/DeviceConfig/res/values-large/strings.xml
new file mode 100644
index 000000000..579cc7d4a
--- /dev/null
+++ b/apps/DeviceConfig/res/values-large/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="screen_size">LARGE</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-ldpi/strings.xml b/apps/DeviceConfig/res/values-ldpi/strings.xml
new file mode 100644
index 000000000..8a19b696e
--- /dev/null
+++ b/apps/DeviceConfig/res/values-ldpi/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="density">LOW</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-long/strings.xml b/apps/DeviceConfig/res/values-long/strings.xml
new file mode 100644
index 000000000..a2ab99138
--- /dev/null
+++ b/apps/DeviceConfig/res/values-long/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="screen_long">LONG</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-mdpi/strings.xml b/apps/DeviceConfig/res/values-mdpi/strings.xml
new file mode 100644
index 000000000..1509fb2d1
--- /dev/null
+++ b/apps/DeviceConfig/res/values-mdpi/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="density">MEDIUM</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-navexposed/strings.xml b/apps/DeviceConfig/res/values-navexposed/strings.xml
new file mode 100644
index 000000000..ec714f192
--- /dev/null
+++ b/apps/DeviceConfig/res/values-navexposed/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="nav_state">EXPOSED</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-navhidden/strings.xml b/apps/DeviceConfig/res/values-navhidden/strings.xml
new file mode 100644
index 000000000..f60b41f0d
--- /dev/null
+++ b/apps/DeviceConfig/res/values-navhidden/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="nav_state">HIDDEN</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-night/strings.xml b/apps/DeviceConfig/res/values-night/strings.xml
new file mode 100644
index 000000000..dc601f08f
--- /dev/null
+++ b/apps/DeviceConfig/res/values-night/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="night">NIGHT</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-nodpi/strings.xml b/apps/DeviceConfig/res/values-nodpi/strings.xml
new file mode 100644
index 000000000..00ef99a9d
--- /dev/null
+++ b/apps/DeviceConfig/res/values-nodpi/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="density">NODPI</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-nokeys/strings.xml b/apps/DeviceConfig/res/values-nokeys/strings.xml
new file mode 100644
index 000000000..fdfaab87e
--- /dev/null
+++ b/apps/DeviceConfig/res/values-nokeys/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="text_input">NO KEYS</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-nonav/strings.xml b/apps/DeviceConfig/res/values-nonav/strings.xml
new file mode 100644
index 000000000..1e4198c9b
--- /dev/null
+++ b/apps/DeviceConfig/res/values-nonav/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="navigation">NO NAV</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-normal/strings.xml b/apps/DeviceConfig/res/values-normal/strings.xml
new file mode 100644
index 000000000..2be7ed056
--- /dev/null
+++ b/apps/DeviceConfig/res/values-normal/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="screen_size">NORMAL</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-notlong/strings.xml b/apps/DeviceConfig/res/values-notlong/strings.xml
new file mode 100644
index 000000000..13730e33b
--- /dev/null
+++ b/apps/DeviceConfig/res/values-notlong/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="screen_long">NOTLONG</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-notnight/strings.xml b/apps/DeviceConfig/res/values-notnight/strings.xml
new file mode 100644
index 000000000..596d27e07
--- /dev/null
+++ b/apps/DeviceConfig/res/values-notnight/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="night">NOTNIGHT</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-notouch/strings.xml b/apps/DeviceConfig/res/values-notouch/strings.xml
new file mode 100644
index 000000000..cf643b995
--- /dev/null
+++ b/apps/DeviceConfig/res/values-notouch/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="touch">NOTOUCH</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-port/strings.xml b/apps/DeviceConfig/res/values-port/strings.xml
new file mode 100644
index 000000000..4dc45158c
--- /dev/null
+++ b/apps/DeviceConfig/res/values-port/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="orientation">PORTRAIT</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-qwerty/strings.xml b/apps/DeviceConfig/res/values-qwerty/strings.xml
new file mode 100644
index 000000000..7c58d63bd
--- /dev/null
+++ b/apps/DeviceConfig/res/values-qwerty/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="text_input">QWERTY</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-small/strings.xml b/apps/DeviceConfig/res/values-small/strings.xml
new file mode 100644
index 000000000..861eda799
--- /dev/null
+++ b/apps/DeviceConfig/res/values-small/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="screen_size">SMALL</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-stylus/strings.xml b/apps/DeviceConfig/res/values-stylus/strings.xml
new file mode 100644
index 000000000..a59efa794
--- /dev/null
+++ b/apps/DeviceConfig/res/values-stylus/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="touch">STYLUS</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-trackball/strings.xml b/apps/DeviceConfig/res/values-trackball/strings.xml
new file mode 100644
index 000000000..bb9b35f9e
--- /dev/null
+++ b/apps/DeviceConfig/res/values-trackball/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="navigation">TRACKBALL</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-tvdpi/strings.xml b/apps/DeviceConfig/res/values-tvdpi/strings.xml
new file mode 100644
index 000000000..1bcc8fa0d
--- /dev/null
+++ b/apps/DeviceConfig/res/values-tvdpi/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="density">TV</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-v1/strings.xml b/apps/DeviceConfig/res/values-v1/strings.xml
new file mode 100644
index 000000000..78f474e23
--- /dev/null
+++ b/apps/DeviceConfig/res/values-v1/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="version">1</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-v14/strings.xml b/apps/DeviceConfig/res/values-v14/strings.xml
new file mode 100644
index 000000000..d0c64ce63
--- /dev/null
+++ b/apps/DeviceConfig/res/values-v14/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="version">14</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-v2/strings.xml b/apps/DeviceConfig/res/values-v2/strings.xml
new file mode 100644
index 000000000..251dbd3ee
--- /dev/null
+++ b/apps/DeviceConfig/res/values-v2/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="version">2</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-v3/strings.xml b/apps/DeviceConfig/res/values-v3/strings.xml
new file mode 100644
index 000000000..7b9d0be96
--- /dev/null
+++ b/apps/DeviceConfig/res/values-v3/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="version">3</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-v4/strings.xml b/apps/DeviceConfig/res/values-v4/strings.xml
new file mode 100644
index 000000000..217ebe59a
--- /dev/null
+++ b/apps/DeviceConfig/res/values-v4/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="version">4</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-v5/strings.xml b/apps/DeviceConfig/res/values-v5/strings.xml
new file mode 100644
index 000000000..56f1a6f5a
--- /dev/null
+++ b/apps/DeviceConfig/res/values-v5/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="version">5</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-v6/strings.xml b/apps/DeviceConfig/res/values-v6/strings.xml
new file mode 100644
index 000000000..7846da8e4
--- /dev/null
+++ b/apps/DeviceConfig/res/values-v6/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="version">6</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-v7/strings.xml b/apps/DeviceConfig/res/values-v7/strings.xml
new file mode 100644
index 000000000..55649e271
--- /dev/null
+++ b/apps/DeviceConfig/res/values-v7/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="version">7</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-v8/strings.xml b/apps/DeviceConfig/res/values-v8/strings.xml
new file mode 100644
index 000000000..e546c5fa1
--- /dev/null
+++ b/apps/DeviceConfig/res/values-v8/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="version">8</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-v9/strings.xml b/apps/DeviceConfig/res/values-v9/strings.xml
new file mode 100644
index 000000000..1a0bbae01
--- /dev/null
+++ b/apps/DeviceConfig/res/values-v9/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="version">9</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-wheel/strings.xml b/apps/DeviceConfig/res/values-wheel/strings.xml
new file mode 100644
index 000000000..ef5fa852d
--- /dev/null
+++ b/apps/DeviceConfig/res/values-wheel/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="navigation">WHEEL</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-xhdpi/strings.xml b/apps/DeviceConfig/res/values-xhdpi/strings.xml
new file mode 100644
index 000000000..214329d4f
--- /dev/null
+++ b/apps/DeviceConfig/res/values-xhdpi/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="density">XHIGH</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values-xlarge/strings.xml b/apps/DeviceConfig/res/values-xlarge/strings.xml
new file mode 100644
index 000000000..f59006d95
--- /dev/null
+++ b/apps/DeviceConfig/res/values-xlarge/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+<string name="screen_size">XLARGE</string>
+</resources>
diff --git a/apps/DeviceConfig/res/values/strings.xml b/apps/DeviceConfig/res/values/strings.xml
new file mode 100644
index 000000000..d13facac4
--- /dev/null
+++ b/apps/DeviceConfig/res/values/strings.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">DeviceConfig</string>
+ <string name="dock">DEFAULT</string>
+ <string name="nav_state">DEFAULT</string>
+ <string name="generate_config">Generate Config</string>
+ <string name="type">Type</string>
+ <string name="resource">Resource</string>
+</resources>
diff --git a/apps/DeviceConfig/src/com/example/android/deviceconfig/ConfigGenerator.java b/apps/DeviceConfig/src/com/example/android/deviceconfig/ConfigGenerator.java
new file mode 100644
index 000000000..b2b08c6cc
--- /dev/null
+++ b/apps/DeviceConfig/src/com/example/android/deviceconfig/ConfigGenerator.java
@@ -0,0 +1,635 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.deviceconfig;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+
+import android.annotation.SuppressLint;
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.hardware.Camera;
+import android.hardware.Camera.CameraInfo;
+import android.os.Environment;
+import android.os.StatFs;
+import android.util.DisplayMetrics;
+import android.util.Log;
+import android.widget.Toast;
+
+public class ConfigGenerator {
+ private Context mCtx;
+
+ public static final String NS_DEVICES_XSD = "http://schemas.android.com/sdk/devices/1";
+
+ /**
+ * The "devices" element is the root element of this schema.
+ *
+ * It must contain one or more "device" elements that each define the
+ * hardware, software, and states for a given device.
+ */
+ public static final String NODE_DEVICES = "devices";
+
+ /**
+ * A "device" element contains a "hardware" element, a "software" element
+ * for each API version it supports, and a "state" element for each possible
+ * state the device could be in.
+ */
+ public static final String NODE_DEVICE = "device";
+
+ /**
+ * The "hardware" element contains all of the hardware information for a
+ * given device.
+ */
+ public static final String NODE_HARDWARE = "hardware";
+
+ /**
+ * The "software" element contains all of the software information for an
+ * API version of the given device.
+ */
+ public static final String NODE_SOFTWARE = "software";
+
+ /**
+ * The "state" element contains all of the parameters for a given state of
+ * the device. It's also capable of redefining hardware configurations if
+ * they change based on state.
+ */
+
+ public static final String NODE_STATE = "state";
+
+ public static final String NODE_KEYBOARD = "keyboard";
+ public static final String NODE_TOUCH = "touch";
+ public static final String NODE_GL_EXTENSIONS = "gl-extensions";
+ public static final String NODE_GL_VERSION = "gl-version";
+ public static final String NODE_NETWORKING = "networking";
+ public static final String NODE_REMOVABLE_STORAGE = "removable-storage";
+ public static final String NODE_FLASH = "flash";
+ public static final String NODE_LIVE_WALLPAPER_SUPPORT = "live-wallpaper-support";
+ public static final String NODE_BUTTONS = "buttons";
+ public static final String NODE_CAMERA = "camera";
+ public static final String NODE_LOCATION = "location";
+ public static final String NODE_GPU = "gpu";
+ public static final String NODE_DOCK = "dock";
+ public static final String NODE_YDPI = "ydpi";
+ public static final String NODE_PLUGGED_IN = "plugged-in";
+ public static final String NODE_Y_DIMENSION = "y-dimension";
+ public static final String NODE_SCREEN_RATIO = "screen-ratio";
+ public static final String NODE_NAV_STATE = "nav-state";
+ public static final String NODE_MIC = "mic";
+ public static final String NODE_RAM = "ram";
+ public static final String NODE_XDPI = "xdpi";
+ public static final String NODE_DIMENSIONS = "dimensions";
+ public static final String NODE_ABI = "abi";
+ public static final String NODE_MECHANISM = "mechanism";
+ public static final String NODE_MULTITOUCH = "multitouch";
+ public static final String NODE_NAV = "nav";
+ public static final String NODE_PIXEL_DENSITY = "pixel-density";
+ public static final String NODE_SCREEN_ORIENTATION = "screen-orientation";
+ public static final String NODE_AUTOFOCUS = "autofocus";
+ public static final String NODE_SCREEN_SIZE = "screen-size";
+ public static final String NODE_DESCRIPTION = "description";
+ public static final String NODE_BLUETOOTH_PROFILES = "bluetooth-profiles";
+ public static final String NODE_SCREEN = "screen";
+ public static final String NODE_SENSORS = "sensors";
+ public static final String NODE_DIAGONAL_LENGTH = "diagonal-length";
+ public static final String NODE_SCREEN_TYPE = "screen-type";
+ public static final String NODE_KEYBOARD_STATE = "keyboard-state";
+ public static final String NODE_X_DIMENSION = "x-dimension";
+ public static final String NODE_CPU = "cpu";
+ public static final String NODE_INTERNAL_STORAGE = "internal-storage";
+ public static final String NODE_NAME = "name";
+ public static final String NODE_MANUFACTURER = "manufacturer";
+ public static final String NODE_API_LEVEL = "api-level";
+ public static final String ATTR_DEFAULT = "default";
+ public static final String ATTR_UNIT = "unit";
+ public static final String UNIT_BYTES = "B";
+ public static final String UNIT_KIBIBYTES = "KiB";
+ public static final String UNIT_MEBIBYTES = "MiB";
+ public static final String UNIT_GIBIBYTES = "GiB";
+ public static final String UNIT_TEBIBYTES = "TiB";
+ public static final String LOCAL_NS = "d";
+ public static final String PREFIX = LOCAL_NS + ":";
+
+ private static final String TAG = "ConfigGenerator";
+
+ public ConfigGenerator(Context ctx) {
+ mCtx = ctx;
+ }
+
+ @SuppressLint("WorldReadableFiles")
+ public String generateConfig() {
+ Resources resources = mCtx.getResources();
+ PackageManager packageMgr = mCtx.getPackageManager();
+ DisplayMetrics metrics = resources.getDisplayMetrics();
+ Configuration config = resources.getConfiguration();
+
+ try {
+ Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+
+ Element devices = doc.createElement(PREFIX + NODE_DEVICES);
+ devices.setAttribute(XMLConstants.XMLNS_ATTRIBUTE + ":xsi",
+ XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
+ devices.setAttribute(XMLConstants.XMLNS_ATTRIBUTE + ":" + LOCAL_NS, NS_DEVICES_XSD);
+ doc.appendChild(devices);
+
+ Element device = doc.createElement(PREFIX + NODE_DEVICE);
+ devices.appendChild(device);
+
+ Element name = doc.createElement(PREFIX + NODE_NAME);
+ device.appendChild(name);
+ name.appendChild(doc.createTextNode(android.os.Build.MODEL));
+ Element manufacturer = doc.createElement(PREFIX + NODE_MANUFACTURER);
+ device.appendChild(manufacturer);
+ manufacturer.appendChild(doc.createTextNode(android.os.Build.MANUFACTURER));
+
+ Element hardware = doc.createElement(PREFIX + NODE_HARDWARE);
+ device.appendChild(hardware);
+
+ Element screen = doc.createElement(PREFIX + NODE_SCREEN);
+ hardware.appendChild(screen);
+
+ Element screenSize = doc.createElement(PREFIX + NODE_SCREEN_SIZE);
+ screen.appendChild(screenSize);
+ Text screenSizeText;
+ switch (config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) {
+ case Configuration.SCREENLAYOUT_SIZE_SMALL:
+ screenSizeText = doc.createTextNode("small");
+ break;
+ case Configuration.SCREENLAYOUT_SIZE_NORMAL:
+ screenSizeText = doc.createTextNode("normal");
+ break;
+ case Configuration.SCREENLAYOUT_SIZE_LARGE:
+ screenSizeText = doc.createTextNode("large");
+ break;
+ case Configuration.SCREENLAYOUT_SIZE_XLARGE:
+ screenSizeText = doc.createTextNode("xlarge");
+ break;
+ default:
+ screenSizeText = doc.createTextNode(" ");
+ break;
+ }
+ screenSize.appendChild(screenSizeText);
+
+ Element diagonalLength = doc.createElement(PREFIX + NODE_DIAGONAL_LENGTH);
+ screen.appendChild(diagonalLength);
+ double xin = metrics.widthPixels / metrics.xdpi;
+ double yin = metrics.heightPixels / metrics.ydpi;
+ double diag = Math.sqrt(Math.pow(xin, 2) + Math.pow(yin, 2));
+ diagonalLength.appendChild(doc.createTextNode(String.format("%1$.2f", diag)));
+
+ Element pixelDensity = doc.createElement(PREFIX + NODE_PIXEL_DENSITY);
+ screen.appendChild(pixelDensity);
+ Text pixelDensityText;
+ switch (metrics.densityDpi) {
+ case DisplayMetrics.DENSITY_LOW:
+ pixelDensityText = doc.createTextNode("ldpi");
+ break;
+ case DisplayMetrics.DENSITY_MEDIUM:
+ pixelDensityText = doc.createTextNode("mdpi");
+ break;
+ case DisplayMetrics.DENSITY_TV:
+ pixelDensityText = doc.createTextNode("tvdpi");
+ break;
+ case DisplayMetrics.DENSITY_HIGH:
+ pixelDensityText = doc.createTextNode("hdpi");
+ break;
+ case DisplayMetrics.DENSITY_XHIGH:
+ pixelDensityText = doc.createTextNode("xhdpi");
+ break;
+ default:
+ pixelDensityText = doc.createTextNode(" ");
+ }
+ pixelDensity.appendChild(pixelDensityText);
+
+ Element screenRatio = doc.createElement(PREFIX + NODE_SCREEN_RATIO);
+ screen.appendChild(screenRatio);
+ Text screenRatioText;
+ switch (config.screenLayout & Configuration.SCREENLAYOUT_LONG_MASK) {
+ case Configuration.SCREENLAYOUT_LONG_YES:
+ screenRatioText = doc.createTextNode("long");
+ break;
+ case Configuration.SCREENLAYOUT_LONG_NO:
+ screenRatioText = doc.createTextNode("notlong");
+ break;
+ default:
+ screenRatioText = doc.createTextNode(" ");
+ break;
+ }
+ screenRatio.appendChild(screenRatioText);
+
+ Element dimensions = doc.createElement(PREFIX + NODE_DIMENSIONS);
+ screen.appendChild(dimensions);
+
+ Element xDimension = doc.createElement(PREFIX + NODE_X_DIMENSION);
+ dimensions.appendChild(xDimension);
+ xDimension.appendChild(doc.createTextNode(Integer.toString(metrics.widthPixels)));
+
+ Element yDimension = doc.createElement(PREFIX + NODE_Y_DIMENSION);
+ dimensions.appendChild(yDimension);
+ yDimension.appendChild(doc.createTextNode(Integer.toString(metrics.heightPixels)));
+
+ Element xdpi = doc.createElement(PREFIX + NODE_XDPI);
+ screen.appendChild(xdpi);
+ xdpi.appendChild(doc.createTextNode(Double.toString(metrics.xdpi)));
+
+ Element ydpi = doc.createElement(PREFIX + NODE_YDPI);
+ screen.appendChild(ydpi);
+ ydpi.appendChild(doc.createTextNode(Double.toString(metrics.ydpi)));
+
+ Element touch = doc.createElement(PREFIX + NODE_TOUCH);
+ screen.appendChild(touch);
+
+ Element multitouch = doc.createElement(PREFIX + NODE_MULTITOUCH);
+ touch.appendChild(multitouch);
+ Text multitouchText;
+ if (packageMgr
+ .hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND)) {
+ multitouchText = doc.createTextNode("jazz-hands");
+ } else if (packageMgr
+ .hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT)) {
+ multitouchText = doc.createTextNode("distinct");
+ } else if (packageMgr.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)) {
+ multitouchText = doc.createTextNode("basic");
+ } else {
+ multitouchText = doc.createTextNode("none");
+ }
+ multitouch.appendChild(multitouchText);
+
+ Element mechanism = doc.createElement(PREFIX + NODE_MECHANISM);
+ touch.appendChild(mechanism);
+ Text mechanismText;
+ switch (config.touchscreen) {
+ case Configuration.TOUCHSCREEN_STYLUS:
+ mechanismText = doc.createTextNode("stylus");
+ case Configuration.TOUCHSCREEN_FINGER:
+ mechanismText = doc.createTextNode("finger");
+ case Configuration.TOUCHSCREEN_NOTOUCH:
+ mechanismText = doc.createTextNode("notouch");
+ default:
+ mechanismText = doc.createTextNode(" ");
+ }
+ mechanism.appendChild(mechanismText);
+
+ // Create an empty place holder node for screen-type since we can't
+ // actually determine it
+
+ Element screenType = doc.createElement(PREFIX + NODE_SCREEN_TYPE);
+ touch.appendChild(screenType);
+ screenType.appendChild(doc.createTextNode(" "));
+
+ Element networking = doc.createElement(PREFIX + NODE_NETWORKING);
+ hardware.appendChild(networking);
+ Text networkingText = doc.createTextNode("");
+ networking.appendChild(networkingText);
+ if (packageMgr.hasSystemFeature(PackageManager.FEATURE_WIFI)) {
+ networkingText.appendData("\nWifi");
+ }
+ if (packageMgr.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
+ networkingText.appendData("\nBluetooth");
+ }
+ if (packageMgr.hasSystemFeature(PackageManager.FEATURE_NFC)) {
+ networkingText.appendData("\nNFC");
+ }
+
+ Element sensors = doc.createElement(PREFIX + NODE_SENSORS);
+ hardware.appendChild(sensors);
+ Text sensorsText = doc.createTextNode("");
+ sensors.appendChild(sensorsText);
+ if (packageMgr.hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER)) {
+ sensorsText.appendData("\nAccelerometer");
+ }
+ if (packageMgr.hasSystemFeature(PackageManager.FEATURE_SENSOR_BAROMETER)) {
+ sensorsText.appendData("\nBarometer");
+ }
+ if (packageMgr.hasSystemFeature(PackageManager.FEATURE_SENSOR_COMPASS)) {
+ sensorsText.appendData("\nCompass");
+ }
+ if (packageMgr.hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS)) {
+ sensorsText.appendData("\nGPS");
+ }
+ if (packageMgr.hasSystemFeature(PackageManager.FEATURE_SENSOR_GYROSCOPE)) {
+ sensorsText.appendData("\nGyroscope");
+ }
+ if (packageMgr.hasSystemFeature(PackageManager.FEATURE_SENSOR_LIGHT)) {
+ sensorsText.appendData("\nLightSensor");
+ }
+ if (packageMgr.hasSystemFeature(PackageManager.FEATURE_SENSOR_PROXIMITY)) {
+ sensorsText.appendData("\nProximitySensor");
+ }
+
+ Element mic = doc.createElement(PREFIX + NODE_MIC);
+ hardware.appendChild(mic);
+ Text micText;
+ if (packageMgr.hasSystemFeature(PackageManager.FEATURE_MICROPHONE)) {
+ micText = doc.createTextNode("true");
+ } else {
+ micText = doc.createTextNode("false");
+ }
+ mic.appendChild(micText);
+
+ if (android.os.Build.VERSION.SDK_INT >= 9){
+ List<Element> cameras = getCameraElements(doc);
+ for (Element cam : cameras){
+ hardware.appendChild(cam);
+ }
+ } else {
+ Camera c = Camera.open();
+ Element camera = doc.createElement(PREFIX + NODE_CAMERA);
+ hardware.appendChild(camera);
+ Element location = doc.createElement(PREFIX + NODE_LOCATION);
+ camera.appendChild(location);
+ // All camera's before API 9 were on the back
+ location.appendChild(doc.createTextNode("back"));
+ Camera.Parameters cParams = c.getParameters();
+ Element autofocus = doc.createElement(PREFIX + NODE_AUTOFOCUS);
+ camera.appendChild(autofocus);
+ List<String> foci = cParams.getSupportedFocusModes();
+ if (foci == null) {
+ autofocus.appendChild(doc.createTextNode(" "));
+ } else if (foci.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
+ autofocus.appendChild(doc.createTextNode("true"));
+ } else {
+ autofocus.appendChild(doc.createTextNode("false"));
+ }
+
+ Element flash = doc.createElement(PREFIX + NODE_FLASH);
+ camera.appendChild(flash);
+ List<String> flashes = cParams.getSupportedFlashModes();
+ if (flashes == null || !flashes.contains(Camera.Parameters.FLASH_MODE_ON)) {
+ flash.appendChild(doc.createTextNode("false"));
+ } else {
+ flash.appendChild(doc.createTextNode("true"));
+ }
+ c.release();
+ }
+
+
+ Element keyboard = doc.createElement(PREFIX + NODE_KEYBOARD);
+ hardware.appendChild(keyboard);
+ Text keyboardText;
+ switch (config.keyboard) {
+ case Configuration.KEYBOARD_NOKEYS:
+ keyboardText = doc.createTextNode("nokeys");
+ break;
+ case Configuration.KEYBOARD_12KEY:
+ keyboardText = doc.createTextNode("12key");
+ break;
+ case Configuration.KEYBOARD_QWERTY:
+ keyboardText = doc.createTextNode("qwerty");
+ break;
+ default:
+ keyboardText = doc.createTextNode(" ");
+ }
+ keyboard.appendChild(keyboardText);
+
+ Element nav = doc.createElement(PREFIX + NODE_NAV);
+ hardware.appendChild(nav);
+ Text navText;
+ switch (config.navigation) {
+ case Configuration.NAVIGATION_DPAD:
+ navText = doc.createTextNode("dpad");
+ case Configuration.NAVIGATION_TRACKBALL:
+ navText = doc.createTextNode("trackball");
+ case Configuration.NAVIGATION_WHEEL:
+ navText = doc.createTextNode("wheel");
+ case Configuration.NAVIGATION_NONAV:
+ navText = doc.createTextNode("nonav");
+ default:
+ navText = doc.createTextNode(" ");
+ }
+ nav.appendChild(navText);
+
+ Element ram = doc.createElement(PREFIX + NODE_RAM);
+ hardware.appendChild(ram);
+ // totalMemory given in bytes, divide by 1048576 to get RAM in MiB
+ String line;
+ long ramAmount = 0;
+ String unit = UNIT_BYTES;
+ try {
+ BufferedReader meminfo = new BufferedReader(new FileReader("/proc/meminfo"));
+ while ((line = meminfo.readLine()) != null) {
+ String[] vals = line.split("[\\s]+");
+ if (vals[0].equals("MemTotal:")) {
+ try {
+ /*
+ * We're going to want it as a string eventually,
+ * but parsing it lets us validate it's actually a
+ * number and something strange isn't going on
+ */
+ ramAmount = Long.parseLong(vals[1]);
+ unit = vals[2];
+ break;
+ } catch (NumberFormatException e) {
+ // Ignore
+ }
+ }
+ }
+ meminfo.close();
+ } catch (FileNotFoundException e) {
+ // Ignore
+ }
+ if (ramAmount > 0) {
+ if (unit.equals("B")) {
+ unit = UNIT_BYTES;
+ } else if (unit.equals("kB")) {
+ unit = UNIT_KIBIBYTES;
+ } else if (unit.equals("MB")) {
+ unit = UNIT_MEBIBYTES;
+ } else if (unit.equals("GB")) {
+ unit = UNIT_GIBIBYTES;
+ } else {
+ unit = " ";
+ }
+ }
+ ram.setAttribute(ATTR_UNIT, unit);
+ ram.appendChild(doc.createTextNode(Long.toString(ramAmount)));
+
+ // Can't actually get whether we're using software buttons
+ Element buttons = doc.createElement(PREFIX + NODE_BUTTONS);
+ hardware.appendChild(buttons);
+ buttons.appendChild(doc.createTextNode(" "));
+
+ Element internalStorage = doc.createElement(PREFIX + NODE_INTERNAL_STORAGE);
+ hardware.appendChild(internalStorage);
+ StatFs rootStat = new StatFs(Environment.getRootDirectory().getAbsolutePath());
+ long bytesAvailable = rootStat.getBlockSize() * rootStat.getBlockCount();
+ long internalStorageSize = bytesAvailable / (1024 * 1024);
+ internalStorage.appendChild(doc.createTextNode(Long.toString(internalStorageSize)));
+ internalStorage.setAttribute(ATTR_UNIT, UNIT_MEBIBYTES);
+
+ Element externalStorage = doc.createElement(PREFIX + NODE_REMOVABLE_STORAGE);
+ hardware.appendChild(externalStorage);
+ externalStorage.appendChild(doc.createTextNode(" "));
+
+
+ // Don't know CPU, GPU types
+ Element cpu = doc.createElement(PREFIX + NODE_CPU);
+ hardware.appendChild(cpu);
+ cpu.appendChild(doc.createTextNode(" "));
+ Element gpu = doc.createElement(PREFIX + NODE_GPU);
+ hardware.appendChild(gpu);
+ gpu.appendChild(doc.createTextNode(" "));
+
+ Element abi = doc.createElement(PREFIX + NODE_ABI);
+ hardware.appendChild(abi);
+ Text abiText = doc.createTextNode("");
+ abi.appendChild(abiText);
+ abiText.appendData("\n" + android.os.Build.CPU_ABI);
+ abiText.appendData("\n" + android.os.Build.CPU_ABI2);
+
+ // Don't know about either the dock or plugged-in element
+ Element dock = doc.createElement(PREFIX + NODE_DOCK);
+ hardware.appendChild(dock);
+ dock.appendChild(doc.createTextNode(" "));
+
+ Element pluggedIn = doc.createElement(PREFIX + NODE_PLUGGED_IN);
+ hardware.appendChild(pluggedIn);
+ pluggedIn.appendChild(doc.createTextNode(" "));
+
+ Element software = doc.createElement(PREFIX + NODE_SOFTWARE);
+ device.appendChild(software);
+
+ Element apiLevel = doc.createElement(PREFIX + NODE_API_LEVEL);
+ software.appendChild(apiLevel);
+ apiLevel.appendChild(doc.createTextNode(Integer
+ .toString(android.os.Build.VERSION.SDK_INT)));
+
+ Element liveWallpaperSupport = doc.createElement(PREFIX + NODE_LIVE_WALLPAPER_SUPPORT);
+ software.appendChild(liveWallpaperSupport);
+ if (packageMgr.hasSystemFeature(PackageManager.FEATURE_LIVE_WALLPAPER)) {
+ liveWallpaperSupport.appendChild(doc.createTextNode("true"));
+ } else {
+ liveWallpaperSupport.appendChild(doc.createTextNode("flase"));
+ }
+
+ Element bluetoothProfiles = doc.createElement(PREFIX + NODE_BLUETOOTH_PROFILES);
+ software.appendChild(bluetoothProfiles);
+ bluetoothProfiles.appendChild(doc.createTextNode(" "));
+
+ Element glVersion = doc.createElement(PREFIX + NODE_GL_VERSION);
+ software.appendChild(glVersion);
+ glVersion.appendChild(doc.createTextNode(" "));
+
+ Element glExtensions = doc.createElement(PREFIX + NODE_GL_EXTENSIONS);
+ software.appendChild(glExtensions);
+ glExtensions.appendChild(doc.createTextNode(" "));
+
+ Transformer tf = TransformerFactory.newInstance().newTransformer();
+ tf.setOutputProperty(OutputKeys.INDENT, "yes");
+ DOMSource source = new DOMSource(doc);
+ String filename = String.format("devices_%1$tm_%1$td_%1$ty.xml", Calendar.getInstance()
+ .getTime());
+ File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
+ File outFile = new File(dir, filename);
+ FileOutputStream out = new FileOutputStream(new File(dir, filename));
+ StreamResult result = new StreamResult(out);
+ tf.transform(source, result);
+ out.flush();
+ out.close();
+ return outFile.getAbsolutePath();
+ } catch (ParserConfigurationException e) {
+ error("Parser config exception", e);
+ } catch (TransformerConfigurationException e) {
+ error("Transformer config exception", e);
+ } catch (TransformerFactoryConfigurationError e) {
+ error("TransformerFactory config exception", e);
+ } catch (TransformerException e) {
+ error("Error transforming", e);
+ } catch (IOException e) {
+ error("I/O Error", e);
+ }
+ return null;
+ }
+
+ @TargetApi(9)
+ private List<Element> getCameraElements(Document doc) {
+ List<Element> cList = new ArrayList<Element>();
+ for (int i = 0; i < Camera.getNumberOfCameras(); i++) {
+ Element camera = doc.createElement(PREFIX + NODE_CAMERA);
+ cList.add(camera);
+ Element location = doc.createElement(PREFIX + NODE_LOCATION);
+ camera.appendChild(location);
+ Text locationText;
+ Camera.CameraInfo cInfo = new Camera.CameraInfo();
+ Camera.getCameraInfo(i, cInfo);
+ if (cInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
+ locationText = doc.createTextNode("front");
+ } else if (cInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
+ locationText = doc.createTextNode("back");
+ } else {
+ locationText = doc.createTextNode(" ");
+ }
+ location.appendChild(locationText);
+
+ Camera c = Camera.open(i);
+ Camera.Parameters cParams = c.getParameters();
+
+ Element autofocus = doc.createElement(PREFIX + NODE_AUTOFOCUS);
+ camera.appendChild(autofocus);
+ List<String> foci = cParams.getSupportedFocusModes();
+ if (foci == null) {
+ autofocus.appendChild(doc.createTextNode(" "));
+ } else if (foci.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
+ autofocus.appendChild(doc.createTextNode("true"));
+ } else {
+ autofocus.appendChild(doc.createTextNode("false"));
+ }
+
+ Element flash = doc.createElement(PREFIX + NODE_FLASH);
+ camera.appendChild(flash);
+ List<String> flashes = cParams.getSupportedFlashModes();
+ if (flashes == null || !flashes.contains(Camera.Parameters.FLASH_MODE_ON)) {
+ flash.appendChild(doc.createTextNode("false"));
+ } else {
+ flash.appendChild(doc.createTextNode("true"));
+ }
+ c.release();
+ }
+ return cList;
+ }
+
+ private void error(String err, Throwable e) {
+ Toast.makeText(mCtx, "Error Generating Configuration", Toast.LENGTH_SHORT).show();
+ Log.e(TAG, err);
+ Log.e(TAG, e.getLocalizedMessage());
+ }
+}
diff --git a/apps/DeviceConfig/src/com/example/android/deviceconfig/MyActivity.java b/apps/DeviceConfig/src/com/example/android/deviceconfig/MyActivity.java
new file mode 100644
index 000000000..837d072b8
--- /dev/null
+++ b/apps/DeviceConfig/src/com/example/android/deviceconfig/MyActivity.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.deviceconfig;
+
+import java.io.File;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.DisplayMetrics;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.TextView;
+import com.example.android.deviceconfig.R;
+
+public class MyActivity extends Activity implements OnClickListener {
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ Button btn = (Button) findViewById(R.id.generateConfigButton);
+ btn.setOnClickListener(this);
+ Configuration config = getResources().getConfiguration();
+
+ TextView tv = (TextView) findViewById(R.id.keyboard_state_api);
+ if (tv != null) {
+ String separator = config.orientation == Configuration.ORIENTATION_PORTRAIT ? "\n" : "";
+ String foo = "keyboardHidden=" + separator;
+ if (config.keyboardHidden == Configuration.KEYBOARDHIDDEN_NO) {
+ foo += "EXPOSED";
+ } else if (config.keyboardHidden == Configuration.KEYBOARDHIDDEN_YES) {
+ foo += "HIDDEN";
+ } else if (config.keyboardHidden == Configuration.KEYBOARDHIDDEN_UNDEFINED) {
+ foo += "UNDEFINED";
+ } else {
+ foo += "?";
+ }
+ foo += "\nhardKeyboardHidden=" + separator;
+ if (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
+ foo = foo + "EXPOSED";
+ } else if (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
+ foo = foo + "HIDDEN";
+ } else if (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_UNDEFINED) {
+ foo = foo + "UNDEFINED";
+ } else {
+ foo = "?";
+ }
+
+ tv.setText(foo);
+ }
+
+ tv = (TextView) findViewById(R.id.nav_state_api);
+ if (tv != null) {
+ if (config.navigationHidden == Configuration.NAVIGATIONHIDDEN_NO) {
+ tv.setText("EXPOSED");
+ } else if (config.navigationHidden == Configuration.NAVIGATIONHIDDEN_YES) {
+ tv.setText("HIDDEN");
+ } else if (config.navigationHidden == Configuration.NAVIGATIONHIDDEN_UNDEFINED) {
+ tv.setText("UNDEFINED");
+ } else {
+ tv.setText("??");
+ }
+ }
+
+ DisplayMetrics metrics = getResources().getDisplayMetrics();
+
+
+ tv = (TextView) findViewById(R.id.size_api);
+ if (tv != null) {
+ int a = metrics.heightPixels;
+ int b = metrics.widthPixels;
+ tv.setText(b + "x" + a);
+ }
+
+ tv = (TextView) findViewById(R.id.xdpi);
+ if (tv != null) {
+ tv.setText(String.format("%f", metrics.xdpi));
+ }
+ tv = (TextView) findViewById(R.id.ydpi);
+ if (tv != null) {
+ tv.setText(String.format("%f", metrics.ydpi));
+ }
+
+ tv = (TextView) findViewById(R.id.scaled_density);
+ if (tv != null) {
+ tv.setText(String.format("%f", metrics.scaledDensity));
+ }
+
+ tv = (TextView) findViewById(R.id.font_scale);
+ if (tv != null) {
+ tv.setText(String.format("%f", config.fontScale));
+ }
+
+ }
+
+ public void onClick(View v) {
+ ConfigGenerator configGen = new ConfigGenerator(this);
+ final String filename = configGen.generateConfig();
+ if (filename != null) {
+ Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
+ emailIntent.setType("text/xml");
+ File devicesXml = new File(filename);
+ emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Device XML: " + devicesXml.getName());
+ emailIntent.putExtra(Intent.EXTRA_TEXT, "Note: This is intended to generate a base "
+ + "XML description. After running this, you should double check the generated "
+ + "information and add all of the missing fields.");
+ emailIntent.putExtra(Intent.EXTRA_STREAM,
+ Uri.parse("file://" + devicesXml.getAbsolutePath()));
+ startActivity(emailIntent);
+ }
+ }
+
+}