Java Code Examples for android.content.Intent.getComponent()

The following are Jave code examples for showing how to use getComponent() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: chromium-for-android-56-debug-video   File: ActivityDelegate.java   View Source Code Vote up 7 votes
/**
 * Checks whether or not the Intent corresponds to an Activity that should be tracked.
 * @param isIncognito Whether or not the TabModel is managing incognito tabs.
 * @param intent Intent used to launch the Activity.
 * @return Whether or not to track the Activity.
 */
public boolean isValidActivity(boolean isIncognito, Intent intent) {
    if (intent == null) return false;
    String desiredClassName = isIncognito ? mIncognitoClass.getName() : mRegularClass.getName();
    String desiredLegacyClassName = isIncognito
            ? DocumentActivity.LEGACY_INCOGNITO_CLASS_NAME
            : DocumentActivity.LEGACY_CLASS_NAME;
    String className = null;
    if (intent.getComponent() == null) {
        ResolveInfo resolveInfo = ExternalNavigationDelegateImpl.resolveActivity(intent);
        if (resolveInfo != null) className = resolveInfo.activityInfo.name;
    } else {
        className = intent.getComponent().getClassName();
    }

    return TextUtils.equals(className, desiredClassName)
            || TextUtils.equals(className, desiredLegacyClassName);
}
 
Example 2
Project: TPlayer   File: VirtualCore.java   View Source Code Vote up 7 votes
public synchronized ActivityInfo resolveActivityInfo(Intent intent, int userId) {
    ActivityInfo activityInfo = null;
    if (intent.getComponent() == null) {
        ResolveInfo resolveInfo = VPackageManager.get().resolveIntent(intent, intent.getType(), 0, userId);
        if (resolveInfo != null && resolveInfo.activityInfo != null) {
            activityInfo = resolveInfo.activityInfo;
            intent.setClassName(activityInfo.packageName, activityInfo.name);
        }
    } else {
        activityInfo = resolveActivityInfo(intent.getComponent(), userId);
    }
    if (activityInfo != null) {
        if (activityInfo.targetActivity != null) {
            ComponentName componentName = new ComponentName(activityInfo.packageName, activityInfo.targetActivity);
            activityInfo = VPackageManager.get().getActivityInfo(componentName, 0, userId);
            intent.setComponent(componentName);
        }
    }
    return activityInfo;
}
 
Example 3
Project: VirtualHook   File: VirtualCore.java   View Source Code Vote up 7 votes
public synchronized ActivityInfo resolveActivityInfo(Intent intent, int userId) {
    ActivityInfo activityInfo = null;
    if (intent.getComponent() == null) {
        ResolveInfo resolveInfo = VPackageManager.get().resolveIntent(intent, intent.getType(), 0, userId);
        if (resolveInfo != null && resolveInfo.activityInfo != null) {
            activityInfo = resolveInfo.activityInfo;
            intent.setClassName(activityInfo.packageName, activityInfo.name);
        }
    } else {
        activityInfo = resolveActivityInfo(intent.getComponent(), userId);
    }
    if (activityInfo != null) {
        if (activityInfo.targetActivity != null) {
            ComponentName componentName = new ComponentName(activityInfo.packageName, activityInfo.targetActivity);
            activityInfo = VPackageManager.get().getActivityInfo(componentName, 0, userId);
            intent.setComponent(componentName);
        }
    }
    return activityInfo;
}
 
