blob: 6df5cd940b5bd358f52a8a6f01c44caa4c619362 [file] [log] [blame]
Alex Deymo40d86b22015-09-03 22:27:10 -07001//
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 Deymodd132f32015-09-14 19:12:07 -070019#include <base/files/file_util.h>
Alex Deymo40d86b22015-09-03 22:27:10 -070020#include <chromeos/make_unique_ptr.h>
21
22#include "update_engine/hardware.h"
23
24using std::string;
25
Alex Deymodd132f32015-09-14 19:12:07 -070026namespace {
27
28// The stateful directory used by update_engine.
29const char kNonVolatileDirectory[] = "/data/misc/update_engine";
30
31} // namespace
32
Alex Deymo40d86b22015-09-03 22:27:10 -070033namespace chromeos_update_engine {
34
35namespace hardware {
36
37// Factory defined in hardware.h.
38std::unique_ptr<HardwareInterface> CreateHardware() {
39 return chromeos::make_unique_ptr(new HardwareAndroid());
40}
41
42} // namespace hardware
43
44bool 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
51bool 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
58bool HardwareAndroid::IsOOBEComplete(base::Time* out_time_of_oobe) const {
59 LOG(WARNING) << "STUB: Assuming OOBE is complete.";
Alex Deymo4d2990d2015-09-15 12:11:26 -070060 if (out_time_of_oobe)
61 *out_time_of_oobe = base::Time();
Alex Deymo40d86b22015-09-03 22:27:10 -070062 return true;
63}
64
65string HardwareAndroid::GetHardwareClass() const {
66 LOG(WARNING) << "STUB: GetHardwareClass().";
67 return "ANDROID";
68}
69
70string HardwareAndroid::GetFirmwareVersion() const {
71 LOG(WARNING) << "STUB: GetFirmwareVersion().";
72 return "0";
73}
74
75string HardwareAndroid::GetECVersion() const {
76 LOG(WARNING) << "STUB: GetECVersion().";
77 return "0";
78}
79
80int HardwareAndroid::GetPowerwashCount() const {
81 LOG(WARNING) << "STUB: Assuming no factory reset was performed.";
82 return 0;
83}
84
Alex Deymodd132f32015-09-14 19:12:07 -070085bool 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
95bool HardwareAndroid::GetPowerwashSafeDirectory(base::FilePath* path) const {
96 // On Android, we don't have a directory persisted across powerwash.
97 return false;
98}
99
Alex Deymo40d86b22015-09-03 22:27:10 -0700100} // namespace chromeos_update_engine