private String __startServer() { String errmsg = ""; try { AndroidFile f = new AndroidFile(localPath); Context ctx = cordova.getActivity().getApplicationContext(); if (!fromApplicationData) { AssetManager am = ctx.getResources().getAssets(); f.setAssetManager(am); dumpAssets(am); } server = new WebServer(port, f, cordovaRoot, ctx.getResources().getAssets()); } catch (IOException e) { errmsg = String.format("IO Exception: %s", e.getMessage()); Log.w(LOGTAG, errmsg); } return errmsg; }
/** * Updates the list of APDU messages and writes it to the log file * * @param toAdd The APDU message to add */ public void update(String toAdd) { if (toAdd.equals(ApduService.NON_RECOGNISED_APDU)) { Vibrator v = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(500); } protocol = toAdd + "\n"; androidFile.write(protocol); protocols += protocol + "\n"; output.setText(protocols); scrollView.post( new Runnable() { @Override public void run() { scrollView.fullScroll(View.FOCUS_DOWN); } }); }
/** * Creates a new unique file with the following pattern: <code>kouchat-current_time.extension * </code>. * * @param image The image to get the extension from. * @return A new unique file. Should not exist on the file system. */ public static File createNewFile(final AndroidFile image) { final File externalStorageDirectory = Environment.getExternalStorageDirectory(); final String fileName = "kouchat-" + System.currentTimeMillis() + image.getExtension(); return new File(externalStorageDirectory, fileName); }