Example 4
Project: VirtualAPK   File: RemoteService.java   View Source Code Vote up 7 votes
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent == null) {
        return super.onStartCommand(intent, flags, startId);
    }

    Intent target = intent.getParcelableExtra(EXTRA_TARGET);
    if (target != null) {
        String pluginLocation = intent.getStringExtra(EXTRA_PLUGIN_LOCATION);
        ComponentName component = target.getComponent();
        LoadedPlugin plugin = PluginManager.getInstance(this).getLoadedPlugin(component);
        if (plugin == null && pluginLocation != null) {
            try {
                PluginManager.getInstance(this).loadPlugin(new File(pluginLocation));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    return super.onStartCommand(intent, flags, startId);
}
 
Example 5
Project: DroidPlugin   File: IPluginManagerImpl.java   View Source Code Vote up 7 votes
@Override
public ServiceInfo selectStubServiceInfoByIntent(Intent intent) throws RemoteException {
    ServiceInfo ai = null;
    if (intent.getComponent() != null) {
        ai = getServiceInfo(intent.getComponent(), 0);
    } else {
        ResolveInfo resolveInfo = resolveIntent(intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), 0);
        if (resolveInfo.serviceInfo != null) {
            ai = resolveInfo.serviceInfo;
        }
    }

    if (ai != null) {
        return selectStubServiceInfo(ai);
    }
    return null;
}
 
Example 6
Project: CleanArchitechture   File: Logger.java   View Source Code Vote up 6 votes
public static void dump(Intent intent) {
    if (intent == null) {
        e("Intent is null");
        return;
    }

    e("Intent: action: %s", intent.getAction());

    if (intent.getPackage() != null) {
        e("  pkg: %s", intent.getPackage());
    }

    if (intent.getType() != null) {
        e("  type: %s", intent.getType());
    }

    if (intent.getComponent() != null) {
        e("  comp: %s", intent.getComponent().flattenToString());
    }

    if (intent.getDataString() != null) {
        e("  data: %s", intent.getDataString());
    }

    if (intent.getCategories() != null) {
        for (String cat : intent.getCategories()) {
            e("  cat: %s", cat);
        }
    }

    Bundle bundle = intent.getExtras();
    if (bundle != null) {
        for (String key : bundle.keySet()) {
            Object value = bundle.get(key);
            e("  extra: %s->%s", key, value);
        }
    }

}
 
Example 7
Project: springreplugin   File: RePluginInternal.java   View Source Code Vote up 6 votes
/**
 * 获取插件名称
 */
private static String getPluginName(Activity activity, Intent intent) {
    String plugin = "";
    if (intent.getComponent() != null) {
        plugin = intent.getComponent().getPackageName();
    }
    // 如果 plugin 是包名,则说明启动的是本插件。
    if (TextUtils.isEmpty(plugin) || plugin.contains(".")) {
        plugin = RePlugin.fetchPluginNameByClassLoader(activity.getClassLoader());
    }
    // 否则是其它插件
    return plugin;
}
 
Example 8
Project: atlas   File: InstrumentationHook.java   View Source Code Vote up 6 votes
public static void fallBackToClassNotFoundCallback(Context context,
		Intent intent, String componentName) {
	if(Framework.getClassNotFoundCallback() !=null){
		TrackH5FallBack(componentName);
		if(intent.getComponent() == null && !TextUtils.isEmpty(componentName)){
			intent.setClassName(context,componentName);
		}
	    if(intent.getComponent()!=null) {
	        Framework.getClassNotFoundCallback().returnIntent(intent);
	    }
	}
}
 
Example 9
Project: LaunchEnr   File: Utilities.java   View Source Code Vote up 6 votes
/**
 * Returns true if the intent is a valid launch intent for a launcher activity of an app.
 * This is used to identify shortcuts which are different from the ones exposed by the
 * applications' manifest file.
 *
 * @param launchIntent The intent that will be launched when the shortcut is clicked.
 */
public static boolean isLauncherAppTarget(Intent launchIntent) {
    if (launchIntent != null
            && Intent.ACTION_MAIN.equals(launchIntent.getAction())
            && launchIntent.getComponent() != null
            && launchIntent.getCategories() != null
            && launchIntent.getCategories().size() == 1
            && launchIntent.hasCategory(Intent.CATEGORY_LAUNCHER)
            && TextUtils.isEmpty(launchIntent.getDataString())) {
        // An app target can either have no extra or have ItemInfo.EXTRA_PROFILE.
        Bundle extras = launchIntent.getExtras();
        return extras == null || extras.keySet().isEmpty();
    }
    return false;
}
 
Example 10
Project: VirtualAPK   File: ComponentsHandler.java   View Source Code Vote up 6 votes
public void markIntentIfNeeded(Intent intent) {
    if (intent.getComponent() == null) {
        return;
    }

    String targetPackageName = intent.getComponent().getPackageName();
    String targetClassName = intent.getComponent().getClassName();
    // search map and return specific launchmode stub activity
    if (!targetPackageName.equals(mContext.getPackageName()) && mPluginManager.getLoadedPlugin(targetPackageName) != null) {
        intent.putExtra(Constants.KEY_IS_PLUGIN, true);
        intent.putExtra(Constants.KEY_TARGET_PACKAGE, targetPackageName);
        intent.putExtra(Constants.KEY_TARGET_ACTIVITY, targetClassName);
        dispatchStubActivity(intent);
    }
}
 
Example 11
Project: TPlayer   File: VPackageManagerService.java   View Source Code Vote up 6 votes
@Override
public List<ResolveInfo> queryIntentActivities(Intent intent, String resolvedType, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    ComponentName comp = intent.getComponent();
    if (comp == null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            if (intent.getSelector() != null) {
                intent = intent.getSelector();
                comp = intent.getComponent();
            }
        }
    }
    if (comp != null) {
        final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
        final ActivityInfo ai = getActivityInfo(comp, flags, userId);
        if (ai != null) {
            final ResolveInfo ri = new ResolveInfo();
            ri.activityInfo = ai;
            list.add(ri);
        }
        return list;
    }

    // reader
    synchronized (mPackages) {
        final String pkgName = intent.getPackage();
        if (pkgName == null) {
            return mActivities.queryIntent(intent, resolvedType, flags, userId);
        }
        final VPackage pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mActivities.queryIntentForPackage(intent, resolvedType, flags, pkg.activities, userId);
        }
        return Collections.emptyList();
    }
}
 
