Search in sources :

Example 46 with LogPrinter

use of android.util.LogPrinter in project android_frameworks_base by AOSPA.

the class BaseInputConnection method replaceText.

private void replaceText(CharSequence text, int newCursorPosition, boolean composing) {
    final Editable content = getEditable();
    if (content == null) {
        return;
    }
    beginBatchEdit();
    // delete composing text set previously.
    int a = getComposingSpanStart(content);
    int b = getComposingSpanEnd(content);
    if (DEBUG)
        Log.v(TAG, "Composing span: " + a + " to " + b);
    if (b < a) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    if (a != -1 && b != -1) {
        removeComposingSpans(content);
    } else {
        a = Selection.getSelectionStart(content);
        b = Selection.getSelectionEnd(content);
        if (a < 0)
            a = 0;
        if (b < 0)
            b = 0;
        if (b < a) {
            int tmp = a;
            a = b;
            b = tmp;
        }
    }
    if (composing) {
        Spannable sp = null;
        if (!(text instanceof Spannable)) {
            sp = new SpannableStringBuilder(text);
            text = sp;
            ensureDefaultComposingSpans();
            if (mDefaultComposingSpans != null) {
                for (int i = 0; i < mDefaultComposingSpans.length; ++i) {
                    sp.setSpan(mDefaultComposingSpans[i], 0, sp.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_COMPOSING);
                }
            }
        } else {
            sp = (Spannable) text;
        }
        setComposingSpans(sp);
    }
    if (DEBUG)
        Log.v(TAG, "Replacing from " + a + " to " + b + " with \"" + text + "\", composing=" + composing + ", type=" + text.getClass().getCanonicalName());
    if (DEBUG) {
        LogPrinter lp = new LogPrinter(Log.VERBOSE, TAG);
        lp.println("Current text:");
        TextUtils.dumpSpans(content, lp, "  ");
        lp.println("Composing text:");
        TextUtils.dumpSpans(text, lp, "  ");
    }
    // we are providing here.
    if (newCursorPosition > 0) {
        newCursorPosition += b - 1;
    } else {
        newCursorPosition += a;
    }
    if (newCursorPosition < 0)
        newCursorPosition = 0;
    if (newCursorPosition > content.length())
        newCursorPosition = content.length();
    Selection.setSelection(content, newCursorPosition);
    content.replace(a, b, text);
    if (DEBUG) {
        LogPrinter lp = new LogPrinter(Log.VERBOSE, TAG);
        lp.println("Final text:");
        TextUtils.dumpSpans(content, lp, "  ");
    }
    endBatchEdit();
}
Also used : Editable(android.text.Editable) Spannable(android.text.Spannable) SpannableStringBuilder(android.text.SpannableStringBuilder) LogPrinter(android.util.LogPrinter)

Example 47 with LogPrinter

use of android.util.LogPrinter in project android_frameworks_base by AOSPA.

the class IntentResolver method removeFilterInternal.

void removeFilterInternal(F f) {
    if (localLOGV) {
        Slog.v(TAG, "Removing filter: " + f);
        f.dump(new LogPrinter(Log.VERBOSE, TAG, Log.LOG_ID_SYSTEM), "      ");
        Slog.v(TAG, "    Cleaning Lookup Maps:");
    }
    int numS = unregister_intent_filter(f, f.schemesIterator(), mSchemeToFilter, "      Scheme: ");
    int numT = unregister_mime_types(f, "      Type: ");
    if (numS == 0 && numT == 0) {
        unregister_intent_filter(f, f.actionsIterator(), mActionToFilter, "      Action: ");
    }
    if (numT != 0) {
        unregister_intent_filter(f, f.actionsIterator(), mTypedActionToFilter, "      TypedAction: ");
    }
}
Also used : LogPrinter(android.util.LogPrinter)

Example 48 with LogPrinter

use of android.util.LogPrinter in project android_frameworks_base by ResurrectionRemix.

the class BaseInputConnection method replaceText.

