blob: 5c26961ef4302611d98c7a751d33148d92ba2691 [file] [log] [blame]
Peter Beverlooc0e3f8402017-08-31 16:08:301// 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 Grieve4a42c22e2019-06-24 16:14:299#include "chrome/android/chrome_jni_headers/DecoderService_jni.h"
Peter Beverlooc0e3f8402017-08-31 16:08:3010#include "sandbox/linux/seccomp-bpf-helpers/seccomp_starter_android.h"
Scott Violet73634e322018-04-04 21:05:0211#include "sandbox/sandbox_buildflags.h"
Peter Beverlooc0e3f8402017-08-31 16:08:3012
13#if BUILDFLAG(USE_SECCOMP_BPF)
Peter Beverlooc0e3f8402017-08-31 16:08:3014#include "sandbox/linux/seccomp-bpf-helpers/baseline_policy_android.h"
15#endif
16
Aiden Bennerc99e9052018-11-30 20:50:5017void JNI_DecoderService_InitializePhotoPickerSandbox(JNIEnv* env) {
Peter Beverlooc0e3f8402017-08-31 16:08:3018 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 Bang7fa90e872018-01-15 18:04:1223 starter.set_policy(std::make_unique<sandbox::BaselinePolicyAndroid>());
Peter Beverlooc0e3f8402017-08-31 16:08:3024#endif
25 starter.StartSandbox();
26
27 UMA_HISTOGRAM_ENUMERATION("Android.SeccompStatus.PhotoPickerSandbox",
28 starter.status(),
29 sandbox::SeccompSandboxStatus::STATUS_MAX);
30}