From 35dc255180d2d84be7fdc86a3eecff05c33937d0 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Thu, 1 Feb 2018 13:18:00 -0800 Subject: [PATCH] releasetools: Add sdk and security patch level info to metadata. The info comes from the build.prop file of the target build (thus no backward compatibility concerns). OTA server and client can optionally use these info to understand the expected behavior of an OTA package. Bug: 72751683 Test: python -m unittest test_ota_from_target_files Test: `m dist`, then check the metadata in the generated OTA package. Change-Id: I5935f67684d2486bb5f00d67ce4bc756589a56ed --- tools/releasetools/ota_from_target_files.py | 4 ++++ .../releasetools/test_ota_from_target_files.py | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index 95b73033cd..c3d742e525 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -778,6 +778,10 @@ def GetPackageMetadata(target_info, source_info=None): 'post-build' : target_info.fingerprint, 'post-build-incremental' : target_info.GetBuildProp( 'ro.build.version.incremental'), + 'post-sdk-level' : target_info.GetBuildProp( + 'ro.build.version.sdk'), + 'post-security-patch-level' : target_info.GetBuildProp( + 'ro.build.version.security_patch'), } if target_info.is_ab: diff --git a/tools/releasetools/test_ota_from_target_files.py b/tools/releasetools/test_ota_from_target_files.py index fa6655b4fa..6f808e1b64 100644 --- a/tools/releasetools/test_ota_from_target_files.py +++ b/tools/releasetools/test_ota_from_target_files.py @@ -318,6 +318,8 @@ class OtaFromTargetFilesTest(unittest.TestCase): 'ro.product.device' : 'product-device', 'ro.build.fingerprint' : 'build-fingerprint-target', 'ro.build.version.incremental' : 'build-version-incremental-target', + 'ro.build.version.sdk' : '27', + 'ro.build.version.security_patch' : '2017-12-01', 'ro.build.date.utc' : '1500000000', }, } @@ -327,6 +329,8 @@ class OtaFromTargetFilesTest(unittest.TestCase): 'ro.product.device' : 'product-device', 'ro.build.fingerprint' : 'build-fingerprint-source', 'ro.build.version.incremental' : 'build-version-incremental-source', + 'ro.build.version.sdk' : '25', + 'ro.build.version.security_patch' : '2016-12-01', 'ro.build.date.utc' : '1400000000', }, } @@ -349,6 +353,8 @@ class OtaFromTargetFilesTest(unittest.TestCase): 'ota-required-cache' : '0', 'post-build' : 'build-fingerprint-target', 'post-build-incremental' : 'build-version-incremental-target', + 'post-sdk-level' : '27', + 'post-security-patch-level' : '2017-12-01', 'post-timestamp' : '1500000000', 'pre-device' : 'product-device', }, @@ -367,6 +373,8 @@ class OtaFromTargetFilesTest(unittest.TestCase): 'ota-required-cache' : '0', 'post-build' : 'build-fingerprint-target', 'post-build-incremental' : 'build-version-incremental-target', + 'post-sdk-level' : '27', + 'post-security-patch-level' : '2017-12-01', 'post-timestamp' : '1500000000', 'pre-device' : 'product-device', 'pre-build' : 'build-fingerprint-source', @@ -382,6 +390,8 @@ class OtaFromTargetFilesTest(unittest.TestCase): 'ota-type' : 'BLOCK', 'post-build' : 'build-fingerprint-target', 'post-build-incremental' : 'build-version-incremental-target', + 'post-sdk-level' : '27', + 'post-security-patch-level' : '2017-12-01', 'post-timestamp' : '1500000000', 'pre-device' : 'product-device', }, @@ -397,6 +407,8 @@ class OtaFromTargetFilesTest(unittest.TestCase): 'ota-type' : 'BLOCK', 'post-build' : 'build-fingerprint-target', 'post-build-incremental' : 'build-version-incremental-target', + 'post-sdk-level' : '27', + 'post-security-patch-level' : '2017-12-01', 'post-timestamp' : '1500000000', 'pre-device' : 'product-device', 'pre-build' : 'build-fingerprint-source', @@ -414,6 +426,8 @@ class OtaFromTargetFilesTest(unittest.TestCase): 'ota-wipe' : 'yes', 'post-build' : 'build-fingerprint-target', 'post-build-incremental' : 'build-version-incremental-target', + 'post-sdk-level' : '27', + 'post-security-patch-level' : '2017-12-01', 'post-timestamp' : '1500000000', 'pre-device' : 'product-device', }, @@ -457,6 +471,8 @@ class OtaFromTargetFilesTest(unittest.TestCase): 'ota-wipe' : 'yes', 'post-build' : 'build-fingerprint-target', 'post-build-incremental' : 'build-version-incremental-target', + 'post-sdk-level' : '27', + 'post-security-patch-level' : '2017-12-01', 'pre-device' : 'product-device', 'pre-build' : 'build-fingerprint-source', 'pre-build-incremental' : 'build-version-incremental-source', @@ -479,6 +495,8 @@ class OtaFromTargetFilesTest(unittest.TestCase): 'ota-type' : 'BLOCK', 'post-build' : 'build-fingerprint-target', 'post-build-incremental' : 'build-version-incremental-target', + 'post-sdk-level' : '27', + 'post-security-patch-level' : '2017-12-01', 'post-timestamp' : '1500000001', 'pre-device' : 'product-device', 'pre-build' : 'build-fingerprint-source',