-
Notifications
You must be signed in to change notification settings - Fork 15
/
unlockscreen.go
118 lines (104 loc) · 4.53 KB
/
unlockscreen.go
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
package main
import(
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
"github.com/amo13/anarchy-droid/logger"
"github.com/amo13/anarchy-droid/device"
"github.com/amo13/anarchy-droid/device/adb"
)
var Center_flashing_box *fyne.Container
var Unlock_sony_box *fyne.Container
var Lbl_unlock_info *widget.Label
var Lbl_unlock_data *widget.Label
var Btn_first_unlock_step *widget.Button
func sonyUnlockScreen() fyne.CanvasObject {
Lbl_unlocking_title := widget.NewLabelWithStyle("Unlock the device", fyne.TextAlignCenter ,fyne.TextStyle{Bold: true})
Lbl_unlock_info = widget.NewLabel("On the Sony website, select your device, enter your IMEI, check the two boxes below and submit to get your unlock code.\n")
Lbl_unlock_info.Wrapping = fyne.TextWrapWord
Lbl_unlock_info.Alignment = fyne.TextAlignCenter
Lbl_unlock_data = widget.NewLabel("Your IMEI: " + device.D1.Imei)
if device.D1.Imei == "" {
err := adb.ShowImeiOnDeviceScreen()
if err != nil {
logger.LogError("Error trying to show IMEI on device screen:", err)
// What now?
}
Lbl_unlock_data.SetText("Your IMEI should be showing on your device screen.")
}
btn_open_sony_website := widget.NewButton("Open Sony website", func() {OpenWebBrowser("https://developer.sony.com/develop/open-devices/get-started/unlock-bootloader/#unlock-code")})
input := widget.NewEntry()
input.PlaceHolder = "Enter the unlock code here"
Unlock_sony_box = container.NewVBox(Lbl_unlocking_title, Lbl_unlock_info,
container.NewGridWithColumns(2,
Lbl_unlock_data,
btn_open_sony_website,
input,
widget.NewButton("Unlock and continue", func() {
if input.Text != "" {
unlockStep(input.Text)
}
}),
),
)
return Unlock_sony_box
}
func motorolaUnlockScreen() fyne.CanvasObject {
Lbl_unlocking_title := widget.NewLabelWithStyle("Unlock the device", fyne.TextAlignCenter ,fyne.TextStyle{Bold: true})
Lbl_unlock_info = widget.NewLabel("Click the first button to reboot your device into the bootloader and read the needed unlock data. If the unlock data can be read out successfully, a website will open guiding you through the process of obtaining the unlock code for your device. Once you have the unlock code, enter it in the box below and click the second button to continue.")
Lbl_unlock_info.Wrapping = fyne.TextWrapWord
Btn_first_unlock_step = widget.NewButton("Open unlock guide", func() { go func() {
Btn_first_unlock_step.SetText("Please wait...")
Btn_first_unlock_step.Disable()
defer Btn_first_unlock_step.Enable()
defer Btn_first_unlock_step.SetText("Open unlock guide")
unlock_data, err := device.D1.GetUnlockData()
if err != nil && err.Error() != "unlocked" {
logger.LogError("Error during retrieval of unlock data:", err)
// What now?
} else if err.Error() != "unlocked" {
logger.Log("Unlock data is:", unlock_data)
OpenWebBrowser("https://help.anarchy-droid.com/unlock-motorola/?code=" + unlock_data)
} else {
logger.Log("Bootloader is already unlocked")
w.SetContent(flashingScreen())
Lbl_flashing_instructions.SetText("Your bootloader is already unlocked.")
bootTwrpStep()
}
}()
})
input := widget.NewEntry()
input.PlaceHolder = "Enter the unlock code here"
Unlock_motorola_box := container.NewVBox(Lbl_unlocking_title, Lbl_unlock_info,
container.NewCenter(Btn_first_unlock_step),
container.NewGridWithColumns(2, input,
widget.NewButton("Unlock and continue", func() {
if input.Text != "" {
unlockStep(input.Text)
}
}),
))
return Unlock_motorola_box
}
func fairphoneUnlockScreen() fyne.CanvasObject {
Lbl_unlocking_title := widget.NewLabelWithStyle("Unlock the device", fyne.TextAlignCenter ,fyne.TextStyle{Bold: true})
Lbl_unlock_info = widget.NewLabel("Follow the instructions:")
Lbl_unlock_info.Wrapping = fyne.TextWrapWord
Lbl_unlock_info.Alignment = fyne.TextAlignCenter
Lbl_unlock_data = widget.NewLabel("")
if device.D1.Imei != "" && device.D1.SerialNumber != "" {
Lbl_unlock_data.SetText("Your IMEI: " + device.D1.Imei + " - Your Serial Number: " + device.D1.SerialNumber + "\n")
}
btn_open_fairphone_website := widget.NewButton("Open Fairphone website", func() {OpenWebBrowser("https://www.fairphone.com/en/bootloader-unlocking-code-for-fairphone-3/")})
Unlock_fairphone_box := container.NewVBox(Lbl_unlocking_title, Lbl_unlock_data,
container.NewGridWithColumns(2,
Lbl_unlock_info,
btn_open_fairphone_website,
widget.NewLabelWithStyle("Once you are done:", fyne.TextAlignCenter ,fyne.TextStyle{}),
widget.NewButton("Continue", func() {
unlockStep("")
}),
),
)
return Unlock_fairphone_box
}