Search in sources :

Example 36 with ComponentName

use of android.content.ComponentName in project VirtualApp by asLody.

the class GetServiceInfo method call.

@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    ComponentName componentName = (ComponentName) args[0];
    int flags = (int) args[1];
    if ((flags & GET_DISABLED_COMPONENTS) == 0) {
        flags |= GET_DISABLED_COMPONENTS;
    }
    int userId = VUserHandle.myUserId();
    ServiceInfo info = VPackageManager.get().getServiceInfo(componentName, flags, userId);
    if (info != null) {
        return info;
    }
    info = (ServiceInfo) method.invoke(who, args);
    if (info != null) {
        if (getHostPkg().equals(info.packageName) || ComponentUtils.isSystemApp(info.applicationInfo)) {
            return info;
        }
    }
    return null;
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) ComponentName(android.content.ComponentName)

Example 37 with ComponentName

use of android.content.ComponentName in project enroscar by stanfy.

the class SharingHelper method createSharingData.

private SharingData createSharingData(final Intent sharingIntent) {
    final SharingData data = TextUtils.isEmpty(sharingIntent.getAction()) ? new PickData() : new SharingData();
    data.intent = sharingIntent;
    final Context context = this.context.get();
    if (context instanceof Activity) {
        data.callerInfo = ((Activity) context).getCallingActivity();
    } else {
        final String pkg = sharingIntent.getStringExtra(ShareCompat.EXTRA_CALLING_PACKAGE);
        final String act = sharingIntent.getStringExtra(ShareCompat.EXTRA_CALLING_ACTIVITY);
        if (!TextUtils.isEmpty(pkg) && !TextUtils.isEmpty(act)) {
            data.callerInfo = new ComponentName(pkg, act);
        }
    }
    return data;
}
Also used : Context(android.content.Context) Activity(android.app.Activity) ComponentName(android.content.ComponentName)

Example 38 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class VpnConfig method getIntentForConfirmation.

public static Intent getIntentForConfirmation() {
    Intent intent = new Intent();
    ComponentName componentName = ComponentName.unflattenFromString(Resources.getSystem().getString(com.android.internal.R.string.config_customVpnConfirmDialogComponent));
    intent.setClassName(componentName.getPackageName(), componentName.getClassName());
    return intent;
}
Also used : Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) ComponentName(android.content.ComponentName)

Example 39 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class LifecycleTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    mTopIntent = mIntent;
    mTabIntent = new Intent(mContext, LaunchpadTabActivity.class);
    mTabIntent.putExtra("tab", new ComponentName(mContext, LaunchpadActivity.class));
}
Also used : Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 40 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class LocalReceiver method onReceive.

public void onReceive(Context context, Intent intent) {
    String resultString = LaunchpadActivity.RECEIVER_LOCAL;
    if (BroadcastTest.BROADCAST_FAIL_REGISTER.equals(intent.getAction())) {
        resultString = "Successfully registered, but expected it to fail";
        try {
            context.registerReceiver(this, new IntentFilter("foo.bar"));
            context.unregisterReceiver(this);
        } catch (ReceiverCallNotAllowedException e) {
            //resultString = "This is the correct behavior but not yet implemented";
            resultString = LaunchpadActivity.RECEIVER_LOCAL;
        }
    } else if (BroadcastTest.BROADCAST_FAIL_BIND.equals(intent.getAction())) {
        resultString = "Successfully bound to service, but expected it to fail";
        try {
            ServiceConnection sc = new ServiceConnection() {

                public void onServiceConnected(ComponentName name, IBinder service) {
                }

                public void onServiceDisconnected(ComponentName name) {
                }
            };
            context.bindService(new Intent(context, LocalService.class), sc, 0);
            context.unbindService(sc);
        } catch (ReceiverCallNotAllowedException e) {
            //resultString = "This is the correct behavior but not yet implemented";
            resultString = LaunchpadActivity.RECEIVER_LOCAL;
        }
    } else if (LaunchpadActivity.BROADCAST_REPEAT.equals(intent.getAction())) {
        Intent newIntent = new Intent(intent);
        newIntent.setAction(LaunchpadActivity.BROADCAST_LOCAL);
        context.sendOrderedBroadcast(newIntent, null);
    }
    try {
        IBinder caller = intent.getIBinderExtra("caller");
        Parcel data = Parcel.obtain();
        data.writeInterfaceToken(LaunchpadActivity.LAUNCH);
        data.writeString(resultString);
        caller.transact(LaunchpadActivity.GOT_RECEIVE_TRANSACTION, data, null, 0);
        data.recycle();
    } catch (RemoteException ex) {
    }
}
Also used : ReceiverCallNotAllowedException(android.content.ReceiverCallNotAllowedException) IntentFilter(android.content.IntentFilter) ServiceConnection(android.content.ServiceConnection) IBinder(android.os.IBinder) Parcel(android.os.Parcel) ComponentName(android.content.ComponentName) Intent(android.content.Intent) RemoteException(android.os.RemoteException)

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