Merge "init: only provide control message results for devices launching > Q"
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index 06c8176..57ed362 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -200,9 +200,7 @@
return value;
}
-bool BatteryMonitor::update(void) {
- bool logthis;
-
+void BatteryMonitor::updateValues(void) {
initBatteryProperties(&props);
if (!mHealthdConfig->batteryPresentPath.isEmpty())
@@ -289,50 +287,44 @@
}
}
}
+}
- logthis = !healthd_board_battery_update(&props);
+void BatteryMonitor::logValues(void) {
+ char dmesgline[256];
+ size_t len;
+ if (props.batteryPresent) {
+ snprintf(dmesgline, sizeof(dmesgline), "battery l=%d v=%d t=%s%d.%d h=%d st=%d",
+ props.batteryLevel, props.batteryVoltage, props.batteryTemperature < 0 ? "-" : "",
+ abs(props.batteryTemperature / 10), abs(props.batteryTemperature % 10),
+ props.batteryHealth, props.batteryStatus);
- if (logthis) {
- char dmesgline[256];
- size_t len;
- if (props.batteryPresent) {
- snprintf(dmesgline, sizeof(dmesgline),
- "battery l=%d v=%d t=%s%d.%d h=%d st=%d",
- props.batteryLevel, props.batteryVoltage,
- props.batteryTemperature < 0 ? "-" : "",
- abs(props.batteryTemperature / 10),
- abs(props.batteryTemperature % 10), props.batteryHealth,
- props.batteryStatus);
-
- len = strlen(dmesgline);
- if (!mHealthdConfig->batteryCurrentNowPath.isEmpty()) {
- len += snprintf(dmesgline + len, sizeof(dmesgline) - len,
- " c=%d", props.batteryCurrent);
- }
-
- if (!mHealthdConfig->batteryFullChargePath.isEmpty()) {
- len += snprintf(dmesgline + len, sizeof(dmesgline) - len,
- " fc=%d", props.batteryFullCharge);
- }
-
- if (!mHealthdConfig->batteryCycleCountPath.isEmpty()) {
- len += snprintf(dmesgline + len, sizeof(dmesgline) - len,
- " cc=%d", props.batteryCycleCount);
- }
- } else {
- len = snprintf(dmesgline, sizeof(dmesgline),
- "battery none");
+ len = strlen(dmesgline);
+ if (!mHealthdConfig->batteryCurrentNowPath.isEmpty()) {
+ len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " c=%d",
+ props.batteryCurrent);
}
- snprintf(dmesgline + len, sizeof(dmesgline) - len, " chg=%s%s%s",
- props.chargerAcOnline ? "a" : "",
- props.chargerUsbOnline ? "u" : "",
- props.chargerWirelessOnline ? "w" : "");
+ if (!mHealthdConfig->batteryFullChargePath.isEmpty()) {
+ len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " fc=%d",
+ props.batteryFullCharge);
+ }
- KLOG_WARNING(LOG_TAG, "%s\n", dmesgline);
+ if (!mHealthdConfig->batteryCycleCountPath.isEmpty()) {
+ len += snprintf(dmesgline + len, sizeof(dmesgline) - len, " cc=%d",
+ props.batteryCycleCount);
+ }
+ } else {
+ len = snprintf(dmesgline, sizeof(dmesgline), "battery none");
}
- healthd_mode_ops->battery_update(&props);
+ snprintf(dmesgline + len, sizeof(dmesgline) - len, " chg=%s%s%s",
+ props.chargerAcOnline ? "a" : "", props.chargerUsbOnline ? "u" : "",
+ props.chargerWirelessOnline ? "w" : "");
+
+ KLOG_WARNING(LOG_TAG, "%s\n", dmesgline);
+}
+
+bool BatteryMonitor::isChargerOnline() {
return props.chargerAcOnline | props.chargerUsbOnline |
props.chargerWirelessOnline;
}
diff --git a/healthd/include/healthd/BatteryMonitor.h b/healthd/include/healthd/BatteryMonitor.h
index 4d1d53f..0fd3824 100644
--- a/healthd/include/healthd/BatteryMonitor.h
+++ b/healthd/include/healthd/BatteryMonitor.h
@@ -38,12 +38,15 @@
BatteryMonitor();
void init(struct healthd_config *hc);
- bool update(void);
int getChargeStatus();
status_t getProperty(int id, struct BatteryProperty *val);
void dumpState(int fd);
friend struct BatteryProperties getBatteryProperties(BatteryMonitor* batteryMonitor);
+ void updateValues(void);
+ void logValues(void);
+ bool isChargerOnline();
+
private:
struct healthd_config *mHealthdConfig;
Vector<String8> mChargerNames;
diff --git a/libcutils/trace-dev.inc b/libcutils/trace-dev.inc
index e3da77b..fc7a870 100644
--- a/libcutils/trace-dev.inc
+++ b/libcutils/trace-dev.inc
@@ -32,7 +32,6 @@
#include <cutils/properties.h>
#include <cutils/trace.h>
#include <log/log.h>
-#include <log/log_properties.h>
/**
* Maximum size of a message that can be logged to the trace buffer.
diff --git a/liblog/include_vndk/log/log.h b/liblog/include_vndk/log/log.h
index a79beec..393b480 100644
--- a/liblog/include_vndk/log/log.h
+++ b/liblog/include_vndk/log/log.h
@@ -1,13 +1,11 @@
/*Special log.h file for VNDK linking modules*/
-#ifndef _LIBS_LOG_LOG_H
-#define _LIBS_LOG_LOG_H
+#pragma once
#include <android/log.h>
#include <log/log_id.h>
#include <log/log_main.h>
#include <log/log_radio.h>
-#include <log/log_read.h>
#include <log/log_safetynet.h>
#include <log/log_system.h>
#include <log/log_time.h>
@@ -22,4 +20,16 @@
#define LOG_TAG NULL
#endif
-#endif /*_LIBS_LOG_LOG_H*/
+// Legacy dependencies...
+/* deal with possible sys/cdefs.h conflict with fcntl.h */
+#ifdef __unused
+#define __unused_defined __unused
+#undef __unused
+#endif
+
+#include <fcntl.h> /* Pick up O_* macros */
+
+/* restore definitions from above */
+#ifdef __unused_defined
+#define __unused __attribute__((__unused__))
+#endif
diff --git a/liblog/include_vndk/log/log_event_list.h b/liblog/include_vndk/log/log_event_list.h
index 1f3dd37..81c879f 100644
--- a/liblog/include_vndk/log/log_event_list.h
+++ b/liblog/include_vndk/log/log_event_list.h
@@ -16,8 +16,7 @@
/* Special log_event_list.h file for VNDK linking modules */
-#ifndef _LIBS_LOG_EVENT_LIST_H
-#define _LIBS_LOG_EVENT_LIST_H
+#pragma once
#include <stdint.h>
@@ -30,10 +29,7 @@
/*
* The opaque context used to manipulate lists of events.
*/
-#ifndef __android_log_context_defined
-#define __android_log_context_defined
typedef struct android_log_context_internal* android_log_context;
-#endif
/*
* Creates a context associated with an event tag to write elements to
@@ -61,18 +57,9 @@
/* NB: LOG_ID_EVENTS and LOG_ID_SECURITY only valid binary buffers */
int android_log_write_list(android_log_context ctx, log_id_t id);
-/* Reset writer context */
-int android_log_reset(android_log_context ctx);
-
-/* Reset reader context */
-int android_log_parser_reset(android_log_context ctx,
- const char* msg, size_t len);
-
/* Finished with reader or writer context */
int android_log_destroy(android_log_context* ctx);
#ifdef __cplusplus
}
#endif
-
-#endif /* _LIBS_LOG_EVENT_LIST_H */
diff --git a/liblog/include_vndk/log/log_id.h b/liblog/include_vndk/log/log_id.h
deleted file mode 120000
index dce92b9..0000000
--- a/liblog/include_vndk/log/log_id.h
+++ /dev/null
@@ -1 +0,0 @@
-../../include/log/log_id.h
\ No newline at end of file
diff --git a/liblog/include_vndk/log/log_id.h b/liblog/include_vndk/log/log_id.h
new file mode 100644
index 0000000..3c6df8b
--- /dev/null
+++ b/liblog/include_vndk/log/log_id.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2005-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.
+ */
+
+#pragma once
+
+#include <android/log.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Send a simple string to the log.
+ */
+int __android_log_buf_write(int bufID, int prio, const char* tag, const char* text);
+int __android_log_buf_print(int bufID, int prio, const char* tag, const char* fmt, ...)
+ __attribute__((__format__(printf, 4, 5)));
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/liblog/include_vndk/log/log_properties.h b/liblog/include_vndk/log/log_properties.h
deleted file mode 120000
index bbec426..0000000
--- a/liblog/include_vndk/log/log_properties.h
+++ /dev/null
@@ -1 +0,0 @@
-../../include/log/log_properties.h
\ No newline at end of file
diff --git a/liblog/include_vndk/log/log_read.h b/liblog/include_vndk/log/log_read.h
deleted file mode 120000
index 01de8b9..0000000
--- a/liblog/include_vndk/log/log_read.h
+++ /dev/null
@@ -1 +0,0 @@
-../../include/log/log_read.h
\ No newline at end of file
diff --git a/liblog/include_vndk/log/log_time.h b/liblog/include_vndk/log/log_time.h
index 5a09959..014af08 100644
--- a/liblog/include_vndk/log/log_time.h
+++ b/liblog/include_vndk/log/log_time.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef _LIBS_LOG_LOG_TIME_H
-#define _LIBS_LOG_LOG_TIME_H
+#pragma once
#include <stdint.h>
@@ -30,9 +29,6 @@
#define MS_PER_SEC 1000ULL
#endif
-#ifndef __struct_log_time_defined
-#define __struct_log_time_defined
-
#define LOG_TIME_SEC(t) ((t)->tv_sec)
/* next power of two after NS_PER_SEC */
#define LOG_TIME_NSEC(t) ((t)->tv_nsec & (UINT32_MAX >> 2))
@@ -41,7 +37,3 @@
uint32_t tv_sec;
uint32_t tv_nsec;
} __attribute__((__packed__)) log_time;
-
-#endif
-
-#endif /* _LIBS_LOG_LOG_TIME_H */
diff --git a/liblog/liblog.map.txt b/liblog/liblog.map.txt
index ce4c53c..ece8b75 100644
--- a/liblog/liblog.map.txt
+++ b/liblog/liblog.map.txt
@@ -1,7 +1,5 @@
LIBLOG {
global:
- android_name_to_log_id; # vndk
- android_log_id_to_name; # vndk
__android_log_assert;
__android_log_buf_print;
__android_log_buf_write;
@@ -14,25 +12,15 @@
LIBLOG_L {
global:
- android_logger_clear; # vndk
- android_logger_get_id; # vndk
- android_logger_get_log_readable_size; # vndk
- android_logger_get_log_version; # vndk
- android_logger_get_log_size; # vndk
- android_logger_list_alloc; # apex vndk
- android_logger_list_alloc_time; # apex vndk
- android_logger_list_free; # apex vndk
- android_logger_list_open; # vndk
- android_logger_list_read; # apex vndk
- android_logger_open; # apex vndk
- android_logger_set_log_size; # vndk
+ android_logger_list_alloc; # apex
+ android_logger_list_alloc_time; # apex
+ android_logger_list_free; # apex
+ android_logger_list_read; # apex
+ android_logger_open; # apex
};
LIBLOG_M {
global:
- android_logger_get_prune_list; # vndk
- android_logger_set_prune_list; # vndk
- android_logger_get_statistics; # vndk
__android_log_error_write; # apex vndk
__android_log_is_loggable;
create_android_logger; # apex vndk
@@ -51,7 +39,6 @@
LIBLOG_O {
global:
__android_log_is_loggable_len;
- __android_log_is_debuggable; # vndk
};
LIBLOG_Q {
@@ -61,21 +48,24 @@
__android_log_bwrite; # apex
__android_log_close; # apex
__android_log_security; # apex
- android_log_reset; #vndk
- android_log_parser_reset; #vndk
};
LIBLOG_PRIVATE {
global:
+ __android_log_is_debuggable;
__android_log_pmsg_file_read;
__android_log_pmsg_file_write;
__android_log_security_bswrite;
__android_logger_get_buffer_size;
__android_logger_property_get_bool;
+ android_name_to_log_id;
android_openEventTagMap;
+ android_logger_list_open;
+ android_log_id_to_name;
android_log_processBinaryLogBuffer;
android_log_processLogBuffer;
android_log_read_next;
+ android_log_reset;
android_log_write_list_buffer;
android_lookupEventTagNum;
create_android_log_parser;
diff --git a/libunwindstack/Android.bp b/libunwindstack/Android.bp
index b0f3786..2573b1c 100644
--- a/libunwindstack/Android.bp
+++ b/libunwindstack/Android.bp
@@ -239,6 +239,7 @@
"tests/files/offline/bad_eh_frame_hdr_arm64/*",
"tests/files/offline/debug_frame_first_x86/*",
"tests/files/offline/debug_frame_load_bias_arm/*",
+ "tests/files/offline/eh_frame_bias_x86/*",
"tests/files/offline/eh_frame_hdr_begin_x86_64/*",
"tests/files/offline/invalid_elf_offset_arm/*",
"tests/files/offline/jit_debug_arm/*",
diff --git a/libunwindstack/ElfInterface.cpp b/libunwindstack/ElfInterface.cpp
index e34273c..e863f22 100644
--- a/libunwindstack/ElfInterface.cpp
+++ b/libunwindstack/ElfInterface.cpp
@@ -228,7 +228,7 @@
case PT_GNU_EH_FRAME:
// This is really the pointer to the .eh_frame_hdr section.
eh_frame_hdr_offset_ = phdr.p_offset;
- eh_frame_hdr_section_bias_ = static_cast<uint64_t>(phdr.p_paddr) - phdr.p_offset;
+ eh_frame_hdr_section_bias_ = static_cast<uint64_t>(phdr.p_vaddr) - phdr.p_offset;
eh_frame_hdr_size_ = phdr.p_memsz;
break;
diff --git a/libunwindstack/tests/ElfInterfaceTest.cpp b/libunwindstack/tests/ElfInterfaceTest.cpp
index b048b17..ea27e3e 100644
--- a/libunwindstack/tests/ElfInterfaceTest.cpp
+++ b/libunwindstack/tests/ElfInterfaceTest.cpp
@@ -1310,7 +1310,7 @@
memset(&phdr, 0, sizeof(phdr));
phdr.p_type = PT_GNU_EH_FRAME;
- phdr.p_paddr = addr;
+ phdr.p_vaddr = addr;
phdr.p_offset = offset;
memory_.SetMemory(phdr_offset, &phdr, sizeof(phdr));
diff --git a/libunwindstack/tests/UnwindOfflineTest.cpp b/libunwindstack/tests/UnwindOfflineTest.cpp
index 72eef3e..0d58c09 100644
--- a/libunwindstack/tests/UnwindOfflineTest.cpp
+++ b/libunwindstack/tests/UnwindOfflineTest.cpp
@@ -1583,4 +1583,50 @@
EXPECT_EQ(0x7fdd4a4170ULL, unwinder.frames()[11].sp);
}
+TEST_F(UnwindOfflineTest, eh_frame_bias_x86) {
+ ASSERT_NO_FATAL_FAILURE(Init("eh_frame_bias_x86/", ARCH_X86));
+
+ Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
+ unwinder.Unwind();
+
+ std::string frame_info(DumpFrames(unwinder));
+ ASSERT_EQ(11U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
+ EXPECT_EQ(
+ " #00 pc ffffe430 vdso.so (__kernel_vsyscall+16)\n"
+ " #01 pc 00082a4b libc.so (__epoll_pwait+43)\n"
+ " #02 pc 000303a3 libc.so (epoll_pwait+115)\n"
+ " #03 pc 000303ed libc.so (epoll_wait+45)\n"
+ " #04 pc 00010ea2 tombstoned (epoll_dispatch+226)\n"
+ " #05 pc 0000c5e7 tombstoned (event_base_loop+1095)\n"
+ " #06 pc 0000c193 tombstoned (event_base_dispatch+35)\n"
+ " #07 pc 00005c77 tombstoned (main+884)\n"
+ " #08 pc 00015f66 libc.so (__libc_init+102)\n"
+ " #09 pc 0000360e tombstoned (_start+98)\n"
+ " #10 pc 00000001 <unknown>\n",
+ frame_info);
+
+ EXPECT_EQ(0xffffe430ULL, unwinder.frames()[0].pc);
+ EXPECT_EQ(0xfffe1a30ULL, unwinder.frames()[0].sp);
+ EXPECT_EQ(0xeb585a4bULL, unwinder.frames()[1].pc);
+ EXPECT_EQ(0xfffe1a40ULL, unwinder.frames()[1].sp);
+ EXPECT_EQ(0xeb5333a3ULL, unwinder.frames()[2].pc);
+ EXPECT_EQ(0xfffe1a60ULL, unwinder.frames()[2].sp);
+ EXPECT_EQ(0xeb5333edULL, unwinder.frames()[3].pc);
+ EXPECT_EQ(0xfffe1ab0ULL, unwinder.frames()[3].sp);
+ EXPECT_EQ(0xeb841ea2ULL, unwinder.frames()[4].pc);
+ EXPECT_EQ(0xfffe1ae0ULL, unwinder.frames()[4].sp);
+ EXPECT_EQ(0xeb83d5e7ULL, unwinder.frames()[5].pc);
+ EXPECT_EQ(0xfffe1b30ULL, unwinder.frames()[5].sp);
+ EXPECT_EQ(0xeb83d193ULL, unwinder.frames()[6].pc);
+ EXPECT_EQ(0xfffe1bd0ULL, unwinder.frames()[6].sp);
+ EXPECT_EQ(0xeb836c77ULL, unwinder.frames()[7].pc);
+ EXPECT_EQ(0xfffe1c00ULL, unwinder.frames()[7].sp);
+ EXPECT_EQ(0xeb518f66ULL, unwinder.frames()[8].pc);
+ EXPECT_EQ(0xfffe1d00ULL, unwinder.frames()[8].sp);
+ EXPECT_EQ(0xeb83460eULL, unwinder.frames()[9].pc);
+ EXPECT_EQ(0xfffe1d40ULL, unwinder.frames()[9].sp);
+ EXPECT_EQ(0x00000001ULL, unwinder.frames()[10].pc);
+ EXPECT_EQ(0xfffe1d74ULL, unwinder.frames()[10].sp);
+}
+
} // namespace unwindstack
diff --git a/libunwindstack/tests/files/offline/eh_frame_bias_x86/libc.so b/libunwindstack/tests/files/offline/eh_frame_bias_x86/libc.so
new file mode 100644
index 0000000..f3eb615
--- /dev/null
+++ b/libunwindstack/tests/files/offline/eh_frame_bias_x86/libc.so
Binary files differ
diff --git a/libunwindstack/tests/files/offline/eh_frame_bias_x86/maps.txt b/libunwindstack/tests/files/offline/eh_frame_bias_x86/maps.txt
new file mode 100644
index 0000000..7d52483
--- /dev/null
+++ b/libunwindstack/tests/files/offline/eh_frame_bias_x86/maps.txt
@@ -0,0 +1,3 @@
+eb503000-eb5e8000 r-xp 0 00:00 0 libc.so
+eb831000-eb852000 r-xp 0 00:00 0 tombstoned
+ffffe000-fffff000 r-xp 0 00:00 0 vdso.so
diff --git a/libunwindstack/tests/files/offline/eh_frame_bias_x86/regs.txt b/libunwindstack/tests/files/offline/eh_frame_bias_x86/regs.txt
new file mode 100644
index 0000000..821928e
--- /dev/null
+++ b/libunwindstack/tests/files/offline/eh_frame_bias_x86/regs.txt
@@ -0,0 +1,9 @@
+eax: fffffffc
+ebx: 4
+ecx: eb290180
+edx: 20
+ebp: 8
+edi: 0
+esi: ffffffff
+esp: fffe1a30
+eip: ffffe430
diff --git a/libunwindstack/tests/files/offline/eh_frame_bias_x86/stack.data b/libunwindstack/tests/files/offline/eh_frame_bias_x86/stack.data
new file mode 100644
index 0000000..b95bfac
--- /dev/null
+++ b/libunwindstack/tests/files/offline/eh_frame_bias_x86/stack.data
Binary files differ
diff --git a/libunwindstack/tests/files/offline/eh_frame_bias_x86/tombstoned b/libunwindstack/tests/files/offline/eh_frame_bias_x86/tombstoned
new file mode 100644
index 0000000..aefdb6b
--- /dev/null
+++ b/libunwindstack/tests/files/offline/eh_frame_bias_x86/tombstoned
Binary files differ
diff --git a/libunwindstack/tests/files/offline/eh_frame_bias_x86/vdso.so b/libunwindstack/tests/files/offline/eh_frame_bias_x86/vdso.so
new file mode 100644
index 0000000..c71dcfb
--- /dev/null
+++ b/libunwindstack/tests/files/offline/eh_frame_bias_x86/vdso.so
Binary files differ
diff --git a/libunwindstack/tools/unwind_for_offline.cpp b/libunwindstack/tools/unwind_for_offline.cpp
index 4f67d67..64b58a8 100644
--- a/libunwindstack/tools/unwind_for_offline.cpp
+++ b/libunwindstack/tools/unwind_for_offline.cpp
@@ -275,6 +275,9 @@
if (maps_by_start.count(frame.map_start) == 0) {
map_info = maps->Find(frame.map_start);
+ if (map_info == nullptr) {
+ continue;
+ }
auto info = FillInAndGetMapInfo(maps_by_start, map_info);
bool file_copied = false;
diff --git a/libziparchive/Android.bp b/libziparchive/Android.bp
index 0253f2f..2251479 100644
--- a/libziparchive/Android.bp
+++ b/libziparchive/Android.bp
@@ -184,3 +184,10 @@
],
recovery_available: true,
}
+
+cc_fuzz {
+ name: "libziparchive_fuzzer",
+ srcs: ["libziparchive_fuzzer.cpp"],
+ static_libs: ["libziparchive", "libbase", "libz", "liblog"],
+ host_supported: true,
+}
diff --git a/libziparchive/include/ziparchive/zip_archive.h b/libziparchive/include/ziparchive/zip_archive.h
index e3ac114..391cff9 100644
--- a/libziparchive/include/ziparchive/zip_archive.h
+++ b/libziparchive/include/ziparchive/zip_archive.h
@@ -114,7 +114,7 @@
int32_t OpenArchiveFd(const int fd, const char* debugFileName, ZipArchiveHandle* handle,
bool assume_ownership = true);
-int32_t OpenArchiveFromMemory(void* address, size_t length, const char* debugFileName,
+int32_t OpenArchiveFromMemory(const void* address, size_t length, const char* debugFileName,
ZipArchiveHandle* handle);
/*
* Close archive, releasing resources associated with it. This will
diff --git a/libziparchive/libziparchive_fuzzer.cpp b/libziparchive/libziparchive_fuzzer.cpp
new file mode 100644
index 0000000..75e7939
--- /dev/null
+++ b/libziparchive/libziparchive_fuzzer.cpp
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: Apache-2.0
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <ziparchive/zip_archive.h>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ ZipArchiveHandle handle = nullptr;
+ OpenArchiveFromMemory(data, size, "fuzz", &handle);
+ CloseArchive(handle);
+ return 0;
+}
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc
index c95b035..3a552d8 100644
--- a/libziparchive/zip_archive.cc
+++ b/libziparchive/zip_archive.cc
@@ -178,7 +178,7 @@
#endif
}
-ZipArchive::ZipArchive(void* address, size_t length)
+ZipArchive::ZipArchive(const void* address, size_t length)
: mapped_zip(address, length),
close_file(false),
directory_offset(0),
@@ -471,7 +471,7 @@
return OpenArchiveInternal(archive, fileName);
}
-int32_t OpenArchiveFromMemory(void* address, size_t length, const char* debug_file_name,
+int32_t OpenArchiveFromMemory(const void* address, size_t length, const char* debug_file_name,
ZipArchiveHandle* handle) {
ZipArchive* archive = new ZipArchive(address, length);
*handle = archive;
@@ -1152,7 +1152,7 @@
return fd_;
}
-void* MappedZipFile::GetBasePtr() const {
+const void* MappedZipFile::GetBasePtr() const {
if (has_fd_) {
ALOGW("Zip: MappedZipFile doesn't have a base pointer.");
return nullptr;
@@ -1188,13 +1188,14 @@
ALOGE("Zip: invalid offset: %" PRId64 ", data length: %" PRId64 "\n", off, data_length_);
return false;
}
- memcpy(buf, static_cast<uint8_t*>(base_ptr_) + off, len);
+ memcpy(buf, static_cast<const uint8_t*>(base_ptr_) + off, len);
}
return true;
}
-void CentralDirectory::Initialize(void* map_base_ptr, off64_t cd_start_offset, size_t cd_size) {
- base_ptr_ = static_cast<uint8_t*>(map_base_ptr) + cd_start_offset;
+void CentralDirectory::Initialize(const void* map_base_ptr, off64_t cd_start_offset,
+ size_t cd_size) {
+ base_ptr_ = static_cast<const uint8_t*>(map_base_ptr) + cd_start_offset;
length_ = cd_size;
}
diff --git a/libziparchive/zip_archive_private.h b/libziparchive/zip_archive_private.h
index 30a1d72..60fdec0 100644
--- a/libziparchive/zip_archive_private.h
+++ b/libziparchive/zip_archive_private.h
@@ -95,14 +95,14 @@
explicit MappedZipFile(const int fd)
: has_fd_(true), fd_(fd), base_ptr_(nullptr), data_length_(0) {}
- explicit MappedZipFile(void* address, size_t length)
+ explicit MappedZipFile(const void* address, size_t length)
: has_fd_(false), fd_(-1), base_ptr_(address), data_length_(static_cast<off64_t>(length)) {}
bool HasFd() const { return has_fd_; }
int GetFileDescriptor() const;
- void* GetBasePtr() const;
+ const void* GetBasePtr() const;
off64_t GetFileLength() const;
@@ -117,7 +117,7 @@
const int fd_;
- void* const base_ptr_;
+ const void* const base_ptr_;
const off64_t data_length_;
};
@@ -129,7 +129,7 @@
size_t GetMapLength() const { return length_; }
- void Initialize(void* map_base_ptr, off64_t cd_start_offset, size_t cd_size);
+ void Initialize(const void* map_base_ptr, off64_t cd_start_offset, size_t cd_size);
private:
const uint8_t* base_ptr_;
@@ -177,7 +177,7 @@
ZipStringOffset* hash_table;
ZipArchive(const int fd, bool assume_ownership);
- ZipArchive(void* address, size_t length);
+ ZipArchive(const void* address, size_t length);
~ZipArchive();
bool InitializeCentralDirectory(off64_t cd_start_offset, size_t cd_size);