Example usage for android.util Log WARN

List of usage examples for android.util Log WARN

Introduction

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

Prototype

int WARN

To view the source code for android.util Log WARN.

Click Source Link

Document

Priority constant for the println method; use Log.w.

Usage

From source file:com.radicaldynamic.groupinform.services.DatabaseService.java

public boolean isDbLocal(String db) {
    final String tt = t + "isDbLocal(): ";

    boolean result = false;

    try {//ww  w.  j  a  va  2s.com
        if (mLocalDbInstance == null)
            connectToLocalServer();

        if (mLocalDbInstance.getAllDatabases().indexOf("db_" + db) != -1)
            result = true;
    } catch (DbAccessException e) {
        if (Collect.Log.WARN)
            Log.w(Collect.LOGTAG, tt + e.toString());
    } catch (Exception e) {
        if (Collect.Log.ERROR)
            Log.e(Collect.LOGTAG, tt + "unhandled exception: " + e.toString());
    }

    return result;
}

From source file:biz.bokhorst.xprivacy.Util.java

@SuppressLint("NewApi")
public static int getUserId(int uid) {
    int userId = 0;
    if (uid > 99) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
            try {
                // UserHandle: public static final int getUserId(int uid)
                Method method = (Method) UserHandle.class.getDeclaredMethod("getUserId", int.class);
                userId = (Integer) method.invoke(null, uid);
            } catch (Throwable ex) {
                Util.log(null, Log.WARN, ex.toString());
            }//  ww  w  .  j  a v  a2  s . c  om
    } else
        userId = uid;
    return userId;
}

From source file:com.ofalvai.bpinfo.api.bkkinfo.BkkInfoClient.java

@NonNull
private List<Alert> parseTodayAlerts(JSONObject response) throws JSONException {
    List<Alert> alerts = new ArrayList<>();

    boolean isDebugMode = mSharedPreferences.getBoolean(mContext.getString(R.string.pref_key_debug_mode),
            false);/*from  w  w w.jav  a 2s  .c om*/

    JSONArray activeAlertsList = response.getJSONArray("active");
    for (int i = 0; i < activeAlertsList.length(); i++) {
        try {
            JSONObject alertNode = activeAlertsList.getJSONObject(i);
            Alert alert = parseAlert(alertNode);

            // Some alerts are still listed a few minutes after they ended, we need to hide them,
            // but still show them if debug mode is enabled
            DateTime alertEndTime = new DateTime(alert.getEnd() * 1000L);
            if (alertEndTime.isAfterNow() || alert.getEnd() == 0 || isDebugMode) {
                alerts.add(parseAlert(alertNode));
            }
        } catch (JSONException ex) {
            Crashlytics.log(Log.WARN, TAG, "Alert parse: failed to parse:\n" + ex.toString());
        }
    }

    return alerts;
}

From source file:com.kth.common.utils.etc.LogUtil.java

/**
 * WARN  ?./*ww w .  j av a2 s  . co m*/
 * 
 * @param clazz  ??  Class.
 * @param msg .
 * @param tr Throwable.
 */
public static void w(final Class<?> clazz, final String msg, final Throwable tr) {
    if (LogUtil.isWarnEnabled()) {
        Log.println(Log.WARN, TAG,
                LogUtil.getClassLineNumber(clazz) + " - " + msg + '\n' + Log.getStackTraceString(tr));

        //  ?? ?   ?.
        if (LogUtil.isFileLogEnabled()) {
            write(Log.WARN, LogUtil.getClassLineNumber(clazz), msg, tr);
        }
    }
}

From source file:com.ofalvai.bpinfo.api.bkkinfo.BkkInfoClient.java

@NonNull
private List<Alert> parseFutureAlerts(JSONObject response) throws JSONException {
    List<Alert> alerts = new ArrayList<>();

    // Future alerts are in two groups: near-future and far-future
    JSONArray soonAlertList = response.getJSONArray("soon");
    for (int i = 0; i < soonAlertList.length(); i++) {
        try {/*from w  ww .j a  v  a2  s.c  o  m*/
            JSONObject alertNode = soonAlertList.getJSONObject(i);
            alerts.add(parseAlert(alertNode));
        } catch (JSONException ex) {
            Crashlytics.log(Log.WARN, TAG, "Alert parse: failed to parse:\n" + ex.toString());
        }
    }

    JSONArray futureAlertList = response.getJSONArray("future");
    for (int i = 0; i < futureAlertList.length(); i++) {
        try {
            JSONObject alertNode = futureAlertList.getJSONObject(i);
            alerts.add(parseAlert(alertNode));
        } catch (JSONException ex) {
            Crashlytics.log(Log.WARN, TAG, "Alert parse: failed to parse:\n" + ex.toString());
        }
    }

    return alerts;
}

