blob: 72af7323c607a2cbeb3046e47d1b6d3c16aa7d97 [file] [log] [blame]
Zvikomborero VIncent Zvikaramba6c3a8732016-09-01 05:34:27 -04001# Copyright (C) 2015 The CyanogenMod Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""Emit commands needed for TCL devices during OTA installation
16(installing images)."""
17
18import common
19import re
20import sha
21
22def FullOTA_Assertions(info):
23 print "FullOTA_Assertions not implemented"
24
25def IncrementalOTA_Assertions(info):
26 print "IncrementalOTA_Assertions not implemented"
27
28def InstallImage(img_name, img_file, partition, info):
29 common.ZipWriteStr(info.output_zip, img_name, img_file)
30 info.script.AppendExtra(('package_extract_file("' + img_name + '", "/dev/block/bootdevice/by-name/' + partition + '");'))
31
32image_partitions = {
33 'emmc_appsboot.mbn' : 'aboot',
34 'hyp.mbn' : 'hyp',
35 'rpm.mbn' : 'rpm',
36 'sbl1.mbn' : 'sbl1',
37 'tz.mbn' : 'tz'
38}
39
40def FullOTA_InstallEnd(info):
41 info.script.Print("Writing radio image...")
42 for k, v in image_partitions.iteritems():
43 try:
44 img_file = info.input_zip.read("RADIO/" + k)
45 info.script.Print("update image " + k + "...")
46 InstallImage(k, img_file, v, info)
47 except KeyError:
48 print "warning: no " + k + " image in input target_files; not flashing " + k
49
50
51def IncrementalOTA_InstallEnd(info):
52 for k, v in image_partitions.iteritems():
53 try:
54 source_file = info.source_zip.read("RADIO/" + k)
55 target_file = info.target_zip.read("RADIO/" + k)
56 if source_file != target_file:
57 InstallImage(k, target_file, v, info)
58 else:
59 print k + " image unchanged; skipping"
60 except KeyError:
61 print "warning: " + k + " image missing from target; not flashing " + k