Example 12
Project: springreplugin   File: PluginServiceServer.java   View Source Code Vote up 6 votes
int bindServiceLocked(Intent intent, IServiceConnection connection, int flags, Messenger client) {
    intent = cloneIntentLocked(intent);
    ComponentName cn = intent.getComponent();
    ProcessRecord callerPr = retrieveProcessRecordLocked(client);
    ServiceRecord sr = retrieveServiceLocked(intent);
    if (sr == null) {
        return 0;
    }
    if (!installServiceIfNeededLocked(sr)) {
        return 0;
    }

    // 将ServiceConnection连接加入各种表中
    ProcessBindRecord b = sr.retrieveAppBindingLocked(intent, callerPr);
    insertConnectionToRecords(sr, b, connection, flags);

    // 判断是否已经绑定过
    if (b.intent.hasBound) {
        // 之前此Intent已绑定过,则直接返回。像系统那样
        // 注意:不管哪个进程,只要第一次绑定过了,其后直接返回。像系统那样
        callConnectedMethodLocked(connection, cn, b.intent.binder);
    } else {
        // 没有绑定,则直接调用onBind,且记录绑定状态
        if (b.intent.apps.size() > 0) {
            IBinder bd = sr.service.onBind(intent);
            b.intent.hasBound = true;
            b.intent.binder = bd;
            if (bd != null) {
                // 为空就不会回调,但仍算绑定成功。像系统那样
                callConnectedMethodLocked(connection, cn, bd);
            }
        }
    }
    if (LOG) {
        LogDebug.i(PLUGIN_TAG, "PSM.bindService(): Bind! inb=" + b + "; fl=" + flags + "; sr=" + sr);
    }
    return 1;
}
 
Example 13
Project: container   File: ComponentUtils.java   View Source Code Vote up 5 votes
public static boolean isStubComponent(Intent intent) {
    return intent != null
            && intent.getComponent() != null
            && VirtualCore.get().getHostPkg().equals(intent.getComponent().getPackageName());
}
 
