Browse Source

upgrade to sdk 29

master
fuwa 1 year ago
parent
commit
e9cbeae179
  1. 2
      .gitignore
  2. 8
      README.md
  3. 4
      cyberwow/android/app/build.gradle
  4. 2
      cyberwow/android/app/src/main/kotlin/org/wownero/cyberwow/MainActivity.kt
  5. 1
      cyberwow/lib/config.dart
  6. 2
      cyberwow/lib/config/cyberwow.dart
  7. 49
      cyberwow/lib/controller/process/deploy.dart
  8. 5
      cyberwow/lib/controller/process/run.dart
  9. 45
      cyberwow/lib/logic/sensor/helper.dart
  10. 12
      cyberwow/lib/main.dart
  11. 23
      cyberwow/lib/state/loading.dart
  12. 35
      cyberwow/pubspec.lock
  13. 3
      cyberwow/pubspec.yaml

2
.gitignore

@ -8,3 +8,5 @@ git/
flutter_export_environment.sh
.flutter-plugins-dependencies
*.so

8
README.md

@ -47,13 +47,11 @@ popd
git clone https://github.com/wownero/cyberwow/
cd cyberwow
mkdir -p cyberwow/native/output/arm64
mkdir -p cyberwow/native/output/x86_64
mkdir -p cyberwow/android/app/src/main/jniLibs/arm64-v8a
# Copy wownerod that we just built
cp $PATH_TO_WOWNEROD cyberwow/native/output/arm64/
# Generate a dummy x86_64 bin
touch cyberwow/native/output/x86_64/wownerod
cp $PATH_TO_WOWNEROD \
cyberwow/android/app/src/main/jniLibs/arm64-v8a/libwownerod.so
make build
```

4
cyberwow/android/app/build.gradle

@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
compileSdkVersion 29
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
@ -40,7 +40,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "org.wownero.cyberwow"
minSdkVersion 26
targetSdkVersion 28
targetSdkVersion 29
versionCode 23
versionName "0.7.0.0-j"
}

2
cyberwow/android/app/src/main/kotlin/org/wownero/cyberwow/MainActivity.kt

@ -30,6 +30,8 @@ class MainActivity: FlutterActivity() {
call, result ->
if (call.method == "getInitialIntent") {
result.success(initialIntentText)
} else if (call.method == "getBinaryDir") {
result.success(getApplicationInfo().nativeLibraryDir)
} else {
result.notImplemented()
}

1
cyberwow/lib/config.dart

@ -36,4 +36,5 @@ const emuHost = '192.168.10.100';
const host = isEmu ? emuHost : '127.0.0.1';
const stdoutLineBufferSize = 100;
const bannerShownKey = 'banner-shown';

2
cyberwow/lib/config/cyberwow.dart

@ -81,7 +81,7 @@ final _theme = ThemeData
final config = CryptoConfig
(
'wownerod',
'libwownerod.so',
'wownerod',
'Follow the white rabbit.',
70,

49
cyberwow/lib/controller/process/deploy.dart

@ -1,49 +0,0 @@
/*
Copyright 2019 fuwa
This file is part of CyberWOW.
CyberWOW is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CyberWOW is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with CyberWOW. If not, see <https://www.gnu.org/licenses/>.
*/
import 'dart:io';
import 'dart:async';
import 'dart:convert';
import 'package:flutter/services.dart';
import '../helper.dart';
Stream<String> deployBinary
(
final AssetBundle bundle,
final String path,
final String name
) async* {
final binData = await bundle.load(path);
final newPath = await getBinaryPath(name);
yield 'output binary path: $newPath\n';
final inputBytes = binData.buffer.asUint8List();
final outputFile = await new File(newPath).writeAsBytes(inputBytes);
final chmodResult = await Process.run('chmod', ['u+x', newPath]);
yield chmodResult.stderr + '\n';
final outputStat = await outputFile.stat();
yield outputStat.toString() + '\n';
}

5
cyberwow/lib/controller/process/run.dart

@ -29,6 +29,7 @@ import 'dart:convert';
import '../helper.dart';
import '../../config.dart' as config;
import '../../logging.dart';
import '../../logic/sensor/helper.dart' as helper;
typedef ShouldExit = bool Function();
@ -40,7 +41,7 @@ Stream<String> runBinary
final List<String> userArgs = const [],
}
) async* {
final newPath = await getBinaryPath(name);
final binPath = await helper.getBinaryPath(name);
final appDocDir = await getApplicationDocumentsDirectory();
final appDocPath = appDocDir.path;
@ -66,7 +67,7 @@ Stream<String> runBinary
log.info('args: ' + args.toString());
final outputProcess = await Process.start(newPath, args);
final outputProcess = await Process.start(binPath, args);
Future<void> printInput() async {
await for (final line in input) {

45
cyberwow/lib/logic/sensor/helper.dart

@ -0,0 +1,45 @@
/*
Copyright 2020 fuwa
This file is part of CyberWOW.
Wowllet is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wowllet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wowllet. If not, see <https://www.gnu.org/licenses/>.
*/
import 'dart:async';
import 'dart:io';
import 'package:path_provider/path_provider.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import '../../logging.dart';
const _methodChannel = const MethodChannel('send-intent');
Future<String> getBinaryDir() async {
final _dir = await _methodChannel.invokeMethod('getBinaryDir');
final _binDir = Directory(_dir);
final _bins = _binDir.listSync(recursive: true);
return _dir;
}
Future<String> getBinaryPath(final String name) async {
final _binaryDir = await getBinaryDir();
return _binaryDir + '/' + name;
}

12
cyberwow/lib/main.dart

@ -28,7 +28,6 @@ import 'dart:io';
import 'dart:async';
import 'config.dart' as config;
import 'controller/process/deploy.dart' as process;
import 'controller/process/run.dart' as process;
import 'logging.dart';
import 'state.dart' as state;
@ -118,14 +117,7 @@ class _CyberWOW_PageState extends State<CyberWOW_Page> with WidgetsBindingObserv
Future<void> buildStateMachine(final state.BlankState _blankState) async {
final loadingText = config.c.splash;
state.LoadingState _loadingState = await _blankState.next(loadingText);
final binName = config.c.outputBin;
final resourcePath = 'native/output/' + describeEnum(config.arch) + '/' + binName;
final bundle = DefaultAssetBundle.of(context);
final loading = process.deployBinary(bundle, resourcePath, binName);
state.SyncingState _syncingState = await _loadingState.next(loading);
state.SyncingState _syncingState = await _loadingState.next();
final _initialIntent = await getInitialIntent();
final _userArgs = _initialIntent
@ -141,7 +133,7 @@ class _CyberWOW_PageState extends State<CyberWOW_Page> with WidgetsBindingObserv
final syncing = process
.runBinary
(
binName,
config.c.outputBin,
input: inputStreamController.stream,
shouldExit: _isExiting,
userArgs: _userArgs,

23
cyberwow/lib/state/loading.dart

@ -19,6 +19,8 @@ along with CyberWOW. If not, see <https://www.gnu.org/licenses/>.
*/
import 'package:shared_preferences/shared_preferences.dart';
import '../controller/helper.dart';
import '../config.dart' as config;
import '../logging.dart';
@ -37,8 +39,7 @@ class LoadingState extends AppState {
syncState();
}
Future<SyncingState> next(final Stream<String> loadingProgress) async {
Future<SyncingState> next() async {
Future<void> showBanner() async {
List<String> chars = [];
banner.runes.forEach((int rune) {
@ -54,20 +55,12 @@ class LoadingState extends AppState {
await Future.delayed(const Duration(seconds: 2), () => "1");
}
Future<void> load() async {
log.fine("Loading next");
await for (final line in loadingProgress) {
// append(line);
log.info(line);
}
}
SharedPreferences _prefs = await SharedPreferences.getInstance();
final _bannerShown = await _prefs.getBool(config.bannerShownKey);
final outputBinExists = await binaryExists(config.c.outputBin);
if (outputBinExists) {
await load();
}
else {
await Future.wait([load(), showBanner()]);
if (_bannerShown == null) {
await showBanner();
_prefs.setBool(config.bannerShownKey, true);
}
SyncingState _next = SyncingState(appHook);

35
cyberwow/pubspec.lock

@ -67,6 +67,11 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
http:
dependency: "direct main"
description:
@ -158,6 +163,34 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.6+1"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+4"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2+3"
sky_engine:
dependency: transitive
description: flutter
@ -228,4 +261,4 @@ packages:
version: "3.5.0"
sdks:
dart: ">=2.4.0 <3.0.0"
flutter: ">=0.1.4 <2.0.0"
flutter: ">=1.12.13+hotfix.4 <2.0.0"

3
cyberwow/pubspec.yaml

@ -14,6 +14,7 @@ dependencies:
http: ^0.12.0
logging: ^0.11.3
intl: ^0.16.0
shared_preferences: ^0.5.6
dev_dependencies:
flutter_test:
@ -24,8 +25,6 @@ flutter:
uses-material-design: true
assets:
- native/output/x86_64/wownerod
- native/output/arm64/wownerod
- assets/wownero_symbol.png
fonts:

Loading…
Cancel
Save