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:com.android.talkback.SpeechController.java

private boolean processNextFragmentInternal() {
    if (mCurrentFragmentIterator == null || !mCurrentFragmentIterator.hasNext()) {
        return false;
    }//from  w w w .  j av  a 2 s.co m

    FeedbackFragment fragment = mCurrentFragmentIterator.next();
    playEarconsFromFragment(fragment);
    playHapticsFromFragment(fragment);

    // Reuse the global instance of speech parameters.
    final HashMap<String, String> params = mSpeechParametersMap;
    params.clear();

    // Add all custom speech parameters.
    final Bundle speechParams = fragment.getSpeechParams();
    for (String key : speechParams.keySet()) {
        params.put(key, String.valueOf(speechParams.get(key)));
    }

    // Utterance ID, stream, and volume override item params.
    params.put(Engine.KEY_PARAM_UTTERANCE_ID, mCurrentFeedbackItem.getUtteranceId());
    params.put(Engine.KEY_PARAM_STREAM, String.valueOf(DEFAULT_STREAM));
    params.put(Engine.KEY_PARAM_VOLUME, String.valueOf(mSpeechVolume));

    final float pitch = mSpeechPitch * (mUseIntonation ? parseFloatParam(params, SpeechParam.PITCH, 1) : 1);
    final float rate = mSpeechRate * (mUseIntonation ? parseFloatParam(params, SpeechParam.RATE, 1) : 1);
    final CharSequence text;
    if (shouldSilenceSpeech(mCurrentFeedbackItem) || TextUtils.isEmpty(fragment.getText())) {
        text = null;
    } else {
        text = fragment.getText();
    }

    String logText = text == null ? null : text.toString();
    LogUtils.log(this, Log.VERBOSE, "Speaking fragment text \"%s\"", logText);

    mVoiceRecognitionChecker.onUtteranceStart();

    // It's okay if the utterance is empty, the fail-over TTS will
    // immediately call the fragment completion listener. This process is
    // important for things like continuous reading.
    mFailoverTts.speak(text, pitch, rate, params, DEFAULT_STREAM, mSpeechVolume);

    if (mTtsOverlay != null) {
        mTtsOverlay.speak(text);
    }

    return true;
}

From source file:com.android.mms.transaction.MessagingNotification.java

private static final void addMmsNotificationInfos(Context context, Set<Long> threads,
        SortedSet<NotificationInfo> notificationSet) {
    ContentResolver resolver = context.getContentResolver();

    // This query looks like this when logged:
    // I/Database(  147): elapsedTime4Sql|/data/data/com.android.providers.telephony/databases/
    // mmssms.db|0.362 ms|SELECT thread_id, date, _id, sub, sub_cs FROM pdu WHERE ((msg_box=1
    // AND seen=0 AND (m_type=130 OR m_type=132))) ORDER BY date desc

    Cursor cursor = SqliteWrapper.query(context, resolver, Mms.CONTENT_URI, MMS_STATUS_PROJECTION,
            NEW_INCOMING_MM_CONSTRAINT, null, Mms.DATE + " desc");

    if (cursor == null) {
        return;//from  ww w.j  a  v a 2  s  .  c o m
    }

    try {
        while (cursor.moveToNext()) {

            long msgId = cursor.getLong(COLUMN_MMS_ID);
            Uri msgUri = Mms.CONTENT_URI.buildUpon().appendPath(Long.toString(msgId)).build();
            String address = AddressUtils.getFrom(context, msgUri);

            Contact contact = Contact.get(address, false);
            if (contact.getSendToVoicemail()) {
                // don't notify, skip this one
                continue;
            }

            String subject = getMmsSubject(cursor.getString(COLUMN_MMS_SUBJECT),
                    cursor.getInt(COLUMN_MMS_SUBJECT_CS));
            subject = MessageUtils.cleanseMmsSubject(context, subject);

            long threadId = cursor.getLong(COLUMN_MMS_THREAD_ID);
            long timeMillis = cursor.getLong(COLUMN_MMS_DATE) * 1000;
            int subId = cursor.getInt(COLUMN_MMS_SUB_ID);

            if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
                Log.d(TAG, "addMmsNotificationInfos: count=" + cursor.getCount() + ", addr = " + address
                        + ", thread_id=" + threadId);
            }

            // Extract the message and/or an attached picture from the first slide
            Bitmap attachedPicture = null;
            String messageBody = null;
            int attachmentType = WorkingMessage.TEXT;
            try {
                GenericPdu pdu = sPduPersister.load(msgUri);
                if (pdu != null && pdu instanceof MultimediaMessagePdu) {
                    SlideshowModel slideshow = SlideshowModel.createFromPduBody(context,
                            ((MultimediaMessagePdu) pdu).getBody());
                    attachmentType = getAttachmentType(slideshow);
                    SlideModel firstSlide = slideshow.get(0);
                    if (firstSlide != null) {
                        if (firstSlide.hasImage()) {
                            int maxDim = dp2Pixels(MAX_BITMAP_DIMEN_DP);
                            attachedPicture = firstSlide.getImage().getBitmap(maxDim, maxDim);
                        }
                        if (firstSlide.hasText()) {
                            messageBody = firstSlide.getText().getText();
                        }
                    }
                }
            } catch (final MmsException e) {
                Log.e(TAG, "MmsException loading uri: " + msgUri, e);
                continue; // skip this bad boy -- don't generate an empty notification
            }

            NotificationInfo info = getNewMessageNotificationInfo(context, false /* isSms */, address,
                    messageBody, subject, threadId, subId, timeMillis, attachedPicture, contact,
                    attachmentType);
            if (MessageUtils.isMailboxMode()) {
                info.mClickIntent.setData(msgUri);
            }
            notificationSet.add(info);

            threads.add(threadId);
        }
    } finally {
        cursor.close();
    }
}

