Alex Deymo | 40d86b2 | 2015-09-03 22:27:10 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2015 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 "update_engine/hardware_android.h" |
| 18 | |
Alex Deymo | dd132f3 | 2015-09-14 19:12:07 -0700 | [diff] [blame] | 19 | #include <base/files/file_util.h> |
Alex Deymo | 40d86b2 | 2015-09-03 22:27:10 -0700 | [diff] [blame] | 20 | #include <chromeos/make_unique_ptr.h> |
| 21 | |
| 22 | #include "update_engine/hardware.h" |
| 23 | |
| 24 | using std::string; |
| 25 | |
Alex Deymo | dd132f3 | 2015-09-14 19:12:07 -0700 | [diff] [blame] | 26 | namespace { |
| 27 | |
| 28 | // The stateful directory used by update_engine. |
| 29 | const char kNonVolatileDirectory[] = "/data/misc/update_engine"; |
| 30 | |
| 31 | } // namespace |
| 32 | |
Alex Deymo | 40d86b2 | 2015-09-03 22:27:10 -0700 | [diff] [blame] | 33 | namespace chromeos_update_engine { |
| 34 | |
| 35 | namespace hardware { |
| 36 | |
| 37 | // Factory defined in hardware.h. |
| 38 | std::unique_ptr<HardwareInterface> CreateHardware() { |
| 39 | return chromeos::make_unique_ptr(new HardwareAndroid()); |
| 40 | } |
| 41 | |
| 42 | } // namespace hardware |
| 43 | |
| 44 | bool HardwareAndroid::IsOfficialBuild() const { |
| 45 | // TODO(deymo): Read the kind of build we are running from the metadata |
| 46 | // partition. |
| 47 | LOG(WARNING) << "STUB: Assuming we are not an official build."; |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | bool HardwareAndroid::IsNormalBootMode() const { |
| 52 | // TODO(deymo): Read the kind of build we are running from the metadata |
| 53 | // partition. |
| 54 | LOG(WARNING) << "STUB: Assuming we are in dev-mode."; |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | bool HardwareAndroid::IsOOBEComplete(base::Time* out_time_of_oobe) const { |
| 59 | LOG(WARNING) << "STUB: Assuming OOBE is complete."; |
Alex Deymo | 4d2990d | 2015-09-15 12:11:26 -0700 | [diff] [blame] | 60 | if (out_time_of_oobe) |
| 61 | *out_time_of_oobe = base::Time(); |
Alex Deymo | 40d86b2 | 2015-09-03 22:27:10 -0700 | [diff] [blame] | 62 | return true; |
| 63 | } |
| 64 | |
| 65 | string HardwareAndroid::GetHardwareClass() const { |
| 66 | LOG(WARNING) << "STUB: GetHardwareClass()."; |
| 67 | return "ANDROID"; |
| 68 | } |
| 69 | |
| 70 | string HardwareAndroid::GetFirmwareVersion() const { |
| 71 | LOG(WARNING) << "STUB: GetFirmwareVersion()."; |
| 72 | return "0"; |
| 73 | } |
| 74 | |
| 75 | string HardwareAndroid::GetECVersion() const { |
| 76 | LOG(WARNING) << "STUB: GetECVersion()."; |
| 77 | return "0"; |
| 78 | } |
| 79 | |
| 80 | int HardwareAndroid::GetPowerwashCount() const { |
| 81 | LOG(WARNING) << "STUB: Assuming no factory reset was performed."; |
| 82 | return 0; |
| 83 | } |
| 84 | |
Alex Deymo | dd132f3 | 2015-09-14 19:12:07 -0700 | [diff] [blame] | 85 | bool HardwareAndroid::GetNonVolatileDirectory(base::FilePath* path) const { |
| 86 | base::FilePath local_path(kNonVolatileDirectory); |
| 87 | if (!base::PathExists(local_path)) { |
| 88 | LOG(ERROR) << "Non-volatile directory not found: " << local_path.value(); |
| 89 | return false; |
| 90 | } |
| 91 | *path = local_path; |
| 92 | return true; |
| 93 | } |
| 94 | |
| 95 | bool HardwareAndroid::GetPowerwashSafeDirectory(base::FilePath* path) const { |
| 96 | // On Android, we don't have a directory persisted across powerwash. |
| 97 | return false; |
| 98 | } |
| 99 | |
Alex Deymo | 40d86b2 | 2015-09-03 22:27:10 -0700 | [diff] [blame] | 100 | } // namespace chromeos_update_engine |