Example usage for android.util Log w

List of usage examples for android.util Log w

Introduction

In this page you can find the example usage for android.util Log w.

Prototype

public static int w(String tag, Throwable tr) 

Source Link

Usage

From source file:org.thoughtcrime.securesms.mms.OutgoingMmsConnection.java

private byte[] sendBytes(boolean useMmsRadio, boolean useProxyIfAvailable) throws IOException {
    final boolean useProxy = useProxyIfAvailable && apn.hasProxy();
    final String targetHost = useProxy ? apn.getProxy() : Uri.parse(apn.getMmsc()).getHost();

    Log.w(TAG, "Sending MMS of length: " + mms.length + (useMmsRadio ? ", using mms radio" : "")
            + (useProxy ? ", using proxy" : ""));

    try {//  w  w  w  . java 2s  . c o m
        if (checkRouteToHost(context, targetHost, useMmsRadio)) {
            Log.w(TAG, "got successful route to host " + targetHost);
            byte[] response = makeRequest(useProxy);
            if (response != null)
                return response;
        }
    } catch (IOException ioe) {
        Log.w(TAG, ioe);
    }
    throw new IOException("Connection manager could not obtain route to host.");
}

From source file:org.thoughtcrime.securesms.mms.OutgoingMmsConnection.java

public static boolean isConnectionPossible(Context context) {
    try {/*from  w  w w  .j  ava 2 s. c  o m*/
        ConnectivityManager connectivityManager = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connectivityManager.getNetworkInfo(MmsRadio.TYPE_MOBILE_MMS);
        if (networkInfo == null) {
            Log.w(TAG, "MMS network info was null, unsupported by this device");
            return false;
        }

        getApn(context, networkInfo.getExtraInfo());
        return true;
    } catch (ApnUnavailableException e) {
        Log.w(TAG, e);
        return false;
    }
}

From source file:Main.java

public static Bitmap getBitmapByFixingRotationForFile(String filePath, Bitmap sourceBitmap,
        Activity activityForScreenOrientation, boolean freeSourceBitmap) {
    try {//  w  ww .  j a va 2  s .  co m
        ExifInterface exif = new ExifInterface(filePath);
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

        if (orientation == ExifInterface.ORIENTATION_UNDEFINED
                && Build.MANUFACTURER.toLowerCase(Locale.ENGLISH).contains("htc"))
            return null;

        boolean flippedHorizontally = false, flippedVertically = false;

        int angle = 0;

        if (orientation == ExifInterface.ORIENTATION_ROTATE_90) {
            angle += 90;
        } else if (orientation == ExifInterface.ORIENTATION_ROTATE_180) {
            angle += 180;
        } else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) {
            angle += 270;
        } else if (orientation == ExifInterface.ORIENTATION_FLIP_HORIZONTAL) {
            flippedHorizontally = true;
        } else if (orientation == ExifInterface.ORIENTATION_FLIP_VERTICAL) {
            flippedVertically = true;
        } else if (orientation == ExifInterface.ORIENTATION_TRANSPOSE) {
            angle += 90;
            flippedVertically = true;
        } else if (orientation == ExifInterface.ORIENTATION_TRANSVERSE) {
            angle -= 90;
            flippedVertically = true;
        }

        if (activityForScreenOrientation != null) {
            orientation = getScreenOrientation(activityForScreenOrientation);
            if (orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
                angle += 90;
            } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) {
                angle += 180;
            } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) {
                angle += 270;
            }
        }

        Bitmap bmp = sourceBitmap;
        if (bmp == null) {
            bmp = BitmapFactory.decodeFile(filePath, null);
        }
        if (angle != 0) {
            Matrix mat = new Matrix();
            mat.postRotate(angle);

            if (flippedHorizontally) {
                mat.postScale(-1.f, 1.f);
            }
            if (flippedVertically) {
                mat.postScale(1.f, -1.f);
            }

            Bitmap rotated = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), mat, true);
            if (freeSourceBitmap || bmp != sourceBitmap) {
                bmp.recycle();
            }
            bmp = rotated;
        }

        return bmp;

    } catch (IOException e) {
        Log.w("TAG", "-- Error in setting image");
    } catch (OutOfMemoryError oom) {
        Log.w("TAG", "-- OOM Error in setting image");
    }

    return null;
}

