blob: d10fc8d65f6d2db1c8120ddaffdcda2dafd93c98 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#
# Copyright (C) 2015 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Functions and globals to check and report the status of BSPs."""
import os
import package as package_types
from tools import bdk_root
from tools import popen
# Statuses should be numbered low to high, where a higher status
# of a single package within a BSP dominates a lower status
# for determining the overall health of that BSP.
INSTALLED = 0
NOT_INSTALLED = 1
INCORRECT_VERSION = 2
INVALID = 3
def StatusString(status):
"""Human readable version of a status."""
if status == INSTALLED:
return "Installed"
elif status == NOT_INSTALLED:
return "Not Installed"
elif status == INCORRECT_VERSION:
return "Incorrect Version"
elif status == INVALID:
return "Invalid State"
else:
return "Unknown State"
def CheckDeviceStatus(device_manifest):
"""Checks the status of a device.
Args:
device_manifest - The manifest dictionary of the device.
Returns:
The highest status of any package that is part of the device BSP.
INSTALLED if the BSP has no packages.
"""
status = INSTALLED
install_root = bdk_root.BDKRoot()
for package in device_manifest["packages"]:
status = max(status, package.Status(install_root))
return status
|