delete CloudKit and added BalanceFlutter
Android CI / Build and Test (push) Failing after 21m18s
iOS CI / Build and Test SwiftUI App (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build Unsigned iOS IPA (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build macOS ZIP (push) Canceled after 0s
Android CI / Build and Test (push) Failing after 21m18s
iOS CI / Build and Test SwiftUI App (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build Unsigned iOS IPA (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build macOS ZIP (push) Canceled after 0s
This commit is contained in:
1 parent
a715eca947
commit
2c278044bb
214 files changed
+13411
-2290
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'runtime_lock_stub.dart'
|
||||
if (dart.library.js_interop) 'runtime_lock_web.dart'
|
||||
as browser;
|
||||
|
||||
/// Native Android lock shared by the UI engine and WorkManager headless engines.
|
||||
/// Callers must hold it over reloading preferences/session, ledger IO and sync.
|
||||
class RuntimeLock {
|
||||
static const _channel = MethodChannel('balance/runtime');
|
||||
final _browserLock = browser.BrowserRuntimeLock();
|
||||
String? _token;
|
||||
bool get _android =>
|
||||
!kIsWeb && defaultTargetPlatform == TargetPlatform.android;
|
||||
|
||||
Future<void> acquire() async {
|
||||
if (kIsWeb) return _browserLock.acquire();
|
||||
if (!_android) return;
|
||||
if (_token != null) throw StateError('Ledger lock is already held');
|
||||
final token = await _channel.invokeMethod<String>('acquireLock');
|
||||
if (token == null || token.isEmpty) {
|
||||
throw StateError('Native ledger lock returned no ownership token');
|
||||
}
|
||||
_token = token;
|
||||
}
|
||||
|
||||
Future<void> release() async {
|
||||
if (kIsWeb) return _browserLock.release();
|
||||
if (!_android) return;
|
||||
final token = _token;
|
||||
if (token == null) throw StateError('Ledger lock is not held');
|
||||
await _channel.invokeMethod<void>('releaseLock', {'token': token});
|
||||
_token = null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user