Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@
"googleVerificationWarningP1": "Google has announced that, starting in 2026/2027, all apps on \"certified\" Android devices will require the developer to submit personal identity details directly to Google.\n\nSince the developers of this app do not agree to this requirement, Obtainium will no longer work on certified Android devices after that time.",
"googleVerificationWarningP2": "Go to https://keepandroidopen.org/ for more information.",
"googleVerificationWarningP3": "Note that in the short term, it may continue to be possible to install \"unverified\" (non-compliant) apps through an \"advanced flow\" process that Google has promised to implement after broad backlash to their announcement, but they have not detailed how this would work so it is unclear whether it will truly preserve user freedoms in any practical way.\n\nIn any case, Google's move is a significant step towards the end of free, general-purpose computing for individuals.\n\nNon-certified OSes, like GrapheneOS, should be unaffected by this for as long as they are allowed to continue to exist.",
"multipleSigners": "Multiple Signers",
"removeAppQuestion": {
"one": "Remove app?",
"other": "Remove apps?"
Expand Down Expand Up @@ -401,5 +402,9 @@
"apk": {
"one": "{} APK",
"other": "{} APKs"
},
"certificateHash": {
"one": "Certificate Hash",
"other": "Certificate Hashes"
}
}
69 changes: 69 additions & 0 deletions lib/pages/app.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:crypto/crypto.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand All @@ -14,6 +15,7 @@ import 'package:url_launcher/url_launcher_string.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:provider/provider.dart';
import 'package:markdown/markdown.dart' as md;
import 'package:android_package_manager/android_package_manager.dart' hide LaunchMode;

class AppPage extends StatefulWidget {
const AppPage({
Expand All @@ -34,6 +36,36 @@ class _AppPageState extends State<AppPage> {
bool _wasWebViewOpened = false;
AppInMemory? prevApp;
bool updating = false;
bool hasMultipleSigners = false;
List<String> certificateHashes = [];

Future<void> _loadAppHashes() async {
final AndroidPackageManager pm = AndroidPackageManager();

final packageInfo = await pm.getPackageInfo(
packageName: prevApp?.app.id as String,
flags: PackageInfoFlags({PMFlag.getSigningCertificates})
);

final multipleSigners = packageInfo?.signingInfo?.hasMultipleSigners ?? false;

// https://developer.android.com/reference/android/content/pm/SigningInfo#getApkContentsSigners()
final signatures = hasMultipleSigners ?
packageInfo?.signingInfo?.apkContentSigners :
packageInfo?.signingInfo?.signingCertificateHistory;

final hashes = signatures?.map((signature) {
final digest = sha256.convert(signature);
return digest.bytes
.map((b) => b.toRadixString(16).padLeft(2, '0').toUpperCase())
.join(':');
}).toList() ?? [];

setState(() {
hasMultipleSigners = multipleSigners;
certificateHashes = hashes;
});
}

@override
void initState() {
Expand Down Expand Up @@ -110,6 +142,7 @@ class _AppPageState extends State<AppPage> {
app != null &&
settingsProvider.checkUpdateOnDetailPage) {
prevApp = app;
_loadAppHashes();
getUpdate(app.app.id);
}
var trackOnly = app?.app.additionalSettings['trackOnly'] == true;
Expand Down Expand Up @@ -256,6 +289,42 @@ class _AppPageState extends State<AppPage> {
],
),
),

/* Certificate Hashes */
if (installed && certificateHashes.isNotEmpty) Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: 48),
Text(
"${plural('certificateHash', certificateHashes.length)}"
"${hasMultipleSigners ? " (${tr('multipleSigners')})" : ""}",
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 13),
),
Column(
mainAxisSize: MainAxisSize.min,
children: certificateHashes.map((hash) {
return GestureDetector(
onLongPress: () {
Clipboard.setData(ClipboardData(text: hash));
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(tr('copiedToClipboard'))),
);
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 25,vertical: 5),
child: Text(
hash,
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 14),
),
),
);
}).toList(),
),
],
),

const SizedBox(height: 48),
CategoryEditorSelector(
alignment: WrapAlignment.center,
Expand Down