Chong Zhang | 8f91543 | 2018-09-05 11:17:17 -0700 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2018, 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 <android-base/logging.h> |
| 19 | |
| 20 | // from LOCAL_C_INCLUDES |
| 21 | #include "minijail.h" |
Chong Zhang | 8f91543 | 2018-09-05 11:17:17 -0700 | [diff] [blame] | 22 | #include <hidl/HidlTransportSupport.h> |
Chong Zhang | ea788f7 | 2018-10-12 14:44:24 -0700 | [diff] [blame] | 23 | |
Chong Zhang | 8f91543 | 2018-09-05 11:17:17 -0700 | [diff] [blame] | 24 | using namespace android; |
| 25 | |
Chong Zhang | 9bda452 | 2019-02-27 13:43:50 -0800 | [diff] [blame] | 26 | // kSystemSeccompPolicyPath points to the policy for the swcodecs themselves and |
| 27 | // is part of the updates. kVendorSeccompPolicyPath points to any additional |
| 28 | // policies that the vendor may need for the device. |
Chong Zhang | 8f91543 | 2018-09-05 11:17:17 -0700 | [diff] [blame] | 29 | static const char kSystemSeccompPolicyPath[] = |
Chong Zhang | 9bda452 | 2019-02-27 13:43:50 -0800 | [diff] [blame] | 30 | "/apex/com.android.media.swcodec/etc/seccomp_policy/mediaswcodec.policy"; |
Chong Zhang | 8f91543 | 2018-09-05 11:17:17 -0700 | [diff] [blame] | 31 | static const char kVendorSeccompPolicyPath[] = |
Ivan Lozano | fffc228 | 2019-01-10 15:18:12 -0800 | [diff] [blame] | 32 | "/vendor/etc/seccomp_policy/mediaswcodec.policy"; |
Chong Zhang | 8f91543 | 2018-09-05 11:17:17 -0700 | [diff] [blame] | 33 | |
Chong Zhang | 9bda452 | 2019-02-27 13:43:50 -0800 | [diff] [blame] | 34 | extern "C" void RegisterCodecServices(); |
| 35 | |
Chong Zhang | 0808b17 | 2019-04-16 17:27:07 -0700 | [diff] [blame^] | 36 | int main(int argc __unused, char** argv) |
Chong Zhang | 8f91543 | 2018-09-05 11:17:17 -0700 | [diff] [blame] | 37 | { |
| 38 | LOG(INFO) << "media swcodec service starting"; |
| 39 | signal(SIGPIPE, SIG_IGN); |
| 40 | SetUpMinijail(kSystemSeccompPolicyPath, kVendorSeccompPolicyPath); |
Chong Zhang | 0808b17 | 2019-04-16 17:27:07 -0700 | [diff] [blame^] | 41 | strcpy(argv[0], "media.swcodec"); |
Chong Zhang | 8f91543 | 2018-09-05 11:17:17 -0700 | [diff] [blame] | 42 | |
Chong Zhang | 8f91543 | 2018-09-05 11:17:17 -0700 | [diff] [blame] | 43 | ::android::hardware::configureRpcThreadpool(64, false); |
| 44 | |
Chong Zhang | 9bda452 | 2019-02-27 13:43:50 -0800 | [diff] [blame] | 45 | RegisterCodecServices(); |
Chong Zhang | 8f91543 | 2018-09-05 11:17:17 -0700 | [diff] [blame] | 46 | |
| 47 | ::android::hardware::joinRpcThreadpool(); |
| 48 | } |