Example 14
Project: LaunchTime   File: ShortcutReceiver.java   View Source Code Vote up 5 votes
@Override
    public void onReceive(Context context, Intent intent) {
        if (!BuildConfig.DEBUG) Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(context));
        String action = intent.getAction();
        if ("com.android.launcher.action.INSTALL_SHORTCUT".equals(action)) {
            Log.d("ShortcutCatch", "intent received");
            Bundle extras = intent.getExtras();
            if (extras != null) {

                try {
                    Log.d("ShortcutCatch", "Shortcut name: " + intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME));
                    Intent intent2 = (Intent) extras.get(Intent.EXTRA_SHORTCUT_INTENT);
                    Bitmap receivedicon = (Bitmap) extras.get(Intent.EXTRA_SHORTCUT_ICON);
                    if (intent2 != null) {
                        Uri data = intent2.getData();
                        ComponentName cn = intent2.getComponent();


                        String intentaction = intent2.getAction();
                        String shortcutLabel = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
//                        for (String key: intent2.getExtras().keySet()) {
//                            Log.d("ShortcutCatch", " extra2: " + key + " = " + intent2.getExtras().get(key));
//                        }

                        Log.d("ShortcutCatch", "intent2.action=" + intent2.getAction());
                        Log.d("ShortcutCatch", "uri=" + data);
                        if (cn != null) {
                            Log.d("ShortcutCatch", "cn2package=" + cn.getPackageName() + ", cn2classname=" + cn.getClassName());

                            addLink(context, shortcutLabel, data, cn, receivedicon);
                        } else if (intentaction!=null){
                            Log.d("ShortcutCatch", "intentaction=" + intentaction + " uri=" + data);
                            addLink(context, intentaction, shortcutLabel, data, receivedicon);
                        }
                    }
                } catch (Exception e) {
                    Log.e("ShortcutCatch", "Can't make shortcutlink", e);
                }

            }


        } else {
            Log.d("ShortcutCatch", "unknown intent received: " + action);
        }

    }
 
Example 15
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
final void attach(Context context, ActivityThread aThread,
                  Instrumentation instr, IBinder token, int ident,
                  Application application, Intent intent, ActivityInfo info,
                  CharSequence title, Activity parent, String id,
                  NonConfigurationInstances lastNonConfigurationInstances,
                  Configuration config, String referrer, IVoiceInteractor voiceInteractor,
                  Window window) {
    attachBaseContext(context);

    mFragments.attachHost(null /*parent*/);

    mWindow = new PhoneWindow(this, window);
    mWindow.setWindowControllerCallback(this);
    mWindow.setCallback(this);
    mWindow.setOnWindowDismissedCallback(this);
    mWindow.getLayoutInflater().setPrivateFactory(this);
    if (info.softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
        mWindow.setSoftInputMode(info.softInputMode);
    }
    if (info.uiOptions != 0) {
        mWindow.setUiOptions(info.uiOptions);
    }
    mUiThread = Thread.currentThread();

    mMainThread = aThread;
    mInstrumentation = instr;
    mToken = token;
    mIdent = ident;
    mApplication = application;
    mIntent = intent;
    mReferrer = referrer;
    mComponent = intent.getComponent();
    mActivityInfo = info;
    mTitle = title;
    mParent = parent;
    mEmbeddedID = id;
    mLastNonConfigurationInstances = lastNonConfigurationInstances;
    if (voiceInteractor != null) {
        if (lastNonConfigurationInstances != null) {
            mVoiceInteractor = lastNonConfigurationInstances.voiceInteractor;
        } else {
            mVoiceInteractor = new VoiceInteractor(voiceInteractor, this, this,
                    Looper.myLooper());
        }
    }

    mWindow.setWindowManager(
            (WindowManager)context.getSystemService(Context.WINDOW_SERVICE),
            mToken, mComponent.flattenToString(),
            (info.flags & ActivityInfo.FLAG_HARDWARE_ACCELERATED) != 0);
    if (mParent != null) {
        mWindow.setContainer(mParent.getWindow());
    }
    mWindowManager = mWindow.getWindowManager();
    mCurrentConfig = config;
}
 
Example 16
Project: android-apkbox   File: ApkComponentModifier.java   View Source Code Vote up 5 votes
public static String getClassName(Intent intent) {
    if (intent != null && intent.getComponent() != null) {
        return intent.getComponent().getClassName();
    }
    return null;
}
 
Example 17
Project: condom   File: CondomCore.java   View Source Code Vote up 5 votes
static String getTargetPackage(final Intent intent) {
	final ComponentName component = intent.getComponent();
	return component != null ? component.getPackageName() : intent.getPackage();
}
 
Example 18
Project: prevent   File: PreventRunningUtils.java   View Source Code Vote up 5 votes
public static void onCleanUpRemovedTask(Intent intent) {
    if (intent != null && intent.getComponent() != null) {
        mPreventRunning.onCleanUpRemovedTask(intent.getComponent().getPackageName());
    }
}
 
