Example usage for android.util Log VERBOSE

List of usage examples for android.util Log VERBOSE

Introduction

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

Prototype

int VERBOSE

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

Click Source Link

Document

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

Usage

From source file:assistive.com.scanme.com.googlecode.eyesfree.utils.AccessibilityNodeInfoUtils.java

private static boolean hasNonActionableSpeakingChildren(Context context, AccessibilityNodeInfoCompat node) {
    final int childCount = node.getChildCount();

    AccessibilityNodeInfoCompat child = null;

    // Has non-actionable, speaking children?
    for (int i = 0; i < childCount; i++) {
        try {// ww  w  .  j a  v  a 2 s. co m
            child = node.getChild(i);

            if (child == null) {
                LogUtils.log(AccessibilityNodeInfoUtils.class, Log.VERBOSE, "Child %d is null, skipping it", i);
                continue;
            }

            // Ignore invisible nodes.
            if (!isVisibleOrLegacy(child)) {
                LogUtils.log(AccessibilityNodeInfoUtils.class, Log.VERBOSE,
                        "Child %d is invisible, skipping it", i);
                continue;
            }

            // Ignore focusable nodes.
            if (FILTER_ACCESSIBILITY_FOCUSABLE.accept(context, child)) {
                LogUtils.log(AccessibilityNodeInfoUtils.class, Log.VERBOSE,
                        "Child %d is focusable, skipping it", i);
                continue;
            }

            // Recursively check non-focusable child nodes.
            // TODO: Mutual recursion is probably not a good idea.
            if (isSpeakingNode(context, child)) {
                LogUtils.log(AccessibilityNodeInfoUtils.class, Log.VERBOSE,
                        "Does have actionable speaking children (child %d)", i);
                return true;
            }
        } finally {
            AccessibilityNodeInfoUtils.recycleNodes(child);
        }
    }

    LogUtils.log(AccessibilityNodeInfoUtils.class, Log.VERBOSE,
            "Does not have non-actionable speaking children");
    return false;
}

From source file:com.taxicop.client.NetworkUtilities.java

public static String authenticate(String username, String password, String country, Handler handler,
        final Context context) {
    final HttpResponse resp;
    final ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair(PARAM_USERNAME, username));
    params.add(new BasicNameValuePair(PARAM_PASSWORD, password));
    params.add(new BasicNameValuePair(PARAM_COUNTRY, country));
    HttpEntity entity = null;/*w w  w  .  ja  va2s .  c  om*/
    try {
        entity = new UrlEncodedFormEntity(params);
    } catch (final UnsupportedEncodingException e) {
        throw new AssertionError(e);
    }
    final HttpPost post = new HttpPost(BASE_URL + URL + AUTH_URI);
    Log.d(TAG, "URI= " + (BASE_URL + URL + AUTH_URI));
    post.addHeader(entity.getContentType());
    post.setEntity(entity);
    CreateHttpClient();
    Log.i(TAG, "authenticate(): obtencion de autenticacion. ");

    try {
        resp = mHttpClient.execute(post);
        ByteArrayOutputStream outstream = new ByteArrayOutputStream();
        resp.getEntity().writeTo(outstream);
        byte[] responseBody = outstream.toByteArray();
        String response = new String(responseBody);
        //         response = response.replaceAll("Status: 200", "")
        //               .replaceAll("OK", "")
        //               .replaceAll("Content\\-Type: text\\/html", "")
        //               .replaceAll("charset=utf\\-8", "")
        //               .replaceAll(";", "")
        //               .replaceAll("\\\n", "").trim();

        Log.i(TAG, "authenticate(): respuesta obtenida del servidor. response=" + response);
        if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "Successful authentication");
            }
            sendResult(true, handler, context);
            return response;
        } else {
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "Error authenticating" + resp.getStatusLine());
            }
            sendResult(false, handler, context);
            return response;
        }
    } catch (final IOException e) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "IOException when getting authtoken", e);
        }
        sendResult(false, handler, context);
        return null;
    } finally {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "getAuthtoken completing");
        }
    }
}

