upload android base code part6

This commit is contained in:
August 2018-08-08 17:48:24 +08:00
parent 421e214c7d
commit 4e516ec6ed
35396 changed files with 9188716 additions and 0 deletions

View file

@ -0,0 +1,24 @@
#
# Copyright (C) 2017 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.
#
BasedOnStyle: Google
CommentPragmas: NOLINT:.*
DerivePointerAlignment: false
AllowShortFunctionsOnASingleLine: Inline
ColumnLimit: 100
TabWidth: 4
UseTab: Never
IndentWidth: 4

View file

@ -0,0 +1,7 @@
// This is an autogenerated file, do not edit.
subdirs = [
"net/netd/1.0",
"net/netd/1.0/vts/functional",
"wifi/keystore/1.0",
"wifi/keystore/1.0/vts/functional",
]

View file

@ -0,0 +1,5 @@
elsk@google.com
hridya@google.com
maco@google.com
malchev@google.com
smoreland@google.com

View file

@ -0,0 +1,5 @@
[Options]
ignore_merged_commits = true
[Builtin Hooks]
clang_format = true

View file

@ -0,0 +1,10 @@
# Do not change this file except to add new interfaces. Changing
# pre-existing interfaces will fail VTS and break framework-only OTAs
# Frameworks HALs released in Android O
b0ff0dc756845dd132f998e8c55f1a0d7e3efd8aa85f6253776fb7012814524b android.system.wifi.keystore@1.0::IKeystore
# Frameworks HALs released in Android O-MR1
2cfd7918acf09462fe8fe3f5608be2956c9f737c78d3bb3f176cc5531c09f5d6 android.system.net.netd@1.0::INetd

View file

@ -0,0 +1,62 @@
// This file is autogenerated by hidl-gen. Do not edit manually.
filegroup {
name: "android.system.net.netd@1.0_hal",
srcs: [
"INetd.hal",
],
}
genrule {
name: "android.system.net.netd@1.0_genc++",
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hidl:system/libhidl/transport -randroid.system:system/hardware/interfaces android.system.net.netd@1.0",
srcs: [
":android.system.net.netd@1.0_hal",
],
out: [
"android/system/net/netd/1.0/NetdAll.cpp",
],
}
genrule {
name: "android.system.net.netd@1.0_genc++_headers",
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hidl:system/libhidl/transport -randroid.system:system/hardware/interfaces android.system.net.netd@1.0",
srcs: [
":android.system.net.netd@1.0_hal",
],
out: [
"android/system/net/netd/1.0/INetd.h",
"android/system/net/netd/1.0/IHwNetd.h",
"android/system/net/netd/1.0/BnHwNetd.h",
"android/system/net/netd/1.0/BpHwNetd.h",
"android/system/net/netd/1.0/BsNetd.h",
],
}
cc_library {
name: "android.system.net.netd@1.0",
defaults: ["hidl-module-defaults"],
generated_sources: ["android.system.net.netd@1.0_genc++"],
generated_headers: ["android.system.net.netd@1.0_genc++_headers"],
export_generated_headers: ["android.system.net.netd@1.0_genc++_headers"],
vendor_available: true,
vndk: {
enabled: true,
},
shared_libs: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"liblog",
"libutils",
"libcutils",
],
export_shared_lib_headers: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"libutils",
],
}

View file

@ -0,0 +1,58 @@
/*
* Copyright 2017 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.
*/
package android.system.net.netd@1.0;
/**
* This is the root of the HAL module and is the interface returned when
* loading an implementation of the INetd HAL.
*/
interface INetd {
/**
* Return values for INetd requests
*/
enum StatusCode : int32_t {
OK,
INVALID_ARGUMENTS,
NO_NETWORK,
ALREADY_EXISTS,
PERMISSION_DENIED,
UNKNOWN_ERROR
};
/**
* Creates a physical network to be used for interfaces managed by the OEM
*
* @return networkHandle a handle to the OEM network. Zero implies
* no networks are available and created
* @return packetMark The packet mark that vendor network stack configuration code must use when
* routing packets to this network. No applications may use this mark. They must
* instead pass the networkHandle to the android_set*network LL-NDK APIs.
* @return status operation status
*/
@entry
@callflow(next={"*"})
createOemNetwork() generates (uint64_t networkHandle, uint32_t packetMark, StatusCode status);
/**
* Destroys the specified network previously created using createOemNetwork()
*
* @return status operation status
*/
@exit
@callflow(next="createOemNetwork")
destroyOemNetwork(uint64_t networkHandle) generates (StatusCode status);
};

