Search in sources :

Example 31 with ComponentName

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;
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) Bundle(android.os.Bundle) ActivityClientRecord(com.lody.virtual.client.ipc.ActivityClientRecord) Intent(android.content.Intent) IBinder(android.os.IBinder) TypedArray(android.content.res.TypedArray) ChooserActivity(com.lody.virtual.client.stub.ChooserActivity) ComponentName(android.content.ComponentName) Resources(android.content.res.Resources) TypedValue(android.util.TypedValue)

Example 32 with ComponentName

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);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) IInterface(android.os.IInterface) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 33 with ComponentName

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);
        }
    }
}
Also used : Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 34 with ComponentName

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);
}
Also used : ComponentName(android.content.ComponentName) Intent(android.content.Intent)

Example 35 with ComponentName

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);
}
Also used : ComponentName(android.content.ComponentName)

Aggregations

ComponentName (android.content.ComponentName)2548 Intent (android.content.Intent)959 ResolveInfo (android.content.pm.ResolveInfo)375 RemoteException (android.os.RemoteException)317 PackageManager (android.content.pm.PackageManager)269 PendingIntent (android.app.PendingIntent)252 ActivityInfo (android.content.pm.ActivityInfo)243 ArrayList (java.util.ArrayList)242 ShortcutInfo (android.content.pm.ShortcutInfo)152 Point (android.graphics.Point)145 Bundle (android.os.Bundle)139 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)132 IBinder (android.os.IBinder)128 IOException (java.io.IOException)125 ServiceConnection (android.content.ServiceConnection)96 ServiceInfo (android.content.pm.ServiceInfo)96 UserHandle (android.os.UserHandle)86 ArraySet (android.util.ArraySet)73 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)69 Uri (android.net.Uri)68