Search in sources :

Example 11 with VPackage

use of com.lody.virtual.server.pm.parser.VPackage in project VirtualApp by asLody.

the class VPackageManagerService method getReceiverInfo.

@Override
public ActivityInfo getReceiverInfo(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.ActivityComponent a = mReceivers.mActivities.get(component);
            if (a != null) {
                ActivityInfo receiverInfo = PackageParserEx.generateActivityInfo(a, flags, ps.readUserState(userId), userId);
                ComponentFixer.fixComponentInfo(ps, receiverInfo, userId);
                return receiverInfo;
            }
        }
    }
    return null;
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) VPackage(com.lody.virtual.server.pm.parser.VPackage)

Example 12 with VPackage

use of com.lody.virtual.server.pm.parser.VPackage in project VirtualApp by asLody.

the class VPackageManagerService method getInstalledPackages.

@Override
public VParceledListSlice<PackageInfo> getInstalledPackages(int flags, int userId) {
    checkUserId(userId);
    ArrayList<PackageInfo> pkgList = new ArrayList<>(mPackages.size());
    synchronized (mPackages) {
        for (VPackage p : mPackages.values()) {
            PackageSetting ps = (PackageSetting) p.mExtras;
            PackageInfo info = generatePackageInfo(p, ps, flags, userId);
            if (info != null) {
                pkgList.add(info);
            }
        }
    }
    return new VParceledListSlice<>(pkgList);
}
Also used : VPackage(com.lody.virtual.server.pm.parser.VPackage) VParceledListSlice(com.lody.virtual.remote.VParceledListSlice) PackageInfo(android.content.pm.PackageInfo) ArrayList(java.util.ArrayList)

Example 13 with VPackage

use of com.lody.virtual.server.pm.parser.VPackage in project VirtualApp by asLody.

the class VPackageManagerService method getServiceInfo.

@Override
public ServiceInfo getServiceInfo(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.ServiceComponent s = mServices.mServices.get(component);
            if (s != null) {
                ServiceInfo serviceInfo = PackageParserEx.generateServiceInfo(s, flags, ps.readUserState(userId), userId);
                ComponentFixer.fixComponentInfo(ps, serviceInfo, userId);
                return serviceInfo;
            }
        }
    }
    return null;
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) VPackage(com.lody.virtual.server.pm.parser.VPackage)

Example 14 with VPackage

use of com.lody.virtual.server.pm.parser.VPackage in project VirtualApp by asLody.

the class VPackageManagerService method deletePackageLocked.

void deletePackageLocked(String packageName) {
    VPackage pkg = mPackages.get(packageName);
    if (pkg == null) {
        return;
    }
    int N = pkg.activities.size();
    for (int i = 0; i < N; i++) {
        VPackage.ActivityComponent a = pkg.activities.get(i);
        mActivities.removeActivity(a, "activity");
    }
    N = pkg.services.size();
    for (int i = 0; i < N; i++) {
        VPackage.ServiceComponent a = pkg.services.get(i);
        mServices.removeService(a);
    }
    N = pkg.receivers.size();
    for (int i = 0; i < N; i++) {
        VPackage.ActivityComponent a = pkg.receivers.get(i);
        mReceivers.removeActivity(a, "receiver");
    }
    N = pkg.providers.size();
    for (int i = 0; i < N; i++) {
        VPackage.ProviderComponent p = pkg.providers.get(i);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            mProviders.removeProvider(p);
        }
        String[] names = p.info.authority.split(";");
        for (String name : names) {
            mProvidersByAuthority.remove(name);
        }
        mProvidersByComponent.remove(p.getComponentName());
    }
    N = pkg.permissions.size();
    for (int i = 0; i < N; i++) {
        VPackage.PermissionComponent permission = pkg.permissions.get(i);
        mPermissions.remove(permission.className);
    }
    N = pkg.permissionGroups.size();
    for (int i = 0; i < N; i++) {
        VPackage.PermissionGroupComponent group = pkg.permissionGroups.get(i);
        mPermissionGroups.remove(group.className);
    }
}
Also used : VPackage(com.lody.virtual.server.pm.parser.VPackage)

Example 15 with VPackage

use of com.lody.virtual.server.pm.parser.VPackage in project VirtualApp by asLody.

the class VPackageManagerService method queryIntentServices.

@Override
public List<ResolveInfo> queryIntentServices(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 ServiceInfo si = getServiceInfo(comp, flags, userId);
        if (si != null) {
            final ResolveInfo ri = new ResolveInfo();
            ri.serviceInfo = si;
            list.add(ri);
        }
        return list;
    }
    // reader
    synchronized (mPackages) {
        String pkgName = intent.getPackage();
        if (pkgName == null) {
            return mServices.queryIntent(intent, resolvedType, flags, userId);
        }
        final VPackage pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mServices.queryIntentForPackage(intent, resolvedType, flags, pkg.services, userId);
        }
        return null;
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) VPackage(com.lody.virtual.server.pm.parser.VPackage) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName)

Aggregations

VPackage (com.lody.virtual.server.pm.parser.VPackage)23 ArrayList (java.util.ArrayList)10 ActivityInfo (android.content.pm.ActivityInfo)5 ComponentName (android.content.ComponentName)4 ResolveInfo (android.content.pm.ResolveInfo)4 ProviderInfo (android.content.pm.ProviderInfo)3 ServiceInfo (android.content.pm.ServiceInfo)2 InstalledAppInfo (com.lody.virtual.remote.InstalledAppInfo)2 VParceledListSlice (com.lody.virtual.remote.VParceledListSlice)2 File (java.io.File)2 TargetApi (android.annotation.TargetApi)1 BroadcastReceiver (android.content.BroadcastReceiver)1 IntentFilter (android.content.IntentFilter)1 ApplicationInfo (android.content.pm.ApplicationInfo)1 PackageInfo (android.content.pm.PackageInfo)1 InstallResult (com.lody.virtual.remote.InstallResult)1 PackageSetting (com.lody.virtual.server.pm.PackageSetting)1 IOException (java.io.IOException)1