1 /* 2 * Copyright (C) 2021 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 #include <android-base/properties.h> 18 #include <gtest/gtest.h> 19 20 #include <IVhalClient.h> 21 #include <VehicleHalTypes.h> 22 23 namespace android { 24 namespace automotive { 25 namespace security { 26 namespace { 27 28 using ::aidl::android::hardware::automotive::vehicle::StatusCode; 29 using ::aidl::android::hardware::automotive::vehicle::VehiclePropConfig; 30 using ::aidl::android::hardware::automotive::vehicle::VehicleProperty; 31 using ::android::frameworks::automotive::vhal::IVhalClient; 32 isSeedVhalPropertySupported(std::shared_ptr<IVhalClient> vehicle)33bool isSeedVhalPropertySupported(std::shared_ptr<IVhalClient> vehicle) { 34 std::vector<int32_t> props = { 35 static_cast<int32_t>(VehicleProperty::STORAGE_ENCRYPTION_BINDING_SEED)}; 36 37 auto result = vehicle->getPropConfigs(props); 38 return result.ok() && result.value().size() != 0; 39 } 40 41 // Verify that vold got the binding seed if VHAL reports a seed TEST(VehicleBindingIntegrationTedt,TestVehicleBindingSeedSet)42TEST(VehicleBindingIntegrationTedt, TestVehicleBindingSeedSet) { 43 std::string expected_value = "1"; 44 auto client = IVhalClient::create(); 45 if (!isSeedVhalPropertySupported(client)) { 46 GTEST_LOG_(INFO) << "Device does not support vehicle binding seed " 47 "(STORAGE_ENCRYPTION_BINDING_SEED)."; 48 expected_value = ""; 49 } 50 51 ASSERT_EQ(expected_value, android::base::GetProperty("vold.storage_seed_bound", "")); 52 } 53 54 } // namespace 55 } // namespace security 56 } // namespace automotive 57 } // namespace android 58