Search in sources :

Example 21 with NonNull

use of android.annotation.NonNull in project platform_frameworks_base by android.

the class Layout method createTitleBar.

@NonNull
private TitleBar createTitleBar(BridgeContext context, String title, int simulatedPlatformVersion) {
    TitleBar titleBar = new TitleBar(context, title, simulatedPlatformVersion);
    LayoutParams params = createLayoutParams(MATCH_PARENT, mBuilder.mTitleBarSize);
    if (mBuilder.hasStatusBar() && mBuilder.solidBars()) {
        params.addRule(BELOW, getId(ID_STATUS_BAR));
    }
    if (mBuilder.isNavBarVertical() && mBuilder.solidBars()) {
        params.addRule(START_OF, getId(ID_NAV_BAR));
    }
    titleBar.setLayoutParams(params);
    titleBar.setId(getId(ID_TITLE_BAR));
    return titleBar;
}
Also used : TitleBar(com.android.layoutlib.bridge.bars.TitleBar) NonNull(android.annotation.NonNull)

Example 22 with NonNull

use of android.annotation.NonNull in project platform_frameworks_base by android.

the class PackageManagerService method queryIntentContentProvidersInternal.

@NonNull
private List<ResolveInfo> queryIntentContentProvidersInternal(Intent intent, String resolvedType, int flags, int userId) {
    if (!sUserManager.exists(userId))
        return Collections.emptyList();
    flags = updateFlagsForResolve(flags, userId, intent);
    ComponentName comp = intent.getComponent();
    if (comp == null) {
        if (intent.getSelector() != null) {
            intent = intent.getSelector();
            comp = intent.getComponent();
        }
    }
    if (comp != null) {
        final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
        final ProviderInfo pi = getProviderInfo(comp, flags, userId);
        if (pi != null) {
            final ResolveInfo ri = new ResolveInfo();
            ri.providerInfo = pi;
            list.add(ri);
        }
        return list;
    }
    // reader
    synchronized (mPackages) {
        String pkgName = intent.getPackage();
        if (pkgName == null) {
            return mProviders.queryIntent(intent, resolvedType, flags, userId);
        }
        final PackageParser.Package pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mProviders.queryIntentForPackage(intent, resolvedType, flags, pkg.providers, userId);
        }
        return Collections.emptyList();
    }
}
Also used : EphemeralResolveInfo(android.content.pm.EphemeralResolveInfo) ResolveInfo(android.content.pm.ResolveInfo) ProviderInfo(android.content.pm.ProviderInfo) PackageParser(android.content.pm.PackageParser) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName) NonNull(android.annotation.NonNull)

Example 23 with NonNull

use of android.annotation.NonNull in project platform_frameworks_base by android.

the class PackageManagerService method queryIntentActivityOptionsInternal.

