android-device-manager 25.8.11-1614 → 25.10.16-1930

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # AndroidDeviceManager
1
+ # Android Device Manager
2
2
 
3
3
  ## Description ##
4
- Java desktop app to manage multiple Android devices via adb
4
+ Android Device Manager is a desktop app which can manage one or more Android devices
5
5
 
6
6
  ## Features ##
7
7
  - View all connected (and wireless) devices
@@ -1,5 +1,8 @@
1
1
  #! /usr/bin/env node
2
2
 
3
+ var path = require('path');
4
+ var os = require('os');
5
+ var jdeployHomeDir = process.env.JDEPLOY_HOME || path.join(os.homedir(), '.jdeploy');
3
6
  var jarName = "AndroidDeviceManager.jar";
4
7
  var mainClass = "{{MAIN_CLASS}}";
5
8
  var classPath = "{{CLASSPATH}}";
@@ -23,9 +26,7 @@ var jdkProvider = 'zulu';
23
26
  function njreWrap() {
24
27
  'use strict'
25
28
 
26
- const path = require('path')
27
29
  const fs = require('fs')
28
- const os = require('os')
29
30
  const crypto = require('crypto')
30
31
  const fetch = require('node-fetch')
31
32
  const yauzl = require('yauzl')
@@ -105,7 +106,7 @@ function njreWrap() {
105
106
 
106
107
  function move (file) {
107
108
  return new Promise((resolve, reject) => {
108
- const jdeployDir = path.join(os.homedir(), '.jdeploy');
109
+ const jdeployDir = jdeployHomeDir;
109
110
  if (!fs.existsSync(jdeployDir)) {
110
111
  fs.mkdirSync(jdeployDir);
111
112
  }
@@ -231,8 +232,16 @@ function njreWrap() {
231
232
  const { openjdk_impl = 'hotspot', release = 'latest', type = 'jre', javafx = false, provider = 'zulu' } = options
232
233
  options = { ...options, openjdk_impl, release, type }
233
234
 
235
+ // Determine the architecture based on the platform and environment
236
+ let arch = process.arch;
237
+ if (arch === 'arm64' || arch === 'aarch64') {
238
+ arch = 'aarch64'; // For ARM-based systems, standardize on aarch64
239
+ } else {
240
+ arch = 'x64'; // Default to x64 for non-ARM systems
241
+ }
242
+
234
243
  if (provider === 'zulu') {
235
- return installZulu(version, options);
244
+ return installZulu(version, options, arch);
236
245
  }
237
246
 
238
247
  let url = 'https://api.adoptopenjdk.net/v2/info/releases/openjdk' + version + '?'
@@ -258,13 +267,9 @@ function njreWrap() {
258
267
  return Promise.reject(new Error('Unsupported operating system'))
259
268
  }
260
269
  }
270
+
261
271
  if (!options.arch) {
262
- if (options.os == 'mac') {
263
- // For now, for compatibility reasons use x64 always
264
- options.arch = 'x64';
265
- } else if (/^ppc64|s390x|x32|x64$/g.test(process.arch)) options.arch = process.arch
266
- else if (process.arch === 'ia32') options.arch = 'x32'
267
- else return Promise.reject(new Error('Unsupported architecture'))
272
+ options.arch = arch; // Use the detected architecture
268
273
  }
269
274
 
270
275
  Object.keys(options).forEach(key => { url += key + '=' + options[key] + '&' })
@@ -279,68 +284,85 @@ function njreWrap() {
279
284
  .then(extract)
280
285
  }
281
286
 
282
- function installZulu(version = 11, options = {}) {
283
- const { type = 'jre', javafx = false } = options
284
- var q = {
287
+ function installZulu(version = 11, options = {}, arch) {
288
+ const { type = 'jre', javafx = false } = options;
285
289
 
290
+ // Prepare the query parameters for the request
291
+ let q = {
286
292
  java_version: version,
287
293
  ext: 'zip',
288
294
  bundle_type: type,
289
- javafx: ''+javafx,
290
- arch: 'x86',
295
+ javafx: '' + javafx,
296
+ arch: arch, // Use the detected architecture
291
297
  hw_bitness: '64',
298
+ };
292
299
 
293
- };
294
-
300
+ // Base URL for the Azul API
301
+ const zuluBaseURL = "https://api.azul.com/zulu/download/community/v1.0/bundles/latest/binary?";
295
302
 
296
- var zuluBaseURL = "https://api.azul.com/zulu/download/community/v1.0/bundles/latest/binary?"
297
- if (!options.os) {
298
- switch (process.platform) {
299
-
300
- case 'darwin':
301
- q.os = 'macos'
302
- break
303
- case 'linux':
304
- q.os = 'linux'
305
- q.ext = 'tar.gz'
306
- break
303
+ // Determine the OS
304
+ if (!options.os) {
305
+ switch (process.platform) {
306
+ case 'darwin':
307
+ q.os = 'macos';
308
+ break;
309
+ case 'linux':
310
+ q.os = 'linux';
311
+ q.ext = 'tar.gz';
312
+ break;
313
+ case 'win32':
314
+ case 'win64':
315
+ q.os = 'windows';
316
+ break;
317
+ default:
318
+ return Promise.reject(new Error('Unsupported operating system'));
319
+ }
320
+ }
307
321
 
308
- case 'win32':
309
- case 'win64':
310
- q.os = 'windows'
311
- break
312
- default:
313
- return Promise.reject(new Error('Unsupported operating system'))
314
- }
315
- }
322
+ // Construct the URL for the download request
323
+ let url = zuluBaseURL;
324
+ Object.keys(q).forEach(key => { url += key + '=' + q[key] + '&' });
316
325
 
326
+ const tmpdir = path.join(os.tmpdir(), 'njre');
317
327
 
318
- var url = zuluBaseURL;
319
- Object.keys(q).forEach(key => { url += key + '=' + q[key] + '&' })
320
- const tmpdir = path.join(os.tmpdir(), 'njre')
321
- //console.log("Downloading "+url);
322
- return download(tmpdir, url)
328
+ // Function to handle the download and extraction
329
+ const attemptDownload = (url) => {
330
+ return download(tmpdir, url)
323
331
  .then(move)
324
- .then(extract)
325
-
332
+ .then(extract);
333
+ };
334
+
335
+ // First, attempt to download the JRE
336
+ return download(tmpdir, url)
337
+ .then(response => {
338
+ // If the JRE is available, proceed with the download and extraction
339
+ if (response.status === 200) {
340
+ return attemptDownload(url);
341
+ } else {
342
+ // If JRE is not available, switch to JDK
343
+ console.log(`JRE not available for version ${version}, falling back to JDK...`);
344
+ // Update the query to request JDK instead of JRE
345
+ q.bundle_type = 'jdk'; // Switch to JDK
346
+ url = zuluBaseURL;
347
+ Object.keys(q).forEach(key => { url += key + '=' + q[key] + '&' });
348
+ return attemptDownload(url); // Try downloading the JDK
349
+ }
350
+ })
351
+ .catch(err => {
352
+ console.error("Download failed: ", err);
353
+ throw err; // Re-throw the error after logging
354
+ });
326
355
  }
327
356
 
328
- return {install:install};
329
-
330
-
331
357
 
358
+ return {install:install};
332
359
  }
333
360
 
334
361
 
335
362
  var fs = require('fs');
336
- var os = require('os');
337
- var path = require('path');
338
363
  const njre = njreWrap();
339
364
  const targetJavaVersion = parseInt(javaVersionString);
340
365
  var shell = require("shelljs/global");
341
- function getJdeploySupportDir() {
342
- return os.homedir() + path.sep + ".jdeploy";
343
- }
344
366
 
345
367
  function getJavaVersion(binPath) {
346
368
 
@@ -408,7 +430,7 @@ function getJavaHomeInPath(basepath) {
408
430
  }
409
431
 
410
432
  function findSupportedRuntime(javaVersion, jdk, javafx) {
411
- var jdeployDir = path.join(os.homedir(), ".jdeploy");
433
+ var jdeployDir = jdeployHomeDir;
412
434
  var JAVA_HOME_OVERRIDE = env['JDEPLOY_JAVA_HOME_OVERRIDE'];
413
435
 
414
436
  if (JAVA_HOME_OVERRIDE && fs.existsSync(JAVA_HOME_OVERRIDE)) {
@@ -460,7 +482,7 @@ function getEmbeddedJavaHome() {
460
482
  }
461
483
  var typeDir = jdk ? 'jdk' : 'jre';
462
484
 
463
- var jreDir = path.join(os.homedir(), '.jdeploy', 'jre', vs, 'jre');
485
+ var jreDir = path.join(jdeployHomeDir, 'jre', vs, 'jre');
464
486
  try {
465
487
  var out = jreDir + path.sep + getDirectories(jreDir)[0] + (_driver ? (path.sep + _driver) : '');
466
488
  return out;
package/package.json CHANGED
@@ -1 +1 @@
1
- {"bin":{"adm":"jdeploy-bundle/jdeploy.js"},"author":"Joe Page","description":"Java desktop app to manage multiple Android devices via adb","main":"index.js","preferGlobal":true,"repository":"","version":"25.8.11-1614","jdeploy":{"jdk":false,"checksums":{"icon.png":"4b08e47a91c363c29f10aa1ca9a9ce55","installsplash.png":"b8596a651c248c986b5f572760b64dbf"},"javaVersion":"17","documentTypes":[{"editor":false,"extension":"apk","mimetype":"application/vnd.android.package-archive"},{"editor":false,"extension":"xapk","mimetype":"application/vnd.android.package-archive"}],"jar":"target/AndroidDeviceManager.jar","javafx":false,"title":"Android Device Manager"},"dependencies":{"command-exists-promise":"^2.0.2","node-fetch":"2.6.7","tar":"^4.4.8","yauzl":"^2.10.0","run":"^1.5.0","jdeploy":"^4.1.2","shelljs":"^0.8.4"},"license":"ISC","name":"android-device-manager","files":["jdeploy-bundle"],"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"homepage":""}
1
+ {"bin":{"adm":"jdeploy-bundle/jdeploy.js"},"author":"Joe Page","description":"Java desktop app to manage multiple Android devices via adb","main":"index.js","preferGlobal":true,"repository":"","version":"25.10.16-1930","jdeploy":{"jdk":false,"checksums":{"icon.png":"4b08e47a91c363c29f10aa1ca9a9ce55","installsplash.png":"b8596a651c248c986b5f572760b64dbf"},"mainClass":"com.jpage4500.devicemanager.MainApplication","javaVersion":"17","documentTypes":[{"editor":false,"extension":"apk","mimetype":"application/vnd.android.package-archive"},{"editor":false,"extension":"xapk","mimetype":"application/vnd.android.package-archive"}],"jar":"target/AndroidDeviceManager.jar","javafx":false,"title":"Android Device Manager"},"dependencies":{"command-exists-promise":"^2.0.2","node-fetch":"2.6.7","tar":"^4.4.8","yauzl":"^2.10.0","run":"^1.5.0","jdeploy":"^5.2.5","shelljs":"^0.8.4"},"license":"ISC","name":"android-device-manager","files":["jdeploy-bundle"],"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"homepage":""}