Example usage for android.util Log wtf

List of usage examples for android.util Log wtf

Introduction

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

Prototype

public static int wtf(String tag, Throwable tr) 

Source Link

Document

What a Terrible Failure: Report an exception that should never happen.

Usage

From source file:com.bullmobi.message.ui.activities.MainActivity.java

/**
 * Turns screen off and sends a test notification.
 *
 * @param cheat {@code true} if it simply starts {@link EasyNotificationActivity},
 *              {@code false} if it turns device off and then uses notification
 *              to wake it up./*from w w w. j av a 2s .c  o  m*/
 */
private void startEasyNotificationTest(boolean cheat) {
    if (cheat) {
        startActivity(new Intent(this, EasyNotificationActivity.class));
        sendTestNotification(this);
        return;
    }

    int delay = getResources().getInteger(R.integer.config_test_notification_delay);

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Test notification.");
    wakeLock.acquire(delay);

    try {
        // Go sleep
        DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
        dpm.lockNow();

        new Handler().postDelayed(new Runnable() {

            private final Context context = getApplicationContext();

            @Override
            public void run() {
                sendTestNotification(context);
            }
        }, delay);
    } catch (SecurityException e) {
        Log.wtf(TAG, "Failed to turn screen off!");
        wakeLock.release();
    }
}

From source file:org.jivesoftware.spark.util.DummySSLSocketFactory.java

public Socket createSocket(String s, int i) throws IOException {
    AsyncTask<Object, Void, Object> socketCreationTask = new AsyncTask<Object, Void, Object>() {
        @Override/*ww w . ja va  2 s. c  om*/
        protected Object doInBackground(Object... params) {
            Object ret;
            try {
                ret = factory.createSocket((String) params[0], (int) params[1]);
            } catch (Exception e) {
                Log.wtf("F10 :" + getClass().getName(), e);
                launchBroadcastChatEvent();
                ret = e;
            }
            return ret;
        }
    };
    //It's necessary to run the task in an executor because the main one is already full and if we
    // add this one a livelock will occur
    ExecutorService socketCreationExecutor = Executors.newFixedThreadPool(1);
    socketCreationTask.executeOnExecutor(socketCreationExecutor, s, i);
    Object returned;
    try {
        returned = socketCreationTask.get();
    } catch (InterruptedException | ExecutionException e) {
        Log.wtf("F11 :" + getClass().getName(), e);
        throw new IOException("Failure intentionally provoked. See log above.");
    }

    if (returned instanceof Exception) {
        throw (IOException) returned;
    } else {
        return (Socket) returned;
    }
}

From source file:com.thelastcrusade.soundstream.components.ConnectFragment.java

private void registerReceivers() {
    this.broadcastRegistrar = new BroadcastRegistrar();
    this.broadcastRegistrar
            .addLocalAction(ConnectionService.ACTION_HOST_CONNECTED, new IBroadcastActionHandler() {

                @Override//from w  ww  .j a v  a2 s.  c o m
                public void onReceiveAction(Context context, Intent intent) {
                    joinView.setEnabled(true);
                    joinView.findViewById(R.id.searching).setVisibility(View.INVISIBLE);
                    //switch 
                    Transitions.transitionToHome((CoreActivity) getActivity());
                    ((CoreActivity) getActivity()).enableSlidingMenu();

                    //add the playbar fragment onto the active content view
                    ((CoreActivity) getActivity()).showPlaybar();
                }
            }).addGlobalAction(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED, new IBroadcastActionHandler() {

                @Override
                public void onReceiveAction(Context context, Intent intent) {
                    int mode = intent.getIntExtra(BluetoothAdapter.EXTRA_SCAN_MODE,
                            BluetoothAdapter.SCAN_MODE_NONE);
                    if (joinView != null) {
                        switch (mode) {
                        case BluetoothAdapter.SCAN_MODE_NONE: //fall through to connectable
                        case BluetoothAdapter.SCAN_MODE_CONNECTABLE:
                            isSearching = false;
                            setJoinToDefaultState();
                            break;
                        case BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE:
                            isSearching = true;
                            setJoinToSearchingState();
                            break;
                        default:
                            Log.wtf(TAG, "Recieved scan mode changed with unknown mode");
                            break;
                        }
                    }
                }
            }).register(this.getActivity());
}

From source file:cc.softwarefactory.lokki.android.androidServices.LocationService.java

