Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 109 lines (94 sloc) 4.166 kB
a3631c5 @codeworkx initial push, cloned from galaxys
codeworkx authored
1 # Copyright (C) 2010 The Android Open Source 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 import sha
16
17 import common
18
19 def FullOTA_InstallEnd(info):
20
21 try:
22 bootloader_img = info.input_zip.read("RADIO/bootloader.img")
23 except KeyError:
24 print "no bootloader.img in target_files; skipping install"
25 else:
26 common.ZipWriteStr(info.output_zip, "bootloader.img", bootloader_img)
27 info.script.Print("Writing bootloader...")
28 info.script.WriteRawImage("/bootloader", "bootloader.img")
29
30 try:
31 radio_img = info.input_zip.read("RADIO/radio.img")
32 except KeyError:
33 print "no radio.img in target_files; skipping install"
34 else:
35 common.ZipWriteStr(info.output_zip, "radio.img", radio_img)
36 info.script.Print("Writing radio...")
37 info.script.WriteRawImage("/radio", "radio.img")
38
39 def IncrementalOTA_VerifyEnd(info):
40 try:
41 target_radio_img = info.target_zip.read("RADIO/radio.img")
42 source_radio_img = info.source_zip.read("RADIO/radio.img")
43 except KeyError:
44 pass
45 else:
46 if source_radio_img != target_radio_img:
47 info.script.CacheFreeSpaceCheck(len(source_radio_img))
48 radio_type, radio_device = common.GetTypeAndDevice("/radio", info.info_dict)
49 info.script.PatchCheck("%s:%s:%d:%s:%d:%s" % (
50 radio_type, radio_device,
51 len(source_radio_img), sha.sha(source_radio_img).hexdigest(),
52 len(target_radio_img), sha.sha(target_radio_img).hexdigest()))
53
54 def IncrementalOTA_InstallEnd(info):
55 try:
56 target_bootloader_img = info.target_zip.read("RADIO/bootloader.img")
57 try:
58 source_bootloader_img = info.source_zip.read("RADIO/bootloader.img")
59 except KeyError:
60 source_bootloader_img = None
61
62 if source_bootloader_img == target_bootloader_img:
63 print "bootloader unchanged; skipping"
64 else:
65 common.ZipWriteStr(info.output_zip, "bootloader.img", target_bootloader_img)
66 info.script.Print("Writing bootloader...")
67 info.script.WriteRawImage("/bootloader", "bootloader.img")
68
69 except KeyError:
70 print "no bootloader.img in target target_files; skipping install"
71
72
73 try:
74 tf = common.File("radio.img", info.target_zip.read("RADIO/radio.img"))
75 try:
76 sf = common.File("radio.img", info.source_zip.read("RADIO/radio.img"))
77
78 if tf.sha1 == sf.sha1:
79 print "radio image unchanged; skipping"
80 else:
81 diff = common.Difference(tf, sf)
82 common.ComputeDifferences([diff])
83 _, _, d = diff.GetPatch()
84 if d is None or len(d) > tf.size * common.OPTIONS.patch_threshold:
85 # computing difference failed, or difference is nearly as
86 # big as the target: simply send the target.
87 tf.AddToZip(info.output_zip)
88 info.script.Print("Writing radio...")
89 info.script.WriteRawImage("radio", tf.name)
90 else:
91 common.ZipWriteStr(info.output_zip, "radio.img.p", d)
92 info.script.Print("Patching radio...")
93 radio_type, radio_device = common.GetTypeAndDevice("/radio", info.info_dict)
94 info.script.ApplyPatch(
95 "%s:%s:%d:%s:%d:%s" % (radio_type, radio_device,
96 sf.size, sf.sha1, tf.size, tf.sha1),
97 "-", tf.size, tf.sha1, sf.sha1, "radio.img.p")
98
99 except KeyError:
100 # failed to read SOURCE radio image: include the whole target
101 # radio image.
102 tf.AddToZip(info.output_zip)
103 info.script.Print("Writing radio...")
104 info.script.WriteRawImage("/radio", tf.name)
105
106 except KeyError:
107 # failed to read TARGET radio image: don't include any radio in update.
108 print "no radio.img in target target_files; skipping install"
Something went wrong with that request. Please try again.