Back to project page androiddevice.info.
The source code is released under:
GNU General Public License
If you think the Android project androiddevice.info listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package info.androiddevice.deviceinventory.info; /* w w w . j a v a 2 s .c o m*/ import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.Signature; import org.json.JSONArray; import org.json.JSONObject; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; import info.androiddevice.deviceinventory.Application; import static info.androiddevice.deviceinventory.info.Utils.byteToHexString; public class PackageSigProperty implements Property { @Override public String getName() { return "package_signature"; } @Override public Object getProperty() { try { JSONArray result = new JSONArray(); PackageInfo packageInfo = Application.getContext().getPackageManager().getPackageInfo("android", PackageManager.GET_SIGNATURES); for(Signature item: Arrays.asList(packageInfo.signatures)) { MessageDigest digest = null; try { digest = MessageDigest.getInstance("SHA-256"); digest.update(item.toCharsString().getBytes()); result.put(byteToHexString(digest.digest())); } catch (NoSuchAlgorithmException e) {} } return result; } catch (PackageManager.NameNotFoundException e) { return JSONObject.NULL; } } }