Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
raymanfx committed May 30, 2014
2 parents 3892f6d + e29da25 commit 25caf2d
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 23 deletions.
56 changes: 36 additions & 20 deletions cmds/installd/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,20 @@ int install(const char *pkgname, uid_t uid, gid_t gid, const char *seinfo)
}
}

if (symlink(applibdir, libsymlink) < 0) {
ALOGE("couldn't symlink directory '%s' -> '%s': %s\n", libsymlink, applibdir,
strerror(errno));
unlink(pkgdir);
return -1;
}

if (selinux_android_setfilecon(pkgdir, pkgname, seinfo, uid) < 0) {
ALOGE("cannot setfilecon dir '%s': %s\n", pkgdir, strerror(errno));
unlink(libsymlink);
unlink(pkgdir);
return -errno;
}

if (symlink(applibdir, libsymlink) < 0) {
ALOGE("couldn't symlink directory '%s' -> '%s': %s\n", libsymlink, applibdir,
strerror(errno));
unlink(pkgdir);
return -1;
}

if (chown(pkgdir, uid, gid) < 0) {
ALOGE("cannot chown dir '%s': %s\n", pkgdir, strerror(errno));
unlink(libsymlink);
Expand Down Expand Up @@ -240,20 +240,20 @@ int make_user_data(const char *pkgname, uid_t uid, userid_t userid, const char*
}
}

if (symlink(applibdir, libsymlink) < 0) {
ALOGE("couldn't symlink directory for non-primary '%s' -> '%s': %s\n", libsymlink,
applibdir, strerror(errno));
unlink(pkgdir);
return -1;
}

if (selinux_android_setfilecon(pkgdir, pkgname, seinfo, uid) < 0) {
ALOGE("cannot setfilecon dir '%s': %s\n", pkgdir, strerror(errno));
unlink(libsymlink);
unlink(pkgdir);
return -errno;
}

if (symlink(applibdir, libsymlink) < 0) {
ALOGE("couldn't symlink directory for non-primary '%s' -> '%s': %s\n", libsymlink,
applibdir, strerror(errno));
unlink(pkgdir);
return -1;
}

