| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 1 | // Copyright 2021, The Android Open Source Project | 
|  | 2 | // | 
|  | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 4 | // you may not use this file except in compliance with the License. | 
|  | 5 | // You may obtain a copy of the License at | 
|  | 6 | // | 
|  | 7 | //     http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 8 | // | 
|  | 9 | // Unless required by applicable law or agreed to in writing, software | 
|  | 10 | // distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 12 | // See the License for the specific language governing permissions and | 
|  | 13 | // limitations under the License. | 
|  | 14 |  | 
| Janis Danisevskis | 34a0cf2 | 2021-03-08 09:19:03 -0800 | [diff] [blame] | 15 | //! This module implements IKeystoreMaintenance AIDL interface. | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 16 |  | 
| Janis Danisevskis | cdcf4e5 | 2021-04-14 15:44:36 -0700 | [diff] [blame] | 17 | use crate::database::{KeyEntryLoadBits, KeyType, MonotonicRawTime}; | 
| Satya Tangirala | 5b9e5b1 | 2021-03-09 12:54:21 -0800 | [diff] [blame] | 18 | use crate::error::map_km_error; | 
| Janis Danisevskis | cdcf4e5 | 2021-04-14 15:44:36 -0700 | [diff] [blame] | 19 | use crate::error::map_or_log_err; | 
|  | 20 | use crate::error::Error; | 
| Satya Tangirala | 5b9e5b1 | 2021-03-09 12:54:21 -0800 | [diff] [blame] | 21 | use crate::globals::get_keymint_device; | 
| Hasini Gunasinghe | 3ed5da7 | 2021-02-04 15:18:54 +0000 | [diff] [blame] | 22 | use crate::globals::{DB, LEGACY_MIGRATOR, SUPER_KEY}; | 
| Janis Danisevskis | cdcf4e5 | 2021-04-14 15:44:36 -0700 | [diff] [blame] | 23 | use crate::permission::{KeyPerm, KeystorePerm}; | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 24 | use crate::super_key::UserState; | 
| Janis Danisevskis | 2ee014b | 2021-05-05 14:29:08 -0700 | [diff] [blame] | 25 | use crate::utils::{check_key_permission, check_keystore_permission, watchdog as wd}; | 
| Satya Tangirala | 5b9e5b1 | 2021-03-09 12:54:21 -0800 | [diff] [blame] | 26 | use android_hardware_security_keymint::aidl::android::hardware::security::keymint::SecurityLevel::SecurityLevel; | 
| Hasini Gunasinghe | 9ee1841 | 2021-03-11 20:12:44 +0000 | [diff] [blame] | 27 | use android_security_maintenance::aidl::android::security::maintenance::{ | 
|  | 28 | IKeystoreMaintenance::{BnKeystoreMaintenance, IKeystoreMaintenance}, | 
|  | 29 | UserState::UserState as AidlUserState, | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 30 | }; | 
| Andrew Walbran | de45c8b | 2021-04-13 14:42:38 +0000 | [diff] [blame] | 31 | use android_security_maintenance::binder::{ | 
|  | 32 | BinderFeatures, Interface, Result as BinderResult, Strong, ThreadState, | 
|  | 33 | }; | 
| Janis Danisevskis | 5898d15 | 2021-06-15 08:23:46 -0700 | [diff] [blame] | 34 | use android_system_keystore2::aidl::android::system::keystore2::KeyDescriptor::KeyDescriptor; | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 35 | use android_system_keystore2::aidl::android::system::keystore2::ResponseCode::ResponseCode; | 
|  | 36 | use anyhow::{Context, Result}; | 
| Paul Crowley | f61fee7 | 2021-03-17 14:38:44 -0700 | [diff] [blame] | 37 | use keystore2_crypto::Password; | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 38 |  | 
| Janis Danisevskis | 5898d15 | 2021-06-15 08:23:46 -0700 | [diff] [blame] | 39 | /// Reexport Domain for the benefit of DeleteListener | 
|  | 40 | pub use android_system_keystore2::aidl::android::system::keystore2::Domain::Domain; | 
|  | 41 |  | 
|  | 42 | /// The Maintenance module takes a delete listener argument which observes user and namespace | 
|  | 43 | /// deletion events. | 
|  | 44 | pub trait DeleteListener { | 
|  | 45 | /// Called by the maintenance module when an app/namespace is deleted. | 
|  | 46 | fn delete_namespace(&self, domain: Domain, namespace: i64) -> Result<()>; | 
|  | 47 | /// Called by the maintenance module when a user is deleted. | 
|  | 48 | fn delete_user(&self, user_id: u32) -> Result<()>; | 
|  | 49 | } | 
|  | 50 |  | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 51 | /// This struct is defined to implement the aforementioned AIDL interface. | 
| Janis Danisevskis | 5898d15 | 2021-06-15 08:23:46 -0700 | [diff] [blame] | 52 | pub struct Maintenance { | 
|  | 53 | delete_listener: Box<dyn DeleteListener + Send + Sync + 'static>, | 
|  | 54 | } | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 55 |  | 
| Janis Danisevskis | 34a0cf2 | 2021-03-08 09:19:03 -0800 | [diff] [blame] | 56 | impl Maintenance { | 
| Janis Danisevskis | 5898d15 | 2021-06-15 08:23:46 -0700 | [diff] [blame] | 57 | /// Create a new instance of Keystore Maintenance service. | 
|  | 58 | pub fn new_native_binder( | 
|  | 59 | delete_listener: Box<dyn DeleteListener + Send + Sync + 'static>, | 
|  | 60 | ) -> Result<Strong<dyn IKeystoreMaintenance>> { | 
| Andrew Walbran | de45c8b | 2021-04-13 14:42:38 +0000 | [diff] [blame] | 61 | Ok(BnKeystoreMaintenance::new_binder( | 
| Janis Danisevskis | 5898d15 | 2021-06-15 08:23:46 -0700 | [diff] [blame] | 62 | Self { delete_listener }, | 
| Andrew Walbran | de45c8b | 2021-04-13 14:42:38 +0000 | [diff] [blame] | 63 | BinderFeatures { set_requesting_sid: true, ..BinderFeatures::default() }, | 
|  | 64 | )) | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 65 | } | 
|  | 66 |  | 
| Paul Crowley | f61fee7 | 2021-03-17 14:38:44 -0700 | [diff] [blame] | 67 | fn on_user_password_changed(user_id: i32, password: Option<Password>) -> Result<()> { | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 68 | //Check permission. Function should return if this failed. Therefore having '?' at the end | 
|  | 69 | //is very important. | 
|  | 70 | check_keystore_permission(KeystorePerm::change_password()) | 
|  | 71 | .context("In on_user_password_changed.")?; | 
|  | 72 |  | 
| Paul Crowley | 7a65839 | 2021-03-18 17:08:20 -0700 | [diff] [blame] | 73 | if let Some(pw) = password.as_ref() { | 
|  | 74 | DB.with(|db| { | 
| Paul Crowley | 8d5b253 | 2021-03-19 10:53:07 -0700 | [diff] [blame] | 75 | SUPER_KEY.unlock_screen_lock_bound_key(&mut db.borrow_mut(), user_id as u32, pw) | 
| Paul Crowley | 7a65839 | 2021-03-18 17:08:20 -0700 | [diff] [blame] | 76 | }) | 
| Paul Crowley | 8d5b253 | 2021-03-19 10:53:07 -0700 | [diff] [blame] | 77 | .context("In on_user_password_changed: unlock_screen_lock_bound_key failed")?; | 
| Paul Crowley | 7a65839 | 2021-03-18 17:08:20 -0700 | [diff] [blame] | 78 | } | 
|  | 79 |  | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 80 | match DB | 
|  | 81 | .with(|db| { | 
|  | 82 | UserState::get_with_password_changed( | 
|  | 83 | &mut db.borrow_mut(), | 
| Hasini Gunasinghe | 3ed5da7 | 2021-02-04 15:18:54 +0000 | [diff] [blame] | 84 | &LEGACY_MIGRATOR, | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 85 | &SUPER_KEY, | 
|  | 86 | user_id as u32, | 
| Paul Crowley | f61fee7 | 2021-03-17 14:38:44 -0700 | [diff] [blame] | 87 | password.as_ref(), | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 88 | ) | 
|  | 89 | }) | 
|  | 90 | .context("In on_user_password_changed.")? | 
|  | 91 | { | 
|  | 92 | UserState::LskfLocked => { | 
| Janis Danisevskis | eed6984 | 2021-02-18 20:04:10 -0800 | [diff] [blame] | 93 | // Error - password can not be changed when the device is locked | 
| Janis Danisevskis | cdcf4e5 | 2021-04-14 15:44:36 -0700 | [diff] [blame] | 94 | Err(Error::Rc(ResponseCode::LOCKED)) | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 95 | .context("In on_user_password_changed. Device is locked.") | 
|  | 96 | } | 
|  | 97 | _ => { | 
| Janis Danisevskis | eed6984 | 2021-02-18 20:04:10 -0800 | [diff] [blame] | 98 | // LskfLocked is the only error case for password change | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 99 | Ok(()) | 
|  | 100 | } | 
|  | 101 | } | 
|  | 102 | } | 
|  | 103 |  | 
| Janis Danisevskis | 5898d15 | 2021-06-15 08:23:46 -0700 | [diff] [blame] | 104 | fn add_or_remove_user(&self, user_id: i32) -> Result<()> { | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 105 | // Check permission. Function should return if this failed. Therefore having '?' at the end | 
|  | 106 | // is very important. | 
|  | 107 | check_keystore_permission(KeystorePerm::change_user()).context("In add_or_remove_user.")?; | 
| Janis Danisevskis | eed6984 | 2021-02-18 20:04:10 -0800 | [diff] [blame] | 108 | DB.with(|db| { | 
|  | 109 | UserState::reset_user( | 
|  | 110 | &mut db.borrow_mut(), | 
|  | 111 | &SUPER_KEY, | 
|  | 112 | &LEGACY_MIGRATOR, | 
|  | 113 | user_id as u32, | 
|  | 114 | false, | 
|  | 115 | ) | 
|  | 116 | }) | 
| Janis Danisevskis | 5898d15 | 2021-06-15 08:23:46 -0700 | [diff] [blame] | 117 | .context("In add_or_remove_user: Trying to delete keys from db.")?; | 
|  | 118 | self.delete_listener | 
|  | 119 | .delete_user(user_id as u32) | 
|  | 120 | .context("In add_or_remove_user: While invoking the delete listener.") | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 121 | } | 
| Janis Danisevskis | ddd6e75 | 2021-02-22 18:46:55 -0800 | [diff] [blame] | 122 |  | 
| Janis Danisevskis | 5898d15 | 2021-06-15 08:23:46 -0700 | [diff] [blame] | 123 | fn clear_namespace(&self, domain: Domain, nspace: i64) -> Result<()> { | 
| Janis Danisevskis | ddd6e75 | 2021-02-22 18:46:55 -0800 | [diff] [blame] | 124 | // Permission check. Must return on error. Do not touch the '?'. | 
|  | 125 | check_keystore_permission(KeystorePerm::clear_uid()).context("In clear_namespace.")?; | 
|  | 126 |  | 
|  | 127 | LEGACY_MIGRATOR | 
|  | 128 | .bulk_delete_uid(domain, nspace) | 
|  | 129 | .context("In clear_namespace: Trying to delete legacy keys.")?; | 
|  | 130 | DB.with(|db| db.borrow_mut().unbind_keys_for_namespace(domain, nspace)) | 
| Janis Danisevskis | 5898d15 | 2021-06-15 08:23:46 -0700 | [diff] [blame] | 131 | .context("In clear_namespace: Trying to delete keys from db.")?; | 
|  | 132 | self.delete_listener | 
|  | 133 | .delete_namespace(domain, nspace) | 
|  | 134 | .context("In clear_namespace: While invoking the delete listener.") | 
| Janis Danisevskis | ddd6e75 | 2021-02-22 18:46:55 -0800 | [diff] [blame] | 135 | } | 
| Hasini Gunasinghe | 9ee1841 | 2021-03-11 20:12:44 +0000 | [diff] [blame] | 136 |  | 
|  | 137 | fn get_state(user_id: i32) -> Result<AidlUserState> { | 
|  | 138 | // Check permission. Function should return if this failed. Therefore having '?' at the end | 
|  | 139 | // is very important. | 
|  | 140 | check_keystore_permission(KeystorePerm::get_state()).context("In get_state.")?; | 
|  | 141 | let state = DB | 
|  | 142 | .with(|db| { | 
|  | 143 | UserState::get(&mut db.borrow_mut(), &LEGACY_MIGRATOR, &SUPER_KEY, user_id as u32) | 
|  | 144 | }) | 
|  | 145 | .context("In get_state. Trying to get UserState.")?; | 
|  | 146 |  | 
|  | 147 | match state { | 
|  | 148 | UserState::Uninitialized => Ok(AidlUserState::UNINITIALIZED), | 
|  | 149 | UserState::LskfUnlocked(_) => Ok(AidlUserState::LSKF_UNLOCKED), | 
|  | 150 | UserState::LskfLocked => Ok(AidlUserState::LSKF_LOCKED), | 
|  | 151 | } | 
|  | 152 | } | 
| Janis Danisevskis | 333b7c0 | 2021-03-23 18:57:41 -0700 | [diff] [blame] | 153 |  | 
| Janis Danisevskis | 2ee014b | 2021-05-05 14:29:08 -0700 | [diff] [blame] | 154 | fn early_boot_ended_help(sec_level: SecurityLevel) -> Result<()> { | 
| Janis Danisevskis | 5f3a057 | 2021-06-18 11:26:42 -0700 | [diff] [blame] | 155 | let (km_dev, _, _) = get_keymint_device(&sec_level) | 
| Janis Danisevskis | 2ee014b | 2021-05-05 14:29:08 -0700 | [diff] [blame] | 156 | .context("In early_boot_ended: getting keymint device")?; | 
| Janis Danisevskis | 2ee014b | 2021-05-05 14:29:08 -0700 | [diff] [blame] | 157 |  | 
|  | 158 | let _wp = wd::watch_millis_with( | 
|  | 159 | "In early_boot_ended_help: calling earlyBootEnded()", | 
|  | 160 | 500, | 
|  | 161 | move || format!("Seclevel: {:?}", sec_level), | 
|  | 162 | ); | 
| Satya Tangirala | 5b9e5b1 | 2021-03-09 12:54:21 -0800 | [diff] [blame] | 163 | map_km_error(km_dev.earlyBootEnded()) | 
|  | 164 | .context("In keymint device: calling earlyBootEnded")?; | 
|  | 165 | Ok(()) | 
|  | 166 | } | 
|  | 167 |  | 
|  | 168 | fn early_boot_ended() -> Result<()> { | 
|  | 169 | check_keystore_permission(KeystorePerm::early_boot_ended()) | 
|  | 170 | .context("In early_boot_ended. Checking permission")?; | 
| Paul Crowley | 44c02da | 2021-04-08 17:04:43 +0000 | [diff] [blame] | 171 | log::info!("In early_boot_ended."); | 
|  | 172 |  | 
|  | 173 | if let Err(e) = DB.with(|db| SUPER_KEY.set_up_boot_level_cache(&mut db.borrow_mut())) { | 
|  | 174 | log::error!("SUPER_KEY.set_up_boot_level_cache failed:\n{:?}\n:(", e); | 
|  | 175 | } | 
| Satya Tangirala | 5b9e5b1 | 2021-03-09 12:54:21 -0800 | [diff] [blame] | 176 |  | 
|  | 177 | let sec_levels = [ | 
|  | 178 | (SecurityLevel::TRUSTED_ENVIRONMENT, "TRUSTED_ENVIRONMENT"), | 
|  | 179 | (SecurityLevel::STRONGBOX, "STRONGBOX"), | 
|  | 180 | ]; | 
|  | 181 | sec_levels.iter().fold(Ok(()), |result, (sec_level, sec_level_string)| { | 
| Janis Danisevskis | 2ee014b | 2021-05-05 14:29:08 -0700 | [diff] [blame] | 182 | let curr_result = Maintenance::early_boot_ended_help(*sec_level); | 
| Satya Tangirala | 5b9e5b1 | 2021-03-09 12:54:21 -0800 | [diff] [blame] | 183 | if curr_result.is_err() { | 
|  | 184 | log::error!( | 
|  | 185 | "Call to earlyBootEnded failed for security level {}.", | 
|  | 186 | &sec_level_string | 
|  | 187 | ); | 
|  | 188 | } | 
|  | 189 | result.and(curr_result) | 
|  | 190 | }) | 
|  | 191 | } | 
|  | 192 |  | 
| Janis Danisevskis | 333b7c0 | 2021-03-23 18:57:41 -0700 | [diff] [blame] | 193 | fn on_device_off_body() -> Result<()> { | 
|  | 194 | // Security critical permission check. This statement must return on fail. | 
|  | 195 | check_keystore_permission(KeystorePerm::report_off_body()) | 
|  | 196 | .context("In on_device_off_body.")?; | 
|  | 197 |  | 
| Matthew Maurer | d7815ca | 2021-05-06 21:58:45 -0700 | [diff] [blame] | 198 | DB.with(|db| db.borrow_mut().update_last_off_body(MonotonicRawTime::now())); | 
|  | 199 | Ok(()) | 
| Janis Danisevskis | 333b7c0 | 2021-03-23 18:57:41 -0700 | [diff] [blame] | 200 | } | 
| Janis Danisevskis | cdcf4e5 | 2021-04-14 15:44:36 -0700 | [diff] [blame] | 201 |  | 
|  | 202 | fn migrate_key_namespace(source: &KeyDescriptor, destination: &KeyDescriptor) -> Result<()> { | 
|  | 203 | let caller_uid = ThreadState::get_calling_uid(); | 
|  | 204 |  | 
|  | 205 | DB.with(|db| { | 
|  | 206 | let key_id_guard = match source.domain { | 
|  | 207 | Domain::APP | Domain::SELINUX | Domain::KEY_ID => { | 
|  | 208 | let (key_id_guard, _) = LEGACY_MIGRATOR | 
| Chris Wailes | d5aaaef | 2021-07-27 16:04:33 -0700 | [diff] [blame] | 209 | .with_try_migrate(source, caller_uid, || { | 
| Janis Danisevskis | cdcf4e5 | 2021-04-14 15:44:36 -0700 | [diff] [blame] | 210 | db.borrow_mut().load_key_entry( | 
| Chris Wailes | d5aaaef | 2021-07-27 16:04:33 -0700 | [diff] [blame] | 211 | source, | 
| Janis Danisevskis | cdcf4e5 | 2021-04-14 15:44:36 -0700 | [diff] [blame] | 212 | KeyType::Client, | 
|  | 213 | KeyEntryLoadBits::NONE, | 
|  | 214 | caller_uid, | 
|  | 215 | |k, av| { | 
|  | 216 | check_key_permission(KeyPerm::use_(), k, &av)?; | 
|  | 217 | check_key_permission(KeyPerm::delete(), k, &av)?; | 
|  | 218 | check_key_permission(KeyPerm::grant(), k, &av) | 
|  | 219 | }, | 
|  | 220 | ) | 
|  | 221 | }) | 
|  | 222 | .context("In migrate_key_namespace: Failed to load key blob.")?; | 
|  | 223 | key_id_guard | 
|  | 224 | } | 
|  | 225 | _ => { | 
|  | 226 | return Err(Error::Rc(ResponseCode::INVALID_ARGUMENT)).context(concat!( | 
|  | 227 | "In migrate_key_namespace: ", | 
|  | 228 | "Source domain must be one of APP, SELINUX, or KEY_ID." | 
|  | 229 | )) | 
|  | 230 | } | 
|  | 231 | }; | 
|  | 232 |  | 
|  | 233 | db.borrow_mut().migrate_key_namespace(key_id_guard, destination, caller_uid, |k| { | 
|  | 234 | check_key_permission(KeyPerm::rebind(), k, &None) | 
|  | 235 | }) | 
|  | 236 | }) | 
|  | 237 | } | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 238 | } | 
|  | 239 |  | 
| Janis Danisevskis | 34a0cf2 | 2021-03-08 09:19:03 -0800 | [diff] [blame] | 240 | impl Interface for Maintenance {} | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 241 |  | 
| Janis Danisevskis | 34a0cf2 | 2021-03-08 09:19:03 -0800 | [diff] [blame] | 242 | impl IKeystoreMaintenance for Maintenance { | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 243 | fn onUserPasswordChanged(&self, user_id: i32, password: Option<&[u8]>) -> BinderResult<()> { | 
| Hasini Gunasinghe | 5a893e8 | 2021-05-05 14:32:32 +0000 | [diff] [blame] | 244 | let _wp = wd::watch_millis("IKeystoreMaintenance::onUserPasswordChanged", 500); | 
| Paul Crowley | f61fee7 | 2021-03-17 14:38:44 -0700 | [diff] [blame] | 245 | map_or_log_err(Self::on_user_password_changed(user_id, password.map(|pw| pw.into())), Ok) | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 246 | } | 
|  | 247 |  | 
|  | 248 | fn onUserAdded(&self, user_id: i32) -> BinderResult<()> { | 
| Hasini Gunasinghe | 5a893e8 | 2021-05-05 14:32:32 +0000 | [diff] [blame] | 249 | let _wp = wd::watch_millis("IKeystoreMaintenance::onUserAdded", 500); | 
| Janis Danisevskis | 5898d15 | 2021-06-15 08:23:46 -0700 | [diff] [blame] | 250 | map_or_log_err(self.add_or_remove_user(user_id), Ok) | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 251 | } | 
|  | 252 |  | 
|  | 253 | fn onUserRemoved(&self, user_id: i32) -> BinderResult<()> { | 
| Hasini Gunasinghe | 5a893e8 | 2021-05-05 14:32:32 +0000 | [diff] [blame] | 254 | let _wp = wd::watch_millis("IKeystoreMaintenance::onUserRemoved", 500); | 
| Janis Danisevskis | 5898d15 | 2021-06-15 08:23:46 -0700 | [diff] [blame] | 255 | map_or_log_err(self.add_or_remove_user(user_id), Ok) | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 256 | } | 
| Janis Danisevskis | ddd6e75 | 2021-02-22 18:46:55 -0800 | [diff] [blame] | 257 |  | 
|  | 258 | fn clearNamespace(&self, domain: Domain, nspace: i64) -> BinderResult<()> { | 
| Hasini Gunasinghe | 5a893e8 | 2021-05-05 14:32:32 +0000 | [diff] [blame] | 259 | let _wp = wd::watch_millis("IKeystoreMaintenance::clearNamespace", 500); | 
| Janis Danisevskis | 5898d15 | 2021-06-15 08:23:46 -0700 | [diff] [blame] | 260 | map_or_log_err(self.clear_namespace(domain, nspace), Ok) | 
| Janis Danisevskis | ddd6e75 | 2021-02-22 18:46:55 -0800 | [diff] [blame] | 261 | } | 
| Hasini Gunasinghe | 9ee1841 | 2021-03-11 20:12:44 +0000 | [diff] [blame] | 262 |  | 
| Janis Danisevskis | 333b7c0 | 2021-03-23 18:57:41 -0700 | [diff] [blame] | 263 | fn getState(&self, user_id: i32) -> BinderResult<AidlUserState> { | 
| Hasini Gunasinghe | 5a893e8 | 2021-05-05 14:32:32 +0000 | [diff] [blame] | 264 | let _wp = wd::watch_millis("IKeystoreMaintenance::getState", 500); | 
| Hasini Gunasinghe | 9ee1841 | 2021-03-11 20:12:44 +0000 | [diff] [blame] | 265 | map_or_log_err(Self::get_state(user_id), Ok) | 
|  | 266 | } | 
| Janis Danisevskis | 333b7c0 | 2021-03-23 18:57:41 -0700 | [diff] [blame] | 267 |  | 
| Satya Tangirala | 5b9e5b1 | 2021-03-09 12:54:21 -0800 | [diff] [blame] | 268 | fn earlyBootEnded(&self) -> BinderResult<()> { | 
| Hasini Gunasinghe | 5a893e8 | 2021-05-05 14:32:32 +0000 | [diff] [blame] | 269 | let _wp = wd::watch_millis("IKeystoreMaintenance::earlyBootEnded", 500); | 
| Satya Tangirala | 5b9e5b1 | 2021-03-09 12:54:21 -0800 | [diff] [blame] | 270 | map_or_log_err(Self::early_boot_ended(), Ok) | 
|  | 271 | } | 
|  | 272 |  | 
| Janis Danisevskis | 333b7c0 | 2021-03-23 18:57:41 -0700 | [diff] [blame] | 273 | fn onDeviceOffBody(&self) -> BinderResult<()> { | 
| Hasini Gunasinghe | 5a893e8 | 2021-05-05 14:32:32 +0000 | [diff] [blame] | 274 | let _wp = wd::watch_millis("IKeystoreMaintenance::onDeviceOffBody", 500); | 
| Janis Danisevskis | 333b7c0 | 2021-03-23 18:57:41 -0700 | [diff] [blame] | 275 | map_or_log_err(Self::on_device_off_body(), Ok) | 
|  | 276 | } | 
| Janis Danisevskis | cdcf4e5 | 2021-04-14 15:44:36 -0700 | [diff] [blame] | 277 |  | 
|  | 278 | fn migrateKeyNamespace( | 
|  | 279 | &self, | 
|  | 280 | source: &KeyDescriptor, | 
|  | 281 | destination: &KeyDescriptor, | 
|  | 282 | ) -> BinderResult<()> { | 
| Hasini Gunasinghe | 5a893e8 | 2021-05-05 14:32:32 +0000 | [diff] [blame] | 283 | let _wp = wd::watch_millis("IKeystoreMaintenance::migrateKeyNamespace", 500); | 
| Janis Danisevskis | cdcf4e5 | 2021-04-14 15:44:36 -0700 | [diff] [blame] | 284 | map_or_log_err(Self::migrate_key_namespace(source, destination), Ok) | 
|  | 285 | } | 
| Hasini Gunasinghe | da89555 | 2021-01-27 19:34:37 +0000 | [diff] [blame] | 286 | } |