Example usage for android.util Log isLoggable

List of usage examples for android.util Log isLoggable

Introduction

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

Prototype

public static native boolean isLoggable(String tag, int level);

Source Link

Document

Checks to see whether or not a log for the specified tag is loggable at the specified level.

Usage

From source file:com.android.contacts.list.DefaultContactBrowseListFragment.java

private void setSwipeRefreshLayoutEnabledOrNot(ContactListFilter filter) {
    final SwipeRefreshLayout swipeRefreshLayout = getSwipeRefreshLayout();
    if (swipeRefreshLayout == null) {
        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "Can not load swipeRefreshLayout, swipeRefreshLayout is null");
        }//from   w  w  w . j  a v a 2 s. c o m
        return;
    }

    swipeRefreshLayout.setRefreshing(false);
    swipeRefreshLayout.setEnabled(false);

    if (filter != null && !mActionBarAdapter.isSearchMode() && !mActionBarAdapter.isSelectionMode()) {
        if (filter.isSyncable() || (filter.shouldShowSyncState()
                && SyncUtil.hasSyncableAccount(AccountTypeManager.getInstance(getContext())))) {
            swipeRefreshLayout.setEnabled(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;/*ww w. j a v a2s.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  a va 2  s . c o m*/
@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.ex.chips.RecipientEditTextView.java

/**
 * Remove any characters after the last valid chip.
 *//*from  w  ww . j a  v a  2  s  .co m*/
// Visible for testing.
/* package */void sanitizeEnd() {
    // Don't sanitize while we are waiting for pending chips to complete.
    if (mPendingChipsCount > 0)
        return;
    // Find the last chip; eliminate any commit characters after it.
    final DrawableRecipientChip[] chips = getSortedRecipients();
    final Spannable spannable = getSpannable();
    if (chips != null && chips.length > 0) {
        int end;
        mMoreChip = getMoreChip();
        if (mMoreChip != null)
            end = spannable.getSpanEnd(mMoreChip);
        else
            end = getSpannable().getSpanEnd(getLastChip());
        final Editable editable = getText();
        final int length = editable.length();
        if (length > end) {
            // See what characters occur after that and eliminate them.
            if (Log.isLoggable(TAG, Log.DEBUG))
                Log.d(TAG, "There were extra characters after the last tokenizable entry." + editable);
            editable.delete(end + 1, length);
        }
    }
}

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;/*from  www .j  a  v  a  2 s . c  o m*/
    }

    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:info.guardianproject.otr.app.im.app.ChatView.java

public void bindChat(long chatId) {
    log("bind " + this + " " + chatId);
    mLastChatId = chatId;// ww w  .  j a  va  2s .  c om

    Uri contactUri = ContentUris.withAppendedId(Imps.Contacts.CONTENT_URI, chatId);
    Cursor c = mNewChatActivity.getContentResolver().query(contactUri, CHAT_PROJECTION, null, null, null);

    if (c == null)
        return;

    if (!c.moveToFirst()) {
        if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) {
            log("Failed to query chat: " + chatId);
        }
        mLastChatId = -1;

        c.close();

    } else {

        updateSessionInfo(c);

        if (mRemoteAvatar == null) {
            try {
                mRemoteAvatar = DatabaseUtils.getAvatarFromCursor(c, AVATAR_COLUMN, ImApp.DEFAULT_AVATAR_WIDTH,
                        ImApp.DEFAULT_AVATAR_HEIGHT);
            } catch (Exception e) {
            }

            if (mRemoteAvatar == null) {
                mRemoteAvatar = new RoundedAvatarDrawable(
                        BitmapFactory.decodeResource(getResources(), R.drawable.avatar_unknown));

            }

            updatePresenceDisplay();

        }

        c.close();

        mCurrentChatSession = getChatSession();

        if (mCurrentChatSession == null)
            mCurrentChatSession = createChatSession();

        if (mCurrentChatSession != null) {
            isServiceUp = true;

        }

        updateChat();
    }

}

From source file:com.google.android.gms.common.GooglePlayServicesUtil.java

private static byte[] m107a(PackageInfo packageInfo, byte[]... bArr) {
    try {//ww  w .ja  va2 s.  c o  m
        CertificateFactory instance = CertificateFactory.getInstance("X509");
        if (packageInfo.signatures.length != 1) {
            Log.w("GooglePlayServicesUtil", "Package has more than one signature.");
            return null;
        }
        try {
            try {
                ((X509Certificate) instance
                        .generateCertificate(new ByteArrayInputStream(packageInfo.signatures[0].toByteArray())))
                                .checkValidity();
                byte[] toByteArray = packageInfo.signatures[0].toByteArray();
                for (byte[] bArr2 : bArr) {
                    if (Arrays.equals(bArr2, toByteArray)) {
                        return bArr2;
                    }
                }
                if (Log.isLoggable("GooglePlayServicesUtil", 2)) {
                    Log.v("GooglePlayServicesUtil",
                            "Signature not valid.  Found: \n" + Base64.encodeToString(toByteArray, 0));
                }
                return null;
            } catch (CertificateExpiredException e) {
                Log.w("GooglePlayServicesUtil", "Certificate has expired.");
                return null;
            } catch (CertificateNotYetValidException e2) {
                Log.w("GooglePlayServicesUtil", "Certificate is not yet valid.");
                return null;
            }
        } catch (CertificateException e3) {
            Log.w("GooglePlayServicesUtil", "Could not generate certificate.");
            return null;
        }
    } catch (CertificateException e4) {
        Log.w("GooglePlayServicesUtil", "Could not get certificate instance.");
        return null;
    }
}

From source file:info.guardianproject.otr.app.im.app.ChatView.java

public void bindInvitation(long invitationId) {
    Uri uri = ContentUris.withAppendedId(Imps.Invitation.CONTENT_URI, invitationId);
    ContentResolver cr = mNewChatActivity.getContentResolver();
    Cursor cursor = cr.query(uri, INVITATION_PROJECT, null, null, null);
    try {// w  w  w.  j  av a  2s.  co  m
        if (!cursor.moveToFirst()) {
            if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) {
                log("Failed to query invitation: " + invitationId);
            }
            //  mNewChatActivity.finish();
        } else {
            setViewType(VIEW_TYPE_INVITATION);

            mInvitationId = cursor.getLong(INVITATION_ID_COLUMN);
            mProviderId = cursor.getLong(INVITATION_PROVIDER_COLUMN);
            String sender = cursor.getString(INVITATION_SENDER_COLUMN);

            TextView mInvitationText = (TextView) findViewById(R.id.txtInvitation);
            mInvitationText.setText(mContext.getString(R.string.invitation_prompt, sender));
            //  mNewChatActivity.setTitle(mContext.getString(R.string.chat_with, sender));
        }
    } finally {
        cursor.close();
    }

}

From source file:com.google.android.gms.common.GooglePlayServicesUtil.java

public static boolean m111b(PackageManager packageManager, String str) {
    try {/*w  ww .j a v a  2 s . c  o m*/
        return m105a(packageManager, packageManager.getPackageInfo(str, 64));
    } catch (NameNotFoundException e) {
        if (Log.isLoggable("GooglePlayServicesUtil", 3)) {
            Log.d("GooglePlayServicesUtil",
                    "Package manager can't find package " + str + ", defaulting to false");
        }
        return false;
    }
}

From source file:info.guardianproject.otr.app.im.app.ChatView.java

private synchronized void startQuery(long chatId) {
    if (mQueryHandler == null) {
        mQueryHandler = new QueryHandler(mContext);
    } else {//from  ww  w.  j a v a 2 s. c om
        // Cancel any pending queries
        mQueryHandler.cancelOperation(QUERY_TOKEN);
    }

    Uri uri = Imps.Messages.getContentUriByThreadId(chatId);

    if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) {
        log("queryCursor: uri=" + uri);
    }

    mQueryHandler.startQuery(QUERY_TOKEN, null, uri, null, null /* selection */, null /* selection args */,
            "date");
}