From c2be0d61830dd867f3092923e149e0cc251cdfc5 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Mon, 23 Sep 2013 11:16:28 -0700 Subject: [PATCH] Unmarshall PFDs properly when hand-crafting interface stubs ParcelFileDescriptors now carry an optional socket fd to communicate close events. So, make sure that the correct creator is called when reconstructing parceled PFDs. Bug: 10759966 Change-Id: Ic6b9ffb8cb7af5f3a12440def595f74682231866 --- core/java/android/app/ActivityManagerNative.java | 8 ++++---- core/java/android/app/ApplicationThreadNative.java | 8 ++++---- core/java/android/preference/PreferenceActivity.java | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index a727b076e9bbd..7d4d57cf5c779 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -152,7 +152,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM int startFlags = data.readInt(); String profileFile = data.readString(); ParcelFileDescriptor profileFd = data.readInt() != 0 - ? data.readFileDescriptor() : null; + ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null; Bundle options = data.readInt() != 0 ? Bundle.CREATOR.createFromParcel(data) : null; int userId = data.readInt(); @@ -178,7 +178,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM int startFlags = data.readInt(); String profileFile = data.readString(); ParcelFileDescriptor profileFd = data.readInt() != 0 - ? data.readFileDescriptor() : null; + ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null; Bundle options = data.readInt() != 0 ? Bundle.CREATOR.createFromParcel(data) : null; int userId = data.readInt(); @@ -1354,7 +1354,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM int profileType = data.readInt(); String path = data.readString(); ParcelFileDescriptor fd = data.readInt() != 0 - ? data.readFileDescriptor() : null; + ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null; boolean res = profileControl(process, userId, start, path, fd, profileType); reply.writeNoException(); reply.writeInt(res ? 1 : 0); @@ -1608,7 +1608,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM boolean managed = data.readInt() != 0; String path = data.readString(); ParcelFileDescriptor fd = data.readInt() != 0 - ? data.readFileDescriptor() : null; + ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null; boolean res = dumpHeap(process, userId, managed, path, fd); reply.writeNoException(); reply.writeInt(res ? 1 : 0); diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java index 876bf78418cb7..e40a04b41ec0e 100644 --- a/core/java/android/app/ApplicationThreadNative.java +++ b/core/java/android/app/ApplicationThreadNative.java @@ -143,7 +143,7 @@ public abstract class ApplicationThreadNative extends Binder boolean isForward = data.readInt() != 0; String profileName = data.readString(); ParcelFileDescriptor profileFd = data.readInt() != 0 - ? data.readFileDescriptor() : null; + ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null; boolean autoStopProfiler = data.readInt() != 0; scheduleLaunchActivity(intent, b, ident, info, curConfig, compatInfo, procState, state, ri, pi, notResumed, isForward, profileName, profileFd, autoStopProfiler); @@ -267,7 +267,7 @@ public abstract class ApplicationThreadNative extends Binder ? new ComponentName(data) : null; String profileName = data.readString(); ParcelFileDescriptor profileFd = data.readInt() != 0 - ? data.readFileDescriptor() : null; + ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null; boolean autoStopProfiler = data.readInt() != 0; Bundle testArgs = data.readBundle(); IBinder binder = data.readStrongBinder(); @@ -418,7 +418,7 @@ public abstract class ApplicationThreadNative extends Binder int profileType = data.readInt(); String path = data.readString(); ParcelFileDescriptor fd = data.readInt() != 0 - ? data.readFileDescriptor() : null; + ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null; profilerControl(start, path, fd, profileType); return true; } @@ -473,7 +473,7 @@ public abstract class ApplicationThreadNative extends Binder boolean managed = data.readInt() != 0; String path = data.readString(); ParcelFileDescriptor fd = data.readInt() != 0 - ? data.readFileDescriptor() : null; + ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null; dumpHeap(managed, path, fd); return true; } diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java index a99705bd12aea..2ab5a91a7013e 100644 --- a/core/java/android/preference/PreferenceActivity.java +++ b/core/java/android/preference/PreferenceActivity.java @@ -887,8 +887,9 @@ public abstract class PreferenceActivity extends ListActivity implements /** * Subclasses should override this method and verify that the given fragment is a valid type - * to be attached to this activity. The default implementation returns true prior - * to Key Lime Pie, false otherwise. + * to be attached to this activity. The default implementation returns true for + * apps built for android:targetSdkVersion older than + * {@link android.os.Build.VERSION_CODES#KITKAT}. For later versions, it will throw an exception. * @param fragmentName the class name of the Fragment about to be attached to this activity. * @return true if the fragment class name is valid for this Activity and false otherwise. */