diff options
-rw-r--r-- | cmds/flatland/Main.cpp | 12 | ||||
-rw-r--r-- | include/binder/PersistableBundle.h | 14 | ||||
-rw-r--r-- | libs/binder/PersistableBundle.cpp | 79 |
3 files changed, 88 insertions, 17 deletions
diff --git a/cmds/flatland/Main.cpp b/cmds/flatland/Main.cpp index 866203f3f2..c47b0c8f4b 100644 --- a/cmds/flatland/Main.cpp +++ b/cmds/flatland/Main.cpp @@ -206,8 +206,8 @@ static const BenchmarkDesc benchmarks[] = { static const ShaderDesc shaders[] = { { - name: "Blit", - vertexShader: { + .name="Blit", + .vertexShader={ "precision mediump float;", "", "attribute vec4 position;", @@ -223,7 +223,7 @@ static const ShaderDesc shaders[] = { " texCoords = uvToTex * uv;", "}", }, - fragmentShader: { + .fragmentShader={ "#extension GL_OES_EGL_image_external : require", "precision mediump float;", "", @@ -240,8 +240,8 @@ static const ShaderDesc shaders[] = { }, { - name: "Gradient", - vertexShader: { + .name="Gradient", + .vertexShader={ "precision mediump float;", "", "attribute vec4 position;", @@ -257,7 +257,7 @@ static const ShaderDesc shaders[] = { " interp = (uvToInterp * uv).x;", "}", }, - fragmentShader: { + .fragmentShader={ "precision mediump float;", "", "varying float interp;", diff --git a/include/binder/PersistableBundle.h b/include/binder/PersistableBundle.h index fe5619fc52..322fef9e4f 100644 --- a/include/binder/PersistableBundle.h +++ b/include/binder/PersistableBundle.h @@ -18,6 +18,7 @@ #define ANDROID_PERSISTABLE_BUNDLE_H #include <map> +#include <set> #include <vector> #include <binder/Parcelable.h> @@ -79,6 +80,19 @@ public: bool getStringVector(const String16& key, std::vector<String16>* out) const; bool getPersistableBundle(const String16& key, PersistableBundle* out) const; + /* Getters for all keys for each value type */ + std::set<String16> getBooleanKeys() const; + std::set<String16> getIntKeys() const; + std::set<String16> getLongKeys() const; + std::set<String16> getDoubleKeys() const; + std::set<String16> getStringKeys() const; + std::set<String16> getBooleanVectorKeys() const; + std::set<String16> getIntVectorKeys() const; + std::set<String16> getLongVectorKeys() const; + std::set<String16> getDoubleVectorKeys() const; + std::set<String16> getStringVectorKeys() const; + std::set<String16> getPersistableBundleKeys() const; + friend bool operator==(const PersistableBundle& lhs, const PersistableBundle& rhs) { return (lhs.mBoolMap == rhs.mBoolMap && lhs.mIntMap == rhs.mIntMap && lhs.mLongMap == rhs.mLongMap && lhs.mDoubleMap == rhs.mDoubleMap && diff --git a/libs/binder/PersistableBundle.cpp b/libs/binder/PersistableBundle.cpp index aef791c37b..a20359f243 100644 --- a/libs/binder/PersistableBundle.cpp +++ b/libs/binder/PersistableBundle.cpp @@ -32,6 +32,9 @@ using android::Parcel; using android::sp; using android::status_t; using android::UNEXPECTED_NULL; +using std::map; +using std::set; +using std::vector; enum { // Keep in sync with BUNDLE_MAGIC in frameworks/base/core/java/android/os/BaseBundle.java. @@ -55,12 +58,22 @@ enum { namespace { template <typename T> -bool getValue(const android::String16& key, T* out, const std::map<android::String16, T>& map) { +bool getValue(const android::String16& key, T* out, const map<android::String16, T>& map) { const auto& it = map.find(key); if (it == map.end()) return false; *out = it->second; return true; } + +template <typename T> +set<android::String16> getKeys(const map<android::String16, T>& map) { + if (map.empty()) return set<android::String16>(); + set<android::String16> keys; + for (const auto& key_value_pair : map) { + keys.emplace(key_value_pair.first); + } + return keys; +} } // namespace namespace android { @@ -188,27 +201,27 @@ void PersistableBundle::putString(const String16& key, const String16& value) { mStringMap[key] = value; } -void PersistableBundle::putBooleanVector(const String16& key, const std::vector<bool>& value) { +void PersistableBundle::putBooleanVector(const String16& key, const vector<bool>& value) { erase(key); mBoolVectorMap[key] = value; } -void PersistableBundle::putIntVector(const String16& key, const std::vector<int32_t>& value) { +void PersistableBundle::putIntVector(const String16& key, const vector<int32_t>& value) { erase(key); mIntVectorMap[key] = value; } -void PersistableBundle::putLongVector(const String16& key, const std::vector<int64_t>& value) { +void PersistableBundle::putLongVector(const String16& key, const vector<int64_t>& value) { erase(key); mLongVectorMap[key] = value; } -void PersistableBundle::putDoubleVector(const String16& key, const std::vector<double>& value) { +void PersistableBundle::putDoubleVector(const String16& key, const vector<double>& value) { erase(key); mDoubleVectorMap[key] = value; } -void PersistableBundle::putStringVector(const String16& key, const std::vector<String16>& value) { +void PersistableBundle::putStringVector(const String16& key, const vector<String16>& value) { erase(key); mStringVectorMap[key] = value; } @@ -238,23 +251,23 @@ bool PersistableBundle::getString(const String16& key, String16* out) const { return getValue(key, out, mStringMap); } -bool PersistableBundle::getBooleanVector(const String16& key, std::vector<bool>* out) const { +bool PersistableBundle::getBooleanVector(const String16& key, vector<bool>* out) const { return getValue(key, out, mBoolVectorMap); } -bool PersistableBundle::getIntVector(const String16& key, std::vector<int32_t>* out) const { +bool PersistableBundle::getIntVector(const String16& key, vector<int32_t>* out) const { return getValue(key, out, mIntVectorMap); } -bool PersistableBundle::getLongVector(const String16& key, std::vector<int64_t>* out) const { +bool PersistableBundle::getLongVector(const String16& key, vector<int64_t>* out) const { return getValue(key, out, mLongVectorMap); } -bool PersistableBundle::getDoubleVector(const String16& key, std::vector<double>* out) const { +bool PersistableBundle::getDoubleVector(const String16& key, vector<double>* out) const { return getValue(key, out, mDoubleVectorMap); } -bool PersistableBundle::getStringVector(const String16& key, std::vector<String16>* out) const { +bool PersistableBundle::getStringVector(const String16& key, vector<String16>* out) const { return getValue(key, out, mStringVectorMap); } @@ -262,6 +275,50 @@ bool PersistableBundle::getPersistableBundle(const String16& key, PersistableBun return getValue(key, out, mPersistableBundleMap); } +set<String16> PersistableBundle::getBooleanKeys() const { + return getKeys(mBoolMap); +} + +set<String16> PersistableBundle::getIntKeys() const { + return getKeys(mIntMap); +} + +set<String16> PersistableBundle::getLongKeys() const { + return getKeys(mLongMap); +} + +set<String16> PersistableBundle::getDoubleKeys() const { + return getKeys(mDoubleMap); +} + +set<String16> PersistableBundle::getStringKeys() const { + return getKeys(mStringMap); +} + +set<String16> PersistableBundle::getBooleanVectorKeys() const { + return getKeys(mBoolVectorMap); +} + +set<String16> PersistableBundle::getIntVectorKeys() const { + return getKeys(mIntVectorMap); +} + +set<String16> PersistableBundle::getLongVectorKeys() const { + return getKeys(mLongVectorMap); +} + +set<String16> PersistableBundle::getDoubleVectorKeys() const { + return getKeys(mDoubleVectorMap); +} + +set<String16> PersistableBundle::getStringVectorKeys() const { + return getKeys(mStringVectorMap); +} + +set<String16> PersistableBundle::getPersistableBundleKeys() const { + return getKeys(mPersistableBundleMap); +} + status_t PersistableBundle::writeToParcelInner(Parcel* parcel) const { /* * To keep this implementation in sync with writeArrayMapInternal() in |