Example 19
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
final void attach(Context context, ActivityThread aThread,
                  Instrumentation instr, IBinder token, int ident,
                  Application application, Intent intent, ActivityInfo info,
                  CharSequence title, Activity parent, String id,
                  NonConfigurationInstances lastNonConfigurationInstances,
                  Configuration config, String referrer, IVoiceInteractor voiceInteractor,
                  Window window) {
    attachBaseContext(context);

    mFragments.attachHost(null /*parent*/);

    mWindow = new PhoneWindow(this, window);
    mWindow.setWindowControllerCallback(this);
    mWindow.setCallback(this);
    mWindow.setOnWindowDismissedCallback(this);
    mWindow.getLayoutInflater().setPrivateFactory(this);
    if (info.softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
        mWindow.setSoftInputMode(info.softInputMode);
    }
    if (info.uiOptions != 0) {
        mWindow.setUiOptions(info.uiOptions);
    }
    mUiThread = Thread.currentThread();

    mMainThread = aThread;
    mInstrumentation = instr;
    mToken = token;
    mIdent = ident;
    mApplication = application;
    mIntent = intent;
    mReferrer = referrer;
    mComponent = intent.getComponent();
    mActivityInfo = info;
    mTitle = title;
    mParent = parent;
    mEmbeddedID = id;
    mLastNonConfigurationInstances = lastNonConfigurationInstances;
    if (voiceInteractor != null) {
        if (lastNonConfigurationInstances != null) {
            mVoiceInteractor = lastNonConfigurationInstances.voiceInteractor;
        } else {
            mVoiceInteractor = new VoiceInteractor(voiceInteractor, this, this,
                    Looper.myLooper());
        }
    }

    mWindow.setWindowManager(
            (WindowManager)context.getSystemService(Context.WINDOW_SERVICE),
            mToken, mComponent.flattenToString(),
            (info.flags & ActivityInfo.FLAG_HARDWARE_ACCELERATED) != 0);
    if (mParent != null) {
        mWindow.setContainer(mParent.getWindow());
    }
    mWindowManager = mWindow.getWindowManager();
    mCurrentConfig = config;
}
 
Example 20
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
final void attach(Context context, ActivityThread aThread,
                  Instrumentation instr, IBinder token, int ident,
                  Application application, Intent intent, ActivityInfo info,
                  CharSequence title, Activity parent, String id,
                  NonConfigurationInstances lastNonConfigurationInstances,
                  Configuration config, String referrer, IVoiceInteractor voiceInteractor,
                  Window window) {
    attachBaseContext(context);

    mFragments.attachHost(null /*parent*/);

    mWindow = new PhoneWindow(this, window);
    mWindow.setWindowControllerCallback(this);
    mWindow.setCallback(this);
    mWindow.setOnWindowDismissedCallback(this);
    mWindow.getLayoutInflater().setPrivateFactory(this);
    if (info.softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
        mWindow.setSoftInputMode(info.softInputMode);
    }
    if (info.uiOptions != 0) {
        mWindow.setUiOptions(info.uiOptions);
    }
    mUiThread = Thread.currentThread();

    mMainThread = aThread;
    mInstrumentation = instr;
    mToken = token;
    mIdent = ident;
    mApplication = application;
    mIntent = intent;
    mReferrer = referrer;
    mComponent = intent.getComponent();
    mActivityInfo = info;
    mTitle = title;
    mParent = parent;
    mEmbeddedID = id;
    mLastNonConfigurationInstances = lastNonConfigurationInstances;
    if (voiceInteractor != null) {
        if (lastNonConfigurationInstances != null) {
            mVoiceInteractor = lastNonConfigurationInstances.voiceInteractor;
        } else {
            mVoiceInteractor = new VoiceInteractor(voiceInteractor, this, this,
                    Looper.myLooper());
        }
    }

    mWindow.setWindowManager(
            (WindowManager)context.getSystemService(Context.WINDOW_SERVICE),
            mToken, mComponent.flattenToString(),
            (info.flags & ActivityInfo.FLAG_HARDWARE_ACCELERATED) != 0);
    if (mParent != null) {
        mWindow.setContainer(mParent.getWindow());
    }
    mWindowManager = mWindow.getWindowManager();
    mCurrentConfig = config;
}