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:biz.bokhorst.xprivacy.Util.java

public static String importProLicense(File licenseFile) {
    // Get imported license file name
    String importedLicense = getUserDataDirectory(Process.myUid()) + File.separator + LICENSE_FILE_NAME;
    File out = new File(importedLicense);

    // Check if license file exists
    if (licenseFile.exists() && licenseFile.canRead()) {
        try {/*from  ww w.ja  v  a  2s  .  c o  m*/
            // Import license file
            Util.log(null, Log.WARN, "Licensing: importing " + out.getAbsolutePath());
            InputStream is = null;
            is = new FileInputStream(licenseFile.getAbsolutePath());
            try {
                OutputStream os = null;
                try {
                    os = new FileOutputStream(out.getAbsolutePath());
                    byte[] buffer = new byte[1024];
                    int read;
                    while ((read = is.read(buffer)) != -1)
                        os.write(buffer, 0, read);
                    os.flush();
                } finally {
                    if (os != null)
                        os.close();
                }
            } finally {
                if (is != null)
                    is.close();
            }

            // Protect imported license file
            setPermissions(out.getAbsolutePath(), 0700, Process.myUid(), Process.myUid());

            // Remove original license file
            licenseFile.delete();
        } catch (FileNotFoundException ignored) {
        } catch (Throwable ex) {
            Util.bug(null, ex);
        }
    }

    return (out.exists() && out.canRead() ? importedLicense : null);
}

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

/**
 * Launches the upgrade checking service. Returns immediately.
 *///from   w w  w  . j  a va  2 s . c  o  m
private void checkForUpgrade(Context context) {
    log(context, R.string.upgrade_checker_start_service, MyLog.Sensitivity.NOT_SENSITIVE, Log.WARN);

    Intent service = new Intent(context, UpgradeCheckerService.class);
    startWakefulService(context, service);
}

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

/**
 * WARN  ? ?  ?.
 */
public static boolean isWarnEnabled() {
    return Log.isLoggable(TAG, Log.WARN);
}

From source file:de.madvertise.android.sdk.MadvertiseMraidView.java

public void setPlacementType(int placementType) {
    if (placementType != MadvertiseUtil.PLACEMENT_TYPE_INTERSTITIAL
            && placementType != MadvertiseUtil.PLACEMENT_TYPE_INLINE) {
        MadvertiseUtil.logMessage(null, Log.WARN,
                "Placement type must be one of MadvertiseUtil.PLACEMENT_TYPE_INLINE or MadvertiseUtil.PLACEMENT_TYPE_INTERSTITIAL");
    } else {//from w ww. j av  a  2s. c  o m
        mPlacementType = placementType;
        injectJs("mraid.setPlacementType(" + mPlacementType + ");");
    }
}

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

public void shutdown() {
    mDisplayHandler.stop();//from   www. j  a  va 2  s  .  co  m
    // Block on display shutdown. We need to make sure this finishes before
    // we can consider DisplayManager to be shut down.
    try {
        mHandlerThread.join(1000 /*milis*/);
    } catch (InterruptedException e) {
        LogUtils.log(this, Log.WARN, "Display handler shutdown interrupted");
    }
    mTranslatorManager.removeOnTablesChangedListener(this);
}

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