private void replaceText(CharSequence text, int newCursorPosition, boolean composing) {
    final Editable content = getEditable();
    if (content == null) {
        return;
    }
    beginBatchEdit();
    // delete composing text set previously.
    int a = getComposingSpanStart(content);
    int b = getComposingSpanEnd(content);
    if (DEBUG)
        Log.v(TAG, "Composing span: " + a + " to " + b);
    if (b < a) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    if (a != -1 && b != -1) {
        removeComposingSpans(content);
    } else {
        a = Selection.getSelectionStart(content);
        b = Selection.getSelectionEnd(content);
        if (a < 0)
            a = 0;
        if (b < 0)
            b = 0;
        if (b < a) {
            int tmp = a;
            a = b;
            b = tmp;
        }
    }
    if (composing) {
        Spannable sp = null;
        if (!(text instanceof Spannable)) {
            sp = new SpannableStringBuilder(text);
            text = sp;
            ensureDefaultComposingSpans();
            if (mDefaultComposingSpans != null) {
                for (int i = 0; i < mDefaultComposingSpans.length; ++i) {
                    sp.setSpan(mDefaultComposingSpans[i], 0, sp.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_COMPOSING);
                }
            }
        } else {
            sp = (Spannable) text;
        }
        setComposingSpans(sp);
    }
    if (DEBUG)
        Log.v(TAG, "Replacing from " + a + " to " + b + " with \"" + text + "\", composing=" + composing + ", type=" + text.getClass().getCanonicalName());
    if (DEBUG) {
        LogPrinter lp = new LogPrinter(Log.VERBOSE, TAG);
        lp.println("Current text:");
        TextUtils.dumpSpans(content, lp, "  ");
        lp.println("Composing text:");
        TextUtils.dumpSpans(text, lp, "  ");
    }
    // we are providing here.
    if (newCursorPosition > 0) {
        newCursorPosition += b - 1;
    } else {
        newCursorPosition += a;
    }
    if (newCursorPosition < 0)
        newCursorPosition = 0;
    if (newCursorPosition > content.length())
        newCursorPosition = content.length();
    Selection.setSelection(content, newCursorPosition);
    content.replace(a, b, text);
    if (DEBUG) {
        LogPrinter lp = new LogPrinter(Log.VERBOSE, TAG);
        lp.println("Final text:");
        TextUtils.dumpSpans(content, lp, "  ");
    }
    endBatchEdit();
}
Also used : Editable(android.text.Editable) Spannable(android.text.Spannable) SpannableStringBuilder(android.text.SpannableStringBuilder) LogPrinter(android.util.LogPrinter)

Example 49 with LogPrinter

use of android.util.LogPrinter in project android_frameworks_base by ResurrectionRemix.

the class IntentResolver method removeFilterInternal.

void removeFilterInternal(F f) {
    if (localLOGV) {
        Slog.v(TAG, "Removing filter: " + f);
        f.dump(new LogPrinter(Log.VERBOSE, TAG, Log.LOG_ID_SYSTEM), "      ");
        Slog.v(TAG, "    Cleaning Lookup Maps:");
    }
    int numS = unregister_intent_filter(f, f.schemesIterator(), mSchemeToFilter, "      Scheme: ");
    int numT = unregister_mime_types(f, "      Type: ");
    if (numS == 0 && numT == 0) {
        unregister_intent_filter(f, f.actionsIterator(), mActionToFilter, "      Action: ");
    }
    if (numT != 0) {
        unregister_intent_filter(f, f.actionsIterator(), mTypedActionToFilter, "      TypedAction: ");
    }
}
Also used : LogPrinter(android.util.LogPrinter)

Example 50 with LogPrinter

use of android.util.LogPrinter in project android_frameworks_base by ResurrectionRemix.

the class IntentResolver method buildResolveList.

