diff options
61 files changed, 477 insertions, 610 deletions
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp index a4b00f8e0c..587d25f9ed 100644 --- a/cmds/atrace/atrace.cpp +++ b/cmds/atrace/atrace.cpp @@ -1467,10 +1467,11 @@ int main(int argc, char **argv) // Reset the trace buffer size to 1. if (traceStop) { - cleanUpVendorTracing(); cleanUpUserspaceTracing(); - if (!onlyUserspace) + if (!onlyUserspace) { + cleanUpVendorTracing(); cleanUpKernelTracing(); + } } return g_traceAborted ? 1 : 0; diff --git a/cmds/bugreport/bugreport.cpp b/cmds/bugreport/bugreport.cpp index 917c8132b7..840ae473bc 100644 --- a/cmds/bugreport/bugreport.cpp +++ b/cmds/bugreport/bugreport.cpp @@ -37,7 +37,7 @@ int main() { property_set("ctl.start", "dumpstate"); // Socket will not be available until service starts. - int s; + int s = -1; for (int i = 0; i < 20; i++) { s = socket_local_client("dumpstate", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); diff --git a/cmds/bugreportz/main.cpp b/cmds/bugreportz/main.cpp index 74a95b0b57..40346bee1f 100644 --- a/cmds/bugreportz/main.cpp +++ b/cmds/bugreportz/main.cpp @@ -72,7 +72,7 @@ int main(int argc, char* argv[]) { property_set("ctl.start", "dumpstatez"); // Socket will not be available until service starts. - int s; + int s = -1; for (int i = 0; i < 20; i++) { s = socket_local_client("dumpstate", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); if (s >= 0) break; diff --git a/cmds/dumpstate/Android.bp b/cmds/dumpstate/Android.bp index ee32cb4495..4020480479 100644 --- a/cmds/dumpstate/Android.bp +++ b/cmds/dumpstate/Android.bp @@ -123,7 +123,6 @@ cc_binary { "lsmod", "lsof", "netstat", - "parse_radio_log", "printenv", "procrank", "screencap", @@ -146,6 +145,8 @@ cc_test { "tests/dumpstate_test.cpp", ], static_libs: ["libgmock"], + test_config: "dumpstate_test.xml", + data: [":dumpstate_test_fixture", "tests/testdata/**/*"] } cc_test { diff --git a/cmds/dumpstate/DumpstateService.cpp b/cmds/dumpstate/DumpstateService.cpp index ddae9ea8f6..37ba4f906e 100644 --- a/cmds/dumpstate/DumpstateService.cpp +++ b/cmds/dumpstate/DumpstateService.cpp @@ -151,15 +151,15 @@ binder::Status DumpstateService::startBugreport(int32_t calling_uid, signalErrorAndExit(listener, IDumpstateListener::BUGREPORT_ERROR_INVALID_INPUT); } - if (bugreport_fd.get() == -1 || screenshot_fd.get() == -1) { - // TODO(b/111441001): screenshot fd should be optional + std::unique_ptr<Dumpstate::DumpOptions> options = std::make_unique<Dumpstate::DumpOptions>(); + options->Initialize(static_cast<Dumpstate::BugreportMode>(bugreport_mode), bugreport_fd, + screenshot_fd); + + if (bugreport_fd.get() == -1 || (options->do_fb && screenshot_fd.get() == -1)) { MYLOGE("Invalid filedescriptor"); signalErrorAndExit(listener, IDumpstateListener::BUGREPORT_ERROR_INVALID_INPUT); } - std::unique_ptr<Dumpstate::DumpOptions> options = std::make_unique<Dumpstate::DumpOptions>(); - options->Initialize(static_cast<Dumpstate::BugreportMode>(bugreport_mode), bugreport_fd, - screenshot_fd); ds_ = &(Dumpstate::GetInstance()); ds_->SetOptions(std::move(options)); diff --git a/cmds/dumpstate/binder/android/os/IDumpstate.aidl b/cmds/dumpstate/binder/android/os/IDumpstate.aidl index 347856ddcb..cb2d8b8d2c 100644 --- a/cmds/dumpstate/binder/android/os/IDumpstate.aidl +++ b/cmds/dumpstate/binder/android/os/IDumpstate.aidl @@ -73,7 +73,7 @@ interface IDumpstate { * @param callingUid UID of the original application that requested the report. * @param callingPackage package of the original application that requested the report. * @param bugreportFd the file to which the zipped bugreport should be written - * @param screenshotFd the file to which screenshot should be written; optional + * @param screenshotFd the file to which screenshot should be written * @param bugreportMode the mode that specifies other run time options; must be one of above * @param listener callback for updates; optional */ diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 4ac7b689cf..cc745708c8 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -94,7 +94,6 @@ using android::os::IDumpstateListener; using android::os::dumpstate::CommandOptions; using android::os::dumpstate::DumpFileToFd; using android::os::dumpstate::DumpstateSectionReporter; -using android::os::dumpstate::GetPidByName; using android::os::dumpstate::PropertiesHelper; typedef Dumpstate::ConsentCallback::ConsentResult UserConsentResult; @@ -421,108 +420,6 @@ static void dump_dev_files(const char *title, const char *driverpath, const char closedir(d); } - - -// dump anrd's trace and add to the zip file. -// 1. check if anrd is running on this device. -// 2. send a SIGUSR1 to its pid which will dump anrd's trace. -// 3. wait until the trace generation completes and add to the zip file. -static bool dump_anrd_trace() { - unsigned int pid; - char buf[50], path[PATH_MAX]; - struct dirent *trace; - struct stat st; - DIR *trace_dir; - int retry = 5; - long max_ctime = 0, old_mtime; - long long cur_size = 0; - const char *trace_path = "/data/misc/anrd/"; - - if (!ds.IsZipping()) { - MYLOGE("Not dumping anrd trace because it's not a zipped bugreport\n"); - return false; - } - - // find anrd's pid if it is running. - pid = GetPidByName("/system/bin/anrd"); - - if (pid > 0) { - if (stat(trace_path, &st) == 0) { - old_mtime = st.st_mtime; - } else { - MYLOGE("Failed to find: %s\n", trace_path); - return false; - } - - // send SIGUSR1 to the anrd to generate a trace. - sprintf(buf, "%u", pid); - if (RunCommand("ANRD_DUMP", {"kill", "-SIGUSR1", buf}, - CommandOptions::WithTimeout(1).Build())) { - MYLOGE("anrd signal timed out. Please manually collect trace\n"); - return false; - } - - while (retry-- > 0 && old_mtime == st.st_mtime) { - sleep(1); - stat(trace_path, &st); - } - - if (retry < 0 && old_mtime == st.st_mtime) { - MYLOGE("Failed to stat %s or trace creation timeout\n", trace_path); - return false; - } - - // identify the trace file by its creation time. - if (!(trace_dir = opendir(trace_path))) { - MYLOGE("Can't open trace file under %s\n", trace_path); - } - while ((trace = readdir(trace_dir))) { - if (strcmp(trace->d_name, ".") == 0 - || strcmp(trace->d_name, "..") == 0) { - continue; - } - sprintf(path, "%s%s", trace_path, trace->d_name); - if (stat(path, &st) == 0) { - if (st.st_ctime > max_ctime) { - max_ctime = st.st_ctime; - sprintf(buf, "%s", trace->d_name); - } - } - } - closedir(trace_dir); - - // Wait until the dump completes by checking the size of the trace. - if (max_ctime > 0) { - sprintf(path, "%s%s", trace_path, buf); - while(true) { - sleep(1); - if (stat(path, &st) == 0) { - if (st.st_size == cur_size) { - break; - } else if (st.st_size > cur_size) { - cur_size = st.st_size; - } else { - return false; - } - } else { - MYLOGE("Cant stat() %s anymore\n", path); - return false; - } - } - // Add to the zip file. - if (!ds.AddZipEntry("anrd_trace.txt", path)) { - MYLOGE("Unable to add anrd_trace file %s to zip file\n", path); - } else { - android::os::UnlinkAndLogOnError(path); - return true; - } - } else { - MYLOGE("Can't stats any trace file under %s\n", trace_path); - } - } - return false; -} - static bool skip_not_stat(const char *path) { static const char stat[] = "/stat"; size_t len = strlen(path); @@ -1380,7 +1277,7 @@ static Dumpstate::RunStatus dumpstate() { /* Dump Bluetooth HCI logs */ ds.AddDir("/data/misc/bluetooth/logs", true); - if (!ds.do_early_screenshot_) { + if (ds.options_->do_fb && !ds.do_early_screenshot_) { MYLOGI("taking late screenshot\n"); ds.TakeScreenshot(); } @@ -1419,8 +1316,6 @@ static Dumpstate::RunStatus dumpstate() { RunCommand("FILESYSTEMS & FREE SPACE", {"df"}); - RunCommand("LAST RADIO LOG", {"parse_radio_log", "/proc/last_radio_log"}); - /* Binder state is expensive to look at as it uses a lot of memory. */ DumpFile("BINDER FAILED TRANSACTION LOG", "/sys/kernel/debug/binder/failed_transaction_log"); DumpFile("BINDER TRANSACTION LOG", "/sys/kernel/debug/binder/transaction_log"); @@ -1428,7 +1323,6 @@ static Dumpstate::RunStatus dumpstate() { DumpFile("BINDER STATS", "/sys/kernel/debug/binder/stats"); DumpFile("BINDER STATE", "/sys/kernel/debug/binder/state"); - RunDumpsys("WINSCOPE TRACE", {"window", "trace"}); /* Add window and surface trace files. */ if (!PropertiesHelper::IsUserBuild()) { ds.AddDir(WMTRACE_DATA_DIR, false); @@ -1539,9 +1433,6 @@ static Dumpstate::RunStatus dumpstate() { * with the caller. */ static Dumpstate::RunStatus DumpstateDefault() { - // Try to dump anrd trace if the daemon is running. - dump_anrd_trace(); - // Invoking the following dumpsys calls before DumpTraces() to try and // keep the system stats as close to its initial state as possible. RUN_SLOW_FUNCTION_WITH_CONSENT_CHECK(RunDumpsysCritical); @@ -1903,22 +1794,21 @@ void Dumpstate::DumpstateBoard() { static void ShowUsage() { fprintf(stderr, - "usage: dumpstate [-h] [-b soundfile] [-e soundfile] [-o file] [-d] [-p] " + "usage: dumpstate [-h] [-b soundfile] [-e soundfile] [-d] [-p] " "[-z]] [-s] [-S] [-q] [-B] [-P] [-R] [-V version]\n" " -h: display this help message\n" " -b: play sound file instead of vibrate, at beginning of job\n" " -e: play sound file instead of vibrate, at end of job\n" - " -o: write to file (instead of stdout)\n" - " -d: append date to filename (requires -o)\n" - " -p: capture screenshot to filename.png (requires -o)\n" - " -z: generate zipped file (requires -o)\n" + " -d: append date to filename\n" + " -p: capture screenshot to filename.png\n" + " -z: generate zipped file\n" " -s: write output to control socket (for init)\n" - " -S: write file location to control socket (for init; requires -o and -z)\n" + " -S: write file location to control socket (for init; requires -z)\n" " -q: disable vibrate\n" - " -B: send broadcast when finished (requires -o)\n" + " -B: send broadcast when finished\n" " -P: send broadcast when started and update system properties on " - "progress (requires -o and -B)\n" - " -R: take bugreport in remote mode (requires -o, -z, -d and -B, " + "progress (requires -B)\n" + " -R: take bugreport in remote mode (requires -z, -d and -B, " "shouldn't be used with -P)\n" " -w: start binder service and make it wait for a call to startBugreport\n" " -v: prints the dumpstate header and exit\n"); @@ -2402,7 +2292,6 @@ Dumpstate::RunStatus Dumpstate::DumpOptions::Initialize(int argc, char* argv[]) } } - // TODO: use helper function to convert argv into a string for (int i = 0; i < argc; i++) { args += argv[i]; if (i < argc - 1) { @@ -2626,13 +2515,8 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid, } if (options_->do_fb && do_early_screenshot_) { - if (screenshot_path_.empty()) { - // should not have happened - MYLOGE("INTERNAL ERROR: skipping early screenshot because path was not set\n"); - } else { - MYLOGI("taking early screenshot\n"); - TakeScreenshot(); - } + MYLOGI("taking early screenshot\n"); + TakeScreenshot(); } if (options_->do_zip_file && zip_file != nullptr) { diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h index d02ec759a7..ae6a72171a 100644 --- a/cmds/dumpstate/dumpstate.h +++ b/cmds/dumpstate/dumpstate.h @@ -441,8 +441,7 @@ class Dumpstate { // Full path of the bugreport file, be it zip or text, inside bugreport_internal_dir_. std::string path_; - // TODO: If temporary this should be removed at the end. - // Full path of the temporary file containing the screenshot (when requested). + // Full path of the file containing the screenshot (when requested). std::string screenshot_path_; // Pointer to the zipped file. diff --git a/cmds/dumpstate/dumpstate_test.xml b/cmds/dumpstate/dumpstate_test.xml new file mode 100644 index 0000000000..e4e4a30a1e --- /dev/null +++ b/cmds/dumpstate/dumpstate_test.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2019 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. +--> +<configuration description="Config for dumpstate_test"> + <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer"> + <option name="cleanup" value="true" /> + <option name="push" value="dumpstate_test->/data/local/tmp/dumpstate_test" /> + </target_preparer> + <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/> + <option name="test-suite-tag" value="apct" /> + <test class="com.android.tradefed.testtype.GTest" > + <option name="native-test-device-path" value="/data/local/tmp" /> + <option name="file-exclusion-filter-regex" value=".*/dumpstate_test_fixture" /> + <option name="file-exclusion-filter-regex" value=".*/tests/.*" /> + <option name="module-name" value="dumpstate_test" /> + </test> +</configuration> diff --git a/cmds/dumpstate/tests/dumpstate_smoke_test.cpp b/cmds/dumpstate/tests/dumpstate_smoke_test.cpp index fc3642c912..5bde7db287 100644 --- a/cmds/dumpstate/tests/dumpstate_smoke_test.cpp +++ b/cmds/dumpstate/tests/dumpstate_smoke_test.cpp @@ -208,7 +208,7 @@ class ZippedBugReportContentsTest : public Test { void FileExists(const char* filename, uint32_t minsize, uint32_t maxsize) { ZipEntry entry; - EXPECT_EQ(FindEntry(handle, ZipString(filename), &entry), 0); + EXPECT_EQ(FindEntry(handle, filename, &entry), 0); EXPECT_GT(entry.uncompressed_length, minsize); EXPECT_LT(entry.uncompressed_length, maxsize); } @@ -217,7 +217,7 @@ class ZippedBugReportContentsTest : public Test { TEST_F(ZippedBugReportContentsTest, ContainsMainEntry) { ZipEntry mainEntryLoc; // contains main entry name file - EXPECT_EQ(FindEntry(handle, ZipString("main_entry.txt"), &mainEntryLoc), 0); + EXPECT_EQ(FindEntry(handle, "main_entry.txt", &mainEntryLoc), 0); char* buf = new char[mainEntryLoc.uncompressed_length]; ExtractToMemory(handle, &mainEntryLoc, (uint8_t*)buf, mainEntryLoc.uncompressed_length); @@ -230,7 +230,7 @@ TEST_F(ZippedBugReportContentsTest, ContainsMainEntry) { TEST_F(ZippedBugReportContentsTest, ContainsVersion) { ZipEntry entry; // contains main entry name file - EXPECT_EQ(FindEntry(handle, ZipString("version.txt"), &entry), 0); + EXPECT_EQ(FindEntry(handle, "version.txt", &entry), 0); char* buf = new char[entry.uncompressed_length + 1]; ExtractToMemory(handle, &entry, (uint8_t*)buf, entry.uncompressed_length); diff --git a/cmds/dumpstate/tests/dumpstate_test.cpp b/cmds/dumpstate/tests/dumpstate_test.cpp index 71d15f4761..0e88e43258 100644 --- a/cmds/dumpstate/tests/dumpstate_test.cpp +++ b/cmds/dumpstate/tests/dumpstate_test.cpp @@ -105,9 +105,8 @@ class DumpstateBaseTest : public Test { protected: const std::string kTestPath = dirname(android::base::GetExecutablePath().c_str()); - const std::string kFixturesPath = kTestPath + "/../dumpstate_test_fixture/"; - const std::string kTestDataPath = kFixturesPath + "tests/testdata/"; - const std::string kSimpleCommand = kFixturesPath + "dumpstate_test_fixture"; + const std::string kTestDataPath = kTestPath + "/tests/testdata/"; + const std::string kSimpleCommand = kTestPath + "/dumpstate_test_fixture"; const std::string kEchoCommand = "/system/bin/echo"; /* @@ -664,7 +663,8 @@ TEST_F(DumpstateTest, RunCommandNoTitle) { TEST_F(DumpstateTest, RunCommandWithTitle) { EXPECT_EQ(0, RunCommand("I AM GROOT", {kSimpleCommand})); EXPECT_THAT(err, StrEq("stderr\n")); - // We don't know the exact duration, so we check the prefix and suffix + // The duration may not get output, depending on how long it takes, + // so we just check the prefix. EXPECT_THAT(out, StartsWith("------ I AM GROOT (" + kSimpleCommand + ") ------\nstdout\n")); } @@ -699,7 +699,8 @@ TEST_F(DumpstateTest, RunCommandWithMultipleArgs) { TEST_F(DumpstateTest, RunCommandDryRun) { SetDryRun(true); EXPECT_EQ(0, RunCommand("I AM GROOT", {kSimpleCommand})); - // We don't know the exact duration, so we check the prefix and suffix + // The duration may not get output, depending on how long it takes, + // so we just check the prefix. EXPECT_THAT(out, StartsWith("------ I AM GROOT (" + kSimpleCommand + ") ------\n\t(skipped on dry run)\n")); EXPECT_THAT(err, IsEmpty()); @@ -1037,7 +1038,8 @@ TEST_F(DumpstateTest, DumpFileNotFoundNoTitle) { TEST_F(DumpstateTest, DumpFileNotFoundWithTitle) { EXPECT_EQ(-1, DumpFile("Y U NO EXIST?", "/I/cant/believe/I/exist")); EXPECT_THAT(err, IsEmpty()); - // We don't know the exact duration, so we check the prefix and suffix + // The duration may not get output, depending on how long it takes, + // so we just check the prefix. EXPECT_THAT(out, StartsWith("*** Error dumping /I/cant/believe/I/exist (Y U NO EXIST?): No " "such file or directory\n")); } diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp index 0bb80dcfba..4cbf5776d3 100644 --- a/cmds/dumpstate/utils.cpp +++ b/cmds/dumpstate/utils.cpp @@ -733,6 +733,11 @@ int open_socket(const char *service) { struct sockaddr addr; socklen_t alen = sizeof(addr); int fd = accept(s, &addr, &alen); + + // Close socket just after accept(), to make sure that connect() by client will get error + // when the socket is used by the other services. + close(s); + if (fd < 0) { MYLOGE("accept(control socket): %s\n", strerror(errno)); return -1; diff --git a/cmds/installd/Android.bp b/cmds/installd/Android.bp index c80ae3bbf6..064a268d2e 100644 --- a/cmds/installd/Android.bp +++ b/cmds/installd/Android.bp @@ -151,6 +151,7 @@ cc_binary { shared_libs: [ "libbase", "libbinder", + "libcrypto", "liblog", "libprotobuf-cpp-full", "libselinux", @@ -163,6 +164,7 @@ cc_binary { "lib_apex_manifest_proto", "libavb", "libdm", + "libverity_tree", "libvold_binder", ], } @@ -172,6 +174,7 @@ filegroup { srcs: [ "binder/android/os/IInstalld.aidl", ], + path: "binder", } // diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp index caac2e89a7..dd51898422 100644 --- a/cmds/installd/InstalldNativeService.cpp +++ b/cmds/installd/InstalldNativeService.cpp @@ -2107,10 +2107,15 @@ binder::Status InstalldNativeService::dexopt(const std::string& apkPath, int32_t CHECK_ARGUMENT_PATH(dexMetadataPath); std::lock_guard<std::recursive_mutex> lock(mLock); + const char* oat_dir = getCStr(outputPath); + const char* instruction_set = instructionSet.c_str(); + if (oat_dir != nullptr && !createOatDir(oat_dir, instruction_set).isOk()) { + // Can't create oat dir - let dexopt use cache dir. + oat_dir = nullptr; + } + const char* apk_path = apkPath.c_str(); const char* pkgname = getCStr(packageName, "*"); - const char* instruction_set = instructionSet.c_str(); - const char* oat_dir = getCStr(outputPath); const char* compiler_filter = compilerFilter.c_str(); const char* volume_uuid = getCStr(uuid); const char* class_loader_context = getCStr(classLoaderContext); diff --git a/cmds/installd/OWNERS b/cmds/installd/OWNERS index 56739181bb..9a21104131 100644 --- a/cmds/installd/OWNERS +++ b/cmds/installd/OWNERS @@ -4,7 +4,9 @@ agampe@google.com calin@google.com jsharkey@android.com maco@google.com +mast@google.com mathieuc@google.com narayan@google.com ngeoffray@google.com +rpl@google.com toddke@google.com diff --git a/cmds/installd/art_helper/Android.bp b/cmds/installd/art_helper/Android.bp deleted file mode 100644 index c47dd722f9..0000000000 --- a/cmds/installd/art_helper/Android.bp +++ /dev/null @@ -1,12 +0,0 @@ -// Inherit image values. -art_global_defaults { - name: "libartimagevalues_defaults", -} - -cc_library_static { - name: "libartimagevalues", - defaults: ["libartimagevalues_defaults"], - srcs: ["art_image_values.cpp"], - export_include_dirs: ["."], - cflags: ["-Wconversion"], -} diff --git a/cmds/installd/art_helper/art_image_values.cpp b/cmds/installd/art_helper/art_image_values.cpp deleted file mode 100644 index a139049d9f..0000000000 --- a/cmds/installd/art_helper/art_image_values.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2018 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 "art_image_values.h" - -namespace android { -namespace installd { -namespace art { - -uint32_t GetImageBaseAddress() { - return ART_BASE_ADDRESS; -} -int32_t GetImageMinBaseAddressDelta() { - return ART_BASE_ADDRESS_MIN_DELTA; -} -int32_t GetImageMaxBaseAddressDelta() { - return ART_BASE_ADDRESS_MAX_DELTA; -} - -static_assert(ART_BASE_ADDRESS_MIN_DELTA < ART_BASE_ADDRESS_MAX_DELTA, "Inconsistent setup"); - -} // namespace art -} // namespace installd -} // namespace android diff --git a/cmds/installd/art_helper/art_image_values.h b/cmds/installd/art_helper/art_image_values.h deleted file mode 100644 index 20c44c953f..0000000000 --- a/cmds/installd/art_helper/art_image_values.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2018 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 FRAMEWORKS_NATIVE_CMDS_INSTALLD_ART_HELPER_ART_IMAGE_VALUES_H -#define FRAMEWORKS_NATIVE_CMDS_INSTALLD_ART_HELPER_ART_IMAGE_VALUES_H - -#include <cstdint> - -namespace android { -namespace installd { -namespace art { - -uint32_t GetImageBaseAddress(); -int32_t GetImageMinBaseAddressDelta(); -int32_t GetImageMaxBaseAddressDelta(); - -} // namespace art -} // namespace installd -} // namespace android - -#endif // FRAMEWORKS_NATIVE_CMDS_INSTALLD_ART_HELPER_ART_IMAGE_VALUES_H diff --git a/cmds/installd/dexopt.cpp b/cmds/installd/dexopt.cpp index dbb4f22372..7eee749be9 100644 --- a/cmds/installd/dexopt.cpp +++ b/cmds/installd/dexopt.cpp @@ -2117,14 +2117,20 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins // Create a swap file if necessary. unique_fd swap_fd = maybe_open_dexopt_swap_file(out_oat_path); - // Create the app image file if needed. - Dex2oatFileWrapper image_fd = maybe_open_app_image( - out_oat_path, generate_app_image, is_public, uid, is_secondary_dex); - // Open the reference profile if needed. Dex2oatFileWrapper reference_profile_fd = maybe_open_reference_profile( pkgname, dex_path, profile_name, profile_guided, is_public, uid, is_secondary_dex); + if (reference_profile_fd.get() == -1) { + // We don't create an app image without reference profile since there is no speedup from + // loading it in that case and instead will be a small overhead. + generate_app_image = false; + } + + // Create the app image file if needed. + Dex2oatFileWrapper image_fd = maybe_open_app_image( + out_oat_path, generate_app_image, is_public, uid, is_secondary_dex); + unique_fd dex_metadata_fd; if (dex_metadata_path != nullptr) { dex_metadata_fd.reset(TEMP_FAILURE_RETRY(open(dex_metadata_path, O_RDONLY | O_NOFOLLOW))); diff --git a/cmds/installd/otapreopt.cpp b/cmds/installd/otapreopt.cpp index de7b2499b8..db36ce3c9e 100644 --- a/cmds/installd/otapreopt.cpp +++ b/cmds/installd/otapreopt.cpp @@ -445,9 +445,11 @@ private: } cmd.push_back(StringPrintf("--oat-file=%s", oat_path.c_str())); - int32_t base_offset = ChooseRelocationOffsetDelta(art::GetImageMinBaseAddressDelta(), - art::GetImageMaxBaseAddressDelta()); - cmd.push_back(StringPrintf("--base=0x%x", art::GetImageBaseAddress() + base_offset)); + int32_t base_offset = ChooseRelocationOffsetDelta( + art::imagevalues::GetImageMinBaseAddressDelta(), + art::imagevalues::GetImageMaxBaseAddressDelta()); + cmd.push_back(StringPrintf("--base=0x%x", + art::imagevalues::GetImageBaseAddress() + base_offset)); cmd.push_back(StringPrintf("--instruction-set=%s", isa)); @@ -464,7 +466,7 @@ private: "--compiler-filter=", false, cmd); - cmd.push_back("--image-classes=/system/etc/preloaded-classes"); + cmd.push_back("--profile-file=/system/etc/boot-image.prof"); // TODO: Compiled-classes. const std::string* extra_opts = system_properties_.GetProperty("dalvik.vm.image-dex2oat-flags"); diff --git a/cmds/installd/otapreopt_chroot.cpp b/cmds/installd/otapreopt_chroot.cpp index 2e2cc182ec..0c4badf489 100644 --- a/cmds/installd/otapreopt_chroot.cpp +++ b/cmds/installd/otapreopt_chroot.cpp @@ -64,16 +64,18 @@ static std::vector<apex::ApexFile> ActivateApexPackages() { // system/apex/apexd/apexd_main.cpp. // // Only scan the APEX directory under /system (within the chroot dir). - apex::scanPackagesDirAndActivate(apex::kApexPackageSystemDir); + // Cast call to void to suppress warn_unused_result. + static_cast<void>(apex::scanPackagesDirAndActivate(apex::kApexPackageSystemDir)); return apex::getActivePackages(); } static void DeactivateApexPackages(const std::vector<apex::ApexFile>& active_packages) { for (const apex::ApexFile& apex_file : active_packages) { const std::string& package_path = apex_file.GetPath(); - apex::Status status = apex::deactivatePackage(package_path); - if (!status.Ok()) { - LOG(ERROR) << "Failed to deactivate " << package_path << ": " << status.ErrorMessage(); + base::Result<void> status = apex::deactivatePackage(package_path); + if (!status) { + LOG(ERROR) << "Failed to deactivate " << package_path << ": " + << status.error(); } } } diff --git a/cmds/installd/tests/Android.bp b/cmds/installd/tests/Android.bp index aa79fdc100..bd45005fd1 100644 --- a/cmds/installd/tests/Android.bp +++ b/cmds/installd/tests/Android.bp @@ -89,6 +89,8 @@ cc_test { "libinstalld", "liblog", "liblogwrap", + "libziparchive", + "libz", ], test_config: "installd_dexopt_test.xml", } diff --git a/cmds/installd/tests/installd_dexopt_test.cpp b/cmds/installd/tests/installd_dexopt_test.cpp index fa2b0d9660..73780eccbf 100644 --- a/cmds/installd/tests/installd_dexopt_test.cpp +++ b/cmds/installd/tests/installd_dexopt_test.cpp @@ -41,6 +41,7 @@ #include "globals.h" #include "tests/test_utils.h" #include "utils.h" +#include "ziparchive/zip_writer.h" using android::base::ReadFully; using android::base::unique_fd; @@ -195,6 +196,7 @@ protected: std::unique_ptr<std::string> volume_uuid_; std::string package_name_; std::string apk_path_; + std::string empty_dm_file_; std::string app_apk_dir_; std::string app_private_dir_ce_; std::string app_private_dir_de_; @@ -239,18 +241,14 @@ protected: } ::testing::AssertionResult create_mock_app() { - // Create the oat dir. - app_oat_dir_ = app_apk_dir_ + "/oat"; // For debug mode, the directory might already exist. Avoid erroring out. if (mkdir(app_apk_dir_, kSystemUid, kSystemGid, 0755) != 0 && !kDebug) { return ::testing::AssertionFailure() << "Could not create app dir " << app_apk_dir_ << " : " << strerror(errno); } - binder::Status status = service_->createOatDir(app_oat_dir_, kRuntimeIsa); - if (!status.isOk()) { - return ::testing::AssertionFailure() << "Could not create oat dir: " - << status.toString8().c_str(); - } + + // Initialize the oat dir path. + app_oat_dir_ = app_apk_dir_ + "/oat"; // Copy the primary apk. apk_path_ = app_apk_dir_ + "/base.jar"; @@ -260,8 +258,28 @@ protected: << " : " << error_msg; } + // Create an empty dm file. + empty_dm_file_ = apk_path_ + ".dm"; + { + int fd = open(empty_dm_file_.c_str(), O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); + if (fd < 0) { + return ::testing::AssertionFailure() << "Could not open " << empty_dm_file_; + } + FILE* file = fdopen(fd, "wb"); + if (file == nullptr) { + return ::testing::AssertionFailure() << "Null file for " << empty_dm_file_ + << " fd=" << fd; + } + ZipWriter writer(file); + // Add vdex to zip. + writer.StartEntry("primary.prof", ZipWriter::kCompress); + writer.FinishEntry(); + writer.Finish(); + close(fd); + } + // Create the app user data. - status = service_->createAppData( + binder::Status status = service_->createAppData( volume_uuid_, package_name_, kTestUserId, @@ -479,7 +497,7 @@ protected: bool prof_result; ASSERT_BINDER_SUCCESS(service_->prepareAppProfile( package_name_, kTestUserId, kTestAppId, *profile_name_ptr, apk_path_, - /*dex_metadata*/ nullptr, &prof_result)); + dm_path_ptr, &prof_result)); ASSERT_TRUE(prof_result); binder::Status result = service_->dexopt(apk_path_, @@ -625,6 +643,16 @@ TEST_F(DexoptTest, DexoptPrimaryPublic) { DEX2OAT_FROM_SCRATCH); } +TEST_F(DexoptTest, DexoptPrimaryPublicCreateOatDir) { + LOG(INFO) << "DexoptPrimaryPublic"; + ASSERT_BINDER_SUCCESS(service_->createOatDir(app_oat_dir_, kRuntimeIsa)); + CompilePrimaryDexOk("verify", + DEXOPT_BOOTCOMPLETE | DEXOPT_PUBLIC, + app_oat_dir_.c_str(), + kTestAppGid, + DEX2OAT_FROM_SCRATCH); +} + TEST_F(DexoptTest, DexoptPrimaryFailedInvalidFilter) { LOG(INFO) << "DexoptPrimaryFailedInvalidFilter"; binder::Status status; @@ -645,7 +673,9 @@ TEST_F(DexoptTest, DexoptPrimaryProfileNonPublic) { DEXOPT_BOOTCOMPLETE | DEXOPT_PROFILE_GUIDED | DEXOPT_GENERATE_APP_IMAGE, app_oat_dir_.c_str(), kTestAppGid, - DEX2OAT_FROM_SCRATCH); + DEX2OAT_FROM_SCRATCH, + /*binder_result=*/nullptr, + empty_dm_file_.c_str()); } TEST_F(DexoptTest, DexoptPrimaryProfilePublic) { @@ -655,7 +685,9 @@ TEST_F(DexoptTest, DexoptPrimaryProfilePublic) { DEXOPT_GENERATE_APP_IMAGE, app_oat_dir_.c_str(), kTestAppGid, - DEX2OAT_FROM_SCRATCH); + DEX2OAT_FROM_SCRATCH, + /*binder_result=*/nullptr, + empty_dm_file_.c_str()); } TEST_F(DexoptTest, DexoptPrimaryBackgroundOk) { @@ -665,7 +697,9 @@ TEST_F(DexoptTest, DexoptPrimaryBackgroundOk) { DEXOPT_GENERATE_APP_IMAGE, app_oat_dir_.c_str(), kTestAppGid, - DEX2OAT_FROM_SCRATCH); + DEX2OAT_FROM_SCRATCH, + /*binder_result=*/nullptr, + empty_dm_file_.c_str()); } TEST_F(DexoptTest, ResolveStartupConstStrings) { @@ -684,7 +718,9 @@ TEST_F(DexoptTest, ResolveStartupConstStrings) { DEXOPT_GENERATE_APP_IMAGE, app_oat_dir_.c_str(), kTestAppGid, - DEX2OAT_FROM_SCRATCH); + DEX2OAT_FROM_SCRATCH, + /*binder_result=*/nullptr, + empty_dm_file_.c_str()); run_cmd_and_process_output( "oatdump --header-only --oat-file=" + odex, [&](const std::string& line) { @@ -701,7 +737,9 @@ TEST_F(DexoptTest, ResolveStartupConstStrings) { DEXOPT_GENERATE_APP_IMAGE, app_oat_dir_.c_str(), kTestAppGid, - DEX2OAT_FROM_SCRATCH); + DEX2OAT_FROM_SCRATCH, + /*binder_result=*/nullptr, + empty_dm_file_.c_str()); run_cmd_and_process_output( "oatdump --header-only --oat-file=" + odex, [&](const std::string& line) { diff --git a/cmds/lshal/Android.bp b/cmds/lshal/Android.bp index 93d878b607..f7dd8c82c3 100644 --- a/cmds/lshal/Android.bp +++ b/cmds/lshal/Android.bp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -cc_library_shared { +cc_library_static { name: "liblshal", shared_libs: [ "libbase", @@ -47,13 +47,16 @@ cc_defaults { name: "lshal_defaults", shared_libs: [ "libbase", + "libcutils", + "libutils", "libhidlbase", - "libhidl-gen-utils", "libhidltransport", - "liblshal", - "libutils", + "libhidl-gen-hash", + "libhidl-gen-utils", + "libvintf", ], static_libs: [ + "liblshal", "libprocpartition", ], cflags: ["-Wall", "-Werror"], diff --git a/cmds/lshal/Command.h b/cmds/lshal/Command.h index e19e3f7fc2..84809d9a5d 100644 --- a/cmds/lshal/Command.h +++ b/cmds/lshal/Command.h @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef FRAMEWORK_NATIVE_CMDS_LSHAL_COMMAND_H_ -#define FRAMEWORK_NATIVE_CMDS_LSHAL_COMMAND_H_ +#pragma once #include "utils.h" @@ -48,5 +47,3 @@ protected: } // namespace lshal } // namespace android - -#endif // FRAMEWORK_NATIVE_CMDS_LSHAL_LIST_COMMAND_H_ diff --git a/cmds/lshal/DebugCommand.cpp b/cmds/lshal/DebugCommand.cpp index 0952db6e72..af22ac9b3d 100644 --- a/cmds/lshal/DebugCommand.cpp +++ b/cmds/lshal/DebugCommand.cpp @@ -79,7 +79,7 @@ void DebugCommand::usage() const { " lshal debug [-E] <interface> [options [options [...]]] \n" " Print debug information of a specified interface.\n" " -E: excludes debug output if HAL is actually a subclass.\n" - " <inteface>: Format is `android.hardware.foo@1.0::IFoo/default`.\n" + " <interface>: Format is `android.hardware.foo@1.0::IFoo/default`.\n" " If instance name is missing `default` is used.\n" " options: space separated options to IBase::debug.\n"; @@ -88,4 +88,3 @@ void DebugCommand::usage() const { } // namespace lshal } // namespace android - diff --git a/cmds/lshal/DebugCommand.h b/cmds/lshal/DebugCommand.h index 3c3f56fde5..cd57e31bfc 100644 --- a/cmds/lshal/DebugCommand.h +++ b/cmds/lshal/DebugCommand.h @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef FRAMEWORK_NATIVE_CMDS_LSHAL_DEBUG_COMMAND_H_ -#define FRAMEWORK_NATIVE_CMDS_LSHAL_DEBUG_COMMAND_H_ +#pragma once #include <string> @@ -53,5 +52,3 @@ private: } // namespace lshal } // namespace android - -#endif // FRAMEWORK_NATIVE_CMDS_LSHAL_DEBUG_COMMAND_H_ diff --git a/cmds/lshal/HelpCommand.h b/cmds/lshal/HelpCommand.h index da0cba6f42..bfa850075d 100644 --- a/cmds/lshal/HelpCommand.h +++ b/cmds/lshal/HelpCommand.h @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef FRAMEWORK_NATIVE_CMDS_LSHAL_HELP_COMMAND_H_ -#define FRAMEWORK_NATIVE_CMDS_LSHAL_HELP_COMMAND_H_ +#pragma once #include <string> @@ -44,5 +43,3 @@ public: } // namespace lshal } // namespace android - -#endif // FRAMEWORK_NATIVE_CMDS_LSHAL_HELP_COMMAND_H_ diff --git a/cmds/lshal/ListCommand.h b/cmds/lshal/ListCommand.h index 85195fcc54..b3ed23d1fc 100644 --- a/cmds/lshal/ListCommand.h +++ b/cmds/lshal/ListCommand.h @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef FRAMEWORK_NATIVE_CMDS_LSHAL_LIST_COMMAND_H_ -#define FRAMEWORK_NATIVE_CMDS_LSHAL_LIST_COMMAND_H_ +#pragma once #include <getopt.h> #include <stdint.h> @@ -206,5 +205,3 @@ private: } // namespace lshal } // namespace android - -#endif // FRAMEWORK_NATIVE_CMDS_LSHAL_LIST_COMMAND_H_ diff --git a/cmds/lshal/Lshal.h b/cmds/lshal/Lshal.h index 9457f1e563..2679650611 100644 --- a/cmds/lshal/Lshal.h +++ b/cmds/lshal/Lshal.h @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef FRAMEWORK_NATIVE_CMDS_LSHAL_LSHAL_H_ -#define FRAMEWORK_NATIVE_CMDS_LSHAL_LSHAL_H_ +#pragma once #include <iostream> #include <string> @@ -76,5 +75,3 @@ private: } // namespace lshal } // namespace android - -#endif // FRAMEWORK_NATIVE_CMDS_LSHAL_LSHAL_H_ diff --git a/cmds/lshal/NullableOStream.h b/cmds/lshal/NullableOStream.h index 737d3a2963..7cffcf8193 100644 --- a/cmds/lshal/NullableOStream.h +++ b/cmds/lshal/NullableOStream.h @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef FRAMEWORK_NATIVE_CMDS_LSHAL_NULLABLE_O_STREAM_H_ -#define FRAMEWORK_NATIVE_CMDS_LSHAL_NULLABLE_O_STREAM_H_ +#pragma once #include <iostream> @@ -69,5 +68,3 @@ private: } // namespace lshal } // namespace android - -#endif // FRAMEWORK_NATIVE_CMDS_LSHAL_NULLABLE_O_STREAM_H_ diff --git a/cmds/lshal/PipeRelay.h b/cmds/lshal/PipeRelay.h index 8dc3093742..8350160419 100644 --- a/cmds/lshal/PipeRelay.h +++ b/cmds/lshal/PipeRelay.h @@ -14,9 +14,7 @@ * limitations under the License. */ -#ifndef FRAMEWORKS_NATIVE_CMDS_LSHAL_PIPE_RELAY_H_ - -#define FRAMEWORKS_NATIVE_CMDS_LSHAL_PIPE_RELAY_H_ +#pragma once #include <android-base/macros.h> #include <ostream> @@ -53,6 +51,3 @@ private: } // namespace lshal } // namespace android - -#endif // FRAMEWORKS_NATIVE_CMDS_LSHAL_PIPE_RELAY_H_ - diff --git a/cmds/lshal/TableEntry.h b/cmds/lshal/TableEntry.h index 601b7e25f9..0ff0c96d38 100644 --- a/cmds/lshal/TableEntry.h +++ b/cmds/lshal/TableEntry.h @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef FRAMEWORK_NATIVE_CMDS_LSHAL_TABLE_ENTRY_H_ -#define FRAMEWORK_NATIVE_CMDS_LSHAL_TABLE_ENTRY_H_ +#pragma once #include <stdint.h> @@ -157,5 +156,3 @@ private: } // namespace lshal } // namespace android - -#endif // FRAMEWORK_NATIVE_CMDS_LSHAL_TABLE_ENTRY_H_ diff --git a/cmds/lshal/TextTable.h b/cmds/lshal/TextTable.h index 301b4bd969..be41a08251 100644 --- a/cmds/lshal/TextTable.h +++ b/cmds/lshal/TextTable.h @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef FRAMEWORK_NATIVE_CMDS_LSHAL_TEXT_TABLE_H_ -#define FRAMEWORK_NATIVE_CMDS_LSHAL_TEXT_TABLE_H_ +#pragma once #include <iostream> #include <string> @@ -80,5 +79,3 @@ private: } // namespace lshal } // namespace android - -#endif // FRAMEWORK_NATIVE_CMDS_LSHAL_TEXT_TABLE_H_ diff --git a/cmds/lshal/Timeout.h b/cmds/lshal/Timeout.h index 46d817759d..e8d22d9b58 100644 --- a/cmds/lshal/Timeout.h +++ b/cmds/lshal/Timeout.h @@ -14,6 +14,8 @@ * limitations under the License. */ +#pragma once + #include <condition_variable> #include <chrono> #include <functional> diff --git a/cmds/lshal/libprocpartition/include/procpartition/procpartition.h b/cmds/lshal/libprocpartition/include/procpartition/procpartition.h index 7e864327af..ca1e690694 100644 --- a/cmds/lshal/libprocpartition/include/procpartition/procpartition.h +++ b/cmds/lshal/libprocpartition/include/procpartition/procpartition.h @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef FRAMEWORK_NATIVE_CMDS_LSHAL_PROCPARTITION_H_ -#define FRAMEWORK_NATIVE_CMDS_LSHAL_PROCPARTITION_H_ +#pragma once #include <sys/types.h> @@ -44,5 +43,3 @@ Partition getPartition(pid_t pid); } // namespace procpartition } // namespace android - -#endif // FRAMEWORK_NATIVE_CMDS_LSHAL_PROCPARTITION_H_ diff --git a/cmds/lshal/utils.h b/cmds/lshal/utils.h index 240155e4d0..04f52726e3 100644 --- a/cmds/lshal/utils.h +++ b/cmds/lshal/utils.h @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef FRAMEWORK_NATIVE_CMDS_LSHAL_UTILS_H_ -#define FRAMEWORK_NATIVE_CMDS_LSHAL_UTILS_H_ +#pragma once #include <iomanip> #include <iostream> @@ -88,5 +87,3 @@ void replaceAll(std::string *s, char from, char to); } // namespace lshal } // namespace android - -#endif // FRAMEWORK_NATIVE_CMDS_LSHAL_UTILS_H_ diff --git a/include/android/font.h b/include/android/font.h index 435a573f51..8001ee1938 100644 --- a/include/android/font.h +++ b/include/android/font.h @@ -16,7 +16,7 @@ /** * @addtogroup Font - * { + * @{ */ /** diff --git a/include/android/font_matcher.h b/include/android/font_matcher.h index e286a4c812..0b8f892b9b 100644 --- a/include/android/font_matcher.h +++ b/include/android/font_matcher.h @@ -16,7 +16,7 @@ /** * @addtogroup Font - * { + * @{ */ /** diff --git a/include/android/system_fonts.h b/include/android/system_fonts.h index dde9055c7a..f0485a1871 100644 --- a/include/android/system_fonts.h +++ b/include/android/system_fonts.h @@ -16,7 +16,7 @@ /** * @addtogroup Font - * { + * @{ */ /** diff --git a/include/audiomanager/OWNERS b/include/audiomanager/OWNERS new file mode 100644 index 0000000000..2bd527cc3f --- /dev/null +++ b/include/audiomanager/OWNERS @@ -0,0 +1,2 @@ +elaurent@google.com +jmtrivi@google.com diff --git a/libs/binder/Android.bp b/libs/binder/Android.bp index aedf6b0d18..905b25f397 100644 --- a/libs/binder/Android.bp +++ b/libs/binder/Android.bp @@ -143,6 +143,7 @@ filegroup { srcs: [ "aidl/android/content/pm/IPackageManagerNative.aidl", ], + path: "aidl", } subdirs = ["tests"] diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp index 9a561cba64..a2d10ab0ab 100644 --- a/libs/binder/IPCThreadState.cpp +++ b/libs/binder/IPCThreadState.cpp @@ -33,6 +33,7 @@ #include <private/binder/binder_module.h> #include <private/binder/Static.h> +#include <atomic> #include <errno.h> #include <inttypes.h> #include <pthread.h> @@ -116,7 +117,7 @@ static const int64_t kWorkSourcePropagatedBitIndex = 32; static const char* getReturnString(uint32_t cmd) { - size_t idx = cmd & 0xff; + size_t idx = cmd & _IOC_NRMASK; if (idx < sizeof(kReturnStrings) / sizeof(kReturnStrings[0])) return kReturnStrings[idx]; else @@ -278,14 +279,14 @@ static const void* printCommand(TextOutput& out, const void* _cmd) } static pthread_mutex_t gTLSMutex = PTHREAD_MUTEX_INITIALIZER; -static bool gHaveTLS = false; +static std::atomic<bool> gHaveTLS(false); static pthread_key_t gTLS = 0; -static bool gShutdown = false; -static bool gDisableBackgroundScheduling = false; +static std::atomic<bool> gShutdown = false; +static std::atomic<bool> gDisableBackgroundScheduling = false; IPCThreadState* IPCThreadState::self() { - if (gHaveTLS) { + if (gHaveTLS.load(std::memory_order_acquire)) { restart: const pthread_key_t k = gTLS; IPCThreadState* st = (IPCThreadState*)pthread_getspecific(k); @@ -293,13 +294,14 @@ restart: return new IPCThreadState; } - if (gShutdown) { + // Racey, heuristic test for simultaneous shutdown. + if (gShutdown.load(std::memory_order_relaxed)) { ALOGW("Calling IPCThreadState::self() during shutdown is dangerous, expect a crash.\n"); return nullptr; } pthread_mutex_lock(&gTLSMutex); - if (!gHaveTLS) { + if (!gHaveTLS.load(std::memory_order_relaxed)) { int key_create_value = pthread_key_create(&gTLS, threadDestructor); if (key_create_value != 0) { pthread_mutex_unlock(&gTLSMutex); @@ -307,7 +309,7 @@ restart: strerror(key_create_value)); return nullptr; } - gHaveTLS = true; + gHaveTLS.store(true, std::memory_order_release); } pthread_mutex_unlock(&gTLSMutex); goto restart; @@ -315,7 +317,7 @@ restart: IPCThreadState* IPCThreadState::selfOrNull() { - if (gHaveTLS) { + if (gHaveTLS.load(std::memory_order_acquire)) { const pthread_key_t k = gTLS; IPCThreadState* st = (IPCThreadState*)pthread_getspecific(k); return st; @@ -325,9 +327,9 @@ IPCThreadState* IPCThreadState::selfOrNull() void IPCThreadState::shutdown() { - gShutdown = true; + gShutdown.store(true, std::memory_order_relaxed); - if (gHaveTLS) { + if (gHaveTLS.load(std::memory_order_acquire)) { // XXX Need to wait for all thread pool threads to exit! IPCThreadState* st = (IPCThreadState*)pthread_getspecific(gTLS); if (st) { @@ -335,18 +337,18 @@ void IPCThreadState::shutdown() pthread_setspecific(gTLS, nullptr); } pthread_key_delete(gTLS); - gHaveTLS = false; + gHaveTLS.store(false, std::memory_order_release); } } void IPCThreadState::disableBackgroundScheduling(bool disable) { - gDisableBackgroundScheduling = disable; + gDisableBackgroundScheduling.store(disable, std::memory_order_relaxed); } bool IPCThreadState::backgroundSchedulingDisabled() { - return gDisableBackgroundScheduling; + return gDisableBackgroundScheduling.load(std::memory_order_relaxed); } sp<ProcessState> IPCThreadState::process() @@ -674,11 +676,11 @@ status_t IPCThreadState::transact(int32_t handle, if ((flags & TF_ONE_WAY) == 0) { if (UNLIKELY(mCallRestriction != ProcessState::CallRestriction::NONE)) { if (mCallRestriction == ProcessState::CallRestriction::ERROR_IF_NOT_ONEWAY) { - ALOGE("Process making non-oneway call but is restricted."); + ALOGE("Process making non-oneway call (code: %u) but is restricted.", code); CallStack::logStack("non-oneway call", CallStack::getCurrent(10).get(), ANDROID_LOG_ERROR); } else /* FATAL_IF_NOT_ONEWAY */ { - LOG_ALWAYS_FATAL("Process may not make oneway calls."); + LOG_ALWAYS_FATAL("Process may not make oneway calls (code: %u).", code); } } diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp index 4ba6c2a923..0203d41992 100644 --- a/libs/binder/IServiceManager.cpp +++ b/libs/binder/IServiceManager.cpp @@ -36,6 +36,9 @@ namespace android { sp<IServiceManager> defaultServiceManager() { + static Mutex gDefaultServiceManagerLock; + static sp<IServiceManager> gDefaultServiceManager; + if (gDefaultServiceManager != nullptr) return gDefaultServiceManager; { @@ -74,10 +77,13 @@ bool checkCallingPermission(const String16& permission, int32_t* outPid, int32_t bool checkPermission(const String16& permission, pid_t pid, uid_t uid) { + static Mutex gPermissionControllerLock; + static sp<IPermissionController> gPermissionController; + sp<IPermissionController> pc; - gDefaultServiceManagerLock.lock(); + gPermissionControllerLock.lock(); pc = gPermissionController; - gDefaultServiceManagerLock.unlock(); + gPermissionControllerLock.unlock(); int64_t startTime = 0; @@ -101,11 +107,11 @@ bool checkPermission(const String16& permission, pid_t pid, uid_t uid) } // Object is dead! - gDefaultServiceManagerLock.lock(); + gPermissionControllerLock.lock(); if (gPermissionController == pc) { gPermissionController = nullptr; } - gDefaultServiceManagerLock.unlock(); + gPermissionControllerLock.unlock(); } // Need to retrieve the permission controller. @@ -121,9 +127,9 @@ bool checkPermission(const String16& permission, pid_t pid, uid_t uid) } else { pc = interface_cast<IPermissionController>(binder); // Install the new permission controller, and try again. - gDefaultServiceManagerLock.lock(); + gPermissionControllerLock.lock(); gPermissionController = pc; - gDefaultServiceManagerLock.unlock(); + gPermissionControllerLock.unlock(); } } } @@ -142,6 +148,8 @@ public: virtual sp<IBinder> getService(const String16& name) const { + static bool gSystemBootCompleted = false; + sp<IBinder> svc = checkService(name); if (svc != nullptr) return svc; diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index afa3d33349..458961b70d 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -93,7 +93,7 @@ enum { BLOB_ASHMEM_MUTABLE = 2, }; -void acquire_object(const sp<ProcessState>& proc, +static void acquire_object(const sp<ProcessState>& proc, const flat_binder_object& obj, const void* who, size_t* outAshmemSize) { switch (obj.hdr.type) { @@ -135,12 +135,6 @@ void acquire_object(const sp<ProcessState>& proc, ALOGD("Invalid object type 0x%08x", obj.hdr.type); } -void acquire_object(const sp<ProcessState>& proc, - const flat_binder_object& obj, const void* who) -{ - acquire_object(proc, obj, who, nullptr); -} - static void release_object(const sp<ProcessState>& proc, const flat_binder_object& obj, const void* who, size_t* outAshmemSize) { @@ -189,19 +183,13 @@ static void release_object(const sp<ProcessState>& proc, ALOGE("Invalid object type 0x%08x", obj.hdr.type); } -void release_object(const sp<ProcessState>& proc, - const flat_binder_object& obj, const void* who) -{ - release_object(proc, obj, who, nullptr); -} - inline static status_t finish_flatten_binder( const sp<IBinder>& /*binder*/, const flat_binder_object& flat, Parcel* out) { return out->writeObject(flat, false); } -status_t flatten_binder(const sp<ProcessState>& /*proc*/, +static status_t flatten_binder(const sp<ProcessState>& /*proc*/, const sp<IBinder>& binder, Parcel* out) { flat_binder_object obj; @@ -243,7 +231,7 @@ status_t flatten_binder(const sp<ProcessState>& /*proc*/, return finish_flatten_binder(binder, obj, out); } -status_t flatten_binder(const sp<ProcessState>& /*proc*/, +static status_t flatten_binder(const sp<ProcessState>& /*proc*/, const wp<IBinder>& binder, Parcel* out) { flat_binder_object obj; @@ -299,7 +287,7 @@ inline static status_t finish_unflatten_binder( return NO_ERROR; } -status_t unflatten_binder(const sp<ProcessState>& proc, +static status_t unflatten_binder(const sp<ProcessState>& proc, const Parcel& in, sp<IBinder>* out) { const flat_binder_object* flat = in.readObject(false); @@ -318,7 +306,7 @@ status_t unflatten_binder(const sp<ProcessState>& proc, return BAD_TYPE; } -status_t unflatten_binder(const sp<ProcessState>& proc, +static status_t unflatten_binder(const sp<ProcessState>& proc, const Parcel& in, wp<IBinder>* out) { const flat_binder_object* flat = in.readObject(false); diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp index 63f49ddba7..2d156df56b 100644 --- a/libs/binder/ProcessState.cpp +++ b/libs/binder/ProcessState.cpp @@ -40,7 +40,7 @@ #include <sys/stat.h> #include <sys/types.h> -#define BINDER_VM_SIZE ((1 * 1024 * 1024) - sysconf(_SC_PAGE_SIZE) * 2) +#define DEFAULT_BINDER_VM_SIZE ((1 * 1024 * 1024) - sysconf(_SC_PAGE_SIZE) * 2) #define DEFAULT_MAX_BINDER_THREADS 15 #ifdef __ANDROID_VNDK__ @@ -77,7 +77,13 @@ sp<ProcessState> ProcessState::self() if (gProcess != nullptr) { return gProcess; } - gProcess = new ProcessState(kDefaultDriver); + gProcess = new ProcessState(kDefaultDriver, DEFAULT_BINDER_VM_SIZE); + return gProcess; +} + +sp<ProcessState> ProcessState::selfOrNull() +{ + Mutex::Autolock _l(gProcessMutex); return gProcess; } @@ -98,13 +104,19 @@ sp<ProcessState> ProcessState::initWithDriver(const char* driver) driver = "/dev/binder"; } - gProcess = new ProcessState(driver); + gProcess = new ProcessState(driver, DEFAULT_BINDER_VM_SIZE); return gProcess; } -sp<ProcessState> ProcessState::selfOrNull() -{ +sp<ProcessState> ProcessState::initWithMmapSize(size_t mmap_size) { Mutex::Autolock _l(gProcessMutex); + if (gProcess != nullptr) { + LOG_ALWAYS_FATAL_IF(mmap_size != gProcess->getMmapSize(), + "ProcessState already initialized with a different mmap size."); + return gProcess; + } + + gProcess = new ProcessState(kDefaultDriver, mmap_size); return gProcess; } @@ -237,6 +249,10 @@ ssize_t ProcessState::getKernelReferences(size_t buf_count, uintptr_t* buf) return count; } +size_t ProcessState::getMmapSize() { + return mMmapSize; +} + void ProcessState::setCallRestriction(CallRestriction restriction) { LOG_ALWAYS_FATAL_IF(IPCThreadState::selfOrNull(), "Call restrictions must be set before the threadpool is started."); @@ -421,7 +437,7 @@ static int open_driver(const char *driver) return fd; } -ProcessState::ProcessState(const char *driver) +ProcessState::ProcessState(const char *driver, size_t mmap_size) : mDriverName(String8(driver)) , mDriverFD(open_driver(driver)) , mVMStart(MAP_FAILED) @@ -435,11 +451,12 @@ ProcessState::ProcessState(const char *driver) , mBinderContextUserData(nullptr) , mThreadPoolStarted(false) , mThreadPoolSeq(1) + , mMmapSize(mmap_size) , mCallRestriction(CallRestriction::NONE) { if (mDriverFD >= 0) { // mmap the binder, providing a chunk of virtual address space to receive transactions. - mVMStart = mmap(nullptr, BINDER_VM_SIZE, PROT_READ, MAP_PRIVATE | MAP_NORESERVE, mDriverFD, 0); + mVMStart = mmap(nullptr, mMmapSize, PROT_READ, MAP_PRIVATE | MAP_NORESERVE, mDriverFD, 0); if (mVMStart == MAP_FAILED) { // *sigh* ALOGE("Using %s failed: unable to mmap transaction memory.\n", mDriverName.c_str()); @@ -456,7 +473,7 @@ ProcessState::~ProcessState() { if (mDriverFD >= 0) { if (mVMStart != MAP_FAILED) { - munmap(mVMStart, BINDER_VM_SIZE); + munmap(mVMStart, mMmapSize); } close(mDriverFD); } diff --git a/libs/binder/Static.cpp b/libs/binder/Static.cpp index bd0e6f9a11..8625c6f278 100644 --- a/libs/binder/Static.cpp +++ b/libs/binder/Static.cpp @@ -75,13 +75,4 @@ TextOutput& aerr(gStderrTextOutput); Mutex& gProcessMutex = *new Mutex; sp<ProcessState> gProcess; -// ------------ IServiceManager.cpp - -Mutex gDefaultServiceManagerLock; -sp<IServiceManager> gDefaultServiceManager; -#ifndef __ANDROID_VNDK__ -sp<IPermissionController> gPermissionController; -#endif -bool gSystemBootCompleted = false; - } // namespace android diff --git a/libs/binder/include/binder/BpBinder.h b/libs/binder/include/binder/BpBinder.h index 1d4f88113a..78f2e1d831 100644 --- a/libs/binder/include/binder/BpBinder.h +++ b/libs/binder/include/binder/BpBinder.h @@ -67,7 +67,6 @@ public: virtual BpBinder* remoteBinder(); - status_t setConstantData(const void* data, size_t size); void sendObituary(); static uint32_t getBinderProxyCount(uint32_t uid); diff --git a/libs/binder/include/binder/Parcel.h b/libs/binder/include/binder/Parcel.h index e5219a5590..0cdabb0265 100644 --- a/libs/binder/include/binder/Parcel.h +++ b/libs/binder/include/binder/Parcel.h @@ -932,23 +932,6 @@ inline TextOutput& operator<<(TextOutput& to, const Parcel& parcel) return to; } -// --------------------------------------------------------------------------- - -// Generic acquire and release of objects. -void acquire_object(const sp<ProcessState>& proc, - const flat_binder_object& obj, const void* who); -void release_object(const sp<ProcessState>& proc, - const flat_binder_object& obj, const void* who); - -void flatten_binder(const sp<ProcessState>& proc, - const sp<IBinder>& binder, flat_binder_object* out); -void flatten_binder(const sp<ProcessState>& proc, - const wp<IBinder>& binder, flat_binder_object* out); -status_t unflatten_binder(const sp<ProcessState>& proc, - const flat_binder_object& flat, sp<IBinder>* out); -status_t unflatten_binder(const sp<ProcessState>& proc, - const flat_binder_object& flat, wp<IBinder>* out); - }; // namespace android // --------------------------------------------------------------------------- diff --git a/libs/binder/include/binder/ProcessState.h b/libs/binder/include/binder/ProcessState.h index 224cb36807..1622ba2712 100644 --- a/libs/binder/include/binder/ProcessState.h +++ b/libs/binder/include/binder/ProcessState.h @@ -36,6 +36,8 @@ class ProcessState : public virtual RefBase public: static sp<ProcessState> self(); static sp<ProcessState> selfOrNull(); + // Note: don't call self() or selfOrNull() before initWithMmapSize() + static sp<ProcessState> initWithMmapSize(size_t mmapSize); // size in bytes /* initWithDriver() can be used to configure libbinder to use * a different binder driver dev node. It must be called *before* @@ -76,6 +78,7 @@ public: String8 getDriverName(); ssize_t getKernelReferences(size_t count, uintptr_t* buf); + size_t getMmapSize(); enum class CallRestriction { // all calls okay @@ -92,7 +95,7 @@ public: private: friend class IPCThreadState; - explicit ProcessState(const char* driver); + explicit ProcessState(const char* driver, size_t mmap_size); ~ProcessState(); ProcessState(const ProcessState& o); @@ -121,6 +124,8 @@ private: int64_t mStarvationStartTimeMs; mutable Mutex mLock; // protects everything below. + // TODO: mManagesContexts is often accessed without the lock. + // Explain why that's safe. Vector<handle_entry>mHandleToObject; @@ -135,6 +140,7 @@ private: String8 mRootDir; bool mThreadPoolStarted; volatile int32_t mThreadPoolSeq; + const size_t mMmapSize; CallRestriction mCallRestriction; }; diff --git a/libs/binder/include/private/binder/Static.h b/libs/binder/include/private/binder/Static.h index 171be7791e..f8e0ee5f8d 100644 --- a/libs/binder/include/private/binder/Static.h +++ b/libs/binder/include/private/binder/Static.h @@ -21,10 +21,6 @@ #include <binder/IBinder.h> #include <binder/ProcessState.h> -#ifndef __ANDROID_VNDK__ -#include <binder/IPermissionController.h> -#endif -#include <binder/IServiceManager.h> namespace android { @@ -35,12 +31,4 @@ extern Vector<int32_t> gTextBuffers; extern Mutex& gProcessMutex; extern sp<ProcessState> gProcess; -// For IServiceManager.cpp -extern Mutex gDefaultServiceManagerLock; -extern sp<IServiceManager> gDefaultServiceManager; -#ifndef __ANDROID_VNDK__ -extern sp<IPermissionController> gPermissionController; -#endif -extern bool gSystemBootCompleted; - } // namespace android diff --git a/libs/sensorprivacy/Android.bp b/libs/sensorprivacy/Android.bp index e0e3469fbb..4a606ffec2 100644 --- a/libs/sensorprivacy/Android.bp +++ b/libs/sensorprivacy/Android.bp @@ -28,8 +28,7 @@ cc_library_shared { ], srcs: [ - "aidl/android/hardware/ISensorPrivacyListener.aidl", - "aidl/android/hardware/ISensorPrivacyManager.aidl", + ":libsensorprivacy_aidl", "SensorPrivacyManager.cpp", ], @@ -45,3 +44,12 @@ cc_library_shared { export_shared_lib_headers: ["libbinder"], } + +filegroup { + name: "libsensorprivacy_aidl", + srcs: [ + "aidl/android/hardware/ISensorPrivacyListener.aidl", + "aidl/android/hardware/ISensorPrivacyManager.aidl", + ], + path: "aidl", +} diff --git a/opengl/libs/ETC1/etc1.cpp b/opengl/libs/ETC1/etc1.cpp index 97d10851de..19d428a394 100644 --- a/opengl/libs/ETC1/etc1.cpp +++ b/opengl/libs/ETC1/etc1.cpp @@ -378,34 +378,30 @@ static void etc_encodeBaseColors(etc1_byte* pBaseColors, const etc1_byte* pColors, etc_compressed* pCompressed) { int r1, g1, b1, r2, g2, b2; // 8 bit base colors for sub-blocks bool differential; - { - int r51 = convert8To5(pColors[0]); - int g51 = convert8To5(pColors[1]); - int b51 = convert8To5(pColors[2]); - int r52 = convert8To5(pColors[3]); - int g52 = convert8To5(pColors[4]); - int b52 = convert8To5(pColors[5]); - - r1 = convert5To8(r51); - g1 = convert5To8(g51); - b1 = convert5To8(b51); - - int dr = r52 - r51; - int dg = g52 - g51; - int db = b52 - b51; - - differential = inRange4bitSigned(dr) && inRange4bitSigned(dg) - && inRange4bitSigned(db); - if (differential) { - r2 = convert5To8(r51 + dr); - g2 = convert5To8(g51 + dg); - b2 = convert5To8(b51 + db); - pCompressed->high |= (r51 << 27) | ((7 & dr) << 24) | (g51 << 19) - | ((7 & dg) << 16) | (b51 << 11) | ((7 & db) << 8) | 2; - } - } - - if (!differential) { + int r51 = convert8To5(pColors[0]); + int g51 = convert8To5(pColors[1]); + int b51 = convert8To5(pColors[2]); + int r52 = convert8To5(pColors[3]); + int g52 = convert8To5(pColors[4]); + int b52 = convert8To5(pColors[5]); + + r1 = convert5To8(r51); + g1 = convert5To8(g51); + b1 = convert5To8(b51); + + int dr = r52 - r51; + int dg = g52 - g51; + int db = b52 - b51; + + differential = inRange4bitSigned(dr) && inRange4bitSigned(dg) + && inRange4bitSigned(db); + if (differential) { + r2 = convert5To8(r51 + dr); + g2 = convert5To8(g51 + dg); + b2 = convert5To8(b51 + db); + pCompressed->high |= (r51 << 27) | ((7 & dr) << 24) | (g51 << 19) + | ((7 & dg) << 16) | (b51 << 11) | ((7 & db) << 8) | 2; + } else { int r41 = convert8To4(pColors[0]); int g41 = convert8To4(pColors[1]); int b41 = convert8To4(pColors[2]); diff --git a/services/gpuservice/OWNERS b/services/gpuservice/OWNERS new file mode 100644 index 0000000000..5d028393f6 --- /dev/null +++ b/services/gpuservice/OWNERS @@ -0,0 +1,3 @@ +chrisforbes@google.com +lpy@google.com +zzyiwei@google.com diff --git a/services/surfaceflinger/Android.bp b/services/surfaceflinger/Android.bp index 501d176401..5b298b4a93 100644 --- a/services/surfaceflinger/Android.bp +++ b/services/surfaceflinger/Android.bp @@ -100,6 +100,10 @@ cc_defaults { lto: { thin: true, }, + // TODO(b/131771163): Fix broken fuzzer support with LTO. + sanitize: { + fuzzer: false, + }, } cc_library_headers { diff --git a/services/surfaceflinger/layerproto/Android.bp b/services/surfaceflinger/layerproto/Android.bp index cb368b0886..d03cb7b22a 100644 --- a/services/surfaceflinger/layerproto/Android.bp +++ b/services/surfaceflinger/layerproto/Android.bp @@ -43,7 +43,7 @@ java_library_static { type: "nano", }, srcs: ["*.proto"], - no_framework_libs: true, + sdk_version: "core_platform", target: { android: { jarjar_rules: "jarjar-rules.txt", diff --git a/services/surfaceflinger/tests/fakehwc/SFFakeHwc_test.cpp b/services/surfaceflinger/tests/fakehwc/SFFakeHwc_test.cpp index f9e0b6413b..a892a2abd0 100644 --- a/services/surfaceflinger/tests/fakehwc/SFFakeHwc_test.cpp +++ b/services/surfaceflinger/tests/fakehwc/SFFakeHwc_test.cpp @@ -54,10 +54,11 @@ using namespace sftest; namespace { // Mock test helpers +using ::testing::_; +using ::testing::DoAll; using ::testing::Invoke; using ::testing::Return; using ::testing::SetArgPointee; -using ::testing::_; using Transaction = SurfaceComposerClient::Transaction; diff --git a/services/vr/hardware_composer/Android.bp b/services/vr/hardware_composer/Android.bp index 4c34b938c8..1604775da5 100644 --- a/services/vr/hardware_composer/Android.bp +++ b/services/vr/hardware_composer/Android.bp @@ -1,180 +1,153 @@ cc_library_shared { - name: "libvr_hwc-hal", + name: "libvr_hwc-hal", + + srcs: [ + "impl/vr_hwc.cpp", + "impl/vr_composer_client.cpp", + ], + + static_libs: [ + "libbroadcastring", + "libdisplay", + ], + + shared_libs: [ + "android.frameworks.vr.composer@1.0", + "android.hardware.graphics.composer@2.1", + "android.hardware.graphics.mapper@2.0", + "android.hardware.graphics.mapper@3.0", + "libbase", + "libbufferhubqueue", + "libbinder", + "libcutils", + "libfmq", + "libhardware", + "libhidlbase", + "libhidltransport", + "liblog", + "libsync", + "libui", + "libutils", + "libpdx_default_transport", + ], + + header_libs: [ + "android.hardware.graphics.composer@2.1-command-buffer", + "android.hardware.graphics.composer@2.1-hal", + ], + + export_header_lib_headers: [ + "android.hardware.graphics.composer@2.1-hal", + ], + + export_static_lib_headers: [ + "libdisplay", + ], + + export_shared_lib_headers: [ + "android.frameworks.vr.composer@1.0", + "android.hardware.graphics.composer@2.1", + ], + + export_include_dirs: ["."], + + cflags: [ + "-DLOG_TAG=\"vr_hwc\"", + "-DATRACE_TAG=ATRACE_TAG_GRAPHICS", + "-Wall", + "-Werror", + "-Wno-error=unused-private-field", + // Warnings in vr_hwc.cpp to be fixed after sync of goog/master. + "-Wno-sign-compare", + "-Wno-unused-parameter", + ], - srcs: [ - "impl/vr_hwc.cpp", - "impl/vr_composer_client.cpp", - ], - - static_libs: [ - "libbroadcastring", - "libdisplay", - ], - - shared_libs: [ - "android.frameworks.vr.composer@1.0", - "android.hardware.graphics.composer@2.1", - "android.hardware.graphics.mapper@2.0", - "android.hardware.graphics.mapper@3.0", - "libbase", - "libbufferhubqueue", - "libbinder", - "libcutils", - "libfmq", - "libhardware", - "libhidlbase", - "libhidltransport", - "liblog", - "libsync", - "libui", - "libutils", - "libpdx_default_transport", - ], - - header_libs: [ - "android.hardware.graphics.composer@2.1-command-buffer", - "android.hardware.graphics.composer@2.1-hal", - ], - - export_header_lib_headers: [ - "android.hardware.graphics.composer@2.1-hal", - ], - - export_static_lib_headers: [ - "libdisplay", - ], - - export_shared_lib_headers: [ - "android.frameworks.vr.composer@1.0", - "android.hardware.graphics.composer@2.1", - ], - - export_include_dirs: ["."], - - cflags: [ - "-DLOG_TAG=\"vr_hwc\"", - "-DATRACE_TAG=ATRACE_TAG_GRAPHICS", - "-Wall", - "-Werror", - "-Wno-error=unused-private-field", - // Warnings in vr_hwc.cpp to be fixed after sync of goog/master. - "-Wno-sign-compare", - "-Wno-unused-parameter", - ], - -} - -cc_library_static { - name: "libvr_hwc-binder", - srcs: [ - "aidl/android/dvr/IVrComposer.aidl", - "aidl/android/dvr/IVrComposerCallback.aidl", - "aidl/android/dvr/parcelable_composer_frame.cpp", - "aidl/android/dvr/parcelable_composer_layer.cpp", - "aidl/android/dvr/parcelable_unique_fd.cpp", - ], - aidl: { - include_dirs: ["frameworks/native/services/vr/hardware_composer/aidl"], - export_aidl_headers: true, - }, - export_include_dirs: ["aidl"], - - cflags: [ - "-Wall", - "-Werror", - ], - - shared_libs: [ - "libbinder", - "libui", - "libutils", - "libvr_hwc-hal", - ], } cc_library_static { - name: "libvr_hwc-impl", - srcs: [ - "vr_composer.cpp", - ], - static_libs: [ - "libvr_hwc-binder", - ], - shared_libs: [ - "libbase", - "libbinder", - "liblog", - "libui", - "libutils", - "libvr_hwc-hal", - ], - export_shared_lib_headers: [ - "libvr_hwc-hal", - ], - cflags: [ - "-DLOG_TAG=\"vr_hwc\"", - "-Wall", - "-Werror", - ], + name: "libvr_hwc-impl", + srcs: [ + "vr_composer.cpp", + ], + static_libs: [ + "libvr_hwc-binder", + ], + shared_libs: [ + "libbase", + "libbinder", + "liblog", + "libui", + "libutils", + "libvr_hwc-hal", + ], + export_shared_lib_headers: [ + "libvr_hwc-hal", + ], + cflags: [ + "-DLOG_TAG=\"vr_hwc\"", + "-Wall", + "-Werror", + ], } cc_binary { - name: "vr_hwc", - vintf_fragments: ["manifest_vr_hwc.xml"], - srcs: [ - "vr_hardware_composer_service.cpp" - ], - static_libs: [ - "libvr_hwc-impl", - // NOTE: This needs to be included after the *-impl lib otherwise the - // symbols in the *-binder library get optimized out. - "libvr_hwc-binder", - ], - shared_libs: [ - "android.frameworks.vr.composer@1.0", - "android.hardware.graphics.composer@2.1", - "libbase", - "libbinder", - "liblog", - "libhardware", - "libhidlbase", - "libui", - "libutils", - "libvr_hwc-hal", - ], - cflags: [ - "-DLOG_TAG=\"vr_hwc\"", - "-Wall", - "-Werror", - ], - init_rc: [ - "vr_hwc.rc", - ], + name: "vr_hwc", + vintf_fragments: ["manifest_vr_hwc.xml"], + srcs: [ + "vr_hardware_composer_service.cpp", + ], + static_libs: [ + "libvr_hwc-impl", + // NOTE: This needs to be included after the *-impl lib otherwise the + // symbols in the *-binder library get optimized out. + "libvr_hwc-binder", + ], + shared_libs: [ + "android.frameworks.vr.composer@1.0", + "android.hardware.graphics.composer@2.1", + "libbase", + "libbinder", + "liblog", + "libhardware", + "libhwbinder", + "libhidlbase", + "libui", + "libutils", + "libvr_hwc-hal", + ], + cflags: [ + "-DLOG_TAG=\"vr_hwc\"", + "-Wall", + "-Werror", + ], + init_rc: [ + "vr_hwc.rc", + ], } cc_test { - name: "vr_hwc_test", - gtest: true, - srcs: ["tests/vr_composer_test.cpp"], - static_libs: [ - "libgtest", - "libvr_hwc-impl", - // NOTE: This needs to be included after the *-impl lib otherwise the - // symbols in the *-binder library get optimized out. - "libvr_hwc-binder", - ], - cflags: [ - "-Wall", - "-Werror", - // warnings in vr_composer_test.cpp to be fixed after merge of goog/master - "-Wno-sign-compare", - "-Wno-unused-parameter", - ], - shared_libs: [ - "libbase", - "libbinder", - "liblog", - "libui", - "libutils", - ], + name: "vr_hwc_test", + gtest: true, + srcs: ["tests/vr_composer_test.cpp"], + static_libs: [ + "libgtest", + "libvr_hwc-impl", + // NOTE: This needs to be included after the *-impl lib otherwise the + // symbols in the *-binder library get optimized out. + "libvr_hwc-binder", + ], + cflags: [ + "-Wall", + "-Werror", + // warnings in vr_composer_test.cpp to be fixed after merge of goog/master + "-Wno-sign-compare", + "-Wno-unused-parameter", + ], + shared_libs: [ + "libbase", + "libbinder", + "liblog", + "libui", + "libutils", + ], } diff --git a/services/vr/hardware_composer/aidl/Android.bp b/services/vr/hardware_composer/aidl/Android.bp new file mode 100644 index 0000000000..a1d5392071 --- /dev/null +++ b/services/vr/hardware_composer/aidl/Android.bp @@ -0,0 +1,27 @@ +cc_library_static { + name: "libvr_hwc-binder", + srcs: [ + "android/dvr/IVrComposer.aidl", + "android/dvr/IVrComposerCallback.aidl", + "android/dvr/parcelable_composer_frame.cpp", + "android/dvr/parcelable_composer_layer.cpp", + "android/dvr/parcelable_unique_fd.cpp", + ], + aidl: { + local_include_dirs: ["."], + export_aidl_headers: true, + }, + export_include_dirs: ["."], + + cflags: [ + "-Wall", + "-Werror", + ], + + shared_libs: [ + "libbinder", + "libui", + "libutils", + "libvr_hwc-hal", + ], +} diff --git a/services/vr/virtual_touchpad/Android.bp b/services/vr/virtual_touchpad/Android.bp index 131a306c08..dcaa663160 100644 --- a/services/vr/virtual_touchpad/Android.bp +++ b/services/vr/virtual_touchpad/Android.bp @@ -62,7 +62,7 @@ cc_test { service_src = [ "main.cpp", "VirtualTouchpadService.cpp", - "aidl/android/dvr/IVirtualTouchpadService.aidl", + ":virtualtouchpad_aidl", ] service_static_libs = [ @@ -99,7 +99,7 @@ cc_binary { client_src = [ "VirtualTouchpadClient.cpp", "DvrVirtualTouchpadClient.cpp", - "aidl/android/dvr/IVirtualTouchpadService.aidl", + ":virtualtouchpad_aidl", ] client_shared_libs = [ @@ -122,3 +122,9 @@ cc_library { name: "libvirtualtouchpadclient", export_include_dirs: ["include"], } + +filegroup { + name: "virtualtouchpad_aidl", + srcs: ["aidl/android/dvr/IVirtualTouchpadService.aidl"], + path: "aidl", +} diff --git a/vulkan/libvulkan/layers_extensions.cpp b/vulkan/libvulkan/layers_extensions.cpp index af1adcff62..5679412732 100644 --- a/vulkan/libvulkan/layers_extensions.cpp +++ b/vulkan/libvulkan/layers_extensions.cpp @@ -388,9 +388,8 @@ void ForEachFileInZip(const std::string& zipname, return; } std::string prefix(dir_in_zip + "/"); - const ZipString prefix_str(prefix.c_str()); void* iter_cookie = nullptr; - if ((err = StartIteration(zip, &iter_cookie, &prefix_str, nullptr)) != 0) { + if ((err = StartIteration(zip, &iter_cookie, prefix, "")) != 0) { ALOGE("failed to iterate entries in apk '%s': %d", zipname.c_str(), err); CloseArchive(zip); @@ -399,11 +398,9 @@ void ForEachFileInZip(const std::string& zipname, ALOGD("searching for layers in '%s!/%s'", zipname.c_str(), dir_in_zip.c_str()); ZipEntry entry; - ZipString name; + std::string name; while (Next(iter_cookie, &entry, &name) == 0) { - std::string filename( - reinterpret_cast<const char*>(name.name) + prefix.length(), - name.name_length - prefix.length()); + std::string filename(name.substr(prefix.length())); // only enumerate direct entries of the directory, not subdirectories if (filename.find('/') != filename.npos) continue; |