@NonNull
private List<ResolveInfo> queryIntentActivityOptionsInternal(ComponentName caller, Intent[] specifics, String[] specificTypes, Intent intent, String resolvedType, int flags, int userId) {
    if (!sUserManager.exists(userId))
        return Collections.emptyList();
    flags = updateFlagsForResolve(flags, userId, intent);
    enforceCrossUserPermission(Binder.getCallingUid(), userId, false, /* requireFullPermission */
    false, /* checkShell */
    "query intent activity options");
    final String resultsAction = intent.getAction();
    final List<ResolveInfo> results = queryIntentActivitiesInternal(intent, resolvedType, flags | PackageManager.GET_RESOLVED_FILTER, userId);
    if (DEBUG_INTENT_MATCHING) {
        Log.v(TAG, "Query " + intent + ": " + results);
    }
    int specificsPos = 0;
    int N;
    // duplicate items in the generic resolve list.
    if (specifics != null) {
        for (int i = 0; i < specifics.length; i++) {
            final Intent sintent = specifics[i];
            if (sintent == null) {
                continue;
            }
            if (DEBUG_INTENT_MATCHING) {
                Log.v(TAG, "Specific #" + i + ": " + sintent);
            }
            String action = sintent.getAction();
            if (resultsAction != null && resultsAction.equals(action)) {
                // If this action was explicitly requested, then don't
                // remove things that have it.
                action = null;
            }
            ResolveInfo ri = null;
            ActivityInfo ai = null;
            ComponentName comp = sintent.getComponent();
            if (comp == null) {
                ri = resolveIntent(sintent, specificTypes != null ? specificTypes[i] : null, flags, userId);
                if (ri == null) {
                    continue;
                }
                if (ri == mResolveInfo) {
                // ACK!  Must do something better with this.
                }
                ai = ri.activityInfo;
                comp = new ComponentName(ai.applicationInfo.packageName, ai.name);
            } else {
                ai = getActivityInfo(comp, flags, userId);
                if (ai == null) {
                    continue;
                }
            }
            // of this specific one, and remove them from the results.
            if (DEBUG_INTENT_MATCHING)
                Log.v(TAG, "Specific #" + i + ": " + ai);
            N = results.size();
            int j;
            for (j = specificsPos; j < N; j++) {
                ResolveInfo sri = results.get(j);
                if ((sri.activityInfo.name.equals(comp.getClassName()) && sri.activityInfo.applicationInfo.packageName.equals(comp.getPackageName())) || (action != null && sri.filter.matchAction(action))) {
                    results.remove(j);
                    if (DEBUG_INTENT_MATCHING)
                        Log.v(TAG, "Removing duplicate item from " + j + " due to specific " + specificsPos);
                    if (ri == null) {
                        ri = sri;
                    }
                    j--;
                    N--;
                }
            }
            // Add this specific item to its proper place.
            if (ri == null) {
                ri = new ResolveInfo();
                ri.activityInfo = ai;
            }
            results.add(specificsPos, ri);
            ri.specificIndex = i;
            specificsPos++;
        }
    }
    // Now we go through the remaining generic results and remove any
    // duplicate actions that are found here.
    N = results.size();
    for (int i = specificsPos; i < N - 1; i++) {
        final ResolveInfo rii = results.get(i);
        if (rii.filter == null) {
            continue;
        }
        // Iterate over all of the actions of this result's intent
        // filter...  typically this should be just one.
        final Iterator<String> it = rii.filter.actionsIterator();
        if (it == null) {
            continue;
        }
        while (it.hasNext()) {
            final String action = it.next();
            if (resultsAction != null && resultsAction.equals(action)) {
                // remove things that have it.
                continue;
            }
            for (int j = i + 1; j < N; j++) {
                final ResolveInfo rij = results.get(j);
                if (rij.filter != null && rij.filter.hasAction(action)) {
                    results.remove(j);
                    if (DEBUG_INTENT_MATCHING)
                        Log.v(TAG, "Removing duplicate item from " + j + " due to action " + action + " at " + i);
                    j--;
                    N--;
                }
            }
        }
        // so we don't have to marshall/unmarshall it.
        if ((flags & PackageManager.GET_RESOLVED_FILTER) == 0) {
            rii.filter = null;
        }
    }
    // Filter out the caller activity if so requested.
    if (caller != null) {
        N = results.size();
        for (int i = 0; i < N; i++) {
            ActivityInfo ainfo = results.get(i).activityInfo;
            if (caller.getPackageName().equals(ainfo.applicationInfo.packageName) && caller.getClassName().equals(ainfo.name)) {
                results.remove(i);
                break;
            }
        }
    }
    // marshall/unmarshall it.
    if ((flags & PackageManager.GET_RESOLVED_FILTER) == 0) {
        N = results.size();
        for (int i = 0; i < N; i++) {
            results.get(i).filter = null;
        }
    }
    if (DEBUG_INTENT_MATCHING)
        Log.v(TAG, "Result: " + results);
    return results;
}
Also used : EphemeralResolveInfo(android.content.pm.EphemeralResolveInfo) ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) Intent(android.content.Intent) ComponentName(android.content.ComponentName) NonNull(android.annotation.NonNull)

Example 24 with NonNull

use of android.annotation.NonNull in project platform_frameworks_base by android.

the class PackageManagerService method queryIntentActivitiesInternal.

