Merge "Memtrack HAL: Remove MemtrackType::NUM_TYPES"

This commit is contained in:
Kalesh Singh 2021-02-13 22:35:11 +00:00 committed by Gerrit Code Review
commit 5a52686fd6
7 changed files with 103 additions and 41 deletions

View file

@ -1,14 +1,29 @@
///////////////////////////////////////////////////////////////////////////////
/*
* Copyright (C) 2020 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.
*////////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
// edit this file. It looks like you are doing that because you have modified
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
// from an interface or a field from a parcelable and it broke the build. That
// breakage is intended.
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible changes to the AIDL files built
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped

View file

@ -1,14 +1,29 @@
///////////////////////////////////////////////////////////////////////////////
/*
* Copyright (C) 2020 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.
*////////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
// edit this file. It looks like you are doing that because you have modified
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
// from an interface or a field from a parcelable and it broke the build. That
// breakage is intended.
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible changes to the AIDL files built
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped

View file

@ -1,14 +1,29 @@
///////////////////////////////////////////////////////////////////////////////
/*
* Copyright (C) 2020 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.
*////////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
// edit this file. It looks like you are doing that because you have modified
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
// from an interface or a field from a parcelable and it broke the build. That
// breakage is intended.
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible changes to the AIDL files built
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped

View file

@ -1,14 +1,29 @@
///////////////////////////////////////////////////////////////////////////////
/*
* Copyright (C) 2020 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.
*////////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
// edit this file. It looks like you are doing that because you have modified
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
// from an interface or a field from a parcelable and it broke the build. That
// breakage is intended.
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible changes to the AIDL files built
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
@ -23,5 +38,4 @@ enum MemtrackType {
GRAPHICS = 2,
MULTIMEDIA = 3,
CAMERA = 4,
NUM_TYPES = 5,
}

View file

@ -27,5 +27,4 @@ enum MemtrackType {
GRAPHICS = 2,
MULTIMEDIA = 3,
CAMERA = 4,
NUM_TYPES,
}

View file

@ -26,7 +26,8 @@ ndk::ScopedAStatus Memtrack::getMemory(int pid, MemtrackType type,
if (pid < 0) {
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_ILLEGAL_ARGUMENT));
}
if (type < MemtrackType::OTHER || type >= MemtrackType::NUM_TYPES) {
if (type != MemtrackType::OTHER && type != MemtrackType::GL && type != MemtrackType::GRAPHICS &&
type != MemtrackType::MULTIMEDIA && type != MemtrackType::CAMERA) {
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
}
_aidl_return->clear();

View file

@ -46,17 +46,19 @@ class MemtrackAidlTest : public testing::TestWithParam<std::string> {
TEST_P(MemtrackAidlTest, GetMemoryInvalidPid) {
int pid = -1;
MemtrackType type = MemtrackType::OTHER;
std::vector<MemtrackRecord> records;
auto status = memtrack_->getMemory(pid, type, &records);
for (MemtrackType type : ndk::enum_range<MemtrackType>()) {
std::vector<MemtrackRecord> records;
EXPECT_EQ(status.getExceptionCode(), EX_ILLEGAL_ARGUMENT);
auto status = memtrack_->getMemory(pid, type, &records);
EXPECT_EQ(status.getExceptionCode(), EX_ILLEGAL_ARGUMENT);
}
}
TEST_P(MemtrackAidlTest, GetMemoryInvalidType) {
int pid = 1;
MemtrackType type = MemtrackType::NUM_TYPES;
MemtrackType type = static_cast<MemtrackType>(-1);
std::vector<MemtrackRecord> records;
auto status = memtrack_->getMemory(pid, type, &records);
@ -66,12 +68,13 @@ TEST_P(MemtrackAidlTest, GetMemoryInvalidType) {
TEST_P(MemtrackAidlTest, GetMemory) {
int pid = 1;
MemtrackType type = MemtrackType::OTHER;
std::vector<MemtrackRecord> records;
for (MemtrackType type : ndk::enum_range<MemtrackType>()) {
std::vector<MemtrackRecord> records;
auto status = memtrack_->getMemory(pid, type, &records);
auto status = memtrack_->getMemory(pid, type, &records);
EXPECT_TRUE(status.isOk());
EXPECT_TRUE(status.isOk());
}
}
TEST_P(MemtrackAidlTest, GetGpuDeviceInfo) {
@ -87,7 +90,7 @@ TEST_P(MemtrackAidlTest, GetGpuDeviceInfo) {
->getRuntimeInfo(RuntimeInfo::FetchFlag::CPU_VERSION)
->kernelVersion();
EXPECT_LT(kernel_version, min_kernel_version)
<< "Devices with 5.10 or later kernels must implement getGpuDeviceInfo()";
<< "Devices with 5.4 or later kernels must implement getGpuDeviceInfo()";
return;
}