private static String extractConfig() { if (!enabled()) { UserError.Log.d(TAG, "Not tested except on RPI - skipping"); return null; } return readSystemFileContent(KEY_STORE); }
private static String extractCachedBtMac() { if (localMac == null) { localMac = extractBtMac(); } return localMac; }
final String data = extractConfig(); if (data == null) { UserError.Log.e(TAG, "Cannot extract local config for merge"); final String[] adapterArray = split(xfer.adapter); final String[] deviceArray = split(xfer.device); final String[] array = split(data); case INJECT_COLLISION_KEY: if (!processedAdapter) { addAll(adapterArray, output); processedAdapter = true; case INJECT_DEVICE_KEY: if (!processedDevice) { addAll(deviceArray, output); processedDevice = true; add(line, output); break; UserError.Log.d(TAG, "No current device - appending"); output.append("\n"); addAll(deviceArray, output); } else { UserError.Log.e(TAG, "Device section without adapter"); writeSystemFileContent(KEY_STORE, fOutput); UserError.Log.d(TAG, "Merge probably successful - restarting bluetooth");
private static Xfer getXfer(final String data) { if (data == null) return null; final String[] array = split(data); SearchState state = SCAN; final StringBuilder asb = new StringBuilder(); add(line, asb); break; case COPY_DEVICE_KEY: add(line, dsb); break; .setSpoofMac(extractCachedBtMac()); return xfer.valid() ? xfer : null;
private static synchronized String readSystemFileContent(final String path) { final String tmpPath = getUniqueTmpFileName(); final List<String> results = Root.exec( String.format("cp '%s' '%s'", path, tmpPath), String.format("chmod 777 '%s'", tmpPath)); if (results == null) return null; final String result = readFileContent(tmpPath); Root.exec(String.format("rm -f '%s'", tmpPath)); return result; }
private static synchronized boolean writeSystemFileContent(final String path, final String content) { final String tmpPath = getUniqueTmpFileName(); if (!writeFileContent(tmpPath, content)) { UserError.Log.e(TAG, "Failed to write to: " + path); return false; } // TODO detect failure?? Root.exec( String.format("cat '%s' > '%s'", tmpPath, path), String.format("rm -f '%s'", tmpPath)); return true; }
private static String getExtractedXferJson() { final Xfer xfer = getXfer(extractConfig()); return xfer != null ? xfer.valid() ? xfer.toJson() : null : null; }
private synchronized static void pollTask(boolean hint) { // TODO rate limit checking without hint? allow force push and improve persistence final String result = getExtractedXferJson(); if (result != null) { if (result.equals(lastBroadcast) && JoH.pratelimit("mimeograph last bcast", 3600)) { UserError.Log.d(TAG, "Data unchanged since last broadcast"); } else { GcmActivity.sendMimeoGraphUpdate(result); lastBroadcast = result; } } else { UserError.Log.d(TAG, "No valid Xfer on poll"); } }
final String data = extractConfig(); if (data == null) { UserError.Log.e(TAG, "Cannot extract local config for merge"); final String[] adapterArray = split(xfer.adapter); final String[] deviceArray = split(xfer.device); final String[] array = split(data); case INJECT_COLLISION_KEY: if (!processedAdapter) { addAll(adapterArray, output); processedAdapter = true; case INJECT_DEVICE_KEY: if (!processedDevice) { addAll(deviceArray, output); processedDevice = true; add(line, output); break; UserError.Log.d(TAG, "No current device - appending"); output.append("\n"); addAll(deviceArray, output); } else { UserError.Log.e(TAG, "Device section without adapter"); writeSystemFileContent(KEY_STORE, fOutput); UserError.Log.d(TAG, "Merge probably successful - restarting bluetooth");
private static Xfer getXfer(final String data) { if (data == null) return null; final String[] array = split(data); SearchState state = SCAN; final StringBuilder asb = new StringBuilder(); add(line, asb); break; case COPY_DEVICE_KEY: add(line, dsb); break; .setSpoofMac(extractCachedBtMac()); return xfer.valid() ? xfer : null;
private static synchronized String readSystemFileContent(final String path) { final String tmpPath = getUniqueTmpFileName(); final List<String> results = Root.exec( String.format("cp '%s' '%s'", path, tmpPath), String.format("chmod 777 '%s'", tmpPath)); if (results == null) return null; final String result = readFileContent(tmpPath); Root.exec(String.format("rm -f '%s'", tmpPath)); return result; }
private static synchronized boolean writeSystemFileContent(final String path, final String content) { final String tmpPath = getUniqueTmpFileName(); if (!writeFileContent(tmpPath, content)) { UserError.Log.e(TAG, "Failed to write to: " + path); return false; } // TODO detect failure?? Root.exec( String.format("cat '%s' > '%s'", tmpPath, path), String.format("rm -f '%s'", tmpPath)); return true; }
private static String getExtractedXferJson() { final Xfer xfer = getXfer(extractConfig()); return xfer != null ? xfer.valid() ? xfer.toJson() : null : null; }
private synchronized static void pollTask(boolean hint) { // TODO rate limit checking without hint? allow force push and improve persistence final String result = getExtractedXferJson(); if (result != null) { if (result.equals(lastBroadcast) && JoH.pratelimit("mimeograph last bcast", 3600)) { UserError.Log.d(TAG, "Data unchanged since last broadcast"); } else { GcmActivity.sendMimeoGraphUpdate(result); lastBroadcast = result; } } else { UserError.Log.d(TAG, "No valid Xfer on poll"); } }
final String data = extractConfig(); if (data == null) { UserError.Log.e(TAG, "Cannot extract local config for merge"); final String[] adapterArray = split(xfer.adapter); final String[] deviceArray = split(xfer.device); final String[] array = split(data); case INJECT_COLLISION_KEY: if (!processedAdapter) { addAll(adapterArray, output); processedAdapter = true; case INJECT_DEVICE_KEY: if (!processedDevice) { addAll(deviceArray, output); processedDevice = true; add(line, output); break; UserError.Log.d(TAG, "No current device - appending"); output.append("\n"); addAll(deviceArray, output); } else { UserError.Log.e(TAG, "Device section without adapter"); writeSystemFileContent(KEY_STORE, fOutput); UserError.Log.d(TAG, "Merge probably successful - restarting bluetooth");