1 /* 2 * Copyright 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <binder/Parcelable.h> 20 21 #include <unordered_map> 22 23 namespace android { 24 25 enum { METADATA_OWNER_UID = 1, METADATA_WINDOW_TYPE = 2, METADATA_TASK_ID = 3 }; 26 27 struct LayerMetadata : public Parcelable { 28 std::unordered_map<uint32_t, std::vector<uint8_t>> mMap; 29 30 LayerMetadata(); 31 LayerMetadata(const LayerMetadata& other); 32 LayerMetadata(LayerMetadata&& other); 33 explicit LayerMetadata(std::unordered_map<uint32_t, std::vector<uint8_t>> map); 34 LayerMetadata& operator=(const LayerMetadata& other); 35 LayerMetadata& operator=(LayerMetadata&& other); 36 37 // Merges other into this LayerMetadata. If eraseEmpty is true, any entries in 38 // in this whose keys are paired with empty values in other will be erased. 39 bool merge(const LayerMetadata& other, bool eraseEmpty = false); 40 41 status_t writeToParcel(Parcel* parcel) const override; 42 status_t readFromParcel(const Parcel* parcel) override; 43 44 bool has(uint32_t key) const; 45 int32_t getInt32(uint32_t key, int32_t fallback) const; 46 void setInt32(uint32_t key, int32_t value); 47 48 std::string itemToString(uint32_t key, const char* separator) const; 49 }; 50 51 } // namespace android 52