From source file:com.phonemetra.lockclock.weather.YahooWeatherProvider.java

@Override
public WeatherInfo getWeatherInfo(Location location, boolean metric) {
    String language = getLanguage();
    String params = String.format(Locale.US, "\"%f %f\" and locale=\"%s\"", location.getLatitude(),
            location.getLongitude(), language);
    String url = URL_PLACEFINDER + Uri.encode(params);
    JSONObject results = fetchResults(url);
    if (results == null) {
        return null;
    }/*from   w ww. j  av  a  2s  .  co m*/

    try {
        JSONObject result = results.getJSONObject("Result");
        String woeid = result.getString("woeid");

        String city = null;
        for (String name : PLACE_NAMES) {
            if (!result.isNull(name)) {
                city = result.getString(name);
                if (Log.isLoggable(TAG, Log.VERBOSE)) {
                    Log.v(TAG,
                            String.format(Locale.US, "Placefinder for location %f %f " + "matched %s using %s",
                                    location.getLatitude(), location.getLongitude(), city, name));
                }
                break;
            }
        }

        // The city name in the placefinder result is HTML encoded :-(
        if (city != null) {
            city = Html.fromHtml(city).toString();
        } else {
            Log.w(TAG, "Can not resolve place name for " + location);
        }

        Log.d(TAG, "Resolved location " + location + " to " + city + " (" + woeid + ")");

        WeatherInfo info = getWeatherInfo(woeid, city, metric);
        if (info != null) {
            return info;
        }
    } catch (JSONException e) {
        Log.e(TAG, "Received malformed placefinder data (location=" + location + ", lang=" + language + ")", e);
    }

    return null;
}

From source file:com.digipom.manteresting.android.service.cache.CacheService.java

/**
 * Loads the bitmap only, to ensure it's cached for when we request it.
 * These requests will be done at a lower priority, and in FIFO order. The
 * width is used to determine the minimum quality required.
 *//*w w w.  j a  v a  2 s.  c  o m*/
public void loadOnlyLowerPriorityFifoAsync(String originalUriFromJson, int requestedWidth) {
    if (LoggerConfig.canLog(Log.VERBOSE)) {
        Log.v(TAG, "loadOnlyLowerPriorityFifoAsync(" + originalUriFromJson + ", " + requestedWidth + ")");
    }

    // Since the runnable itself is based on a LIFO queue, then putting a
    // decreasing timestamp for subsequent requests turns it into a FIFO
    // queue, and since the timestamp is so small, all of these requests
    // have a lower priority than the LIFO request.
    if (bitmapMemoryCache != null && !isCachedBitmapAdequateForWidth(originalUriFromJson, requestedWidth)) {
        queueOrUpdateRunnable(originalUriFromJson, requestedWidth, null, fifoTimestamp.getAndDecrement());
    }
}

From source file:br.com.bioscada.apps.biotracks.io.gdata.AndroidGDataClient.java

