use of android.content.ComponentName in project VirtualApp by asLody.
the class StartActivity method call.
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
int intentIndex = ArrayUtils.indexOfObject(args, Intent.class, 1);
if (intentIndex < 0) {
return ActivityManagerCompat.START_INTENT_NOT_RESOLVED;
}
int resultToIndex = ArrayUtils.indexOfObject(args, IBinder.class, 2);
String resolvedType = (String) args[intentIndex + 1];
Intent intent = (Intent) args[intentIndex];
intent.setDataAndType(intent.getData(), resolvedType);
IBinder resultTo = resultToIndex >= 0 ? (IBinder) args[resultToIndex] : null;
int userId = VUserHandle.myUserId();
if (ComponentUtils.isStubComponent(intent)) {
return method.invoke(who, args);
}
if (Intent.ACTION_INSTALL_PACKAGE.equals(intent.getAction()) || (Intent.ACTION_VIEW.equals(intent.getAction()) && "application/vnd.android.package-archive".equals(intent.getType()))) {
if (handleInstallRequest(intent)) {
return 0;
}
} else if ((Intent.ACTION_UNINSTALL_PACKAGE.equals(intent.getAction()) || Intent.ACTION_DELETE.equals(intent.getAction())) && "package".equals(intent.getScheme())) {
if (handleUninstallRequest(intent)) {
return 0;
}
}
String resultWho = null;
int requestCode = 0;
Bundle options = ArrayUtils.getFirst(args, Bundle.class);
if (resultTo != null) {
resultWho = (String) args[resultToIndex + 1];
requestCode = (int) args[resultToIndex + 2];
}
// chooser
if (ChooserActivity.check(intent)) {
intent.setComponent(new ComponentName(getHostContext(), ChooserActivity.class));
intent.putExtra(Constants.EXTRA_USER_HANDLE, userId);
intent.putExtra(ChooserActivity.EXTRA_DATA, options);
intent.putExtra(ChooserActivity.EXTRA_WHO, resultWho);
intent.putExtra(ChooserActivity.EXTRA_REQUEST_CODE, requestCode);
return method.invoke(who, args);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
args[intentIndex - 1] = getHostPkg();
}
ActivityInfo activityInfo = VirtualCore.get().resolveActivityInfo(intent, userId);
if (activityInfo == null) {
return method.invoke(who, args);
}
int res = VActivityManager.get().startActivity(intent, activityInfo, resultTo, options, resultWho, requestCode, VUserHandle.myUserId());
if (res != 0 && resultTo != null && requestCode > 0) {
VActivityManager.get().sendActivityResult(resultTo, resultWho, requestCode);
}
if (resultTo != null) {
ActivityClientRecord r = VActivityManager.get().getActivityRecord(resultTo);
if (r != null && r.activity != null) {
try {
TypedValue out = new TypedValue();
Resources.Theme theme = r.activity.getResources().newTheme();
theme.applyStyle(activityInfo.getThemeResource(), true);
if (theme.resolveAttribute(android.R.attr.windowAnimationStyle, out, true)) {
TypedArray array = theme.obtainStyledAttributes(out.data, new int[] { android.R.attr.activityOpenEnterAnimation, android.R.attr.activityOpenExitAnimation });
r.activity.overridePendingTransition(array.getResourceId(0, 0), array.getResourceId(1, 0));
array.recycle();
}
} catch (Throwable e) {
// Ignore
}
}
}
return res;
}
use of android.content.ComponentName in project VirtualApp by asLody.
the class StopService method call.
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
IInterface caller = (IInterface) args[0];
Intent intent = (Intent) args[1];
String resolvedType = (String) args[2];
intent.setDataAndType(intent.getData(), resolvedType);
ComponentName componentName = intent.getComponent();
PackageManager pm = VirtualCore.getPM();
if (componentName == null) {
ResolveInfo resolveInfo = pm.resolveService(intent, 0);
if (resolveInfo != null && resolveInfo.serviceInfo != null) {
componentName = new ComponentName(resolveInfo.serviceInfo.packageName, resolveInfo.serviceInfo.name);
}
}
if (componentName != null && !getHostPkg().equals(componentName.getPackageName())) {
return VActivityManager.get().stopService(caller, intent, resolvedType);
}
return method.invoke(who, args);
}
use of android.content.ComponentName in project VirtualApp by asLody.
the class BroadcastIntent method handleUninstallShortcutIntent.
private void handleUninstallShortcutIntent(Intent intent) {
Intent shortcut = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
if (shortcut != null) {
ComponentName componentName = shortcut.resolveActivity(getPM());
if (componentName != null) {
Intent newShortcutIntent = new Intent();
newShortcutIntent.putExtra("_VA_|_uri_", shortcut);
newShortcutIntent.setClassName(getHostPkg(), Constants.SHORTCUT_PROXY_ACTIVITY_NAME);
newShortcutIntent.removeExtra(Intent.EXTRA_SHORTCUT_INTENT);
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, newShortcutIntent);
}
}
}
use of android.content.ComponentName in project VirtualApp by asLody.
the class ActivitySupportsIntent method call.
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
ComponentName component = (ComponentName) args[0];
Intent intent = (Intent) args[1];
String resolvedType = (String) args[2];
return VPackageManager.get().activitySupportsIntent(component, intent, resolvedType);
}
use of android.content.ComponentName in project VirtualApp by asLody.
the class GetReceiverInfo method call.
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
ComponentName componentName = (ComponentName) args[0];
if (getHostPkg().equals(componentName.getPackageName())) {
return method.invoke(who, args);
}
int flags = (int) args[1];
if ((flags & GET_DISABLED_COMPONENTS) == 0) {
flags |= GET_DISABLED_COMPONENTS;
}
return VPackageManager.get().getReceiverInfo(componentName, flags, 0);
}
Aggregations