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" |
| 9 | #include "jni/DecoderService_jni.h" |
| 10 | #include "sandbox/linux/seccomp-bpf-helpers/seccomp_starter_android.h" |
| 11 | #include "sandbox/sandbox_features.h" |
| 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 | |
Daniel Bratell | 7aacf95 | 2017-11-21 17:51:25 | [diff] [blame] | 17 | void JNI_DecoderService_InitializePhotoPickerSandbox( |
Peter Beverloo | c0e3f840 | 2017-08-31 16:08:30 | [diff] [blame] | 18 | JNIEnv* env, |
| 19 | const base::android::JavaParamRef<jclass>& jcaller) { |
| 20 | auto* info = base::android::BuildInfo::GetInstance(); |
| 21 | sandbox::SeccompStarterAndroid starter(info->sdk_int(), info->device()); |
| 22 | |
| 23 | #if BUILDFLAG(USE_SECCOMP_BPF) |
| 24 | // The policy compiler is only available if USE_SECCOMP_BPF is enabled. |
Jinho Bang | 7fa90e87 | 2018-01-15 18:04:12 | [diff] [blame^] | 25 | starter.set_policy(std::make_unique<sandbox::BaselinePolicyAndroid>()); |
Peter Beverloo | c0e3f840 | 2017-08-31 16:08:30 | [diff] [blame] | 26 | #endif |
| 27 | starter.StartSandbox(); |
| 28 | |
| 29 | UMA_HISTOGRAM_ENUMERATION("Android.SeccompStatus.PhotoPickerSandbox", |
| 30 | starter.status(), |
| 31 | sandbox::SeccompSandboxStatus::STATUS_MAX); |
| 32 | } |