-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathGUIProt0.proto
3623 lines (3148 loc) · 72.4 KB
/
GUIProt0.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
In contrast to the rest of the app, this file is licensed under the Unlicense:
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to https://unlicense.org
*/
syntax = "proto3";
// Feel free to change these values to fit the structure of your own implementation.
package tgui.proto0;
option java_package = "com.termux.gui.protocol.protobuf.v0";
/*
Protocol
For establishing the connection, see https://github.com/termux/termux-gui/blob/main/Protocol.md#connection . Here is the relevant part:
The program has to open 2 AF_UNIX SO_STREAM server sockets in the abstract linux namespace and listen to new connections.
One of these Sockets is used as the main communication socket with the plugin, the other one is used to send asynchronous event data to the program, eg. click events.
The program then has to send a broadcast to com.termux.gui/.GUIReceiver with the string extra mainSocket and the string extra eventSocket, the values of which specify the socket name used for that communication type. The names have to be transferred without the leading null byte required to specify the abstract linux namespace.
Delivering the broadcast can be easily done with the am command:
am broadcast --user 0 -n com.termux.gui/.GUIReceiver --es mainSocket mainSocketName --es eventSocket eventSocketName
For additional security, the program should check if the connected peer has the same user id as the program itself, to ensure only the plugin can accept the connection.
Each message is send delimited, that is the size of the message is send as a varint first.
All protocol buffer implementations should allow you to read the varint or a delimited message directly.
Events are send via the Event message, with the oneof sent to the actual event.
Methods are called with the Method message, with the oneof set to the request you want to do.
After a request, the corresponding response is send back.
*/
// Types used by multiple messages
/*
Possible Activity orientation settings. See https://developer.android.com/reference/android/R.attr#screenOrientation for the meanings.
*/
enum Orientation {
unspecified = 0;
behind = 1;
fullSensor = 2;
fullUser = 3;
landscape = 4;
locked = 5;
nosensor = 6;
portrait = 7;
reverseLandscape = 8;
reversePortrait = 9;
sensor = 10;
sensorLandscape = 11;
sensorPortrait = 12;
user = 13;
userLandscape = 14;
userPortrait = 15;
}
/*
The configuration of an Activity.
*/
message Configuration {
/*
Is dark mode enabled?
*/
bool darkMode = 2;
/*
The current country code.
*/
string country = 3;
/*
The current language code.
*/
string language = 4;
/*
The current screen orientation.
Only valid values are landscape, portrait and unspecified
*/
Orientation orientation = 5;
/*
Is the software keyboard showing?
*/
bool keyboardHidden = 6;
/*
Screen width in pixels.
*/
int32 screenWidth = 7;
/*
Screen height in pixels.
*/
int32 screenHeight = 8;
/*
The font scale, such that sp = fontscale * px
*/
float fontscale = 9;
/*
The density of the display.
*/
float density = 10;
}
/*
Visibility states for Views.
*/
enum Visibility {
/*
The View is visible.
*/
visible = 0;
/*
The View is invisible, but takes up space in the layout.
*/
hidden = 1;
/*
The View is invisible and doesn't take up space in the layout.
*/
gone = 2;
}
/*
Information necessary for the creation of View, encapsulated as a message type for simplicity.
*/
message Create {
/*
The Activity of the View.
*/
int32 aid = 1;
/*
The parent View id. Use -1 if you want to set the top level View.
*/
int32 parent = 2;
/*
The initial visibility.
*/
Visibility v = 3;
}
/*
Information uniquely identifying a View.
*/
message View {
/*
The Activity of the View.
*/
int32 aid = 1;
/*
The id of the View in the Activity.
*/
int32 id = 2;
}
/*
Directions for applying paddings and margins.
*/
enum Direction {
/*
Use all directions.
*/
ALL = 0;
TOP = 1;
LEFT = 2;
BOTTOM = 3;
RIGHT = 4;
}
/*
Importance values for notifications.
*/
enum Importance {
DEFAULT = 0;
MIN = 1;
LOW = 2;
HIGH = 3;
MAX = 4;
}
/*
The protobuf implementation allows you to specify more size units, so it's encapsulated in a message type.
*/
message Size {
/*
The value.
*/
float value = 1;
// see https://developer.android.com/guide/topics/resources/more-resources.html#Dimension
enum Unit {
dp = 0; // density-independent pixels
sp = 1; // scale-independent pixels
px = 2; // pixels
mm = 3; // millimeters
in = 4; // inches
pt = 5; // points
}
/*
The unit of the value.
*/
Unit unit = 2;
}
/*
A type for View sizing.
Only used for setWidth and setHeight, to include the special constants MATCH_PARENT and WRAP_CONTENT.
*/
message ViewSize {
/*
Special constants.
*/
enum Constant {
/*
Math the parent size.
*/
MATCH_PARENT = 0;
/*
Match the content size
*/
WRAP_CONTENT = 1;
}
/*
The value is either a constant or a size value.
*/
oneof value {
Size size = 1;
Constant constant = 2;
}
}
/*
Error return codes as failure reasons for unsuccessful methods.
0 means no error, negative numbers are non-fatal informational codes send along a successful method if needed, positive codes are fatal errors send with failed methods.
*/
enum Error {
/*
No error.
*/
OK = 0;
/*
The Activity the method tried to act on has been stopped by the system.
Retry the method when you get a start event for the Activity.
*/
ACTIVITY_STOPPED = 1;
/*
The Activity the method tried to act on has been destroyed, or was never created (in case an invalid id was used).
*/
INVALID_ACTIVITY = 2;
/*
An exception occurred while handling the method. Retrying the method or issuing other methods may or may not work, depending on the type of error.
*/
INTERNAL_ERROR = 3;
/*
The View id wasn't found in the Activity.
*/
INVALID_VIEW = 4;
/*
The View id was found, but doesn't correspond to a valid View type for the method.
*/
INVALID_VIEW_TYPE = 5;
/*
The remote layout with the specified ID wasn't found.
*/
INVALID_REMOTE_LAYOUT = 6;
/*
An image was too big to be used by Android. Images for remote ImageViews and Task icons have to be smaller than 2 MB.
*/
IMAGE_TOO_BIG = 7;
/*
The specified notification channel wasn't found.
*/
CHANNEL_NOT_FOUND = 8;
/*
The specified notification widget wasn't found.
*/
WIDGET_NOT_FOUND = 9;
/*
An enumeration value wasn't recognized.
*/
INVALID_ENUM = 10;
/*
The specified Task id wasn't found.
*/
TASK_NOT_FOUND = 11;
/*
The ratio in SetPiPParamsRequest was out of range for Android PiP window ratios.
*/
INVALID_RATIO = 12;
/*
The method can't work, because the feature was introduced in a later Android version.
*/
ANDROID_VERSION_TOO_LOW = 13;
/*
The specified buffer wasn't found.
*/
BUFFER_NOT_FOUND = 14;
}
// Request and response types
// Activity, Task and global methods
/*
Create a new Activity.
*/
message NewActivityRequest {
/*
Use -1 to start in a new Task stack.
*/
int32 tid = 1;
/*
The type of Activity that you want to launch.
*/
enum ActivityType {
/*
A normal Activity.
*/
normal = 0;
/*
Launch as a dialog. Is destroyed when the user navigates away or clicks outside.
*/
dialog = 1;
/*
Launch as a dialog. Is destroyed when the user navigates away.
*/
dialogCancelOutside = 2;
/*
Launch in PiP-mode.
*/
pip = 3;
/*
Display also on the lockscreen.
Make sure the Activity is secure, as the device doesn't need to be unlocked to interact with the Activity.
*/
lockscreen = 4;
/*
Display in an overlay over everything else like Termux:Float.
*/
overlay = 5;
}
/*
The type you want to launch.
*/
ActivityType type = 2;
/*
Whether the back button is intercepted and send as an event instead of closing the Activity or not.
*/
bool interceptBackButton = 3;
}
/*
A message with aid = -1 and tid = -1 indicates an error.
For overlays, the tid is invalid though.
*/
message NewActivityResponse {
/*
The id of the new Activity.
*/
int32 aid = 1;
/*
The id of the Task of the Activity.
*/
int32 tid = 2;
}
/*
Finish an Activity.
*/
message FinishActivityRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
}
message FinishActivityResponse {
bool success = 1;
Error code = 2;
}
/*
Finish a Task, including all its Activities.
*/
message FinishTaskRequest {
/*
The id of the Task.
*/
int32 tid = 1;
}
message FinishTaskResponse {
bool success = 1;
Error code = 2;
}
/*
Bring a Task to the front, showing it to the user.
*/
message BringTaskToFrontRequest {
/*
The id of the Task.
*/
int32 tid = 1;
}
message BringTaskToFrontResponse {
bool success = 1;
Error code = 2;
}
/*
Move a Task to the back, hiding it and returning the user to the homescreen.
*/
message MoveTaskToBackRequest {
/*
The id of an Activity in the Task.
*/
int32 aid = 1;
}
message MoveTaskToBackResponse {
bool success = 1;
Error code = 2;
}
/*
Sets the Activity theme.
The text color is only applied to newly created Views, not retroactively.
*/
message SetThemeRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
/*
The status bar color.
*/
uint32 statusBarColor = 2;
/*
The primary color.
*/
uint32 colorPrimary = 3;
/*
The background color.
*/
uint32 windowBackground = 4;
/*
The text color.
*/
uint32 textColor = 5;
/*
The accent color.
*/
uint32 colorAccent = 6;
}
message SetThemeResponse {
bool success = 1;
Error code = 2;
}
message SetTaskDescriptionRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
/*
Images have to be a PNG or JPEG file in binary format (not base64 encoded like for JSON).
If empty (length 0), resets the icon to the default.
*/
bytes img = 2;
/*
The Activity label (seems unused in Android).
*/
string label = 3;
}
message SetTaskDescriptionResponse {
bool success = 1;
Error code = 2;
}
/*
Configures the PiP-mode of the Activity.
*/
message SetPiPParamsRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
/*
The numerator of the aspect ratio.
*/
uint32 num = 2;
/*
The denominator of the aspect ratio.
*/
uint32 den = 3;
}
message SetPiPParamsResponse {
bool success = 1;
Error code = 2;
}
/*
Configures how the Activity responds to the software keyboard.
*/
message SetInputModeRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
/*
How the Activity responds to the software keyboard.
*/
enum InputMode {
/*
Pan the Activity, hiding some content at the top to make room for the keyboard.
*/
pan = 0;
/*
Resize the Activity, shifting the Layout to make room for the keyboard.
*/
resize = 1;
}
/*
The requested mode.
*/
InputMode mode = 2;
}
message SetInputModeResponse {
bool success = 1;
Error code = 2;
}
/*
Enter or leave PiP-mode.
*/
message SetPiPModeRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
/*
Whether PiP-mode should be enabled.
*/
bool pip = 2;
}
message SetPiPModeResponse {
bool success = 1;
Error code = 2;
}
/*
Set whether PiP-mode should be entered automatically when the user exits the Activity.
*/
message SetPiPModeAutoRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
/*
Whether PiP-mode should be entered automatically when the user exits the Activity.
*/
bool pip = 2;
}
message SetPiPModeAutoResponse {
bool success = 1;
Error code = 2;
}
/*
Send a Toast.
*/
message ToastRequest {
/*
The text to display.
*/
string text = 1;
/*
Whether the text should be displayed for a loner or shorter time.
*/
bool long = 2;
}
message ToastResponse {
bool success = 1;
Error code = 2;
}
/*
Requests to keep the screen on while the Activity is shown.
*/
message KeepScreenOnRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
/*
Whether to keep the screen on while the Activity is shown.
*/
bool on = 2;
}
message KeepScreenOnResponse {
bool success = 1;
Error code = 2;
}
/*
Set the Orientation of the Activity.
*/
message SetOrientationRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
/*
The orientation value.
*/
Orientation orientation = 2;
}
message SetOrientationResponse {
bool success = 1;
Error code = 2;
}
/*
Set the position of an overlay Activity.
*/
message SetPositionRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
/*
The x position in pixels from the left.
*/
uint32 x = 2;
/*
The y position in pixels from the top.
*/
uint32 y = 3;
}
message SetPositionResponse {
bool success = 1;
Error code = 2;
}
/*
Get the current Activity configuration.
*/
message GetConfigurationRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
}
message GetConfigurationResponse {
bool success = 1;
Configuration configuration = 2;
Error code = 3;
}
/*
Turn the screen on.
*/
message TurnScreenOnRequest {
}
message TurnScreenOnResponse {
bool success = 1;
Error code = 2;
}
/*
Check whether the device is locked.
*/
message IsLockedRequest {
}
message IsLockedResponse {
/*
Possible lock states.
*/
enum Locked {
/*
Lock state unknown.
*/
UNKNOWN = 0;
/*
Device locked.
*/
LOCKED = 1;
/*
Device unlocked.
*/
UNLOCKED = 2;
}
/*
Current lock state.
*/
Locked locked = 1;
}
/*
Request an unlock. Will bring up the UI for the user to unlock the device.
*/
message RequestUnlockRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
}
message RequestUnlockResponse {
bool success = 1;
Error code = 2;
}
/*
Hide the software keyboard.
*/
message HideSoftKeyboardRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
}
message HideSoftKeyboardResponse {
bool success = 1;
Error code = 2;
}
/*
Sets whether the back button is intercepted. See NewActivityRequest.
*/
message InterceptBackButtonRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
bool intercept = 2;
}
message InterceptBackButtonResponse {
bool success = 1;
Error code = 2;
}
/*
Sets whether the volume button(s) is intercepted. Instead of changing the volume, you will get an event.
*/
message InterceptVolumeButtonRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
/*
Whether to intercept volume up.
*/
bool interceptUp = 2;
/*
Whether to intercept volume down.
*/
bool interceptDown = 3;
}
message InterceptVolumeButtonResponse {
bool success = 1;
Error code = 2;
}
/*
Sets the behaviour of the status and navigation bar.
*/
message ConfigureInsetsRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
/*
Which bars should be hidden/shown.
*/
enum Bars {
/*
Both the navigation and the status bar.
*/
BOTH_BARS = 0;
/*
Navigation bar only.
*/
NAVIGATION_BAR = 1;
/*
Status bar only.
*/
STATUS_BAR = 2;
/*
No bar.
*/
NO_BAR = 3;
}
/*
How the hidden bars should behave.
*/
enum BarBehaviour {
/*
Show the bars on system gestures like swipe from the top or the bottom of the screen.
*/
BAR_BEHAVIOUR_DEFAULT = 0;
/*
Like BAR_BEHAVIOUR_DEFAULT, but the bars will be shown transparent, temporarily and overlay over the window.
*/
BAR_BEHAVIOUR_TRANSIENT = 1;
}
/*
The bars that should be shown.
*/
Bars shown = 2;
/*
How the bars should behave to user input.
*/
BarBehaviour behaviour = 3;
}
message ConfigureInsetsResponse {
bool success = 1;
Error code = 2;
}
/*
Get the plugin version code.
*/
message GetVersionRequest {
}
message GetVersionResponse {
int32 versionCode = 1;
}
/*
Set the secure flag for the Activity, making screenshots impossible and showing a blank Activity in the task switcher if on.
*/
message SetSecureFlagRequest {
/*
The id of the Activity.
*/
int32 aid = 1;
bool secure = 2;
}
message SetSecureFlagResponse {
bool success = 1;
Error code = 2;
}
/*
Set the logging level for this connection.
*/
message SetLogLevelRequest {
/*
The log level.
Should be from 0 to 10 (inclusive).
*/
uint32 level = 1;
}
message SetLogLevelResponse {
bool success = 1;
}
/*
Gets the log for this connection.
*/
message GetLogRequest {
/*
Whether to clear the log after getting it.
*/
bool clear = 1;
}
message GetLogResponse {
bool success = 1;
/*
The log for this connection.
*/
string log = 2;
}
// View creation methods
/*
All these methods work the same:
data is a Create submessage filled with information about the View to create: The visibility, the Activity and the parent View.
All other fields are specific to each View type and explained in each message type.
For all creation responses, an id of -1 indicates a failure.
In other cases, a valid View id for further methods is returned.
*/
message CreateLinearLayoutRequest {
Create data = 1;
/*
Whether the LineaLayout lays out its children horizontally or vertically.
*/
bool horizontal = 2;
}
message CreateLinearLayoutResponse {
int32 id = 1;
Error code = 2;
}
message CreateFrameLayoutRequest {
Create data = 1;
}
message CreateFrameLayoutResponse {
int32 id = 1;
Error code = 2;
}
message CreateSwipeRefreshLayoutRequest {
Create data = 1;
}
message CreateSwipeRefreshLayoutResponse {
int32 id = 1;
Error code = 2;
}
message CreateTextViewRequest {
Create data = 1;
/*
The initial text.
*/
string text = 2;
/*
Sets the text to be selectable by the user.
*/
bool selectableText = 3;
/*
Sets links to be clickable by the user.
*/
bool clickableLinks = 4;
}
message CreateTextViewResponse {
int32 id = 1;
Error code = 2;
}
message CreateEditTextRequest {
Create data = 1;
/*
A small line is displayed under an EditText. This option removes it.
*/
bool noline = 2;
/*
The type of input. Determines the layout of keys in the software keyboard.
See https://developer.android.com/reference/android/text/InputType .
*/
enum Type {