diff options
author | 2018-04-26 09:11:28 -0700 | |
---|---|---|
committer | 2018-04-26 16:37:57 -0700 | |
commit | 39696bdac980e8c766fff9e71df12a3258bfeeed (patch) | |
tree | 6bfd21e824ca03ac15fca1f0bedde0c3404ad0e5 | |
parent | a991bc00d85a18ffc8c256aa2be9c41b5170ea94 (diff) |
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
-rw-r--r-- | libs/binder/PersistableBundle.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
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; } |