diff options
author | Scott Murray <scott.murray@konsulko.com> | 2023-09-26 11:02:55 -0400 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2023-09-26 11:04:31 -0400 |
commit | 6532dfae339faa2f7fa2d06519bf2ca5c6c77b4c (patch) | |
tree | eccbaa00565d5b0ba944d868061d961712bcb4e6 /lib/homescreen.dart | |
parent | cbbb9f40e283d12f6c52ad28609516f390316f7a (diff) |
Switch to compositor's gRPC API
Rework application surface activation to use the new compositor gRPC
API instead of our custom platform channel.
Bug-AGL: SPEC-4914
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: I589af7236c0489125a5ee226cd00ea1f8f1ec9d3
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) { |