Search in sources :

Example 16 with ArraySet

use of android.util.ArraySet in project platform_frameworks_base by android.

the class NetworkSecurityConfigTests method testEmptyPerNetworkSecurityConfig.

public void testEmptyPerNetworkSecurityConfig() throws Exception {
    ArraySet<Pair<Domain, NetworkSecurityConfig>> domainMap = new ArraySet<Pair<Domain, NetworkSecurityConfig>>();
    domainMap.add(new Pair<Domain, NetworkSecurityConfig>(new Domain("android.com", true), getEmptyConfig()));
    NetworkSecurityConfig defaultConfig = getSystemStoreConfig();
    SSLContext context = TestUtils.getSSLContext(new TestConfigSource(domainMap, defaultConfig));
    TestUtils.assertConnectionFails(context, "android.com", 443);
    TestUtils.assertConnectionSucceeds(context, "google.com", 443);
}
Also used : ArraySet(android.util.ArraySet) SSLContext(javax.net.ssl.SSLContext) Pair(android.util.Pair)

Example 17 with ArraySet

use of android.util.ArraySet in project platform_frameworks_base by android.

the class HdmiControlService method initPortInfo.

// Initialize HDMI port information. Combine the information from CEC and MHL HAL and
// keep them in one place.
@ServiceThreadOnly
private void initPortInfo() {
    assertRunOnServiceThread();
    HdmiPortInfo[] cecPortInfo = null;
    // each port. Return empty array if CEC HAL didn't provide the info.
    if (mCecController != null) {
        cecPortInfo = mCecController.getPortInfos();
    }
    if (cecPortInfo == null) {
        return;
    }
    SparseArray<HdmiPortInfo> portInfoMap = new SparseArray<>();
    SparseIntArray portIdMap = new SparseIntArray();
    SparseArray<HdmiDeviceInfo> portDeviceMap = new SparseArray<>();
    for (HdmiPortInfo info : cecPortInfo) {
        portIdMap.put(info.getAddress(), info.getId());
        portInfoMap.put(info.getId(), info);
        portDeviceMap.put(info.getId(), new HdmiDeviceInfo(info.getAddress(), info.getId()));
    }
    mPortIdMap = new UnmodifiableSparseIntArray(portIdMap);
    mPortInfoMap = new UnmodifiableSparseArray<>(portInfoMap);
    mPortDeviceMap = new UnmodifiableSparseArray<>(portDeviceMap);
    HdmiPortInfo[] mhlPortInfo = mMhlController.getPortInfos();
    ArraySet<Integer> mhlSupportedPorts = new ArraySet<Integer>(mhlPortInfo.length);
    for (HdmiPortInfo info : mhlPortInfo) {
        if (info.isMhlSupported()) {
            mhlSupportedPorts.add(info.getId());
        }
    }
    // cec port info if we do not have have port that supports MHL.
    if (mhlSupportedPorts.isEmpty()) {
        mPortInfo = Collections.unmodifiableList(Arrays.asList(cecPortInfo));
        return;
    }
    ArrayList<HdmiPortInfo> result = new ArrayList<>(cecPortInfo.length);
    for (HdmiPortInfo info : cecPortInfo) {
        if (mhlSupportedPorts.contains(info.getId())) {
            result.add(new HdmiPortInfo(info.getId(), info.getType(), info.getAddress(), info.isCecSupported(), true, info.isArcSupported()));
        } else {
            result.add(info);
        }
    }
    mPortInfo = Collections.unmodifiableList(result);
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ArraySet(android.util.ArraySet) HdmiPortInfo(android.hardware.hdmi.HdmiPortInfo) ArrayList(java.util.ArrayList) SparseArray(android.util.SparseArray) SparseIntArray(android.util.SparseIntArray) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 18 with ArraySet

use of android.util.ArraySet in project platform_frameworks_base by android.

the class PackageManagerService method compareSignaturesCompat.

/**
     * Used for backward compatibility to make sure any packages with
     * certificate chains get upgraded to the new style. {@code existingSigs}
     * will be in the old format (since they were stored on disk from before the
     * system upgrade) and {@code scannedSigs} will be in the newer format.
     */
private int compareSignaturesCompat(PackageSignatures existingSigs, PackageParser.Package scannedPkg) {
    if (!isCompatSignatureUpdateNeeded(scannedPkg)) {
        return PackageManager.SIGNATURE_NO_MATCH;
    }
    ArraySet<Signature> existingSet = new ArraySet<Signature>();
    for (Signature sig : existingSigs.mSignatures) {
        existingSet.add(sig);
    }
    ArraySet<Signature> scannedCompatSet = new ArraySet<Signature>();
    for (Signature sig : scannedPkg.mSignatures) {
        try {
            Signature[] chainSignatures = sig.getChainSignatures();
            for (Signature chainSig : chainSignatures) {
                scannedCompatSet.add(chainSig);
            }
        } catch (CertificateEncodingException e) {
            scannedCompatSet.add(sig);
        }
    }
    /*
         * Make sure the expanded scanned set contains all signatures in the
         * existing one.
         */
    if (scannedCompatSet.equals(existingSet)) {
        // Migrate the old signatures to the new scheme.
        existingSigs.assignSignatures(scannedPkg.mSignatures);
        // The new KeySets will be re-added later in the scanning process.
        synchronized (mPackages) {
            mSettings.mKeySetManagerService.removeAppKeySetDataLPw(scannedPkg.packageName);
        }
        return PackageManager.SIGNATURE_MATCH;
    }
    return PackageManager.SIGNATURE_NO_MATCH;
}
Also used : ArraySet(android.util.ArraySet) Signature(android.content.pm.Signature) CertificateEncodingException(java.security.cert.CertificateEncodingException)

Example 19 with ArraySet

use of android.util.ArraySet in project platform_frameworks_base by android.

the class PackageManagerService method dumpDomainString.

private String dumpDomainString(String packageName) {
    List<IntentFilterVerificationInfo> iviList = getIntentFilterVerifications(packageName).getList();
    List<IntentFilter> filters = getAllIntentFilters(packageName).getList();
    ArraySet<String> result = new ArraySet<>();
    if (iviList.size() > 0) {
        for (IntentFilterVerificationInfo ivi : iviList) {
            for (String host : ivi.getDomains()) {
                result.add(host);
            }
        }
    }
    if (filters != null && filters.size() > 0) {
        for (IntentFilter filter : filters) {
            if (filter.hasCategory(Intent.CATEGORY_BROWSABLE) && (filter.hasDataScheme(IntentFilter.SCHEME_HTTP) || filter.hasDataScheme(IntentFilter.SCHEME_HTTPS))) {
                result.addAll(filter.getHostsList());
            }
        }
    }
    StringBuilder sb = new StringBuilder(result.size() * 16);
    for (String domain : result) {
        if (sb.length() > 0)
            sb.append(" ");
        sb.append(domain);
    }
    return sb.toString();
}
Also used : IntentFilter(android.content.IntentFilter) ArraySet(android.util.ArraySet) IntentFilterVerificationInfo(android.content.pm.IntentFilterVerificationInfo)

Example 20 with ArraySet

use of android.util.ArraySet in project platform_frameworks_base by android.

the class PackageManagerService method enableSystemUserPackages.

private void enableSystemUserPackages() {
    if (!UserManager.isSplitSystemUser()) {
        return;
    }
    // For system user, enable apps based on the following conditions:
    // - app is whitelisted or belong to one of these groups:
    //   -- system app which has no launcher icons
    //   -- system app which has INTERACT_ACROSS_USERS permission
    //   -- system IME app
    // - app is not in the blacklist
    AppsQueryHelper queryHelper = new AppsQueryHelper(this);
    Set<String> enableApps = new ArraySet<>();
    enableApps.addAll(queryHelper.queryApps(AppsQueryHelper.GET_NON_LAUNCHABLE_APPS | AppsQueryHelper.GET_APPS_WITH_INTERACT_ACROSS_USERS_PERM | AppsQueryHelper.GET_IMES, /* systemAppsOnly */
    true, UserHandle.SYSTEM));
    ArraySet<String> wlApps = SystemConfig.getInstance().getSystemUserWhitelistedApps();
    enableApps.addAll(wlApps);
    enableApps.addAll(queryHelper.queryApps(AppsQueryHelper.GET_REQUIRED_FOR_SYSTEM_USER, /* systemAppsOnly */
    false, UserHandle.SYSTEM));
    ArraySet<String> blApps = SystemConfig.getInstance().getSystemUserBlacklistedApps();
    enableApps.removeAll(blApps);
    Log.i(TAG, "Applications installed for system user: " + enableApps);
    List<String> allAps = queryHelper.queryApps(0, /* systemAppsOnly */
    false, UserHandle.SYSTEM);
    final int allAppsSize = allAps.size();
    synchronized (mPackages) {
        for (int i = 0; i < allAppsSize; i++) {
            String pName = allAps.get(i);
            PackageSetting pkgSetting = mSettings.mPackages.get(pName);
            // Should not happen, but we shouldn't be failing if it does
            if (pkgSetting == null) {
                continue;
            }
            boolean install = enableApps.contains(pName);
            if (pkgSetting.getInstalled(UserHandle.USER_SYSTEM) != install) {
                Log.i(TAG, (install ? "Installing " : "Uninstalling ") + pName + " for system user");
                pkgSetting.setInstalled(install, UserHandle.USER_SYSTEM);
            }
        }
    }
}
Also used : ArraySet(android.util.ArraySet) AppsQueryHelper(android.content.pm.AppsQueryHelper)

Aggregations

ArraySet (android.util.ArraySet)431 PublicKey (java.security.PublicKey)94 ComponentName (android.content.ComponentName)73 ArrayMap (android.util.ArrayMap)73 ArrayList (java.util.ArrayList)66 Pair (android.util.Pair)47 File (java.io.File)33 SSLContext (javax.net.ssl.SSLContext)32 Intent (android.content.Intent)30 RemoteException (android.os.RemoteException)29 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)28 ResolveInfo (android.content.pm.ResolveInfo)25 Point (android.graphics.Point)24 IOException (java.io.IOException)23 UserInfo (android.content.pm.UserInfo)21 X509Certificate (java.security.cert.X509Certificate)20 ContentResolver (android.content.ContentResolver)16 PackageManager (android.content.pm.PackageManager)15 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)15 SparseArray (android.util.SparseArray)15