From source file:com.dirkgassen.wator.ui.activity.MainActivity.java

/**
 * The activitiy is resuming. We need to start our simulator and world updater thread.
 *//*from  w w  w .j av  a  2 s.  c  om*/
@Override
protected void onResume() {
    super.onResume();

    drawingAverageTime = new RollingAverage();

    worldUpdateNotifierThread = new Thread(getString(R.string.worldUpdateNotifierThreadName)) {
        @Override
        public void run() {
            if (Log.isLoggable("Wa-Tor", Log.DEBUG)) {
                Log.d("Wa-Tor", "Entering world update notifier thread");
            }
            try {
                long lastUpdateFinished = 0;
                while (Thread.currentThread() == worldUpdateNotifierThread) {
                    long startUpdate = System.currentTimeMillis();
                    if (Log.isLoggable("Wa-Tor", Log.VERBOSE)) {
                        Log.v("Wa-Tor", "WorldUpdateNotifierThread: Notifying observers of world update");
                    }
                    worldUpdated();
                    if (Log.isLoggable("Wa-Tor", Log.VERBOSE)) {
                        Log.v("Wa-Tor", "WorldUpdateNotifierThread: Notifying observers took "
                                + (System.currentTimeMillis() - startUpdate) + " ms");
                    }
                    long now = System.currentTimeMillis();
                    if (lastUpdateFinished > 0 && drawingAverageTime != null) {
                        drawingAverageTime.add(now - lastUpdateFinished);
                        if (Log.isLoggable("Wa-Tor", Log.VERBOSE)) {
                            Log.v("Wa-Tor", "WorldUpdateNotifierThread: Time delta since last redraw "
                                    + (now - lastUpdateFinished) + " ms");
                        }
                    }
                    lastUpdateFinished = now;
                    if (Log.isLoggable("Wa-Tor", Log.VERBOSE)) {
                        Log.v("Wa-Tor", "WorldUpdateNotifierThread: Waiting for next update");
                    }
                    synchronized (this) {
                        wait();
                    }
                }
            } catch (InterruptedException e) {
                if (Log.isLoggable("Wa-Tor", Log.DEBUG)) {
                    Log.d("Wa-Tor", "World update notifier thread got interrupted");
                }
                synchronized (this) {
                    worldUpdateNotifierThread = null;
                }
            }
            if (Log.isLoggable("Wa-Tor", Log.DEBUG)) {
                Log.d("Wa-Tor", "Exiting world update notifier thread");
            }
        }
    };
    worldUpdateNotifierThread.start();

    desiredFpsSlider.setValue(simulatorRunnable.getTargetFps());
    startSimulatorThread();

    synchronized (this) {
        if (drawerLayout.isDrawerVisible(GravityCompat.START)) {
            currentSimFps = (TextView) findViewById(R.id.fps_simulator);
            currentDrawFps = (TextView) findViewById(R.id.fps_drawing);
        }
    }
}

From source file:com.android.mms.transaction.MessagingNotification.java

