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

Commit a898440a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes If5c3dcc9,Ia8be7b9c

* changes:
  Allow media.codec and media.extractor to specify two policy files.
  Unify media.codec and media.extractor Minijail usage.
parents 86289612 80959a7c
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -15,9 +15,9 @@ include $(BUILD_SHARED_LIBRARY)
# service executable
include $(CLEAR_VARS)
LOCAL_REQUIRED_MODULES_arm := mediacodec-seccomp.policy
LOCAL_SRC_FILES := main_codecservice.cpp minijail/minijail.cpp
LOCAL_SRC_FILES := main_codecservice.cpp
LOCAL_SHARED_LIBRARIES := libmedia libmediacodecservice libbinder libutils \
    liblog libminijail libcutils \
    libbase libavservices_minijail libcutils \
    android.hardware.media.omx@1.0
LOCAL_C_INCLUDES := \
    $(TOP)/frameworks/av/media/libstagefright \
@@ -28,4 +28,3 @@ LOCAL_INIT_RC := mediacodec.rc
include $(BUILD_EXECUTABLE)

include $(call all-makefiles-under, $(LOCAL_PATH))
+13 −10
Original line number Diff line number Diff line
@@ -15,31 +15,34 @@
** limitations under the License.
*/

#define LOG_TAG "mediacodec"
//#define LOG_NDEBUG 0

#include <fcntl.h>
#include <sys/prctl.h>
#include <sys/wait.h>
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <utils/Log.h>
#include <cutils/properties.h>

#include <string>

#include <android-base/logging.h>

// from LOCAL_C_INCLUDES
#include "MediaCodecService.h"
#include "minijail/minijail.h"
#include "minijail.h"

#include <android/hardware/media/omx/1.0/IOmx.h>

using namespace android;

// Must match location in Android.mk.
static const char kSeccompPolicyPath[] = "/system/etc/seccomp_policy/mediacodec-seccomp.policy";

int main(int argc __unused, char** argv)
{
    ALOGI("@@@ mediacodecservice starting");
    LOG(INFO) << "mediacodecservice starting";
    signal(SIGPIPE, SIG_IGN);
    MiniJail();
    SetUpMinijail(kSeccompPolicyPath, std::string());

    strcpy(argv[0], "media.codec");
    sp<ProcessState> proc(ProcessState::self());
@@ -52,11 +55,11 @@ int main(int argc __unused, char** argv)
        using namespace ::android::hardware::media::omx::V1_0;
        sp<IOmx> omx = IOmx::getService(true);
        if (omx == nullptr) {
            ALOGE("Cannot create a Treble IOmx service.");
            LOG(ERROR) << "Cannot create a Treble IOmx service.";
        } else if (omx->registerAsService("default") != OK) {
            ALOGE("Cannot register a Treble IOmx service.");
            LOG(ERROR) << "Cannot register a Treble IOmx service.";
        } else {
            ALOGV("Treble IOmx service created.");
            LOG(VERBOSE) << "Treble IOmx service created.";
        }
    }

+0 −55
Original line number Diff line number Diff line
/*
**
** Copyright 2016, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

#define LOG_TAG "minijail"

#include <unistd.h>

#include <log/log.h>

#include <libminijail.h>

#include "minijail.h"

namespace android {

/* Must match location in Android.mk */
static const char kSeccompFilePath[] = "/system/etc/seccomp_policy/mediacodec-seccomp.policy";

int MiniJail()
{
    /* no seccomp policy for this architecture */
    if (access(kSeccompFilePath, R_OK) == -1) {
        ALOGW("No seccomp filter defined for this architecture.");
        return 0;
    }

    struct minijail *jail = minijail_new();
    if (jail == NULL) {
        ALOGW("Failed to create minijail.");
        return -1;
    }

    minijail_no_new_privs(jail);
    minijail_log_seccomp_filter_failures(jail);
    minijail_use_seccomp_filter(jail);
    minijail_parse_seccomp_filters(jail, kSeccompFilePath);
    minijail_enter(jail);
    minijail_destroy(jail);
    return 0;
}
}
+0 −20
Original line number Diff line number Diff line
/*
**
** Copyright 2016, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

namespace android {
int MiniJail();
}
+3 −2
Original line number Diff line number Diff line
@@ -15,8 +15,9 @@ LOCAL_REQUIRED_MODULES_arm := mediaextractor-seccomp.policy
LOCAL_REQUIRED_MODULES_arm64 := mediaextractor-seccomp.policy
LOCAL_REQUIRED_MODULES_x86 := mediaextractor-seccomp.policy
# TODO add seccomp filter for x86_64.
LOCAL_SRC_FILES := main_extractorservice.cpp minijail/minijail.cpp
LOCAL_SHARED_LIBRARIES := libmedia libmediaextractorservice libbinder libutils liblog libicuuc libminijail
LOCAL_SRC_FILES := main_extractorservice.cpp
LOCAL_SHARED_LIBRARIES := libmedia libmediaextractorservice libbinder libutils \
    liblog libbase libicuuc libavservices_minijail
LOCAL_STATIC_LIBRARIES := libicuandroid_utils
LOCAL_MODULE:= mediaextractor
LOCAL_INIT_RC := mediaextractor.rc
Loading