Merge "Move some properties users to __system_property_read_callback()"
This commit is contained in:
commit
4a5a337ef2
4 changed files with 32 additions and 40 deletions
|
|
@ -36,13 +36,18 @@ std::string GetProperty(const std::string& key, const std::string& default_value
|
||||||
const prop_info* pi = __system_property_find(key.c_str());
|
const prop_info* pi = __system_property_find(key.c_str());
|
||||||
if (pi == nullptr) return default_value;
|
if (pi == nullptr) return default_value;
|
||||||
|
|
||||||
char buf[PROP_VALUE_MAX];
|
std::string property_value;
|
||||||
if (__system_property_read(pi, nullptr, buf) > 0) return buf;
|
__system_property_read_callback(pi,
|
||||||
|
[](void* cookie, const char*, const char* value, unsigned) {
|
||||||
|
auto property_value = reinterpret_cast<std::string*>(cookie);
|
||||||
|
*property_value = value;
|
||||||
|
},
|
||||||
|
&property_value);
|
||||||
|
|
||||||
// If the property exists but is empty, also return the default value.
|
// If the property exists but is empty, also return the default value.
|
||||||
// Since we can't remove system properties, "empty" is traditionally
|
// Since we can't remove system properties, "empty" is traditionally
|
||||||
// the same as "missing" (this was true for cutils' property_get).
|
// the same as "missing" (this was true for cutils' property_get).
|
||||||
return default_value;
|
return property_value.empty() ? default_value : property_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetBoolProperty(const std::string& key, bool default_value) {
|
bool GetBoolProperty(const std::string& key, bool default_value) {
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,12 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
|
#include <android-base/properties.h>
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
#include <android-base/unique_fd.h>
|
#include <android-base/unique_fd.h>
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
#include <backtrace/Backtrace.h>
|
#include <backtrace/Backtrace.h>
|
||||||
#include <backtrace/BacktraceMap.h>
|
#include <backtrace/BacktraceMap.h>
|
||||||
#include <cutils/properties.h>
|
|
||||||
#include <log/log.h>
|
#include <log/log.h>
|
||||||
#include <log/logprint.h>
|
#include <log/logprint.h>
|
||||||
#include <private/android_filesystem_config.h>
|
#include <private/android_filesystem_config.h>
|
||||||
|
|
@ -53,6 +53,8 @@
|
||||||
#include "libdebuggerd/machine.h"
|
#include "libdebuggerd/machine.h"
|
||||||
#include "libdebuggerd/open_files_list.h"
|
#include "libdebuggerd/open_files_list.h"
|
||||||
|
|
||||||
|
using android::base::GetBoolProperty;
|
||||||
|
using android::base::GetProperty;
|
||||||
using android::base::StringPrintf;
|
using android::base::StringPrintf;
|
||||||
|
|
||||||
#define STACK_WORDS 16
|
#define STACK_WORDS 16
|
||||||
|
|
@ -206,14 +208,11 @@ static const char* get_sigcode(int signo, int code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dump_header_info(log_t* log) {
|
static void dump_header_info(log_t* log) {
|
||||||
char fingerprint[PROPERTY_VALUE_MAX];
|
auto fingerprint = GetProperty("ro.build.fingerprint", "unknown");
|
||||||
char revision[PROPERTY_VALUE_MAX];
|
auto revision = GetProperty("ro.revision", "unknown");
|
||||||
|
|
||||||
property_get("ro.build.fingerprint", fingerprint, "unknown");
|
_LOG(log, logtype::HEADER, "Build fingerprint: '%s'\n", fingerprint.c_str());
|
||||||
property_get("ro.revision", revision, "unknown");
|
_LOG(log, logtype::HEADER, "Revision: '%s'\n", revision.c_str());
|
||||||
|
|
||||||
_LOG(log, logtype::HEADER, "Build fingerprint: '%s'\n", fingerprint);
|
|
||||||
_LOG(log, logtype::HEADER, "Revision: '%s'\n", revision);
|
|
||||||
_LOG(log, logtype::HEADER, "ABI: '%s'\n", ABI_STRING);
|
_LOG(log, logtype::HEADER, "ABI: '%s'\n", ABI_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -724,9 +723,7 @@ static void dump_crash(log_t* log, BacktraceMap* map, BacktraceMap* map_new,
|
||||||
const std::string& process_name, const std::map<pid_t, std::string>& threads,
|
const std::string& process_name, const std::map<pid_t, std::string>& threads,
|
||||||
uintptr_t abort_msg_address) {
|
uintptr_t abort_msg_address) {
|
||||||
// don't copy log messages to tombstone unless this is a dev device
|
// don't copy log messages to tombstone unless this is a dev device
|
||||||
char value[PROPERTY_VALUE_MAX];
|
bool want_logs = GetBoolProperty("ro.debuggable", false);
|
||||||
property_get("ro.debuggable", value, "0");
|
|
||||||
bool want_logs = (value[0] == '1');
|
|
||||||
|
|
||||||
_LOG(log, logtype::HEADER,
|
_LOG(log, logtype::HEADER,
|
||||||
"*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n");
|
"*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n");
|
||||||
|
|
|
||||||
|
|
@ -55,12 +55,22 @@ cc_library_static {
|
||||||
"liblogwrap",
|
"liblogwrap",
|
||||||
"libfstab",
|
"libfstab",
|
||||||
],
|
],
|
||||||
|
cppflags: [
|
||||||
|
"-DALLOW_SKIP_SECURE_CHECK=0",
|
||||||
|
"-DALLOW_ADBD_DISABLE_VERITY=0",
|
||||||
|
],
|
||||||
product_variables: {
|
product_variables: {
|
||||||
debuggable: {
|
debuggable: {
|
||||||
cppflags: ["-DALLOW_ADBD_DISABLE_VERITY=1"],
|
cppflags: [
|
||||||
|
"-UALLOW_ADBD_DISABLE_VERITY",
|
||||||
|
"-DALLOW_ADBD_DISABLE_VERITY=1",
|
||||||
|
],
|
||||||
},
|
},
|
||||||
eng: {
|
eng: {
|
||||||
cppflags: ["-DALLOW_SKIP_SECURE_CHECK=1"],
|
cppflags: [
|
||||||
|
"-UALLOW_SKIP_SECURE_CHECK",
|
||||||
|
"-DALLOW_SKIP_SECURE_CHECK=1",
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -543,15 +543,6 @@ static int fs_match(const char *in1, const char *in2)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int device_is_force_encrypted() {
|
|
||||||
int ret = -1;
|
|
||||||
char value[PROP_VALUE_MAX];
|
|
||||||
ret = __system_property_get("ro.vold.forceencryption", value);
|
|
||||||
if (ret < 0)
|
|
||||||
return 0;
|
|
||||||
return strcmp(value, "1") ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tries to mount any of the consecutive fstab entries that match
|
* Tries to mount any of the consecutive fstab entries that match
|
||||||
* the mountpoint of the one given by fstab->recs[start_idx].
|
* the mountpoint of the one given by fstab->recs[start_idx].
|
||||||
|
|
@ -726,7 +717,9 @@ out:
|
||||||
|
|
||||||
static bool needs_block_encryption(const struct fstab_rec* rec)
|
static bool needs_block_encryption(const struct fstab_rec* rec)
|
||||||
{
|
{
|
||||||
if (device_is_force_encrypted() && fs_mgr_is_encryptable(rec)) return true;
|
if (android::base::GetBoolProperty("ro.vold.forceencryption", false) &&
|
||||||
|
fs_mgr_is_encryptable(rec))
|
||||||
|
return true;
|
||||||
if (rec->fs_mgr_flags & MF_FORCECRYPT) return true;
|
if (rec->fs_mgr_flags & MF_FORCECRYPT) return true;
|
||||||
if (rec->fs_mgr_flags & MF_CRYPT) {
|
if (rec->fs_mgr_flags & MF_CRYPT) {
|
||||||
/* Check for existence of convert_fde breadcrumb file */
|
/* Check for existence of convert_fde breadcrumb file */
|
||||||
|
|
@ -769,20 +762,7 @@ static int handle_encryptable(const struct fstab_rec* rec)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_device_secure() {
|
bool is_device_secure() {
|
||||||
int ret = -1;
|
return android::base::GetBoolProperty("ro.secure", ALLOW_SKIP_SECURE_CHECK ? false : true);
|
||||||
char value[PROP_VALUE_MAX];
|
|
||||||
ret = __system_property_get("ro.secure", value);
|
|
||||||
if (ret == 0) {
|
|
||||||
#ifdef ALLOW_SKIP_SECURE_CHECK
|
|
||||||
// Allow eng builds to skip this check if the property
|
|
||||||
// is not readable (happens during early mount)
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
// If error and not an 'eng' build, we want to fail secure.
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return strcmp(value, "0") ? true : false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When multiple fstab records share the same mount_point, it will
|
/* When multiple fstab records share the same mount_point, it will
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue