Search in sources :

Example 1 with VPackage

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

the class VPackageManagerService method getPackagesForUid.

@Override
public String[] getPackagesForUid(int uid) {
    int userId = VUserHandle.getUserId(uid);
    checkUserId(userId);
    synchronized (this) {
        List<String> pkgList = new ArrayList<>(2);
        for (VPackage p : mPackages.values()) {
            PackageSetting settings = (PackageSetting) p.mExtras;
            if (VUserHandle.getUid(userId, settings.appId) == uid) {
                pkgList.add(p.packageName);
            }
        }
        return pkgList.toArray(new String[pkgList.size()]);
    }
}
Also used : VPackage(com.lody.virtual.server.pm.parser.VPackage) ArrayList(java.util.ArrayList)

Example 2 with VPackage

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

the class VPackageManagerService method getApplicationInfo.

@Override
public ApplicationInfo getApplicationInfo(String packageName, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    synchronized (mPackages) {
        VPackage p = mPackages.get(packageName);
        if (p != null) {
            PackageSetting ps = (PackageSetting) p.mExtras;
            return PackageParserEx.generateApplicationInfo(p, flags, ps.readUserState(userId), userId);
        }
    }
    return null;
}
Also used : VPackage(com.lody.virtual.server.pm.parser.VPackage)

Example 3 with VPackage

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

the class VPackageManagerService method querySharedPackages.

@Override
public List<String> querySharedPackages(String packageName) {
    synchronized (mPackages) {
        VPackage p = mPackages.get(packageName);
        if (p == null || p.mSharedUserId == null) {
            // noinspection unchecked
            return Collections.EMPTY_LIST;
        }
        ArrayList<String> list = new ArrayList<>();
        for (VPackage one : mPackages.values()) {
            if (TextUtils.equals(one.mSharedUserId, p.mSharedUserId)) {
                list.add(one.packageName);
            }
        }
        return list;
    }
}
Also used : VPackage(com.lody.virtual.server.pm.parser.VPackage) ArrayList(java.util.ArrayList)

Example 4 with VPackage

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

the class BroadcastSystem method startApp.

public void startApp(VPackage p) {
    PackageSetting setting = (PackageSetting) p.mExtras;
    for (VPackage.ActivityComponent receiver : p.receivers) {
        ActivityInfo info = receiver.info;
        List<BroadcastReceiver> receivers = mReceivers.get(p.packageName);
        if (receivers == null) {
            receivers = new ArrayList<>();
            mReceivers.put(p.packageName, receivers);
        }
        String componentAction = String.format("_VA_%s_%s", info.packageName, info.name);
        IntentFilter componentFilter = new IntentFilter(componentAction);
        BroadcastReceiver r = new StaticBroadcastReceiver(setting.appId, info, componentFilter);
        mContext.registerReceiver(r, componentFilter, null, mScheduler);
        receivers.add(r);
        for (VPackage.ActivityIntentInfo ci : receiver.intents) {
            IntentFilter cloneFilter = new IntentFilter(ci.filter);
            redirectFilterActions(cloneFilter);
            r = new StaticBroadcastReceiver(setting.appId, info, cloneFilter);
            mContext.registerReceiver(r, cloneFilter, null, mScheduler);
            receivers.add(r);
        }
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) IntentFilter(android.content.IntentFilter) VPackage(com.lody.virtual.server.pm.parser.VPackage) PackageSetting(com.lody.virtual.server.pm.PackageSetting) BroadcastReceiver(android.content.BroadcastReceiver)

Example 5 with VPackage

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

the class VAppManagerService method getInstalledApps.

@Override
public List<InstalledAppInfo> getInstalledApps(int flags) {
    List<InstalledAppInfo> infoList = new ArrayList<>(getInstalledAppCount());
    for (VPackage p : PackageCacheManager.PACKAGE_CACHE.values()) {
        PackageSetting setting = (PackageSetting) p.mExtras;
        infoList.add(setting.getAppInfo(flags));
    }
    return infoList;
}
Also used : VPackage(com.lody.virtual.server.pm.parser.VPackage) ArrayList(java.util.ArrayList) InstalledAppInfo(com.lody.virtual.remote.InstalledAppInfo)

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