forked from IsMyPhonePwned/webadb-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadvanced.html
More file actions
2561 lines (2205 loc) · 113 KB
/
advanced.html
File metadata and controls
2561 lines (2205 loc) · 113 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ADB Bugreport & Diagnostics - Rust WebADB</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1200px;
margin: 0 auto;
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
padding: 40px;
}
h1 {
color: #333;
margin-bottom: 10px;
}
.subtitle {
color: #666;
margin-bottom: 30px;
}
.status {
padding: 15px;
border-radius: 10px;
margin-bottom: 20px;
font-weight: 500;
}
.status.disconnected {
background: #fee;
color: #c33;
}
.status.connected {
background: #efe;
color: #3c3;
}
.status.working {
background: #ffc;
color: #cc6;
}
button {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 12px 24px;
border-radius: 8px;
font-size: 16px;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
margin-right: 10px;
margin-bottom: 10px;
}
button:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}
button:disabled {
background: #ccc;
cursor: not-allowed;
transform: none;
}
.section {
margin: 30px 0;
padding: 20px;
background: #f8f9fa;
border-radius: 10px;
}
.section h2 {
color: #333;
margin-bottom: 15px;
display: flex;
align-items: center;
gap: 10px;
}
.section p {
color: #666;
margin-bottom: 15px;
}
.progress {
width: 100%;
height: 30px;
background: #e0e0e0;
border-radius: 15px;
overflow: hidden;
margin: 15px 0;
display: none;
}
.progress.show {
display: block;
}
.progress-bar {
height: 100%;
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
width: 0%;
transition: width 0.3s;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: bold;
}
.output {
background: #1e1e1e;
color: #d4d4d4;
padding: 20px;
border-radius: 10px;
font-family: 'Courier New', monospace;
font-size: 14px;
max-height: 400px;
overflow-y: auto;
white-space: pre-wrap;
word-wrap: break-word;
margin-top: 15px;
}
.file-info {
background: #e8f4f8;
padding: 15px;
border-radius: 8px;
margin: 15px 0;
display: none;
}
.file-info.show {
display: block;
}
.file-info h3 {
color: #333;
margin-bottom: 10px;
}
.file-info p {
color: #555;
margin: 5px 0;
}
.download-btn {
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}
.warning {
background: #fff3cd;
border-left: 4px solid #ffc107;
padding: 15px;
margin: 15px 0;
border-radius: 5px;
color: #856404;
}
.success {
background: #d4edda;
border-left: 4px solid #28a745;
padding: 15px;
margin: 15px 0;
border-radius: 5px;
color: #155724;
}
.error {
background: #f8d7da;
border-left: 4px solid #dc3545;
padding: 15px;
margin: 15px 0;
border-radius: 5px;
color: #721c24;
}
.logcat-controls {
display: flex;
gap: 10px;
align-items: center;
margin-bottom: 15px;
}
.logcat-controls input {
padding: 10px;
border: 2px solid #e0e0e0;
border-radius: 8px;
font-size: 16px;
width: 120px;
}
.file-list {
max-height: 300px;
overflow-y: auto;
background: #f8f9fa;
padding: 10px;
border-radius: 5px;
margin: 10px 0;
}
.file-item {
padding: 8px;
margin: 5px 0;
background: white;
border-radius: 5px;
display: flex;
justify-content: space-between;
align-items: center;
}
.file-item:hover {
background: #e8f4f8;
}
.file-icon {
margin-right: 10px;
}
/* File Manager Styles */
#fileTable tbody tr {
border-bottom: 1px solid #eee;
transition: background 0.2s;
}
#fileTable tbody tr:hover {
background: #f5f5f5;
}
#fileTable tbody tr.selected {
background: #E3F2FD !important;
}
#fileTable tbody td {
padding: 12px;
}
.file-row-name {
display: flex;
align-items: center;
gap: 8px;
cursor: pointer;
user-select: none;
}
.file-icon-large {
font-size: 20px;
}
.context-menu-item:hover {
background: #f5f5f5;
}
.breadcrumb-part {
cursor: pointer;
padding: 2px 6px;
border-radius: 3px;
transition: background 0.2s;
}
.breadcrumb-part:hover {
background: #e0e0e0;
}
.breadcrumb-separator {
color: #999;
margin: 0 2px;
}
.quickPath:hover:not(:disabled) {
opacity: 0.8;
}
#fileDropZone {
display: none !important;
}
#fileDropZone.active {
display: flex !important;
}
</style>
</head>
<body>
<div class="container">
<h1>🔧 ADB Bugreport & Diagnostics</h1>
<p class="subtitle">Generate comprehensive device reports and diagnostics</p>
<div id="status" class="status disconnected">
Status: Disconnected
</div>
<div class="controls">
<button id="connectBtn">Connect to Device</button>
<button id="disconnectBtn" disabled>Disconnect</button>
<button id="resetQueueBtn" onclick="resetQueue()" style="background: #f44336; display: none;" title="Reset stuck queue">🔄 Reset Queue</button>
</div>
<!-- Connection Diagnostics Section -->
<div class="section" style="background: #f0f8ff; border-left: 4px solid #2196F3;">
<h2>🔍 Connection Diagnostics</h2>
<p>Monitor ADB connection health and manage streams.</p>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin: 20px 0;">
<div style="background: white; padding: 15px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<div style="color: #666; font-size: 12px; margin-bottom: 5px;">Active Streams</div>
<div style="font-size: 28px; font-weight: bold; color: #2196F3;" id="streamCount">0</div>
</div>
<div style="background: white; padding: 15px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<div style="color: #666; font-size: 12px; margin-bottom: 5px;">Connection Health</div>
<div style="font-size: 24px; font-weight: bold; color: #999;" id="healthStatus">Unknown</div>
</div>
<div style="background: white; padding: 15px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<div style="color: #666; font-size: 12px; margin-bottom: 5px;">Stale Cleaned</div>
<div style="font-size: 28px; font-weight: bold; color: #FF9800;" id="cleanedCount">0</div>
</div>
</div>
<div style="display: flex; gap: 10px; flex-wrap: wrap;">
<button id="healthCheckBtn" disabled style="background: #4CAF50;">Check Health</button>
<button id="cleanupStreamsBtn" disabled style="background: #FF9800;">Cleanup Stale</button>
<button id="refreshDiagnosticsBtn" disabled style="background: #2196F3;">Refresh</button>
</div>
<div id="diagnosticsLog" style="margin-top: 15px; padding: 10px; background: white; border-radius: 5px; font-family: monospace; font-size: 12px; max-height: 200px; overflow-y: auto; display: none;"></div>
</div>
<!-- Shell Terminal Section -->
<div class="section" style="background: #1e1e1e; color: #d4d4d4; border-left: 4px solid #00ff00;">
<h2 style="color: #00ff00;">💻 Shell Terminal</h2>
<p style="color: #d4d4d4;">Execute commands on the Android device.</p>
<!-- Quick Commands -->
<div style="margin-bottom: 15px; display: flex; flex-wrap: wrap; gap: 8px;">
<button id="shellCmdLs" style="background: #2d2d2d; color: #00ff00; border: 1px solid #00ff00; padding: 6px 12px; font-size: 12px;">ls -la</button>
<button id="shellCmdPwd" style="background: #2d2d2d; color: #00ff00; border: 1px solid #00ff00; padding: 6px 12px; font-size: 12px;">pwd</button>
<button id="shellCmdDf" style="background: #2d2d2d; color: #00ff00; border: 1px solid #00ff00; padding: 6px 12px; font-size: 12px;">df -h</button>
<button id="shellCmdPs" style="background: #2d2d2d; color: #00ff00; border: 1px solid #00ff00; padding: 6px 12px; font-size: 12px;">ps</button>
<button id="shellCmdVersion" style="background: #2d2d2d; color: #00ff00; border: 1px solid #00ff00; padding: 6px 12px; font-size: 12px;">version</button>
<button id="shellCmdUname" style="background: #2d2d2d; color: #00ff00; border: 1px solid #00ff00; padding: 6px 12px; font-size: 12px;">uname</button>
<button id="shellCmdClear" style="background: #2d2d2d; color: #ff6b6b; border: 1px solid #ff6b6b; padding: 6px 12px; font-size: 12px;">clear</button>
</div>
<!-- Terminal Output -->
<div id="terminalOutput" style="
background: #000000;
color: #00ff00;
font-family: 'Courier New', monospace;
font-size: 13px;
padding: 15px;
border-radius: 5px;
height: 400px;
overflow-y: auto;
margin-bottom: 10px;
white-space: pre-wrap;
word-wrap: break-word;
border: 2px solid #00ff00;
">$ <span style="color: #888;">Connected. Type a command or use quick buttons above.</span></div>
<!-- Command Input -->
<div style="display: flex; gap: 10px; align-items: center;">
<span style="color: #00ff00; font-family: 'Courier New', monospace; font-size: 14px; font-weight: bold;">$</span>
<input
type="text"
id="shellInput"
placeholder="Enter command (e.g., ls -la, df -h, ps)"
disabled
style="
flex: 1;
background: #000000;
color: #00ff00;
border: 2px solid #00ff00;
padding: 10px;
font-family: 'Courier New', monospace;
font-size: 14px;
border-radius: 5px;
"
/>
<button
id="shellExecuteBtn"
disabled
style="background: #00ff00; color: #000; padding: 10px 20px; font-weight: bold;">
Execute
</button>
</div>
<div style="margin-top: 10px; color: #888; font-size: 12px;">
💡 Tips: Use ↑/↓ arrows for command history | Ctrl+C to stop | Ctrl+L to clear
</div>
</div>
<!-- File Manager Section -->
<div class="section" style="background: #f5f5f5; border-left: 4px solid #FF9800;">
<h2>📁 File Manager</h2>
<p>Browse, upload, download, and manage files on your Android device.</p>
<!-- Toolbar -->
<div style="background: white; padding: 15px; border-radius: 5px; margin-bottom: 15px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<!-- Breadcrumb Navigation -->
<div style="display: flex; align-items: center; gap: 10px; margin-bottom: 10px;">
<button id="fileNavBack" disabled style="background: #666; padding: 6px 12px;">← Back</button>
<button id="fileNavUp" disabled style="background: #666; padding: 6px 12px;">↑ Up</button>
<div id="breadcrumbNav" style="flex: 1; display: flex; align-items: center; gap: 5px; padding: 8px; background: #f9f9f9; border-radius: 3px; font-family: monospace; font-size: 13px; overflow-x: auto;">
<span style="color: #666;">Loading...</span>
</div>
<button id="fileRefresh" disabled style="background: #2196F3; padding: 6px 12px;">🔄 Refresh</button>
</div>
<!-- Quick Paths -->
<div style="display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px;">
<button class="quickPath" data-path="/sdcard" disabled style="background: #4CAF50; color: white; padding: 4px 10px; font-size: 12px;">📱 SD Card</button>
<button class="quickPath" data-path="/sdcard/Download" disabled style="background: #4CAF50; color: white; padding: 4px 10px; font-size: 12px;">📥 Downloads</button>
<button class="quickPath" data-path="/sdcard/DCIM" disabled style="background: #4CAF50; color: white; padding: 4px 10px; font-size: 12px;">📷 Camera</button>
<button class="quickPath" data-path="/data/local/tmp" disabled style="background: #4CAF50; color: white; padding: 4px 10px; font-size: 12px;">🔧 Tmp</button>
<button class="quickPath" data-path="/" disabled style="background: #4CAF50; color: white; padding: 4px 10px; font-size: 12px;">🏠 Root</button>
</div>
<!-- Actions -->
<div style="display: flex; gap: 10px; flex-wrap: wrap;">
<button id="fileUploadBtn" disabled style="background: #FF9800;">⬆️ Upload Files</button>
<input type="file" id="fileUploadInput" multiple style="display: none;">
<button id="fileNewFolderBtn" disabled style="background: #9C27B0; color: white;">📁 New Folder</button>
<button id="fileSelectAllBtn" disabled style="background: #666;">Select All</button>
<button id="fileDeselectAllBtn" disabled style="background: #666;">Deselect All</button>
</div>
</div>
<!-- File List Container -->
<div style="background: white; border-radius: 5px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); overflow: hidden;">
<div id="fileListContainer" style="max-height: 500px; overflow-y: auto;">
<table id="fileTable" style="width: 100%; border-collapse: collapse;">
<thead style="position: sticky; top: 0; background: #f5f5f5; z-index: 10;">
<tr>
<th style="padding: 12px; text-align: left; border-bottom: 2px solid #ddd; cursor: pointer; user-select: none;" data-sort="name">
<input type="checkbox" id="selectAllCheckbox" style="margin-right: 8px;">
📄 Name <span id="sortNameIndicator">▼</span>
</th>
<th style="padding: 12px; text-align: right; border-bottom: 2px solid #ddd; cursor: pointer; user-select: none; width: 120px;" data-sort="size">
💾 Size <span id="sortSizeIndicator"></span>
</th>
<th style="padding: 12px; text-align: left; border-bottom: 2px solid #ddd; width: 100px;">
📋 Type
</th>
<th style="padding: 12px; text-align: center; border-bottom: 2px solid #ddd; width: 100px;">
⚙️ Actions
</th>
</tr>
</thead>
<tbody id="fileTableBody">
<tr>
<td colspan="4" style="padding: 40px; text-align: center; color: #999;">
Connect to a device to browse files
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Drop Zone Overlay -->
<div id="fileDropZone" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255, 152, 0, 0.9); z-index: 9999; align-items: center; justify-content: center;">
<div style="text-align: center; color: white;">
<div style="font-size: 72px; margin-bottom: 20px;">📤</div>
<div style="font-size: 32px; font-weight: bold;">Drop files here to upload</div>
<div style="font-size: 18px; margin-top: 10px;" id="dropZonePath"></div>
</div>
</div>
<!-- Context Menu -->
<div id="fileContextMenu" style="display: none; position: fixed; background: white; border: 1px solid #ccc; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.2); z-index: 10000; min-width: 180px;">
<div class="context-menu-item" data-action="open" style="padding: 10px 15px; cursor: pointer; border-bottom: 1px solid #eee;">
📂 Open
</div>
<div class="context-menu-item" data-action="download" style="padding: 10px 15px; cursor: pointer; border-bottom: 1px solid #eee;">
📥 Download
</div>
<div class="context-menu-item" data-action="rename" style="padding: 10px 15px; cursor: pointer; border-bottom: 1px solid #eee;">
✏️ Rename
</div>
<div class="context-menu-item" data-action="delete" style="padding: 10px 15px; cursor: pointer; border-bottom: 1px solid #eee; color: #f44336;">
🗑️ Delete
</div>
<div class="context-menu-item" data-action="copypath" style="padding: 10px 15px; cursor: pointer;">
📋 Copy Path
</div>
</div>
</div>
<!-- Modals -->
<div id="fileManagerModals">
<!-- Rename Modal -->
<div id="renameModal" class="modal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 10001; align-items: center; justify-content: center;">
<div style="background: white; padding: 25px; border-radius: 8px; min-width: 400px; box-shadow: 0 4px 12px rgba(0,0,0,0.3);">
<h3 style="margin-top: 0;">✏️ Rename</h3>
<input type="text" id="renameInput" placeholder="New name" style="width: 100%; padding: 10px; font-size: 14px; border: 2px solid #ddd; border-radius: 4px; margin-bottom: 15px;">
<div style="display: flex; gap: 10px; justify-content: flex-end;">
<button onclick="closeRenameModal()" style="background: #999; padding: 8px 20px;">Cancel</button>
<button onclick="confirmRename()" style="background: #2196F3; padding: 8px 20px;">Rename</button>
</div>
</div>
</div>
<!-- New Folder Modal -->
<div id="newFolderModal" class="modal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 10001; align-items: center; justify-content: center;">
<div style="background: white; padding: 25px; border-radius: 8px; min-width: 400px; box-shadow: 0 4px 12px rgba(0,0,0,0.3);">
<h3 style="margin-top: 0;">📁 Create New Folder</h3>
<input type="text" id="newFolderInput" placeholder="Folder name" style="width: 100%; padding: 10px; font-size: 14px; border: 2px solid #ddd; border-radius: 4px; margin-bottom: 15px;">
<div style="display: flex; gap: 10px; justify-content: flex-end;">
<button onclick="closeNewFolderModal()" style="background: #999; padding: 8px 20px;">Cancel</button>
<button onclick="confirmNewFolder()" style="background: #9C27B0; color: white; padding: 8px 20px;">Create</button>
</div>
</div>
</div>
<!-- Delete Confirm Modal -->
<div id="deleteConfirmModal" class="modal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 10001; align-items: center; justify-content: center;">
<div style="background: white; padding: 25px; border-radius: 8px; min-width: 400px; box-shadow: 0 4px 12px rgba(0,0,0,0.3);">
<h3 style="margin-top: 0; color: #f44336;">🗑️ Confirm Delete</h3>
<p id="deleteConfirmText">Are you sure you want to delete this item?</p>
<div class="warning" style="margin: 15px 0;">
<strong>⚠️ Warning:</strong> This action cannot be undone!
</div>
<div style="display: flex; gap: 10px; justify-content: flex-end;">
<button onclick="closeDeleteConfirmModal()" style="background: #999; padding: 8px 20px;">Cancel</button>
<button onclick="confirmDelete()" style="background: #f44336; padding: 8px 20px;">Delete</button>
</div>
</div>
</div>
<!-- Upload Progress Modal -->
<div id="uploadProgressModal" class="modal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 10001; align-items: center; justify-content: center;">
<div style="background: white; padding: 25px; border-radius: 8px; min-width: 400px; box-shadow: 0 4px 12px rgba(0,0,0,0.3);">
<h3 style="margin-top: 0;">⬆️ Uploading Files</h3>
<div id="uploadFileName" style="margin-bottom: 10px; font-weight: bold;">file.txt</div>
<div style="background: #eee; border-radius: 10px; height: 24px; overflow: hidden; margin-bottom: 10px;">
<div id="uploadProgressBar" style="background: linear-gradient(90deg, #FF9800, #FFC107); height: 100%; width: 0%; transition: width 0.3s;"></div>
</div>
<div id="uploadProgressText" style="text-align: center; color: #666; font-size: 14px;">0%</div>
<div id="uploadStatus" style="margin-top: 10px; font-size: 12px; color: #666; text-align: center;"></div>
</div>
</div>
</div>
<!-- Bugreport Section -->
<div class="section">
<h2>📋 Bug Reports</h2>
<p>Access device diagnostic reports for troubleshooting.</p>
<div class="warning">
<strong>💡 Tip:</strong> Check "Available Bugreports" below first to download existing reports instantly!
Generating a new report takes 5-10 minutes (2-5 min generation + 1-5 min download for large files).
</div>
<button id="bugreportLiteBtn" disabled>Generate Lite Report (Fast ~30s)</button>
<button id="bugreportFullBtn" disabled>Generate Full Report (Very Slow ~5-10min)</button>
<div id="bugreportProgress" class="progress">
<div id="bugreportProgressBar" class="progress-bar">0%</div>
</div>
<div id="bugreportInfo" class="file-info">
<h3>Report Generated</h3>
<p><strong>Size:</strong> <span id="reportSize">-</span></p>
<p><strong>Format:</strong> <span id="reportFormat">-</span></p>
<button id="downloadReportBtn" class="download-btn">Download Report</button>
<button id="viewReportBtn">View Report</button>
</div>
<div id="bugreportOutput" class="output" style="display: none;"></div>
<!-- Available Bugreports -->
<div style="margin-top: 30px; padding-top: 20px; border-top: 2px solid #eee; background: #f9f9f9; padding: 20px; border-radius: 8px;">
<h3>⚡ Available Bugreports on Device (Recommended)</h3>
<p style="color: #666; margin-bottom: 15px;">
<strong>Fastest option:</strong> Download previously generated bugreports instantly.<br>
If you recently ran "adb bugreportz" or generated a report, it will appear here.
</p>
<button id="listBugreportsBtn" disabled style="background: #4CAF50;">List Available Bugreports</button>
<div id="bugreportsList" class="output" style="display: none;"></div>
<!-- Download Debug Panel -->
<div id="downloadDebug" style="display: none; margin-top: 20px; padding: 15px; background: #f0f0f0; border-radius: 8px; font-family: monospace; font-size: 12px;">
<div style="display: flex; justify-content: space-between; margin-bottom: 10px;">
<strong style="color: #2196F3;">📊 Download Progress</strong>
<span id="downloadStatus" style="color: #666;">Idle</span>
</div>
<div style="margin: 10px 0;">
<div style="background: #ddd; border-radius: 10px; height: 20px; overflow: hidden;">
<div id="downloadProgressBar" style="background: linear-gradient(90deg, #4CAF50, #45a049); height: 100%; width: 0%; transition: width 0.3s; display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; font-size: 11px;"></div>
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px;">
<div>📁 <strong>File:</strong> <span id="debugFile">-</span></div>
<div>📦 <strong>Size:</strong> <span id="debugSize">-</span></div>
<div>⏱️ <strong>Elapsed:</strong> <span id="debugTime">0s</span></div>
<div>⚡ <strong>Speed:</strong> <span id="debugSpeed">-</span></div>
</div>
<div style="margin-top: 10px; padding: 8px; background: white; border-radius: 4px;">
<div style="color: #666; font-size: 11px; margin-bottom: 5px;">Console Log:</div>
<div id="debugLog" style="max-height: 100px; overflow-y: auto; color: #333;"></div>
</div>
</div>
</div>
</div>
<!-- Logcat Section -->
<div class="section">
<h2>📝 Logcat</h2>
<p>View device logs for debugging and troubleshooting.</p>
<div class="logcat-controls">
<input type="number" id="logcatLines" value="100" min="10" max="10000" placeholder="Lines">
<button id="logcatBtn" disabled>Get Logcat</button>
<button id="logcatClearBtn" disabled>Clear Logcat</button>
<button id="downloadLogBtn" class="download-btn" disabled>Download Log</button>
</div>
<div id="logcatOutput" class="output"></div>
</div>
<!-- File Browser Section -->
<div class="section">
<h2>📁 File Browser</h2>
<p>Browse and download files from your device.</p>
<div class="logcat-controls">
<input type="text" id="filePath" value="/sdcard" placeholder="Path">
<button id="listBtn" disabled>List Directory</button>
<button id="statBtn" disabled>Get File Info</button>
</div>
<div id="fileList" class="file-list" style="display: none;"></div>
<div id="fileStatOutput" class="output" style="display: none;"></div>
</div>
<!-- Screen Recording (future) -->
<div class="section">
<h2>🎥 Advanced Operations</h2>
<p>Additional diagnostic and data collection tools.</p>
<button id="screenshotBtn" disabled>Capture Screenshot</button>
<button id="dumpStateBtn" disabled>Dump System State</button>
<button id="packageListBtn" disabled>List All Packages</button>
<div id="advancedOutput" class="output"></div>
</div>
</div>
<script type="module">
import init, { Adb, generate_keypair, has_keypair } from './pkg/webadb_rs.js';
let adb = null;
let currentReport = null;
let currentLog = null;
// Operation queue to prevent concurrent access
let operationQueue = [];
let isProcessingQueue = false;
let queueProcessingStartTime = null;
let queueWatchdogInterval = null;
// Watchdog to detect stuck queues
function startQueueWatchdog() {
if (queueWatchdogInterval) {
clearInterval(queueWatchdogInterval);
}
queueWatchdogInterval = setInterval(() => {
if (isProcessingQueue && queueProcessingStartTime) {
const stuckTime = Date.now() - queueProcessingStartTime;
// If queue has been processing for more than 10 minutes, something is wrong
if (stuckTime > 10 * 60 * 1000) {
console.error(`[Queue] WARNING: Queue appears to be stuck! Processing for ${formatDuration(stuckTime)}`);
console.error(`[Queue] Queue state: isProcessing=${isProcessingQueue}, queueLength=${operationQueue.length}, resetting...`);
resetQueue();
} else if (stuckTime > 2 * 60 * 1000) {
// Warn after 2 minutes
console.warn(`[Queue] Queue has been processing for ${formatDuration(stuckTime)}. This might be normal for long operations.`);
}
} else if (isProcessingQueue && !queueProcessingStartTime) {
// Queue says it's processing but we don't have a start time - reset
console.error(`[Queue] WARNING: Queue state inconsistent! isProcessing=true but no start time. Resetting...`);
resetQueue();
}
}, 30000); // Check every 30 seconds
}
function stopQueueWatchdog() {
if (queueWatchdogInterval) {
clearInterval(queueWatchdogInterval);
queueWatchdogInterval = null;
}
}
// Reset queue state (emergency recovery)
function resetQueue() {
console.error(`[Queue] RESET: Resetting queue state`);
const queueLength = operationQueue.length;
// Reject all pending operations
operationQueue.forEach((item, index) => {
try {
if (item && item.reject) {
item.reject(new Error('Queue was reset due to stuck state'));
}
} catch (e) {
console.error(`[Queue] Error rejecting queued operation ${index}:`, e);
}
});
operationQueue = [];
isProcessingQueue = false;
queueProcessingStartTime = null;
stopQueueWatchdog();
// Hide reset button
const resetBtn = document.getElementById('resetQueueBtn');
if (resetBtn) {
resetBtn.style.display = 'none';
}
console.error(`[Queue] RESET: Cleared ${queueLength} pending operations. Queue is now empty and ready.`);
if (queueLength > 0) {
showError(`Queue was reset. ${queueLength} pending operation(s) were cancelled. Please try again.`);
} else {
showSuccess('Queue reset successfully.');
}
}
// Expose reset function globally for manual recovery
window.resetQueue = resetQueue;
// Show/hide reset button based on queue state
function updateResetButtonVisibility() {
const resetBtn = document.getElementById('resetQueueBtn');
if (resetBtn) {
if (isProcessingQueue || operationQueue.length > 0) {
resetBtn.style.display = 'inline-block';
} else {
resetBtn.style.display = 'none';
}
}
}
// Helper function to format duration in human-readable format
function formatDuration(ms) {
if (ms < 1000) {
return `${ms.toFixed(2)}ms`;
}
const seconds = Math.floor(ms / 1000);
const milliseconds = Math.floor(ms % 1000);
if (seconds < 60) {
return `${seconds}s ${milliseconds}ms (${ms.toFixed(2)}ms)`;
}
const minutes = Math.floor(seconds / 60);
const remainingSeconds = seconds % 60;
return `${minutes}m ${remainingSeconds}s ${milliseconds}ms (${ms.toFixed(2)}ms)`;
}
async function queueOperation(operation) {
const queueId = Math.random().toString(36).substr(2, 9);
const queueLengthBefore = operationQueue.length;
console.log(`[Queue] Adding operation to queue (id: ${queueId}), current queue length: ${queueLengthBefore}, will be: ${queueLengthBefore + 1}`);
return new Promise((resolve, reject) => {
operationQueue.push({ operation, resolve, reject, queueId });
const queueLengthAfter = operationQueue.length;
console.log(`[Queue] Operation queued (id: ${queueId}), queue length now: ${queueLengthAfter}, isProcessing: ${isProcessingQueue}`);
// Update reset button visibility
updateResetButtonVisibility();
if (!isProcessingQueue) {
console.log(`[Queue] Starting queue processing (id: ${queueId})`);
// Use setTimeout to ensure this happens asynchronously
setTimeout(() => {
if (!isProcessingQueue && operationQueue.length > 0) {
processQueue();
} else if (isProcessingQueue) {
console.log(`[Queue] Queue started processing between check and setTimeout`);
} else if (operationQueue.length === 0) {
console.log(`[Queue] Queue was cleared between check and setTimeout`);
}
}, 0);
} else {
console.log(`[Queue] Queue already processing, operation queued (id: ${queueId}). Will be processed after current operation(s) complete.`);
// Safety check: if queue has been processing for a very long time, warn user
if (queueProcessingStartTime) {
const processingTime = Date.now() - queueProcessingStartTime;
if (processingTime > 5 * 60 * 1000) {
console.warn(`[Queue] WARNING: Queue has been processing for ${formatDuration(processingTime)}. This might indicate a stuck operation.`);
console.warn(`[Queue] If operations are not completing, click the "Reset Queue" button or call resetQueue() in the console.`);
const resetBtn = document.getElementById('resetQueueBtn');
if (resetBtn) {
resetBtn.style.display = 'inline-block';
}
}
}
}
});
}
async function processQueue() {
if (isProcessingQueue) {
console.log('[Queue] Already processing, skipping');
return;
}
console.log(`[Queue] Starting queue processing, ${operationQueue.length} operations pending`);
isProcessingQueue = true;
queueProcessingStartTime = Date.now();
startQueueWatchdog();
updateResetButtonVisibility();
let processed = 0;
const maxIterations = 1000; // Safety limit to prevent infinite loops
let iterations = 0;
try {
while (operationQueue.length > 0 && iterations < maxIterations) {
iterations++;
const queueItem = operationQueue.shift();
if (!queueItem) {
console.warn(`[Queue] WARNING: Shifted null/undefined item from queue, breaking loop`);
break;
}
const { operation, resolve, reject, queueId } = queueItem;
processed++;
const totalOps = processed + operationQueue.length;
const itemId = queueId || `op-${processed}`;
console.log(`[Queue] Processing operation ${processed}/${totalOps} (id: ${itemId}, ${operationQueue.length} remaining in queue)`);
const startTime = performance.now();
let timeoutId = null;
try {
// Wrap in Promise.resolve to ensure it's always a promise
const operationPromise = Promise.resolve(operation());
// Add timeout to prevent operations from hanging indefinitely
// Use longer timeout for operations that might take a while (like bugreport)
// Check if this looks like a bugreport operation by checking the operation function
const operationStr = operation.toString();
const isLongOperation = operationStr.includes('bugreport') ||
operationStr.includes('Bugreport') ||
operationStr.includes('bugreport()');
const timeoutMs = isLongOperation ? 15 * 60 * 1000 : 5 * 60 * 1000; // 15 min for bugreport, 5 min for others
const timeoutPromise = new Promise((_, timeoutReject) => {
timeoutId = setTimeout(() => {
timeoutReject(new Error(`Operation timeout after ${formatDuration(timeoutMs)}`));
}, timeoutMs);
});
const result = await Promise.race([operationPromise, timeoutPromise]);
// Clear timeout if operation completed successfully
if (timeoutId) {
clearTimeout(timeoutId);
timeoutId = null;
}
const duration = performance.now() - startTime;
console.log(`[Queue] Operation ${processed} (id: ${itemId}) completed in ${formatDuration(duration)}`);
try {
resolve(result);
} catch (resolveError) {
console.error(`[Queue] Error resolving promise for operation ${processed} (id: ${itemId}):`, resolveError);
}
} catch (error) {
// Clear timeout if there was an error
if (timeoutId) {
clearTimeout(timeoutId);
timeoutId = null;
}
const duration = performance.now() - startTime;
console.error(`[Queue] Operation ${processed} failed after ${formatDuration(duration)}:`, error);
try {
reject(error);
} catch (rejectError) {
console.error(`[Queue] Error rejecting promise for operation ${processed}:`, rejectError);
}
}
// Small delay to allow other operations to be queued if needed
// This ensures we don't miss operations that are queued during processing
if (operationQueue.length > 0) {
await new Promise(resolve => setTimeout(resolve, 0));
}
}
if (iterations >= maxIterations) {
console.error(`[Queue] WARNING: Reached max iterations (${maxIterations}), stopping queue processing`);
}
const remainingOps = operationQueue.length;
if (remainingOps > 0) {
console.warn(`[Queue] WARNING: ${remainingOps} operations still in queue after processing stopped`);
}
const processingDuration = queueProcessingStartTime ? Date.now() - queueProcessingStartTime : 0;
console.log(`[Queue] Queue processing complete, processed ${processed} operations in ${formatDuration(processingDuration)}`);
} catch (error) {
console.error(`[Queue] FATAL ERROR in processQueue:`, error);
console.error(`[Queue] Error stack:`, error.stack);
showError(`Queue processing error: ${error.message}. Queue has been reset.`);
// Reset queue state on fatal error
operationQueue = [];
} finally {
// IMPORTANT: Always reset the flag, even on error
// This ensures that if new operations are queued, they can trigger processing
isProcessingQueue = false;
queueProcessingStartTime = null;
stopQueueWatchdog();
updateResetButtonVisibility();
// Check if any new operations were added while we were processing
// This handles the case where an operation was queued right as we finished
const newOpsCount = operationQueue.length;
if (newOpsCount > 0) {
console.log(`[Queue] ${newOpsCount} new operation(s) detected after completion, restarting queue processing`);
// Use setTimeout to avoid recursion issues and ensure state is fully reset
setTimeout(() => {
// Double-check conditions to avoid race conditions
if (!isProcessingQueue && operationQueue.length > 0) {
console.log(`[Queue] Restarting queue processing for ${operationQueue.length} operation(s)`);
processQueue();
} else if (isProcessingQueue) {
console.log(`[Queue] Queue already processing, skipping restart`);
} else if (operationQueue.length === 0) {
console.log(`[Queue] Queue is empty, no restart needed`);
}
}, 10); // Small delay to ensure state is fully reset
} else {
console.log(`[Queue] No new operations, queue processing finished`);
}
}
}
// Shell state
let commandHistory = [];
let historyIndex = -1;
let isExecuting = false;
// Shell functions
async function executeShellCommand() {
const input = document.getElementById('shellInput');
const output = document.getElementById('terminalOutput');
const command = input.value.trim();
console.log(`[Shell] executeShellCommand called with command: "${command}"`);
if (!command) {
console.log('[Shell] Empty command, returning');
return;
}
if (isExecuting) {
console.log('[Shell] Already executing, returning');
return;
}
// Add to history
if (commandHistory.length === 0 || commandHistory[commandHistory.length - 1] !== command) {
commandHistory.push(command);
}
historyIndex = commandHistory.length;
// Display command
appendTerminal(`$ ${command}\n`, '#00ff00');
input.value = '';
input.disabled = true;
isExecuting = true;
const startTime = performance.now();
console.log(`[Shell] Executing command: "${command}"`);
try {
const result = await queueOperation(async () => {