Add new API to find out whether external storage is removable.

This is implemented based on whether we are using the "nosdcard"
product.  Needed to tweak aapt to allow use of the product attribute
with other resource definition tags besides strings.

Change-Id: I49922d23b52a34183a8e2f4d2515adaf1fc9149a
diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java
index c7cbed6..e8ae7e6 100644
--- a/core/java/android/os/Environment.java
+++ b/core/java/android/os/Environment.java
@@ -18,6 +18,7 @@
 
 import java.io.File;
 
+import android.content.res.Resources;
 import android.os.storage.IMountService;
 
 /**
@@ -116,6 +117,19 @@
      * happened.  You can determine its current state with
      * {@link #getExternalStorageState()}.
      * 
+     * <p><em>Note: don't be confused by the word "external" here.  This
+     * directory can better be thought as media/shared storage.  It is a
+     * filesystem that can hold a relatively large amount of data and that
+     * is shared across all applications (does not enforce permissions).
+     * Traditionally this is an SD card, but it may also be implemented as
+     * built-in storage in a device that is distinct from the protected
+     * internal storage and can be mounted as a filesystem on a computer.</em></p>
+     *
+     * <p>In devices with multiple "external" storage directories (such as
+     * both secure app storage and mountable shared storage), this directory
+     * represents the "primary" external storage that the user will interact
+     * with.</p>
+     *
      * <p>Applications should not directly use this top-level directory, in
      * order to avoid polluting the user's root namespace.  Any files that are
      * private to the application should be placed in a directory returned
@@ -130,6 +144,9 @@
      * 
      * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java
      * monitor_storage}
+     *
+     * @see #getExternalStorageState()
+     * @see #isExternalStorageRemovable()
      */
     public static File getExternalStorageDirectory() {
         return EXTERNAL_STORAGE_DIRECTORY;
@@ -359,11 +376,9 @@
     public static final String MEDIA_UNMOUNTABLE = "unmountable";
 
     /**
-     * Gets the current state of the external storage device.
-     * Note: This call should be deprecated as it doesn't support
-     * multiple volumes.
+     * Gets the current state of the primary "external" storage device.
      * 
-     * <p>See {@link #getExternalStorageDirectory()} for an example of its use.
+     * <p>See {@link #getExternalStorageDirectory()} for more information.
      */
     public static String getExternalStorageState() {
         try {
@@ -377,6 +392,19 @@
         }
     }
 
+    /**
+     * Returns whether the primary "external" storage device is removable.
+     * If true is returned, this device is for example an SD card that the
+     * user can remove.  If false is returned, the storage is built into
+     * the device and can not be physically removed.
+     *
+     * <p>See {@link #getExternalStorageDirectory()} for more information.
+     */
+    public static boolean isExternalStorageRemovable() {
+        return Resources.getSystem().getBoolean(
+                com.android.internal.R.bool.config_externalStorageRemovable);
+    }
+
     static File getDirectory(String variableName, String defaultPath) {
         String path = System.getenv(variableName);
         return path == null ? new File(defaultPath) : new File(path);