private void buildResolveList(Intent intent, FastImmutableArraySet<String> categories, boolean debug, boolean defaultOnly, String resolvedType, String scheme, F[] src, List<R> dest, int userId) {
    final String action = intent.getAction();
    final Uri data = intent.getData();
    final String packageName = intent.getPackage();
    final boolean excludingStopped = intent.isExcludingStopped();
    final Printer logPrinter;
    final PrintWriter logPrintWriter;
    if (debug) {
        logPrinter = new LogPrinter(Log.VERBOSE, TAG, Log.LOG_ID_SYSTEM);
        logPrintWriter = new FastPrintWriter(logPrinter);
    } else {
        logPrinter = null;
        logPrintWriter = null;
    }
    final int N = src != null ? src.length : 0;
    boolean hasNonDefaults = false;
    int i;
    F filter;
    for (i = 0; i < N && (filter = src[i]) != null; i++) {
        int match;
        if (debug)
            Slog.v(TAG, "Matching against filter " + filter);
        if (excludingStopped && isFilterStopped(filter, userId)) {
            if (debug) {
                Slog.v(TAG, "  Filter's target is stopped; skipping");
            }
            continue;
        }
        // Is delivery being limited to filters owned by a particular package?
        if (packageName != null && !isPackageForFilter(packageName, filter)) {
            if (debug) {
                Slog.v(TAG, "  Filter is not from package " + packageName + "; skipping");
            }
            continue;
        }
        // Are we verified ?
        if (filter.getAutoVerify()) {
            if (localVerificationLOGV || debug) {
                Slog.v(TAG, "  Filter verified: " + isFilterVerified(filter));
                int authorities = filter.countDataAuthorities();
                for (int z = 0; z < authorities; z++) {
                    Slog.v(TAG, "   " + filter.getDataAuthority(z).getHost());
                }
            }
        }
        // Do we already have this one?
        if (!allowFilterResult(filter, dest)) {
            if (debug) {
                Slog.v(TAG, "  Filter's target already added");
            }
            continue;
        }
        match = filter.match(action, resolvedType, scheme, data, categories, TAG);
        if (match >= 0) {
            if (debug)
                Slog.v(TAG, "  Filter matched!  match=0x" + Integer.toHexString(match) + " hasDefault=" + filter.hasCategory(Intent.CATEGORY_DEFAULT));
            if (!defaultOnly || filter.hasCategory(Intent.CATEGORY_DEFAULT)) {
                final R oneResult = newResult(filter, match, userId);
                if (oneResult != null) {
                    dest.add(oneResult);
                    if (debug) {
                        dumpFilter(logPrintWriter, "    ", filter);
                        logPrintWriter.flush();
                        filter.dump(logPrinter, "    ");
                    }
                }
            } else {
                hasNonDefaults = true;
            }
        } else {
            if (debug) {
                String reason;
                switch(match) {
                    case IntentFilter.NO_MATCH_ACTION:
                        reason = "action";
                        break;
                    case IntentFilter.NO_MATCH_CATEGORY:
                        reason = "category";
                        break;
                    case IntentFilter.NO_MATCH_DATA:
                        reason = "data";
                        break;
                    case IntentFilter.NO_MATCH_TYPE:
                        reason = "type";
                        break;
                    default:
                        reason = "unknown reason";
                        break;
                }
                Slog.v(TAG, "  Filter did not match: " + reason);
            }
        }
    }
    if (debug && hasNonDefaults) {
        if (dest.size() == 0) {
            Slog.v(TAG, "resolveIntent failed: found match, but none with CATEGORY_DEFAULT");
        } else if (dest.size() > 1) {
            Slog.v(TAG, "resolveIntent: multiple matches, only some with CATEGORY_DEFAULT");
        }
    }
}
Also used : FastPrintWriter(com.android.internal.util.FastPrintWriter) PrintWriterPrinter(android.util.PrintWriterPrinter) LogPrinter(android.util.LogPrinter) Printer(android.util.Printer) Uri(android.net.Uri) PrintWriter(java.io.PrintWriter) FastPrintWriter(com.android.internal.util.FastPrintWriter) LogPrinter(android.util.LogPrinter)

Aggregations

LogPrinter (android.util.LogPrinter)52 Uri (android.net.Uri)10 Editable (android.text.Editable)7 Spannable (android.text.Spannable)7 SpannableStringBuilder (android.text.SpannableStringBuilder)7 AndroidRuntimeException (android.util.AndroidRuntimeException)7 ActivityInfo (android.content.pm.ActivityInfo)6 ResolveInfo (android.content.pm.ResolveInfo)6 Intent (android.content.Intent)5 IntentFilter (android.content.IntentFilter)5 PatternMatcher (android.os.PatternMatcher)5 PrintWriterPrinter (android.util.PrintWriterPrinter)5 Printer (android.util.Printer)5 FastPrintWriter (com.android.internal.util.FastPrintWriter)5 File (java.io.File)5 PrintWriter (java.io.PrintWriter)5 EphemeralResolveInfo (android.content.pm.EphemeralResolveInfo)4 Handler (android.os.Handler)2 ComponentName (android.content.ComponentName)1 Context (android.content.Context)1