synchronized public ReplicationStatus replicate(String db, int mode) {
    final String tt = t + "replicate(): ";

    if (Collect.Log.DEBUG)
        Log.d(Collect.LOGTAG, tt + "about to replicate " + db);

    // Will not replicate unless signed in
    if (!Collect.getInstance().getIoService().isSignedIn()) {
        if (Collect.Log.DEBUG)
            Log.d(Collect.LOGTAG, tt + "aborting replication: not signed in");
        return null;
    }//from  w  w  w. j a  v  a  2  s . c  o  m

    if (Collect.getInstance().getInformOnlineState().isOfflineModeEnabled()) {
        if (Collect.Log.DEBUG)
            Log.d(Collect.LOGTAG, tt + "aborting replication: offline mode is enabled");
        return null;
    }

    /*
     * Lookup master cluster by IP.  Do this instead of relying on Erlang's internal resolver 
     * (and thus Google's public DNS).  Our builds of Erlang for Android do not yet use 
     * Android's native DNS resolver.
     */
    String masterClusterIP = null;

    try {
        InetAddress[] clusterInetAddresses = InetAddress
                .getAllByName(getString(R.string.tf_default_ionline_server));
        masterClusterIP = clusterInetAddresses[new Random().nextInt(clusterInetAddresses.length)]
                .getHostAddress();
    } catch (UnknownHostException e) {
        if (Collect.Log.ERROR)
            Log.e(Collect.LOGTAG, tt + "unable to lookup master cluster IP addresses: " + e.toString());
        e.printStackTrace();
    }

    // Create local instance of database
    boolean dbCreated = false;

    // User may not have connected to local database yet - start up the connection for them
    try {
        if (mLocalDbInstance == null) {
            connectToLocalServer();
        }
    } catch (DbUnavailableException e) {
        if (Collect.Log.ERROR)
            Log.e(Collect.LOGTAG, tt + "cannot connect to local database server");
        e.printStackTrace();
    }

    if (mLocalDbInstance.getAllDatabases().indexOf("db_" + db) == -1) {
        switch (mode) {
        case REPLICATE_PULL:
            if (Collect.Log.INFO)
                Log.i(Collect.LOGTAG, tt + "creating local database " + db);
            mLocalDbInstance.createDatabase("db_" + db);
            dbCreated = true;
            break;

        case REPLICATE_PUSH:
            // If the database does not exist client side then there is no point in continuing
            if (Collect.Log.WARN)
                Log.w(Collect.LOGTAG, tt + "cannot find local database " + db + " to push");
            return null;
        }
    }

    // Configure replication direction
    String source = null;
    String target = null;

    String deviceId = Collect.getInstance().getInformOnlineState().getDeviceId();
    String deviceKey = Collect.getInstance().getInformOnlineState().getDeviceKey();

    String localServer = "http://" + mLocalHost + ":" + mLocalPort + "/db_" + db;
    String remoteServer = "http://" + deviceId + ":" + deviceKey + "@" + masterClusterIP + ":5984/db_" + db;

    // Should we use encrypted transfers?
    SharedPreferences settings = PreferenceManager
            .getDefaultSharedPreferences(Collect.getInstance().getBaseContext());

    if (settings.getBoolean(PreferencesActivity.KEY_ENCRYPT_SYNCHRONIZATION, true)) {
        remoteServer = "https://" + deviceId + ":" + deviceKey + "@" + masterClusterIP + ":6984/db_" + db;
    }

    switch (mode) {
    case REPLICATE_PUSH:
        source = localServer;
        target = remoteServer;
        break;

    case REPLICATE_PULL:
        source = remoteServer;
        target = localServer;
        break;
    }

    ReplicationCommand cmd = new ReplicationCommand.Builder().source(source).target(target).build();
    ReplicationStatus status = null;

    try {
        status = mLocalDbInstance.replicate(cmd);
    } catch (Exception e) {
        // Remove a recently created DB if the replication failed
        if (dbCreated) {
            if (Collect.Log.ERROR)
                Log.e(Collect.LOGTAG, t + "replication exception: " + e.toString());
            e.printStackTrace();

            mLocalDbInstance.deleteDatabase("db_" + db);
        }
    }

    return status;
}

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

private static List<PRestriction> getUpgradeWork(Version sVersion, int uid, boolean dangerous) {
    List<PRestriction> listWork = new ArrayList<PRestriction>();

    for (String restrictionName : PrivacyManager.getRestrictions()) {
        boolean restricted = PrivacyManager.getRestrictionEx(uid, restrictionName, null).restricted;

        for (Hook hook : PrivacyManager.getHooks(restrictionName, null)) {
            // Disable new dangerous restrictions
            if (hook.getFrom() != null) {
                if (sVersion.compareTo(hook.getFrom()) < 0) {
                    if (hook.isDangerous()) {
                        Util.log(null, Log.WARN,
                                "Upgrading dangerous " + hook + " from=" + hook.getFrom() + " uid=" + uid);
                        PRestriction restriction = new PRestriction(uid, hook.getRestrictionName(),
                                hook.getName(), false, true);
                        listWork.add(restriction);
                    }//w w w  .j  av  a  2 s .  co m

                    // Restrict replaced methods
                    if (hook.getReplacedMethod() != null) {
                        PRestriction restriction = PrivacyManager.getRestrictionEx(uid,
                                hook.getReplacedRestriction(), hook.getReplacedMethod());
                        listWork.add(new PRestriction(uid, hook.getRestrictionName(), hook.getName(),
                                restriction.restricted, restriction.asked));
                        Util.log(null, Log.WARN,
                                "Replacing " + hook.getReplacedRestriction() + "/" + hook.getReplacedMethod()
                                        + " by " + hook + " from=" + hook.getFrom() + " uid=" + uid);
                    }
                }
            }

            // Restrict dangerous
            if (dangerous && restricted && hook.isDangerous()) {
                PRestriction restriction = new PRestriction(uid, hook.getRestrictionName(), hook.getName(),
                        true, hook.whitelist() == null);
                if (PrivacyManager.isRestrictionSet(restriction))
                    Util.log(null, Log.WARN, "Restrict dangerous set restriction=" + restriction);
                else {
                    Util.log(null, Log.WARN, "Restrict dangerous setting restriction=" + restriction);
                    listWork.add(restriction);
                }
            }
        }
    }

    return listWork;
}

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