From source file:com.arellomobile.android.push.DeviceFeature2_5.java

static JSONArray sendTags(Context context, Map<String, Object> tags) throws Exception {
    final Map<String, Object> data = new HashMap<String, Object>();

    data.putAll(RequestHelper.getSendTagsData(context, NetworkUtils.PUSH_VERSION));

    JSONObject tagsObject = new JSONObject();
    for (String key : tags.keySet()) {
        Object value = tags.get(key);
        if (value instanceof String || value instanceof Integer) {
            tagsObject.put(key, value);// www.j  a  v  a  2  s  .  c om
        } else if (value instanceof List) {
            JSONArray values = new JSONArray();
            for (Object item : (List<?>) value) {
                if (item instanceof String || item instanceof Integer) {
                    values.put(String.valueOf(item));
                } else {
                    throw new RuntimeException("wrong type for tag: " + key);
                }
            }
            tagsObject.put(key, values);
        } else {
            throw new RuntimeException("wrong type for tag: " + key);
        }
    }

    data.put("tags", tagsObject);

    Log.w(TAG, "Try To sent Tags");

    NetworkUtils.NetworkResult res = new NetworkUtils.NetworkResult(-1, null);
    Exception exception = new Exception();
    for (int i = 0; i < NetworkUtils.MAX_TRIES; ++i) {
        try {
            res = NetworkUtils.makeRequest(data, TAGS_PATH);
            if (200 == res.getResultCode()) {
                Log.w(TAG, "Send Tags success");
                return res.getResultData().getJSONObject("response").getJSONArray("skipped");
            }
        } catch (Exception e) {
            exception = e;
        }
    }

    Log.e(TAG, "ERROR: sent Tags " + exception.getMessage() + ". Response = " + res, exception);
    throw exception;
}

From source file:org.smssecure.smssecure.mms.OutgoingLegacyMmsConnection.java

@Override
public @Nullable SendConf send(@NonNull byte[] pduBytes, int subscriptionId)
        throws UndeliverableMessageException {
    try {//from ww  w .  ja v a  2  s  .  c  o  m
        MmsRadio radio = MmsRadio.getInstance(context);

        if (isDirectConnect()) {
            Log.w(TAG, "Sending MMS directly without radio change...");
            try {
                return send(pduBytes, false, false);
            } catch (IOException e) {
                Log.w(TAG, e);
            }
        }

        Log.w(TAG, "Sending MMS with radio change and proxy...");
        radio.connect();

        try {
            try {
                return send(pduBytes, true, true);
            } catch (IOException e) {
                Log.w(TAG, e);
            }

            Log.w(TAG, "Sending MMS with radio change and without proxy...");

            try {
                return send(pduBytes, true, false);
            } catch (IOException ioe) {
                Log.w(TAG, ioe);
                throw new UndeliverableMessageException(ioe);
            }
        } finally {
            radio.disconnect();
        }

    } catch (MmsRadioException e) {
        Log.w(TAG, e);
        throw new UndeliverableMessageException(e);
    }

}

From source file:cn.suishen.email.mail.store.imap.ImapTempFileLiteral.java

@Override
public String getString() {
    checkNotDestroyed();/* w w w.jav a 2 s . c o m*/
    try {
        return Utility.fromAscii(IOUtils.toByteArray(getAsStream()));
    } catch (IOException e) {
        Log.w(Logging.LOG_TAG, "ImapTempFileLiteral: Error while reading temp file");
        return "";
    }
}

From source file:com.hemou.android.util.StrUtils.java

