From cfe53c2c018eaac7991faa98b144543c8fcd174d Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Tue, 3 Oct 2017 14:37:21 -0700 Subject: otautil: Export headers. Test: mmma bootable/recovery Change-Id: Ic01b68e2a394d578fc9fc09da2dabe9061b98122 --- Android.mk | 1 + otautil/Android.bp | 4 +++ otautil/DirUtil.cpp | 2 +- otautil/DirUtil.h | 39 -------------------------- otautil/SysUtil.cpp | 2 +- otautil/SysUtil.h | 53 ----------------------------------- otautil/ThermalUtil.cpp | 4 +-- otautil/ThermalUtil.h | 24 ---------------- otautil/include/otautil/DirUtil.h | 39 ++++++++++++++++++++++++++ otautil/include/otautil/SysUtil.h | 53 +++++++++++++++++++++++++++++++++++ otautil/include/otautil/ThermalUtil.h | 24 ++++++++++++++++ 11 files changed, 125 insertions(+), 120 deletions(-) delete mode 100644 otautil/DirUtil.h delete mode 100644 otautil/SysUtil.h delete mode 100644 otautil/ThermalUtil.h create mode 100644 otautil/include/otautil/DirUtil.h create mode 100644 otautil/include/otautil/SysUtil.h create mode 100644 otautil/include/otautil/ThermalUtil.h diff --git a/Android.mk b/Android.mk index c55771fbe..ac72bac01 100644 --- a/Android.mk +++ b/Android.mk @@ -56,6 +56,7 @@ endif LOCAL_MODULE := librecovery LOCAL_STATIC_LIBRARIES := \ libminui \ + libotautil \ libvintf_recovery \ libcrypto_utils \ libcrypto \ diff --git a/otautil/Android.bp b/otautil/Android.bp index a2eaa0402..9cde7baa7 100644 --- a/otautil/Android.bp +++ b/otautil/Android.bp @@ -30,4 +30,8 @@ cc_library_static { "-Werror", "-Wall", ], + + export_include_dirs: [ + "include", + ], } diff --git a/otautil/DirUtil.cpp b/otautil/DirUtil.cpp index fffc82219..61c832813 100644 --- a/otautil/DirUtil.cpp +++ b/otautil/DirUtil.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "DirUtil.h" +#include "otautil/DirUtil.h" #include #include diff --git a/otautil/DirUtil.h b/otautil/DirUtil.h deleted file mode 100644 index 85d6c16d1..000000000 --- a/otautil/DirUtil.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef OTAUTIL_DIRUTIL_H_ -#define OTAUTIL_DIRUTIL_H_ - -#include // mode_t - -#include - -struct selabel_handle; - -// Like "mkdir -p", try to guarantee that all directories specified in path are present, creating as -// many directories as necessary. The specified mode is passed to all mkdir calls; no modifications -// are made to umask. -// -// If strip_filename is set, everything after the final '/' is stripped before creating the -// directory -// hierarchy. -// -// Returns 0 on success; returns -1 (and sets errno) on failure (usually if some element of path is -// not a directory). -int mkdir_recursively(const std::string& path, mode_t mode, bool strip_filename, - const struct selabel_handle* sehnd); - -#endif // OTAUTIL_DIRUTIL_H_ diff --git a/otautil/SysUtil.cpp b/otautil/SysUtil.cpp index dfa215073..d54a824d2 100644 --- a/otautil/SysUtil.cpp +++ b/otautil/SysUtil.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "SysUtil.h" +#include "otautil/SysUtil.h" #include #include // SIZE_MAX diff --git a/otautil/SysUtil.h b/otautil/SysUtil.h deleted file mode 100644 index 52f6d20a7..000000000 --- a/otautil/SysUtil.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2006 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. - */ - -#ifndef _OTAUTIL_SYSUTIL -#define _OTAUTIL_SYSUTIL - -#include - -#include -#include - -/* - * Use this to keep track of mapped segments. - */ -class MemMapping { - public: - ~MemMapping(); - // Map a file into a private, read-only memory segment. If 'filename' begins with an '@' - // character, it is a map of blocks to be mapped, otherwise it is treated as an ordinary file. - bool MapFile(const std::string& filename); - size_t ranges() const { - return ranges_.size(); - }; - - unsigned char* addr; // start of data - size_t length; // length of data - - private: - struct MappedRange { - void* addr; - size_t length; - }; - - bool MapBlockFile(const std::string& filename); - bool MapFD(int fd); - - std::vector ranges_; -}; - -#endif // _OTAUTIL_SYSUTIL diff --git a/otautil/ThermalUtil.cpp b/otautil/ThermalUtil.cpp index 13d36432a..5d9bd45c0 100644 --- a/otautil/ThermalUtil.cpp +++ b/otautil/ThermalUtil.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "ThermalUtil.h" +#include "otautil/ThermalUtil.h" #include #include @@ -77,4 +77,4 @@ int GetMaxValueFromThermalZone() { } LOG(INFO) << "current maximum temperature: " << max_temperature; return max_temperature; -} \ No newline at end of file +} diff --git a/otautil/ThermalUtil.h b/otautil/ThermalUtil.h deleted file mode 100644 index 43ab55940..000000000 --- a/otautil/ThermalUtil.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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. - */ - -#ifndef OTAUTIL_THERMALUTIL_H -#define OTAUTIL_THERMALUTIL_H - -// We can find the temperature reported by all sensors in /sys/class/thermal/thermal_zone*/temp. -// Their values are in millidegree Celsius; and we will log the maximum one. -int GetMaxValueFromThermalZone(); - -#endif // OTAUTIL_THERMALUTIL_H diff --git a/otautil/include/otautil/DirUtil.h b/otautil/include/otautil/DirUtil.h new file mode 100644 index 000000000..85d6c16d1 --- /dev/null +++ b/otautil/include/otautil/DirUtil.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2007 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. + */ + +#ifndef OTAUTIL_DIRUTIL_H_ +#define OTAUTIL_DIRUTIL_H_ + +#include // mode_t + +#include + +struct selabel_handle; + +// Like "mkdir -p", try to guarantee that all directories specified in path are present, creating as +// many directories as necessary. The specified mode is passed to all mkdir calls; no modifications +// are made to umask. +// +// If strip_filename is set, everything after the final '/' is stripped before creating the +// directory +// hierarchy. +// +// Returns 0 on success; returns -1 (and sets errno) on failure (usually if some element of path is +// not a directory). +int mkdir_recursively(const std::string& path, mode_t mode, bool strip_filename, + const struct selabel_handle* sehnd); + +#endif // OTAUTIL_DIRUTIL_H_ diff --git a/otautil/include/otautil/SysUtil.h b/otautil/include/otautil/SysUtil.h new file mode 100644 index 000000000..52f6d20a7 --- /dev/null +++ b/otautil/include/otautil/SysUtil.h @@ -0,0 +1,53 @@ +/* + * Copyright 2006 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. + */ + +#ifndef _OTAUTIL_SYSUTIL +#define _OTAUTIL_SYSUTIL + +#include + +#include +#include + +/* + * Use this to keep track of mapped segments. + */ +class MemMapping { + public: + ~MemMapping(); + // Map a file into a private, read-only memory segment. If 'filename' begins with an '@' + // character, it is a map of blocks to be mapped, otherwise it is treated as an ordinary file. + bool MapFile(const std::string& filename); + size_t ranges() const { + return ranges_.size(); + }; + + unsigned char* addr; // start of data + size_t length; // length of data + + private: + struct MappedRange { + void* addr; + size_t length; + }; + + bool MapBlockFile(const std::string& filename); + bool MapFD(int fd); + + std::vector ranges_; +}; + +#endif // _OTAUTIL_SYSUTIL diff --git a/otautil/include/otautil/ThermalUtil.h b/otautil/include/otautil/ThermalUtil.h new file mode 100644 index 000000000..43ab55940 --- /dev/null +++ b/otautil/include/otautil/ThermalUtil.h @@ -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. + */ + +#ifndef OTAUTIL_THERMALUTIL_H +#define OTAUTIL_THERMALUTIL_H + +// We can find the temperature reported by all sensors in /sys/class/thermal/thermal_zone*/temp. +// Their values are in millidegree Celsius; and we will log the maximum one. +int GetMaxValueFromThermalZone(); + +#endif // OTAUTIL_THERMALUTIL_H -- cgit v1.2.3