use of com.lody.virtual.remote.InstalledAppInfo in project VirtualApp by asLody.
the class VirtualCore method createShortcut.
public boolean createShortcut(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;
Bitmap icon;
try {
CharSequence sequence = appInfo.loadLabel(pm);
name = sequence.toString();
icon = BitmapUtils.drawableToBitmap(appInfo.loadIcon(pm));
} catch (Throwable e) {
return false;
}
if (listener != null) {
String newName = listener.getName(name);
if (newName != null) {
name = newName;
}
Bitmap newIcon = listener.getIcon(icon);
if (newIcon != null) {
icon = newIcon;
}
}
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.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon);
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
context.sendBroadcast(addIntent);
return true;
}
use of com.lody.virtual.remote.InstalledAppInfo in project VirtualApp by asLody.
the class HomePresenterImpl method addApp.
@Override
public void addApp(AppInfoLite info) {
class AddResult {
private PackageAppData appData;
private int userId;
}
AddResult addResult = new AddResult();
VUiKit.defer().when(() -> {
InstalledAppInfo installedAppInfo = VirtualCore.get().getInstalledAppInfo(info.packageName, 0);
if (installedAppInfo != null) {
int[] userIds = installedAppInfo.getInstalledUsers();
int nextUserId = userIds.length;
addResult.userId = nextUserId;
if (VUserManager.get().getUserInfo(nextUserId) == null) {
String nextUserName = "Space " + nextUserId + 1;
VUserInfo newUserInfo = VUserManager.get().createUser(nextUserName, VUserInfo.FLAG_ADMIN);
if (newUserInfo == null) {
throw new IllegalStateException();
}
}
boolean success = VirtualCore.get().installPackageAsUser(nextUserId, info.packageName);
if (!success) {
throw new IllegalStateException();
}
} else {
InstallResult res = mRepo.addVirtualApp(info);
if (!res.isSuccess) {
throw new IllegalStateException();
}
}
}).then((res) -> {
addResult.appData = PackageAppDataStorage.get().acquire(info.packageName);
}).done(res -> {
if (addResult.userId == 0) {
PackageAppData data = addResult.appData;
data.isLoading = true;
mView.addAppToLauncher(data);
handleOptApp(data);
} else {
MultiplePackageAppData data = new MultiplePackageAppData(addResult.appData, addResult.userId);
data.isLoading = true;
mView.addAppToLauncher(data);
handleMultipleApp(data);
}
});
}
use of com.lody.virtual.remote.InstalledAppInfo in project VirtualApp by asLody.
the class NativeEngine method onOpenDexFileNative.
public static void onOpenDexFileNative(String[] params) {
String dexOrJarPath = params[0];
String outputPath = params[1];
VLog.d(TAG, "DexOrJarPath = %s, OutputPath = %s.", dexOrJarPath, outputPath);
try {
String canonical = new File(dexOrJarPath).getCanonicalPath();
InstalledAppInfo info = sDexOverrideMap.get(canonical);
if (info != null && !info.dependSystem) {
outputPath = info.getOdexFile().getPath();
params[1] = outputPath;
}
} catch (IOException e) {
e.printStackTrace();
}
}
use of com.lody.virtual.remote.InstalledAppInfo in project VirtualApp by asLody.
the class AppRepository method getVirtualApps.
@Override
public Promise<List<AppData>, Throwable, Void> getVirtualApps() {
return VUiKit.defer().when(() -> {
List<InstalledAppInfo> infos = VirtualCore.get().getInstalledApps(0);
List<AppData> models = new ArrayList<AppData>();
for (InstalledAppInfo info : infos) {
if (VirtualCore.get().getLaunchIntent(info.packageName, 0) == null) {
continue;
}
PackageAppData data = new PackageAppData(mContext, info);
models.add(data);
int[] userIds = info.getInstalledUsers();
for (int userId : userIds) {
if (userId != 0) {
models.add(new MultiplePackageAppData(data, userId));
}
}
}
return models;
});
}
use of com.lody.virtual.remote.InstalledAppInfo 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;
}
Aggregations