Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera: Add feature extensions #1

Open
wants to merge 13 commits into
base: thirteen
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion debuggerd/libdebuggerd/tombstone_proto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ void engrave_tombstone_proto(Tombstone* tombstone, unwindstack::Unwinder* unwind
Tombstone result;

result.set_arch(get_arch());
result.set_lineage_version(android::base::GetProperty("ro.lineage.version", "unknown"));
result.set_lineage_version(android::base::GetProperty("ro.havoc.version", "unknown"));
result.set_build_fingerprint(android::base::GetProperty("ro.build.fingerprint", "unknown"));
result.set_revision(android::base::GetProperty("ro.revision", "unknown"));
result.set_timestamp(get_timestamp());
Expand Down
2 changes: 1 addition & 1 deletion debuggerd/libdebuggerd/tombstone_proto_to_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ void print_logs(CallbackType callback, const Tombstone& tombstone, int tail) {

bool tombstone_proto_to_text(const Tombstone& tombstone, CallbackType callback) {
CBL("*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***");
CBL("LineageOS Version: '%s'", tombstone.lineage_version().c_str());
CBL("Havoc-OS Version: '%s'", tombstone.lineage_version().c_str());
CBL("Build fingerprint: '%s'", tombstone.build_fingerprint().c_str());
CBL("Revision: '%s'", tombstone.revision().c_str());
CBL("ABI: '%s'", abi_string(tombstone));
Expand Down
16 changes: 6 additions & 10 deletions healthd/BatteryMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

#define POWER_SUPPLY_SUBSYSTEM "power_supply"
#define POWER_SUPPLY_SYSFS_PATH "/sys/class/" POWER_SUPPLY_SUBSYSTEM
#define SYSFS_BATTERY_CURRENT "/sys/class/power_supply/battery/current_now"
#define SYSFS_BATTERY_VOLTAGE "/sys/class/power_supply/battery/voltage_now"
#define FAKE_BATTERY_CAPACITY 42
#define FAKE_BATTERY_TEMPERATURE 424
#define MILLION 1.0e6
Expand Down Expand Up @@ -434,19 +436,13 @@ void BatteryMonitor::updateValues(void) {
KLOG_WARNING(LOG_TAG, "%s: Unknown power supply type\n",
mChargerNames[i].string());
}
path.clear();
path.appendFormat("%s/%s/current_max", POWER_SUPPLY_SYSFS_PATH,
mChargerNames[i].string());
int ChargingCurrent =
(access(path.string(), R_OK) == 0) ? getIntField(path) : 0;

path.clear();
path.appendFormat("%s/%s/voltage_max", POWER_SUPPLY_SYSFS_PATH,
mChargerNames[i].string());
int ChargingCurrent =
(access(SYSFS_BATTERY_CURRENT, R_OK) == 0) ? abs(getIntField(String8(SYSFS_BATTERY_CURRENT))) : 0;

int ChargingVoltage =
(access(path.string(), R_OK) == 0) ? getIntField(path) :
DEFAULT_VBUS_VOLTAGE;
(access(SYSFS_BATTERY_VOLTAGE, R_OK) == 0) ? getIntField(String8(SYSFS_BATTERY_VOLTAGE)) :
DEFAULT_VBUS_VOLTAGE;

double power = ((double)ChargingCurrent / MILLION) *
((double)ChargingVoltage / MILLION);
Expand Down
101 changes: 99 additions & 2 deletions init/property_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ struct PropertyAuditData {
const char* name;
};

static bool weaken_prop_override_security = false;

static int PropertyAuditCallback(void* data, security_class_t /*cls*/, char* buf, size_t len) {
auto* d = reinterpret_cast<PropertyAuditData*>(data);

Expand Down Expand Up @@ -189,8 +191,8 @@ static uint32_t PropertySet(const std::string& name, const std::string& value, s

prop_info* pi = (prop_info*) __system_property_find(name.c_str());
if (pi != nullptr) {
// ro.* properties are actually "write-once".
if (StartsWith(name, "ro.")) {
// ro.* properties are actually "write-once", unless the system decides to
if (StartsWith(name, "ro.") && !weaken_prop_override_security) {
*error = "Read-only property was already set";
return PROP_ERROR_READ_ONLY_PROPERTY;
}
Expand Down Expand Up @@ -796,6 +798,98 @@ static void load_override_properties() {
}
}

static const char *snet_prop_key[] = {
"ro.boot.vbmeta.device_state",
"ro.boot.verifiedbootstate",
"ro.boot.flash.locked",
"ro.boot.selinux",
"ro.boot.veritymode",
"ro.boot.warranty_bit",
"ro.warranty_bit",
"ro.debuggable",
"ro.secure",
"ro.bootimage.build.type",
"ro.build.type",
"ro.system.build.type",
"ro.system_ext.build.type",
"ro.vendor.build.type",
"ro.vendor_dlkm.build.type",
"ro.product.build.type",
"ro.odm.build.type",
"ro.build.keys",
"ro.build.tags",
"ro.system.build.tags",
"ro.vendor.boot.warranty_bit",
"ro.vendor.warranty_bit",
"vendor.boot.vbmeta.device_state",
"vendor.boot.verifiedbootstate",
NULL
};

static const char *snet_prop_value[] = {
"locked", // ro.boot.vbmeta.device_state
"green", // ro.boot.verifiedbootstate
"1", // ro.boot.flash.locked
"enforcing", // ro.boot.selinux
"enforcing", // ro.boot.veritymode
"0", // ro.boot.warranty_bit
"0", // ro.warranty_bit
"0", // ro.debuggable
"1", // ro.secure
"user", // ro.bootimage.build.type
"user", // ro.build.type
"user", // ro.system.build.type
"user", // ro.system_ext.build.type
"user", // ro.vendor.build.type
"user", // ro.vendor_dlkm.build.type
"user", // ro.product.build.type
"user", // ro.odm.build.type
"release-keys", // ro.build.keys
"release-keys", // ro.build.tags
"release-keys", // ro.system.build.tags
"0", // ro.vendor.boot.warranty_bit
"0", // ro.vendor.warranty_bit
"locked", // vendor.boot.vbmeta.device_state
"green", // vendor.boot.verifiedbootstate
NULL
};

static void workaround_snet_properties() {
std::string build_type = android::base::GetProperty("ro.build.type", "");

// Bail out if this is recovery, fastbootd, or anything other than a normal boot.
// fastbootd, in particular, needs the real values so it can allow flashing on
// unlocked bootloaders.
if (IsRecoveryMode()) {
return;
}

// Exit if eng build
if (build_type == "eng") {
return;
}

// Weaken property override security to set safetynet props
weaken_prop_override_security = true;

std::string error;

// Hide all sensitive props
LOG(INFO) << "snet: Hiding sensitive props";
for (int i = 0; snet_prop_key[i]; ++i) {
PropertySet(snet_prop_key[i], snet_prop_value[i], &error);
}

// Extra pops
std::string build_flavor_key = "ro.build.flavor";
std::string build_flavor_value = android::base::GetProperty(build_flavor_key, "");
build_flavor_value = android::base::StringReplace(build_flavor_value, "userdebug", "user", false);
PropertySet(build_flavor_key, build_flavor_value, &error);

// Restore the normal property override security after safetynet props have been set
weaken_prop_override_security = false;
}

// If the ro.product.[brand|device|manufacturer|model|name] properties have not been explicitly
// set, derive them from ro.product.${partition}.* properties
static void property_initialize_ro_product_props() {
Expand Down Expand Up @@ -1144,6 +1238,9 @@ void PropertyLoadBootDefaults() {
property_initialize_ro_vendor_api_level();

update_sys_usb_config();

// Workaround SafetyNet
workaround_snet_properties();
}

bool LoadPropertyInfoFromFile(const std::string& filename,
Expand Down
53 changes: 51 additions & 2 deletions libsystem/include/system/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,20 @@ enum {
// Notify on autofocus start and stop. This is useful in continuous
// autofocus - FOCUS_MODE_CONTINUOUS_VIDEO and FOCUS_MODE_CONTINUOUS_PICTURE.
CAMERA_MSG_FOCUS_MOVE = 0x0800, // notifyCallback
CAMERA_MSG_VENDOR_START = 0x1000,
CAMERA_MSG_STATS_DATA = CAMERA_MSG_VENDOR_START,
CAMERA_MSG_META_DATA = 0x2000,
CAMERA_MSG_VENDOR_END = 0x8000,
CAMERA_MSG_ALL_MSGS = 0xFFFF
};

/** meta data type in CameraMetaDataCallback */
enum {
CAMERA_META_DATA_ASD = 0x001, //ASD data
CAMERA_META_DATA_FD = 0x002, //FD/FP data
CAMERA_META_DATA_HDR = 0x003, //Auto HDR data
};

/** cmdType in sendCommand functions */
enum {
CAMERA_CMD_START_SMOOTH_ZOOM = 1,
Expand Down Expand Up @@ -189,7 +200,25 @@ enum {
* IMPLEMENTATION_DEFINED, then HALv3 devices will use gralloc usage flags
* of SW_READ_OFTEN.
*/
CAMERA_CMD_SET_VIDEO_FORMAT = 11
CAMERA_CMD_SET_VIDEO_FORMAT = 11,

CAMERA_CMD_VENDOR_START = 20,
/**
* Commands to enable/disable preview histogram
*
* Based on user's input to enable/disable histogram from the camera
* UI, send the appropriate command to the HAL to turn on/off the histogram
* stats and start sending the data to the application.
*/
CAMERA_CMD_HISTOGRAM_ON = CAMERA_CMD_VENDOR_START,
CAMERA_CMD_HISTOGRAM_OFF = CAMERA_CMD_VENDOR_START + 1,
CAMERA_CMD_HISTOGRAM_SEND_DATA = CAMERA_CMD_VENDOR_START + 2,
CAMERA_CMD_LONGSHOT_ON = CAMERA_CMD_VENDOR_START + 3,
CAMERA_CMD_LONGSHOT_OFF = CAMERA_CMD_VENDOR_START + 4,
CAMERA_CMD_STOP_LONGSHOT = CAMERA_CMD_VENDOR_START + 5,
CAMERA_CMD_METADATA_ON = CAMERA_CMD_VENDOR_START + 6,
CAMERA_CMD_METADATA_OFF = CAMERA_CMD_VENDOR_START + 7,
CAMERA_CMD_VENDOR_END = 200,
};

/** camera fatal errors */
Expand Down Expand Up @@ -284,9 +313,29 @@ typedef struct camera_face {
* -2000, -2000 if this is not supported.
*/
int32_t mouth[2];
int32_t smile_degree;
int32_t smile_score;
int32_t blink_detected;
int32_t face_recognised;
int32_t gaze_angle;
int32_t updown_dir;
int32_t leftright_dir;
int32_t roll_dir;
int32_t left_right_gaze;
int32_t top_bottom_gaze;
int32_t leye_blink;
int32_t reye_blink;

} camera_face_t;

/**
* The information of a data type received in a camera frame.
*/
typedef enum {
/** Data buffer */
CAMERA_FRAME_DATA_BUF = 0x000,
/** File descriptor */
CAMERA_FRAME_DATA_FD = 0x100
} camera_frame_data_type_t;
/**
* The metadata of the frame data.
*/
Expand Down
3 changes: 3 additions & 0 deletions rootdir/etc/hosts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
127.0.0.1 localhost
::1 ip6-localhost
127.0.0.1 ota.googlezip.net
127.0.0.1 ota-cache1.googlezip.net
127.0.0.1 ota-cache2.googlezip.net