@@ -10,7 +10,7 @@ String macZip = 'https://dl.google.com/android/repository/platform-tools-latest-
10
10
String linuxZip = 'https://dl.google.com/android/repository/platform-tools-latest-linux.zip' ;
11
11
String windowsZip = 'https://dl.google.com/android/repository/platform-tools-latest-windows.zip' ;
12
12
Map envVars = io.Platform .environment;
13
- double appVersion = 5.6 ;
13
+ double appVersion = 5.7 ;
14
14
String baseRepo = 'corbindavenport/nexus-tools' ;
15
15
16
16
// Function for checking for update
@@ -50,7 +50,7 @@ String nexusToolsDir() {
50
50
}
51
51
52
52
// Function for installing Platform Tools package
53
- Future installPlatformTools () async {
53
+ Future installPlatformTools (cpuArch ) async {
54
54
print ('[INFO] You agree to the Terms & Conditions by installing this software: https://developer.android.com/studio/terms' );
55
55
var dir = nexusToolsDir ();
56
56
// Get the proper ZIP file
@@ -68,7 +68,7 @@ Future installPlatformTools() async {
68
68
try {
69
69
var data = await http.readBytes (net);
70
70
var archive = ZipDecoder ().decodeBytes (data);
71
- extractArchiveToDisk (archive, dir);
71
+ await extractArchiveToDisk (archive, dir);
72
72
} catch (e) {
73
73
print ('[EROR] There was an error downloading Platform Tools: ' + e.toString ());
74
74
io.exit (1 );
@@ -102,19 +102,23 @@ Future installPlatformTools() async {
102
102
}
103
103
// Windows-specific functions
104
104
if (io.Platform .isWindows) {
105
- // Check if Universal Adb Driver package is already installed
106
- var info = await io.Process .run ('wmic' , ['product' , 'get' , 'Name' ]);
107
- var parsedInfo = info.stdout.toString ();
108
- if (parsedInfo.contains ('Universal Adb Driver' )) {
109
- print ('[ OK ] Universal ADB Drivers already installed.' );
110
- } else {
111
- // Prompt to install drivers
112
- print ('[WARN] Drivers may be required for ADB if they are not already installed.' );
113
- io.stdout.write ('[WARN] Install drivers from adb.clockworkmod.com? [Y/N] ' );
114
- var input = io.stdin.readLineSync ();
115
- if (input? .toLowerCase () == 'y' ) {
116
- await installWindowsDrivers (dir);
105
+ // Install Universal Adb Driver package on x86_64 Windows
106
+ if (cpuArch == 'AMD64' ) {
107
+ var info = await io.Process .run ('PowerShell' , ['-Command' , 'Get-WmiObject -Class Win32_Product | Select-Object -Property Name' ]);
108
+ var parsedInfo = info.stdout.toString ();
109
+ if (parsedInfo.contains ('Universal Adb Driver' )) {
110
+ print ('[ OK ] Universal ADB Drivers already installed.' );
111
+ } else {
112
+ // Prompt to install drivers
113
+ print ('[WARN] Drivers may be required for ADB if they are not already installed.' );
114
+ io.stdout.write ('[WARN] Install drivers from adb.clockworkmod.com? [Y/N] ' );
115
+ var input = io.stdin.readLineSync ();
116
+ if (input? .toLowerCase () == 'y' ) {
117
+ await installWindowsDrivers (dir);
118
+ }
117
119
}
120
+ } else {
121
+ print ('[WARN] Universal ADB Driver package cannot be installed on $cpuArch , some devices might not work.' );
118
122
}
119
123
// Check if old Nexus Tools directory needs to be deleted
120
124
var oldFolder = envVars['UserProfile' ] + r'\NexusTools' ;
@@ -207,7 +211,7 @@ Future installWindowsDrivers(String dir) async {
207
211
}
208
212
209
213
// Function for Plausible Analytics reporting
210
- void connectAnalytics () async {
214
+ void connectAnalytics (String cpuArch ) async {
211
215
var uuid = Uuid ();
212
216
var id = uuid.v4 ();
213
217
// Get exact operating system
@@ -221,12 +225,11 @@ void connectAnalytics() async {
221
225
} else {
222
226
realOS = io.Platform .operatingSystem;
223
227
}
224
- var cpu = await sys.getCPUArchitecture ();
225
228
// Set data
226
229
var net = Uri .parse ('https://plausible.io/api/event' );
227
230
final ipv4 = await Ipify .ipv4 ();
228
231
var netHeaders = {'user-agent' : 'Nexus Tools' , 'X-Forwarded-For' : ipv4, 'Content-Type' : 'application/json' , 'User-Agent' : 'Mozilla/5.0 ($realOS ) AppleWebKit/500 (KHTML, like Gecko) Chrome/$appVersion $id ' };
229
- var netBody = '{"name":"pageview","url":"app://localhost/$realOS /$cpu ","domain":"nexustools.corbin.io"}' ;
232
+ var netBody = '{"name":"pageview","url":"app://localhost/$realOS /$cpuArch ","domain":"nexustools.corbin.io"}' ;
230
233
// Send request
231
234
try {
232
235
await http.post (net, headers: netHeaders, body: netBody);
@@ -236,7 +239,7 @@ void connectAnalytics() async {
236
239
}
237
240
238
241
// Pre-installation steps
239
- Future checkInstall () async {
242
+ Future checkInstall (String cpuArch ) async {
240
243
// Check if directory already exists
241
244
var dir = nexusToolsDir ();
242
245
var installExists = false ;
@@ -270,9 +273,9 @@ Future checkInstall() async {
270
273
}
271
274
}
272
275
273
- void printHelp () {
276
+ void printHelp (cpuArch ) {
274
277
var helpDoc = '''
275
- Nexus Tools $appVersion
278
+ Nexus Tools $appVersion on $ cpuArch
276
279
Downloader/management app for Android SDK Platform Tools
277
280
278
281
Usage: nexustools [OPTIONS]
@@ -290,8 +293,9 @@ Example: nexustools -i (this installs Platform Tools)
290
293
}
291
294
292
295
void main (List <String > arguments) async {
296
+ var cpuArch = await sys.getCPUArchitecture ();
293
297
if (arguments.contains ('-i' ) || arguments.contains ('--install' )) {
294
- print ('[INFO] Nexus Tools $appVersion ' );
298
+ print ('[INFO] Nexus Tools $appVersion on $ cpuArch ' );
295
299
// Check version unless Nexus Tools is running from web (curl) installer
296
300
// The web installer adds the -w parameter
297
301
if (! arguments.contains ('-w' )) {
@@ -301,11 +305,11 @@ void main(List<String> arguments) async {
301
305
if (arguments.contains ('--no-analytics' )) {
302
306
print ('[ OK ] Plausible Analytics are disabled.' );
303
307
} else {
304
- connectAnalytics ();
308
+ connectAnalytics (cpuArch );
305
309
}
306
310
// Start installation
307
- await checkInstall ();
308
- await installPlatformTools ();
311
+ await checkInstall (cpuArch );
312
+ await installPlatformTools (cpuArch );
309
313
// Post-install
310
314
var appName = '' ;
311
315
if (io.Platform .isWindows) {
@@ -322,7 +326,7 @@ void main(List<String> arguments) async {
322
326
// Start removal
323
327
await removePlatformTools ();
324
328
} else if (arguments.contains ('-h' ) || arguments.contains ('--help' )) {
325
- printHelp ();
329
+ printHelp (cpuArch );
326
330
} else if (arguments.contains ('-c' ) || arguments.contains ('--check' )) {
327
331
await checkUpdate ();
328
332
} else {
0 commit comments