diff options
Diffstat (limited to 'lib/homescreen.dart')
-rw-r--r-- | lib/homescreen.dart | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/lib/homescreen.dart b/lib/homescreen.dart index be9c7ca..6d7ce5f 100644 --- a/lib/homescreen.dart +++ b/lib/homescreen.dart @@ -4,6 +4,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_homescreen/config.dart'; import 'package:grpc/grpc.dart'; +import 'package:flutter_homescreen/generated/agl_shell.pbgrpc.dart'; import 'package:flutter_homescreen/generated/applauncher.pbgrpc.dart'; import 'package:flutter_homescreen/page_apps.dart'; import 'package:flutter_homescreen/widget_clock.dart'; @@ -24,14 +25,17 @@ class _HomescreenState extends ConsumerState<Homescreen> with TickerProviderStat int _selectedIndex = 0; int _previousIndex = 0; - late ClientChannel channel; - late AppLauncherClient stub; + late ClientChannel appLauncherChannel; + late AppLauncherClient appLauncher; List<String> apps_stack = []; - static const agl_shell_channel = MethodChannel('flutter/agl_shell'); + + late ClientChannel aglShellChannel; + late AglShellManagerServiceClient aglShell; + late VssClient vss; Future<List<AppInfo>> getAppList() async { - var response = await stub.listApplications(ListRequest()); + var response = await appLauncher.listApplications(ListRequest()); for (AppInfo info in response.apps) { debugPrint("Got app:"); debugPrint("$info"); @@ -53,12 +57,8 @@ class _HomescreenState extends ConsumerState<Homescreen> with TickerProviderStat } activateApp(String id) async { - try { - agl_shell_channel - .invokeMethod('activate_app', {'app_id': id, 'index': 0}); - } catch (e) { - print('Could not invoke flutter/agl_shell/activate_app: $e'); - } + var req = ActivateRequest(appId: id); + var response = aglShell.activateApp(req); addAppToStack(id); } @@ -73,7 +73,7 @@ class _HomescreenState extends ConsumerState<Homescreen> with TickerProviderStat handleAppStatusEvents() async { try { - var response = stub.getStatusEvents(StatusRequest()); + var response = appLauncher.getStatusEvents(StatusRequest()); await for (var event in response) { if (event.hasApp()) { AppStatus app_status = event.app; @@ -95,11 +95,18 @@ class _HomescreenState extends ConsumerState<Homescreen> with TickerProviderStat initState() { //debugPrint("_HomescreenState.initState!"); - channel = ClientChannel('localhost', + + aglShellChannel = ClientChannel('localhost', + port: 14005, + options: ChannelOptions(credentials: ChannelCredentials.insecure())); + + aglShell = AglShellManagerServiceClient(aglShellChannel); + + appLauncherChannel = ClientChannel('localhost', port: 50052, options: ChannelOptions(credentials: ChannelCredentials.insecure())); - stub = AppLauncherClient(channel); + appLauncher = AppLauncherClient(appLauncherChannel); handleAppStatusEvents(); @@ -110,7 +117,7 @@ class _HomescreenState extends ConsumerState<Homescreen> with TickerProviderStat } void startApp(String id) async { - await stub.startApplication(StartRequest(id: id)); + await appLauncher.startApplication(StartRequest(id: id)); } setNavigationIndex(int index) { |