if (chown(pkgdir, uid, uid) < 0) {
ALOGE("cannot chown dir '%s': %s\n", pkgdir, strerror(errno));
unlink(libsymlink);
Expand Down Expand Up @@ -1268,7 +1268,8 @@ int idmap(const char *target_apk, const char *overlay_apk, uid_t uid,
return -1;
}

static void run_aapt(const char *source_apk, const char *internal_path, int restable_fd, int resapk_fd, int pkgId)
static void run_aapt(const char *source_apk, const char *internal_path, int restable_fd,
int resapk_fd, int pkgId, const char *common_res_path)
{
static const char *AAPT_BIN = "/system/bin/aapt";
static const char *MANIFEST = "/data/app/AndroidManifest.xml";
Expand All @@ -1282,23 +1283,38 @@ static void run_aapt(const char *source_apk, const char *internal_path, int rest
snprintf(restable_str, sizeof(restable_str), "%d", restable_fd);
snprintf(resapk_str, sizeof(resapk_str), "%d", resapk_fd);
snprintf(pkgId_str, sizeof(pkgId_str), "%d", pkgId);
bool hasCommonResources = (common_res_path != NULL && common_res_path[0] != '\0');

execl(AAPT_BIN, AAPT_BIN, "package",
if (hasCommonResources) {
execl(AAPT_BIN, AAPT_BIN, "package",
"-M", MANIFEST,
"-S", source_apk,
"-X", internal_path,
"-R", restable_str,
"-I", FRAMEWORK_RES,
"-I", common_res_path,
"-r", resapk_str,
"-x", pkgId_str,
(char*)NULL);
} else {
execl(AAPT_BIN, AAPT_BIN, "package",
"-M", MANIFEST,
"-S", source_apk,
"-X", internal_path,
"-R", restable_str,
"-I", FRAMEWORK_RES,
"-r", resapk_str,
"-x", pkgId_str,
(char*)NULL);
}
ALOGE("execl(%s) failed: %s\n", AAPT_BIN, strerror(errno));
}

int aapt(const char *source_apk, const char *internal_path, const char *out_restable, uid_t uid, int pkgId)
int aapt(const char *source_apk, const char *internal_path, const char *out_restable, uid_t uid,
int pkgId, const char *common_res_path)
{
ALOGD("aapt source_apk=%s internal_path=%s out_restable=%s uid=%d, pkgId=%d\n",
source_apk, internal_path, out_restable, uid, pkgId);
ALOGD("aapt source_apk=%s internal_path=%s out_restable=%s uid=%d, pkgId=%d, common_res_path=%s",
source_apk, internal_path, out_restable, uid, pkgId, common_res_path);
static const int PARENT_READ_PIPE = 0;
static const int CHILD_WRITE_PIPE = 1;

Expand Down Expand Up @@ -1374,7 +1390,7 @@ int aapt(const char *source_apk, const char *internal_path, const char *out_rest
}
}

run_aapt(source_apk, internal_path, restable_fd, resapk_fd, pkgId);
run_aapt(source_apk, internal_path, restable_fd, resapk_fd, pkgId, common_res_path);

if (pipefd[CHILD_WRITE_PIPE] > 0) {
close(pipefd[CHILD_WRITE_PIPE]);
Expand Down
16 changes: 14 additions & 2 deletions cmds/installd/installd.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,23 @@ static int do_restorecon_data(char **arg __attribute__((unused)),
}

static int do_idmap(char **arg, char reply[REPLY_MAX])
{
return idmap(arg[0], arg[1], atoi(arg[2]), atoi(arg[3]), atoi(arg[4]), "");
}

static int do_idmap_with_redirs(char **arg, char reply[REPLY_MAX])
{
return idmap(arg[0], arg[1], atoi(arg[2]), atoi(arg[3]), atoi(arg[4]), arg[5]);
}

static int do_aapt(char **arg, char reply[REPLY_MAX])
{
return aapt(arg[0], arg[1], arg[2], atoi(arg[3]), atoi(arg[4]));
return aapt(arg[0], arg[1], arg[2], atoi(arg[3]), atoi(arg[4]), "");
}

static int do_aapt_with_common(char **arg, char reply[REPLY_MAX])
{
return aapt(arg[0], arg[1], arg[2], atoi(arg[3]), atoi(arg[4]), arg[5]);
}

struct cmdinfo {
Expand All @@ -162,8 +172,10 @@ struct cmdinfo cmds[] = {
{ "mkuserdata", 4, do_mk_user_data },
{ "rmuser", 1, do_rm_user },
{ "restorecondata", 0, do_restorecon_data },
{ "idmap", 6, do_idmap },
{ "idmap", 5, do_idmap },
{ "idmap_with_redirs", 6, do_idmap_with_redirs },
{ "aapt", 5, do_aapt },
{ "aapt_with_common", 6, do_aapt_with_common },
};

char write_error = 0;
Expand Down
3 changes: 2 additions & 1 deletion cmds/installd/installd.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,6 @@ int linklib(const char* target, const char* source, int userId);
int restorecon_data();
int idmap(const char *target_path, const char *overlay_path, uid_t uid,
uint32_t target_hash, uint32_t overlay_hash, const char *redirections);
int aapt(const char *source_apk, const char *internal_path, const char *out_restable, uid_t uid, int pkgId);
int aapt(const char *source_apk, const char *internal_path, const char *out_restable, uid_t uid,
int pkgId, const char *common_res_path);

80 changes: 80 additions & 0 deletions include/media/openmax/OMX_Audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ typedef enum OMX_AUDIO_CODINGTYPE {
#endif // DOLBY_UDC
OMX_AUDIO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_AUDIO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_AUDIO_CodingMP2, /**< Any variant of MP2 encoded data */
OMX_AUDIO_CodingAC3, /**< Any variant of AC3 encoded data */
OMX_AUDIO_CodingAPE, /**< Any variant of APE encoded data */
OMX_AUDIO_CodingDTS, /**< Any variant of DTS encoded data */
OMX_AUDIO_CodingFFMPEG, /**< Any variant of FFMPEG encoded data */
OMX_AUDIO_CodingMax = 0x7FFFFFFF
} OMX_AUDIO_CODINGTYPE;

Expand Down Expand Up @@ -376,6 +381,81 @@ typedef struct OMX_AUDIO_PARAM_FLACTYPE {
} OMX_AUDIO_PARAM_FLACTYPE;


/** MP2 params */
typedef struct OMX_AUDIO_PARAM_MP2TYPE {
OMX_U32 nSize; /**< size of the structure in bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
OMX_U32 nPortIndex; /**< port that this structure applies to */
OMX_U32 nChannels; /**< Number of channels */
OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable
rate or unknown bit rates */
OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for
variable or unknown sampling rate. */
OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */
OMX_AUDIO_MP3STREAMFORMATTYPE eFormat; /**< MP3 stream format */
} OMX_AUDIO_PARAM_MP2TYPE;


/** AC3 params */
typedef struct OMX_AUDIO_PARAM_AC3TYPE {
OMX_U32 nSize; /**< size of the structure in bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
OMX_U32 nPortIndex; /**< port that this structure applies to */
OMX_U32 nChannels; /**< Number of channels */
OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable
rate or unknown bit rates */
OMX_U32 nSamplingRate; /**< Sampling rate of the source data. Use 0 for
variable or unknown sampling rate. */
OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */
} OMX_AUDIO_PARAM_AC3TYPE;


/** APE params */
typedef struct OMX_AUDIO_PARAM_APETYPE {
OMX_U32 nSize; /**< size of the structure in bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
OMX_U32 nPortIndex; /**< port that this structure applies to */
OMX_U32 nChannels; /**< Number of channels */
OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable
rate or unknown bit rates */
OMX_U32 nSamplingRate; /**< Sampling rate of the source data. Use 0 for
variable or unknown sampling rate. */
OMX_U32 nBitsPerSample; /**< Number of bits in each sample */
OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */
} OMX_AUDIO_PARAM_APETYPE;


/** DTS params */
typedef struct OMX_AUDIO_PARAM_DTSTYPE {
OMX_U32 nSize; /**< size of the structure in bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
OMX_U32 nPortIndex; /**< port that this structure applies to */
OMX_U32 nChannels; /**< Number of channels */
OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable
rate or unknown bit rates */
OMX_U32 nSamplingRate; /**< Sampling rate of the source data. Use 0 for
variable or unknown sampling rate. */
OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */
} OMX_AUDIO_PARAM_DTSTYPE;

/** FFMPEG Audio params */
typedef struct OMX_AUDIO_PARAM_FFMPEGTYPE {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_U32 nPortIndex;

OMX_S32 eCodecId; /**< enum AVCodecID */
OMX_U32 nChannels; /**< Number of channels */
OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable
rate or unknown bit rates */
OMX_U32 nBitsPerSample; /**< Number of bits in each sample */
OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for
variable or unknown sampling rate. */
OMX_U32 nBlockAlign; /**< is the block alignment, or block size, in bytes of the audio codec */

OMX_S32 eSampleFormat; /**< enum AVSampleFormat */
} OMX_AUDIO_PARAM_FFMPEGTYPE;

/** WMA Version */
typedef enum OMX_AUDIO_WMAFORMATTYPE {
OMX_AUDIO_WMAFormatUnused = 0, /**< format unused or unknown */
Expand Down
6 changes: 6 additions & 0 deletions include/media/openmax/OMX_Index.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ typedef enum OMX_INDEXTYPE {
to 0x7FFFFFFE. This range is not broken out by vendor, so
private indexes are not guaranteed unique and therefore should
only be sent to the appropriate component. */
OMX_IndexParamAudioMp2, /**< reference: OMX_AUDIO_PARAM_MP2TYPE */
OMX_IndexParamAudioAc3, /**< reference: OMX_AUDIO_PARAM_AC3TYPE */
OMX_IndexParamAudioApe, /**< reference: OMX_AUDIO_PARAM_APETYPE */
OMX_IndexParamAudioDts, /**< reference: OMX_AUDIO_PARAM_DTSTYPE */
OMX_IndexParamVideoFFmpeg, /**< reference: OMX_VIDEO_PARAM_FFMPEGTYPE */
OMX_IndexParamAudioFFmpeg, /**< reference: OMX_AUDIO_PARAM_FFMPEGTYPE */

OMX_IndexMax = 0x7FFFFFFF

Expand Down
18 changes: 18 additions & 0 deletions include/media/openmax/OMX_Video.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ typedef enum OMX_VIDEO_CODINGTYPE {
OMX_VIDEO_CodingVP9, /**< Google VP9 */
OMX_VIDEO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_VIDEO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_VIDEO_CodingVC1, /**< VC1 */
OMX_VIDEO_CodingFLV1, /**< Sorenson's H.263 */
OMX_VIDEO_CodingDIVX, /**< DIVX */
OMX_VIDEO_CodingHEVC, /**< HEVC */
OMX_VIDEO_CodingFFMPEG, /**< FFMPEG */
OMX_VIDEO_CodingMax = 0x7FFFFFFF
} OMX_VIDEO_CODINGTYPE;

Expand Down Expand Up @@ -1068,6 +1073,19 @@ typedef struct OMX_VIDEO_CONFIG_NALSIZE {
OMX_U32 nNaluBytes;
} OMX_VIDEO_CONFIG_NALSIZE;

/**
* FFMPEG Video Params
*/
typedef struct OMX_VIDEO_PARAM_FFMPEGTYPE {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_U32 nPortIndex;

OMX_S32 eCodecId; /**< enum AVCodecID */
OMX_U32 nWidth;
OMX_U32 nHeight;
} OMX_VIDEO_PARAM_FFMPEGTYPE;

/** @} */

#ifdef __cplusplus
Expand Down
2 changes: 2 additions & 0 deletions libs/gui/GLConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ status_t GLConsumer::updateAndReleaseLocked(const BufferQueue::BufferItem& item)
if (image == EGL_NO_IMAGE_KHR) {
ST_LOGW("updateAndRelease: unable to createImage on display=%p slot=%d",
mEglDisplay, buf);
releaseBufferLocked(buf, mSlots[buf].mGraphicBuffer,
mEglDisplay, EGL_NO_SYNC_KHR);
return UNKNOWN_ERROR;
}
mEglSlots[buf].mEglImage = image;
Expand Down

0 comments on commit 25caf2d

Please sign in to comment.