bug 721741 - Add support for Flash on Android 4.0+, follow up to use reflection and not require ICS SDK r=dougt a=akeybl
authorBrad Lassey <blassey@mozilla.com>
Wed, 01 Feb 2012 01:29:09 -0500
changeset 88345 976580a0c9d79f3e717e060e011f3ed00c3d0e53
parent 88344 d39937f28182dbe2731cc90057dba9bf725676cf
child 88346 dfce8408f9407da0a2f1f96b0998b386a329e5b1
push idunknown
push userunknown
push dateunknown
reviewersdougt, akeybl
bugs721741
milestone12.0a2
bug 721741 - Add support for Flash on Android 4.0+, follow up to use reflection and not require ICS SDK r=dougt a=akeybl
mobile/android/base/GeckoApp.java
mobile/android/base/gfx/SurfaceTextureLayer.java
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -216,17 +216,17 @@ abstract public class GeckoApp
 
     private static final String PLUGIN_TYPE = "type";
     private static final String TYPE_NATIVE = "native";
     public ArrayList<PackageInfo> mPackageInfoCache = new ArrayList<PackageInfo>();
 
     String[] getPluginDirectories() {
         // we don't support Honeycomb
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB &&
-            Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH)
+            Build.VERSION.SDK_INT < 14 /*Build.VERSION_CODES.ICE_CREAM_SANDWICH*/ )
             return new String[0];
 
         Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - start of getPluginDirectories");
 
         ArrayList<String> directories = new ArrayList<String>();
         PackageManager pm = mAppContext.getPackageManager();
         List<ResolveInfo> plugins = pm.queryIntentServices(new Intent(PLUGIN_ACTION),
                 PackageManager.GET_SERVICES | PackageManager.GET_META_DATA);
--- a/mobile/android/base/gfx/SurfaceTextureLayer.java
+++ b/mobile/android/base/gfx/SurfaceTextureLayer.java
@@ -79,17 +79,24 @@ public class SurfaceTextureLayer extends
     public SurfaceTextureLayer(int textureId) {
         mTextureId = textureId;
         mHaveFrame = true;
         mInverted = false;
 
         mSurfaceTexture = new SurfaceTexture(mTextureId);
         mSurfaceTexture.setOnFrameAvailableListener(this);
 
-        mSurface = new Surface(mSurfaceTexture);
+        Surface tmp = null;
+        try {
+            tmp = Surface.class.getConstructor(SurfaceTexture.class).newInstance(mSurfaceTexture); }
+        catch (Exception ie) {
+            Log.e(LOGTAG, "error constructing the surface", ie);
+        }
+
+        mSurface = tmp;
 
         float textureMap[] = {
                 0.0f, 1.0f,	// top left
                 0.0f, 0.0f,	// bottom left
                 1.0f, 1.0f,	// top right
                 1.0f, 0.0f,	// bottom right
         };
 
@@ -145,19 +152,27 @@ public class SurfaceTextureLayer extends
         endTransaction();
     }
 
     @Override
     public IntSize getSize() { return mSize; }
 
     @Override
     protected void finalize() throws Throwable {
-        if (mSurfaceTexture != null)
-            mSurfaceTexture.release();
-
+        if (mSurfaceTexture != null) {
+            try {
+                SurfaceTexture.class.getDeclaredMethod("release").invoke(mSurfaceTexture);
+            } catch (NoSuchMethodException nsme) {
+                Log.e(LOGTAG, "error finding release method on mSurfaceTexture", nsme);
+            } catch (IllegalAccessException iae) {
+                Log.e(LOGTAG, "error invoking release method on mSurfaceTexture", iae);
+            } catch (Exception e) {
+                Log.e(LOGTAG, "some other exception while invoking release method on mSurfaceTexture", e);
+            }
+        }
         if (mTextureId > 0)
             TextureReaper.get().add(mTextureId);
     }
 
     @Override
     protected boolean performUpdates(GL10 gl, RenderContext context) {
         super.performUpdates(gl, context);