private InputStream createAndExecuteMethod(HttpRequestCreator creator, String uriString, String authToken)
        throws HttpException, IOException {

    HttpResponse response = null;//from w w w.ja  va 2  s.c om
    int status = 500;
    int redirectsLeft = MAX_REDIRECTS;

    URI uri;
    try {
        uri = new URI(uriString);
    } catch (URISyntaxException use) {
        Log.w(TAG, "Unable to parse " + uriString + " as URI.", use);
        throw new IOException("Unable to parse " + uriString + " as URI: " + use.getMessage());
    }

    // we follow redirects ourselves, since we want to follow redirects even on
    // POSTs, which
    // the HTTP library does not do. following redirects ourselves also allows
    // us to log
    // the redirects using our own logging.
    while (redirectsLeft > 0) {

        HttpUriRequest request = creator.createRequest(uri);
        request.addHeader("User-Agent", "Android-GData");
        request.addHeader("Accept-Encoding", "gzip");

        // only add the auth token if not null (to allow for GData feeds that do
        // not require
        // authentication.)
        if (!TextUtils.isEmpty(authToken)) {
            request.addHeader("Authorization", "GoogleLogin auth=" + authToken);
        }
        if (DEBUG) {
            for (Header h : request.getAllHeaders()) {
                Log.v(TAG, h.getName() + ": " + h.getValue());
            }
            Log.d(TAG, "Executing " + request.getRequestLine().toString());
        }

        response = null;

        try {
            response = httpClient.execute(request);
        } catch (IOException ioe) {
            Log.w(TAG, "Unable to execute HTTP request." + ioe);
            throw ioe;
        }

        StatusLine statusLine = response.getStatusLine();
        if (statusLine == null) {
            Log.w(TAG, "StatusLine is null.");
            throw new NullPointerException("StatusLine is null -- should not happen.");
        }

        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, response.getStatusLine().toString());
            for (Header h : response.getAllHeaders()) {
                Log.d(TAG, h.getName() + ": " + h.getValue());
            }
        }
        status = statusLine.getStatusCode();

        HttpEntity entity = response.getEntity();

        if ((status >= 200) && (status < 300) && entity != null) {
            return getUngzippedContent(entity);
        }

        // TODO: handle 301, 307?
        // TODO: let the http client handle the redirects, if we can be sure we'll
        // never get a
        // redirect on POST.
        if (status == 302) {
            // consume the content, so the connection can be closed.
            entity.consumeContent();
            Header location = response.getFirstHeader("Location");
            if (location == null) {
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, "Redirect requested but no Location " + "specified.");
                }
                break;
            }
            if (Log.isLoggable(TAG, Log.DEBUG)) {
                Log.d(TAG, "Following redirect to " + location.getValue());
            }
            try {
                uri = new URI(location.getValue());
            } catch (URISyntaxException use) {
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, "Unable to parse " + location.getValue() + " as URI.", use);
                    throw new IOException("Unable to parse " + location.getValue() + " as URI.");
                }
                break;
            }
            --redirectsLeft;
        } else {
            break;
        }
    }

    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "Received " + status + " status code.");
    }
    String errorMessage = null;
    HttpEntity entity = response.getEntity();
    try {
        if (entity != null) {
            InputStream in = entity.getContent();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            byte[] buf = new byte[8192];
            int bytesRead = -1;
            while ((bytesRead = in.read(buf)) != -1) {
                baos.write(buf, 0, bytesRead);
            }
            // TODO: use appropriate encoding, picked up from Content-Type.
            errorMessage = new String(baos.toByteArray());
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, errorMessage);
            }
        }
    } finally {
        if (entity != null) {
            entity.consumeContent();
        }
    }
    String exceptionMessage = "Received " + status + " status code";
    if (errorMessage != null) {
        exceptionMessage += (": " + errorMessage);
    }
    throw new HttpException(exceptionMessage, status, null /* InputStream */);
}

From source file:com.google.android.marvin.mytalkback.FullScreenReadController.java

public void setReadingState(AutomaticReadingState newState) {
    LogUtils.log(TAG, Log.VERBOSE, "Continuous reading switching to mode: %s", newState.name());

    mCurrentState = newState;/*from   w w  w .j a  v  a  2 s.  c  o m*/
    mSpeechController.setShouldInjectAutoReadingCallbacks(isActive(), mNodeSpokenRunnable);
}

From source file:com.foxykeep.datadroid.internal.network.NetworkConnectionImpl.java