/**
 * Switched current location update accuracy level to prioritize accuracy or power saving
 * @param acc   The new accuracy level//from  w w  w  .  j  a  va  2 s  .c om
 */
public void setLocationCheckAccuracy(LocationAccuracy acc) {
    currentAccuracy = acc;
    if (mGoogleApiClient == null || !mGoogleApiClient.isConnected()) {
        Log.i(TAG, "Google API client not yet initialized, so not requesting updates yet");
        return;
    }

    LocationRequest req;
    switch (acc) {
    case ACCURATE: {
        Log.d(TAG, "Setting location request accuracy to accurate");
        req = locationRequestAccurate;
        break;
    }
    case BGACCURATE: {
        Log.d(TAG, "Setting location request accuracy to background accurate");
        req = locationRequestBGAccurate;
        break;
    }
    case BGINACCURATE: {
        Log.d(TAG, "Setting location request accuracy to background inaccurate");
        req = locationRequestBGInaccurate;
        break;
    }
    default: {
        Log.wtf(TAG, "Unknown location accuracy level");
        throw new IllegalArgumentException("Unknown location accuracy level");
    }

    }
    LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, req, this);

}

From source file:android.net.SSLCertificateSocketFactory.java

private SSLSocketFactory makeSocketFactory(KeyManager[] keyManagers, TrustManager[] trustManagers) {
    try {/*w w  w  .  ja  va2 s. c  o  m*/
        OpenSSLContextImpl sslContext = new OpenSSLContextImpl();
        sslContext.engineInit(keyManagers, trustManagers, null);
        sslContext.engineGetClientSessionContext().setPersistentCache(mSessionCache);
        return sslContext.engineGetSocketFactory();
    } catch (KeyManagementException e) {
        Log.wtf(TAG, e);
        return (SSLSocketFactory) SSLSocketFactory.getDefault(); // Fallback
    }
}

From source file:com.amazonaws.mobile.auth.google.GoogleSignInProvider.java

/** {@inheritDoc} */
@Override//  w  ww. j  av  a  2s  .c  o m
public void handleActivityResult(final int requestCode, final int resultCode, final Intent data) {
    if (requestCode == RC_SIGN_IN) {
        signingIn = false;

        // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
        final GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result == null) {
            // This should not happen based on Google's documentation.
            final String errMsg = "GoogleSignInResult was null.";
            Log.wtf(LOG_TAG, errMsg);
            resultsHandler.onError(GoogleSignInProvider.this, new IllegalStateException(errMsg));
            return;
        }

        if (!result.isSuccess()) {
            // if the user canceled
            if (GoogleSignInStatusCodes.SIGN_IN_CANCELLED == result.getStatus().getStatusCode()) {
                resultsHandler.onCancel(GoogleSignInProvider.this);
                return;
            }

            // If there was a failure, forward it along.
            resultsHandler.onError(GoogleSignInProvider.this, new GoogleSignInException(result));
        }

        Log.i(LOG_TAG, "Successful GoogleSignInResult, status=" + result.getStatus().toString());

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    handleGoogleSignInSuccessResult(result);
                    Log.d(LOG_TAG, "Google provider sign-in succeeded!");
                    ThreadUtils.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            resultsHandler.onSuccess(GoogleSignInProvider.this);
                        }
                    });
                } catch (final Exception ex) {
                    final String errMsg = "Error retrieving Google token.";
                    Log.e(LOG_TAG, errMsg);
                    ThreadUtils.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            resultsHandler.onError(GoogleSignInProvider.this, ex);
                        }
                    });
                }
            }
        }).start();
    }
}

From source file:free.yhc.netmbuddy.utils.Utils.java

private static void log(Class<?> cls, LogLV lv, String msg) {
    if (null == msg)
        return;/*www .jav  a2  s.com*/

    StackTraceElement ste = Thread.currentThread().getStackTrace()[5];
    msg = ste.getClassName() + "/" + ste.getMethodName() + "(" + ste.getLineNumber() + ") : " + msg;

    if (!LOGF) {
        switch (lv) {
        case V:
            Log.v(cls.getSimpleName(), msg);
            break;
        case D:
            Log.d(cls.getSimpleName(), msg);
            break;
        case I:
            Log.i(cls.getSimpleName(), msg);
            break;
        case W:
            Log.w(cls.getSimpleName(), msg);
            break;
        case E:
            Log.e(cls.getSimpleName(), msg);
            break;
        case F:
            Log.wtf(cls.getSimpleName(), msg);
            break;
        }
    } else {
        long timems = System.currentTimeMillis();
        sLogWriter.printf("<%s:%03d> [%s] %s\n", sLogTimeDateFormat.format(new Date(timems)), timems % 1000,
                lv.name(), msg);
        sLogWriter.flush();
    }
}

