[Android] Display the app signer in the about bottom sheet
Nicolas Pomepuy
git at videolan.org
Mon Oct 7 11:45:24 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Oct 7 11:25:49 2024 +0200| [fbf1472a42b02517a3c860ab3bda43d173830667] | committer: Duncan McNamara
Display the app signer in the about bottom sheet
> https://code.videolan.org/videolan/vlc-android/commit/fbf1472a42b02517a3c860ab3bda43d173830667
---
.../resources/src/main/res/values/strings.xml | 1 +
.../res/layout/dialog_about_version.xml | 25 +++++++++++-
.../videolan/vlc/gui/dialogs/AboutVersionDialog.kt | 44 ++++++++++++++++++++++
3 files changed, 69 insertions(+), 1 deletion(-)
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 8a4fdf618b..a1b3d03224 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -293,6 +293,7 @@
<string name="about_license_text" translatable="false"></string>
<string name="vlc_authors">and VLC Authors.</string>
<string name="is_compiled_by">Compiled by</string>
+ <string name="is_signed_by">Signed by</string>
<string name="sources">Source code</string>
<string name="libraries">Libraries</string>
<string name="feedback_forum">Feedback forum</string>
diff --git a/application/vlc-android/res/layout/dialog_about_version.xml b/application/vlc-android/res/layout/dialog_about_version.xml
index 55a5f6d897..f1e61e69da 100644
--- a/application/vlc-android/res/layout/dialog_about_version.xml
+++ b/application/vlc-android/res/layout/dialog_about_version.xml
@@ -105,6 +105,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/compiled_by" />
+ <TextView
+ android:id="@+id/textView31"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:text="@string/is_signed_by"
+ android:textColor="?attr/font_light"
+ app:layout_constraintBottom_toBottomOf="@+id/signed_by"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="@+id/signed_by" />
+
<View
android:id="@+id/divider"
android:layout_width="0dp"
@@ -113,7 +124,7 @@
android:background="?attr/default_divider"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/compiled_by" />
+ app:layout_constraintTop_toBottomOf="@+id/signed_by" />
<TextView
android:id="@+id/textView29"
@@ -219,6 +230,18 @@
app:layout_constraintTop_toBottomOf="@+id/revision"
tools:text="Gitlab runner" />
+ <TextView
+ android:id="@+id/signed_by"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="24dp"
+ android:layout_marginTop="4dp"
+ android:textColor="?attr/font_default"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@+id/compilation_barrier"
+ app:layout_constraintTop_toBottomOf="@+id/compiled_by"
+ tools:text="VideoLAN" />
+
<TextView
android:id="@+id/remote_access_version"
android:layout_width="0dp"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/AboutVersionDialog.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/AboutVersionDialog.kt
index 2b8f7586fb..712ca7c990 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/AboutVersionDialog.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/AboutVersionDialog.kt
@@ -21,7 +21,10 @@
*/
package org.videolan.vlc.gui.dialogs
+import android.content.pm.PackageManager
+import android.os.Build
import android.os.Bundle
+import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -29,6 +32,8 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_EXPANDE
import org.videolan.vlc.BuildConfig
import org.videolan.vlc.R
import org.videolan.vlc.databinding.DialogAboutVersionBinding
+import java.security.MessageDigest
+
/**
* Dialog showing the info of the current version
@@ -77,6 +82,45 @@ class AboutVersionDialog : VLCBottomSheetDialogFragment() {
whatsNewDialog.show(requireActivity().supportFragmentManager, "fragment_whats_new")
dismiss()
}
+
+
+ val signatures =
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) requireActivity().packageManager.getPackageInfo(
+ requireActivity().packageName,
+ PackageManager.GET_SIGNATURES
+ ).signatures
+ else
+ requireActivity().packageManager.getPackageInfo(
+ requireActivity().packageName,
+ PackageManager.GET_SIGNING_CERTIFICATES
+ ).signingInfo.apkContentsSigners
+ var signer = requireActivity().getString(R.string.unknown)
+ signatures.forEach {
+ try {
+ val md = MessageDigest.getInstance("SHA1")
+ md.update(it.toByteArray())
+
+ val digest = md.digest()
+ val toRet = java.lang.StringBuilder()
+ for (i in digest.indices) {
+ if (i != 0) toRet.append(":")
+ val b = digest[i].toInt() and 0xff
+ val hex = Integer.toHexString(b)
+ if (hex.length == 1) toRet.append("0")
+ toRet.append(hex)
+ }
+ when (toRet.toString().uppercase()) {
+ "AC:5A:BC:F1:99:AC:86:61:6A:79:65:CB:84:59:94:89:A5:A7:3F:86" -> signer = "VideoLAN nightly"
+ "4D:D5:44:A7:51:D3:D5:4C:17:D8:7E:1D:D3:60:F0:C6:40:A5:C1:50" -> signer = "Google"
+ "EE:FB:C9:81:42:83:43:BB:DD:FF:F6:B2:3B:6B:D8:71:73:51:41:0C" -> signer = "VideoLAN"
+ "40:80:86:F9:AE:A6:52:A8:61:44:70:4F:11:79:9A:CA:BA:31:C7:A0" -> signer = "F-Droid"
+ }
+ Log.i(this::class.java.simpleName, "Found signature. Fingerprint: $toRet")
+ } catch (e: Exception) {
+ Log.e("Signature",e.message, e)
+ }
+ }
+ binding.signedBy.text = signer
}
More information about the Android
mailing list