aboutsummaryrefslogtreecommitdiff
path: root/jni/minijail
diff options
context:
space:
mode:
authorNick Chalko <nchalko@google.com>2017-10-03 10:16:37 -0700
committerNick Chalko <nchalko@google.com>2017-10-04 13:48:13 +0000
commit6ebde20b03db4c0d57f67acaac11832b610b966b (patch)
treed31e2adc1f9cce4f27ca07d30bee921032e33a3c /jni/minijail
parentee027a576ddebaf1ae739219be01b0240b15f80c (diff)
downloadTV-6ebde20b03db4c0d57f67acaac11832b610b966b.tar.gz
Sync to match Live Channels 1.15(ncis)oreo-mr1-dev
aka ub-tv-dev at a73a150bb7d0d1ce867ef980c6ac8411899d40ad Bug: 64021596 Change-Id: I7c544fd15e2c58784f8babc31877ad0dfeebb4c0 (cherry picked from commit 633eb826b8c97731dfc5ef12c7bf78a63734275d)
Diffstat (limited to 'jni/minijail')
-rw-r--r--jni/minijail/Android.mk28
-rw-r--r--jni/minijail/minijail.cpp65
-rw-r--r--jni/minijail/minijail.h44
3 files changed, 137 insertions, 0 deletions
diff --git a/jni/minijail/Android.mk b/jni/minijail/Android.mk
new file mode 100644
index 00000000..940237db
--- /dev/null
+++ b/jni/minijail/Android.mk
@@ -0,0 +1,28 @@
+#
+# Copyright (C) 2017 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+# --------------------------------------------------------------
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libminijail_jni
+LOCAL_SRC_FILES := minijail.cpp
+LOCAL_CXX_STL := none
+LOCAL_STATIC_LIBRARIES := libc++_static libminijail
+LOCAL_LDLIBS := -llog
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/jni/minijail/minijail.cpp b/jni/minijail/minijail.cpp
new file mode 100644
index 00000000..9eebc49b
--- /dev/null
+++ b/jni/minijail/minijail.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#include "minijail.h"
+#include <unistd.h>
+#include <sys/types.h>
+#include <signal.h>
+
+#include <libminijail.h>
+#include <scoped_minijail.h>
+#include <android/log.h>
+
+#ifndef LOG_TAG
+#define LOG_TAG "minijail"
+#endif
+
+#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR , LOG_TAG, __VA_ARGS__)
+
+
+/*
+ * Class: com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService
+ * Method: nativeSetupMinijail
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL
+Java_com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService_nativeSetupMinijail
+(JNIEnv *, jobject, jint policyFd) {
+ ScopedMinijail jail{minijail_new()};
+ if (!jail) {
+ ALOGE("Failed to create minijail");
+ }
+
+ minijail_no_new_privs(jail.get());
+ minijail_log_seccomp_filter_failures(jail.get());
+ minijail_use_seccomp_filter(jail.get());
+ minijail_set_seccomp_filter_tsync(jail.get());
+ // Transfer ownership of |policy_fd|.
+ minijail_parse_seccomp_filters_from_fd(jail.get(), policyFd);
+ minijail_enter(jail.get());
+ close(policyFd);
+}
+
+/*
+ * Class: com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService
+ * Method: nativeTestMinijail
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL
+Java_com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService_nativeTestMinijail
+(JNIEnv *, jobject) {
+ kill(getpid(), SIGUSR1);
+} \ No newline at end of file
diff --git a/jni/minijail/minijail.h b/jni/minijail/minijail.h
new file mode 100644
index 00000000..cdf272c7
--- /dev/null
+++ b/jni/minijail/minijail.h
@@ -0,0 +1,44 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService */
+
+#ifndef _Included_com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService
+#define _Included_com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService_DEBUG
+#define com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService_DEBUG 0L
+#undef com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService_MINIJAIL_SETUP_WAIT_TIMEOUT_MS
+#define com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService_MINIJAIL_SETUP_WAIT_TIMEOUT_MS 5000LL
+/*
+ * Class: com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService
+ * Method: nativeSetupMinijail
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService_nativeSetupMinijail
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService
+ * Method: nativeTestMinijail
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService_nativeTestMinijail
+ (JNIEnv *, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+/* Header for class com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService_FfmpegDecoder */
+
+#ifndef _Included_com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService_FfmpegDecoder
+#define _Included_com_android_tv_tuner_exoplayer_ffmpeg_FfmpegDecoderService_FfmpegDecoder
+#ifdef __cplusplus
+extern "C" {
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif \ No newline at end of file