View file

@ -0,0 +1,18 @@
cc_test {
name: "VtsHalNetNetdV1_0TargetTest",
srcs: [
"VtsHalNetNetdV1_0TargetTest.cpp",
],
shared_libs: [
"liblog",
"libhidlbase",
"libhidltransport",
"libutils",
"android.system.net.netd@1.0",
],
static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
],
}

View file

@ -0,0 +1,65 @@
/*
* Copyright 2017 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 "netd_hidl_test"
#include <VtsHalHidlTargetTestBase.h>
#include <android/system/net/netd/1.0/INetd.h>
#include <log/log.h>
using ::android::system::net::netd::V1_0::INetd;
using ::android::hardware::Return;
using ::android::sp;
class NetdHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
netd = ::testing::VtsHalHidlTargetTestBase::getService<INetd>();
ASSERT_NE(nullptr, netd.get()) << "Could not get HIDL instance";
}
sp<INetd> netd;
};
// positive test. Ensure netd creates an oem network and returns valid netHandle, and destroys it.
TEST_F(NetdHidlTest, TestCreateAndDestroyOemNetworkOk) {
auto cb = [this](uint64_t netHandle, uint32_t packetMark, INetd::StatusCode status) {
ASSERT_EQ(INetd::StatusCode::OK, status);
ASSERT_NE((uint64_t)0, netHandle);
ASSERT_NE((uint32_t)0, packetMark);
Return<INetd::StatusCode> retStatus = netd->destroyOemNetwork(netHandle);
ASSERT_EQ(INetd::StatusCode::OK, retStatus);
};
Return<void> ret = netd->createOemNetwork(cb);
ASSERT_TRUE(ret.isOk());
}
// negative test. Ensure destroy for invalid OEM network fails appropriately
TEST_F(NetdHidlTest, TestDestroyOemNetworkInvalid) {
const uint64_t nh = 0x6600FACADE;
Return<INetd::StatusCode> retStatus = netd->destroyOemNetwork(nh);
ASSERT_EQ(INetd::StatusCode::INVALID_ARGUMENTS, retStatus);
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
int status = RUN_ALL_TESTS();
ALOGE("Test result with status=%d", status);
return status;
}

View file

@ -0,0 +1,8 @@
#!/bin/bash
source $ANDROID_BUILD_TOP/system/tools/hidl/update-makefiles-helper.sh
do_makefiles_update \
"android.system:system/hardware/interfaces" \
"android.hidl:system/libhidl/transport"

View file

@ -0,0 +1,62 @@
// This file is autogenerated by hidl-gen. Do not edit manually.
filegroup {
name: "android.system.wifi.keystore@1.0_hal",
srcs: [
"IKeystore.hal",
],
}
genrule {
name: "android.system.wifi.keystore@1.0_genc++",
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hidl:system/libhidl/transport -randroid.system:system/hardware/interfaces android.system.wifi.keystore@1.0",
srcs: [
":android.system.wifi.keystore@1.0_hal",
],
out: [
"android/system/wifi/keystore/1.0/KeystoreAll.cpp",
],
}
genrule {
name: "android.system.wifi.keystore@1.0_genc++_headers",
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hidl:system/libhidl/transport -randroid.system:system/hardware/interfaces android.system.wifi.keystore@1.0",
srcs: [
":android.system.wifi.keystore@1.0_hal",
],
out: [
"android/system/wifi/keystore/1.0/IKeystore.h",
"android/system/wifi/keystore/1.0/IHwKeystore.h",
"android/system/wifi/keystore/1.0/BnHwKeystore.h",
"android/system/wifi/keystore/1.0/BpHwKeystore.h",
"android/system/wifi/keystore/1.0/BsKeystore.h",
],
}
cc_library {
name: "android.system.wifi.keystore@1.0",
defaults: ["hidl-module-defaults"],
generated_sources: ["android.system.wifi.keystore@1.0_genc++"],
generated_headers: ["android.system.wifi.keystore@1.0_genc++_headers"],
export_generated_headers: ["android.system.wifi.keystore@1.0_genc++_headers"],
vendor_available: true,
vndk: {
enabled: true,
},
shared_libs: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"liblog",
"libutils",
"libcutils",
],
export_shared_lib_headers: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"libutils",
],
}

View file

@ -0,0 +1,76 @@
/*
* Copyright 2017 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.
*/
package android.system.wifi.keystore@1.0;
/**
* This is the root of the HAL module and is the interface returned when
* loading an implementation of the Wi-Fi HAL. There must be at most one
* module loaded in the system.
*/
interface IKeystore {
/**
* Return values for Keystore requests.
*/
enum KeystoreStatusCode : uint32_t {
/** No errors. */
SUCCESS,
ERROR_UNKNOWN
};
/**
* Requests a binary blob from the keystore's key-value store.
*
* @param key the key into the keystore.
* @return status KeystoreStatusCode of the operation.
* Possible status codes:
* |KeystoreStatusCode.SUCCESS|,
* |KeystoreStatusCode.ERROR_UNKNOWN|
* @return value the value associated with |key| in the keystore.
*/
getBlob(string key)
generates (KeystoreStatusCode status, vec<uint8_t> value);
/**
* Requests the public key associated with the credential referred to by
* |keyId|.
*
* @param keyId the key identifier associated with the credential.
* @return status KeystoreStatusCode of the operation.
* Possible status codes:
* |KeystoreStatusCode.SUCCESS|,
* |KeystoreStatusCode.ERROR_UNKNOWN|
* @return publicKey the public key associated with the credential.
*/
getPublicKey(string keyId)
generates (KeystoreStatusCode status, vec<uint8_t> publicKey);
/**
* Signs the digest in |dataToSign| with the private key associated with
* the credential identified by |keyId|. This is a raw RSA or ECDSA
* operation that assumes |dataToSign| is already propertly digested and
* padded if necessary for the type of key.
*
* @param keyId the key identifier associated with the credential.
* @return status KeystoreStatusCode of the operation.
* Possible status codes:
* |KeystoreStatusCode.SUCCESS|,
* |KeystoreStatusCode.UNKNOWN|
* @return signedData the signed data.
*/
sign(string keyId, vec<uint8_t> dataToSign)
generates (KeystoreStatusCode status, vec<uint8_t> signedData);
};

