|
| 1 | +# Image manager |
| 2 | + |
| 3 | +Image manager stores update item images and provide update item image info for other modules. |
| 4 | + |
| 5 | +It implements the following interfaces: |
| 6 | + |
| 7 | +* [aos::cm::imagemanager::ImageMangerItf]() - image manager to manage update items images; |
| 8 | +* [aos::cm::imagemanager::UpdateItemNotifierItf]() - update item notifier to notify other modules about update items; |
| 9 | +* [aos::cm::launcher::UpdateItemProviderItf]() - update item provider for [launcher]() module; |
| 10 | +* [aos::cm::smcontroller::UpdateImageProviderItf]() - update image provider for [smcontroller]() module; |
| 11 | + action. |
| 12 | + |
| 13 | +It requires the following interfaces: |
| 14 | + |
| 15 | +* TODO: add required interfaces. |
| 16 | + |
| 17 | +```mermaid |
| 18 | +classDiagram |
| 19 | + class ImageManager["aos::cm::imagemanager::ImageManager"] { |
| 20 | + } |
| 21 | +
|
| 22 | + class ImageManagerItf["aos::cm::imagemanager::ImageMangerItf"] { |
| 23 | + <<interface>> |
| 24 | + } |
| 25 | +
|
| 26 | + class UpdateItemNotifierItf ["aos::cm::imagemanager::UpdateItemNotifierItf"] { |
| 27 | + <<interface>> |
| 28 | + } |
| 29 | +
|
| 30 | + class UpdateItemProviderItf ["aos::cm::launcher::UpdateItemProviderItf"] { |
| 31 | + <<interface>> |
| 32 | + } |
| 33 | + |
| 34 | + class UpdateImageProviderItf ["aos::cm::smcontroller::UpdateImageProviderItf"] { |
| 35 | + <<interface>> |
| 36 | + } |
| 37 | +
|
| 38 | +
|
| 39 | + ImageManager <|.. ImageManagerItf |
| 40 | + ImageManager <|.. UpdateItemNotifierItf |
| 41 | + ImageManager <|.. UpdateItemProviderItf |
| 42 | + ImageManager <|.. UpdateImageProviderItf |
| 43 | +``` |
| 44 | + |
| 45 | +## Initialization |
| 46 | + |
| 47 | +During initialization: |
| 48 | + |
| 49 | +* verifies integrity of each item and removes corrupted or not fully installed items; |
| 50 | +* removes outdated items. |
| 51 | + |
| 52 | +## Removing outdated items |
| 53 | + |
| 54 | +Image manager has configuration parameter that indicated how long cached update items should be stored on file system. |
| 55 | +If update item is in cached stated more than configured timeout, this item should be completely removed from the unit. |
| 56 | + |
| 57 | +For this purpose, image manager checks and removes outdated items during initialization and also performs periodical |
| 58 | +outdated items check and removal during operation. |
| 59 | + |
| 60 | +## aos::cm::updatemanager::UpdateItemManagerItf |
| 61 | + |
| 62 | +### GetUpdateItemsStatuses |
| 63 | + |
| 64 | +Returns currently installed images statuses for each update item. It return only active update items versions. |
| 65 | + |
| 66 | +### InstallUpdateItem |
| 67 | + |
| 68 | +Installs update item images. |
| 69 | + |
| 70 | +This method performs the following actions: |
| 71 | + |
| 72 | +* decrypts update item images and verifies signature; |
| 73 | +* unpacks certain update item types images in order to retrieve metadata or/and modify it and store it in the internal |
| 74 | + storage. It is required to provide frequently used data to other modules; |
| 75 | +* cached outdate items for revert purpose; |
| 76 | +* if install of at least one image of desired update item fails, error with corresponding update item status is returned |
| 77 | + and all artifacts of this update item version are removed from file system. |
| 78 | + |
| 79 | +This method maintains update item versions as following: |
| 80 | + |
| 81 | +* if there is no such update item installed, this update item is installed normally; |
| 82 | +* if there is already such update item installed then versions of installed and requested update items compares and next |
| 83 | + actions are performed based on version comparison result: |
| 84 | + * if requested item version is less than installed item version, version mismatch error is returned; |
| 85 | + * if requested item version equals to installed item version and requested item images differ from installed item |
| 86 | + images, then differ requested images should be installed over existing differ images. Otherwise, no action is |
| 87 | + performed and installed status for all images is returner; |
| 88 | + * if requested item version is greater than installed item version, requested item is installed normally and then |
| 89 | + existing item is marked as cached. It is required to perform update item revert. If there are cached version of this |
| 90 | + item before install, this item version is completely removed from file system before install requested one. Image |
| 91 | + manager doesn't keep more than two versions (one active and one cached) of the same item at the same time; |
| 92 | +* if there is already such update item installed but in cached state, then versions of cached and requested update |
| 93 | + items compares and next actions are performed based on version comparison result: |
| 94 | + * if version of cached item is less than requested item version, requested item version is installed normally; |
| 95 | + * if version of cached item equals to requested item version, cached version becomes active if all images of cached |
| 96 | + item are identical to all images of requested item. Otherwise, images are updated and item becomes active; |
| 97 | + * if version of cached item is grated then requested then cached item is removed and requested item normally |
| 98 | + installed. |
| 99 | + |
| 100 | +### UninstallUpdateItem |
| 101 | + |
| 102 | +Uninstalls update item images. |
| 103 | + |
| 104 | +This method performs the following actions: |
| 105 | + |
| 106 | +* mark requested update item as cached. If there is already cached version of the requested item, the cached version is |
| 107 | + remove in order to have only one cached version of update item at the same time. |
| 108 | + |
| 109 | +### RevertUpdateItem |
| 110 | + |
| 111 | +Reverts update item images. |
| 112 | + |
| 113 | +This method performs the following actions: |
| 114 | + |
| 115 | +* if there is active and cached version of requested item, active version is removed from file system and cached version |
| 116 | + is marked as active; |
| 117 | +* if there is only active version of requested item, it is remove from file system; |
| 118 | +* if there is only cached version of requested item, `not found` error is returned. |
| 119 | + |
| 120 | +## aos::cm::launcher::UpdateItemProviderItf |
| 121 | + |
| 122 | +### GetServiceNetworkData |
| 123 | + |
| 124 | +Returns network data for specified service. This information is taken from local storage based on retrieved from service |
| 125 | +image metadata. |
| 126 | + |
| 127 | +### GetUpdateItemVersion |
| 128 | + |
| 129 | +Returns currently installed active update item version. |
| 130 | + |
| 131 | +## aos::cm::smcontroller::UpdateImageProviderItf |
| 132 | + |
| 133 | +### GetUpdateImageInfo |
| 134 | + |
| 135 | +Returns update image info such as download URL, size, checksum etc. for specified platform. |
| 136 | + |
| 137 | +TODO: describe platform match rules. |
| 138 | + |
| 139 | +## aos::cm::imagemanager::UpdateItemNotifierItf |
| 140 | + |
| 141 | +Notifies subscribers about changing update item states. |
| 142 | + |
| 143 | +### SubscribeListener |
| 144 | + |
| 145 | +Subscribes to changing update item states. |
| 146 | + |
| 147 | +### UnsubscribeListener |
| 148 | + |
| 149 | +Unsubscribes from changing update item states. |
| 150 | + |
| 151 | +## aos::cm::imagemanager::UpdateItemListenerItf |
| 152 | + |
| 153 | +### OnUpdateItemRemoved |
| 154 | + |
| 155 | +This method is called for each registered listener when specified update item is completely removed from file system. |
| 156 | +It is required to perform cleanup operation by other modules e.g. remove associated instances etc. |
| 157 | +It is not called when update item becomes cached. |
0 commit comments