Add API to get path to OBBs.

Also hide the bitmap thumbnail stuff, we can't support it in its
current form.

And fix some bugs with propagating paths to native code.  Yikes!

Change-Id: I13ab37ddbdba5c073489cba5eab035117d3c1574
diff --git a/api/11.xml b/api/11.xml
index 1733652..1ac57a1 100644
--- a/api/11.xml
+++ b/api/11.xml
@@ -4250,6 +4250,17 @@
  visibility="public"
 >
 </field>
+<field name="fastScrollTextColor"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843611"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="fastScrollThumbDrawable"
  type="int"
  transient="false"
@@ -5812,6 +5823,17 @@
  visibility="public"
 >
 </field>
+<field name="largeHeap"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843612"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="largeScreens"
  type="int"
  transient="false"
@@ -11462,6 +11484,28 @@
  visibility="public"
 >
 </field>
+<field name="notification_large_icon_height"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="17104902"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="notification_large_icon_width"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="17104901"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="thumbnail_height"
  type="int"
  transient="false"
@@ -25114,17 +25158,6 @@
  visibility="public"
 >
 </field>
-<field name="TASKS_GET_THUMBNAILS"
- type="int"
- transient="false"
- volatile="false"
- value="4096"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 </class>
 <class name="ActivityManager.MemoryInfo"
  extends="java.lang.Object"
@@ -25523,16 +25556,6 @@
  visibility="public"
 >
 </field>
-<field name="thumbnail"
- type="android.graphics.Bitmap"
- transient="false"
- volatile="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 </class>
 <class name="ActivityManager.RunningAppProcessInfo"
  extends="java.lang.Object"
@@ -38947,6 +38970,17 @@
  visibility="public"
 >
 </method>
+<method name="clearViews"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+</method>
 <method name="createView"
  return="android.appwidget.AppWidgetHostView"
  abstract="false"
@@ -48119,6 +48153,17 @@
  visibility="public"
 >
 </method>
+<method name="getObbDir"
+ return="java.io.File"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getPackageCodePath"
  return="java.lang.String"
  abstract="true"
@@ -49727,6 +49772,17 @@
  visibility="public"
 >
 </method>
+<method name="getObbDir"
+ return="java.io.File"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getPackageCodePath"
  return="java.lang.String"
  abstract="false"
@@ -58210,6 +58266,17 @@
  visibility="public"
 >
 </field>
+<field name="FLAG_LARGE_HEAP"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1048576"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="FLAG_PERSISTENT"
  type="int"
  transient="false"
@@ -60220,6 +60287,19 @@
 <exception name="PackageManager.NameNotFoundException" type="android.content.pm.PackageManager.NameNotFoundException">
 </exception>
 </method>
+<method name="getPackageObbPaths"
+ return="java.lang.String[]"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="packageName" type="java.lang.String">
+</parameter>
+</method>
 <method name="getPackagesForUid"
  return="java.lang.String[]"
  abstract="true"
@@ -60706,6 +60786,21 @@
 <parameter name="installerPackageName" type="java.lang.String">
 </parameter>
 </method>
+<method name="setPackageObbPaths"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="packageName" type="java.lang.String">
+</parameter>
+<parameter name="paths" type="java.lang.String[]">
+</parameter>
+</method>
 <field name="COMPONENT_ENABLED_STATE_DEFAULT"
  type="int"
  transient="false"
@@ -137446,6 +137541,34 @@
 <parameter name="params" type="Params...">
 </parameter>
 </method>
+<method name="execute"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="runnable" type="java.lang.Runnable">
+</parameter>
+</method>
+<method name="executeOnExecutor"
+ return="android.os.AsyncTask&lt;Params, Progress, Result&gt;"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="exec" type="java.util.concurrent.Executor">
+</parameter>
+<parameter name="params" type="Params...">
+</parameter>
+</method>
 <method name="get"
  return="Result"
  abstract="false"
@@ -137578,6 +137701,16 @@
 <parameter name="values" type="Progress...">
 </parameter>
 </method>
+<field name="THREAD_POOL_EXECUTOR"
+ type="java.util.concurrent.ThreadPoolExecutor"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 </class>
 <class name="AsyncTask.Status"
  extends="java.lang.Enum"