/**
 * Call the webservice using the given parameters to construct the request and return the
 * result.// www  .java  2s . co  m
 *
 * @param context The context to use for this operation. Used to generate the user agent if
 *            needed.
 * @param urlValue The webservice URL.
 * @param method The request method to use.
 * @param parameterList The parameters to add to the request.
 * @param headerMap The headers to add to the request.
 * @param isGzipEnabled Whether the request will use gzip compression if available on the
 *            server.
 * @param userAgent The user agent to set in the request. If null, a default Android one will be
 *            created.
 * @param postText The POSTDATA text to add in the request.
 * @param credentials The credentials to use for authentication.
 * @param isSslValidationEnabled Whether the request will validate the SSL certificates.
 * @return The result of the webservice call.
 */
public static ConnectionResult execute(Context context, String urlValue, Method method,
        ArrayList<BasicNameValuePair> parameterList, HashMap<String, String> headerMap, boolean isGzipEnabled,
        String userAgent, String postText, UsernamePasswordCredentials credentials,
        boolean isSslValidationEnabled) throws ConnectionException {
    HttpURLConnection connection = null;
    try {
        // Prepare the request information
        if (userAgent == null) {
            userAgent = UserAgentUtils.get(context);
        }
        if (headerMap == null) {
            headerMap = new HashMap<String, String>();
        }
        headerMap.put(HTTP.USER_AGENT, userAgent);
        if (isGzipEnabled) {
            headerMap.put(ACCEPT_ENCODING_HEADER, "gzip");
        }
        headerMap.put(ACCEPT_CHARSET_HEADER, UTF8_CHARSET);
        if (credentials != null) {
            headerMap.put(AUTHORIZATION_HEADER, createAuthenticationHeader(credentials));
        }

        StringBuilder paramBuilder = new StringBuilder();
        if (parameterList != null && !parameterList.isEmpty()) {
            for (int i = 0, size = parameterList.size(); i < size; i++) {
                BasicNameValuePair parameter = parameterList.get(i);
                String name = parameter.getName();
                String value = parameter.getValue();
                if (TextUtils.isEmpty(name)) {
                    // Empty parameter name. Check the next one.
                    continue;
                }
                if (value == null) {
                    value = "";
                }
                paramBuilder.append(URLEncoder.encode(name, UTF8_CHARSET));
                paramBuilder.append("=");
                paramBuilder.append(URLEncoder.encode(value, UTF8_CHARSET));
                paramBuilder.append("&");
            }
        }

        // Log the request
        if (DataDroidLog.canLog(Log.DEBUG)) {
            DataDroidLog.d(TAG, "Request url: " + urlValue);
            DataDroidLog.d(TAG, "Method: " + method.toString());

            if (parameterList != null && !parameterList.isEmpty()) {
                DataDroidLog.d(TAG, "Parameters:");
                for (int i = 0, size = parameterList.size(); i < size; i++) {
                    BasicNameValuePair parameter = parameterList.get(i);
                    String message = "- \"" + parameter.getName() + "\" = \"" + parameter.getValue() + "\"";
                    DataDroidLog.d(TAG, message);
                }

                DataDroidLog.d(TAG, "Parameters String: \"" + paramBuilder.toString() + "\"");
            }

            if (postText != null) {
                DataDroidLog.d(TAG, "Post data: " + postText);
            }

            if (headerMap != null && !headerMap.isEmpty()) {
                DataDroidLog.d(TAG, "Headers:");
                for (Entry<String, String> header : headerMap.entrySet()) {
                    DataDroidLog.d(TAG, "- " + header.getKey() + " = " + header.getValue());
                }
            }
        }

        // Create the connection object
        URL url = null;
        String outputText = null;
        switch (method) {
        case GET:
        case DELETE:
            String fullUrlValue = urlValue;
            if (paramBuilder.length() > 0) {
                fullUrlValue += "?" + paramBuilder.toString();
            }
            url = new URL(fullUrlValue);
            connection = HttpUrlConnectionHelper.openUrlConnection(url);
            break;
        case PUT:
        case POST:
            url = new URL(urlValue);
            connection = HttpUrlConnectionHelper.openUrlConnection(url);
            connection.setDoOutput(true);

            if (paramBuilder.length() > 0) {
                outputText = paramBuilder.toString();
                headerMap.put(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded");
                headerMap.put(HTTP.CONTENT_LEN, String.valueOf(outputText.getBytes().length));
            } else if (postText != null) {
                outputText = postText;
            }
            break;
        }

        // Set the request method
        connection.setRequestMethod(method.toString());

        // If it's an HTTPS request and the SSL Validation is disabled
        if (url.getProtocol().equals("https") && !isSslValidationEnabled) {
            HttpsURLConnection httpsConnection = (HttpsURLConnection) connection;
            httpsConnection.setSSLSocketFactory(getAllHostsValidSocketFactory());
            httpsConnection.setHostnameVerifier(getAllHostsValidVerifier());
        }

        // Add the headers
        if (!headerMap.isEmpty()) {
            for (Entry<String, String> header : headerMap.entrySet()) {
                connection.addRequestProperty(header.getKey(), header.getValue());
            }
        }

        // Set the connection and read timeout
        connection.setConnectTimeout(OPERATION_TIMEOUT);
        connection.setReadTimeout(OPERATION_TIMEOUT);

        // Set the outputStream content for POST and PUT requests
        if ((method == Method.POST || method == Method.PUT) && outputText != null) {
            OutputStream output = null;
            try {
                output = connection.getOutputStream();
                output.write(outputText.getBytes());
            } finally {
                if (output != null) {
                    try {
                        output.close();
                    } catch (IOException e) {
                        // Already catching the first IOException so nothing to do here.
                    }
                }
            }
        }

        String contentEncoding = connection.getHeaderField(HTTP.CONTENT_ENCODING);

        int responseCode = connection.getResponseCode();
        boolean isGzip = contentEncoding != null && contentEncoding.equalsIgnoreCase("gzip");
        DataDroidLog.d(TAG, "Response code: " + responseCode);

        if (responseCode == HttpStatus.SC_MOVED_PERMANENTLY) {
            String redirectionUrl = connection.getHeaderField(LOCATION_HEADER);
            throw new ConnectionException("New location : " + redirectionUrl, redirectionUrl);
        }

        InputStream errorStream = connection.getErrorStream();
        if (errorStream != null) {
            String error = convertStreamToString(errorStream, isGzip);
            throw new ConnectionException(error, responseCode);
        }

        String body = convertStreamToString(connection.getInputStream(), isGzip);

        if (DataDroidLog.canLog(Log.VERBOSE)) {
            DataDroidLog.v(TAG, "Response body: ");

            int pos = 0;
            int bodyLength = body.length();
            while (pos < bodyLength) {
                DataDroidLog.v(TAG, body.substring(pos, Math.min(bodyLength - 1, pos + 200)));
                pos = pos + 200;
            }
        }

        return new ConnectionResult(connection.getHeaderFields(), body);
    } catch (IOException e) {
        DataDroidLog.e(TAG, "IOException", e);
        throw new ConnectionException(e);
    } catch (KeyManagementException e) {
        DataDroidLog.e(TAG, "KeyManagementException", e);
        throw new ConnectionException(e);
    } catch (NoSuchAlgorithmException e) {
        DataDroidLog.e(TAG, "NoSuchAlgorithmException", e);
        throw new ConnectionException(e);
    } finally {
        if (connection != null) {
            connection.disconnect();
        }
    }
}

From source file:jp.yojio.triplog.Common.DataApi.gdata.AndroidGDataClient.java

private InputStream createAndExecuteMethod(HttpRequestCreator creator, String uriString, String authToken)
        throws HttpException, IOException {

    HttpResponse response = null;//ww  w.  j a v a2  s . c o  m
    int status = 500;
    int redirectsLeft = MAX_REDIRECTS;

    URI uri;
    try {
        uri = new URI(uriString);
    } catch (URISyntaxException use) {
        Log.w(TAG, "Unable to parse " + uriString + " as URI.", use);
        throw new IOException("Unable to parse " + uriString + " as URI: " + use.getMessage());
    }

    // we follow redirects ourselves, since we want to follow redirects even on
    // POSTs, which
    // the HTTP library does not do. following redirects ourselves also allows
    // us to log
    // the redirects using our own logging.
    while (redirectsLeft > 0) {

        HttpUriRequest request = creator.createRequest(uri);
        request.addHeader("Accept-Encoding", "gzip");

        // only add the auth token if not null (to allow for GData feeds that do
        // not require
        // authentication.)
        if (!TextUtils.isEmpty(authToken)) {
            request.addHeader("Authorization", "GoogleLogin auth=" + authToken);
        }
        if (LOCAL_LOGV) {
            for (Header h : request.getAllHeaders()) {
                Log.v(TAG, h.getName() + ": " + h.getValue());
            }
            Log.d(TAG, "Executing " + request.getRequestLine().toString());
        }

        response = null;

        try {
            response = httpClient.execute(request);
        } catch (IOException ioe) {
            Log.w(TAG, "Unable to execute HTTP request." + ioe);
            throw ioe;
        }

        StatusLine statusLine = response.getStatusLine();
        if (statusLine == null) {
            Log.w(TAG, "StatusLine is null.");
            throw new NullPointerException("StatusLine is null -- should not happen.");
        }

        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, response.getStatusLine().toString());
            for (Header h : response.getAllHeaders()) {
                Log.d(TAG, h.getName() + ": " + h.getValue());
            }
        }
        status = statusLine.getStatusCode();

        HttpEntity entity = response.getEntity();

        if ((status >= 200) && (status < 300) && entity != null) {
            return getUngzippedContent(entity);
        }

        // TODO: handle 301, 307?
        // TODO: let the http client handle the redirects, if we can be sure we'll
        // never get a
        // redirect on POST.
        if (status == 302) {
            // consume the content, so the connection can be closed.
            entity.consumeContent();
            Header location = response.getFirstHeader("Location");
            if (location == null) {
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, "Redirect requested but no Location " + "specified.");
                }
                break;
            }
            if (Log.isLoggable(TAG, Log.DEBUG)) {
                Log.d(TAG, "Following redirect to " + location.getValue());
            }
            try {
                uri = new URI(location.getValue());
            } catch (URISyntaxException use) {
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, "Unable to parse " + location.getValue() + " as URI.", use);
                    throw new IOException("Unable to parse " + location.getValue() + " as URI.");
                }
                break;
            }
            --redirectsLeft;
        } else {
            break;
        }
    }

    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "Received " + status + " status code.");
    }
    String errorMessage = null;
    HttpEntity entity = response.getEntity();
    try {
        if (response != null && entity != null) {
            InputStream in = entity.getContent();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            byte[] buf = new byte[8192];
            int bytesRead = -1;
            while ((bytesRead = in.read(buf)) != -1) {
                baos.write(buf, 0, bytesRead);
            }
            // TODO: use appropriate encoding, picked up from Content-Type.
            errorMessage = new String(baos.toByteArray());
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, errorMessage);
            }
        }
    } finally {
        if (entity != null) {
            entity.consumeContent();
        }
    }
    String exceptionMessage = "Received " + status + " status code";
    if (errorMessage != null) {
        exceptionMessage += (": " + errorMessage);
    }
    throw new HttpException(exceptionMessage, status, null /* InputStream */);
}

