1/* 2** 3** Copyright 2008, The Android Open Source Project 4** 5** Licensed under the Apache License, Version 2.0 (the "License"); 6** you may not use this file except in compliance with the License. 7** You may obtain a copy of the License at 8** 9** http://www.apache.org/licenses/LICENSE-2.0 10** 11** Unless required by applicable law or agreed to in writing, software 12** distributed under the License is distributed on an "AS IS" BASIS, 13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14** See the License for the specific language governing permissions and 15** limitations under the License. 16*/ 17 18#include <fcntl.h> 19#include <sys/prctl.h> 20#include <sys/wait.h> 21#include <binder/IPCThreadState.h> 22#include <binder/ProcessState.h> 23#include <binder/IServiceManager.h> 24 25#include <string> 26 27#include <android-base/logging.h> 28#include <utils/misc.h> 29 30// from LOCAL_C_INCLUDES 31#include "IcuUtils.h" 32#include "MediaExtractorService.h" 33#include "MediaUtils.h" 34#include "minijail.h" 35 36using namespace android; 37 38static const char kSystemSeccompPolicyPath[] = 39 "/system/etc/seccomp_policy/mediaextractor.policy"; 40static const char kVendorSeccompPolicyPath[] = 41 "/vendor/etc/seccomp_policy/mediaextractor.policy"; 42 43int main(int argc __unused, char** argv) 44{ 45 limitProcessMemory( 46 "ro.media.maxmem", /* property that defines limit */ 47 SIZE_MAX, /* upper limit in bytes */ 48 20 /* upper limit as percentage of physical RAM */); 49 50 signal(SIGPIPE, SIG_IGN); 51 52 //b/62255959: this forces libutis.so to dlopen vendor version of libutils.so 53 //before minijail is on. This is dirty but required since some syscalls such 54 //as pread64 are used by linker but aren't allowed in the minijail. By 55 //calling the function before entering minijail, we can force dlopen. 56 android::report_sysprop_change(); 57 58 SetUpMinijail(kSystemSeccompPolicyPath, kVendorSeccompPolicyPath); 59 60 InitializeIcuOrDie(); 61 62 strcpy(argv[0], "media.extractor"); 63 sp<ProcessState> proc(ProcessState::self()); 64 sp<IServiceManager> sm = defaultServiceManager(); 65 MediaExtractorService::instantiate(); 66 ProcessState::self()->startThreadPool(); 67 IPCThreadState::self()->joinThreadPool(); 68} 69