@@ -185171,6 +185304,19 @@
 <exception name="PackageManager.NameNotFoundException" type="android.content.pm.PackageManager.NameNotFoundException">
 </exception>
 </method>
+<method name="getPackageObbPaths"
+ return="java.lang.String[]"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="packageName" type="java.lang.String">
+</parameter>
+</method>
 <method name="getPackagesForUid"
  return="java.lang.String[]"
  abstract="false"
@@ -185670,6 +185816,21 @@
 <parameter name="path" type="java.lang.String">
 </parameter>
 </method>
+<method name="setPackageObbPaths"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="packageName" type="java.lang.String">
+</parameter>
+<parameter name="paths" type="java.lang.String[]">
+</parameter>
+</method>
 </class>
 <class name="MockResources"
  extends="android.content.res.Resources"
@@ -238084,6 +238245,34 @@
 >
 </field>
 </class>
+<class name="WebViewFragment"
+ extends="android.app.Fragment"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="WebViewFragment"
+ type="android.webkit.WebViewFragment"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</constructor>
+<method name="getWebView"
+ return="android.webkit.WebView"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+</class>
 </package>
 <package name="android.widget"
 >
diff --git a/api/current.xml b/api/current.xml
index f7172f4..06c81b6 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -25158,17 +25158,6 @@
  visibility="public"
 >
 </field>
-<field name="TASKS_GET_THUMBNAILS"
- type="int"
- transient="false"
- volatile="false"
- value="4096"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 </class>
 <class name="ActivityManager.MemoryInfo"
  extends="java.lang.Object"
@@ -25567,16 +25556,6 @@
  visibility="public"
 >
 </field>
-<field name="thumbnail"
- type="android.graphics.Bitmap"
- transient="false"
- volatile="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 </class>
 <class name="ActivityManager.RunningAppProcessInfo"
  extends="java.lang.Object"
@@ -48174,6 +48153,17 @@
  visibility="public"
 >
 </method>
+<method name="getObbDir"
+ return="java.io.File"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getPackageCodePath"
  return="java.lang.String"
  abstract="true"
@@ -49782,6 +49772,17 @@
  visibility="public"
 >
 </method>
+<method name="getObbDir"
+ return="java.io.File"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getPackageCodePath"
  return="java.lang.String"
  abstract="false"
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 4eae14b..d5aa961 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -122,6 +122,8 @@
         /**
          * Thumbnail representation of the task's last state.  Must
          * use {@link ActivityManager#TASKS_GET_THUMBNAILS} to have this set.
+         * @hide -- this is not scalable, need to have a separate API to get
+         * the bitmap.
          */
         public Bitmap thumbnail;
 
@@ -203,6 +205,7 @@
     /**
      * Flag for use with {@link #getRecentTasks}: also return the thumbnail
      * bitmap (if available) for each recent task.
+     * @hide
      */
     public static final int TASKS_GET_THUMBNAILS = 0x0001000;
     
@@ -214,8 +217,7 @@
      * actual number returned may be smaller, depending on how many tasks the
      * user has started and the maximum number the system can remember.
      * @param flags Information about what to return.  May be any combination