View file

@ -0,0 +1,33 @@
# Copyright (C) 2017 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.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libwifikeystorehal
LOCAL_CPPFLAGS := -Wall -Werror -Wextra
LOCAL_SRC_FILES := \
keystore.cpp
LOCAL_SHARED_LIBRARIES := \
android.system.wifi.keystore@1.0 \
libbase \
libbinder \
libcutils \
libhidlbase \
libhidltransport \
libkeystore_binder \
liblog \
libutils
LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(LOCAL_PATH)/include
include $(BUILD_SHARED_LIBRARY)

View file

@ -0,0 +1,49 @@
#ifndef ANDROID_SYSTEM_WIFI_KEYSTORE_V1_0_KEYSTORE_H
#define ANDROID_SYSTEM_WIFI_KEYSTORE_V1_0_KEYSTORE_H
#include <android/system/wifi/keystore/1.0/IKeystore.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <keystore/IKeystoreService.h>
#include <binder/IServiceManager.h>
namespace android {
namespace system {
namespace wifi {
namespace keystore {
namespace V1_0 {
namespace implementation {
using ::android::hidl::base::V1_0::DebugInfo;
using ::android::hidl::base::V1_0::IBase;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
using ::android::system::wifi::keystore::V1_0::IKeystore;
struct Keystore : public IKeystore {
public:
// Methods from ::android::hardware::wifi::keystore::V1_0::IKeystore follow.
Return<void> getBlob(const hidl_string& key, getBlob_cb _hidl_cb) override;
Return<void> getPublicKey(
const hidl_string& keyId, getPublicKey_cb _hidl_cb) override;
Return<void> sign(
const hidl_string& keyId, const hidl_vec<uint8_t>& dataToSign,
sign_cb _hidl_cb) override;
};
extern "C" IKeystore* HIDL_FETCH_IKeystore(const char* name);
} // namespace implementation
} // namespace V1_0
} // namespace keystore
} // namespace wifi
} // namespace system
} // namespace android
#endif // ANDROID_SYSTEM_WIFI_KEYSTORE_V1_0_KEYSTORE_H

