Search in sources :

Example 66 with ProviderInfo

use of android.content.pm.ProviderInfo in project VirtualApp by asLody.

the class VClientImpl method installContentProviders.

private void installContentProviders(Context app, List<ProviderInfo> providers) {
    long origId = Binder.clearCallingIdentity();
    Object mainThread = VirtualCore.mainThread();
    try {
        for (ProviderInfo cpi : providers) {
            try {
                ActivityThread.installProvider(mainThread, app, cpi, null);
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }
    } finally {
        Binder.restoreCallingIdentity(origId);
    }
}
Also used : ProviderInfo(android.content.pm.ProviderInfo)

Example 67 with ProviderInfo

use of android.content.pm.ProviderInfo in project VirtualApp by asLody.

the class VClientImpl method fixInstalledProviders.

private void fixInstalledProviders() {
    clearSettingProvider();
    Map clientMap = ActivityThread.mProviderMap.get(VirtualCore.mainThread());
    for (Object clientRecord : clientMap.values()) {
        if (BuildCompat.isOreo()) {
            IInterface provider = ActivityThread.ProviderClientRecordJB.mProvider.get(clientRecord);
            Object holder = ActivityThread.ProviderClientRecordJB.mHolder.get(clientRecord);
            if (holder == null) {
                continue;
            }
            ProviderInfo info = ContentProviderHolderOreo.info.get(holder);
            if (!info.authority.startsWith(VASettings.STUB_CP_AUTHORITY)) {
                provider = ProviderHook.createProxy(true, info.authority, provider);
                ActivityThread.ProviderClientRecordJB.mProvider.set(clientRecord, provider);
                ContentProviderHolderOreo.provider.set(holder, provider);
            }
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            IInterface provider = ActivityThread.ProviderClientRecordJB.mProvider.get(clientRecord);
            Object holder = ActivityThread.ProviderClientRecordJB.mHolder.get(clientRecord);
            if (holder == null) {
                continue;
            }
            ProviderInfo info = IActivityManager.ContentProviderHolder.info.get(holder);
            if (!info.authority.startsWith(VASettings.STUB_CP_AUTHORITY)) {
                provider = ProviderHook.createProxy(true, info.authority, provider);
                ActivityThread.ProviderClientRecordJB.mProvider.set(clientRecord, provider);
                IActivityManager.ContentProviderHolder.provider.set(holder, provider);
            }
        } else {
            String authority = ActivityThread.ProviderClientRecord.mName.get(clientRecord);
            IInterface provider = ActivityThread.ProviderClientRecord.mProvider.get(clientRecord);
            if (provider != null && !authority.startsWith(VASettings.STUB_CP_AUTHORITY)) {
                provider = ProviderHook.createProxy(true, authority, provider);
                ActivityThread.ProviderClientRecord.mProvider.set(clientRecord, provider);
            }
        }
    }
}
Also used : ProviderInfo(android.content.pm.ProviderInfo) IInterface(android.os.IInterface) Map(java.util.Map)

Example 68 with ProviderInfo

use of android.content.pm.ProviderInfo in project VirtualApp by asLody.

the class VPackageManagerService method queryIntentContentProviders.

@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public List<ResolveInfo> queryIntentContentProviders(Intent intent, String resolvedType, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    ComponentName comp = intent.getComponent();
    if (comp == null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            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 VPackage pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mProviders.queryIntentForPackage(intent, resolvedType, flags, pkg.providers, userId);
        }
        return Collections.emptyList();
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) VPackage(com.lody.virtual.server.pm.parser.VPackage) ProviderInfo(android.content.pm.ProviderInfo) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName) TargetApi(android.annotation.TargetApi)

Example 69 with ProviderInfo

use of android.content.pm.ProviderInfo in project VirtualApp by asLody.

the class VPackageManagerService method getProviderInfo.

@Override
public ProviderInfo getProviderInfo(ComponentName component, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    synchronized (mPackages) {
        VPackage p = mPackages.get(component.getPackageName());
        if (p != null) {
            PackageSetting ps = (PackageSetting) p.mExtras;
            VPackage.ProviderComponent provider = mProvidersByComponent.get(component);
            if (provider != null) {
                ProviderInfo providerInfo = PackageParserEx.generateProviderInfo(provider, flags, ps.readUserState(userId), userId);
                ComponentFixer.fixComponentInfo(ps, providerInfo, userId);
                return providerInfo;
            }
        }
    }
    return null;
}
Also used : VPackage(com.lody.virtual.server.pm.parser.VPackage) ProviderInfo(android.content.pm.ProviderInfo)

Example 70 with ProviderInfo

use of android.content.pm.ProviderInfo in project VirtualApp by asLody.

the class PackageParserEx method generateProviderInfo.

public static ProviderInfo generateProviderInfo(VPackage.ProviderComponent p, int flags, PackageUserState state, int userId) {
    if (p == null)
        return null;
    if (!checkUseInstalledOrHidden(state, flags)) {
        return null;
    }
    // Make shallow copies so we can store the metadata safely
    ProviderInfo pi = new ProviderInfo(p.info);
    if ((flags & PackageManager.GET_META_DATA) != 0 && (p.metaData != null)) {
        pi.metaData = p.metaData;
    }
    if ((flags & PackageManager.GET_URI_PERMISSION_PATTERNS) == 0) {
        pi.uriPermissionPatterns = null;
    }
    pi.applicationInfo = generateApplicationInfo(p.owner, flags, state, userId);
    return pi;
}
Also used : ProviderInfo(android.content.pm.ProviderInfo)

Aggregations

ProviderInfo (android.content.pm.ProviderInfo)200 ComponentName (android.content.ComponentName)43 RemoteException (android.os.RemoteException)36 ArrayList (java.util.ArrayList)33 PackageManager (android.content.pm.PackageManager)27 ResolveInfo (android.content.pm.ResolveInfo)23 ApplicationInfo (android.content.pm.ApplicationInfo)22 ServiceInfo (android.content.pm.ServiceInfo)16 Point (android.graphics.Point)16 VPackage (com.lody.virtual.server.pm.parser.VPackage)15 PackageInfo (android.content.pm.PackageInfo)14 Map (java.util.Map)14 Test (org.junit.Test)14 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)13 Uri (android.net.Uri)13 File (java.io.File)13 IPackageManager (android.content.pm.IPackageManager)12 ActivityInfo (android.content.pm.ActivityInfo)10 Before (org.junit.Before)10 Intent (android.content.Intent)8