Memtrack HAL: Remove MemtrackType::NUM_TYPES
Remove NUM_TYPES from MemtrackType enum, since this can cause conflicts if the enum changes. Use enum_range to iterate the MemtrackType enum. Bug: 179432507 Test: atest VtsHalMemtrackTargetTest Change-Id: Iadad3e0547c1c2f6aaf0f55a2d50e4c625a909e0
This commit is contained in:
parent
709382fcc5
commit
1bcbf85110
7 changed files with 103 additions and 41 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -27,5 +27,4 @@ enum MemtrackType {
|
|||
GRAPHICS = 2,
|
||||
MULTIMEDIA = 3,
|
||||
CAMERA = 4,
|
||||
NUM_TYPES,
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue