Search in sources :

Example 16 with LogPrinter

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

the class PackageManagerService method findPreferredActivity.

// TODO: handle preferred activities missing while user has amnesia
ResolveInfo findPreferredActivity(Intent intent, String resolvedType, int flags, List<ResolveInfo> query, int priority, boolean always, boolean removeMatches, boolean debug, int userId) {
    if (!sUserManager.exists(userId))
        return null;
    flags = updateFlagsForResolve(flags, userId, intent);
    // writer
    synchronized (mPackages) {
        if (intent.getSelector() != null) {
            intent = intent.getSelector();
        }
        if (DEBUG_PREFERRED)
            intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
        // Try to find a matching persistent preferred activity.
        ResolveInfo pri = findPersistentPreferredActivityLP(intent, resolvedType, flags, query, debug, userId);
        // If a persistent preferred activity matched, use it.
        if (pri != null) {
            return pri;
        }
        PreferredIntentResolver pir = mSettings.mPreferredActivities.get(userId);
        // Get the list of preferred activities that handle the intent
        if (DEBUG_PREFERRED || debug)
            Slog.v(TAG, "Looking for preferred activities...");
        List<PreferredActivity> prefs = pir != null ? pir.queryIntent(intent, resolvedType, (flags & PackageManager.MATCH_DEFAULT_ONLY) != 0, userId) : null;
        if (prefs != null && prefs.size() > 0) {
            boolean changed = false;
            try {
                // First figure out how good the original match set is.
                // We will only allow preferred activities that came
                // from the same match quality.
                int match = 0;
                if (DEBUG_PREFERRED || debug)
                    Slog.v(TAG, "Figuring out best match...");
                final int N = query.size();
                for (int j = 0; j < N; j++) {
                    final ResolveInfo ri = query.get(j);
                    if (DEBUG_PREFERRED || debug)
                        Slog.v(TAG, "Match for " + ri.activityInfo + ": 0x" + Integer.toHexString(match));
                    if (ri.match > match) {
                        match = ri.match;
                    }
                }
                if (DEBUG_PREFERRED || debug)
                    Slog.v(TAG, "Best match: 0x" + Integer.toHexString(match));
                match &= IntentFilter.MATCH_CATEGORY_MASK;
                final int M = prefs.size();
                for (int i = 0; i < M; i++) {
                    final PreferredActivity pa = prefs.get(i);
                    if (DEBUG_PREFERRED || debug) {
                        Slog.v(TAG, "Checking PreferredActivity ds=" + (pa.countDataSchemes() > 0 ? pa.getDataScheme(0) : "<none>") + "\n  component=" + pa.mPref.mComponent);
                        pa.dump(new LogPrinter(Log.VERBOSE, TAG, Log.LOG_ID_SYSTEM), "  ");
                    }
                    if (pa.mPref.mMatch != match) {
                        if (DEBUG_PREFERRED || debug)
                            Slog.v(TAG, "Skipping bad match " + Integer.toHexString(pa.mPref.mMatch));
                        continue;
                    }
                    // looking for, skip it.
                    if (always && !pa.mPref.mAlways) {
                        if (DEBUG_PREFERRED || debug)
                            Slog.v(TAG, "Skipping mAlways=false entry");
                        continue;
                    }
                    final ActivityInfo ai = getActivityInfo(pa.mPref.mComponent, flags | MATCH_DISABLED_COMPONENTS | MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE, userId);
                    if (DEBUG_PREFERRED || debug) {
                        Slog.v(TAG, "Found preferred activity:");
                        if (ai != null) {
                            ai.dump(new LogPrinter(Log.VERBOSE, TAG, Log.LOG_ID_SYSTEM), "  ");
                        } else {
                            Slog.v(TAG, "  null");
                        }
                    }
                    if (ai == null) {
                        // This previously registered preferred activity
                        // component is no longer known.  Most likely an update
                        // to the app was installed and in the new version this
                        // component no longer exists.  Clean it up by removing
                        // it from the preferred activities list, and skip it.
                        Slog.w(TAG, "Removing dangling preferred activity: " + pa.mPref.mComponent);
                        pir.removeFilter(pa);
                        changed = true;
                        continue;
                    }
                    for (int j = 0; j < N; j++) {
                        final ResolveInfo ri = query.get(j);
                        if (!ri.activityInfo.applicationInfo.packageName.equals(ai.applicationInfo.packageName)) {
                            continue;
                        }
                        if (!ri.activityInfo.name.equals(ai.name)) {
                            continue;
                        }
                        if (removeMatches) {
                            pir.removeFilter(pa);
                            changed = true;
                            if (DEBUG_PREFERRED) {
                                Slog.v(TAG, "Removing match " + pa.mPref.mComponent);
                            }
                            break;
                        }
                        // user their preference, if we're looking for an "always" type entry.
                        if (always && !pa.mPref.sameSet(query)) {
                            Slog.i(TAG, "Result set changed, dropping preferred activity for " + intent + " type " + resolvedType);
                            if (DEBUG_PREFERRED) {
                                Slog.v(TAG, "Removing preferred activity since set changed " + pa.mPref.mComponent);
                            }
                            pir.removeFilter(pa);
                            // Re-add the filter as a "last chosen" entry (!always)
                            PreferredActivity lastChosen = new PreferredActivity(pa, pa.mPref.mMatch, null, pa.mPref.mComponent, false);
                            pir.addFilter(lastChosen);
                            changed = true;
                            return null;
                        }
                        // Yay! Either the set matched or we're looking for the last chosen
                        if (DEBUG_PREFERRED || debug)
                            Slog.v(TAG, "Returning preferred activity: " + ri.activityInfo.packageName + "/" + ri.activityInfo.name);
                        return ri;
                    }
                }
            } finally {
                if (changed) {
                    if (DEBUG_PREFERRED) {
                        Slog.v(TAG, "Preferred activity bookkeeping changed; writing restrictions");
                    }
                    scheduleWritePackageRestrictionsLocked(userId);
                }
            }
        }
    }
    if (DEBUG_PREFERRED || debug)
        Slog.v(TAG, "No preferred activity to return");
    return null;
}
Also used : EphemeralResolveInfo(android.content.pm.EphemeralResolveInfo) ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) LogPrinter(android.util.LogPrinter)