@NonNull
private List<ResolveInfo> queryIntentActivitiesInternal(Intent intent, String resolvedType, int flags, int userId) {
    if (!sUserManager.exists(userId))
        return Collections.emptyList();
    flags = updateFlagsForResolve(flags, userId, intent);
    enforceCrossUserPermission(Binder.getCallingUid(), userId, false, /* requireFullPermission */
    false, /* checkShell */
    "query intent activities");
    ComponentName comp = intent.getComponent();
    if (comp == null) {
        if (intent.getSelector() != null) {
            intent = intent.getSelector();
            comp = intent.getComponent();
        }
    }
    if (comp != null) {
        final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
        final ActivityInfo ai = getActivityInfo(comp, flags, userId);
        if (ai != null) {
            final ResolveInfo ri = new ResolveInfo();
            ri.activityInfo = ai;
            list.add(ri);
        }
        return list;
    }
    // reader
    boolean sortResult = false;
    boolean addEphemeral = false;
    boolean matchEphemeralPackage = false;
    List<ResolveInfo> result;
    final String pkgName = intent.getPackage();
    synchronized (mPackages) {
        if (pkgName == null) {
            List<CrossProfileIntentFilter> matchingFilters = getMatchingCrossProfileIntentFilters(intent, resolvedType, userId);
            // Check for results that need to skip the current profile.
            ResolveInfo xpResolveInfo = querySkipCurrentProfileIntents(matchingFilters, intent, resolvedType, flags, userId);
            if (xpResolveInfo != null) {
                List<ResolveInfo> xpResult = new ArrayList<ResolveInfo>(1);
                xpResult.add(xpResolveInfo);
                return filterIfNotSystemUser(xpResult, userId);
            }
            // Check for results in the current profile.
            result = filterIfNotSystemUser(mActivities.queryIntent(intent, resolvedType, flags, userId), userId);
            addEphemeral = isEphemeralAllowed(intent, result, userId, false);
            // Check for cross profile results.
            boolean hasNonNegativePriorityResult = hasNonNegativePriority(result);
            xpResolveInfo = queryCrossProfileIntents(matchingFilters, intent, resolvedType, flags, userId, hasNonNegativePriorityResult);
            if (xpResolveInfo != null && isUserEnabled(xpResolveInfo.targetUserId)) {
                boolean isVisibleToUser = filterIfNotSystemUser(Collections.singletonList(xpResolveInfo), userId).size() > 0;
                if (isVisibleToUser) {
                    result.add(xpResolveInfo);
                    sortResult = true;
                }
            }
            if (hasWebURI(intent)) {
                CrossProfileDomainInfo xpDomainInfo = null;
                final UserInfo parent = getProfileParent(userId);
                if (parent != null) {
                    xpDomainInfo = getCrossProfileDomainPreferredLpr(intent, resolvedType, flags, userId, parent.id);
                }
                if (xpDomainInfo != null) {
                    if (xpResolveInfo != null) {
                        // If we didn't remove it, the cross-profile ResolveInfo would be twice
                        // in the result.
                        result.remove(xpResolveInfo);
                    }
                    if (result.size() == 0 && !addEphemeral) {
                        result.add(xpDomainInfo.resolveInfo);
                        return result;
                    }
                }
                if (result.size() > 1 || addEphemeral) {
                    result = filterCandidatesWithDomainPreferredActivitiesLPr(intent, flags, result, xpDomainInfo, userId);
                    sortResult = true;
                }
            }
        } else {
            final PackageParser.Package pkg = mPackages.get(pkgName);
            if (pkg != null) {
                result = filterIfNotSystemUser(mActivities.queryIntentForPackage(intent, resolvedType, flags, pkg.activities, userId), userId);
            } else {
                // the caller wants to resolve for a particular package; however, there
                // were no installed results, so, try to find an ephemeral result
                addEphemeral = isEphemeralAllowed(intent, null, /*result*/
                userId, true);
                matchEphemeralPackage = true;
                result = new ArrayList<ResolveInfo>();
            }
        }
    }
    if (addEphemeral) {
        Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "resolveEphemeral");
        final EphemeralResolveInfo ai = getEphemeralResolveInfo(mContext, mEphemeralResolverConnection, intent, resolvedType, userId, matchEphemeralPackage ? pkgName : null);
        if (ai != null) {
            if (DEBUG_EPHEMERAL) {
                Slog.v(TAG, "Adding ephemeral installer to the ResolveInfo list");
            }
            final ResolveInfo ephemeralInstaller = new ResolveInfo(mEphemeralInstallerInfo);
            ephemeralInstaller.ephemeralResolveInfo = ai;
            // make sure this resolver is the default
            ephemeralInstaller.isDefault = true;
            ephemeralInstaller.match = IntentFilter.MATCH_CATEGORY_SCHEME_SPECIFIC_PART | IntentFilter.MATCH_ADJUSTMENT_NORMAL;
            // add a non-generic filter
            ephemeralInstaller.filter = new IntentFilter(intent.getAction());
            ephemeralInstaller.filter.addDataPath(intent.getData().getPath(), PatternMatcher.PATTERN_LITERAL);
            result.add(ephemeralInstaller);
        }
        Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
    }
    if (sortResult) {
        Collections.sort(result, mResolvePrioritySorter);
    }
    return result;
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) IntentFilter(android.content.IntentFilter) ArrayList(java.util.ArrayList) UserInfo(android.content.pm.UserInfo) EphemeralResolveInfo(android.content.pm.EphemeralResolveInfo) ResolveInfo(android.content.pm.ResolveInfo) PackageParser(android.content.pm.PackageParser) ComponentName(android.content.ComponentName) EphemeralResolveInfo(android.content.pm.EphemeralResolveInfo) NonNull(android.annotation.NonNull)

