Merge "libbinder_ndk: _delete APIs take * not **."
diff --git a/cmds/installd/Android.bp b/cmds/installd/Android.bp
index 94c3102..9d0d8ba 100644
--- a/cmds/installd/Android.bp
+++ b/cmds/installd/Android.bp
@@ -108,10 +108,8 @@
"-Wall",
"-Werror"
],
- clang: true,
- srcs: [
- "otapreopt_parameters.cpp"],
+ srcs: ["otapreopt_parameters.cpp"],
export_include_dirs: ["."],
@@ -123,4 +121,39 @@
],
}
-subdirs = ["tests"]
+//
+// OTA Executable
+//
+
+cc_binary {
+ name: "otapreopt",
+ cflags: [
+ "-Wall",
+ "-Werror"
+ ],
+
+ srcs: [
+ "dexopt.cpp",
+ "globals.cpp",
+ "otapreopt.cpp",
+ "utils.cpp",
+ ],
+
+ header_libs: ["dex2oat_headers"],
+
+ static_libs: [
+ "libartimagevalues",
+ "libdiskusage",
+ "libotapreoptparameters",
+ ],
+
+ shared_libs: [
+ "libbase",
+ "libcrypto",
+ "libcutils",
+ "liblog",
+ "liblogwrap",
+ "libselinux",
+ "libutils",
+ ],
+}
diff --git a/cmds/installd/Android.mk b/cmds/installd/Android.mk
index a4f95da..30de0b3 100644
--- a/cmds/installd/Android.mk
+++ b/cmds/installd/Android.mk
@@ -1,43 +1,5 @@
LOCAL_PATH := $(call my-dir)
-#
-# OTA Executable
-#
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := otapreopt
-LOCAL_CFLAGS := -Wall -Werror
-
-# Base & ASLR boundaries for boot image creation.
-ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA
- LOCAL_LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA := -0x1000000
-else
- LOCAL_LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA := $(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
-endif
-ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA
- LOCAL_LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA := 0x1000000
-else
- LOCAL_LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA := $(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
-endif
-LOCAL_CFLAGS += -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS)
-LOCAL_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LOCAL_LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
-LOCAL_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LOCAL_LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
-
-LOCAL_SRC_FILES := otapreopt.cpp otapreopt_parameters.cpp globals.cpp utils.cpp dexopt.cpp
-LOCAL_HEADER_LIBRARIES := dex2oat_headers
-LOCAL_SHARED_LIBRARIES := \
- libbase \
- libcrypto \
- libcutils \
- liblog \
- liblogwrap \
- libselinux \
- libutils \
-
-LOCAL_STATIC_LIBRARIES := libdiskusage
-LOCAL_CLANG := true
-include $(BUILD_EXECUTABLE)
-
# OTA slot script
include $(CLEAR_VARS)
diff --git a/cmds/installd/art_helper/Android.bp b/cmds/installd/art_helper/Android.bp
new file mode 100644
index 0000000..c47dd72
--- /dev/null
+++ b/cmds/installd/art_helper/Android.bp
@@ -0,0 +1,12 @@
+// 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
new file mode 100644
index 0000000..a139049
--- /dev/null
+++ b/cmds/installd/art_helper/art_image_values.cpp
@@ -0,0 +1,37 @@
+/*
+ * 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
new file mode 100644
index 0000000..20c44c9
--- /dev/null
+++ b/cmds/installd/art_helper/art_image_values.h
@@ -0,0 +1,34 @@
+/*
+ * 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/otapreopt.cpp b/cmds/installd/otapreopt.cpp
index 7291ef3..73098f8 100644
--- a/cmds/installd/otapreopt.cpp
+++ b/cmds/installd/otapreopt.cpp
@@ -32,6 +32,7 @@
#include <android-base/macros.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
+#include <art_image_values.h>
#include <cutils/fs.h>
#include <cutils/properties.h>
#include <dex2oat_return_codes.h>
@@ -441,8 +442,8 @@
cmd.push_back(StringPrintf("--instruction-set=%s", isa));
- int32_t base_offset = ChooseRelocationOffsetDelta(ART_BASE_ADDRESS_MIN_DELTA,
- ART_BASE_ADDRESS_MAX_DELTA);
+ int32_t base_offset = ChooseRelocationOffsetDelta(art::GetImageMinBaseAddressDelta(),
+ art::GetImageMaxBaseAddressDelta());
cmd.push_back(StringPrintf("--base-offset-delta=%d", base_offset));
std::string error_msg;
@@ -466,9 +467,9 @@
}
cmd.push_back(StringPrintf("--oat-file=%s", oat_path.c_str()));
- int32_t base_offset = ChooseRelocationOffsetDelta(ART_BASE_ADDRESS_MIN_DELTA,
- ART_BASE_ADDRESS_MAX_DELTA);
- cmd.push_back(StringPrintf("--base=0x%x", ART_BASE_ADDRESS + base_offset));
+ int32_t base_offset = ChooseRelocationOffsetDelta(art::GetImageMinBaseAddressDelta(),
+ art::GetImageMaxBaseAddressDelta());
+ cmd.push_back(StringPrintf("--base=0x%x", art::GetImageBaseAddress() + base_offset));
cmd.push_back(StringPrintf("--instruction-set=%s", isa));
@@ -610,7 +611,7 @@
// If the dexopt failed, we may have a stale boot image from a previous OTA run.
// Then regenerate and retry.
if (WEXITSTATUS(dexopt_result) ==
- static_cast<int>(art::dex2oat::ReturnCode::kCreateRuntime)) {
+ static_cast<int>(::art::dex2oat::ReturnCode::kCreateRuntime)) {
if (!PrepareBootImage(/* force */ true)) {
LOG(ERROR) << "Forced boot image creating failed. Original error return was "
<< dexopt_result;
diff --git a/cmds/installd/otapreopt_parameters.cpp b/cmds/installd/otapreopt_parameters.cpp
index cf3de01..b1ad8db 100644
--- a/cmds/installd/otapreopt_parameters.cpp
+++ b/cmds/installd/otapreopt_parameters.cpp
@@ -16,6 +16,8 @@
#include "otapreopt_parameters.h"
+#include <cstring>
+
#include <android-base/logging.h>
#include "dexopt.h"
@@ -248,6 +250,8 @@
case 8: num_args_expected = 16; break;
// Version 9 adds a new dexopt flag: DEXOPT_GENERATE_APP_IMAGE
case 9: num_args_expected = 16; break;
+ // Version 10 is a compatibility bump.
+ case 10: num_args_expected = 16; break;
default:
LOG(ERROR) << "Don't know how to read arguments for version " << version;
return false;
@@ -360,6 +364,15 @@
}
}
+ if (version < 10) {
+ // Do not accept '&' as shared libraries from versions prior to 10. These may lead
+ // to runtime crashes. The server side of version 10+ should send the correct
+ // context in almost all cases (e.g., only for actual shared packages).
+ if (shared_libraries != nullptr && std::string("&") == shared_libraries) {
+ return false;
+ }
+ }
+
return true;
}
diff --git a/cmds/installd/tests/installd_otapreopt_test.cpp b/cmds/installd/tests/installd_otapreopt_test.cpp
index b518507..66dd51e 100644
--- a/cmds/installd/tests/installd_otapreopt_test.cpp
+++ b/cmds/installd/tests/installd_otapreopt_test.cpp
@@ -114,11 +114,14 @@
case 7: return "7";
case 8: return "8";
case 9: return "9";
+ case 10: return "10";
}
return nullptr;
}
- std::vector<const char*> getArgs(uint32_t version, bool versioned) {
+ std::vector<const char*> getArgs(uint32_t version,
+ bool versioned,
+ const char* shared_libs = "shared.lib") {
std::vector<const char*> args;
args.push_back("otapreopt"); // "otapreopt"
args.push_back("a"); // slot
@@ -135,7 +138,7 @@
args.push_back("0"); // dexopt_flags
args.push_back("speed"); // filter
args.push_back("!"); // volume
- args.push_back("shared.lib"); // libs
+ args.push_back(shared_libs); // libs
if (version > 1) {
args.push_back("!"); // seinfo
@@ -159,9 +162,11 @@
return args;
}
- void VerifyReadArguments(uint32_t version, bool versioned) {
+ void VerifyReadArguments(uint32_t version,
+ bool versioned,
+ const char* shared_libs = "shared.lib") {
OTAPreoptParameters params;
- std::vector<const char*> args = getArgs(version, versioned);
+ std::vector<const char*> args = getArgs(version, versioned, shared_libs);
ASSERT_TRUE(params.ReadArguments(args.size() - 1, args.data()));
verifyPackageParameters(params, version, versioned, args.data());
}
@@ -199,6 +204,18 @@
VerifyReadArguments(7, true);
}
+TEST_F(OTAPreoptTest, ReadArgumentsV9SharedLibsAmpersand) {
+ OTAPreoptParameters params;
+ std::vector<const char*> args = getArgs(9, true, "&");
+ ASSERT_FALSE(params.ReadArguments(args.size() - 1, args.data()));
+}
+
+TEST_F(OTAPreoptTest, ReadArgumentsV10SharedLibsAmpersand) {
+ OTAPreoptParameters params;
+ std::vector<const char*> args = getArgs(10, true, "&");
+ ASSERT_TRUE(params.ReadArguments(args.size() - 1, args.data()));
+}
+
TEST_F(OTAPreoptTest, ReadArgumentsFailToManyArgs) {
OTAPreoptParameters params;
std::vector<const char*> args = getArgs(5, true);
diff --git a/libs/binder/ndk/ibinder.cpp b/libs/binder/ndk/ibinder.cpp
index 71310ff..896c5c1 100644
--- a/libs/binder/ndk/ibinder.cpp
+++ b/libs/binder/ndk/ibinder.cpp
@@ -122,7 +122,7 @@
binder_flags_t flags) {
if (isUserCommand(code)) {
if (!data.checkInterface(this)) {
- return STATUS_PERMISSION_DENIED;
+ return STATUS_BAD_TYPE;
}
const AParcel in = AParcel::readOnly(this, &data);
diff --git a/libs/binder/ndk/include_ndk/android/binder_status.h b/libs/binder/ndk/include_ndk/android/binder_status.h
index 206bf40..1a6a6f0 100644
--- a/libs/binder/ndk/include_ndk/android/binder_status.h
+++ b/libs/binder/ndk/include_ndk/android/binder_status.h
@@ -140,7 +140,8 @@
__attribute__((warn_unused_result)) AStatus* AStatus_fromStatus(binder_status_t status);
/**
- * Whether this object represents a successful transaction.
+ * Whether this object represents a successful transaction. If this function returns true, then
+ * AStatus_getExceptionCode will return EX_NONE.
*/
bool AStatus_isOk(const AStatus* status);
@@ -150,16 +151,18 @@
binder_exception_t AStatus_getExceptionCode(const AStatus* status);
/**
- * The service specific error if this object represents one. If this object represents a different
- * kind of exception or is ok, this function will return 0. Just because this function returns 0
- * does not mean that the transaction was a success.
+ * The service specific error if this object represents one. This function will only ever return a
+ * non-zero result if AStatus_getExceptionCode returns EX_SERVICE_SPECIFIC. If this function returns
+ * 0, the status object may still represent a different exception or status. To find out if this
+ * transaction as a whole is okay, use AStatus_isOk instead.
*/
int32_t AStatus_getServiceSpecificError(const AStatus* status);
/**
- * The status if this object represents one. If this object represents a different kind of exception
- * or is ok, this function will return 0. Just because this function returns 0 does not mean that
- * the transaction was a success.
+ * The status if this object represents one. This function will only ever return a non-zero result
+ * if AStatus_getExceptionCode returns EX_TRANSACTION_FAILED. If this function return 0, the status
+ * object may represent a different exception or a service specific error. To find out if this
+ * transaction as a whole is okay, use AStatus_isOk instead.
*/
binder_status_t AStatus_getStatus(const AStatus* status);
diff --git a/services/vr/performanced/task.cpp b/services/vr/performanced/task.cpp
index c2f078e..bda1682 100644
--- a/services/vr/performanced/task.cpp
+++ b/services/vr/performanced/task.cpp
@@ -115,7 +115,7 @@
std::istream file_stream(&filebuf);
for (std::string line; std::getline(file_stream, line);) {
- auto offset = line.find(":");
+ auto offset = line.find(':');
if (offset == std::string::npos) {
ALOGW("ReadStatusFields: Failed to find delimiter \":\" in line=\"%s\"",
line.c_str());