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.android.utils.traversal.OrderedTraversalController.java

public AccessibilityNodeInfoCompat findNext(AccessibilityNodeInfoCompat node) {
    WorkingTree tree = mNodeTreeMap.get(node);
    if (tree == null) {
        LogUtils.log(Log.WARN, "findNext(), can't find WorkingTree for AccessibilityNodeInfo");
        return null;
    }// w  w w  .  j a v a  2s .  co m

    WorkingTree nextTree = tree.getNext();
    if (nextTree != null) {
        return AccessibilityNodeInfoCompat.obtain(nextTree.getNode());
    }

    return null;
}

From source file:org.thoughtland.xlocation.UpdateService.java

private static void randomize(Context context) {
    int first = 0;
    String format = context.getString(R.string.msg_randomizing);
    List<ApplicationInfo> listApp = context.getPackageManager().getInstalledApplications(0);

    // Randomize global
    int userId = Util.getUserId(Process.myUid());
    PrivacyManager.setSettingList(getRandomizeWork(context, userId));

    // Randomize applications
    for (int i = 1; i <= listApp.size(); i++) {
        int uid = listApp.get(i - 1).uid;
        List<PSetting> listSetting = getRandomizeWork(context, uid);
        PrivacyManager.setSettingList(listSetting);

        if (first == 0)
            if (listSetting.size() > 0)
                first = i;/*w w w . j  a v  a 2 s.c  om*/
        if (first > 0 && first < listApp.size())
            notifyProgress(context, Util.NOTIFY_RANDOMIZE, format,
                    100 * (i - first) / (listApp.size() - first));
    }
    if (first == 0)
        Util.log(null, Log.WARN, "Nothing to randomize");
}

From source file:org.thoughtland.xlocation.Util.java

public static String[] getProLicenseUnchecked() {
    // Get license file name
    String storageDir = Environment.getExternalStorageDirectory().getAbsolutePath();
    File licenseFile = new File(storageDir + File.separator + LICENSE_FILE_NAME);
    if (!licenseFile.exists())
        licenseFile = new File(storageDir + File.separator + ".xlocation" + File.separator + LICENSE_FILE_NAME);

    String importedLicense = importProLicense(licenseFile);
    if (importedLicense == null)
        return null;

    // Check license file
    licenseFile = new File(importedLicense);
    if (licenseFile.exists()) {
        // Read license
        try {/*ww  w.j a v  a2  s. c o  m*/
            IniFile iniFile = new IniFile(licenseFile);
            String name = iniFile.get("name", "");
            String email = iniFile.get("email", "");
            String signature = iniFile.get("signature", "");
            if (name == null || email == null || signature == null)
                return null;
            else {
                // Check expiry
                if (email.endsWith("@faircode.eu")) {
                    long expiry = Long.parseLong(email.split("\\.")[0]);
                    long time = System.currentTimeMillis() / 1000L;
                    if (time > expiry) {
                        Util.log(null, Log.WARN, "Licensing: expired");
                        return null;
                    }
                }

                // Valid
                return new String[] { name, email, signature };
            }
        } catch (FileNotFoundException ex) {
            return null;
        } catch (Throwable ex) {
            bug(null, ex);
            return null;
        }
    } else
        Util.log(null, Log.INFO, "Licensing: no license file");
    return null;
}

From source file:com.googlecode.eyesfree.brailleback.SearchNavigationMode.java

/**
 * Translates braille dots into a character sequence and appends it
 * to the current query text.//  w ww. j  a v  a  2 s.c o  m
 */
private boolean handleBrailleKey(int dots) {
    // TODO: handle non-computer braille.
    BrailleTranslator translator = mTranslatorManager.getUncontractedTranslator();

    if (translator == null) {
        LogUtils.log(this, Log.WARN, "missing translator %s", translator);
        mFeedbackManager.emitFeedback(FeedbackManager.TYPE_COMMAND_FAILED);
        return true;
    }

    CharSequence text = translator.backTranslate(new byte[] { (byte) dots });
    if (!TextUtils.isEmpty(text)) {
        return mFeedbackManager.emitOnFailure(tryAddQueryText(text),
                FeedbackManager.TYPE_NAVIGATE_OUT_OF_BOUNDS);
    }

    return true;
}

