libbinder: delete IpPrefix
Seems nothing is using this.
Bug: 183654927
Test: N/A
Change-Id: Ib07336291850ba8000a31f9f5b93313e8c65394c
diff --git a/libs/binder/Android.bp b/libs/binder/Android.bp
index f28af96..2715d6a 100644
--- a/libs/binder/Android.bp
+++ b/libs/binder/Android.bp
@@ -69,7 +69,6 @@
"IUidObserver.cpp",
"PermissionCache.cpp",
"PermissionController.cpp",
- "IpPrefix.cpp",
":activity_manager_procstate_aidl",
]
diff --git a/libs/binder/IpPrefix.cpp b/libs/binder/IpPrefix.cpp
deleted file mode 100644
index 4edc493..0000000
--- a/libs/binder/IpPrefix.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "IpPrefix"
-
-#include <binder/IpPrefix.h>
-#include <vector>
-
-#include <binder/IBinder.h>
-#include <binder/Parcel.h>
-#include <log/log.h>
-#include <utils/Errors.h>
-
-using android::BAD_VALUE;
-using android::NO_ERROR;
-using android::Parcel;
-using android::status_t;
-
-namespace android {
-
-namespace net {
-
-#define RETURN_IF_FAILED(calledOnce) \
- { \
- status_t returnStatus = calledOnce; \
- if (returnStatus) { \
- ALOGE("Failed at %s:%d (%s)", __FILE__, __LINE__, __func__); \
- return returnStatus; \
- } \
- }
-
-status_t IpPrefix::writeToParcel(Parcel* parcel) const {
- /*
- * Keep implementation in sync with writeToParcel() in
- * frameworks/base/core/java/android/net/IpPrefix.java.
- */
- std::vector<uint8_t> byte_vector;
-
- if (mIsIpv6) {
- const uint8_t* bytes = reinterpret_cast<const uint8_t*>(&mUnion.mIn6Addr);
- byte_vector.insert(byte_vector.end(), bytes, bytes+sizeof(mUnion.mIn6Addr));
- } else {
- const uint8_t* bytes = reinterpret_cast<const uint8_t*>(&mUnion.mInAddr);
- byte_vector.insert(byte_vector.end(), bytes, bytes+sizeof(mUnion.mIn6Addr));
- }
-
- RETURN_IF_FAILED(parcel->writeByteVector(byte_vector));
- RETURN_IF_FAILED(parcel->writeInt32(static_cast<int32_t>(mPrefixLength)));
-
- return NO_ERROR;
-}
-
-status_t IpPrefix::readFromParcel(const Parcel* parcel) {
- /*
- * Keep implementation in sync with readFromParcel() in
- * frameworks/base/core/java/android/net/IpPrefix.java.
- */
- std::vector<uint8_t> byte_vector;
-
- RETURN_IF_FAILED(parcel->readByteVector(&byte_vector));
- RETURN_IF_FAILED(parcel->readInt32(&mPrefixLength));
-
- if (byte_vector.size() == 16) {
- mIsIpv6 = true;
- memcpy((void*)&mUnion.mIn6Addr, &byte_vector[0], sizeof(mUnion.mIn6Addr));
-
- } else if (byte_vector.size() == 4) {
- mIsIpv6 = false;
- memcpy((void*)&mUnion.mInAddr, &byte_vector[0], sizeof(mUnion.mInAddr));
-
- } else {
- ALOGE("Failed at %s:%d (%s)", __FILE__, __LINE__, __func__); \
- return BAD_VALUE;
- }
-
- return NO_ERROR;
-}
-
-const struct in6_addr& IpPrefix::getAddressAsIn6Addr() const
-{
- return mUnion.mIn6Addr;
-}
-
-const struct in_addr& IpPrefix::getAddressAsInAddr() const
-{
- return mUnion.mInAddr;
-}
-
-bool IpPrefix::getAddressAsIn6Addr(struct in6_addr* addr) const
-{
- if (isIpv6()) {
- *addr = mUnion.mIn6Addr;
- return true;
- }
- return false;
-}
-
-bool IpPrefix::getAddressAsInAddr(struct in_addr* addr) const
-{
- if (isIpv4()) {
- *addr = mUnion.mInAddr;
- return true;
- }
- return false;
-}
-
-bool IpPrefix::isIpv6() const
-{
- return mIsIpv6;
-}
-
-bool IpPrefix::isIpv4() const
-{
- return !mIsIpv6;
-}
-
-int32_t IpPrefix::getPrefixLength() const
-{
- return mPrefixLength;
-}
-
-void IpPrefix::setAddress(const struct in6_addr& addr)
-{
- mUnion.mIn6Addr = addr;
- mIsIpv6 = true;
-}
-
-void IpPrefix::setAddress(const struct in_addr& addr)
-{
- mUnion.mInAddr = addr;
- mIsIpv6 = false;
-}
-
-void IpPrefix::setPrefixLength(int32_t prefix)
-{
- mPrefixLength = prefix;
-}
-
-bool operator==(const IpPrefix& lhs, const IpPrefix& rhs)
-{
- if (lhs.mIsIpv6 != rhs.mIsIpv6) {
- return false;
- }
-
- if (lhs.mPrefixLength != rhs.mPrefixLength) {
- return false;
- }
-
- if (lhs.mIsIpv6) {
- return 0 == memcmp(lhs.mUnion.mIn6Addr.s6_addr, rhs.mUnion.mIn6Addr.s6_addr, sizeof(struct in6_addr));
- }
-
- return 0 == memcmp(&lhs.mUnion.mInAddr, &rhs.mUnion.mInAddr, sizeof(struct in_addr));
-}
-
-} // namespace net
-
-} // namespace android
diff --git a/libs/binder/include/binder/IpPrefix.h b/libs/binder/include/binder/IpPrefix.h
deleted file mode 100644
index a8faa3f..0000000
--- a/libs/binder/include/binder/IpPrefix.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#ifndef __ANDROID_VNDK__
-
-#include <netinet/in.h>
-
-#include <binder/Parcelable.h>
-#include <utils/String16.h>
-#include <utils/StrongPointer.h>
-
-namespace android {
-
-namespace net {
-
-/*
- * C++ implementation of the Java class android.net.IpPrefix
- */
-class IpPrefix : public Parcelable {
-public:
- IpPrefix() = default;
- virtual ~IpPrefix() = default;
- IpPrefix(const IpPrefix& prefix) = default;
-
- IpPrefix(const struct in6_addr& addr, int32_t plen):
- mUnion(addr), mPrefixLength(plen), mIsIpv6(true) { }
-
- IpPrefix(const struct in_addr& addr, int32_t plen):
- mUnion(addr), mPrefixLength(plen), mIsIpv6(false) { }
-
- bool getAddressAsIn6Addr(struct in6_addr* addr) const;
- bool getAddressAsInAddr(struct in_addr* addr) const;
-
- const struct in6_addr& getAddressAsIn6Addr() const;
- const struct in_addr& getAddressAsInAddr() const;
-
- bool isIpv6() const;
- bool isIpv4() const;
-
- int32_t getPrefixLength() const;
-
- void setAddress(const struct in6_addr& addr);
- void setAddress(const struct in_addr& addr);
-
- void setPrefixLength(int32_t prefix);
-
- friend bool operator==(const IpPrefix& lhs, const IpPrefix& rhs);
-
- friend bool operator!=(const IpPrefix& lhs, const IpPrefix& rhs) {
- return !(lhs == rhs);
- }
-
-public:
- // Overrides
- status_t writeToParcel(Parcel* parcel) const override;
- status_t readFromParcel(const Parcel* parcel) override;
-
-private:
- union InternalUnion {
- InternalUnion() = default;
- explicit InternalUnion(const struct in6_addr &addr):mIn6Addr(addr) { }
- explicit InternalUnion(const struct in_addr &addr):mInAddr(addr) { }
- struct in6_addr mIn6Addr;
- struct in_addr mInAddr;
- } mUnion;
- int32_t mPrefixLength;
- bool mIsIpv6;
-};
-
-} // namespace net
-
-} // namespace android
-
-#else // __ANDROID_VNDK__
-#error "This header is not visible to vendors"
-#endif // __ANDROID_VNDK__