Search in sources :

Example 21 with IntentFilterVerificationInfo

use of android.content.pm.IntentFilterVerificationInfo in project android_frameworks_base by crdroidandroid.

the class Settings method getIntentFilterVerificationsLPr.

/**
     * Used for Settings App and PackageManagerService dump. Should be read only.
     */
List<IntentFilterVerificationInfo> getIntentFilterVerificationsLPr(String packageName) {
    if (packageName == null) {
        return Collections.<IntentFilterVerificationInfo>emptyList();
    }
    ArrayList<IntentFilterVerificationInfo> result = new ArrayList<>();
    for (PackageSetting ps : mPackages.values()) {
        IntentFilterVerificationInfo ivi = ps.getIntentFilterVerificationInfo();
        if (ivi == null || TextUtils.isEmpty(ivi.getPackageName()) || !ivi.getPackageName().equalsIgnoreCase(packageName)) {
            continue;
        }
        result.add(ivi);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) IntentFilterVerificationInfo(android.content.pm.IntentFilterVerificationInfo)

Example 22 with IntentFilterVerificationInfo

use of android.content.pm.IntentFilterVerificationInfo in project android_frameworks_base by crdroidandroid.

the class Settings method createIntentFilterVerificationIfNeededLPw.

/* package protected */
IntentFilterVerificationInfo createIntentFilterVerificationIfNeededLPw(String packageName, ArrayList<String> domains) {
    PackageSetting ps = mPackages.get(packageName);
    if (ps == null) {
        if (DEBUG_DOMAIN_VERIFICATION) {
            Slog.w(PackageManagerService.TAG, "No package known: " + packageName);
        }
        return null;
    }
    IntentFilterVerificationInfo ivi = ps.getIntentFilterVerificationInfo();
    if (ivi == null) {
        ivi = new IntentFilterVerificationInfo(packageName, domains);
        ps.setIntentFilterVerificationInfo(ivi);
        if (DEBUG_DOMAIN_VERIFICATION) {
            Slog.d(PackageManagerService.TAG, "Creating new IntentFilterVerificationInfo for pkg: " + packageName);
        }
    } else {
        ivi.setDomains(domains);
        if (DEBUG_DOMAIN_VERIFICATION) {
            Slog.d(PackageManagerService.TAG, "Setting domains to existing IntentFilterVerificationInfo for pkg: " + packageName + " and with domains: " + ivi.getDomainsString());
        }
    }
    return ivi;
}
Also used : IntentFilterVerificationInfo(android.content.pm.IntentFilterVerificationInfo)

Example 23 with IntentFilterVerificationInfo

use of android.content.pm.IntentFilterVerificationInfo in project android_frameworks_base by crdroidandroid.

the class Settings method addPackageSettingLPw.

// Utility method that adds a PackageSetting to mPackages and
// completes updating the shared user attributes and any restored
// app link verification state
private void addPackageSettingLPw(PackageSetting p, String name, SharedUserSetting sharedUser) {
    mPackages.put(name, p);
    if (sharedUser != null) {
        if (p.sharedUser != null && p.sharedUser != sharedUser) {
            PackageManagerService.reportSettingsProblem(Log.ERROR, "Package " + p.name + " was user " + p.sharedUser + " but is now " + sharedUser + "; I am not changing its files so it will probably fail!");
            p.sharedUser.removePackage(p);
        } else if (p.appId != sharedUser.userId) {
            PackageManagerService.reportSettingsProblem(Log.ERROR, "Package " + p.name + " was user id " + p.appId + " but is now user " + sharedUser + " with id " + sharedUser.userId + "; I am not changing its files so it will probably fail!");
        }
        sharedUser.addPackage(p);
        p.sharedUser = sharedUser;
        p.appId = sharedUser.userId;
    }
    // If the we know about this user id, we have to update it as it
    // has to point to the same PackageSetting instance as the package.
    Object userIdPs = getUserIdLPr(p.appId);
    if (sharedUser == null) {
        if (userIdPs != null && userIdPs != p) {
            replaceUserIdLPw(p.appId, p);
        }
    } else {
        if (userIdPs != null && userIdPs != sharedUser) {
            replaceUserIdLPw(p.appId, sharedUser);
        }
    }
    IntentFilterVerificationInfo ivi = mRestoredIntentFilterVerifications.get(name);
    if (ivi != null) {
        if (DEBUG_DOMAIN_VERIFICATION) {
            Slog.i(TAG, "Applying restored IVI for " + name + " : " + ivi.getStatusString());
        }
        mRestoredIntentFilterVerifications.remove(name);
        p.setIntentFilterVerificationInfo(ivi);
    }
}
Also used : IntentFilterVerificationInfo(android.content.pm.IntentFilterVerificationInfo)

Example 24 with IntentFilterVerificationInfo

use of android.content.pm.IntentFilterVerificationInfo in project platform_frameworks_base by android.

the class PackageManagerService method primeDomainVerificationsLPw.

private void primeDomainVerificationsLPw(int userId) {
    if (DEBUG_DOMAIN_VERIFICATION) {
        Slog.d(TAG, "Priming domain verifications in user " + userId);
    }
    SystemConfig systemConfig = SystemConfig.getInstance();
    ArraySet<String> packages = systemConfig.getLinkedApps();
    ArraySet<String> domains = new ArraySet<String>();
    for (String packageName : packages) {
        PackageParser.Package pkg = mPackages.get(packageName);
        if (pkg != null) {
            if (!pkg.isSystemApp()) {
                Slog.w(TAG, "Non-system app '" + packageName + "' in sysconfig <app-link>");
                continue;
            }
            domains.clear();
            for (PackageParser.Activity a : pkg.activities) {
                for (ActivityIntentInfo filter : a.intents) {
                    if (hasValidDomains(filter)) {
                        domains.addAll(filter.getHostsList());
                    }
                }
            }
            if (domains.size() > 0) {
                if (DEBUG_DOMAIN_VERIFICATION) {
                    Slog.v(TAG, "      + " + packageName);
                }
                // 'Undefined' in the global IntentFilterVerificationInfo, i.e. the usual
                // state w.r.t. the formal app-linkage "no verification attempted" state;
                // and then 'always' in the per-user state actually used for intent resolution.
                final IntentFilterVerificationInfo ivi;
                ivi = mSettings.createIntentFilterVerificationIfNeededLPw(packageName, new ArrayList<String>(domains));
                ivi.setStatus(INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED);
                mSettings.updateIntentFilterVerificationStatusLPw(packageName, INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS, userId);
            } else {
                Slog.w(TAG, "Sysconfig <app-link> package '" + packageName + "' does not handle web links");
            }
        } else {
            Slog.w(TAG, "Unknown package " + packageName + " in sysconfig <app-link>");
        }
    }
    scheduleWritePackageRestrictionsLocked(userId);
    scheduleWriteSettingsLocked();
}
Also used : SystemConfig(com.android.server.SystemConfig) ArraySet(android.util.ArraySet) PackageParser(android.content.pm.PackageParser) ArrayList(java.util.ArrayList) ActivityIntentInfo(android.content.pm.PackageParser.ActivityIntentInfo) IntentFilterVerificationInfo(android.content.pm.IntentFilterVerificationInfo)

Example 25 with IntentFilterVerificationInfo

use of android.content.pm.IntentFilterVerificationInfo in project platform_frameworks_base by android.

the class Settings method writeAllDomainVerificationsLPr.

// Specifically for backup/restore
void writeAllDomainVerificationsLPr(XmlSerializer serializer, int userId) throws IllegalArgumentException, IllegalStateException, IOException {
    serializer.startTag(null, TAG_ALL_INTENT_FILTER_VERIFICATION);
    final int N = mPackages.size();
    for (int i = 0; i < N; i++) {
        PackageSetting ps = mPackages.valueAt(i);
        IntentFilterVerificationInfo ivi = ps.getIntentFilterVerificationInfo();
        if (ivi != null) {
            writeDomainVerificationsLPr(serializer, ivi);
        }
    }
    serializer.endTag(null, TAG_ALL_INTENT_FILTER_VERIFICATION);
}
Also used : IntentFilterVerificationInfo(android.content.pm.IntentFilterVerificationInfo)

Aggregations

IntentFilterVerificationInfo (android.content.pm.IntentFilterVerificationInfo)43 PackageParser (android.content.pm.PackageParser)6 ArrayMap (android.util.ArrayMap)6 FastXmlSerializer (com.android.internal.util.FastXmlSerializer)6 BufferedOutputStream (java.io.BufferedOutputStream)6 FileOutputStream (java.io.FileOutputStream)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 XmlSerializer (org.xmlpull.v1.XmlSerializer)6 ArraySet (android.util.ArraySet)5 PackageCleanItem (android.content.pm.PackageCleanItem)4 ActivityIntentInfo (android.content.pm.PackageParser.ActivityIntentInfo)4 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)4 IntentFilter (android.content.IntentFilter)3 ComponentName (android.content.ComponentName)2 FeatureInfo (android.content.pm.FeatureInfo)2 IndentingPrintWriter (com.android.internal.util.IndentingPrintWriter)2 SystemConfig (com.android.server.SystemConfig)2 BufferedReader (java.io.BufferedReader)2