From 39696bdac980e8c766fff9e71df12a3258bfeeed Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Thu, 26 Apr 2018 09:11:28 -0700 Subject: Fix PersistableBundle C++ -> Java interop PersistableBundle.java expects items to be sorted by the hash codes of the keys, but PersistableBundle.cpp isn't compatible to it. PersistableBundle.java now knowns what was parceled by C++ because it now uses a different magic, and change the unpercel strategy. Change-Id: Ia516f80b6d48dcb9f981767e0e64303434f39fb4 Fixes: 65744965 Test: adb shell sm fstrim and check logcat --- libs/binder/PersistableBundle.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'libs/binder/PersistableBundle.cpp') diff --git a/libs/binder/PersistableBundle.cpp b/libs/binder/PersistableBundle.cpp index d617b5a179..c0aec0a979 100644 --- a/libs/binder/PersistableBundle.cpp +++ b/libs/binder/PersistableBundle.cpp @@ -39,8 +39,9 @@ using std::vector; using namespace ::android::binder; enum { - // Keep in sync with BUNDLE_MAGIC in frameworks/base/core/java/android/os/BaseBundle.java. + // Keep them in sync with BUNDLE_MAGIC* in frameworks/base/core/java/android/os/BaseBundle.java. BUNDLE_MAGIC = 0x4C444E42, + BUNDLE_MAGIC_NATIVE = 0x4C444E44, }; namespace { @@ -99,7 +100,7 @@ status_t PersistableBundle::writeToParcel(Parcel* parcel) const { size_t length_pos = parcel->dataPosition(); RETURN_IF_FAILED(parcel->writeInt32(1)); // dummy, will hold length - RETURN_IF_FAILED(parcel->writeInt32(BUNDLE_MAGIC)); + RETURN_IF_FAILED(parcel->writeInt32(BUNDLE_MAGIC_NATIVE)); size_t start_pos = parcel->dataPosition(); RETURN_IF_FAILED(writeToParcelInner(parcel)); @@ -392,7 +393,7 @@ status_t PersistableBundle::readFromParcelInner(const Parcel* parcel, size_t len int32_t magic; RETURN_IF_FAILED(parcel->readInt32(&magic)); - if (magic != BUNDLE_MAGIC) { + if (magic != BUNDLE_MAGIC && magic != BUNDLE_MAGIC_NATIVE) { ALOGE("Bad magic number for PersistableBundle: 0x%08x", magic); return BAD_VALUE; } -- cgit v1.2.3-59-g8ed1b