Make Surface.toString() show more useful info to help debug bug 2594388.

Change-Id: I005d3388503d8886e11a26fece30b87572934f15
This commit is contained in:
Marco Nelissen
2010-04-26 16:05:48 -07:00
parent 27fba6797b
commit 8138cb49e4
2 changed files with 46 additions and 32 deletions

View File

@@ -147,6 +147,7 @@ public class Surface implements Parcelable {
private int mSaveCount; private int mSaveCount;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private Canvas mCanvas; private Canvas mCanvas;
private String mName;
// The display metrics used to provide the pseudo canvas size for applications // The display metrics used to provide the pseudo canvas size for applications
// running in compatibility mode. This is set to null for non compatibility mode. // running in compatibility mode. This is set to null for non compatibility mode.
@@ -204,6 +205,7 @@ public class Surface implements Parcelable {
} }
mCanvas = new CompatibleCanvas(); mCanvas = new CompatibleCanvas();
init(s,pid,name,display,w,h,format,flags); init(s,pid,name,display,w,h,format,flags);
mName = name;
} }
/** /**
@@ -386,7 +388,7 @@ public class Surface implements Parcelable {
@Override @Override
public String toString() { public String toString() {
return "Surface(native-token=" + mSurface + ")"; return "Surface(name=" + mName + ", identity=" + getIdentity() + ")";
} }
private Surface(Parcel source) throws OutOfResourcesException { private Surface(Parcel source) throws OutOfResourcesException {
@@ -437,4 +439,6 @@ public class Surface implements Parcelable {
throws OutOfResourcesException; throws OutOfResourcesException;
private native void init(Parcel source); private native void init(Parcel source);
private native int getIdentity();
} }

View File

@@ -229,6 +229,15 @@ static void Surface_initParcel(JNIEnv* env, jobject clazz, jobject argParcel)
setSurface(env, clazz, rhs); setSurface(env, clazz, rhs);
} }
static jint Surface_getIdentity(JNIEnv* env, jobject clazz)
{
const sp<SurfaceControl>& control(getSurfaceControl(env, clazz));
if (control != 0) return (jint) control->getIdentity();
const sp<Surface>& surface(getSurface(env, clazz));
if (surface != 0) return (jint) surface->getIdentity();
return -1;
}
static void Surface_destroy(JNIEnv* env, jobject clazz, uintptr_t *ostack) static void Surface_destroy(JNIEnv* env, jobject clazz, uintptr_t *ostack)
{ {
const sp<SurfaceControl>& surface(getSurfaceControl(env, clazz)); const sp<SurfaceControl>& surface(getSurfaceControl(env, clazz));
@@ -640,6 +649,7 @@ static JNINativeMethod gSurfaceMethods[] = {
{"nativeClassInit", "()V", (void*)nativeClassInit }, {"nativeClassInit", "()V", (void*)nativeClassInit },
{"init", "(Landroid/view/SurfaceSession;ILjava/lang/String;IIIII)V", (void*)Surface_init }, {"init", "(Landroid/view/SurfaceSession;ILjava/lang/String;IIIII)V", (void*)Surface_init },
{"init", "(Landroid/os/Parcel;)V", (void*)Surface_initParcel }, {"init", "(Landroid/os/Parcel;)V", (void*)Surface_initParcel },
{"getIdentity", "()I", (void*)Surface_getIdentity },
{"destroy", "()V", (void*)Surface_destroy }, {"destroy", "()V", (void*)Surface_destroy },
{"release", "()V", (void*)Surface_release }, {"release", "()V", (void*)Surface_release },
{"copyFrom", "(Landroid/view/Surface;)V", (void*)Surface_copyFrom }, {"copyFrom", "(Landroid/view/Surface;)V", (void*)Surface_copyFrom },