1
- import { useCallback } from 'react'
1
+ import { useCallback , useState } from 'react'
2
2
3
- import { Step , Error , useFastboot } from '../utils/fastboot '
3
+ import { Step , Error , useQdl } from '../utils/flash '
4
4
5
5
import bolt from '../assets/bolt.svg'
6
6
import cable from '../assets/cable.svg'
@@ -57,8 +57,9 @@ const steps = {
57
57
} ,
58
58
[ Step . DONE ] : {
59
59
status : 'Done' ,
60
- description : 'Your device has been updated successfully. You can now unplug the USB cable from your computer. To ' +
61
- 'complete the system reset, follow the instructions on your device.' ,
60
+ description : 'Your device has been updated successfully. You can now unplug the all cables from your device, '
61
+ + 'and wait for the light to stop blinking then plug the power cord in again. '
62
+ + ' To complete the system reset, follow the instructions on your device.' ,
62
63
bgColor : 'bg-green-500' ,
63
64
icon : done ,
64
65
} ,
@@ -67,7 +68,8 @@ const steps = {
67
68
const errors = {
68
69
[ Error . UNKNOWN ] : {
69
70
status : 'Unknown error' ,
70
- description : 'An unknown error has occurred. Restart your browser and try again.' ,
71
+ description : 'An unknown error has occurred. Unplug your device and wait for 20s. ' +
72
+ 'Restart your browser and try again.' ,
71
73
bgColor : 'bg-red-500' ,
72
74
icon : exclamation ,
73
75
} ,
@@ -79,12 +81,14 @@ const errors = {
79
81
} ,
80
82
[ Error . LOST_CONNECTION ] : {
81
83
status : 'Lost connection' ,
82
- description : 'The connection to your device was lost. Check that your cables are connected properly and try again.' ,
84
+ description : 'The connection to your device was lost. Check that your cables are connected properly and try again. ' +
85
+ 'Unplug your device and wait for around 20s.' ,
83
86
icon : cable ,
84
87
} ,
85
88
[ Error . DOWNLOAD_FAILED ] : {
86
89
status : 'Download failed' ,
87
- description : 'The system image could not be downloaded. Check your internet connection and try again.' ,
90
+ description :'The system image could not be downloaded. Unplug your device and wait for 20s. ' +
91
+ 'Check your internet connection and try again.' ,
88
92
icon : cloudError ,
89
93
} ,
90
94
[ Error . CHECKSUM_MISMATCH ] : {
@@ -111,6 +115,11 @@ const errors = {
111
115
} ,
112
116
}
113
117
118
+ const detachScript = [
119
+ "for d in /sys/bus/usb/drivers/qcserial/*-*; do [ -e \"$d\" ] && echo -n \"$(basename $d)\" | sudo tee /sys/bus/usb/drivers/qcserial/unbind > /dev/null; done"
120
+ ] ;
121
+
122
+ const isLinux = navigator . userAgent . toLowerCase ( ) . includes ( 'linux' ) ;
114
123
115
124
function LinearProgress ( { value, barColor } ) {
116
125
if ( value === - 1 || value > 100 ) value = 100
@@ -187,7 +196,7 @@ export default function Flash() {
187
196
188
197
connected,
189
198
serial,
190
- } = useFastboot ( )
199
+ } = useQdl ( )
191
200
192
201
const handleContinue = useCallback ( ( ) => {
193
202
onContinue ?. ( )
@@ -220,6 +229,15 @@ export default function Flash() {
220
229
window . removeEventListener ( "beforeunload" , beforeUnloadListener , { capture : true } )
221
230
}
222
231
232
+ const [ copied , setCopied ] = useState ( false ) ;
233
+ const handleCopy = ( ) => {
234
+ setCopied ( true ) ;
235
+ setTimeout ( ( ) => {
236
+ setCopied ( false ) ;
237
+ } , 1000 ) ;
238
+ } ;
239
+
240
+
223
241
return (
224
242
< div id = "flash" className = "relative flex flex-col gap-8 justify-center items-center h-full" >
225
243
< div
@@ -240,6 +258,37 @@ export default function Flash() {
240
258
</ div >
241
259
< span className = { `text-3xl dark:text-white font-mono font-light` } > { title } </ span >
242
260
< span className = { `text-xl dark:text-white px-8 max-w-xl` } > { description } </ span >
261
+ { ( title === "Lost connection" || title === "Ready" ) && isLinux && (
262
+ < >
263
+ < span className = { `text-l dark:text-white px-2 max-w-xl` } >
264
+ It seems that you're on Linux, make sure to run the script below in your terminal after plugging in your device.
265
+ </ span >
266
+ < div className = "relative mt-2 max-w-3xl" >
267
+ < div className = "bg-gray-200 dark:bg-gray-800 rounded-md overflow-x-auto" >
268
+ < div className = "relative" >
269
+ < pre className = "font-mono text-sm text-gray-800 dark:text-gray-200 bg-gray-300 dark:bg-gray-700 rounded-md p-6 flex-grow max-w-m text-wrap" >
270
+ { detachScript . map ( ( line , index ) => (
271
+ < span key = { index } className = "block" >
272
+ { line }
273
+ </ span >
274
+ ) ) }
275
+ </ pre >
276
+ < div className = "absolute top-2 right-2" >
277
+ < button
278
+ onClick = { ( ) => {
279
+ navigator . clipboard . writeText ( detachScript . join ( '\n' ) ) ;
280
+ handleCopy ( ) ;
281
+ } }
282
+ className = { `bg-${ copied ? 'green' : 'blue' } -500 text-white px-1 py-1 rounded-md ml-2 text-sm` }
283
+ >
284
+ Copy
285
+ </ button >
286
+ </ div >
287
+ </ div >
288
+ </ div >
289
+ </ div >
290
+ </ >
291
+ ) }
243
292
{ error && (
244
293
< button
245
294
className = "px-4 py-2 rounded-md bg-gray-200 hover:bg-gray-300 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-800 dark:text-gray-200 transition-colors"
0 commit comments