diff options
-rw-r--r-- | fastboot/fastboot.c | 45 | ||||
-rw-r--r-- | fs_mgr/fs_mgr_fstab.c | 6 | ||||
-rw-r--r-- | fs_mgr/fs_mgr_priv.h | 1 | ||||
-rw-r--r-- | fs_mgr/include/fs_mgr.h | 1 | ||||
-rw-r--r-- | healthd/healthd.cpp | 1 | ||||
-rw-r--r-- | healthd/healthd.h | 1 | ||||
-rw-r--r-- | healthd/healthd_mode_charger.cpp | 23 | ||||
-rw-r--r-- | include/system/audio.h | 6 | ||||
-rw-r--r-- | include/system/camera.h | 7 | ||||
-rw-r--r-- | include/system/graphics.h | 209 | ||||
-rw-r--r-- | include/system/window.h | 28 | ||||
-rw-r--r-- | init/init.cpp | 69 | ||||
-rw-r--r-- | init/ueventd.cpp | 26 | ||||
-rw-r--r-- | init/util.cpp | 33 | ||||
-rw-r--r-- | init/util.h | 1 | ||||
-rw-r--r-- | libion/ion.c | 14 | ||||
-rw-r--r-- | logwrapper/logwrap.c | 2 | ||||
-rw-r--r-- | rootdir/init.rc | 4 |
18 files changed, 315 insertions, 162 deletions
diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c index fc544a6..7279b04 100644 --- a/fastboot/fastboot.c +++ b/fastboot/fastboot.c @@ -295,9 +295,8 @@ void usage(void) " Can override the fs type and/or\n" " size the bootloader reports.\n" " getvar <variable> display a bootloader variable\n" - " boot <kernel> [ <ramdisk> [ <second> ] ] download and boot kernel\n" - " flash:raw boot <kernel> [ <ramdisk> [ <second> ] ] create bootimage and \n" - " flash it\n" + " boot <kernel> [ <ramdisk> ] download and boot kernel\n" + " flash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash it\n" " devices list all connected devices\n" " continue continue with autoboot\n" " reboot [bootloader] reboot device, optionally into bootloader\n" @@ -325,11 +324,10 @@ void usage(void) } void *load_bootable_image(const char *kernel, const char *ramdisk, - const char *secondstage, unsigned *sz, - const char *cmdline) + unsigned *sz, const char *cmdline) { - void *kdata = 0, *rdata = 0, *sdata = 0; - unsigned ksize = 0, rsize = 0, ssize = 0; + void *kdata = 0, *rdata = 0; + unsigned ksize = 0, rsize = 0; void *bdata; unsigned bsize; @@ -365,18 +363,10 @@ void *load_bootable_image(const char *kernel, const char *ramdisk, } } - if (secondstage) { - sdata = load_file(secondstage, &ssize); - if(sdata == 0) { - fprintf(stderr,"cannot load '%s': %s\n", secondstage, strerror(errno)); - return 0; - } - } - fprintf(stderr,"creating boot image...\n"); bdata = mkbootimg(kdata, ksize, kernel_offset, rdata, rsize, ramdisk_offset, - sdata, ssize, second_offset, + 0, 0, second_offset, page_size, base_addr, tags_offset, &bsize); if(bdata == 0) { fprintf(stderr,"failed to create boot.img\n"); @@ -1170,7 +1160,6 @@ int main(int argc, char **argv) } else if(!strcmp(*argv, "boot")) { char *kname = 0; char *rname = 0; - char *sname = 0; skip(1); if (argc > 0) { kname = argv[0]; @@ -1180,11 +1169,7 @@ int main(int argc, char **argv) rname = argv[0]; skip(1); } - if (argc > 0) { - sname = argv[0]; - skip(1); - } - data = load_bootable_image(kname, rname, sname, &sz, cmdline); + data = load_bootable_image(kname, rname, &sz, cmdline); if (data == 0) return 1; fb_queue_download("boot.img", data, sz); fb_queue_command("boot", "booting"); @@ -1208,18 +1193,14 @@ int main(int argc, char **argv) char *pname = argv[1]; char *kname = argv[2]; char *rname = 0; - char *sname = 0; require(3); - skip(3); - if (argc > 0) { - rname = argv[0]; - skip(1); - } - if (argc > 0) { - sname = argv[0]; - skip(1); + if(argc > 3) { + rname = argv[3]; + skip(4); + } else { + skip(3); } - data = load_bootable_image(kname, rname, sname, &sz, cmdline); + data = load_bootable_image(kname, rname, &sz, cmdline); if (data == 0) die("cannot load bootable image"); fb_queue_flash(pname, data, sz); } else if(!strcmp(*argv, "flashall")) { diff --git a/fs_mgr/fs_mgr_fstab.c b/fs_mgr/fs_mgr_fstab.c index ab8f128..64f7edc 100644 --- a/fs_mgr/fs_mgr_fstab.c +++ b/fs_mgr/fs_mgr_fstab.c @@ -68,6 +68,7 @@ static struct flag_list fs_mgr_flags[] = { { "zramsize=", MF_ZRAMSIZE }, { "verify", MF_VERIFY }, { "noemulatedsd", MF_NOEMULATEDSD }, + { "notrim", MF_NOTRIM }, { "defaults", 0 }, { 0, 0 }, }; @@ -432,3 +433,8 @@ int fs_mgr_is_noemulatedsd(struct fstab_rec *fstab) { return fstab->fs_mgr_flags & MF_NOEMULATEDSD; } + +int fs_mgr_is_notrim(struct fstab_rec *fstab) +{ + return fstab->fs_mgr_flags & MF_NOTRIM; +} diff --git a/fs_mgr/fs_mgr_priv.h b/fs_mgr/fs_mgr_priv.h index 88a1040..efc7ca5 100644 --- a/fs_mgr/fs_mgr_priv.h +++ b/fs_mgr/fs_mgr_priv.h @@ -76,6 +76,7 @@ #define MF_FORCECRYPT 0x400 #define MF_NOEMULATEDSD 0x800 /* no emulated sdcard daemon, sd card is the only external storage */ +#define MF_NOTRIM 0x1000 #define DM_BUF_SIZE 4096 diff --git a/fs_mgr/include/fs_mgr.h b/fs_mgr/include/fs_mgr.h index 0437d45..a7a0bdb 100644 --- a/fs_mgr/include/fs_mgr.h +++ b/fs_mgr/include/fs_mgr.h @@ -94,6 +94,7 @@ int fs_mgr_is_nonremovable(struct fstab_rec *fstab); int fs_mgr_is_verified(struct fstab_rec *fstab); int fs_mgr_is_encryptable(struct fstab_rec *fstab); int fs_mgr_is_noemulatedsd(struct fstab_rec *fstab); +int fs_mgr_is_notrim(struct fstab_rec *fstab); int fs_mgr_swapon_all(struct fstab *fstab); #ifdef __cplusplus } diff --git a/healthd/healthd.cpp b/healthd/healthd.cpp index 1fee855..b0002cc 100644 --- a/healthd/healthd.cpp +++ b/healthd/healthd.cpp @@ -53,6 +53,7 @@ static struct healthd_config healthd_config = { .batteryCurrentAvgPath = String8(String8::kEmptyString), .batteryChargeCounterPath = String8(String8::kEmptyString), .energyCounter = NULL, + .boot_min_cap = 0, .screen_on = NULL, }; diff --git a/healthd/healthd.h b/healthd/healthd.h index 4704f0b..84b6d76 100644 --- a/healthd/healthd.h +++ b/healthd/healthd.h @@ -67,6 +67,7 @@ struct healthd_config { android::String8 batteryChargeCounterPath; int (*energyCounter)(int64_t *); + int boot_min_cap; bool (*screen_on)(android::BatteryProperties *props); }; diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp index 9ed5944..352510b 100644 --- a/healthd/healthd_mode_charger.cpp +++ b/healthd/healthd_mode_charger.cpp @@ -116,6 +116,7 @@ struct charger { struct animation *batt_anim; gr_surface surf_unknown; + int boot_min_cap; }; static struct frame batt_anim_frames[] = { @@ -520,19 +521,29 @@ static void process_key(struct charger *charger, int code, int64_t now) LOGW("[%" PRId64 "] booting from charger mode\n", now); property_set("sys.boot_from_charger_mode", "1"); } else { - LOGW("[%" PRId64 "] rebooting\n", now); - android_reboot(ANDROID_RB_RESTART, 0, 0); + if (charger->batt_anim->capacity >= charger->boot_min_cap) { + LOGW("[%" PRId64 "] rebooting\n", now); + android_reboot(ANDROID_RB_RESTART, 0, 0); + } else { + LOGV("[%" PRId64 "] ignore power-button press, battery level " + "less than minimum\n", now); + } } } else { /* if the key is pressed but timeout hasn't expired, * make sure we wake up at the right-ish time to check */ set_next_key_check(charger, key, POWER_ON_KEY_TIME); + + /* Turn on the display and kick animation on power-key press + * rather than on key release + */ + kick_animation(charger->batt_anim); + request_suspend(false); } } else { /* if the power key got released, force screen state cycle */ if (key->pending) { - request_suspend(false); kick_animation(charger->batt_anim); } } @@ -555,6 +566,11 @@ static void handle_power_supply_state(struct charger *charger, int64_t now) return; if (!charger->charger_connected) { + + /* Last cycle would have stopped at the extreme top of battery-icon + * Need to show the correct level corresponding to capacity. + */ + kick_animation(charger->batt_anim); request_suspend(false); if (charger->next_pwr_check == -1) { charger->next_pwr_check = now + UNPLUGGED_SHUTDOWN_TIME; @@ -705,4 +721,5 @@ void healthd_mode_charger_init(struct healthd_config* config) charger->next_key_check = -1; charger->next_pwr_check = -1; healthd_config = config; + charger->boot_min_cap = config->boot_min_cap; } diff --git a/include/system/audio.h b/include/system/audio.h index 181a171..17bf260 100644 --- a/include/system/audio.h +++ b/include/system/audio.h @@ -194,7 +194,7 @@ typedef enum { AUDIO_FORMAT_PCM_SUB_16_BIT = 0x1, /* DO NOT CHANGE - PCM signed 16 bits */ AUDIO_FORMAT_PCM_SUB_8_BIT = 0x2, /* DO NOT CHANGE - PCM unsigned 8 bits */ AUDIO_FORMAT_PCM_SUB_32_BIT = 0x3, /* PCM signed .31 fixed point */ - AUDIO_FORMAT_PCM_SUB_8_24_BIT = 0x4, /* PCM signed 7.24 fixed point */ + AUDIO_FORMAT_PCM_SUB_8_24_BIT = 0x4, /* PCM signed 8.23 fixed point */ AUDIO_FORMAT_PCM_SUB_FLOAT = 0x5, /* PCM single-precision floating point */ AUDIO_FORMAT_PCM_SUB_24_BIT_PACKED = 0x6, /* PCM signed .23 fixed point packed in 3 bytes */ } audio_format_pcm_sub_fmt_t; @@ -872,6 +872,8 @@ typedef enum { typedef int audio_port_handle_t; #define AUDIO_PORT_HANDLE_NONE 0 +/* the maximum length for the human-readable device name. i.e. "Alesis iO4"*/ +#define AUDIO_PORT_MAX_NAME_LEN 128 /* maximum audio device address length */ #define AUDIO_DEVICE_MAX_ADDRESS_LEN 32 @@ -966,11 +968,11 @@ struct audio_port_session_ext { audio_session_t session; /* audio session */ }; - struct audio_port { audio_port_handle_t id; /* port unique ID */ audio_port_role_t role; /* sink or source */ audio_port_type_t type; /* device, mix ... */ + char name[AUDIO_PORT_MAX_NAME_LEN]; unsigned int num_sample_rates; /* number of sampling rates in following array */ unsigned int sample_rates[AUDIO_PORT_MAX_SAMPLING_RATES]; unsigned int num_channel_masks; /* number of channel masks in following array */ diff --git a/include/system/camera.h b/include/system/camera.h index 7a4dd53..09c915d 100644 --- a/include/system/camera.h +++ b/include/system/camera.h @@ -194,7 +194,12 @@ enum { /** The facing of the camera is opposite to that of the screen. */ CAMERA_FACING_BACK = 0, /** The facing of the camera is the same as that of the screen. */ - CAMERA_FACING_FRONT = 1 + CAMERA_FACING_FRONT = 1, + /** + * The facing of the camera is not fixed relative to the screen. + * The cameras with this facing are external cameras, e.g. USB cameras. + */ + CAMERA_FACING_EXTERNAL = 2 }; enum { diff --git a/include/system/graphics.h b/include/system/graphics.h index c3fca97..c9f5950 100644 --- a/include/system/graphics.h +++ b/include/system/graphics.h @@ -45,9 +45,12 @@ enum { /* * "linear" color pixel formats: * - * The pixel formats below contain sRGB data but are otherwise treated - * as linear formats, i.e.: no special operation is performed when - * reading or writing into a buffer in one of these formats + * When used with ANativeWindow, the dataSpace field describes the color + * space of the buffer. + * + * The color space determines, for example, if the formats are linear or + * gamma-corrected; or whether any special operations are performed when + * reading or writing into a buffer in one of these formats. */ HAL_PIXEL_FORMAT_RGBA_8888 = 1, HAL_PIXEL_FORMAT_RGBX_8888 = 2, @@ -56,28 +59,6 @@ enum { HAL_PIXEL_FORMAT_BGRA_8888 = 5, /* - * sRGB color pixel formats: - * - * The red, green and blue components are stored in sRGB space, and converted - * to linear space when read, using the standard sRGB to linear equation: - * - * Clinear = Csrgb / 12.92 for Csrgb <= 0.04045 - * = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045 - * - * When written the inverse transformation is performed: - * - * Csrgb = 12.92 * Clinear for Clinear <= 0.0031308 - * = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308 - * - * - * The alpha component, if present, is always stored in linear space and - * is left unmodified when read or written. - * - */ - HAL_PIXEL_FORMAT_sRGB_A_8888 = 0xC, - HAL_PIXEL_FORMAT_sRGB_X_8888 = 0xD, - - /* * 0x100 - 0x1FF * * This range is reserved for pixel formats that are specific to the HAL @@ -111,6 +92,8 @@ enum { * cr_offset = y_size * cb_offset = y_size + c_size * + * When used with ANativeWindow, the dataSpace field describes the color + * space of the buffer. */ HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar @@ -135,6 +118,8 @@ enum { * * size = stride * height * + * When used with ANativeWindow, the dataSpace field describes the color + * space of the buffer. */ HAL_PIXEL_FORMAT_Y8 = 0x20203859, @@ -159,6 +144,10 @@ enum { * * size = stride * height * 2 * + * When used with ANativeWindow, the dataSpace field describes the color + * space of the buffer, except that dataSpace field + * HAL_DATASPACE_DEPTH indicates that this buffer contains a depth + * image where each sample is a distance value measured by a depth camera. */ HAL_PIXEL_FORMAT_Y16 = 0x20363159, @@ -167,7 +156,7 @@ enum { * * This format is exposed outside of the camera HAL to applications. * - * RAW_SENSOR is a single-channel, 16-bit, little endian format, typically + * RAW16 is a single-channel, 16-bit, little endian format, typically * representing raw Bayer-pattern images from an image sensor, with minimal * processing. * @@ -193,9 +182,12 @@ enum { * - GRALLOC_USAGE_HW_CAMERA_* * - GRALLOC_USAGE_SW_* * - GRALLOC_USAGE_RENDERSCRIPT + * + * When used with ANativeWindow, the dataSpace should be + * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial + * extra metadata to define. */ HAL_PIXEL_FORMAT_RAW16 = 0x20, - HAL_PIXEL_FORMAT_RAW_SENSOR = 0x20, // TODO(rubenbrunk): Remove RAW_SENSOR. /* * Android RAW10 format: @@ -244,6 +236,10 @@ enum { * - GRALLOC_USAGE_HW_CAMERA_* * - GRALLOC_USAGE_SW_* * - GRALLOC_USAGE_RENDERSCRIPT + * + * When used with ANativeWindow, the dataSpace field should be + * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial + * extra metadata to define. */ HAL_PIXEL_FORMAT_RAW10 = 0x25, @@ -261,6 +257,10 @@ enum { * - GRALLOC_USAGE_HW_CAMERA_* * - GRALLOC_USAGE_SW_* * - GRALLOC_USAGE_RENDERSCRIPT + * + * When used with ANativeWindow, the dataSpace field should be + * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial + * extra metadata to define. */ HAL_PIXEL_FORMAT_RAW_OPAQUE = 0x24, @@ -276,6 +276,16 @@ enum { * * Buffers of this format must have a height of 1, and width equal to their * size in bytes. + * + * When used with ANativeWindow, the mapping of the dataSpace field to + * buffer contents for BLOB is as follows: + * + * dataSpace value | Buffer contents + * -------------------------------+----------------------------------------- + * HAL_DATASPACE_JFIF | An encoded JPEG image + * HAL_DATASPACE_DEPTH | An android_depth_points buffer + * Other | Unsupported + * */ HAL_PIXEL_FORMAT_BLOB = 0x21, @@ -292,6 +302,8 @@ enum { * framework will assume that sampling the texture will always return an * alpha value of 1.0 (i.e. the buffer contains only opaque pixel values). * + * When used with ANativeWindow, the dataSpace field describes the color + * space of the buffer. */ HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22, @@ -311,6 +323,9 @@ enum { * * This format is locked for use by gralloc's (*lock_ycbcr) method, and * locking with the (*lock) method will return an error. + * + * When used with ANativeWindow, the dataSpace field describes the color + * space of the buffer. */ HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, @@ -355,6 +370,42 @@ struct android_ycbcr { }; /** + * Structure used to define depth point clouds for format HAL_PIXEL_FORMAT_BLOB + * with dataSpace value of HAL_DATASPACE_DEPTH. + * When locking a native buffer of the above format and dataSpace value, + * the vaddr pointer can be cast to this structure. + * + * A variable-length list of (x,y,z) 3D points, as floats. + * + * @num_points is the number of points in the list + * + * @xyz_points is the flexible array of floating-point values. + * It contains (num_points) * 3 floats. + * + * For example: + * android_depth_points d = get_depth_buffer(); + * struct { + * float x; float y; float z; + * } firstPoint, lastPoint; + * + * firstPoint.x = d.xyz_points[0]; + * firstPoint.y = d.xyz_points[1]; + * firstPoint.z = d.xyz_points[2]; + * lastPoint.x = d.xyz_points[(d.num_points - 1) * 3 + 0]; + * lastPoint.y = d.xyz_points[(d.num_points - 1) * 3 + 1]; + * lastPoint.z = d.xyz_points[(d.num_points - 1) * 3 + 2]; + */ + +struct android_depth_points { + uint32_t num_points; + + /** reserved for future use, set to 0 by gralloc's (*lock)() */ + uint32_t reserved[8]; + + float xyz_points[]; +}; + +/** * Transformation definitions * * IMPORTANT NOTE: @@ -378,19 +429,33 @@ enum { }; /** - * Colorspace Definitions + * Dataspace Definitions * ====================== * - * Colorspace is the definition of how pixel values should be interpreted. - * It includes primaries (including white point) and the transfer - * characteristic function, which describes both gamma curve and numeric - * range (within the bit depth). + * Dataspace is the definition of how pixel values should be interpreted. + * + * For many formats, this is the colorspace of the image data, which includes + * primaries (including white point) and the transfer characteristic function, + * which describes both gamma curve and numeric range (within the bit depth). + * + * Other dataspaces include depth measurement data from a depth camera. */ -enum { +typedef enum android_dataspace { + /* + * Default-assumption data space, when not explicitly specified. + * + * It is safest to assume the buffer is an image with sRGB primaries and + * encoding ranges, but the consumer and/or the producer of the data may + * simply be using defaults. No automatic gamma transform should be + * expected, except for a possible display gamma transform when drawn to a + * screen. + */ + HAL_DATASPACE_UNKNOWN = 0x0, + /* - * Arbitrary colorspace with manually defined characteristics. - * Colorspace definition must be communicated separately. + * Arbitrary dataspace with manually defined characteristics. Definition + * for colorspaces or other meaning must be communicated separately. * * This is used when specifying primaries, transfer characteristics, * etc. separately. @@ -399,7 +464,57 @@ enum { * where a colorspace can have separately defined primaries, transfer * characteristics, etc. */ - HAL_COLORSPACE_ARBITRARY = 0x1, + HAL_DATASPACE_ARBITRARY = 0x1, + + /* + * RGB Colorspaces + * ----------------- + * + * Primaries are given using (x,y) coordinates in the CIE 1931 definition + * of x and y specified by ISO 11664-1. + * + * Transfer characteristics are the opto-electronic transfer characteristic + * at the source as a function of linear optical intensity (luminance). + */ + + /* + * sRGB linear encoding: + * + * The red, green, and blue components are stored in sRGB space, but + * are linear, not gamma-encoded. + * The RGB primaries and the white point are the same as BT.709. + * + * The values are encoded using the full range ([0,255] for 8-bit) for all + * components. + */ + HAL_DATASPACE_SRGB_LINEAR = 0x200, + + /* + * sRGB gamma encoding: + * + * The red, green and blue components are stored in sRGB space, and + * converted to linear space when read, using the standard sRGB to linear + * equation: + * + * Clinear = Csrgb / 12.92 for Csrgb <= 0.04045 + * = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045 + * + * When written the inverse transformation is performed: + * + * Csrgb = 12.92 * Clinear for Clinear <= 0.0031308 + * = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308 + * + * + * The alpha component, if present, is always stored in linear space and + * is left unmodified when read or written. + * + * The RGB primaries and the white point are the same as BT.709. + * + * The values are encoded using the full range ([0,255] for 8-bit) for all + * components. + * + */ + HAL_DATASPACE_SRGB = 0x201, /* * YCbCr Colorspaces @@ -429,7 +544,7 @@ enum { * red 0.640 0.330 * white (D65) 0.3127 0.3290 */ - HAL_COLORSPACE_JFIF = 0x101, + HAL_DATASPACE_JFIF = 0x101, /* * ITU-R Recommendation 601 (BT.601) - 625-line @@ -456,7 +571,7 @@ enum { * red 0.640 0.330 * white (D65) 0.3127 0.3290 */ - HAL_COLORSPACE_BT601_625 = 0x102, + HAL_DATASPACE_BT601_625 = 0x102, /* * ITU-R Recommendation 601 (BT.601) - 525-line @@ -483,7 +598,7 @@ enum { * red 0.630 0.340 * white (D65) 0.3127 0.3290 */ - HAL_COLORSPACE_BT601_525 = 0x103, + HAL_DATASPACE_BT601_525 = 0x103, /* * ITU-R Recommendation 709 (BT.709) @@ -504,8 +619,20 @@ enum { * red 0.640 0.330 * white (D65) 0.3127 0.3290 */ - HAL_COLORSPACE_BT709 = 0x104, -}; + HAL_DATASPACE_BT709 = 0x104, + + /* + * The buffer contains depth ranging measurements from a depth camera. + * This value is valid with formats: + * HAL_PIXEL_FORMAT_Y16: 16-bit single channel depth image. + * HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as + * a variable-length float (x,y,z) coordinate point list. + * The point cloud will be represented with the android_depth_points + * structure. + */ + HAL_DATASPACE_DEPTH = 0x1000 + +} android_dataspace_t; #ifdef __cplusplus } diff --git a/include/system/window.h b/include/system/window.h index bf93b79..af0418b 100644 --- a/include/system/window.h +++ b/include/system/window.h @@ -262,6 +262,12 @@ enum { * the aspect ratio of the buffers produced. */ NATIVE_WINDOW_STICKY_TRANSFORM = 11, + + /** + * The default data space for the buffers as set by the consumer. + * The values are defined in graphics.h. + */ + NATIVE_WINDOW_DEFAULT_DATASPACE = 12 }; /* Valid operations for the (*perform)() hook. @@ -294,6 +300,7 @@ enum { NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */ NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */ NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18, + NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19 }; /* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ @@ -498,6 +505,7 @@ struct ANativeWindow * NATIVE_WINDOW_SET_BUFFERS_GEOMETRY (deprecated) * NATIVE_WINDOW_SET_BUFFERS_TRANSFORM * NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP + * NATIVE_WINDOW_SET_BUFFERS_DATASPACE * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS * NATIVE_WINDOW_SET_BUFFERS_FORMAT * NATIVE_WINDOW_SET_SCALING_MODE (private) @@ -799,6 +807,26 @@ static inline int native_window_set_buffers_format( } /* + * native_window_set_buffers_data_space(..., int dataSpace) + * All buffers queued after this call will be associated with the dataSpace + * parameter specified. + * + * dataSpace specifies additional information about the buffer that's dependent + * on the buffer format and the endpoints. For example, it can be used to convey + * the color space of the image data in the buffer, or it can be used to + * indicate that the buffers contain depth measurement data instead of color + * images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been + * overridden by the consumer. + */ +static inline int native_window_set_buffers_data_space( + struct ANativeWindow* window, + android_dataspace_t dataSpace) +{ + return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE, + dataSpace); +} + +/* * native_window_set_buffers_transform(..., int transform) * All buffers queued after this call will be displayed transformed according * to the transform parameter specified. diff --git a/init/init.cpp b/init/init.cpp index 41ceb0a..ddd6223 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -31,6 +31,9 @@ #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> +#include <dirent.h> + +#include <memory> #include <selinux/selinux.h> #include <selinux/label.h> @@ -45,6 +48,8 @@ #include <cutils/fs.h> #include <private/android_filesystem_config.h> #include <termios.h> +#include <utils/file.h> +#include <utils/stringprintf.h> #include "devices.h" #include "init.h" @@ -65,8 +70,6 @@ static int property_triggers_enabled = 0; static char console[32]; static char bootmode[32]; -static char hardware[32]; -static unsigned revision = 0; static char qemu[32]; static struct action *cur_action = NULL; @@ -764,6 +767,8 @@ static void export_kernel_boot_props(void) { "ro.boot.mode", "ro.bootmode", "unknown", }, { "ro.boot.baseband", "ro.baseband", "unknown", }, { "ro.boot.bootloader", "ro.bootloader", "unknown", }, + { "ro.boot.hardware", "ro.hardware", "unknown", }, + { "ro.boot.revision", "ro.revision", "0", }, }; for (i = 0; i < ARRAY_SIZE(prop_map); i++) { @@ -782,16 +787,6 @@ static void export_kernel_boot_props(void) property_get("ro.bootmode", tmp); strlcpy(bootmode, tmp, sizeof(bootmode)); - /* if this was given on kernel command line, override what we read - * before (e.g. from /proc/cpuinfo), if anything */ - ret = property_get("ro.boot.hardware", tmp); - if (ret) - strlcpy(hardware, tmp, sizeof(hardware)); - property_set("ro.hardware", hardware); - - snprintf(tmp, PROP_VALUE_MAX, "%d", revision); - property_set("ro.revision", tmp); - /* TODO: these are obsolete. We should delete them */ if (!strcmp(bootmode,"factory")) property_set("ro.factorytest", "1"); @@ -801,6 +796,40 @@ static void export_kernel_boot_props(void) property_set("ro.factorytest", "0"); } +static void process_kernel_dt(void) +{ + static const char android_dir[] = "/proc/device-tree/firmware/android"; + + std::string file_name = android::StringPrintf("%s/compatible", android_dir); + + std::string dt_file; + android::ReadFileToString(file_name, &dt_file); + if (!dt_file.compare("android,firmware")) { + ERROR("firmware/android is not compatible with 'android,firmware'\n"); + return; + } + + std::unique_ptr<DIR, int(*)(DIR*)>dir(opendir(android_dir), closedir); + if (!dir) + return; + + struct dirent *dp; + while ((dp = readdir(dir.get())) != NULL) { + if (dp->d_type != DT_REG || !strcmp(dp->d_name, "compatible")) + continue; + + file_name = android::StringPrintf("%s/%s", android_dir, dp->d_name); + + android::ReadFileToString(file_name, &dt_file); + std::replace(dt_file.begin(), dt_file.end(), ',', '.'); + + std::string property_name = android::StringPrintf("ro.boot.%s", dp->d_name); + if (property_set(property_name.c_str(), dt_file.c_str())) { + ERROR("Could not set property %s to value %s", property_name.c_str(), dt_file.c_str()); + } + } +} + static void process_kernel_cmdline(void) { /* don't expose the raw commandline to nonpriv processes */ @@ -813,11 +842,6 @@ static void process_kernel_cmdline(void) import_kernel_cmdline(0, import_kernel_nv); if (qemu[0]) import_kernel_cmdline(1, import_kernel_nv); - - /* now propogate the info given on command line to internal variables - * used by init as well as the current required properties - */ - export_kernel_boot_props(); } static int property_service_init_action(int nargs, char **args) @@ -1015,10 +1039,17 @@ int main(int argc, char **argv) klog_init(); property_init(); - get_hardware_name(hardware, &revision); - + process_kernel_dt(); + /* in case one is passing arguments both on the command line and in DT + * Properties set in DT always have priority over the command-line ones + */ process_kernel_cmdline(); + /* now propogate the kernel variables to internal variables + * used by init as well as the current required properties + */ + export_kernel_boot_props(); + union selinux_callback cb; cb.func_log = log_callback; selinux_set_callback(SELINUX_CB_LOG, cb); diff --git a/init/ueventd.cpp b/init/ueventd.cpp index d56b91a..5af6e3d 100644 --- a/init/ueventd.cpp +++ b/init/ueventd.cpp @@ -30,28 +30,13 @@ #include "util.h" #include "devices.h" #include "ueventd_parser.h" - -static char hardware[32]; -static unsigned revision = 0; - -static void import_kernel_nv(char *name, int in_qemu) -{ - if (*name != '\0') { - char *value = strchr(name, '='); - if (value != NULL) { - *value++ = 0; - if (!strcmp(name,"androidboot.hardware")) - { - strlcpy(hardware, value, sizeof(hardware)); - } - } - } -} +#include "property_service.h" int ueventd_main(int argc, char **argv) { struct pollfd ufd; int nr; + char hardware[PROP_VALUE_MAX]; char tmp[32]; /* @@ -83,12 +68,7 @@ int ueventd_main(int argc, char **argv) INFO("starting ueventd\n"); - /* Respect hardware passed in through the kernel cmd line. Here we will look - * for androidboot.hardware param in kernel cmdline, and save its value in - * hardware[]. */ - import_kernel_cmdline(0, import_kernel_nv); - - get_hardware_name(hardware, &revision); + property_get("ro.hardware", hardware); ueventd_parse_config_file("/ueventd.rc"); diff --git a/init/util.cpp b/init/util.cpp index 3dddb15..0726053 100644 --- a/init/util.cpp +++ b/init/util.cpp @@ -400,39 +400,6 @@ void open_devnull_stdio(void) exit(1); } -void get_hardware_name(char *hardware, unsigned int *revision) { - // Hardware string was provided on kernel command line. - if (hardware[0]) { - return; - } - - FILE* fp = fopen("/proc/cpuinfo", "re"); - if (fp == NULL) { - return; - } - char buf[1024]; - while (fgets(buf, sizeof(buf), fp) != NULL) { - if (strncmp(buf, "Hardware", 8) == 0) { - const char* hw = strstr(buf, ": "); - if (hw) { - hw += 2; - size_t n = 0; - while (*hw) { - if (!isspace(*hw)) { - hardware[n++] = tolower(*hw); - } - hw++; - if (n == 31) break; - } - hardware[n] = 0; - } - } else if (strncmp(buf, "Revision", 8) == 0) { - sscanf(buf, "Revision : %ux", revision); - } - } - fclose(fp); -} - void import_kernel_cmdline(int in_qemu, void (*import_kernel_nv)(char *name, int in_qemu)) { diff --git a/init/util.h b/init/util.h index 77da3ac..e0b3c69 100644 --- a/init/util.h +++ b/init/util.h @@ -42,7 +42,6 @@ void make_link(const char *oldpath, const char *newpath); void remove_link(const char *oldpath, const char *newpath); int wait_for_file(const char *filename, int timeout); void open_devnull_stdio(void); -void get_hardware_name(char *hardware, unsigned int *revision); void import_kernel_cmdline(int in_qemu, void (*import_kernel_nv)(char *name, int in_qemu)); int make_dir(const char *path, mode_t mode); int restorecon(const char *pathname); diff --git a/libion/ion.c b/libion/ion.c index 4908932..d1984bd 100644 --- a/libion/ion.c +++ b/libion/ion.c @@ -91,6 +91,7 @@ int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot, int flags, off_t offset, unsigned char **ptr, int *map_fd) { int ret; + unsigned char *tmp_ptr; struct ion_fd_data data = { .handle = handle, }; @@ -103,16 +104,17 @@ int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot, ret = ion_ioctl(fd, ION_IOC_MAP, &data); if (ret < 0) return ret; - *map_fd = data.fd; - if (*map_fd < 0) { + if (data.fd < 0) { ALOGE("map ioctl returned negative fd\n"); return -EINVAL; } - *ptr = mmap(NULL, length, prot, flags, *map_fd, offset); - if (*ptr == MAP_FAILED) { + tmp_ptr = mmap(NULL, length, prot, flags, data.fd, offset); + if (tmp_ptr == MAP_FAILED) { ALOGE("mmap failed: %s\n", strerror(errno)); return -errno; } + *map_fd = data.fd; + *ptr = tmp_ptr; return ret; } @@ -129,11 +131,11 @@ int ion_share(int fd, ion_user_handle_t handle, int *share_fd) ret = ion_ioctl(fd, ION_IOC_SHARE, &data); if (ret < 0) return ret; - *share_fd = data.fd; - if (*share_fd < 0) { + if (data.fd < 0) { ALOGE("share ioctl returned negative fd\n"); return -EINVAL; } + *share_fd = data.fd; return ret; } diff --git a/logwrapper/logwrap.c b/logwrapper/logwrap.c index 3a6276e..83576fb 100644 --- a/logwrapper/logwrap.c +++ b/logwrapper/logwrap.c @@ -325,7 +325,7 @@ static int parent(const char *tag, int parent_read, pid_t pid, if (log_target & LOG_KLOG) { snprintf(log_info.klog_fmt, sizeof(log_info.klog_fmt), - "<6>%.*s: %%s", MAX_KLOG_TAG, log_info.btag); + "<6>%.*s: %%s\n", MAX_KLOG_TAG, log_info.btag); } if ((log_target & LOG_FILE) && !file_path) { diff --git a/rootdir/init.rc b/rootdir/init.rc index e3b5db9..e351e91 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -113,6 +113,10 @@ on init # set fwmark on accepted sockets write /proc/sys/net/ipv4/tcp_fwmark_accept 1 + # disable icmp redirects + write /proc/sys/net/ipv4/conf/all/accept_redirects 0 + write /proc/sys/net/ipv6/conf/all/accept_redirects 0 + # Create cgroup mount points for process groups mkdir /dev/cpuctl mount cgroup none /dev/cpuctl cpu |