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 { 26 METADATA_OWNER_UID = 1, 27 METADATA_WINDOW_TYPE = 2, 28 METADATA_TASK_ID = 3, 29 METADATA_MOUSE_CURSOR = 4, 30 }; 31 32 struct LayerMetadata : public Parcelable { 33 std::unordered_map<uint32_t, std::vector<uint8_t>> mMap; 34 35 LayerMetadata(); 36 LayerMetadata(const LayerMetadata& other); 37 LayerMetadata(LayerMetadata&& other); 38 explicit LayerMetadata(std::unordered_map<uint32_t, std::vector<uint8_t>> map); 39 LayerMetadata& operator=(const LayerMetadata& other); 40 LayerMetadata& operator=(LayerMetadata&& other); 41 42 // Merges other into this LayerMetadata. If eraseEmpty is true, any entries in 43 // in this whose keys are paired with empty values in other will be erased. 44 bool merge(const LayerMetadata& other, bool eraseEmpty = false); 45 46 status_t writeToParcel(Parcel* parcel) const override; 47 status_t readFromParcel(const Parcel* parcel) override; 48 49 bool has(uint32_t key) const; 50 int32_t getInt32(uint32_t key, int32_t fallback) const; 51 void setInt32(uint32_t key, int32_t value); 52 53 std::string itemToString(uint32_t key, const char* separator) const; 54 }; 55 56 } // namespace android 57