public void updateDisplay() {
    if (mExtractedText == null) {
        return;//ww  w.  j a  v a 2 s . c  o  m
    }
    DisplayManager displayManager = getCurrentDisplayManager();
    if (displayManager == null) {
        return;
    }
    EditorInfo ei = getCurrentInputEditorInfo();
    if (ei == null) {
        LogUtils.log(this, Log.WARN, "No input editor info");
        return;
    }
    CharSequence label = ei.label;
    CharSequence hint = ei.hintText;
    if (TextUtils.isEmpty(label)) {
        label = hint;
        hint = null;
    }
    SpannableStringBuilder text = new SpannableStringBuilder();
    if (!TextUtils.isEmpty(label)) {
        text.append(label);
        text.append(": "); // TODO: Put in a resource.
    }
    int editStart = text.length();
    text.append(mCurrentText);
    addMarkingSpan(text, EDIT_TEXT_SPAN, editStart);
    CharSequence actionLabel = getActionLabel();
    if (actionLabel != null) {
        text.append(" [");
        text.append(actionLabel);
        text.append("]");
        addMarkingSpan(text, ACTION_LABEL_SPAN, text.length() - (actionLabel.length() + 2));
    }
    DisplaySpans.addSelection(text, editStart + mSelectionStart, editStart + mSelectionEnd);
    displayManager.setContent(new DisplayManager.Content(text).setPanStrategy(DisplayManager.Content.PAN_CURSOR)
            .setSplitParagraphs(isMultiLineField()));
}

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

private void connect(boolean forceOnline) {
    mConnecting = true;//from   ww  w.j  a v a  2 s . c o m

    // Make sure that the user has not specifically requested that we be offline
    if (Collect.getInstance().getInformOnlineState().isOfflineModeEnabled() && forceOnline == false) {
        if (Collect.Log.INFO)
            Log.i(Collect.LOGTAG, t + "offline mode enabled; not auto-connecting");

        /* 
         * This is not a complete initialization (in the sense that we attempted connection) but we need 
         * to pretend that it is so that the UI can move forward to whatever state is most suitable.
         */
        mInitialized = true;
        mConnecting = false;

        return;
    }

    if (Collect.Log.INFO)
        Log.i(Collect.LOGTAG, t + "pinging " + Collect.getInstance().getInformOnlineState().getServerUrl());

    // Try to ping the service to see if it is "up" (and determine whether we are registered)
    String pingUrl = Collect.getInstance().getInformOnlineState().getServerUrl() + "/ping";
    String getResult = HttpUtils.getUrlData(pingUrl);
    JSONObject ping;

    try {
        ping = (JSONObject) new JSONTokener(getResult).nextValue();

        String result = ping.optString(InformOnlineState.RESULT, InformOnlineState.ERROR);

        // Online and registered (checked in)
        if (result.equals(InformOnlineState.OK)) {
            if (Collect.Log.INFO)
                Log.i(Collect.LOGTAG, t + "ping successful (we are connected and checked in)");
            mServicePingSuccessful = mSignedIn = true;
        } else if (result.equals(InformOnlineState.FAILURE)) {
            if (Collect.Log.WARN)
                Log.w(Collect.LOGTAG, t + "ping successful but not signed in (will attempt checkin)");
            mServicePingSuccessful = true;

            if (Collect.getInstance().getInformOnlineState().hasRegistration() && checkin()) {
                if (Collect.Log.INFO)
                    Log.i(Collect.LOGTAG, t + "checkin successful (we are connected)");

                // Fetch regardless of the fact that we're not yet marked as being signed in
                AccountDeviceList.fetchDeviceList(true);
                AccountFolderList.fetchFolderList(true);

                mSignedIn = true;
            } else {
                if (Collect.Log.WARN)
                    Log.w(Collect.LOGTAG, t + "checkin failed (registration invalid)");
                mSignedIn = false;
            }
        } else {
            // Assume offline
            if (Collect.Log.WARN)
                Log.w(Collect.LOGTAG, t + "ping failed (we are offline)");
            mSignedIn = false;
        }
    } catch (NullPointerException e) {
        // This usually indicates a communication error and will send us into an offline state
        if (Collect.Log.ERROR)
            Log.e(Collect.LOGTAG, t + "ping error while communicating with service (we are offline)");
        e.printStackTrace();
        mServicePingSuccessful = mSignedIn = false;
    } catch (JSONException e) {
        // Parse errors (malformed result) send us into an offline state
        if (Collect.Log.ERROR)
            Log.e(Collect.LOGTAG, t + "ping error while parsing getResult " + getResult + " (we are offline)");
        e.printStackTrace();
        mServicePingSuccessful = mSignedIn = false;
    } finally {
        // Load regardless of whether we are signed in
        AccountDeviceList.loadDeviceList();
        AccountFolderList.loadFolderList();

        // Unblock
        mInitialized = true;
        mConnecting = false;
    }
}

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

public static boolean hasMarketLink(Context context, String packageName) {
    try {//from w  w  w  .j  ava  2 s.co m
        PackageManager pm = context.getPackageManager();
        String installer = pm.getInstallerPackageName(packageName);
        if (installer != null)
            return installer.equals("com.android.vending") || installer.contains("google");
    } catch (Exception ex) {
        log(null, Log.WARN, ex.toString());
    }
    return false;
}