1 /* 2 * Copyright (C) 2016 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 #ifndef SYSTEM_KEYMASTER_KEYMASTER_CONFIGURATION_H_ 18 #define SYSTEM_KEYMASTER_KEYMASTER_CONFIGURATION_H_ 19 20 #include <string> 21 22 #include <stdint.h> 23 24 #include <hardware/keymaster2.h> 25 #include <hardware/keymaster_defs.h> 26 27 namespace keymaster { 28 29 /** 30 * Retrieves OS version information from system build properties and configures the provided 31 * keymaster device. 32 */ 33 keymaster_error_t ConfigureDevice(keymaster2_device_t* dev); 34 35 /** 36 * Parses OS version string, returning in integer form. For example, "6.1.2" will be returned as 37 * 60102. Ignores any non-numeric suffix, and allows short build numbers, e.g. "6" -> 60000 and 38 * "6.1" -> 60100. Returns 0 if the string doesn't contain a numeric version number. 39 */ 40 uint32_t GetOsVersion(const char* version_string); 41 42 /** 43 * Parses OS patch level string, returning year and month in integer form. For example, "2016-03-25" 44 * will be returned as 201603. Returns 0 if the string doesn't contain a date in the form 45 * YYYY-MM-DD. 46 */ 47 uint32_t GetOsPatchlevel(const char* patchlevel_string); 48 49 } // namespace keymaster 50 51 #endif // SYSTEM_KEYMASTER_KEYMASTER_CONFIGURATION_H_ 52