Merge "build code_coverage.policy with Android.bp"
diff --git a/debuggerd/Android.bp b/debuggerd/Android.bp
index c8df3e3..e3ce531 100644
--- a/debuggerd/Android.bp
+++ b/debuggerd/Android.bp
@@ -355,3 +355,49 @@
init_rc: ["tombstoned/tombstoned.rc"],
}
+
+prebuilt_etc {
+ name: "crash_dump.policy",
+ sub_dir: "seccomp_policy",
+ filename_from_src: true,
+ arch: {
+ arm: {
+ src: "seccomp_policy/crash_dump.arm.policy",
+ },
+ arm64: {
+ src: "seccomp_policy/crash_dump.arm64.policy",
+ },
+ x86: {
+ src: "seccomp_policy/crash_dump.x86.policy",
+ },
+ x86_64: {
+ src: "seccomp_policy/crash_dump.x86_64.policy",
+ },
+ },
+ required: [
+ "crash_dump.policy_other",
+ ],
+}
+
+
+// NB -- this installs "the other" architecture. (puts 32 bit config in on 64 bit device)
+// or at least that is the intention so that we get both of them populated
+prebuilt_etc {
+ name: "crash_dump.policy_other",
+ sub_dir: "seccomp_policy",
+ filename_from_src: true,
+ arch: {
+ arm: {
+ src: "seccomp_policy/crash_dump.arm64.policy",
+ },
+ arm64: {
+ src: "seccomp_policy/crash_dump.arm.policy",
+ },
+ x86: {
+ src: "seccomp_policy/crash_dump.x86_64.policy",
+ },
+ x86_64: {
+ src: "seccomp_policy/crash_dump.x86.policy",
+ },
+ },
+}
diff --git a/debuggerd/Android.mk b/debuggerd/Android.mk
deleted file mode 100644
index c03b41d..0000000
--- a/debuggerd/Android.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := crash_dump.policy
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MULTILIB := both
-
-ifeq ($(TARGET_ARCH), $(filter $(TARGET_ARCH), arm arm64))
-LOCAL_MODULE_STEM_32 := crash_dump.arm.policy
-LOCAL_MODULE_STEM_64 := crash_dump.arm64.policy
-endif
-
-ifeq ($(TARGET_ARCH), $(filter $(TARGET_ARCH), x86 x86_64))
-LOCAL_MODULE_STEM_32 := crash_dump.x86.policy
-LOCAL_MODULE_STEM_64 := crash_dump.x86_64.policy
-endif
-
-LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/seccomp_policy
-LOCAL_SRC_FILES_arm := seccomp_policy/crash_dump.arm.policy
-LOCAL_SRC_FILES_arm64 := seccomp_policy/crash_dump.arm64.policy
-LOCAL_SRC_FILES_x86 := seccomp_policy/crash_dump.x86.policy
-LOCAL_SRC_FILES_x86_64 := seccomp_policy/crash_dump.x86_64.policy
-LOCAL_MODULE_TARGET_ARCH := arm arm64 x86 x86_64
-include $(BUILD_PREBUILT)
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp
index 561d994..c55e532 100644
--- a/fs_mgr/fs_mgr_fstab.cpp
+++ b/fs_mgr/fs_mgr_fstab.cpp
@@ -211,7 +211,7 @@
}
} else if (StartsWith(flag, "swapprio=")) {
if (!ParseInt(arg, &entry->swap_prio)) {
- LWARNING << "Warning: length= flag malformed: " << arg;
+ LWARNING << "Warning: swapprio= flag malformed: " << arg;
}
} else if (StartsWith(flag, "zramsize=")) {
if (!arg.empty() && arg.back() == '%') {
diff --git a/fs_mgr/fs_mgr_overlayfs.cpp b/fs_mgr/fs_mgr_overlayfs.cpp
index 2bc53d3..1fa1aa1 100644
--- a/fs_mgr/fs_mgr_overlayfs.cpp
+++ b/fs_mgr/fs_mgr_overlayfs.cpp
@@ -1026,6 +1026,8 @@
}
if (change) *change = true;
+ } else if (scratch_device->empty()) {
+ *scratch_device = GetBootScratchDevice();
}
return true;
}
diff --git a/fs_mgr/libfs_avb/Android.bp b/fs_mgr/libfs_avb/Android.bp
index bf51fe7..8fb9697 100644
--- a/fs_mgr/libfs_avb/Android.bp
+++ b/fs_mgr/libfs_avb/Android.bp
@@ -31,6 +31,7 @@
static_libs: [
"libavb",
"libdm",
+ "libgsi",
"libfstab",
],
export_static_lib_headers: [
diff --git a/fs_mgr/libfs_avb/fs_avb.cpp b/fs_mgr/libfs_avb/fs_avb.cpp
index ed623bc..5d504ab 100644
--- a/fs_mgr/libfs_avb/fs_avb.cpp
+++ b/fs_mgr/libfs_avb/fs_avb.cpp
@@ -33,6 +33,7 @@
#include <android-base/strings.h>
#include <libavb/libavb.h>
#include <libdm/dm.h>
+#include <libgsi/libgsi.h>
#include "avb_ops.h"
#include "avb_util.h"
@@ -266,6 +267,18 @@
return avb_handle;
}
+static bool IsAvbPermissive() {
+ if (IsDeviceUnlocked()) {
+ // Manually putting a file under metadata partition can enforce AVB verification.
+ if (!access(DSU_METADATA_PREFIX "avb_enforce", F_OK)) {
+ LINFO << "Enforcing AVB verification when the device is unlocked";
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
AvbUniquePtr AvbHandle::LoadAndVerifyVbmeta(const FstabEntry& fstab_entry,
const std::vector<std::string>& preload_avb_key_blobs) {
// At least one of the following should be provided for public key matching.
@@ -275,7 +288,7 @@
}
// Binds allow_verification_error and rollback_protection to device unlock state.
- bool allow_verification_error = IsDeviceUnlocked();
+ bool allow_verification_error = IsAvbPermissive();
bool rollback_protection = !allow_verification_error;
std::string public_key_data;
@@ -364,15 +377,15 @@
return LoadAndVerifyVbmeta("vbmeta", fs_mgr_get_slot_suffix(), fs_mgr_get_other_slot_suffix(),
{} /* expected_public_key, already checked by bootloader */,
HashAlgorithm::kSHA256,
- IsDeviceUnlocked(), /* allow_verification_error */
- true, /* load_chained_vbmeta */
+ IsAvbPermissive(), /* allow_verification_error */
+ true, /* load_chained_vbmeta */
false, /* rollback_protection, already checked by bootloader */
nullptr /* custom_device_path */);
}
// TODO(b/128807537): removes this function.
AvbUniquePtr AvbHandle::Open() {
- bool is_device_unlocked = IsDeviceUnlocked();
+ bool allow_verification_error = IsAvbPermissive();
AvbUniquePtr avb_handle(new AvbHandle());
if (!avb_handle) {
@@ -381,8 +394,9 @@
}
FsManagerAvbOps avb_ops;
- AvbSlotVerifyFlags flags = is_device_unlocked ? AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR
- : AVB_SLOT_VERIFY_FLAGS_NONE;
+ AvbSlotVerifyFlags flags = allow_verification_error
+ ? AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR
+ : AVB_SLOT_VERIFY_FLAGS_NONE;
AvbSlotVerifyResult verify_result =
avb_ops.AvbSlotVerify(fs_mgr_get_slot_suffix(), flags, &avb_handle->vbmeta_images_);
@@ -405,9 +419,8 @@
break;
case AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION:
case AVB_SLOT_VERIFY_RESULT_ERROR_PUBLIC_KEY_REJECTED:
- if (!is_device_unlocked) {
- LERROR << "ERROR_VERIFICATION / PUBLIC_KEY_REJECTED isn't allowed "
- << "if the device is LOCKED";
+ if (!allow_verification_error) {
+ LERROR << "ERROR_VERIFICATION / PUBLIC_KEY_REJECTED isn't allowed ";
return nullptr;
}
avb_handle->status_ = AvbHandleStatus::kVerificationError;
diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp
index a937b43..ba53615 100644
--- a/fs_mgr/libsnapshot/snapshot.cpp
+++ b/fs_mgr/libsnapshot/snapshot.cpp
@@ -232,7 +232,12 @@
LOG(WARNING) << callstack_str.c_str();
std::stringstream path;
path << "/data/misc/snapshotctl_log/libsnapshot." << Now() << ".log";
- android::base::WriteStringToFile(callstack_str.c_str(), path.str());
+ std::string path_str = path.str();
+ android::base::WriteStringToFile(callstack_str.c_str(), path_str);
+ if (chmod(path_str.c_str(), 0644) == -1) {
+ PLOG(WARNING) << "Unable to chmod 0644 "
+ << ", file maybe dropped from bugreport:" << path_str;
+ }
#endif
if (!RemoveAllSnapshots(lock)) {
diff --git a/fs_mgr/libsnapshot/snapshotctl.cpp b/fs_mgr/libsnapshot/snapshotctl.cpp
index d724be3..e35ad4b 100644
--- a/fs_mgr/libsnapshot/snapshotctl.cpp
+++ b/fs_mgr/libsnapshot/snapshotctl.cpp
@@ -61,7 +61,16 @@
ss << kLogFilePath << "snapshotctl." << Now() << ".log";
fd_.reset(TEMP_FAILURE_RETRY(
open(ss.str().c_str(),
- O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW | O_SYNC, 0660)));
+ O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW | O_SYNC, 0644)));
+ if (fd_ == -1) {
+ PLOG(ERROR) << "Cannot open persistent log " << ss.str();
+ return;
+ }
+ // Explicitly chmod again because mode in open() may be masked by umask.
+ if (fchmod(fd_.get(), 0644) == -1) {
+ PLOG(ERROR) << "Cannot chmod 0644 persistent log " << ss.str();
+ return;
+ }
}
// Copy-contuctor needed to be converted to std::function.
FileLogger(const FileLogger& other) { fd_.reset(dup(other.fd_)); }
@@ -108,7 +117,8 @@
// 'snapshotctl merge' is stripped away from arguments to
// Logger.
- android::base::InitLogging(argv, MergeCmdLogger(argc - 2, argv + 2));
+ android::base::InitLogging(argv);
+ android::base::SetLogger(MergeCmdLogger(argc - 2, argv + 2));
auto state = SnapshotManager::New()->InitiateMergeAndWait();
diff --git a/healthd/healthd_mode_charger.h b/healthd/healthd_mode_charger.h
index 370ca86..6e569ee 100644
--- a/healthd/healthd_mode_charger.h
+++ b/healthd/healthd_mode_charger.h
@@ -72,7 +72,7 @@
int64_t next_pwr_check_ = 0;
int64_t wait_batt_level_timestamp_ = 0;
- key_state keys_[KEY_MAX + 1];
+ key_state keys_[KEY_MAX + 1] = {};
animation batt_anim_;
GRSurface* surf_unknown_ = nullptr;
diff --git a/init/test_utils/include/init-test-utils/service_utils.h b/init/test_utils/include/init-test-utils/service_utils.h
index 1b59c7b..f9366ea 100644
--- a/init/test_utils/include/init-test-utils/service_utils.h
+++ b/init/test_utils/include/init-test-utils/service_utils.h
@@ -20,7 +20,6 @@
#include <set>
#include <android-base/result.h>
-#include <hidl-util/FqInstance.h>
namespace android {
namespace init {
diff --git a/libcutils/KernelLibcutilsTest.xml b/libcutils/KernelLibcutilsTest.xml
index e27fac6..40e4ef4 100644
--- a/libcutils/KernelLibcutilsTest.xml
+++ b/libcutils/KernelLibcutilsTest.xml
@@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<configuration description="Runs libcutils_test_static.">
+<configuration description="Runs KernelLibcutilsTest.">
<option name="test-suite-tag" value="apct" />
<option name="test-suite-tag" value="apct-native" />
@@ -22,12 +22,12 @@
<target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
<option name="cleanup" value="true" />
- <option name="push" value="libcutils_test_static->/data/local/tmp/libcutils_test_static" />
+ <option name="push" value="KernelLibcutilsTest->/data/local/tmp/KernelLibcutilsTest" />
</target_preparer>
<test class="com.android.tradefed.testtype.GTest" >
<option name="native-test-device-path" value="/data/local/tmp" />
- <option name="module-name" value="libcutils_test_static" />
+ <option name="module-name" value="KernelLibcutilsTest" />
<option name="include-filter" value="*AshmemTest*" />
</test>
</configuration>
diff --git a/libutils/Android.bp b/libutils/Android.bp
index efa4c41..3311793 100644
--- a/libutils/Android.bp
+++ b/libutils/Android.bp
@@ -159,6 +159,11 @@
],
},
},
+
+ apex_available: [
+ "//apex_available:anyapex",
+ "//apex_available:platform",
+ ],
}
cc_library {
diff --git a/libutils/Threads.cpp b/libutils/Threads.cpp
index 31ca138..540dcf4 100644
--- a/libutils/Threads.cpp
+++ b/libutils/Threads.cpp
@@ -18,8 +18,8 @@
#define LOG_TAG "libutils.threads"
#include <assert.h>
-#include <utils/Thread.h>
#include <utils/AndroidThreads.h>
+#include <utils/Thread.h>
#if !defined(_WIN32)
# include <sys/resource.h>
@@ -36,7 +36,10 @@
#include <utils/Log.h>
+#if defined(__ANDROID__)
+#include <processgroup/processgroup.h>
#include <processgroup/sched_policy.h>
+#endif
#if defined(__ANDROID__)
# define __android_unused
@@ -64,6 +67,7 @@
typedef void* (*android_pthread_entry)(void*);
+#if defined(__ANDROID__)
struct thread_data_t {
thread_func_t entryFunction;
void* userData;
@@ -79,10 +83,11 @@
char * name = t->threadName;
delete t;
setpriority(PRIO_PROCESS, 0, prio);
+
+ // A new thread will be in its parent's sched group by default,
+ // so we just need to handle the background case.
if (prio >= ANDROID_PRIORITY_BACKGROUND) {
- set_sched_policy(0, SP_BACKGROUND);
- } else {
- set_sched_policy(0, SP_FOREGROUND);
+ SetTaskProfiles(0, {"SCHED_SP_BACKGROUND"}, true);
}
if (name) {
@@ -92,6 +97,7 @@
return f(u);
}
};
+#endif
void androidSetThreadName(const char* name) {
#if defined(__linux__)
@@ -300,11 +306,19 @@
{
int rc = 0;
int lasterr = 0;
+ int curr_pri = getpriority(PRIO_PROCESS, tid);
+
+ if (curr_pri == pri) {
+ return rc;
+ }
if (pri >= ANDROID_PRIORITY_BACKGROUND) {
- rc = set_sched_policy(tid, SP_BACKGROUND);
- } else if (getpriority(PRIO_PROCESS, tid) >= ANDROID_PRIORITY_BACKGROUND) {
- rc = set_sched_policy(tid, SP_FOREGROUND);
+ rc = SetTaskProfiles(tid, {"SCHED_SP_BACKGROUND"}, true) ? 0 : -1;
+ } else if (curr_pri >= ANDROID_PRIORITY_BACKGROUND) {
+ SchedPolicy policy = SP_FOREGROUND;
+ // Change to the sched policy group of the process.
+ get_sched_policy(getpid(), &policy);
+ rc = SetTaskProfiles(tid, {get_sched_policy_profile_name(policy)}, true) ? 0 : -1;
}
if (rc) {
diff --git a/libutils/include/utils/String16.h b/libutils/include/utils/String16.h
index adc3e7d..c0e3f1e 100644
--- a/libutils/include/utils/String16.h
+++ b/libutils/include/utils/String16.h
@@ -17,7 +17,8 @@
#ifndef ANDROID_STRING16_H
#define ANDROID_STRING16_H
-#include <string> // for std::string
+#include <iostream>
+#include <string>
#include <utils/Errors.h>
#include <utils/String8.h>
@@ -25,18 +26,10 @@
// ---------------------------------------------------------------------------
-extern "C" {
-
-}
-
-// ---------------------------------------------------------------------------
-
namespace android {
// ---------------------------------------------------------------------------
-class String8;
-
template <size_t N>
class StaticString16;
@@ -203,6 +196,11 @@
// require any change to the underlying SharedBuffer contents or reference count.
ANDROID_TRIVIAL_MOVE_TRAIT(String16)
+static inline std::ostream& operator<<(std::ostream& os, const String16& str) {
+ os << String8(str).c_str();
+ return os;
+}
+
// ---------------------------------------------------------------------------
/*
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 9458e23..782f967 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -114,15 +114,6 @@
symlink /proc/self/fd/1 /dev/stdout
symlink /proc/self/fd/2 /dev/stderr
- symlink /system/bin /bin
- symlink /system/etc /etc
-
- # Backward compatibility.
- symlink /sys/kernel/debug /d
-
- # Link /vendor to /system/vendor for devices without a vendor partition.
- symlink /system/vendor /vendor
-
# Create energy-aware scheduler tuning nodes
mkdir /dev/stune/foreground
mkdir /dev/stune/background
@@ -219,7 +210,6 @@
mkdir /mnt/runtime/full/self 0755 root root
# Symlink to keep legacy apps working in multi-user world
- symlink /storage/self/primary /sdcard
symlink /storage/self/primary /mnt/sdcard
symlink /mnt/user/0/primary /mnt/runtime/default/self/primary
@@ -621,7 +611,9 @@
mkdir /data/misc/installd 0700 root root
mkdir /data/misc/apexdata 0711 root root
mkdir /data/misc/apexrollback 0700 root root
- mkdir /data/misc/snapshotctl_log 0770 root root
+ mkdir /data/misc/snapshotctl_log 0755 root root
+ # create location to store pre-reboot information
+ mkdir /data/misc/prereboot 0700 system system
mkdir /data/preloads 0775 system system encryption=None
@@ -772,6 +764,9 @@
# IOCTLs on ashmem fds any more.
setprop sys.use_memfd false
+ # Explicitly disable FUSE
+ setprop persist.sys.fuse false
+
# Set fscklog permission
chown root system /dev/fscklogs/log
chmod 0770 /dev/fscklogs/log
diff --git a/storaged/main.cpp b/storaged/main.cpp
index e35bd6f..a7bda14 100644
--- a/storaged/main.cpp
+++ b/storaged/main.cpp
@@ -46,11 +46,6 @@
// Function of storaged's main thread
void* storaged_main(void* /* unused */) {
- storaged_sp = new storaged_t();
-
- storaged_sp->init();
- storaged_sp->report_storage_info();
-
LOG(INFO) << "storaged: Start";
for (;;) {
@@ -123,6 +118,9 @@
if (flag_main_service) { // start main thread
// Start the main thread of storaged
+ storaged_sp = new storaged_t();
+ storaged_sp->init();
+ storaged_sp->report_storage_info();
pthread_t storaged_main_thread;
errno = pthread_create(&storaged_main_thread, NULL, storaged_main, NULL);
if (errno != 0) {