1 /* 2 * Copyright (C) 2020 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 #pragma once 17 18 #include <memory> 19 20 #include <utils/Errors.h> 21 22 // WARNING: This is a feature which is still in development, and it is subject 23 // to radical change. Any production use of this may subject your code to any 24 // number of problems. 25 26 namespace android { 27 28 class Parcel; 29 struct RpcWireAddress; 30 31 /** 32 * This class represents an identifier of a binder object. 33 * 34 * The purpose of this class it to hide the ABI of an RpcWireAddress, and 35 * potentially allow us to change the size of it in the future (RpcWireAddress 36 * is PIMPL, essentially - although the type that is used here is not exposed). 37 */ 38 class RpcAddress { 39 public: 40 /** 41 * The zero address is used for special RPC transactions, but it might also 42 * be used in conjunction with readFromParcel. 43 */ 44 static RpcAddress zero(); 45 46 bool isZero() const; 47 48 /** 49 * Create a new address which is unique 50 */ 51 static RpcAddress unique(); 52 53 /** 54 * Creates a new address as a copy of an embedded object. 55 */ 56 static RpcAddress fromRawEmbedded(const RpcWireAddress* raw); 57 const RpcWireAddress& viewRawEmbedded() const; 58 59 bool operator<(const RpcAddress& rhs) const; 60 std::string toString() const; 61 62 status_t writeToParcel(Parcel* parcel) const; 63 status_t readFromParcel(const Parcel& parcel); 64 65 ~RpcAddress(); 66 67 private: 68 RpcAddress(); 69 70 std::shared_ptr<RpcWireAddress> mRawAddr; 71 }; 72 73 } // namespace android 74