List of usage examples for android.util Log w
public static int w(String tag, Throwable tr)
From source file:com.joptimizer.util.CholeskyFactorization.java
/** * Cholesky factorization L of psd matrix, Q = L.LT *///from www.jav a2 s. c o m private void factorize() throws Exception { if (!MatrixUtils.isSymmetric(new Array2DRowRealMatrix(Q), Utils.getDoubleMachineEpsilon())) { throw new Exception("Matrix is not symmetric"); } int N = Q.length; double[][] L = new double[N][N]; this.eigenvalues = new ArrayList<Double>(); for (int i = 0; i < N; i++) { for (int j = 0; j <= i; j++) { double sum = 0.0; for (int k = 0; k < j; k++) { sum += L[i][k] * L[j][k]; } if (i == j) { double d = Math.sqrt(Q[i][i] - sum); if (Double.isNaN(d) || d * d < Utils.getDoubleMachineEpsilon()) {//d*d is a Q's eigenvalue Log.w(MainActivity.JOPTIMIZER_LOGTAG, "Not positive eigenvalues: " + d * d); throw new Exception("not positive definite matrix"); } L[i][i] = d; this.eigenvalues.add(this.eigenvalues.size(), d * d); } else { L[i][j] = 1.0 / L[j][j] * (Q[i][j] - sum); } } } this.L = L; }
From source file:com.cpyf.twelve.spies.qr.code.result.supplement.ProductResultInfoRetriever.java
private static String consume(HttpEntity entity) { Log.d(TAG, "Consuming entity"); ByteArrayOutputStream out = new ByteArrayOutputStream(); InputStream in = null;/* w w w. ja v a2 s. c o m*/ try { in = entity.getContent(); byte[] buffer = new byte[1024]; int bytesRead; while ((bytesRead = in.read(buffer)) > 0) { out.write(buffer, 0, bytesRead); } } catch (IOException ioe) { Log.w(TAG, ioe); // continue } finally { if (in != null) { try { in.close(); } catch (IOException ioe) { // continue } } } try { return new String(out.toByteArray(), "UTF-8"); } catch (UnsupportedEncodingException uee) { // can't happen throw new IllegalStateException(uee); } }
From source file:com.norman0406.slimgress.API.Knobs.PortalKnobs.java
public Band getBandForLevel(int level) { for (Band band : mBands) { if (band.applicableLevels.contains((Integer) level)) return band; }/* ww w . java2s . c o m*/ Log.w("PortalKnobs", "band not found for level: " + level); return null; }
From source file:cz.cvut.jirutjak.fastimport.droid.oauth2.OAuth2ClientHttpRequestInterceptor.java
@Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { try {// w w w.ja va 2 s . c om OAuth2AccessToken token = authProvider.obtainAccessToken(resource); String accessToken = token.getAccessToken(); Log.d(TAG, AUTH_HEADER + ": " + TOKEN_PREFIX + accessToken); request.getHeaders().set(AUTH_HEADER, TOKEN_PREFIX + accessToken); } catch (AuthorizationRequiredException ex) { Log.w(TAG, "Authorization required!"); } return execution.execute(request, body); }
From source file:org.thoughtcrime.securesms.mms.MmsConnection.java
protected static boolean checkRouteToHost(Context context, String host, boolean usingMmsRadio) throws IOException { InetAddress inetAddress = InetAddress.getByName(host); if (!usingMmsRadio) { if (inetAddress.isSiteLocalAddress()) { throw new IOException("RFC1918 address in non-MMS radio situation!"); }//w ww. ja v a 2s .c o m Log.w(TAG, "returning vacuous success since MMS radio is not in use"); return true; } byte[] ipAddressBytes = inetAddress.getAddress(); if (ipAddressBytes == null || ipAddressBytes.length != 4) { Log.w(TAG, "returning vacuous success since android.net package doesn't support IPv6"); return true; } Log.w(TAG, "Checking route to address: " + host + ", " + inetAddress.getHostAddress()); ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); int ipAddress = Conversions.byteArrayToIntLittleEndian(ipAddressBytes, 0); boolean routeToHostObtained = manager.requestRouteToHost(MmsRadio.TYPE_MOBILE_MMS, ipAddress); Log.w(TAG, "requestRouteToHost result: " + routeToHostObtained); return routeToHostObtained; }
From source file:com.intel.iotkitlib.utils.Utilities.java
public static List<NameValuePair> createBasicHeadersWithDeviceToken() { if (sharedPreferences == null) { Log.w(TAG, "cannot find shared preferences object, not able to take device token"); return null; }/*from w ww. j a v a 2 s. c o m*/ //building header value(need persistent to store to take auth token at run time) String deviceToken = IotKit.HEADER_AUTHORIZATION_BEARER + " " + sharedPreferences.getString("device_token", ""); return Utilities .addHttpHeaders( Utilities.addHttpHeaders(Utilities.createEmptyListForHeaders(), IotKit.HEADER_CONTENT_TYPE_NAME, IotKit.HEADER_CONTENT_TYPE_JSON), IotKit.HEADER_AUTHORIZATION, deviceToken); }
From source file:com.novel.lightnovel.Utils.DrawableManager.java
public Drawable fetchDrawable(String urlString) { if (drawableMap.containsKey(urlString)) { return drawableMap.get(urlString); }//from w w w . j a v a2 s . c o m Log.d(this.getClass().getSimpleName(), "image url:" + urlString); try { InputStream is = fetch(urlString); Drawable drawable = Drawable.createFromStream(is, "src"); if (drawable != null) { drawableMap.put(urlString, drawable); Log.d(this.getClass().getSimpleName(), "got a thumbnail drawable: " + drawable.getBounds() + ", " + drawable.getIntrinsicHeight() + "," + drawable.getIntrinsicWidth() + ", " + drawable.getMinimumHeight() + "," + drawable.getMinimumWidth()); } else { Log.w(this.getClass().getSimpleName(), "could not get thumbnail"); } return drawable; } catch (MalformedURLException e) { Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e); return null; } catch (IOException e) { Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e); return null; } }
From source file:interactive.billing.Security.java
/** * Verifies that the data was signed with the given signature, and returns * the verified purchase. The data is in JSON format and signed * with a private key. The data also contains the {@link PurchaseState} * and product ID of the purchase./*from www. ja v a 2 s.c o m*/ * @param base64PublicKey the base64-encoded public key to use for verifying. * @param signedData the signed JSON string (signed, not encrypted) * @param signature the signature for the data, signed with the private key */ public static boolean verifyPurchase(String base64PublicKey, String signedData, String signature) { // if (TextUtils.isEmpty(signedData) || TextUtils.isEmpty(base64PublicKey) || // TextUtils.isEmpty(signature)) { // Log.e(TAG, "Purchase verification failed: missing data."); // return false; // } // // PublicKey key = Security.generatePublicKey(base64PublicKey); // return Security.verify(key, signedData, signature); if (signedData == null) { Log.e(TAG, "data is null"); return false; } boolean verified = false; if (!TextUtils.isEmpty(signature)) { PublicKey key = Security.generatePublicKey(base64PublicKey); verified = Security.verify(key, signedData, signature); if (!verified) { Log.w(TAG, "signature does not match data."); return false; } } return true; }
From source file:com.aldogomez.bluebird.DrawableManager.java
public Drawable fetchDrawable(String urlString) { if (drawableMap.containsKey(urlString)) { return drawableMap.get(urlString); }/*from w w w . j a v a2 s . c om*/ Log.d(this.getClass().getSimpleName(), "image url:" + urlString); try { InputStream is = fetch(urlString); Drawable drawable = Drawable.createFromStream(is, "src"); if (drawable != null) { drawableMap.put(urlString, drawable); Log.d(this.getClass().getSimpleName(), "got a thumbnail drawable: " + drawable.getBounds() + ", " + drawable.getIntrinsicHeight() + "," + drawable.getIntrinsicWidth() + ", " + drawable.getMinimumHeight() + "," + drawable.getMinimumWidth()); } else { Log.w(this.getClass().getSimpleName(), "could not get thumbnail"); } return drawable; } catch (MalformedURLException e) { Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e); return null; } catch (IOException e) { Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e); return null; } }
From source file:es.upm.dit.gsi.noticiastvi.gtv.account.CreateThread.java
@Override public void run() { DefaultHttpClient client = new DefaultHttpClient(); StringBuilder query = new StringBuilder(); try {/*from www.j a v a2 s .co m*/ query.append(Constant.SERVER_URL + "?action=" + ACTION + "&name="); query.append(URLEncoder.encode(username.trim(), "UTF-8")); HttpGet get = new HttpGet(query.toString()); HttpResponse getResponse = client.execute(get); final int statusCode = getResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { Log.w(getClass().getSimpleName(), "Error " + statusCode); handler.sendEmptyMessage(RESULT_ERROR); return; } InputStream source = getResponse.getEntity().getContent(); if (source != null) { Gson gson = new Gson(); Reader reader = new InputStreamReader(source); Account account = gson.fromJson(reader, Account.class); if (account.getNombre() != null && account.getNombre() != "") { handler.sendMessage(Message.obtain(handler, RESULT_OK, account)); } else { handler.sendEmptyMessage(RESULT_ERROR); } } else { handler.sendEmptyMessage(RESULT_ERROR); } } catch (Exception e) { handler.sendEmptyMessage(RESULT_ERROR); Log.e("ERROR", e.getMessage()); } }