Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
008c2d1
Give Atrium Enhanced a separate Android application identity
koinupapi Nov 27, 2026
aeb7536
Add opt-in signed APK build and release workflow
koinupapi Nov 27, 2026
82f65f9
Test signed APK release pipeline [build apk]
koinupapi Nov 27, 2026
637a97a
Distinguish Enhanced launcher with Bastion blue background
koinupapi Nov 27, 2026
555869c
Modernize build actions and cache Gradle dependencies
koinupapi Nov 27, 2026
7952790
Preserve Enhanced blue when regenerating launcher icons
koinupapi Nov 27, 2026
e8a4f46
Scope updater file sharing to private update cache
koinupapi Nov 27, 2026
e1be157
Declare Android update installer permission and scoped provider
koinupapi Nov 27, 2026
8426158
Expose installed build and scoped Android installer to Flutter updater
koinupapi Nov 27, 2026
a93728b
Add branch-aware Enhanced release discovery and diagnostics
koinupapi Nov 28, 2026
546aa75
Implement cancellable APK download and SHA-256 verification via Andro…
koinupapi Nov 28, 2026
c19a984
Verify downloaded APK digest off the Android UI thread
koinupapi Nov 28, 2026
8bf3781
Extend existing Riverpod update checker for Enhanced build channels
koinupapi Nov 28, 2026
45d472d
Support numeric build availability in existing update state
koinupapi Nov 28, 2026
17cd045
Expose update channels, diagnostics, download progress and installati…
koinupapi Nov 28, 2026
b6737bb
Persist release metadata separately for each update channel
koinupapi Nov 28, 2026
7ca33d8
Test Enhanced release parsing and numeric channel selection
koinupapi Nov 28, 2026
068a60e
Add opt-in updater validation without publishing an APK [validate upd…
koinupapi Nov 28, 2026
61b23b2
Update widget fixtures for branch-aware updater settings [validate up…
koinupapi Nov 28, 2026
4c585ec
Build first updater-enabled signed APK [build apk]
koinupapi Nov 28, 2026
1e13fcc
Publish second device-test APK for end-to-end in-app update [build apk]
koinupapi Nov 28, 2026
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
75 changes: 75 additions & 0 deletions .github/workflows/enhanced-apk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Build Atrium Enhanced APK
on:
workflow_dispatch:
push:
branches:
- rmg
- 'feature/**'
- 'fix/**'
- 'refactor/**'
permissions:
contents: write
jobs:
build:
if: github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[build apk]')
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '17'
cache: gradle
cache-dependency-path: |
app/android/**/*.gradle*
app/android/gradle/wrapper/gradle-wrapper.properties
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.41.9'
channel: stable
cache: true
pub-cache: true
- name: Restore release signing credentials
env:
KEYSTORE: ${{ secrets.ATRIUM_KEYSTORE_BASE64 }}
STORE_PASSWORD: ${{ secrets.ATRIUM_KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.ATRIUM_KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.ATRIUM_KEY_PASSWORD }}
run: |
set -eu
test -n "$KEYSTORE" && test -n "$STORE_PASSWORD" && test -n "$KEY_ALIAS" && test -n "$KEY_PASSWORD"
printf '%s' "$KEYSTORE" | base64 --decode > "$RUNNER_TEMP/atrium-release.jks"
chmod 600 "$RUNNER_TEMP/atrium-release.jks"
printf 'storeFile=%s\nstorePassword=%s\nkeyAlias=%s\nkeyPassword=%s\n' "$RUNNER_TEMP/atrium-release.jks" "$STORE_PASSWORD" "$KEY_ALIAS" "$KEY_PASSWORD" > app/android/key.properties
chmod 600 app/android/key.properties
- name: Resolve dependencies
working-directory: app
run: |
flutter config --no-analytics
flutter pub get --enforce-lockfile
- name: Generate sources
run: dart run tool/build_all.dart
# Build 19 passed installation and channel discovery; next release tests in-app installation.
- name: Build signed universal APK
working-directory: app
run: flutter build apk --release --build-number="$GITHUB_RUN_NUMBER"
- name: Verify APK signature
run: |
APKSIGNER="$(find "$ANDROID_HOME/build-tools" -name apksigner -type f | sort -V | tail -n 1)"
"$APKSIGNER" verify --print-certs app/build/app/outputs/flutter-apk/app-release.apk
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
run: |
set -eu
APK="Atrium-Enhanced-${GITHUB_RUN_NUMBER}.apk"
cp app/build/app/outputs/flutter-apk/app-release.apk "$APK"
printf 'Branch: %s\nBuild: %s\nCommit: %s\n' "$GITHUB_REF_NAME" "$GITHUB_RUN_NUMBER" "$GITHUB_SHA" > release-notes.txt
if [ "$GITHUB_REF_NAME" = rmg ]; then
gh release create "enhanced-$GITHUB_RUN_NUMBER" "$APK" --target "$GITHUB_SHA" --title "Atrium Enhanced build $GITHUB_RUN_NUMBER" --notes-file release-notes.txt
else
gh release create "enhanced-$GITHUB_RUN_NUMBER" "$APK" --target "$GITHUB_SHA" --prerelease --title "Atrium Enhanced test build $GITHUB_RUN_NUMBER" --notes-file release-notes.txt
fi
- name: Remove signing material
if: always()
run: rm -f app/android/key.properties "$RUNNER_TEMP/atrium-release.jks"
28 changes: 28 additions & 0 deletions .github/workflows/enhanced-validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Validate Enhanced updater
on:
workflow_dispatch:
push:
branches:
- 'feature/**'
- 'fix/**'
- rmg
permissions:
contents: read
jobs:
validate:
if: github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[validate updater]')
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.41.9'
channel: stable
cache: true
- run: flutter pub get --enforce-lockfile
working-directory: app
- run: dart run tool/build_all.dart
- run: dart analyze lib/src/update_check
working-directory: app
- run: flutter test test/update_check
working-directory: app
4 changes: 2 additions & 2 deletions app/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ android {
}

defaultConfig {
applicationId = "app.atrium"
applicationId = "com.koinupapi.atrium.enhanced"
// local_auth + flutter_secure_storage need API 23+ (BiometricPrompt,
// EncryptedSharedPreferences). Floor at 23 regardless of Flutter's
// default.
Expand All @@ -61,7 +61,7 @@ android {
val appNameProp = if (project.hasProperty("appName")) {
project.property("appName") as String
} else {
"Atrium"
"Atrium Enhanced"
}
manifestPlaceholders["appName"] = appNameProp
}
Expand Down
10 changes: 10 additions & 0 deletions app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<!-- Optional biometric unlock (opt-in, gated in-app). -->
<uses-permission android:name="android.permission.USE_BIOMETRIC"/>

<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>

<application
android:label="${appName}"
android:name="${applicationName}"
Expand All @@ -16,6 +18,14 @@
<!-- usesCleartextTraffic: self-hosted LAN services are commonly plain
http:// on a private IP. allowBackup=false keeps credential
material out of cloud/adb backups. -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.updates"
android:exported="false"
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/enhanced_update_paths" />
</provider>
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
56 changes: 56 additions & 0 deletions app/android/app/src/main/kotlin/app/atrium/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,62 @@ class MainActivity : FlutterFragmentActivity() {
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)

MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "app.atrium/enhanced_updates").setMethodCallHandler { call, result ->
try {
when (call.method) {
"installedBuild" -> {
@Suppress("DEPRECATION")
val info = packageManager.getPackageInfo(packageName, 0)
@Suppress("DEPRECATION")
val version = if (Build.VERSION.SDK_INT >= 28) info.longVersionCode else info.versionCode.toLong()
result.success(version)
}
"cacheDirectory" -> result.success(java.io.File(cacheDir, "updates").apply { mkdirs() }.absolutePath)
"sha256" -> {
val directory = java.io.File(cacheDir, "updates").canonicalFile
val file = java.io.File(requireNotNull(call.argument<String>("path"))).canonicalFile
require(file.parentFile == directory && file.isFile)
Thread {
try {
val digest = java.security.MessageDigest.getInstance("SHA-256")
file.inputStream().use { input ->
val buffer = ByteArray(65536)
while (true) {
val count = input.read(buffer)
if (count < 0) break
digest.update(buffer, 0, count)
}
}
val hash = digest.digest().joinToString("") { "%02x".format(it) }
runOnUiThread { result.success(hash) }
} catch (e: Exception) {
runOnUiThread { result.error("HASH_ERROR", e.message, null) }
}
}.start()
}
"install" -> {
val directory = java.io.File(cacheDir, "updates").canonicalFile
val file = java.io.File(requireNotNull(call.argument<String>("path"))).canonicalFile
require(file.parentFile == directory && file.extension == "apk" && file.isFile)
if (Build.VERSION.SDK_INT >= 26 && !packageManager.canRequestPackageInstalls()) {
startActivity(Intent(android.provider.Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, Uri.parse("package:$packageName")))
result.success(false)
} else {
val uri = androidx.core.content.FileProvider.getUriForFile(this, "$packageName.updates", file)
startActivity(Intent(Intent.ACTION_VIEW).apply {
setDataAndType(uri, "application/vnd.android.package-archive")
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
})
result.success(true)
}
}
else -> result.notImplemented()
}
} catch (e: Exception) {
result.error("UPDATE_ERROR", e.message, null)
}
}

pendingShareIntent = intent

shareChannel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, SHARE_CHANNEL).apply {
Expand Down
4 changes: 2 additions & 2 deletions app/android/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#6750A4</color>
</resources>
<color name="ic_launcher_background">#243A67</color>
</resources>
4 changes: 4 additions & 0 deletions app/android/app/src/main/res/xml/enhanced_update_paths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<cache-path name="updates" path="updates/" />
</paths>
40 changes: 40 additions & 0 deletions app/lib/src/update_check/enhanced_download.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/services.dart';
import 'enhanced_release.dart';

class EnhancedDownload {
static const channel = MethodChannel('app.atrium/enhanced_updates');
static Future<int> installedBuild() async =>
(await channel.invokeMethod<int>('installedBuild'))!;
static Future<bool> install(String path) async =>
(await channel.invokeMethod<bool>('install', {'path': path})) ?? false;

Future<String> download(EnhancedRelease release, CancelToken token,
void Function(int, int) progress) async {
final directory = (await channel.invokeMethod<String>('cacheDirectory'))!;
final target = File('$directory/Atrium-Enhanced-${release.build}.apk');
final part = File('${target.path}.part');
final dio = Dio(BaseOptions(connectTimeout: const Duration(seconds: 15),
receiveTimeout: const Duration(seconds: 60)));
try {
await dio.download(release.url, part.path, cancelToken: token,
onReceiveProgress: progress);
final size = await part.length();
if (size == 0 || (release.size > 0 && size != release.size)) {
throw StateError('APK size mismatch');
}
if (release.digest.isNotEmpty) {
final actual = await channel.invokeMethod<String>('sha256', {'path': part.path});
if ('sha256:$actual' != release.digest.toLowerCase()) {
throw StateError('APK checksum mismatch');
}
}
if (token.isCancelled) throw StateError('Download cancelled');
return (await part.rename(target.path)).path;
} finally {
dio.close(force: true);
if (await part.exists()) await part.delete();
}
}
}
75 changes: 75 additions & 0 deletions app/lib/src/update_check/enhanced_release.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import 'package:dio/dio.dart';

class EnhancedRelease {
const EnhancedRelease(this.build, this.branch, this.url, this.page,
this.digest, this.notes, this.date, this.size);
final int build;
final String branch, url, page, digest, notes, date;
final int size;

static EnhancedRelease? parse(Map<String, dynamic> data) {
if (data['draft'] == true) return null;
final match = RegExp(r'^enhanced-(\d+)$').firstMatch(data['tag_name'] as String? ?? '');
if (match == null) return null;
final build = int.parse(match.group(1)!);
final notes = data['body'] as String? ?? '';
final branch = RegExp(r'^Branch: (.+)$', multiLine: true).firstMatch(notes)?.group(1)?.trim();
if (branch == null || !allowedBranch(branch)) return null;
for (final raw in data['assets'] as List? ?? []) {
final asset = Map<String, dynamic>.from(raw as Map);
if (asset['name'] != 'Atrium-Enhanced-$build.apk') continue;
final url = asset['browser_download_url'] as String? ?? '';
if (url != 'https://github.com/koinupapi/Atrium-Enhanced/releases/download/enhanced-$build/Atrium-Enhanced-$build.apk') continue;
return EnhancedRelease(build, branch, url, data['html_url'] as String? ?? '',
asset['digest'] as String? ?? '', notes, data['published_at'] as String? ?? '',
asset['size'] as int? ?? 0);
}
return null;
}

static bool allowedBranch(String branch) => branch == 'rmg' ||
['feature/', 'fix/', 'refactor/'].any(branch.startsWith);
}

class EnhancedReleaseRepository {
EnhancedReleaseRepository(this.dio);
final Dio dio;
static const repo = 'repos/koinupapi/Atrium-Enhanced';

Future<List<dynamic>> _pages(String endpoint) async {
final items = <dynamic>[];
for (var page = 1; ; page++) {
final response = await dio.get<List<dynamic>>('$repo/$endpoint',
queryParameters: {'per_page': 100, 'page': page});
final batch = response.data ?? [];
items.addAll(batch);
if (batch.length < 100) return items;
}
}

Future<List<String>> branches() async {
final names = (await _pages('branches')).map((e) => e['name'] as String)
.where(EnhancedRelease.allowedBranch).toSet()..add('rmg');
return names.toList()..sort((a,b) => a == b ? 0 : a == 'rmg' ? -1 : b == 'rmg' ? 1 : a.compareTo(b));
}

Future<EnhancedRelease?> latest(String branch) async {
final releases = (await _pages('releases'))
.map((e) => EnhancedRelease.parse(Map<String,dynamic>.from(e as Map)))
.whereType<EnhancedRelease>().where((e) => e.branch == branch).toList()
..sort((a,b) => b.build.compareTo(a.build));
return releases.isEmpty ? null : releases.first;
}

static String describeError(Object error) {
if (error is DioException) {
final response = error.response;
final reset = int.tryParse(response?.headers.value('x-ratelimit-reset') ?? '');
if (response?.headers.value('x-ratelimit-remaining') == '0' && reset != null) {
return 'GitHub rate limit reached. Retry after ${DateTime.fromMillisecondsSinceEpoch(reset * 1000).toLocal()}.';
}
return 'GitHub request failed: ${response?.statusCode ?? error.type.name}';
}
return error.toString();
}
}
5 changes: 4 additions & 1 deletion app/lib/src/update_check/update_check_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class UpdateCheckState {
this.checkedAt,
this.latestNotes,
this.latestDate,
this.newerBuild,
});

final UpdateStatus status;
Expand All @@ -30,10 +31,11 @@ class UpdateCheckState {
final DateTime? checkedAt;
final String? latestNotes;
final String? latestDate;
final bool? newerBuild;

/// True when the last known latest release is newer than the running app.
bool get hasNewer =>
latestVersion != null && compareVersions(latestVersion!, appVersion) > 0;
newerBuild ?? (latestVersion != null && compareVersions(latestVersion!, appVersion) > 0);

UpdateCheckState copyWith({UpdateStatus? status}) => UpdateCheckState(
status: status ?? this.status,
Expand All @@ -42,5 +44,6 @@ class UpdateCheckState {
checkedAt: checkedAt,
latestNotes: latestNotes,
latestDate: latestDate,
newerBuild: newerBuild,
);
}
Loading
Loading