private static final void addSmsNotificationInfos(Context context, Set<Long> threads,
        SortedSet<NotificationInfo> notificationSet) {
    ContentResolver resolver = context.getContentResolver();
    Cursor cursor = SqliteWrapper.query(context, resolver, Sms.CONTENT_URI, SMS_STATUS_PROJECTION,
            NEW_INCOMING_SM_CONSTRAINT, null, Sms.DATE + " desc");

    if (cursor == null) {
        return;/*w w  w  .ja  v  a  2  s  .com*/
    }

    try {
        while (cursor.moveToNext()) {
            String address = cursor.getString(COLUMN_SMS_ADDRESS);
            if (MessageUtils.isWapPushNumber(address)) {
                String[] mAddresses = address.split(":");
                address = mAddresses[context.getResources().getInteger(R.integer.wap_push_address_index)];
            }

            Contact contact = Contact.get(address, false);
            if (contact.getSendToVoicemail()) {
                // don't notify, skip this one
                continue;
            }

            String message = cursor.getString(COLUMN_SMS_BODY);
            long threadId = cursor.getLong(COLUMN_SMS_THREAD_ID);
            long timeMillis = cursor.getLong(COLUMN_SMS_DATE);
            int subId = cursor.getInt(COLUMN_SMS_SUB_ID);
            String msgId = cursor.getString(COLUMN_SMS_ID);

            if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
                Log.d(TAG, "addSmsNotificationInfos: count=" + cursor.getCount() + ", addr=" + address
                        + ", thread_id=" + threadId);
            }

            NotificationInfo info = getNewMessageNotificationInfo(context, true /* isSms */, address, message,
                    null /* subject */, threadId, subId, timeMillis, null /* attachmentBitmap */, contact,
                    WorkingMessage.TEXT);
            if (MessageUtils.isMailboxMode()) {
                info.mClickIntent.setData(Uri.withAppendedPath(Sms.CONTENT_URI, msgId));
            }
            notificationSet.add(info);

            threads.add(threadId);
            threads.add(cursor.getLong(COLUMN_SMS_THREAD_ID));
        }
    } finally {
        cursor.close();
    }
}

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

/**
 * Returns whether the device should drop this event. Caches notifications
 * if necessary.//from w ww .  j  a v  a  2  s  .c o 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 (!isServiceActive()) {
        return true;
    }

    // Always drop duplicate events (only applies to API < 14).
    if (AccessibilityEventUtils.eventEquals(mLastSpokenEvent, event)) {
        LogUtils.log(this, Log.VERBOSE, "Drop duplicate event");
        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)) {
        LogUtils.log(this, Log.VERBOSE, "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 (!mPowerManager.isScreenOn() && !shouldSpeakCallerId) {
        if (!mSpeakWhenScreenOff) {
            // If the user doesn't allow speech when the screen is
            // off, drop the event immediately.
            LogUtils.log(this, Log.VERBOSE, "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.
            LogUtils.log(this, Log.VERBOSE, "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 = (mRadialMenuManager.isRadialMenuShowing() && !canInterruptRadialMenu);

    // Don't speak events that cannot interrupt the radial menu, if showing
    if (silencedByRadialMenu) {
        LogUtils.log(this, Log.VERBOSE, "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)) {
        LogUtils.log(this, Log.VERBOSE, "Drop notification due to touch or phone state");
        return true;
    }

    final int touchscreenState = 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.
    final int touchscreenConfig = getResources().getConfiguration().touchscreen;
    if ((touchscreenState == Configuration.TOUCHSCREEN_NOTOUCH) && isTouchInteractionStateChange) {
        return true;
    }

    return false;
}

From source file:com.android.talkback.SpeechController.java

/**
 * Handles the completion of an {@link Utterance}/{@link FeedbackItem}.
 *
 * @param utteranceIndex The ID of the utterance that has completed.
 * @param status One of {@link SpeechController#STATUS_ERROR},
 *            {@link SpeechController#STATUS_INTERRUPTED}, or
 *            {@link SpeechController#STATUS_SPOKEN}
 * @param interrupted {@code true} if the utterance was interrupted, {@code false} otherwise
 * @param advance Whether to advance to the next queue item.
 *///from   ww  w  .  ja  va2  s .c om
