Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 59ee9b8d authored by android-build-team Robot's avatar android-build-team Robot
Browse files

release-request-94878621-f29d-487c-a2aa-213f2be9d20c-for-git_oc-mr1-release-42...

release-request-94878621-f29d-487c-a2aa-213f2be9d20c-for-git_oc-mr1-release-4222039 snap-temp-L91400000086509174

Change-Id: I0f0effbe7ed1346c6a9ea63e180474b94c3a6da2
parents ab8b4a86 4af5a629
Loading
Loading
Loading
Loading
+29 −7
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@

#include "DumpstateInternal.h"

#include <grp.h>
#include <pwd.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
@@ -33,7 +35,6 @@

#include <android-base/file.h>
#include <log/log.h>
#include <private/android_filesystem_config.h>

uint64_t Nanotime() {
    timespec ts;
@@ -43,7 +44,17 @@ uint64_t Nanotime() {

// Switches to non-root user and group.
bool DropRootUser() {
    if (getgid() == AID_SHELL && getuid() == AID_SHELL) {
    struct group* grp = getgrnam("shell");
    gid_t shell_gid = grp != nullptr ? grp->gr_gid : 0;
    struct passwd* pwd = getpwnam("shell");
    uid_t shell_uid = pwd != nullptr ? pwd->pw_uid : 0;

    if (!shell_gid || !shell_uid) {
        MYLOGE("Unable to get AID_SHELL: %s\n", strerror(errno));
        return false;
    }

    if (getgid() == shell_gid && getuid() == shell_uid) {
        MYLOGD("drop_root_user(): already running as Shell\n");
        return true;
    }
@@ -53,17 +64,28 @@ bool DropRootUser() {
        return false;
    }

    gid_t groups[] = {AID_LOG,  AID_SDCARD_R,     AID_SDCARD_RW, AID_MOUNT,
                      AID_INET, AID_NET_BW_STATS, AID_READPROC,  AID_BLUETOOTH};
    if (setgroups(sizeof(groups) / sizeof(groups[0]), groups) != 0) {
    static const std::vector<std::string> group_names{
        "log", "sdcard_r", "sdcard_rw", "mount", "inet", "net_bw_stats", "readproc", "bluetooth"};
    std::vector<gid_t> groups(group_names.size(), 0);
    for (size_t i = 0; i < group_names.size(); ++i) {
        grp = getgrnam(group_names[i].c_str());
        groups[i] = grp != nullptr ? grp->gr_gid : 0;
        if (groups[i] == 0) {
            MYLOGE("Unable to get required gid '%s': %s\n", group_names[i].c_str(),
                   strerror(errno));
            return false;
        }
    }

    if (setgroups(groups.size(), groups.data()) != 0) {
        MYLOGE("Unable to setgroups, aborting: %s\n", strerror(errno));
        return false;
    }
    if (setgid(AID_SHELL) != 0) {
    if (setgid(shell_gid) != 0) {
        MYLOGE("Unable to setgid, aborting: %s\n", strerror(errno));
        return false;
    }
    if (setuid(AID_SHELL) != 0) {
    if (setuid(shell_uid) != 0) {
        MYLOGE("Unable to setuid, aborting: %s\n", strerror(errno));
        return false;
    }
+4 −1
Original line number Diff line number Diff line
cc_library_headers {
    name: "media_plugin_headers",
    vendor_available: true,
    export_include_dirs: ["media_plugin"],
    export_include_dirs: [
        "media_plugin",
        "media_plugin/media/openmax",
    ],
    header_libs: [
        "libstagefright_headers",
        "libcutils_headers",
+12 −4
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */

#include <inttypes.h>
#include <pwd.h>
#include <sys/types.h>

#define LOG_TAG "BufferQueueConsumer"
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
@@ -34,7 +36,6 @@

#include <binder/IPCThreadState.h>
#include <binder/PermissionCache.h>
#include <private/android_filesystem_config.h>

#include <system/window.h>

@@ -747,12 +748,19 @@ status_t BufferQueueConsumer::discardFreeBuffers() {
}

status_t BufferQueueConsumer::dumpState(const String8& prefix, String8* outResult) const {
    struct passwd* pwd = getpwnam("shell");
    uid_t shellUid = pwd ? pwd->pw_uid : 0;
    if (!shellUid) {
        int savedErrno = errno;
        BQ_LOGE("Cannot get AID_SHELL");
        return savedErrno ? -savedErrno : UNKNOWN_ERROR;
    }

    const IPCThreadState* ipc = IPCThreadState::self();
    const pid_t pid = ipc->getCallingPid();
    const uid_t uid = ipc->getCallingUid();
    if ((uid != AID_SHELL)
            && !PermissionCache::checkPermission(String16(
            "android.permission.DUMP"), pid, uid)) {
    if ((uid != shellUid) &&
        !PermissionCache::checkPermission(String16("android.permission.DUMP"), pid, uid)) {
        outResult->appendFormat("Permission Denial: can't dump BufferQueueConsumer "
                "from pid=%d, uid=%d\n", pid, uid);
        android_errorWriteWithInfoLog(0x534e4554, "27046057",
+30 −1
Original line number Diff line number Diff line
@@ -2373,6 +2373,35 @@ bool KeyboardInputMapper::isKeyboardOrGamepadKey(int32_t scanCode) {
        || (scanCode >= BTN_JOYSTICK && scanCode < BTN_DIGI);
}

bool KeyboardInputMapper::isMediaKey(int32_t keyCode) {
    switch (keyCode) {
    case AKEYCODE_MEDIA_PLAY:
    case AKEYCODE_MEDIA_PAUSE:
    case AKEYCODE_MEDIA_PLAY_PAUSE:
    case AKEYCODE_MUTE:
    case AKEYCODE_HEADSETHOOK:
    case AKEYCODE_MEDIA_STOP:
    case AKEYCODE_MEDIA_NEXT:
    case AKEYCODE_MEDIA_PREVIOUS:
    case AKEYCODE_MEDIA_REWIND:
    case AKEYCODE_MEDIA_RECORD:
    case AKEYCODE_MEDIA_FAST_FORWARD:
    case AKEYCODE_MEDIA_SKIP_FORWARD:
    case AKEYCODE_MEDIA_SKIP_BACKWARD:
    case AKEYCODE_MEDIA_STEP_FORWARD:
    case AKEYCODE_MEDIA_STEP_BACKWARD:
    case AKEYCODE_MEDIA_AUDIO_TRACK:
    case AKEYCODE_VOLUME_UP:
    case AKEYCODE_VOLUME_DOWN:
    case AKEYCODE_VOLUME_MUTE:
    case AKEYCODE_TV_AUDIO_DESCRIPTION:
    case AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP:
    case AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN:
        return true;
    }
    return false;
}

void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t scanCode,
        int32_t usageCode) {
    int32_t keyCode;
@@ -2446,7 +2475,7 @@ void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t scanCode,
    // For internal keyboards, the key layout file should specify the policy flags for
    // each wake key individually.
    // TODO: Use the input device configuration to control this behavior more finely.
    if (down && getDevice()->isExternal()) {
    if (down && getDevice()->isExternal() && !isMediaKey(keyCode)) {
        policyFlags |= POLICY_FLAG_WAKE;
    }

+1 −0
Original line number Diff line number Diff line
@@ -1128,6 +1128,7 @@ private:
    void dumpParameters(String8& dump);

    bool isKeyboardOrGamepadKey(int32_t scanCode);
    bool isMediaKey(int32_t keyCode);

    void processKey(nsecs_t when, bool down, int32_t scanCode, int32_t usageCode);