1# Copyright (C) 2012 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"""Emit commands needed for Mantaray during OTA installation 16(installing the bootloader).""" 17 18import common 19 20def FullOTA_InstallEnd(info): 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 WriteBootloader(info, bootloader_img) 27 28def IncrementalOTA_InstallBegin(info): 29 info.script.Unmount("/system") 30 info.script.TunePartition("/system", "-O", "^has_journal") 31 info.script.Mount("/system") 32 33def IncrementalOTA_VerifyEnd(info): 34 # try: 35 # target_radio_img = info.target_zip.read("RADIO/radio.img") 36 # source_radio_img = info.source_zip.read("RADIO/radio.img") 37 # except KeyError: 38 # # No source or target radio. Nothing to verify 39 # pass 40 # else: 41 # if source_radio_img != target_radio_img: 42 # info.script.CacheFreeSpaceCheck(len(source_radio_img)) 43 # radio_type, radio_device = common.GetTypeAndDevice("/radio", info.info_dict) 44 # info.script.PatchCheck("%s:%s:%d:%s:%d:%s" % ( 45 # radio_type, radio_device, 46 # len(source_radio_img), common.sha1(source_radio_img).hexdigest(), 47 # len(target_radio_img), common.sha1(target_radio_img).hexdigest())) 48 pass 49 50def IncrementalOTA_InstallEnd(info): 51 try: 52 target_bootloader_img = info.target_zip.read("RADIO/bootloader.img") 53 try: 54 source_bootloader_img = info.source_zip.read("RADIO/bootloader.img") 55 except KeyError: 56 source_bootloader_img = None 57 58 if source_bootloader_img == target_bootloader_img: 59 print "bootloader unchanged; skipping" 60 else: 61 WriteBootloader(info, target_bootloader_img) 62 except KeyError: 63 print "no bootloader.img in target target_files; skipping install" 64 65def WriteBootloader(info, bootloader_img): 66 common.ZipWriteStr(info.output_zip, "bootloader.img", bootloader_img) 67 bl_type, bl_device = common.GetTypeAndDevice("/bootloader", info.info_dict) 68 69 fstab = info.info_dict["fstab"] 70 71 info.script.Print("Writing bootloader...") 72 force_ro = "/sys/block/" + bl_device.split("/")[-1] + "/force_ro" 73 info.script.AppendExtra( 74 ('samsung.manta.write_bootloader(package_extract_file(' 75 '"bootloader.img"), "%s", "%s");') % 76 (bl_device, force_ro)) 77