Peter Beverloo | c0e3f840 | 2017-08-31 16:08:30 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "base/android/build_info.h" |
| 6 | #include "base/android/jni_android.h" |
| 7 | #include "base/android/scoped_java_ref.h" |
| 8 | #include "base/metrics/histogram_macros.h" |
Andrew Grieve | 4a42c22e | 2019-06-24 16:14:29 | [diff] [blame] | 9 | #include "chrome/android/chrome_jni_headers/DecoderService_jni.h" |
Peter Beverloo | c0e3f840 | 2017-08-31 16:08:30 | [diff] [blame] | 10 | #include "sandbox/linux/seccomp-bpf-helpers/seccomp_starter_android.h" |
Scott Violet | 73634e32 | 2018-04-04 21:05:02 | [diff] [blame] | 11 | #include "sandbox/sandbox_buildflags.h" |
Peter Beverloo | c0e3f840 | 2017-08-31 16:08:30 | [diff] [blame] | 12 | |
| 13 | #if BUILDFLAG(USE_SECCOMP_BPF) |
Peter Beverloo | c0e3f840 | 2017-08-31 16:08:30 | [diff] [blame] | 14 | #include "sandbox/linux/seccomp-bpf-helpers/baseline_policy_android.h" |
| 15 | #endif |
| 16 | |
Aiden Benner | c99e905 | 2018-11-30 20:50:50 | [diff] [blame] | 17 | void JNI_DecoderService_InitializePhotoPickerSandbox(JNIEnv* env) { |
Peter Beverloo | c0e3f840 | 2017-08-31 16:08:30 | [diff] [blame] | 18 | auto* info = base::android::BuildInfo::GetInstance(); |
| 19 | sandbox::SeccompStarterAndroid starter(info->sdk_int(), info->device()); |
| 20 | |
| 21 | #if BUILDFLAG(USE_SECCOMP_BPF) |
| 22 | // The policy compiler is only available if USE_SECCOMP_BPF is enabled. |
Jinho Bang | 7fa90e87 | 2018-01-15 18:04:12 | [diff] [blame] | 23 | starter.set_policy(std::make_unique<sandbox::BaselinePolicyAndroid>()); |
Peter Beverloo | c0e3f840 | 2017-08-31 16:08:30 | [diff] [blame] | 24 | #endif |
| 25 | starter.StartSandbox(); |
| 26 | |
| 27 | UMA_HISTOGRAM_ENUMERATION("Android.SeccompStatus.PhotoPickerSandbox", |
| 28 | starter.status(), |
| 29 | sandbox::SeccompSandboxStatus::STATUS_MAX); |
| 30 | } |