Search in sources :

Example 21 with ResolveInfo

use of android.content.pm.ResolveInfo in project atlas by alibaba.

the class ExternalComponentIntentResolver method newResult.

@Override
protected ResolveInfo newResult(IntentFilter info, int match) {
    try {
        Object activity = AtlasHacks.PackageParser$ActivityIntentInfo_activity.get(info);
        ActivityInfo ai = (ActivityInfo) activity.getClass().getField("info").get(activity);
        if (ai == null) {
            return null;
        }
        final ResolveInfo res = new ResolveInfo();
        res.activityInfo = ai;
        if ((mFlags & PackageManager.GET_RESOLVED_FILTER) != 0) {
            res.filter = (IntentFilter) info;
        }
        res.priority = ((IntentFilter) info).getPriority();
        res.preferredOrder = 0;
        //System.out.println("Result: " + res.activityInfo.className +
        //                   " = " + res.priority);
        res.match = match;
        res.isDefault = true;
        res.labelRes = 0;
        res.nonLocalizedLabel = null;
        res.icon = 0;
        return res;
    } catch (Exception e) {
        return null;
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 22 with ResolveInfo

use of android.content.pm.ResolveInfo in project android_frameworks_base by ParanoidAndroid.

the class UsbResolverActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    Intent intent = getIntent();
    Parcelable targetParcelable = intent.getParcelableExtra(Intent.EXTRA_INTENT);
    if (!(targetParcelable instanceof Intent)) {
        Log.w("UsbResolverActivity", "Target is not an intent: " + targetParcelable);
        finish();
        return;
    }
    Intent target = (Intent) targetParcelable;
    ArrayList<ResolveInfo> rList = intent.getParcelableArrayListExtra(EXTRA_RESOLVE_INFOS);
    CharSequence title = getResources().getText(com.android.internal.R.string.chooseUsbActivity);
    super.onCreate(savedInstanceState, target, title, null, rList, true);
    CheckBox alwaysUse = (CheckBox) findViewById(com.android.internal.R.id.alwaysUse);
    if (alwaysUse != null) {
        if (mDevice == null) {
            alwaysUse.setText(R.string.always_use_accessory);
        } else {
            alwaysUse.setText(R.string.always_use_device);
        }
    }
    mDevice = (UsbDevice) target.getParcelableExtra(UsbManager.EXTRA_DEVICE);
    if (mDevice != null) {
        mDisconnectedReceiver = new UsbDisconnectedReceiver(this, mDevice);
    } else {
        mAccessory = (UsbAccessory) target.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
        if (mAccessory == null) {
            Log.e(TAG, "no device or accessory");
            finish();
            return;
        }
        mDisconnectedReceiver = new UsbDisconnectedReceiver(this, mAccessory);
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) CheckBox(android.widget.CheckBox) Intent(android.content.Intent) Parcelable(android.os.Parcelable)

Example 23 with ResolveInfo

use of android.content.pm.ResolveInfo in project android_frameworks_base by ParanoidAndroid.

the class PhoneWindowManager method createHomeDockIntent.

/**
     * Return an Intent to launch the currently active dock app as home.  Returns
     * null if the standard home should be launched, which is the case if any of the following is
     * true:
     * <ul>
     *  <li>The device is not in either car mode or desk mode
     *  <li>The device is in car mode but ENABLE_CAR_DOCK_HOME_CAPTURE is false
     *  <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false
     *  <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME
     *  <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME
     * </ul>
     * @return
     */
Intent createHomeDockIntent() {
    Intent intent = null;
    // of whether we are actually in a car dock.
    if (mUiMode == Configuration.UI_MODE_TYPE_CAR) {
        if (ENABLE_CAR_DOCK_HOME_CAPTURE) {
            intent = mCarDockIntent;
        }
    } else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) {
        if (ENABLE_DESK_DOCK_HOME_CAPTURE) {
            intent = mDeskDockIntent;
        }
    }
    if (intent == null) {
        return null;
    }
    ActivityInfo ai = null;
    ResolveInfo info = mContext.getPackageManager().resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY, UserHandle.USER_CURRENT);
    if (info != null) {
        ai = info.activityInfo;
    }
    if (ai != null && ai.metaData != null && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) {
        intent = new Intent(intent);
        intent.setClassName(ai.packageName, ai.name);
        return intent;
    }
    return null;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) Intent(android.content.Intent)

Example 24 with ResolveInfo

use of android.content.pm.ResolveInfo in project android_frameworks_base by ParanoidAndroid.

the class KeyguardActivityLauncher method wouldLaunchResolverActivity.

private boolean wouldLaunchResolverActivity(Intent intent) {
    PackageManager packageManager = getContext().getPackageManager();
    ResolveInfo resolved = packageManager.resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY, getLockPatternUtils().getCurrentUser());
    List<ResolveInfo> appList = packageManager.queryIntentActivitiesAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY, getLockPatternUtils().getCurrentUser());
    return wouldLaunchResolverActivity(resolved, appList);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager)

Example 25 with ResolveInfo

use of android.content.pm.ResolveInfo in project android_frameworks_base by ParanoidAndroid.

the class AppWidgetServiceImpl method loadAppWidgetListLocked.

void loadAppWidgetListLocked() {
    Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
    try {
        List<ResolveInfo> broadcastReceivers = mPm.queryIntentReceivers(intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), PackageManager.GET_META_DATA, mUserId);
        final int N = broadcastReceivers == null ? 0 : broadcastReceivers.size();
        for (int i = 0; i < N; i++) {
            ResolveInfo ri = broadcastReceivers.get(i);
            addProviderLocked(ri);
        }
    } catch (RemoteException re) {
    // Shouldn't happen, local call
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Aggregations

ResolveInfo (android.content.pm.ResolveInfo)2316 Intent (android.content.Intent)1476 PackageManager (android.content.pm.PackageManager)875 ComponentName (android.content.ComponentName)637 ArrayList (java.util.ArrayList)515 ActivityInfo (android.content.pm.ActivityInfo)360 Test (org.junit.Test)282 ServiceInfo (android.content.pm.ServiceInfo)203 PendingIntent (android.app.PendingIntent)183 ApplicationInfo (android.content.pm.ApplicationInfo)178 RemoteException (android.os.RemoteException)170 Context (android.content.Context)101 Bundle (android.os.Bundle)97 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)81 IOException (java.io.IOException)78 PackageInfo (android.content.pm.PackageInfo)68 HashSet (java.util.HashSet)65 HashMap (java.util.HashMap)63 ActivityNotFoundException (android.content.ActivityNotFoundException)59 EphemeralResolveInfo (android.content.pm.EphemeralResolveInfo)58