View file

@ -0,0 +1,81 @@
#include <android-base/logging.h>
#include <binder/IServiceManager.h>
#include <keystore/IKeystoreService.h>
#include <private/android_filesystem_config.h>
#include "include/wifikeystorehal/keystore.h"
namespace android {
namespace system {
namespace wifi {
namespace keystore {
namespace V1_0 {
namespace implementation {
// Methods from ::android::hardware::wifi::keystore::V1_0::IKeystore follow.
Return<void> Keystore::getBlob(const hidl_string& key, getBlob_cb _hidl_cb) {
sp<IKeystoreService> service = interface_cast<IKeystoreService>(
defaultServiceManager()->getService(
String16("android.security.keystore")));
if (service == nullptr) {
_hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {});
return Void();
}
hidl_vec<uint8_t> value;
// Retrieve the blob as wifi user.
auto ret = service->get(String16(key.c_str()), AID_WIFI, &value);
if (!ret.isOk()) {
_hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {});
return Void();
}
_hidl_cb(KeystoreStatusCode::SUCCESS, value);
return Void();
}
Return<void> Keystore::getPublicKey(
const hidl_string& keyId, getPublicKey_cb _hidl_cb) {
sp<IKeystoreService> service = interface_cast<IKeystoreService>(
defaultServiceManager()->getService(
String16("android.security.keystore")));
if (service == nullptr) {
_hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {});
return Void();
}
hidl_vec<uint8_t> pubkey;
auto ret = service->get_pubkey(String16(keyId.c_str()), &pubkey);
if (!ret.isOk()) {
_hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {});
return Void();
}
_hidl_cb(KeystoreStatusCode::SUCCESS, pubkey);
return Void();
}
Return<void> Keystore::sign(
const hidl_string& keyId, const hidl_vec<uint8_t>& dataToSign,
sign_cb _hidl_cb) {
sp<IKeystoreService> service = interface_cast<IKeystoreService>(
defaultServiceManager()->getService(
String16("android.security.keystore")));
if (service == nullptr) {
_hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {});
return Void();
}
hidl_vec<uint8_t> signedData;
auto ret = service->sign(String16(keyId.c_str()), dataToSign, &signedData);
if (!ret.isOk()) {
_hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {});
return Void();
}
_hidl_cb(KeystoreStatusCode::SUCCESS, signedData);
return Void();
}
IKeystore* HIDL_FETCH_IKeystore(const char* /* name */) {
return new Keystore();
}
} // namespace implementation
} // namespace V1_0
} // namespace keystore
} // namespace wifi
} // namespace system
} // namespace android

View file

@ -0,0 +1,37 @@
//
// Copyright (C) 2017 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.
//
cc_test {
name: "VtsHalWifiKeystoreV1_0TargetTest",
srcs: [
"VtsHalWifiKeystoreV1_0TargetTest.cpp",
],
shared_libs: [
"libbase",
"liblog",
"libcutils",
"libhidlbase",
"libhidltransport",
"libnativehelper",
"libutils",
"android.system.wifi.keystore@1.0",
],
static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
],
}

View file

@ -0,0 +1,26 @@
/*
* Copyright (C) 2017 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.
*/
#include <android-base/logging.h>
#include <VtsHalHidlTargetTestBase.h>
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
return status;
}