From source file:com.android.screenspeak.eventprocessor.AccessibilityEventProcessor.java

/**
 * Returns whether the device should drop this event. Caches notifications
 * if necessary.// w  w  w. j  ava2s . co m
 *
 * @param event The current event.
 * @return {@code true} if the event should be dropped.
 */
private boolean shouldDropEvent(AccessibilityEvent event) {
    // Always drop null events.
    if (event == null) {
        return true;
    }

    // Always drop events if the service is suspended.
    if (!ScreenSpeakService.isServiceActive()) {
        return true;
    }

    // If touch exploration is enabled, drop automatically generated events
    // that are sent immediately after a window state change... unless we
    // decide to keep the event.
    if (AccessibilityManagerCompat.isTouchExplorationEnabled(mAccessibilityManager)
            && ((event.getEventType() & AUTOMATIC_AFTER_STATE_CHANGE) != 0)
            && ((event.getEventTime() - mLastWindowStateChanged) < DELAY_AUTO_AFTER_STATE)
            && !shouldKeepAutomaticEvent(event)) {
        if (LogUtils.LOG_LEVEL <= Log.VERBOSE) {
            Log.v(LOGTAG, "Drop event after window state change");
        }
        return true;
    }

    // Real notification events always have parcelable data.
    final boolean isNotification = (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED)
            && (event.getParcelableData() != null);

    final boolean isPhoneActive = (mCallStateMonitor != null)
            && (mCallStateMonitor.getCurrentCallState() != TelephonyManager.CALL_STATE_IDLE);
    final boolean shouldSpeakCallerId = (mSpeakCallerId && (mCallStateMonitor != null)
            && (mCallStateMonitor.getCurrentCallState() == TelephonyManager.CALL_STATE_RINGING));

    if (mRingerModeAndScreenMonitor != null && !mRingerModeAndScreenMonitor.isScreenOn()
            && !shouldSpeakCallerId) {
        if (!mSpeakWhenScreenOff) {
            // If the user doesn't allow speech when the screen is
            // off, drop the event immediately.
            if (LogUtils.LOG_LEVEL <= Log.VERBOSE) {
                Log.v(LOGTAG, "Drop event due to screen state and user pref");
            }
            return true;
        } else if (!isNotification) {
            // If the user allows speech when the screen is off, drop
            // all non-notification events.
            if (LogUtils.LOG_LEVEL <= Log.VERBOSE) {
                Log.v(LOGTAG, "Drop non-notification event due to screen state");
            }
            return true;
        }
    }

    final boolean canInterruptRadialMenu = AccessibilityEventUtils.eventMatchesAnyType(event,
            MASK_EVENT_TYPES_INTERRUPT_RADIAL_MENU);
    final boolean silencedByRadialMenu = (mService.getMenuManager().isMenuShowing() && !canInterruptRadialMenu);

    // Don't speak events that cannot interrupt the radial menu, if showing
    if (silencedByRadialMenu) {
        if (LogUtils.LOG_LEVEL <= Log.VERBOSE) {
            Log.v(LOGTAG, "Drop event due to radial menu state");
        }
        return true;
    }

    // Don't speak notification events if the user is touch exploring or a phone call is active.
    if (isNotification && (mIsUserTouchExploring || isPhoneActive)) {
        if (LogUtils.LOG_LEVEL <= Log.VERBOSE) {
            Log.v(LOGTAG, "Drop notification due to touch or phone state");
        }
        return true;
    }

    final int touchscreenState = mService.getResources().getConfiguration().touchscreen;
    final boolean isTouchInteractionStateChange = AccessibilityEventUtils.eventMatchesAnyType(event,
            MASK_EVENT_TYPES_TOUCH_STATE_CHANGES);

    // Drop all events related to touch interaction state on devices that don't support touch.
    return (touchscreenState == Configuration.TOUCHSCREEN_NOTOUCH) && isTouchInteractionStateChange;
}

From source file:com.xorcode.andtweet.TweetListActivity.java

/**
 * TODO: Maybe this code should be moved to "onResume" ???
 *//*w  w  w .  j  ava 2s.  c  om*/
@Override
protected void onStart() {
    super.onStart();
    if (MyLog.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "onStart");
    }
    Intent intent = getIntent();
    queryListData(intent, false, false);

    if (mTweetEditor.isVisible()) {
        // This is done to request focus (if we need this...)
        mTweetEditor.show();
    }
}