private void onUtteranceCompleted(int utteranceIndex, int status, boolean interrupted, boolean advance) {
    while (!mUtteranceCompleteActions.isEmpty()
            && (mUtteranceCompleteActions.peek().utteranceIndex <= utteranceIndex)) {
        final UtteranceCompleteRunnable runnable = mUtteranceCompleteActions.poll().runnable;
        if (runnable != null) {
            mHandler.post(new CompletionRunner(runnable, status));
        }
    }

    if (mSpeechListener != null) {
        mSpeechListener.onUtteranceCompleted(utteranceIndex, status);
    }

    if (interrupted) {
        // We finished an utterance, but we weren't expecting to see a
        // completion. This means we interrupted a previous utterance and
        // can safely ignore this callback.
        LogUtils.log(this, Log.VERBOSE, "Interrupted %d with %s", utteranceIndex,
                mCurrentFeedbackItem.getUtteranceId());
        return;
    }

    if (advance && !speakNextItem()) {
        handleSpeechCompleted();
    }
}

From source file:com.android.talkback.SpeechController.java

/**
 * Removes and speaks the next {@link FeedbackItem} in the queue,
 * interrupting the current utterance if necessary.
 *
 * @return {@code false} if there are no more queued speech items.
 *///  w  w  w .ja  va2  s  .  co  m
private boolean speakNextItem() {
    final FeedbackItem previousItem = mCurrentFeedbackItem;
    final FeedbackItem nextItem = (mFeedbackQueue.isEmpty() ? null : mFeedbackQueue.removeFirst());

    mCurrentFeedbackItem = nextItem;

    if (nextItem == null) {
        LogUtils.log(this, Log.VERBOSE, "No next item, stopping speech queue");
        return false;
    }

    if (previousItem == null) {
        handleSpeechStarting();
    }

    mCurrentFragmentIterator = nextItem.getFragments().iterator();
    speakNextItemInternal(nextItem);
    return true;
}

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

/**
 * Reloads service preferences.// w  ww .  j  a v  a2  s.co  m
 */
private void reloadPreferences() {
    final Resources res = getResources();

    mSpeakWhenScreenOff = SharedPreferencesUtils.getBooleanPref(mPrefs, res, R.string.pref_screenoff_key,
            R.bool.pref_screenoff_default);
    mSpeakCallerId = SharedPreferencesUtils.getBooleanPref(mPrefs, res, R.string.pref_caller_id_key,
            R.bool.pref_caller_id_default);

    final String automaticResume = SharedPreferencesUtils.getStringPref(mPrefs, res,
            R.string.pref_resume_talkback_key, R.string.pref_resume_talkback_default);
    mAutomaticResume = AutomaticResumePreference.safeValueOf(automaticResume);

    final boolean silenceOnProximity = SharedPreferencesUtils.getBooleanPref(mPrefs, res,
            R.string.pref_proximity_key, R.bool.pref_proximity_default);
    mSpeechController.setSilenceOnProximity(silenceOnProximity);

    final int logLevel = (DEBUG ? Log.VERBOSE
            : SharedPreferencesUtils.getIntFromStringPref(mPrefs, res, R.string.pref_log_level_key,
                    R.string.pref_log_level_default));
    LogUtils.setLogLevel(logLevel);

    if (mProcessorFollowFocus != null) {
        final boolean useSingleTap = SharedPreferencesUtils.getBooleanPref(mPrefs, res,
                R.string.pref_single_tap_key, R.bool.pref_single_tap_default);

        mProcessorFollowFocus.setSingleTapEnabled(useSingleTap);

        // Update the "X to select" long-hover hint.
        NodeHintRule.NodeHintHelper.updateActionResId(useSingleTap);
    }

    if (mShakeDetector != null) {
        final int shakeThreshold = SharedPreferencesUtils.getIntFromStringPref(mPrefs, res,
                R.string.pref_shake_to_read_threshold_key, R.string.pref_shake_to_read_threshold_default);
        final boolean useShake = (shakeThreshold > 0) && ((mCallStateMonitor == null)
                || (mCallStateMonitor.getCurrentCallState() == TelephonyManager.CALL_STATE_IDLE));

        mShakeDetector.setEnabled(useShake);
    }

    if (SUPPORTS_TOUCH_PREF) {
        final boolean touchExploration = SharedPreferencesUtils.getBooleanPref(mPrefs, res,
                R.string.pref_explore_by_touch_key, R.bool.pref_explore_by_touch_default);
        requestTouchExploration(touchExploration);

        final String verticalGesturesPref = SharedPreferencesUtils.getStringPref(mPrefs, res,
                R.string.pref_two_part_vertical_gestures_key, R.string.pref_two_part_vertical_gestures_default);
        mVerticalGestureCycleGranularity = verticalGesturesPref
                .equals(getString(R.string.value_two_part_vertical_gestures_cycle));
    }
}

From source file:com.android.providers.contacts.ContactsSyncAdapter.java