From source file:com.playtang.commonnavigation.login.PlayTangLoginActivity.java

private Bundle getMergedOptions() {
    // Read activity metadata from AndroidManifest.xml
    ActivityInfo activityInfo = null;//from  w  w w .  jav  a2 s.com
    try {
        activityInfo = getPackageManager().getActivityInfo(this.getComponentName(),
                PackageManager.GET_META_DATA);
    } catch (NameNotFoundException e) {
        if (Parse.getLogLevel() <= Parse.LOG_LEVEL_ERROR && Log.isLoggable(LOG_TAG, Log.WARN)) {
            Log.w(LOG_TAG, e.getMessage());
        }
    }

    // The options specified in the Intent (from PlayTangLoginBuilder) will
    // override any duplicate options specified in the activity metadata
    Bundle mergedOptions = new Bundle();
    if (activityInfo != null && activityInfo.metaData != null) {
        mergedOptions.putAll(activityInfo.metaData);
    }
    if (getIntent().getExtras() != null) {
        mergedOptions.putAll(getIntent().getExtras());
    }

    return mergedOptions;
}

From source file:com.ofalvai.bpinfo.api.bkkfutar.FutarApiClient.java

@NonNull
private List<Alert> parseAlerts(@NonNull JSONObject response, @NonNull AlertListType alertListType)
        throws JSONException {
    List<Alert> alertList = new ArrayList<>();

    JSONObject dataNode = response.getJSONObject(AlertSearchContract.DATA);
    JSONObject entryNode = dataNode.getJSONObject(AlertSearchContract.DATA_ENTRY);
    JSONArray alertIdsNode = entryNode.getJSONArray(AlertSearchContract.DATA_ENTRY_ALERT_IDS);

    if (alertIdsNode.length() == 0) {
        return alertList;
    }//  ww  w  . ja v  a  2 s. c  o  m

    JSONObject referencesNode = dataNode.getJSONObject(AlertSearchContract.DATA_REFERENCES);
    JSONObject alertsNode = referencesNode.getJSONObject(AlertSearchContract.DATA_REFERENCES_ALERTS);

    JSONArray alerts = Utils.jsonObjectToArray(alertsNode);

    for (int i = 0; i < alerts.length(); i++) {
        JSONObject alertNode = alerts.getJSONObject(i);
        Alert alert;
        try {
            alert = parseAlert(alertNode);

            // Time ranges in the API response are messed up. We need to filter out alerts that are
            // before/after the time range we want.
            DateTime alertStartTime = new DateTime(alert.getStart() * 1000L);
            if (alertListType == AlertListType.ALERTS_TODAY && alertStartTime.isBeforeNow()) {
                alertList.add(alert);
            } else if (alertListType == AlertListType.ALERTS_FUTURE && alertStartTime.isAfterNow()) {
                alertList.add(alert);
            }
        } catch (JSONException ex) {
            Crashlytics.log(Log.WARN, TAG, "Alert parse: failed to parse:\n" + ex.toString());
        }
    }

    return alertList;
}

From source file:com.android.talkback.labeling.LabelProvider.java

/**
 * Deletes a label in the labels database.
 *
 * @param uri The URI matching {code LABELS_ID_CONTENT_URI} that represents
 *            the specific label to delete.
 * @param selection The WHERE clause for the query.
 * @param selectionArgs The arguments for the WHERE clause of the query.
 * @return The number of rows affected./*from  w  ww  .j  av  a2 s  . c  om*/
 */
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
    if (uri == null) {
        LogUtils.log(this, Log.WARN, NULL_URI_FORMAT_STRING);
        return 0;
    }

    if (!UserManagerCompat.isUserUnlocked(getContext())) {
        return 0;
    }

    switch (sUriMatcher.match(uri)) {
    case LABELS: {
        initializeDatabaseIfNull();

        int result = mDatabase.delete(LabelsTable.TABLE_NAME, selection, selectionArgs);
        getContext().getContentResolver().notifyChange(uri, null /* observer */);
        return result;
    }
    case LABELS_ID: {
        initializeDatabaseIfNull();

        final String labelIdString = uri.getLastPathSegment();
        final int labelId;
        try {
            labelId = Integer.parseInt(labelIdString);
        } catch (NumberFormatException e) {
            LogUtils.log(this, Log.WARN, UNKNOWN_URI_FORMAT_STRING, uri);
            return 0;
        }

        final String where = String.format(Locale.ROOT, "%s = %d", LabelsTable.KEY_ID, labelId);
        final int result = mDatabase.delete(LabelsTable.TABLE_NAME, combineSelectionAndWhere(selection, where),
                selectionArgs);

        getContext().getContentResolver().notifyChange(uri, null /* observer */);

        return result;
    }
    default:
        LogUtils.log(this, Log.WARN, UNKNOWN_URI_FORMAT_STRING, uri);
        return 0;
    }
}