From source file:com.google.wireless.speed.speedometer.measurements.PingTask.java

private double filterPingResults(final ArrayList<Double> rrts, double avg) {
    double rrtAvg = avg;
    // Our # of results should be less than the # of times we ping
    try {//from  w  w  w.ja  v  a 2s.  com
        ArrayList<Double> filteredResults = Util.applyInnerBandFilter(rrts, Double.MIN_VALUE,
                rrtAvg * Config.PING_FILTER_THRES);
        // Now we compute the average again based on the filtered results
        if (filteredResults != null && filteredResults.size() > 0) {
            rrtAvg = Util.getSum(filteredResults) / filteredResults.size();
        }
    } catch (InvalidParameterException e) {
        Log.wtf(SpeedometerApp.TAG, "This should never happen because rrts is never empty");
    }
    return rrtAvg;
}

From source file:conexionSiabra.Oauth.java

public JSONObject peticionGet(Pair<String, String> elemento, String url) {
    String baseString = "";
    String parameters;//from  w w  w . ja v a2s  . com
    String complement;
    String signature = "";
    String get = "";
    String parametro1 = "";
    String parametro2 = "";
    //COMPRUEBO si el nuevo elemento alfabeticamente es mayor o menor que la palabra Oauth
    //Esto es debido a que el baseString debe ser formado en orden alfabetico
    if (elemento.first.compareTo("oauth") < 0) {//Es elemento.first es menor que oauth
        parametro1 = elemento.first + "=" + elemento.second + "&";
    } else {
        parametro2 = "&" + elemento.first + "=" + elemento.second;
    }

    try {
        baseString = "GET&" + URLEncoder.encode(url, "UTF-8") + "&";
        parameters = parametro1 + "oauth_consumer_key=" + CONSUMER_KEY + "&oauth_nonce=" + getNonce()
                + "&oauth_signature_method=HMAC-SHA1" + "&oauth_timestamp=" + setTimeStamp() + "&oauth_token="
                + ACCESS_TOKEN + "&oauth_version=1.0" + parametro2;//+elemento.first+"="+elemento.second;

        complement = URLEncoder.encode(parameters, "UTF-8");
        baseString += complement;
        Log.wtf("base", baseString);
        signature = URLEncoder.encode(hmac_sha1(baseString, CONSUMER_SECRET + "&" + ACCESS_TOKEN_SECRET),
                "UTF-8");
        get = url + "?oauth_version=1.0&oauth_nonce=" + getNonce() + "&oauth_timestamp=" + timeStamp
                + "&oauth_consumer_key=" + CONSUMER_KEY + "&oauth_token=" + ACCESS_TOKEN
                + "&oauth_signature_method=HMAC-SHA1&oauth_signature=" + signature + "&" + elemento.first + "="
                + elemento.second;

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    String result;
    //Log.wtf("Envio", get);
    Peticion peticion = new PeticionGet(get);
    result = peticion.Ejecutar();
    Log.wtf("Resultado", result);

    JSONObject resultado;
    try {
        resultado = new JSONObject(result);
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        resultado = new JSONObject();
    }
    return resultado;
}

From source file:de.jadehs.jadehsnavigator.fragment.MensaplanFragment.java

@Override
public void processFinish(ArrayList<ArrayList> items) {
    try {//from  ww  w .  j av a  2 s  .  c  o m
        mViewPager = (ViewPager) getActivity().findViewById(R.id.viewpager);
        getActivity().findViewById(R.id.progressMensaplan).setVisibility(View.GONE);
        mViewPager.setAdapter(new MensaplanPagerAdapter(getActivity(), items, this.week));
        if (week != 1) {
            mViewPager.setCurrentItem(calendarWeekHelper.getDay());
        }
        mSlidingTabLayout = (MensaplanTabLayout) getActivity().findViewById(R.id.sliding_tabs);
        mSlidingTabLayout.setViewPager(mViewPager);

    } catch (Exception e) {
        e.printStackTrace();
        Log.wtf("processFinish", "Aktualisierung unterbrochen, View gewechselt");
    }

}