Collector implementation to extract sha256_cert.

Extract sha256_cert from installed pachages.

Test: under master brahcnes,
- mmma cts/tools/cts-device-info
- adb uninstall com.android.compatibility.common.deviceinfo
- adb shell rm /sdcard/device-info-files/PackageDeviceInfo.deviceinfo.json
- adb install -r -g out/target/product/taimen/data/app/CtsDeviceInfo/CtsDeviceInfo.apk
- adb shell cat /sdcard/device-info-files/PackageDeviceInfo.deviceinfo.json
Confimed that sha256_cert fields are correctly populated.

Change-Id: I442174bdcbae9b157fca1ba0b82c4d4aaf8dc6af
(cherry picked from commit 0686839d7697806ce090ee27e8a62ffe5b33963a)

bug: 149089628
Change-Id: I442174bdcbae9b157fca1ba0b82c4d4aaf8dc6af
diff --git a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/PackageDeviceInfo.java b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/PackageDeviceInfo.java
index 5fc72f0..65b8d75 100644
--- a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/PackageDeviceInfo.java
+++ b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/PackageDeviceInfo.java
@@ -22,6 +22,7 @@
 import android.os.Build;
 import android.os.Process;
 import com.android.compatibility.common.util.DeviceInfoStore;
+import com.android.compatibility.common.util.PackageUtil;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -52,6 +53,7 @@
     private static final String SHARES_INSTALL_PERMISSION = "shares_install_packages_permission";
     private static final String INSTALL_PACKAGES_PERMISSION = "android.permission.INSTALL_PACKAGES";
 
+    private static final String SHA256_CERT = "sha256_cert";
 
     @Override
     protected void collectDeviceInfo(DeviceInfoStore store) throws Exception {
@@ -96,6 +98,8 @@
                 final boolean canInstall = sharesUidWithInstallerPackage(pm, appInfo.uid);
                 store.addResult(SHARES_INSTALL_PERMISSION, canInstall);
             }
+            String sha256_cert = PackageUtil.computePackageSignatureDigest(pkg.packageName);
+            store.addResult(SHA256_CERT, sha256_cert);
             store.endGroup();
         }
         store.endArray(); // "package"