ota : mettre à jour un device android, ok mais comment ça marche ?

36
Mettre à jour un device Android, ok mais comment ça marche ? pod

Upload: sidereo

Post on 09-Apr-2017

436 views

Category:

Technology


1 download

TRANSCRIPT

Mettre à jour un device Android, ok mais comment ça marche ?

pod

Montréal

Paris

Ce dont on ne parlera pas...

Qu’est-ce qu’une OTA ?

Qui a besoin de ce genre de solutions ?

À quoi ça sert ?

Défis techniques

Générer un paquet de mise à jour

% . build/envsetup.sh && lunch tardis-eng

% mkdir dist_output

% make dist DIST_DIR=dist_output

% ./build/tools/releasetools/ota_from_target_files \

dist_output/tardis-target_files.zip ota_update.zip

Ce que ça contientMETA-INF CERT.RSA CERT.SF com android metadata otacert google android update‐binary

updater‐script

MANIFEST.MF

mount("ext4", "EMMC", "/dev/block/platform/dw_mmc.0/by- ‐name/system", “/system");

file_getprop("/system/build.prop", "ro.build.fingerprint") ==

"google/mantaray/manta:4.4.3/KTU84L/1148727:user/release- ‐keys" ||

file_getprop("/system/build.prop", "ro.build.fingerprint") ==

"google/mantaray/manta:4.4.4/KTU84P/1227136:user/release- ‐keys" ||

abort("Package expects build fingerprint of google/mantaray/manta:4.4.3/KTU84L/

1148727:user/release- ‐keys or google/mantaray/manta:4.4.4/KTU84P/1227136:user/release- ‐keys; this

device has " + getprop("ro.build.fingerprint") + ".");

getprop("ro.product.device") == "manta" || abort("This package is for \"manta\" devices; this

is a \"" + getprop("ro.product.device") + "\".");

ui_print("Verifying current system...");

show_progress(0.100000, 0);

apply_patch_check("/system/app/BasicDreams.apk", "42b5544ed0a896f536c1d58ffe1c68a974f12687",

"67280e2672c034505ba417e6c0054be375415c08") || abort("\"/system/app/BasicDreams.apk\" has

unexpected contents.");

set_progress(0.000065);

set_metadata_recursive("/system/xbin", "uid", 0, "gid", 2000, "dmode", 0755, "fmode", 0755,

"capabilities", 0x0, "selabel", "u:object_r:system_file:s0");

ui_print("Patching remaining system files...");

apply_patch("/system/build.prop", "- ‐",

d7978a543a5677b77f7c1b15b5f583fb8fa14bd8, 2774,

4d220efc37eb1786bbb379ae31145bf7edd176d9, package_extract_file("patch/system/build.prop.p"));

set_metadata("/system/build.prop", "uid", 0, "gid", 0, "mode", 0644, "capabilities", 0x0);

unmount("/system");

Full vs. incremental% ./build/tools/releasetools/ota_from_target_files \ -i PREVIOUS-tardis-target_files.zip \ dist_output/tardis-target_files.zip incremental_ota_update.zip

Game of loaders // Updater

Game of loaders // Updaterprivate static final String KEY_SYSTEM_UPDATE_SETTINGS = "system_update_settings";

if (UserHandle.myUserId() == UserHandle.USER_OWNER) { Utils.updatePreferenceToSpecificActivityOrRemove( act, parentPreference, KEY_SYSTEM_UPDATE_SETTINGS, Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY); } else { // Remove for secondary users removePreference(KEY_SYSTEM_UPDATE_SETTINGS); }

Game of loaders // Updater<intent- filter android:priority="999"> <action android:name="android.settings.SYSTEM_UPDATE_SETTINGS" /> <category android:name="android.intent.category.DEFAULT" /> </intent- filter>

Game of loaders // Downloader

Game of loaders // DownloaderDownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);

DownloadManager.Request requestDownload = new DownloadManager.Request(url) .setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI) .setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN) .setVisibleInDownloadsUi(false) .setTitle(update.buildNumber) .setDestinationUri(getDestinationUri()) .setDescription(update.buildNumber);

return dm.enqueue(requestDownload);

Game of loaders // Downloader

<uses- permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" /><uses ‐permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER" /><uses- permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED" />

<receiver android:name=".DownloadReceiver"> <intent- filter> <action android:name="android.intent.action.DOWNLOAD_COMPLETE" /> </intent ‐filter></receiver>

Game of loaders // Updater

Game of loaders // Updater// android.os.RecoverySystem

public static void installPackage (Context context, File packageFile)

public static void rebootWipeCache (Context context)

public static void rebootWipeUserData (Context context)

public static void verifyPackage (File packageFile,

RecoverySystem.ProgressListener listener, File deviceCertsZipFile)

Le jeu des loaders // Bootloader

Game of loaders // Recovery(er?)

Installing the update

After installing

<receiver android:name=".BootReceiver"> <intent-filter> <action android:name="android.intent.action.PRE_BOOT_COMPLETED" /> </intent-filter> </receiver>

Simple back-end

Industrial backend

Industrial backend

Industrial backend

Industrial backend

Branching your OTA

Device identification

Fragmentation

Version compatibility

Let´s have a look...

How did you find about all that ?!

What's next

Questions ?

POD //

[email protected]

Simon //

[email protected]