public static <K> K str2Obj(String str, Class<K> cls) {
    try {//from  w ww.j a  v  a2 s  . co m
        return new ObjectMapper().readValue(str, cls);
    } catch (Exception e) {
        Log.w("Str2Obj", "Can not convert " + str + " to class ?" + cls.getSimpleName() + "");
        e.printStackTrace();
    }
    return null;
}

From source file:org.smssecure.smssecure.crypto.PreKeyUtil.java

public static PreKeyRecord generateLastResortKey(Context context, MasterSecret masterSecret) {
    PreKeyStore preKeyStore = new SilencePreKeyStore(context, masterSecret);

    if (preKeyStore.containsPreKey(Medium.MAX_VALUE)) {
        try {//  w  w  w .  j av a  2  s.  c om
            return preKeyStore.loadPreKey(Medium.MAX_VALUE);
        } catch (InvalidKeyIdException e) {
            Log.w("PreKeyUtil", e);
            preKeyStore.removePreKey(Medium.MAX_VALUE);
        }
    }

    ECKeyPair keyPair = Curve.generateKeyPair();
    PreKeyRecord record = new PreKeyRecord(Medium.MAX_VALUE, keyPair);

    preKeyStore.storePreKey(Medium.MAX_VALUE, record);

    return record;
}

From source file:org.thoughtcrime.SMP.crypto.PreKeyUtil.java

public static PreKeyRecord generateLastResortKey(Context context, MasterSecret masterSecret) {
    PreKeyStore preKeyStore = new TextSecurePreKeyStore(context, masterSecret);

    if (preKeyStore.containsPreKey(Medium.MAX_VALUE)) {
        try {//ww w  .  j  a va  2s  .c o m
            return preKeyStore.loadPreKey(Medium.MAX_VALUE);
        } catch (InvalidKeyIdException e) {
            Log.w("PreKeyUtil", e);
            preKeyStore.removePreKey(Medium.MAX_VALUE);
        }
    }

    ECKeyPair keyPair = Curve.generateKeyPair();
    PreKeyRecord record = new PreKeyRecord(Medium.MAX_VALUE, keyPair);

    preKeyStore.storePreKey(Medium.MAX_VALUE, record);

    return record;
}

From source file:eu.trentorise.smartcampus.ac.authenticator.AuthenticatorActivity.java

@Override
protected void setUp() {
    Intent request = getIntent();/*from  w w w. j ava2s  .  c  o m*/
    String authTokenType = request.getStringExtra(Constants.KEY_AUTHORITY) != null
            ? request.getStringExtra(Constants.KEY_AUTHORITY)
            : Constants.AUTHORITY_DEFAULT;
    if (Constants.TOKEN_TYPE_ANONYMOUS.equals(authTokenType)) {
        new AsyncTask<Void, Void, UserData>() {
            private ProgressDialog progress = null;

            protected void onPostExecute(UserData result) {
                if (progress != null) {
                    try {
                        progress.cancel();
                    } catch (Exception e) {
                        Log.w(getClass().getName(), "Problem closing progress dialog: " + e.getMessage());
                    }
                }
                if (result != null && result.getToken() != null) {
                    getAuthListener().onTokenAcquired(result);
                } else {
                    getAuthListener().onAuthFailed("Failed to create anonymous account");
                }
                // TODO
            }

            @Override
            protected void onPreExecute() {
                progress = ProgressDialog.show(AuthenticatorActivity.this, "",
                        AuthenticatorActivity.this.getString(R.string.auth_in_progress), true);
                super.onPreExecute();
            }

            @Override
            protected UserData doInBackground(Void... params) {
                try {
                    return RemoteConnector.createAnonymousUser(Constants.getAuthUrl(AuthenticatorActivity.this),
                            new DeviceUuidFactory(AuthenticatorActivity.this).getDeviceUuid().toString());
                } catch (NameNotFoundException e) {
                    Log.e(Authenticator.class.getName(), "Failed to create anonymous user: " + e.getMessage());
                    return null;
                }
            }
        }.execute();
    } else {
        super.setUp();
    }
}