Example 17 with LogPrinter

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

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 18 with LogPrinter

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

the class IntentResolver method addFilter.

public void addFilter(F f) {
    if (localLOGV) {
        Slog.v(TAG, "Adding filter: " + f);
        f.dump(new LogPrinter(Log.VERBOSE, TAG, Log.LOG_ID_SYSTEM), "      ");
        Slog.v(TAG, "    Building Lookup Maps:");
    }
    mFilters.add(f);
    int numS = register_intent_filter(f, f.schemesIterator(), mSchemeToFilter, "      Scheme: ");
    int numT = register_mime_types(f, "      Type: ");
    if (numS == 0 && numT == 0) {
        register_intent_filter(f, f.actionsIterator(), mActionToFilter, "      Action: ");
    }
    if (numT != 0) {
        register_intent_filter(f, f.actionsIterator(), mTypedActionToFilter, "      TypedAction: ");
    }
}
Also used : LogPrinter(android.util.LogPrinter)

Example 19 with LogPrinter

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

the class ActivityThread method main.

public static void main(String[] args) {
    Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "ActivityThreadMain");
    SamplingProfilerIntegration.start();
    // CloseGuard defaults to true and can be quite spammy.  We
    // disable it here, but selectively enable it later (via
    // StrictMode) on debug builds, but using DropBox, not logs.
    CloseGuard.setEnabled(false);
    Environment.initForCurrentUser();
    // Set the reporter for event logging in libcore
    EventLogger.setReporter(new EventLoggingReporter());
    // Make sure TrustedCertificateStore looks in the right place for CA certificates
    final File configDir = Environment.getUserConfigDirectory(UserHandle.myUserId());
    TrustedCertificateStore.setDefaultUserDirectory(configDir);
    Process.setArgV0("<pre-initialized>");
    Looper.prepareMainLooper();
    ActivityThread thread = new ActivityThread();
    thread.attach(false);
    if (sMainThreadHandler == null) {
        sMainThreadHandler = thread.getHandler();
    }
    if (false) {
        Looper.myLooper().setMessageLogging(new LogPrinter(Log.DEBUG, "ActivityThread"));
    }
    // End of event ActivityThreadMain.
    Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
    Looper.loop();
    throw new RuntimeException("Main thread loop unexpectedly exited");
}
Also used : AndroidRuntimeException(android.util.AndroidRuntimeException) File(java.io.File) LogPrinter(android.util.LogPrinter)

Example 20 with LogPrinter

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

the class IntentResolver method addFilter.

public void addFilter(F f) {
    if (localLOGV) {
        Slog.v(TAG, "Adding filter: " + f);
        f.dump(new LogPrinter(Log.VERBOSE, TAG, Log.LOG_ID_SYSTEM), "      ");
        Slog.v(TAG, "    Building Lookup Maps:");
    }
    mFilters.add(f);
    int numS = register_intent_filter(f, f.schemesIterator(), mSchemeToFilter, "      Scheme: ");
    int numT = register_mime_types(f, "      Type: ");
    if (numS == 0 && numT == 0) {
        register_intent_filter(f, f.actionsIterator(), mActionToFilter, "      Action: ");
    }
    if (numT != 0) {
        register_intent_filter(f, f.actionsIterator(), mTypedActionToFilter, "      TypedAction: ");
    }
}
Also used : 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