protected void savePhoto(long person, InputStream photoInput, String photoVersion) throws IOException {
    try {//from   w w  w  .  ja  va2s  .  com
        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        byte[] data = new byte[1024];
        while (true) {
            int bytesRead = photoInput.read(data);
            if (bytesRead < 0)
                break;
            byteStream.write(data, 0, bytesRead);
        }

        ContentValues values = new ContentValues();
        // we have to include this here otherwise the provider will set it to 1
        values.put(Photos._SYNC_DIRTY, 0);
        values.put(Photos.LOCAL_VERSION, photoVersion);
        values.put(Photos.DATA, byteStream.toByteArray());
        Uri photoUri = Uri.withAppendedPath(People.CONTENT_URI, "" + person + "/" + Photos.CONTENT_DIRECTORY);
        if (getContext().getContentResolver().update(photoUri, values, "_sync_dirty=0", null) > 0) {
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "savePhoto: updated " + photoUri + " with values " + values);
            }
        } else {
            Log.e(TAG, "savePhoto: update of " + photoUri + " with values " + values + " affected no rows");
        }
    } finally {
        try {
            if (photoInput != null)
                photoInput.close();
        } catch (IOException e) {
            // we don't care about exceptions here
        }
    }
}

From source file:com.google.android.marvin.talkback.TalkBackService.java

/**
 * Reloads service preferences.//from  ww  w . j  a  va2 s .c  om
 */
private void reloadPreferences() {
    final Resources res = getResources();

    mSpeakWhenScreenOff = SharedPreferencesUtils.getBooleanPref(mPrefs, res, R.string.pref_screenoff_key,
            R.bool.pref_screenoff_default);
    mSpeakCallerId = SharedPreferencesUtils.getBooleanPref(mPrefs, res, R.string.pref_caller_id_key,
            R.bool.pref_caller_id_default);

    final String automaticResume = SharedPreferencesUtils.getStringPref(mPrefs, res,
            R.string.pref_resume_talkback_key, R.string.pref_resume_talkback_default);
    mAutomaticResume = AutomaticResumePreference.safeValueOf(automaticResume);

    final boolean silenceOnProximity = SharedPreferencesUtils.getBooleanPref(mPrefs, res,
            R.string.pref_proximity_key, R.bool.pref_proximity_default);
    mSpeechController.setSilenceOnProximity(silenceOnProximity);

    final int logLevel = (DEBUG ? Log.VERBOSE
            : SharedPreferencesUtils.getIntFromStringPref(mPrefs, res, R.string.pref_log_level_key,
                    R.string.pref_log_level_default));
    LogUtils.setLogLevel(logLevel);

    if (mProcessorFollowFocus != null) {
        final boolean useSingleTap = SharedPreferencesUtils.getBooleanPref(mPrefs, res,
                R.string.pref_single_tap_key, R.bool.pref_single_tap_default);

        mProcessorFollowFocus.setSingleTapEnabled(useSingleTap);

        // Update the "X to select" long-hover hint.
        NodeHintRule.NodeHintHelper.updateActionResId(useSingleTap);
    }

    if (mShakeDetector != null) {
        final int shakeThreshold = SharedPreferencesUtils.getIntFromStringPref(mPrefs, res,
                R.string.pref_shake_to_read_threshold_key, R.string.pref_shake_to_read_threshold_default);
        final boolean useShake = (shakeThreshold > 0) && ((mCallStateMonitor == null)
                || (mCallStateMonitor.getCurrentCallState() == TelephonyManager.CALL_STATE_IDLE));

        mShakeDetector.setEnabled(useShake);
    }

    if (SUPPORTS_TOUCH_PREF) {
        final boolean touchExploration = SharedPreferencesUtils.getBooleanPref(mPrefs, res,
                R.string.pref_explore_by_touch_key, R.bool.pref_explore_by_touch_default);
        requestTouchExploration(touchExploration);

        final String verticalGesturesPref = SharedPreferencesUtils.getStringPref(mPrefs, res,
                R.string.pref_two_part_vertical_gestures_key, R.string.pref_two_part_vertical_gestures_default);
        mVerticalGestureCycleGranularity = verticalGesturesPref
                .equals(getString(R.string.value_two_part_vertical_gestures_cycle));
    }

    if (SUPPORTS_WEB_SCRIPT_TOGGLE) {
        final boolean requestWebScripts = SharedPreferencesUtils.getBooleanPref(mPrefs, res,
                R.string.pref_web_scripts_key, R.bool.pref_web_scripts_default);
        requestWebScripts(requestWebScripts);
    }
}