@Test public void setupADBCrypto() { try { AdbCrypto k1=service.setupADBCrypto(); AdbCrypto k2=service.setupADBCrypto(); assertEquals(k1.getAdbPublicKeyPayload(), k2.getAdbPublicKeyPayload()); } catch (Exception err) { } }
public AdbCrypto setupADBCrypto() throws NoSuchAlgorithmException, IOException { String cachePath = this.getApplicationContext().getCacheDir().getAbsolutePath(); File pub = new File(cachePath + File.separatorChar + "pub.key"); File priv = new File(cachePath + File.separatorChar + "priv.key"); AdbCrypto crypto = null; AdbBase64 newadb64 = data -> { String s = Base64.encodeToString(data, 16).replace("\n", ""); return s; }; if (pub.exists() && priv.exists()) { try { crypto = AdbCrypto.loadAdbKeyPair(newadb64, priv, pub); } catch (Exception e) { crypto = null; } } if (crypto == null) { crypto = AdbCrypto.generateAdbKeyPair(newadb64); crypto.saveAdbKeyPair(priv, pub); Log.d("ADBService", "Generated new adb keypair"); } else { Log.d("ADBService", "Loaded existing adb keypair"); } return crypto; }
ADBService extends IntentService { public AdbCrypto setupADBCrypto() throws NoSuchAlgorithmException, IOException { String cachePath = this.getApplicationContext().getCacheDir().getAbsolutePath(); File pub = new File(cachePath + File.separatorChar + "pub.key"); File priv = new File(cachePath + File.separatorChar + "priv.key"); AdbCrypto crypto = null; AdbBase64 newadb64 = data -> { String s = Base64.encodeToString(data, 16).replace("\n", ""); return s; }; if (pub.exists() && priv.exists()) { try { crypto = AdbCrypto.loadAdbKeyPair(newadb64, priv, pub); } catch (Exception e) { crypto = null; } } if (crypto == null) { crypto = AdbCrypto.generateAdbKeyPair(newadb64); crypto.saveAdbKeyPair(priv, pub); Log.d("ADBService", "Generated new adb keypair"); } else { Log.d("ADBService", "Loaded existing adb keypair"); } return crypto; } }
ADBService extends IntentService { public AdbCrypto setupADBCrypto() throws NoSuchAlgorithmException, IOException { String cachePath = this.getApplicationContext().getCacheDir().getAbsolutePath(); File pub = new File(cachePath + File.separatorChar + "pub.key"); File priv = new File(cachePath + File.separatorChar + "priv.key"); AdbCrypto crypto = null; AdbBase64 newadb64 = data -> { String s = Base64.encodeToString(data, 16).replace("\n", ""); return s; }; if (pub.exists() && priv.exists()) { try { crypto = AdbCrypto.loadAdbKeyPair(newadb64, priv, pub); } catch (Exception e) { crypto = null; } } if (crypto == null) { crypto = AdbCrypto.generateAdbKeyPair(newadb64); crypto.saveAdbKeyPair(priv, pub); Log.d("ADBService", "Generated new adb keypair"); } else { Log.d("ADBService", "Loaded existing adb keypair"); } return crypto; } ADBService(String name);  ADBService(); }
ADBService extends IntentService { public AdbCrypto setupADBCrypto() throws NoSuchAlgorithmException, IOException { String cachePath = this.getApplicationContext().getCacheDir().getAbsolutePath(); File pub = new File(cachePath + File.separatorChar + "pub.key"); File priv = new File(cachePath + File.separatorChar + "priv.key"); AdbCrypto crypto = null; AdbBase64 newadb64 = data -> { String s = Base64.encodeToString(data, 16).replace("\n", ""); return s; }; if (pub.exists() && priv.exists()) { try { crypto = AdbCrypto.loadAdbKeyPair(newadb64, priv, pub); } catch (Exception e) { crypto = null; } } if (crypto == null) { crypto = AdbCrypto.generateAdbKeyPair(newadb64); crypto.saveAdbKeyPair(priv, pub); Log.d("ADBService", "Generated new adb keypair"); } else { Log.d("ADBService", "Loaded existing adb keypair"); } return crypto; } ADBService(String name);  ADBService(); @Override void onDestroy(); @Override void onCreate(); AdbCrypto setupADBCrypto(); }
ADBService extends IntentService { public AdbCrypto setupADBCrypto() throws NoSuchAlgorithmException, IOException { String cachePath = this.getApplicationContext().getCacheDir().getAbsolutePath(); File pub = new File(cachePath + File.separatorChar + "pub.key"); File priv = new File(cachePath + File.separatorChar + "priv.key"); AdbCrypto crypto = null; AdbBase64 newadb64 = data -> { String s = Base64.encodeToString(data, 16).replace("\n", ""); return s; }; if (pub.exists() && priv.exists()) { try { crypto = AdbCrypto.loadAdbKeyPair(newadb64, priv, pub); } catch (Exception e) { crypto = null; } } if (crypto == null) { crypto = AdbCrypto.generateAdbKeyPair(newadb64); crypto.saveAdbKeyPair(priv, pub); Log.d("ADBService", "Generated new adb keypair"); } else { Log.d("ADBService", "Loaded existing adb keypair"); } return crypto; } ADBService(String name);  ADBService(); @Override void onDestroy(); @Override void onCreate(); AdbCrypto setupADBCrypto();  }