diff options
-rw-r--r-- | adb/usb_linux_client.cpp | 50 | ||||
-rw-r--r-- | fs_mgr/fs_mgr.c | 205 | ||||
-rw-r--r-- | fs_mgr/include/fs_mgr.h | 1 | ||||
-rw-r--r-- | healthd/BatteryMonitor.cpp | 81 | ||||
-rw-r--r-- | include/private/android_filesystem_config.h | 12 | ||||
-rw-r--r-- | include/system/camera.h | 53 | ||||
-rw-r--r-- | init/builtins.cpp | 21 | ||||
-rw-r--r-- | init/devices.cpp | 8 | ||||
-rw-r--r-- | init/init.cpp | 3 | ||||
-rw-r--r-- | init/ueventd.cpp | 4 | ||||
-rw-r--r-- | rootdir/init.rc | 4 | ||||
-rw-r--r-- | rootdir/ueventd.rc | 2 | ||||
-rw-r--r-- | sdcard/Android.mk | 4 | ||||
-rw-r--r-- | sdcard/sdcard.c | 21 |
14 files changed, 361 insertions, 108 deletions
diff --git a/adb/usb_linux_client.cpp b/adb/usb_linux_client.cpp index 18289e2..f3db346 100644 --- a/adb/usb_linux_client.cpp +++ b/adb/usb_linux_client.cpp @@ -64,6 +64,14 @@ struct func_desc { struct usb_endpoint_descriptor_no_audio sink; } __attribute__((packed)); +struct ss_func_desc { + struct usb_interface_descriptor intf; + struct usb_endpoint_descriptor_no_audio source; + struct usb_ss_ep_comp_descriptor source_comp; + struct usb_endpoint_descriptor_no_audio sink; + struct usb_ss_ep_comp_descriptor sink_comp; +} __attribute__((packed)); + struct desc_v1 { struct usb_functionfs_descs_head_v1 { __le32 magic; @@ -79,7 +87,9 @@ struct desc_v2 { // The rest of the structure depends on the flags in the header. __le32 fs_count; __le32 hs_count; + __le32 ss_count; struct func_desc fs_descs, hs_descs; + struct ss_func_desc ss_descs; } __attribute__((packed)); struct func_desc fs_descriptors = { @@ -136,6 +146,41 @@ struct func_desc hs_descriptors = { }, }; +static struct ss_func_desc ss_descriptors = { + .intf = { + .bLength = sizeof(ss_descriptors.intf), + .bDescriptorType = USB_DT_INTERFACE, + .bInterfaceNumber = 0, + .bNumEndpoints = 2, + .bInterfaceClass = ADB_CLASS, + .bInterfaceSubClass = ADB_SUBCLASS, + .bInterfaceProtocol = ADB_PROTOCOL, + .iInterface = 1, /* first string from the provided table */ + }, + .source = { + .bLength = sizeof(ss_descriptors.source), + .bDescriptorType = USB_DT_ENDPOINT, + .bEndpointAddress = 1 | USB_DIR_OUT, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = MAX_PACKET_SIZE_SS, + }, + .source_comp = { + .bLength = sizeof(ss_descriptors.source_comp), + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, + }, + .sink = { + .bLength = sizeof(ss_descriptors.sink), + .bDescriptorType = USB_DT_ENDPOINT, + .bEndpointAddress = 2 | USB_DIR_IN, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = MAX_PACKET_SIZE_SS, + }, + .sink_comp = { + .bLength = sizeof(ss_descriptors.sink_comp), + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, + }, +}; + #define STR_INTERFACE_ "ADB Interface" static const struct { @@ -279,11 +324,14 @@ static void init_functionfs(struct usb_handle *h) v2_descriptor.header.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2); v2_descriptor.header.length = cpu_to_le32(sizeof(v2_descriptor)); - v2_descriptor.header.flags = FUNCTIONFS_HAS_FS_DESC | FUNCTIONFS_HAS_HS_DESC; + v2_descriptor.header.flags = FUNCTIONFS_HAS_FS_DESC | FUNCTIONFS_HAS_HS_DESC | + FUNCTIONFS_HAS_SS_DESC; v2_descriptor.fs_count = 3; v2_descriptor.hs_count = 3; + v2_descriptor.ss_count = 5; v2_descriptor.fs_descs = fs_descriptors; v2_descriptor.hs_descs = hs_descriptors; + v2_descriptor.ss_descs = ss_descriptors; if (h->control < 0) { // might have already done this before D("OPENING %s\n", USB_FFS_ADB_EP0); diff --git a/fs_mgr/fs_mgr.c b/fs_mgr/fs_mgr.c index 15d44ef..1b26b43 100644 --- a/fs_mgr/fs_mgr.c +++ b/fs_mgr/fs_mgr.c @@ -492,6 +492,52 @@ static int handle_encryptable(struct fstab *fstab, const struct fstab_rec* rec) return FS_MGR_MNTALL_DEV_NOT_ENCRYPTED; } +/* + * Reads the kernel cmdline to check if MDTP is activated. + * When MDTP is activated, kernel cmdline will have the word 'mdtp'. + */ +int fs_mgr_is_mdtp_activated() +{ + char cmdline[2048]; + char *ptr; + int fd; + static int mdtp_activated = 0; + static int mdtp_activated_set = 0; + + if (mdtp_activated_set) { + return mdtp_activated; + } + + fd = open("/proc/cmdline", O_RDONLY); + if (fd >= 0) { + int n = read(fd, cmdline, sizeof(cmdline) - 1); + if (n < 0) n = 0; + + /* get rid of trailing newline, it happens */ + if (n > 0 && cmdline[n-1] == '\n') n--; + + cmdline[n] = 0; + close(fd); + } else { + cmdline[0] = 0; + } + + ptr = cmdline; + while (ptr && *ptr) { + char *x = strchr(ptr, ' '); + if (x != 0) *x++ = 0; + if (!strcmp(ptr,"mdtp")) { + mdtp_activated = 1; + break; + } + ptr = x; + } + + mdtp_activated_set = 1; + + return mdtp_activated; +} + /* When multiple fstab records share the same mount_point, it will * try to mount each one in turn, and ignore any duplicates after a * first successful mount. @@ -547,91 +593,106 @@ int fs_mgr_mount_all(struct fstab *fstab) continue; } } - int last_idx_inspected; - int top_idx = i; - mret = mount_with_alternatives(fstab, i, &last_idx_inspected, &attempted_idx); - i = last_idx_inspected; - mount_errno = errno; + if (fs_mgr_is_mdtp_activated() && ((fstab->recs[i].fs_mgr_flags & MF_FORCECRYPT) || + device_is_force_encrypted())) { + INFO("%s(): mdtp activated, blkdev %s for mount %s type %s expected to be encrypted)\n", + __func__, fstab->recs[i].blk_device, fstab->recs[i].mount_point, + fstab->recs[i].fs_type); + if (fs_mgr_do_tmpfs_mount(fstab->recs[i].mount_point) < 0) { + ++error_count; + continue; + } - /* Deal with encryptability. */ - if (!mret) { - int status = handle_encryptable(fstab, &fstab->recs[attempted_idx]); + encryptable = FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED; - if (status == FS_MGR_MNTALL_FAIL) { - /* Fatal error - no point continuing */ - return status; - } + } else { + int last_idx_inspected; + int top_idx = i; - if (status != FS_MGR_MNTALL_DEV_NOT_ENCRYPTED) { - if (encryptable != FS_MGR_MNTALL_DEV_NOT_ENCRYPTED) { - // Log and continue - ERROR("Only one encryptable/encrypted partition supported\n"); - } - encryptable = status; - } + mret = mount_with_alternatives(fstab, i, &last_idx_inspected, &attempted_idx); + i = last_idx_inspected; + mount_errno = errno; - /* Success! Go get the next one */ - continue; - } + /* Deal with encryptability. */ + if (!mret) { + int status = handle_encryptable(fstab, &fstab->recs[attempted_idx]); - /* mount(2) returned an error, handle the encryptable/formattable case */ - bool wiped = partition_wiped(fstab->recs[top_idx].blk_device); - if (mret && mount_errno != EBUSY && mount_errno != EACCES && - fs_mgr_is_formattable(&fstab->recs[top_idx]) && wiped) { - /* top_idx and attempted_idx point at the same partition, but sometimes - * at two different lines in the fstab. Use the top one for formatting - * as that is the preferred one. - */ - ERROR("%s(): %s is wiped and %s %s is formattable. Format it.\n", __func__, - fstab->recs[top_idx].blk_device, fstab->recs[top_idx].mount_point, - fstab->recs[top_idx].fs_type); - if (fs_mgr_is_encryptable(&fstab->recs[top_idx]) && - strcmp(fstab->recs[top_idx].key_loc, KEY_IN_FOOTER)) { - int fd = open(fstab->recs[top_idx].key_loc, O_WRONLY, 0644); - if (fd >= 0) { - INFO("%s(): also wipe %s\n", __func__, fstab->recs[top_idx].key_loc); - wipe_block_device(fd, get_file_size(fd)); - close(fd); - } else { - ERROR("%s(): %s wouldn't open (%s)\n", __func__, - fstab->recs[top_idx].key_loc, strerror(errno)); + if (status == FS_MGR_MNTALL_FAIL) { + /* Fatal error - no point continuing */ + return status; } - } - if (fs_mgr_do_format(&fstab->recs[top_idx]) == 0) { - /* Let's replay the mount actions. */ - i = top_idx - 1; + + if (status != FS_MGR_MNTALL_DEV_NOT_ENCRYPTED) { + if (encryptable != FS_MGR_MNTALL_DEV_NOT_ENCRYPTED) { + // Log and continue + ERROR("Only one encryptable/encrypted partition supported\n"); + } + encryptable = status; + } + + /* Success! Go get the next one */ continue; } - } - if (mret && mount_errno != EBUSY && mount_errno != EACCES && - fs_mgr_is_encryptable(&fstab->recs[attempted_idx])) { - if (wiped) { - ERROR("%s(): %s is wiped and %s %s is encryptable. Suggest recovery...\n", __func__, - fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point, - fstab->recs[attempted_idx].fs_type); - encryptable = FS_MGR_MNTALL_DEV_NEEDS_RECOVERY; - continue; - } else { - /* Need to mount a tmpfs at this mountpoint for now, and set - * properties that vold will query later for decrypting + + /* mount(2) returned an error, handle the encryptable/formattable case */ + bool wiped = partition_wiped(fstab->recs[top_idx].blk_device); + if (mret && mount_errno != EBUSY && mount_errno != EACCES && + fs_mgr_is_formattable(&fstab->recs[top_idx]) && wiped) { + /* top_idx and attempted_idx point at the same partition, but sometimes + * at two different lines in the fstab. Use the top one for formatting + * as that is the preferred one. */ - ERROR("%s(): possibly an encryptable blkdev %s for mount %s type %s )\n", __func__, - fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point, - fstab->recs[attempted_idx].fs_type); - if (fs_mgr_do_tmpfs_mount(fstab->recs[attempted_idx].mount_point) < 0) { - ++error_count; + ERROR("%s(): %s is wiped and %s %s is formattable. Format it.\n", __func__, + fstab->recs[top_idx].blk_device, fstab->recs[top_idx].mount_point, + fstab->recs[top_idx].fs_type); + if (fs_mgr_is_encryptable(&fstab->recs[top_idx]) && + strcmp(fstab->recs[top_idx].key_loc, KEY_IN_FOOTER)) { + int fd = open(fstab->recs[top_idx].key_loc, O_WRONLY, 0644); + if (fd >= 0) { + INFO("%s(): also wipe %s\n", __func__, fstab->recs[top_idx].key_loc); + wipe_block_device(fd, get_file_size(fd)); + close(fd); + } else { + ERROR("%s(): %s wouldn't open (%s)\n", __func__, + fstab->recs[top_idx].key_loc, strerror(errno)); + } + } + if (fs_mgr_do_format(&fstab->recs[top_idx]) == 0) { + /* Let's replay the mount actions. */ + i = top_idx - 1; continue; } } - encryptable = FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED; - } else { - ERROR("Failed to mount an un-encryptable or wiped partition on" - "%s at %s options: %s error: %s\n", - fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point, - fstab->recs[attempted_idx].fs_options, strerror(mount_errno)); - ++error_count; - continue; + if (mret && mount_errno != EBUSY && mount_errno != EACCES && + fs_mgr_is_encryptable(&fstab->recs[attempted_idx])) { + if (wiped) { + ERROR("%s(): %s is wiped and %s %s is encryptable. Suggest recovery...\n", __func__, + fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point, + fstab->recs[attempted_idx].fs_type); + encryptable = FS_MGR_MNTALL_DEV_NEEDS_RECOVERY; + continue; + } else { + /* Need to mount a tmpfs at this mountpoint for now, and set + * properties that vold will query later for decrypting + */ + ERROR("%s(): possibly an encryptable blkdev %s for mount %s type %s )\n", __func__, + fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point, + fstab->recs[attempted_idx].fs_type); + if (fs_mgr_do_tmpfs_mount(fstab->recs[attempted_idx].mount_point) < 0) { + ++error_count; + continue; + } + } + encryptable = FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED; + } else { + ERROR("Failed to mount an un-encryptable or wiped partition on" + "%s at %s options: %s error: %s\n", + fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point, + fstab->recs[attempted_idx].fs_options, strerror(mount_errno)); + ++error_count; + continue; + } } } diff --git a/fs_mgr/include/fs_mgr.h b/fs_mgr/include/fs_mgr.h index 27fccf7..adcb07b 100644 --- a/fs_mgr/include/fs_mgr.h +++ b/fs_mgr/include/fs_mgr.h @@ -106,6 +106,7 @@ int fs_mgr_is_noemulatedsd(const struct fstab_rec *fstab); int fs_mgr_is_notrim(struct fstab_rec *fstab); int fs_mgr_is_formattable(struct fstab_rec *fstab); int fs_mgr_swapon_all(struct fstab *fstab); +int fs_mgr_is_mdtp_activated(void); int fs_mgr_do_format(struct fstab_rec *fstab); diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index 7ea8250..b0e9a4d 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -134,7 +134,10 @@ BatteryMonitor::PowerSupplyType BatteryMonitor::readPowerSupplyType(const String { "USB_DCP", ANDROID_POWER_SUPPLY_TYPE_AC }, { "USB_CDP", ANDROID_POWER_SUPPLY_TYPE_AC }, { "USB_ACA", ANDROID_POWER_SUPPLY_TYPE_AC }, + { "USB_HVDCP", ANDROID_POWER_SUPPLY_TYPE_AC }, + { "USB_HVDCP_3", ANDROID_POWER_SUPPLY_TYPE_AC }, { "Wireless", ANDROID_POWER_SUPPLY_TYPE_WIRELESS }, + { "Wipower", ANDROID_POWER_SUPPLY_TYPE_WIRELESS }, { NULL, 0 }, }; @@ -209,35 +212,63 @@ bool BatteryMonitor::update(void) { if (readFromFile(mHealthdConfig->batteryTechnologyPath, buf, SIZE) > 0) props.batteryTechnology = String8(buf); - unsigned int i; + // reinitialize the mChargerNames vector everytime there is an update + String8 path; + DIR* dir = opendir(POWER_SUPPLY_SYSFS_PATH); + if (dir == NULL) { + KLOG_ERROR(LOG_TAG, "Could not open %s\n", POWER_SUPPLY_SYSFS_PATH); + } else { + struct dirent* entry; + // reconstruct the charger strings + mChargerNames.clear(); + while ((entry = readdir(dir))) { + const char* name = entry->d_name; - for (i = 0; i < mChargerNames.size(); i++) { - String8 path; - path.appendFormat("%s/%s/online", POWER_SUPPLY_SYSFS_PATH, - mChargerNames[i].string()); + if (!strcmp(name, ".") || !strcmp(name, "..")) + continue; - if (readFromFile(path, buf, SIZE) > 0) { - if (buf[0] != '0') { + // Look for "type" file in each subdirectory + path.clear(); + path.appendFormat("%s/%s/type", POWER_SUPPLY_SYSFS_PATH, name); + switch(readPowerSupplyType(path)) { + case ANDROID_POWER_SUPPLY_TYPE_AC: + case ANDROID_POWER_SUPPLY_TYPE_USB: + case ANDROID_POWER_SUPPLY_TYPE_WIRELESS: path.clear(); - path.appendFormat("%s/%s/type", POWER_SUPPLY_SYSFS_PATH, - mChargerNames[i].string()); - switch(readPowerSupplyType(path)) { - case ANDROID_POWER_SUPPLY_TYPE_AC: - props.chargerAcOnline = true; - break; - case ANDROID_POWER_SUPPLY_TYPE_USB: - props.chargerUsbOnline = true; - break; - case ANDROID_POWER_SUPPLY_TYPE_WIRELESS: - props.chargerWirelessOnline = true; - break; - default: - KLOG_WARNING(LOG_TAG, "%s: Unknown power supply type\n", - mChargerNames[i].string()); + path.appendFormat("%s/%s/online", POWER_SUPPLY_SYSFS_PATH, name); + if (access(path.string(), R_OK) == 0) { + mChargerNames.add(String8(name)); + if (readFromFile(path, buf, SIZE) > 0) { + if (buf[0] != '0') { + path.clear(); + path.appendFormat("%s/%s/type", POWER_SUPPLY_SYSFS_PATH, + name); + switch(readPowerSupplyType(path)) { + case ANDROID_POWER_SUPPLY_TYPE_AC: + props.chargerAcOnline = true; + break; + case ANDROID_POWER_SUPPLY_TYPE_USB: + props.chargerUsbOnline = true; + break; + case ANDROID_POWER_SUPPLY_TYPE_WIRELESS: + props.chargerWirelessOnline = true; + break; + default: + KLOG_WARNING(LOG_TAG, "%s: Unknown power supply type\n", + name); + } + } + } } - } - } - } + break; + case ANDROID_POWER_SUPPLY_TYPE_BATTERY: + break; + default: + break; + } //switch + } //while + closedir(dir); + }//else logthis = !healthd_board_battery_update(&props); diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h index 2ed27dc..8b3390c 100644 --- a/include/private/android_filesystem_config.h +++ b/include/private/android_filesystem_config.h @@ -97,6 +97,12 @@ #define AID_NET_BW_STATS 3006 /* read bandwidth statistics */ #define AID_NET_BW_ACCT 3007 /* change bandwidth statistics accounting */ #define AID_NET_BT_STACK 3008 /* bluetooth: access config files */ +#define AID_QCOM_DIAG 3009 /* can read/write /dev/diag */ + +#define AID_SENSORS 3011 /* access to /dev/socket/sensor_ctl_socket & QCCI/QCSI */ + +#define AID_RFS 3012 /* Remote Filesystem for peripheral processors */ +#define AID_RFS_SHARED 3013 /* Shared files for Remote Filesystem for peripheral processors */ #define AID_EVERYBODY 9997 /* shared between all apps in the same profile */ #define AID_MISC 9998 /* access to misc storage */ @@ -172,6 +178,7 @@ static const struct android_id_info android_ids[] = { { "shell", AID_SHELL, }, { "cache", AID_CACHE, }, { "diag", AID_DIAG, }, + { "qcom_diag", AID_QCOM_DIAG, }, { "net_bt_admin", AID_NET_BT_ADMIN, }, { "net_bt", AID_NET_BT, }, @@ -182,6 +189,11 @@ static const struct android_id_info android_ids[] = { { "net_bw_acct", AID_NET_BW_ACCT, }, { "net_bt_stack", AID_NET_BT_STACK, }, + { "sensors", AID_SENSORS, }, + + { "rfs", AID_RFS, }, + { "rfs_shared", AID_RFS_SHARED, }, + { "everybody", AID_EVERYBODY, }, { "misc", AID_MISC, }, { "nobody", AID_NOBODY, }, diff --git a/include/system/camera.h b/include/system/camera.h index 5d0873a..6de0203 100644 --- a/include/system/camera.h +++ b/include/system/camera.h @@ -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, @@ -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 */ @@ -275,10 +304,32 @@ 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. */ typedef struct camera_frame_metadata { diff --git a/init/builtins.cpp b/init/builtins.cpp index 9e5f9ff..bab30d7 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -401,6 +401,7 @@ int do_mount_all(int nargs, char **args) int ret = -1; int child_ret = -1; int status; + char boot_mode[PROP_VALUE_MAX] = {0}; struct fstab *fstab; if (nargs != 2) { @@ -450,10 +451,13 @@ int do_mount_all(int nargs, char **args) property_set("vold.decrypt", "trigger_default_encryption"); } else if (ret == FS_MGR_MNTALL_DEV_NOT_ENCRYPTED) { property_set("ro.crypto.state", "unencrypted"); - /* If fs_mgr determined this is an unencrypted device, then trigger - * that action. + /* If fs_mgr determined this is an unencrypted device and we are + * not booting into ffbm(fast factory boot mode),then trigger + * that action. */ - action_for_each_trigger("nonencrypted", action_add_queue_tail); + property_get("ro.bootmode", boot_mode); + if (strncmp(boot_mode, "ffbm", 4)) + action_for_each_trigger("nonencrypted", action_add_queue_tail); } else if (ret == FS_MGR_MNTALL_DEV_NEEDS_RECOVERY) { /* Setup a wipe via recovery, and reboot into recovery */ ERROR("fs_mgr_mount_all suggested recovery, so wiping data via recovery.\n"); @@ -468,7 +472,9 @@ int do_mount_all(int nargs, char **args) // Although encrypted, we have device key, so we do not need to // do anything different from the nonencrypted case. - action_for_each_trigger("nonencrypted", action_add_queue_tail); + property_get("ro.bootmode", boot_mode); + if (strncmp(boot_mode, "ffbm", 4)) + action_for_each_trigger("nonencrypted", action_add_queue_tail); } else if (ret == FS_MGR_MNTALL_DEV_NON_DEFAULT_FILE_ENCRYPTED) { if (e4crypt_install_keyring()) { return -1; @@ -578,7 +584,14 @@ int do_powerctl(int nargs, char **args) } if (command[len] == ',') { + char prop_value[PROP_VALUE_MAX] = {0}; reboot_target = &command[len + 1]; + + if ((property_get("init.svc.recovery", prop_value) == 0) && + (strncmp(reboot_target, "keys", 4) == 0)) { + ERROR("powerctl: permission denied\n"); + return -EINVAL; + } } else if (command[len] == '\0') { reboot_target = ""; } else { diff --git a/init/devices.cpp b/init/devices.cpp index 4944cec..9151f06 100644 --- a/init/devices.cpp +++ b/init/devices.cpp @@ -47,6 +47,7 @@ #include "ueventd_parser.h" #include "util.h" #include "log.h" +#include "property_service.h" #define SYSFS_PREFIX "/sys" static const char *firmware_dirs[] = { "/etc/firmware", @@ -55,6 +56,8 @@ static const char *firmware_dirs[] = { "/etc/firmware", extern struct selabel_handle *sehandle; +extern char boot_device[PROP_VALUE_MAX]; + static int device_fd = -1; struct uevent { @@ -518,6 +521,11 @@ static char **get_block_device_symlinks(struct uevent *uevent) else links[link_num] = NULL; + if (pdev && boot_device[0] != '\0' && strstr(device, boot_device)) { + /* Create bootdevice symlink for platform boot stroage device */ + make_link_init(link_path, "/dev/block/bootdevice"); + } + return links; } diff --git a/init/init.cpp b/init/init.cpp index 93fe944..9eb2958 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -1099,6 +1099,9 @@ int main(int argc, char** argv) { char bootmode[PROP_VALUE_MAX]; if (property_get("ro.bootmode", bootmode) > 0 && strcmp(bootmode, "charger") == 0) { action_for_each_trigger("charger", action_add_queue_tail); + } else if (strncmp(bootmode, "ffbm", 4) == 0) { + KLOG_ERROR("Booting into ffbm mode\n"); + action_for_each_trigger("ffbm", action_add_queue_tail); } else { action_for_each_trigger("late-init", action_add_queue_tail); } diff --git a/init/ueventd.cpp b/init/ueventd.cpp index c63fdaa..2dd8b01 100644 --- a/init/ueventd.cpp +++ b/init/ueventd.cpp @@ -33,6 +33,8 @@ #include "ueventd_parser.h" #include "property_service.h" +char boot_device[PROP_VALUE_MAX]; + int ueventd_main(int argc, char **argv) { /* @@ -65,6 +67,8 @@ int ueventd_main(int argc, char **argv) ueventd_parse_config_file("/ueventd.rc"); ueventd_parse_config_file(android::base::StringPrintf("/ueventd.%s.rc", hardware).c_str()); + property_get("ro.boot.bootdevice", boot_device); + device_init(); pollfd ufd; diff --git a/rootdir/init.rc b/rootdir/init.rc index b71908c..d5d12a5 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -601,7 +601,7 @@ service ril-daemon /system/bin/rild socket sap_uim_socket1 stream 660 bluetooth bluetooth socket rild-debug stream 660 radio system user root - group radio cache inet misc audio log + group radio cache inet misc audio log qcom_diag service surfaceflinger /system/bin/surfaceflinger class core @@ -617,7 +617,7 @@ service drm /system/bin/drmserver service media /system/bin/mediaserver class main user media - group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc mediadrm + group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc mediadrm qcom_diag ioprio rt 4 # One shot invocation to deal with encrypted volume. diff --git a/rootdir/ueventd.rc b/rootdir/ueventd.rc index b735dc3..33f29f9 100644 --- a/rootdir/ueventd.rc +++ b/rootdir/ueventd.rc @@ -28,7 +28,7 @@ subsystem adf /dev/dri/* 0666 root graphics # these should not be world writable -/dev/diag 0660 radio radio +/dev/diag 0660 system qcom_diag /dev/diag_arm9 0660 radio radio /dev/android_adb 0660 adb adb /dev/android_adb_enable 0660 adb adb diff --git a/sdcard/Android.mk b/sdcard/Android.mk index cb3a8fb..89c3613 100644 --- a/sdcard/Android.mk +++ b/sdcard/Android.mk @@ -1,6 +1,10 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) +ifeq ($(call is-vendor-board-platform,QCOM),true) +LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include +LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr +endif LOCAL_SRC_FILES := sdcard.c LOCAL_MODULE := sdcard diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c index a79e2dd..840642b 100644 --- a/sdcard/sdcard.c +++ b/sdcard/sdcard.c @@ -1202,7 +1202,13 @@ static int handle_open(struct fuse* fuse, struct fuse_handler* handler, } out.fh = ptr_to_id(h); out.open_flags = 0; - out.padding = 0; + + #ifdef FUSE_SHORTCIRCUIT + out.lower_fd = h->fd; + #else + out.padding = 0; + #endif + fuse_reply(fuse, hdr->unique, &out, sizeof(out)); return NO_STATUS; } @@ -1366,7 +1372,13 @@ static int handle_opendir(struct fuse* fuse, struct fuse_handler* handler, } out.fh = ptr_to_id(h); out.open_flags = 0; - out.padding = 0; + + #ifdef FUSE_SHORTCIRCUIT + out.lower_fd = -1; + #else + out.padding = 0; + #endif + fuse_reply(fuse, hdr->unique, &out, sizeof(out)); return NO_STATUS; } @@ -1448,6 +1460,11 @@ static int handle_init(struct fuse* fuse, struct fuse_handler* handler, out.major = FUSE_KERNEL_VERSION; out.max_readahead = req->max_readahead; out.flags = FUSE_ATOMIC_O_TRUNC | FUSE_BIG_WRITES; + + #ifdef FUSE_SHORTCIRCUIT + out.flags |= FUSE_SHORTCIRCUIT; + #endif + out.max_background = 32; out.congestion_threshold = 32; out.max_write = MAX_WRITE; |