Search in sources :

Example 6 with InstalledAppInfo

use of com.lody.virtual.remote.InstalledAppInfo in project VirtualApp by asLody.

the class VAppManagerService method getInstalledAppsAsUser.

@Override
public List<InstalledAppInfo> getInstalledAppsAsUser(int userId, int flags) {
    List<InstalledAppInfo> infoList = new ArrayList<>(getInstalledAppCount());
    for (VPackage p : PackageCacheManager.PACKAGE_CACHE.values()) {
        PackageSetting setting = (PackageSetting) p.mExtras;
        boolean visible = setting.isInstalled(userId);
        if ((flags & VirtualCore.GET_HIDDEN_APP) == 0 && setting.isHidden(userId)) {
            visible = false;
        }
        if (visible) {
            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)

Example 7 with InstalledAppInfo

use of com.lody.virtual.remote.InstalledAppInfo in project VirtualApp by asLody.

the class VirtualCore method getResources.

public Resources getResources(String pkg) {
    InstalledAppInfo installedAppInfo = getInstalledAppInfo(pkg, 0);
    if (installedAppInfo != null) {
        AssetManager assets = mirror.android.content.res.AssetManager.ctor.newInstance();
        mirror.android.content.res.AssetManager.addAssetPath.call(assets, installedAppInfo.apkPath);
        Resources hostRes = context.getResources();
        return new Resources(assets, hostRes.getDisplayMetrics(), hostRes.getConfiguration());
    }
    return null;
}
Also used : AssetManager(android.content.res.AssetManager) InstalledAppInfo(com.lody.virtual.remote.InstalledAppInfo) Resources(android.content.res.Resources)

Example 8 with InstalledAppInfo

use of com.lody.virtual.remote.InstalledAppInfo in project VirtualApp by asLody.

the class VirtualCore method removeShortcut.

public boolean removeShortcut(int userId, String packageName, Intent splash, OnEmitShortcutListener listener) {
    InstalledAppInfo setting = getInstalledAppInfo(packageName, 0);
    if (setting == null) {
        return false;
    }
    ApplicationInfo appInfo = setting.getApplicationInfo(userId);
    PackageManager pm = context.getPackageManager();
    String name;
    try {
        CharSequence sequence = appInfo.loadLabel(pm);
        name = sequence.toString();
    } catch (Throwable e) {
        return false;
    }
    if (listener != null) {
        String newName = listener.getName(name);
        if (newName != null) {
            name = newName;
        }
    }
    Intent targetIntent = getLaunchIntent(packageName, userId);
    if (targetIntent == null) {
        return false;
    }
    Intent shortcutIntent = new Intent();
    shortcutIntent.setClassName(getHostPkg(), Constants.SHORTCUT_PROXY_ACTIVITY_NAME);
    shortcutIntent.addCategory(Intent.CATEGORY_DEFAULT);
    if (splash != null) {
        shortcutIntent.putExtra("_VA_|_splash_", splash.toUri(0));
    }
    shortcutIntent.putExtra("_VA_|_intent_", targetIntent);
    shortcutIntent.putExtra("_VA_|_uri_", targetIntent.toUri(0));
    shortcutIntent.putExtra("_VA_|_user_id_", VUserHandle.myUserId());
    Intent addIntent = new Intent();
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
    addIntent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
    context.sendBroadcast(addIntent);
    return true;
}
Also used : PackageManager(android.content.pm.PackageManager) VPackageManager(com.lody.virtual.client.ipc.VPackageManager) InstalledAppInfo(com.lody.virtual.remote.InstalledAppInfo) ApplicationInfo(android.content.pm.ApplicationInfo) Intent(android.content.Intent)

Example 9 with InstalledAppInfo

use of com.lody.virtual.remote.InstalledAppInfo in project VirtualApp by asLody.

the class NativeEngine method startDexOverride.

public static void startDexOverride() {
    List<InstalledAppInfo> installedAppInfos = VirtualCore.get().getInstalledApps(0);
    sDexOverrideMap = new HashMap<>(installedAppInfos.size());
    for (InstalledAppInfo info : installedAppInfos) {
        try {
            sDexOverrideMap.put(new File(info.apkPath).getCanonicalPath(), info);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : InstalledAppInfo(com.lody.virtual.remote.InstalledAppInfo) IOException(java.io.IOException) DexFile(dalvik.system.DexFile) File(java.io.File)

Example 10 with InstalledAppInfo

use of com.lody.virtual.remote.InstalledAppInfo in project VirtualApp by asLody.

the class AppAccountParser method getResources.

@Override
public Resources getResources(Context context, ApplicationInfo appInfo) throws Exception {
    InstalledAppInfo appSetting = VAppManagerService.get().getInstalledAppInfo(appInfo.packageName, 0);
    if (appSetting != null) {
        AssetManager assets = mirror.android.content.res.AssetManager.ctor.newInstance();
        mirror.android.content.res.AssetManager.addAssetPath.call(assets, appSetting.apkPath);
        Resources hostRes = context.getResources();
        return new Resources(assets, hostRes.getDisplayMetrics(), hostRes.getConfiguration());
    }
    return null;
}
Also used : AssetManager(android.content.res.AssetManager) InstalledAppInfo(com.lody.virtual.remote.InstalledAppInfo) Resources(android.content.res.Resources)

Aggregations

InstalledAppInfo (com.lody.virtual.remote.InstalledAppInfo)11 ArrayList (java.util.ArrayList)4 ApplicationInfo (android.content.pm.ApplicationInfo)3 PackageManager (android.content.pm.PackageManager)3 IOException (java.io.IOException)3 Intent (android.content.Intent)2 AssetManager (android.content.res.AssetManager)2 Resources (android.content.res.Resources)2 Bitmap (android.graphics.Bitmap)2 VPackageManager (com.lody.virtual.client.ipc.VPackageManager)2 VPackage (com.lody.virtual.server.pm.parser.VPackage)2 DexFile (dalvik.system.DexFile)2 AppData (io.virtualapp.home.models.AppData)2 MultiplePackageAppData (io.virtualapp.home.models.MultiplePackageAppData)2 PackageAppData (io.virtualapp.home.models.PackageAppData)2 File (java.io.File)2 Activity (android.app.Activity)1 PackageInfo (android.content.pm.PackageInfo)1 VirtualCore (com.lody.virtual.client.core.VirtualCore)1 VUserInfo (com.lody.virtual.os.VUserInfo)1