Example 25 with NonNull

use of android.annotation.NonNull in project platform_frameworks_base by android.

the class PackageManagerService method getPersistentApplicationsInternal.

@NonNull
private List<ApplicationInfo> getPersistentApplicationsInternal(int flags) {
    final ArrayList<ApplicationInfo> finalList = new ArrayList<ApplicationInfo>();
    // reader
    synchronized (mPackages) {
        final Iterator<PackageParser.Package> i = mPackages.values().iterator();
        final int userId = UserHandle.getCallingUserId();
        while (i.hasNext()) {
            final PackageParser.Package p = i.next();
            if (p.applicationInfo == null)
                continue;
            final boolean matchesUnaware = ((flags & MATCH_DIRECT_BOOT_UNAWARE) != 0) && !p.applicationInfo.isDirectBootAware();
            final boolean matchesAware = ((flags & MATCH_DIRECT_BOOT_AWARE) != 0) && p.applicationInfo.isDirectBootAware();
            if ((p.applicationInfo.flags & ApplicationInfo.FLAG_PERSISTENT) != 0 && (!mSafeMode || isSystemApp(p)) && (matchesUnaware || matchesAware)) {
                PackageSetting ps = mSettings.mPackages.get(p.packageName);
                if (ps != null) {
                    ApplicationInfo ai = PackageParser.generateApplicationInfo(p, flags, ps.readUserState(userId), userId);
                    if (ai != null) {
                        finalList.add(ai);
                    }
                }
            }
        }
    }
    return finalList;
}
Also used : PackageParser(android.content.pm.PackageParser) ArrayList(java.util.ArrayList) EphemeralApplicationInfo(android.content.pm.EphemeralApplicationInfo) ApplicationInfo(android.content.pm.ApplicationInfo) NonNull(android.annotation.NonNull)

Aggregations

NonNull (android.annotation.NonNull)322 ArrayList (java.util.ArrayList)46 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)45 IOException (java.io.IOException)35 ComponentName (android.content.ComponentName)25 File (java.io.File)22 XmlPullParser (org.xmlpull.v1.XmlPullParser)20 Intent (android.content.Intent)18 EphemeralResolveInfo (android.content.pm.EphemeralResolveInfo)16 ResolveInfo (android.content.pm.ResolveInfo)16 Bundle (android.os.Bundle)15 RemoteException (android.os.RemoteException)15 FileNotFoundException (java.io.FileNotFoundException)15 Paint (android.graphics.Paint)14 PackageParser (android.content.pm.PackageParser)12 ContentResolver (android.content.ContentResolver)10 UserInfo (android.content.pm.UserInfo)10 StorageManager (android.os.storage.StorageManager)10 VolumeInfo (android.os.storage.VolumeInfo)10 KeyCharacteristics (android.security.keymaster.KeyCharacteristics)10