From source file:com.android.utils.traversal.OrderedTraversalController.java

public AccessibilityNodeInfoCompat findPrevious(AccessibilityNodeInfoCompat node) {
    WorkingTree tree = mNodeTreeMap.get(node);
    if (tree == null) {
        LogUtils.log(Log.WARN, "findPrevious(), can't find WorkingTree for AccessibilityNodeInfo");
        return null;
    }//from   ww  w. j  a v a 2 s .co m

    WorkingTree prevTree = tree.getPrevious();
    if (prevTree != null) {
        return AccessibilityNodeInfoCompat.obtain(prevTree.getNode());
    }

    return null;
}

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

/**
 * Creates the periodic alarm used to check for updates. Can be called unconditionally; it
 * handles cases when the alarm is already created.
 * @param appContext The application context.
 *//*  w w  w  .j av a2 s  .  c  o  m*/
private static void createAlarm(Context appContext) {
    if (!allowedToSelfUpgrade(appContext)) {
        // Don't waste resources with an alarm if we can't possibly self-upgrade.
        log(appContext, R.string.upgrade_checker_no_alarm_no_selfupgrading, MyLog.Sensitivity.NOT_SENSITIVE,
                Log.WARN);
        return;
    }

    Intent intent = new Intent(appContext, UpgradeChecker.class);
    intent.setAction(ALARM_INTENT_ACTION);

    boolean alarmExists = (PendingIntent.getBroadcast(appContext, ALARM_INTENT_REQUEST_CODE, intent,
            PendingIntent.FLAG_NO_CREATE) != null);

    if (alarmExists) {
        log(appContext, R.string.upgrade_checker_alarm_exists, MyLog.Sensitivity.NOT_SENSITIVE, Log.WARN);
        return;
    }

    log(appContext, R.string.upgrade_checker_creating_alarm, MyLog.Sensitivity.NOT_SENSITIVE, Log.WARN);

    PendingIntent alarmIntent = PendingIntent.getBroadcast(appContext, ALARM_INTENT_REQUEST_CODE, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    AlarmManager alarmMgr = (AlarmManager) appContext.getSystemService(Context.ALARM_SERVICE);
    alarmMgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
            SystemClock.elapsedRealtime() + AlarmManager.INTERVAL_FIFTEEN_MINUTES,
            AlarmManager.INTERVAL_HALF_DAY, alarmIntent);
}

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

public static String[] getProLicenseUnchecked() {
    // Get license file name
    String storageDir = Environment.getExternalStorageDirectory().getAbsolutePath();
    File licenseFile = new File(storageDir + File.separator + LICENSE_FILE_NAME);
    if (!licenseFile.exists())
        licenseFile = new File(storageDir + File.separator + ".xprivacy" + File.separator + LICENSE_FILE_NAME);
    if (!licenseFile.exists())
        licenseFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
                + File.separator + LICENSE_FILE_NAME);

    String importedLicense = importProLicense(licenseFile);
    if (importedLicense == null)
        return null;

    // Check license file
    licenseFile = new File(importedLicense);
    if (licenseFile.exists()) {
        // Read license
        try {//from  w ww  . j a va  2  s. co  m
            IniFile iniFile = new IniFile(licenseFile);
            String name = iniFile.get("name", "");
            String email = iniFile.get("email", "");
            String signature = iniFile.get("signature", "");
            if (name == null || email == null || signature == null)
                return null;
            else {
                // Check expiry
                if (email.endsWith("@faircode.eu")) {
                    long expiry = Long.parseLong(email.split("\\.")[0]);
                    long time = System.currentTimeMillis() / 1000L;
                    if (time > expiry) {
                        Util.log(null, Log.WARN, "Licensing: expired");
                        return null;
                    }
                }

                // Valid
                return new String[] { name, email, signature };
            }
        } catch (FileNotFoundException ex) {
            return null;
        } catch (Throwable ex) {
            bug(null, ex);
            return null;
        }
    } else
        Util.log(null, Log.INFO, "Licensing: no license file");
    return null;
}

From source file:net.vleu.par.android.rpc.Transceiver.java

/**
 * Performs authentication if necessary, then exchange the data with the
 * server and returns the response/*from w w w.j a v  a 2 s.c o m*/
 * 
 * @param request
 * @return The response to the request, null if none
 * @throws IOException
 * @throws OperationCanceledException
 * @throws AuthenticatorException
 */