From source file:com.psiphon3.psiphonlibrary.UpgradeChecker.java

@Override
public void onReceive(Context context, Intent intent) {
    // This service runs as a separate process, so it needs to initialize embedded values
    EmbeddedValues.initialize(context);/*ww w  .ja v  a2  s . c o  m*/

    // Make sure the alarm is created, regardless of which intent we received.
    createAlarm(context.getApplicationContext());

    String action = intent.getAction();

    if (action.equals(ALARM_INTENT_ACTION)) {
        log(context, R.string.upgrade_checker_alarm_intent_received, MyLog.Sensitivity.NOT_SENSITIVE, Log.WARN);
        if (!upgradeCheckNeeded(context)) {
            return;
        }
        checkForUpgrade(context);
    } else if (action.equals(UPGRADE_FILE_AVAILABLE_INTENT_ACTION)) {
        log(context, R.string.upgrade_checker_upgrade_file_available_intent_received,
                MyLog.Sensitivity.NOT_SENSITIVE, Log.WARN);
        // Create upgrade notification. User clicking the notification will trigger the install.
        UpgradeManager.UpgradeInstaller.notifyUpgrade(context.getApplicationContext());
    } else if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
        log(context, R.string.upgrade_checker_boot_completed_intent_received, MyLog.Sensitivity.NOT_SENSITIVE,
                Log.WARN);
        // Pass. We created the alarm above, so nothing else to do (until the alarm runs).
    } else if (action.equals(CREATE_ALARM_INTENT_ACTION)) {
        log(context, R.string.upgrade_checker_create_alarm_intent_received, MyLog.Sensitivity.NOT_SENSITIVE,
                Log.WARN);
        // Pass. We created the alarm above, so nothing else to do (until the alarm runs).
    }
}

From source file:com.radicaldynamic.groupinform.services.InformOnlineService.java

private boolean checkin() {
    // Assume we are registered unless told otherwise
    boolean registered = true;

    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("deviceId", Collect.getInstance().getInformOnlineState().getDeviceId()));
    params.add(//from w  ww. jav  a2  s  . com
            new BasicNameValuePair("deviceKey", Collect.getInstance().getInformOnlineState().getDeviceKey()));
    params.add(new BasicNameValuePair("fingerprint",
            Collect.getInstance().getInformOnlineState().getDeviceFingerprint()));

    try {
        params.add(new BasicNameValuePair("lastCheckinWith",
                this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName));
    } catch (NameNotFoundException e1) {
        params.add(new BasicNameValuePair("lastCheckinWith", "unknown"));
    }

    String checkinUrl = Collect.getInstance().getInformOnlineState().getServerUrl() + "/checkin";
    String postResult = HttpUtils.postUrlData(checkinUrl, params);
    JSONObject checkin;

    try {
        checkin = (JSONObject) new JSONTokener(postResult).nextValue();
        String result = checkin.optString(InformOnlineState.RESULT, InformOnlineState.FAILURE);

        if (result.equals(InformOnlineState.OK)) {
            if (Collect.Log.INFO)
                Log.i(Collect.LOGTAG, t + "successful checkin");
            Collect.getInstance().getInformOnlineState().setExpired(false);

            // Update device role -- it might have changed
            Collect.getInstance().getInformOnlineState()
                    .setDeviceRole(checkin.optString("role", AccountDevice.ROLE_UNASSIGNED));
        } else if (result.equals(InformOnlineState.EXPIRED)) {
            if (Collect.Log.INFO)
                Log.i(Collect.LOGTAG, t + "associated order is expired; marking device as expired");
            Collect.getInstance().getInformOnlineState().setExpired(true);
        } else if (result.equals(InformOnlineState.FAILURE)) {
            if (Collect.Log.WARN)
                Log.w(Collect.LOGTAG, t + "checkin unsuccessful");
            registered = false;
        } else {
            // Something bad happened
            if (Collect.Log.ERROR)
                Log.e(Collect.LOGTAG, t + "system error while processing postResult");
        }
    } catch (NullPointerException e) {
        // Communication error
        if (Collect.Log.ERROR)
            Log.e(Collect.LOGTAG, t + "no postResult to parse.  Communication error with node.js server?");
        e.printStackTrace();
    } catch (JSONException e) {
        // Parse error (malformed result)
        if (Collect.Log.ERROR)
            Log.e(Collect.LOGTAG, t + "failed to parse postResult " + postResult);
        e.printStackTrace();
    }

    // Clear the session for subsequent requests and reset stored state
    if (registered == false)
        Collect.getInstance().getInformOnlineState().resetDevice();

    return registered;
}