mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-02-04 09:14:10 +01:00
fix: Start on Android and Linux
This commit is contained in:
parent
6b5a121318
commit
28cfb6e5f9
1
android/app/proguard-rules.pro
vendored
1
android/app/proguard-rules.pro
vendored
@ -7,3 +7,4 @@
|
|||||||
-keep class io.flutter.** { *; }
|
-keep class io.flutter.** { *; }
|
||||||
-keep class io.flutter.plugins.** { *; }
|
-keep class io.flutter.plugins.** { *; }
|
||||||
-dontwarn io.flutter.embedding.**
|
-dontwarn io.flutter.embedding.**
|
||||||
|
-keep class net.sqlcipher.** { *; }
|
@ -10,6 +10,7 @@ import 'package:encrypt/encrypt.dart';
|
|||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
import 'package:sqflite_common_ffi/sqflite_ffi.dart' as ffi;
|
||||||
import 'package:sqflite_sqlcipher/sqflite.dart' as sqflite;
|
import 'package:sqflite_sqlcipher/sqflite.dart' as sqflite;
|
||||||
|
|
||||||
class FlutterFluffyBoxDatabase extends FluffyBoxDatabase {
|
class FlutterFluffyBoxDatabase extends FluffyBoxDatabase {
|
||||||
@ -27,26 +28,25 @@ class FlutterFluffyBoxDatabase extends FluffyBoxDatabase {
|
|||||||
static Future<FluffyBoxDatabase> databaseBuilder(Client client) async {
|
static Future<FluffyBoxDatabase> databaseBuilder(Client client) async {
|
||||||
Logs().d('Open FluffyBox...');
|
Logs().d('Open FluffyBox...');
|
||||||
String? password;
|
String? password;
|
||||||
try {
|
if (!kIsWeb && (Platform.isAndroid || Platform.isIOS)) {
|
||||||
// Workaround for secure storage is calling Platform.operatingSystem on web
|
try {
|
||||||
if (kIsWeb) throw MissingPluginException();
|
const secureStorage = FlutterSecureStorage();
|
||||||
|
final containsEncryptionKey =
|
||||||
|
await secureStorage.containsKey(key: _cipherStorageKey);
|
||||||
|
if (!containsEncryptionKey) {
|
||||||
|
final key = SecureRandom(_cipherStorageKeyLength).base64;
|
||||||
|
await secureStorage.write(
|
||||||
|
key: _cipherStorageKey,
|
||||||
|
value: key,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const secureStorage = FlutterSecureStorage();
|
// workaround for if we just wrote to the key and it still doesn't exist
|
||||||
final containsEncryptionKey =
|
password = await secureStorage.read(key: _cipherStorageKey);
|
||||||
await secureStorage.containsKey(key: _cipherStorageKey);
|
if (password == null) throw MissingPluginException();
|
||||||
if (!containsEncryptionKey) {
|
} on MissingPluginException catch (_) {
|
||||||
final key = SecureRandom(_cipherStorageKeyLength).base64;
|
Logs().i('FluffyBox encryption is not supported on this platform');
|
||||||
await secureStorage.write(
|
|
||||||
key: _cipherStorageKey,
|
|
||||||
value: key,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// workaround for if we just wrote to the key and it still doesn't exist
|
|
||||||
password = await secureStorage.read(key: _cipherStorageKey);
|
|
||||||
if (password == null) throw MissingPluginException();
|
|
||||||
} on MissingPluginException catch (_) {
|
|
||||||
Logs().i('FluffyBox encryption is not supported on this platform');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final db = FluffyBoxDatabase(
|
final db = FluffyBoxDatabase(
|
||||||
@ -63,7 +63,18 @@ class FlutterFluffyBoxDatabase extends FluffyBoxDatabase {
|
|||||||
String? password,
|
String? password,
|
||||||
) async {
|
) async {
|
||||||
final path = await _findDatabasePath(client);
|
final path = await _findDatabasePath(client);
|
||||||
return await sqflite.openDatabase(path, password: password);
|
try {
|
||||||
|
if (Platform.isAndroid || Platform.isIOS) {
|
||||||
|
//opensqflite.open.overrideFor(sqlite3.OperatingSystem.android, openCipherOnAndroid);
|
||||||
|
final db = await sqflite.openDatabase(path, password: password);
|
||||||
|
return db;
|
||||||
|
}
|
||||||
|
final db = await ffi.databaseFactoryFfi.openDatabase(path);
|
||||||
|
return db;
|
||||||
|
} catch (_) {
|
||||||
|
File(path).delete();
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<String> _findDatabasePath(Client client) async {
|
static Future<String> _findDatabasePath(Client client) async {
|
||||||
|
@ -1319,7 +1319,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1+1"
|
version: "2.0.1+1"
|
||||||
sqflite_common_ffi:
|
sqflite_common_ffi:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: sqflite_common_ffi
|
name: sqflite_common_ffi
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
@ -1332,6 +1332,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.1.0"
|
||||||
|
sqlcipher_flutter_libs:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: sqlcipher_flutter_libs
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.5.1"
|
||||||
sqlite3:
|
sqlite3:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -67,7 +67,9 @@ dependencies:
|
|||||||
sentry: ^6.0.1
|
sentry: ^6.0.1
|
||||||
share: ^2.0.4
|
share: ^2.0.4
|
||||||
slugify: ^2.0.0
|
slugify: ^2.0.0
|
||||||
|
sqflite_common_ffi: ^2.1.0
|
||||||
sqflite_sqlcipher: ^2.1.0
|
sqflite_sqlcipher: ^2.1.0
|
||||||
|
sqlcipher_flutter_libs: ^0.5.1
|
||||||
swipe_to_action: ^0.2.0
|
swipe_to_action: ^0.2.0
|
||||||
uni_links: ^0.5.1
|
uni_links: ^0.5.1
|
||||||
unifiedpush: ^1.0.6
|
unifiedpush: ^1.0.6
|
||||||
|
@ -67,6 +67,8 @@ parts:
|
|||||||
stage-packages:
|
stage-packages:
|
||||||
- libsecret-1-dev
|
- libsecret-1-dev
|
||||||
- libjsoncpp-dev
|
- libjsoncpp-dev
|
||||||
|
- libsqlite3-0
|
||||||
|
- libsqlite3-dev
|
||||||
gnome-3-28-extension:
|
gnome-3-28-extension:
|
||||||
build-packages:
|
build-packages:
|
||||||
- gcc
|
- gcc
|
||||||
|
Loading…
Reference in New Issue
Block a user