1 /*
2 * Copyright (C) 2024 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 use alloc::vec::Vec;
18 use android_desktop_security_boot_params::aidl::android::desktop::security::boot_params::IBootParams::IBootParams;
19 use android_desktop_security_boot_params::aidl::android::desktop::security::boot_params::IBootParams::BnBootParams;
20 use binder::{BinderFeatures, Interface, Result as BinderResult, Strong};
21 use boot_params::BootParams;
22 use tipc::TipcError;
23
24 pub struct Server {
25 params: BootParams,
26 }
27
28 impl Interface for Server {}
29
30 impl IBootParams for Server {
getEarlyEntropy(&self) -> BinderResult<Vec<u8>>31 fn getEarlyEntropy(&self) -> BinderResult<Vec<u8>> {
32 Ok(self.params.gsc_boot_params.early_entropy.to_vec())
33 }
34 }
35
36 impl Server {
new() -> Self37 fn new() -> Self {
38 Self { params: BootParams::new() }
39 }
40 }
41
create_boot_params_service() -> Result<Strong<dyn IBootParams>, TipcError>42 pub fn create_boot_params_service() -> Result<Strong<dyn IBootParams>, TipcError> {
43 let srv = Server::new();
44
45 let service = BnBootParams::new_binder(srv, BinderFeatures::default());
46
47 Ok(service)
48 }
49