List of usage examples for android.util Log w
public static int w(String tag, String msg, Throwable tr)
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.service.SetKernelTask.java
@Override public void execute() { Log.d(TAG, "Setting kernel for " + mRomId); SetKernelResult result = SetKernelResult.FAILED; MbtoolConnection conn = null;//from w ww. java 2 s . co m try { conn = new MbtoolConnection(getContext()); MbtoolInterface iface = conn.getInterface(); result = iface.setKernel(getContext(), mRomId); } catch (IOException e) { Log.e(TAG, "mbtool communication error", e); } catch (MbtoolException e) { Log.e(TAG, "mbtool error", e); sendOnMbtoolError(e.getReason()); } catch (MbtoolCommandException e) { Log.w(TAG, "mbtool command error", e); } finally { IOUtils.closeQuietly(conn); } synchronized (mStateLock) { mResult = result; sendOnSetKernel(); mFinished = true; } }
From source file:com.commonsware.android.tuning.downloader.Downloader.java
@Override public void onHandleIntent(Intent i) { HttpGet getMethod = new HttpGet(i.getData().toString()); int result = Activity.RESULT_CANCELED; try {//from ww w. j a v a2s.co m ResponseHandler<byte[]> responseHandler = new ByteArrayResponseHandler(); byte[] responseBody = client.execute(getMethod, responseHandler); File output = new File(Environment.getExternalStorageDirectory(), i.getData().getLastPathSegment()); if (output.exists()) { output.delete(); } FileOutputStream fos = new FileOutputStream(output.getPath()); fos.write(responseBody); fos.close(); result = Activity.RESULT_OK; } catch (IOException e2) { Log.e(getClass().getName(), "Exception in download", e2); } Bundle extras = i.getExtras(); if (extras != null) { Messenger messenger = (Messenger) extras.get(EXTRA_MESSENGER); Message msg = Message.obtain(); msg.arg1 = result; try { messenger.send(msg); } catch (android.os.RemoteException e1) { Log.w(getClass().getName(), "Exception sending message", e1); } } }
From source file:com.auth0.util.Telemetry.java
public String asBase64() { Map<String, Object> info = new HashMap<>(); info.put("name", getName("Lock.Android")); info.put("version", getVersion(BuildConfig.VERSION_NAME)); if (isNonEmpty(this.libraryVersion)) { info.put("lib_version", this.libraryVersion); }//from w w w . ja v a2 s. c om if (this.extra != null) { info.putAll(this.extra); } String clientInfo = null; try { String json = new ObjectMapper().writeValueAsString(info); Log.v(TAG, "Telemetry JSON is " + json); clientInfo = Base64.encodeToString(json.getBytes(Charset.defaultCharset()), Base64.URL_SAFE | Base64.NO_WRAP); } catch (JsonProcessingException e) { Log.w(TAG, "Failed to build client info", e); } return clientInfo; }
From source file:com.pocketsoap.convodroid.loaders.JsonLoader.java
@Override public ReturnType loadInBackground() { Log.v("Convodroid", "JsonLoader::loadInBackground " + request.getMethod() + " " + request.getPath()); try {//from w w w . java2s . c om RestResponse res = client.sendSync(request); Log.v("Convodroid", "JsonLoader:: got http response " + res.getStatusCode() + " for " + request.getPath()); if (res.getStatusCode() == HttpStatus.SC_NO_CONTENT) return null; ObjectMapper mapper = new ObjectMapper(); mapper.configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); return mapper.readValue(res.getHttpResponse().getEntity().getContent(), typeReference); } catch (JsonParseException e) { Log.w("Convodroid", "JsonLoader error", e); } catch (JsonMappingException e) { Log.w("Convodroid", "JsonLoader error", e); } catch (IllegalStateException e) { Log.w("Convodroid", "JsonLoader error", e); } catch (IOException e) { Log.w("Convodroid", "JsonLoader error", e); } return null; }
From source file:com.microsoft.azure.engagement.ws.VideoParser.java
/** * Method that returns the result object * * @param urlString The url to parse/*from w w w.jav a 2s . c o m*/ * @return The result object */ private static final JSONObject getJsonObject(String urlString) { Log.d(VideoParser.TAG, "Parse URL: " + urlString); InputStream inputStream = null; try { final URL url = new URL(urlString); final URLConnection urlConnection = url.openConnection(); inputStream = new BufferedInputStream(urlConnection.getInputStream()); final BufferedReader reader = new BufferedReader( new InputStreamReader(urlConnection.getInputStream(), "utf-8"), 8); final StringBuilder sb = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { sb.append(line); } final String json = sb.toString(); return new JSONObject(json); } catch (Exception e) { Log.w(VideoParser.TAG, "Failed to parse the json for media list", e); return null; } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { Log.w(VideoParser.TAG, "JSON feed closed", e); } } } }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.service.CacheWallpaperTask.java
@Override public void execute() { MbtoolConnection conn = null;/*from w ww . j av a 2s .co m*/ CacheWallpaperResult result = CacheWallpaperResult.FAILED; try { conn = new MbtoolConnection(getContext()); MbtoolInterface iface = conn.getInterface(); result = RomUtils.cacheWallpaper(getContext(), mRomInfo, iface); } catch (IOException e) { Log.e(TAG, "mbtool communication error", e); } catch (MbtoolException e) { Log.e(TAG, "mbtool error", e); sendOnMbtoolError(e.getReason()); } catch (MbtoolCommandException e) { Log.w(TAG, "mbtool command error", e); } finally { IOUtils.closeQuietly(conn); } synchronized (mStateLock) { mResult = result; sendOnCachedWallpaper(); mFinished = true; } }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.service.WipeRomTask.java
@Override public void execute() { MbtoolConnection conn = null;/*from w w w .j a v a 2s . c o m*/ try { conn = new MbtoolConnection(getContext()); MbtoolInterface iface = conn.getInterface(); WipeResult result = iface.wipeRom(mRomId, mTargets); synchronized (mStateLock) { mTargetsSucceeded = result.succeeded; mTargetsFailed = result.failed; } } catch (IOException e) { Log.e(TAG, "mbtool communication error", e); } catch (MbtoolException e) { Log.e(TAG, "mbtool error", e); sendOnMbtoolError(e.getReason()); } catch (MbtoolCommandException e) { Log.w(TAG, "mbtool command error", e); } finally { IOUtils.closeQuietly(conn); } synchronized (mStateLock) { sendOnWipedRom(); mFinished = true; } }
From source file:com.kevinquan.android.utils.JSONUtils.java
/** * Retrieve a JSON Array object stored at the provided key from the provided JSON object * @param obj The JSON object to retrieve from * @param key The key to retrieve/*from ww w . jav a2 s . c o m*/ * @return the JSON Array object stored in the key, or null if the key doesn't exist */ public static JSONArray safeGetArray(JSONObject obj, String key) { if (obj == null || TextUtils.isEmpty(key)) return null; if (obj.has(key)) { try { return obj.getJSONArray(key); } catch (JSONException e) { Log.w(TAG, "Could not get JSONArray from key " + key, e); } } return null; }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.service.SwitchRomTask.java
@Override public void execute() { Log.d(TAG, "Switching to " + mRomId + " (force=" + mForceChecksumsUpdate + ")"); SwitchRomResult result = SwitchRomResult.FAILED; MbtoolConnection conn = null;/*from w w w .jav a 2 s . c o m*/ try { conn = new MbtoolConnection(getContext()); MbtoolInterface iface = conn.getInterface(); result = iface.switchRom(getContext(), mRomId, mForceChecksumsUpdate); } catch (IOException e) { Log.e(TAG, "mbtool communication error", e); } catch (MbtoolException e) { Log.e(TAG, "mbtool error", e); sendOnMbtoolError(e.getReason()); } catch (MbtoolCommandException e) { Log.w(TAG, "mbtool command error", e); } finally { IOUtils.closeQuietly(conn); } synchronized (mStateLock) { mResult = result; sendOnSwitchedRom(); mFinished = true; } }
From source file:fr.inria.ucn.collectors.DeviceInfoCollector.java
@Override public void run(Context c, long ts) { try {/*from w w w . j a va2 s .c o m*/ JSONObject data = new JSONObject(); // android dev info + build JSONObject build = new JSONObject(); build.put("brand", android.os.Build.BRAND); build.put("board", android.os.Build.BOARD); build.put("cpu_api", android.os.Build.CPU_ABI); build.put("device", android.os.Build.DEVICE); build.put("display", android.os.Build.DISPLAY); build.put("manufacturer", android.os.Build.MANUFACTURER); build.put("model", android.os.Build.MODEL); build.put("product", android.os.Build.PRODUCT); build.put("version_sdk", android.os.Build.VERSION.SDK_INT); build.put("version_release", android.os.Build.VERSION.RELEASE); data.put("build", build); // display JSONObject display = new JSONObject(); DisplayMetrics metrics = c.getResources().getDisplayMetrics(); display.put("dpi", metrics.densityDpi); display.put("height", metrics.heightPixels); display.put("width", metrics.widthPixels); display.put("density", metrics.density); data.put("display", display); // done Helpers.sendResultObj(c, "device_info", ts, data); } catch (JSONException jex) { Log.w(Constants.LOGTAG, "failed to create json object", jex); } }