public GatewayResponseData exchangeWithServer(final GatewayRequestData request)
        throws IOException, OperationCanceledException, AuthenticatorException {
    final int maxRetries = 10;
    for (int retry = 0; retry < maxRetries; retry++) {
        if (!hasSacsidToken()) {
            /* Gets a Google Auth Token and promotes it to a SACSID Token */
            final GoogleAuthToken googleAuthToken = blockingGetNewAuthToken();
            try {
                promoteToken(googleAuthToken);
            } catch (final InvalidGoogleAuthTokenException e) {
                if (Log.isLoggable(TAG, Log.WARN))
                    Log.w(TAG, "The google auth token is invalid. Refreshing all cookies. ", e);
                invalidatesGoogleAuthToken(googleAuthToken);
                clearSacsidToken();
                continue;
            }
        }
        /* Executes the query */
        try {
            return postData(request);
        } catch (final AuthenticationTokenExpired e) {
            clearSacsidToken();
            if (Log.isLoggable(TAG, Log.WARN))
                Log.w(TAG, "Google and/or SACSID tokens expired. Retried " + retry + " times.", e);
            continue;
        }
    }
    final String failureMessage = "Failed to get valid Google and SACSID tokens !";
    if (Log.isLoggable(TAG, Log.ERROR))
        Log.e(TAG, failureMessage);
    throw new AuthenticatorException(failureMessage);
}

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

@NonNull
private Alert parseAlert(@NonNull JSONObject alertNode) throws JSONException {

    String id = alertNode.getString(AlertContract.ALERT_ID);
    long start = alertNode.getLong(AlertContract.ALERT_START);
    long end = 0;

    if (!alertNode.isNull(AlertContract.ALERT_END)) {
        // There are alerts with unknown ends, represented by null
        end = alertNode.getLong(AlertContract.ALERT_END);
    }//from   w  w w . j ava2s.  com

    long timestamp = alertNode.getLong(AlertContract.ALERT_TIMESTAMP);

    JSONObject urlNode = alertNode.getJSONObject(AlertContract.ALERT_URL);

    String url = null;
    if (!urlNode.isNull(AlertSearchContract.LANG_SOME)) {
        url = urlNode.getString(AlertSearchContract.LANG_SOME) + LANG_PARAM + mLanguageCode;
    }

    String header;
    JSONObject headerNode = alertNode.getJSONObject(AlertContract.ALERT_HEADER);
    JSONObject translationsNode = headerNode.getJSONObject(AlertContract.ALERT_HEADER_TRANSLATIONS);
    try {
        // Trying to get the specific language's translation
        // It might be null or completely missing from the response
        header = translationsNode.getString(mLanguageCode);

        if (header == null || header.equals("null")) {
            throw new JSONException("header field is null");
        }
    } catch (JSONException ex) {
        // Falling back to the "someTranslation" field
        header = headerNode.getString(AlertSearchContract.LANG_SOME);
        Crashlytics.log(Log.WARN, TAG, "Alert parse: header translation missing");
    }
    header = Utils.capitalizeString(header);

    String description;
    JSONObject descriptionNode = alertNode.getJSONObject(AlertContract.ALERT_DESC);
    JSONObject translationsNode2 = descriptionNode.getJSONObject(AlertContract.ALERT_DESC_TRANSLATIONS);
    if (!translationsNode2.isNull(mLanguageCode)) {
        // Trying to get the specific language's translation
        // It might be null or completely missing from the response
        description = translationsNode2.getString(mLanguageCode);
    } else {
        // Falling back to the "someTranslation" field
        description = descriptionNode.getString(AlertSearchContract.LANG_SOME);

        Crashlytics.log(Log.WARN, TAG, "Alert parse: description translation missing");
    }

    JSONArray routeIdsNode = alertNode.getJSONArray(AlertContract.ALERT_ROUTE_IDS);
    List<String> routeIds = Utils.jsonArrayToStringList(routeIdsNode);
    List<Route> affectedRoutes = getRoutesByIds(routeIds);

    return new Alert(id, start, end, timestamp, url, header, description, affectedRoutes, false);
}