-     * of {@link #RECENT_WITH_EXCLUDED}, {@link #RECENT_IGNORE_UNAVAILABLE},
-     * and {@link #TASKS_GET_THUMBNAILS}.
+     * of {@link #RECENT_WITH_EXCLUDED} and {@link #RECENT_IGNORE_UNAVAILABLE}.
      * 
      * @return Returns a list of RecentTaskInfo records describing each of
      * the recent tasks.
@@ -261,8 +263,8 @@
         public ComponentName topActivity;
 
         /**
-         * Thumbnail representation of the task's current state.  Must
-         * use {@link ActivityManager#TASKS_GET_THUMBNAILS} to have this set.
+         * Thumbnail representation of the task's current state.  Currently
+         * always null.
          */
         public Bitmap thumbnail;
 
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index e133ea0..6f63990 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -153,6 +153,7 @@
     private File mPreferencesDir;
     private File mFilesDir;
     private File mCacheDir;
+    private File mObbDir;
     private File mExternalFilesDir;
     private File mExternalCacheDir;
 
@@ -647,6 +648,17 @@
     }
 
     @Override
+    public File getObbDir() {
+        synchronized (mSync) {
+            if (mObbDir == null) {
+                mObbDir = Environment.getExternalStorageAppObbDirectory(
+                        getPackageName());
+            }
+            return mObbDir;
+        }
+    }
+
+    @Override
     public File getCacheDir() {
         synchronized (mSync) {
             if (mCacheDir == null) {
diff --git a/core/java/android/app/NativeActivity.java b/core/java/android/app/NativeActivity.java
index a5c49ec..35cc324 100644
--- a/core/java/android/app/NativeActivity.java
+++ b/core/java/android/app/NativeActivity.java
@@ -84,7 +84,7 @@
     private boolean mDestroyed;
     
     private native int loadNativeCode(String path, String funcname, MessageQueue queue,
-            String internalDataPath, String externalDataPath, int sdkVersion,
+            String internalDataPath, String obbPath, String externalDataPath, int sdkVersion,
             AssetManager assetMgr, byte[] savedState);
     private native void unloadNativeCode(int handle);
     
@@ -191,7 +191,7 @@
                 ? savedInstanceState.getByteArray(KEY_NATIVE_SAVED_STATE) : null;
 
         mNativeHandle = loadNativeCode(path, funcname, Looper.myQueue(),
-                 getFilesDir().toString(),
+                 getFilesDir().toString(), getObbDir().toString(),
                  Environment.getExternalStorageAppFilesDirectory(ai.packageName).toString(),
                  Build.VERSION.SDK_INT, getAssets(), nativeSavedState);
         
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 227df21..d14cf4d 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -516,6 +516,13 @@
     public abstract File getExternalFilesDir(String type);
 
     /**
+     * Return the directory where this application's OBB files (if there
+     * are any) can be found.  Note if the application does not have any OBB
+     * files, this directory may not exist.
+     */
+    public abstract File getObbDir();
+
+    /**
      * Returns the absolute path to the application specific cache directory
      * on the filesystem. These files will be ones that get deleted first when the
      * device runs low on storage.
diff --git a/core/java/android/content/ContextWrapper.java b/core/java/android/content/ContextWrapper.java
index 545144e..3928aaf 100644
--- a/core/java/android/content/ContextWrapper.java
+++ b/core/java/android/content/ContextWrapper.java
@@ -191,6 +191,11 @@
     }
     
     @Override
+    public File getObbDir() {
+        return mBase.getObbDir();
+    }
+    
+    @Override
     public File getCacheDir() {
         return mBase.getCacheDir();
     }
diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java
index 4f188f8..cc95642 100644
--- a/core/java/android/os/Environment.java
+++ b/core/java/android/os/Environment.java
@@ -107,6 +107,10 @@
             = new File (new File(getDirectory("EXTERNAL_STORAGE", "/sdcard"),
                     "Android"), "media");
 
+    private static final File EXTERNAL_STORAGE_ANDROID_OBB_DIRECTORY
+            = new File (new File(getDirectory("EXTERNAL_STORAGE", "/sdcard"),
+                    "Android"), "obb");
+
     private static final File DOWNLOAD_CACHE_DIRECTORY
             = getDirectory("DOWNLOAD_CACHE", "/cache");
 
@@ -304,6 +308,14 @@
     }
     
     /**
+     * Generates the raw path to an application's OBB files
+     * @hide
+     */
+    public static File getExternalStorageAppObbDirectory(String packageName) {
+        return new File(EXTERNAL_STORAGE_ANDROID_OBB_DIRECTORY, packageName);
+    }
+    
+    /**
      * Generates the path to an application's files.
      * @hide
      */
diff --git a/core/jni/android_app_NativeActivity.cpp b/core/jni/android_app_NativeActivity.cpp
index b033878..0430a81 100644
--- a/core/jni/android_app_NativeActivity.cpp
+++ b/core/jni/android_app_NativeActivity.cpp
@@ -500,8 +500,9 @@
     void* dlhandle;
     ANativeActivity_createFunc* createActivityFunc;
     
-    String8 internalDataPath;
-    String8 externalDataPath;
+    String8 internalDataPathObj;
+    String8 externalDataPathObj;
+    String8 obbPathObj;
     
     sp<ANativeWindow> nativeWindow;
     int32_t lastWindowWidth;
@@ -641,8 +642,8 @@
 
 static jint
 loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jstring funcName,
-        jobject messageQueue,
-        jstring internalDataDir, jstring externalDataDir, int sdkVersion,
+        jobject messageQueue, jstring internalDataDir, jstring obbDir,
+        jstring externalDataDir, int sdkVersion,
         jobject jAssetMgr, jbyteArray savedState)
 {
     LOG_TRACE("loadNativeCode_native");
@@ -699,19 +700,24 @@
         code->clazz = env->NewGlobalRef(clazz);
 
         const char* dirStr = env->GetStringUTFChars(internalDataDir, NULL);
-        code->internalDataPath = dirStr;
-        code->internalDataPath = code->internalDataPath.string();
-        env->ReleaseStringUTFChars(path, dirStr);
+        code->internalDataPathObj = dirStr;
+        code->internalDataPath = code->internalDataPathObj.string();
+        env->ReleaseStringUTFChars(internalDataDir, dirStr);
     
         dirStr = env->GetStringUTFChars(externalDataDir, NULL);
-        code->externalDataPath = dirStr;
-        code->externalDataPath = code->externalDataPath.string();
-        env->ReleaseStringUTFChars(path, dirStr);
+        code->externalDataPathObj = dirStr;
+        code->externalDataPath = code->externalDataPathObj.string();
+        env->ReleaseStringUTFChars(externalDataDir, dirStr);
 
         code->sdkVersion = sdkVersion;
         
         code->assetManager = assetManagerForJavaObject(env, jAssetMgr);
 
+        dirStr = env->GetStringUTFChars(obbDir, NULL);
+        code->obbPathObj = dirStr;
+        code->obbPath = code->obbPathObj.string();
+        env->ReleaseStringUTFChars(obbDir, dirStr);
+
         jbyte* rawSavedState = NULL;
         jsize rawSavedSize = 0;
         if (savedState != NULL) {
@@ -1022,7 +1028,7 @@
 }
 
 static const JNINativeMethod g_methods[] = {
-    { "loadNativeCode", "(Ljava/lang/String;Ljava/lang/String;Landroid/os/MessageQueue;Ljava/lang/String;Ljava/lang/String;ILandroid/content/res/AssetManager;[B)I",
+    { "loadNativeCode", "(Ljava/lang/String;Ljava/lang/String;Landroid/os/MessageQueue;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILandroid/content/res/AssetManager;[B)I",
             (void*)loadNativeCode_native },
     { "unloadNativeCode", "(I)V", (void*)unloadNativeCode_native },
     { "onStartNative", "(I)V", (void*)onStart_native },
diff --git a/native/include/android/native_activity.h b/native/include/android/native_activity.h
index d89bc8b..a361846 100644
--- a/native/include/android/native_activity.h
+++ b/native/include/android/native_activity.h
@@ -91,6 +91,13 @@
      * uses this to access binary assets bundled inside its own .apk file.
      */
     AAssetManager* assetManager;
+
+    /**
+     * Available starting with Honeycomb: path to the directory containing
+     * the application's OBB files (if any).  If the app doesn't have any
+     * OBB files, this directory may not exist.
+     */
+    const char* obbPath;
 } ANativeActivity;
 
 /**
diff --git a/test-runner/src/android/test/mock/MockContext.java b/test-runner/src/android/test/mock/MockContext.java
index 3b52252..0b4fc51 100644
--- a/test-runner/src/android/test/mock/MockContext.java
+++ b/test-runner/src/android/test/mock/MockContext.java
@@ -164,6 +164,11 @@
     }
 
     @Override
+    public File getObbDir() {
+        throw new UnsupportedOperationException();
+    }
+    
+    @Override
     public File getCacheDir() {
         throw new UnsupportedOperationException();
     }