Merge "SF: disable HW vsync while dozing"
diff --git a/cmds/atrace/Android.bp b/cmds/atrace/Android.bp
index c89e3b1..425435d 100644
--- a/cmds/atrace/Android.bp
+++ b/cmds/atrace/Android.bp
@@ -17,4 +17,10 @@
],
init_rc: ["atrace.rc"],
+
+ product_variables: {
+ debuggable: {
+ init_rc: ["atrace_userdebug.rc"],
+ },
+ },
}
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp
index cfe3628..054b00e 100644
--- a/cmds/atrace/atrace.cpp
+++ b/cmds/atrace/atrace.cpp
@@ -550,7 +550,13 @@
// ignore
continue;
}
+
sp<IBase> interface = interfaceRet;
+ if (interface == nullptr) {
+ // ignore
+ continue;
+ }
+
auto notifyRet = interface->notifySyspropsChanged();
if (!notifyRet.isOk()) {
// ignore
diff --git a/cmds/atrace/atrace_userdebug.rc b/cmds/atrace/atrace_userdebug.rc
new file mode 100644
index 0000000..5fd28e2
--- /dev/null
+++ b/cmds/atrace/atrace_userdebug.rc
@@ -0,0 +1,47 @@
+## Permissions to allow additional system-wide tracing to the kernel trace buffer.
+## The default list of permissions is set in frameworks/native/cmds/atrace/atrace.rc
+
+# Allow the shell group to enable kernel tracepoints:
+
+on post-fs
+ chown root shell /sys/kernel/debug/tracing/events/sync/enable
+ chown root shell /sys/kernel/debug/tracing/events/workqueue/enable
+ chown root shell /sys/kernel/debug/tracing/events/regulator/enable
+ chown root shell /sys/kernel/debug/tracing/events/pagecache/enable
+
+ # irq
+ chown root shell /sys/kernel/debug/tracing/events/irq/enable
+ chown root shell /sys/kernel/debug/tracing/events/ipi/enable
+
+ # disk
+ chown root shell /sys/kernel/debug/tracing/events/f2fs/f2fs_sync_file_enter/enable
+ chown root shell /sys/kernel/debug/tracing/events/f2fs/f2fs_sync_file_exit/enable
+ chown root shell /sys/kernel/debug/tracing/events/f2fs/f2fs_write_begin/enable
+ chown root shell /sys/kernel/debug/tracing/events/f2fs/f2fs_write_end/enable
+ chown root shell /sys/kernel/debug/tracing/events/ext4/ext4_da_write_begin/enable
+ chown root shell /sys/kernel/debug/tracing/events/ext4/ext4_da_write_end/enable
+ chown root shell /sys/kernel/debug/tracing/events/ext4/ext4_sync_file_enter/enable
+ chown root shell /sys/kernel/debug/tracing/events/ext4/ext4_sync_file_exit/enable
+ chown root shell /sys/kernel/debug/tracing/events/block/block_rq_issue/enable
+ chown root shell /sys/kernel/debug/tracing/events/block/block_rq_complete/enable
+
+ chmod 0664 /sys/kernel/debug/tracing/events/sync/enable
+ chmod 0664 /sys/kernel/debug/tracing/events/workqueue/enable
+ chmod 0664 /sys/kernel/debug/tracing/events/regulator/enable
+ chmod 0664 /sys/kernel/debug/tracing/events/pagecache/enable
+
+ # irq
+ chmod 0664 /sys/kernel/debug/tracing/events/irq/enable
+ chmod 0664 /sys/kernel/debug/tracing/events/ipi/enable
+
+ # disk
+ chmod 0664 /sys/kernel/debug/tracing/events/f2fs/f2fs_sync_file_enter/enable
+ chmod 0664 /sys/kernel/debug/tracing/events/f2fs/f2fs_sync_file_exit/enable
+ chmod 0664 /sys/kernel/debug/tracing/events/f2fs/f2fs_write_begin/enable
+ chmod 0664 /sys/kernel/debug/tracing/events/f2fs/f2fs_write_end/enable
+ chmod 0664 /sys/kernel/debug/tracing/events/ext4/ext4_da_write_begin/enable
+ chmod 0664 /sys/kernel/debug/tracing/events/ext4/ext4_da_write_end/enable
+ chmod 0664 /sys/kernel/debug/tracing/events/ext4/ext4_sync_file_enter/enable
+ chmod 0664 /sys/kernel/debug/tracing/events/ext4/ext4_sync_file_exit/enable
+ chmod 0664 /sys/kernel/debug/tracing/events/block/block_rq_issue/enable
+ chmod 0664 /sys/kernel/debug/tracing/events/block/block_rq_complete/enable
diff --git a/cmds/installd/dexopt.cpp b/cmds/installd/dexopt.cpp
index facb189..e9d06d1 100644
--- a/cmds/installd/dexopt.cpp
+++ b/cmds/installd/dexopt.cpp
@@ -177,9 +177,20 @@
return count;
}
+static const char* get_location_from_path(const char* path) {
+ static constexpr char kLocationSeparator = '/';
+ const char *location = strrchr(path, kLocationSeparator);
+ if (location == NULL) {
+ return path;
+ } else {
+ // Skip the separator character.
+ return location + 1;
+ }
+}
+
static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vdex_fd, int image_fd,
const char* input_file_name, const char* output_file_name, int swap_fd,
- const char *instruction_set, const char* compiler_filter, bool vm_safe_mode,
+ const char* instruction_set, const char* compiler_filter, bool vm_safe_mode,
bool debuggable, bool post_bootcomplete, int profile_fd, const char* shared_libraries) {
static const unsigned int MAX_INSTRUCTION_SET_LEN = 7;
@@ -189,6 +200,9 @@
return;
}
+ // Get the relative path to the input file.
+ const char* relative_input_file_name = get_location_from_path(input_file_name);
+
char dex2oat_Xms_flag[kPropertyValueMax];
bool have_dex2oat_Xms_flag = get_property("dalvik.vm.dex2oat-Xms", dex2oat_Xms_flag, NULL) > 0;
@@ -279,7 +293,7 @@
char dex2oat_image_fd[arraysize("--app-image-fd=") + MAX_INT_LEN];
sprintf(zip_fd_arg, "--zip-fd=%d", zip_fd);
- sprintf(zip_location_arg, "--zip-location=%s", input_file_name);
+ sprintf(zip_location_arg, "--zip-location=%s", relative_input_file_name);
sprintf(input_vdex_fd_arg, "--input-vdex-fd=%d", input_vdex_fd);
sprintf(output_vdex_fd_arg, "--output-vdex-fd=%d", output_vdex_fd);
sprintf(oat_fd_arg, "--oat-fd=%d", oat_fd);
@@ -341,8 +355,18 @@
sprintf(profile_arg, "--profile-file-fd=%d", profile_fd);
}
+ // Get the directory of the apk to pass as a base classpath directory.
+ char base_dir[arraysize("--classpath-dir=") + PKG_PATH_MAX];
+ std::string apk_dir(input_file_name);
+ unsigned long dir_index = apk_dir.rfind('/');
+ bool has_base_dir = dir_index != std::string::npos;
+ if (has_base_dir) {
+ apk_dir = apk_dir.substr(0, dir_index);
+ sprintf(base_dir, "--classpath-dir=%s", apk_dir.c_str());
+ }
- ALOGV("Running %s in=%s out=%s\n", DEX2OAT_BIN, input_file_name, output_file_name);
+
+ ALOGV("Running %s in=%s out=%s\n", DEX2OAT_BIN, relative_input_file_name, output_file_name);
const char* argv[9 // program name, mandatory arguments and the final NULL
+ (have_dex2oat_isa_variant ? 1 : 0)
@@ -360,6 +384,7 @@
+ dex2oat_flags_count
+ (profile_fd == -1 ? 0 : 1)
+ (shared_libraries != nullptr ? 4 : 0)
+ + (has_base_dir ? 1 : 0)
+ (have_dex2oat_large_app_threshold ? 1 : 0)];
int i = 0;
argv[i++] = DEX2OAT_BIN;
@@ -424,6 +449,9 @@
argv[i++] = RUNTIME_ARG;
argv[i++] = shared_libraries;
}
+ if (has_base_dir) {
+ argv[i++] = base_dir;
+ }
// Do not add after dex2oat_flags, they should override others for debugging.
argv[i] = NULL;
@@ -761,17 +789,6 @@
exit(68); /* only get here on exec failure */
}
-static const char* get_location_from_path(const char* path) {
- static constexpr char kLocationSeparator = '/';
- const char *location = strrchr(path, kLocationSeparator);
- if (location == NULL) {
- return path;
- } else {
- // Skip the separator character.
- return location + 1;
- }
-}
-
bool dump_profiles(int32_t uid, const std::string& pkgname, const char* code_paths) {
std::vector<unique_fd> profile_fds;
unique_fd reference_profile_fd;
@@ -1548,14 +1565,12 @@
_exit(67);
}
- // Pass dex2oat the relative path to the input file.
- const char *input_file_name = get_location_from_path(dex_path);
run_dex2oat(input_fd.get(),
out_oat_fd.get(),
in_vdex_fd.get(),
out_vdex_fd.get(),
image_fd.get(),
- input_file_name,
+ dex_path,
out_oat_path,
swap_fd.get(),
instruction_set,