Search in sources :

Example 91 with ActivityInfo

use of android.content.pm.ActivityInfo in project android_frameworks_base by DirtyUnicorns.

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 mEnableCarDockHomeCapture 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 A dock intent.
     */
Intent createHomeDockIntent() {
    Intent intent = null;
    // of whether we are actually in a car dock.
    if (mUiMode == Configuration.UI_MODE_TYPE_CAR) {
        if (mEnableCarDockHomeCapture) {
            intent = mCarDockIntent;
        }
    } else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) {
        if (ENABLE_DESK_DOCK_HOME_CAPTURE) {
            intent = mDeskDockIntent;
        }
    } else if (mUiMode == Configuration.UI_MODE_TYPE_WATCH && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK)) {
        // Always launch dock home from home when watch is docked, if it exists.
        intent = mDeskDockIntent;
    }
    if (intent == null) {
        return null;
    }
    ActivityInfo ai = null;
    ResolveInfo info = mContext.getPackageManager().resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA, mCurrentUserId);
    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) RecognizerIntent(android.speech.RecognizerIntent)

Example 92 with ActivityInfo

use of android.content.pm.ActivityInfo in project android_frameworks_base by DirtyUnicorns.

the class BaseShortcutManagerTest method ri.

protected static ResolveInfo ri(String packageName, String name, boolean isSystem, int priority) {
    final ResolveInfo ri = new ResolveInfo();
    ri.activityInfo = new ActivityInfo();
    ri.activityInfo.applicationInfo = new ApplicationInfo();
    ri.activityInfo.packageName = packageName;
    ri.activityInfo.name = name;
    if (isSystem) {
        ri.activityInfo.applicationInfo.flags |= ApplicationInfo.FLAG_SYSTEM;
    }
    ri.priority = priority;
    return ri;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) ApplicationInfo(android.content.pm.ApplicationInfo)

Example 93 with ActivityInfo

use of android.content.pm.ActivityInfo in project android_frameworks_base by DirtyUnicorns.

the class BaseShortcutManagerTest method injectGetActivitiesWithMetadata.

protected PackageInfo injectGetActivitiesWithMetadata(String packageName, @UserIdInt int userId) {
    final PackageInfo ret = getInjectedPackageInfo(packageName, userId, /* getSignatures=*/
    false);
    final HashMap<ComponentName, Integer> activities = mActivityMetadataResId.get(packageName);
    if (activities != null) {
        final ArrayList<ActivityInfo> list = new ArrayList<>();
        for (ComponentName cn : activities.keySet()) {
            ActivityInfo ai = new ActivityInfo();
            ai.packageName = cn.getPackageName();
            ai.name = cn.getClassName();
            ai.metaData = new Bundle();
            ai.metaData.putInt(ShortcutParser.METADATA_KEY, activities.get(cn));
            ai.applicationInfo = ret.applicationInfo;
            list.add(ai);
        }
        ret.activities = list.toArray(new ActivityInfo[list.size()]);
    }
    return ret;
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) PackageInfo(android.content.pm.PackageInfo) Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle) ShortcutManagerTestUtils.makeBundle(com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.makeBundle) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName)

Example 94 with ActivityInfo

use of android.content.pm.ActivityInfo in project android_frameworks_base by DirtyUnicorns.

the class SuggestionsAdapter method getActivityIcon.

/**
     * Gets the activity or application icon for an activity.
     *
     * @param component Name of an activity.
     * @return A drawable, or {@code null} if neither the acitivy or the application
     *         have an icon set.
     */
private Drawable getActivityIcon(ComponentName component) {
    PackageManager pm = mContext.getPackageManager();
    final ActivityInfo activityInfo;
    try {
        activityInfo = pm.getActivityInfo(component, PackageManager.GET_META_DATA);
    } catch (NameNotFoundException ex) {
        Log.w(LOG_TAG, ex.toString());
        return null;
    }
    int iconId = activityInfo.getIconResource();
    if (iconId == 0)
        return null;
    String pkg = component.getPackageName();
    Drawable drawable = pm.getDrawable(pkg, iconId, activityInfo.applicationInfo);
    if (drawable == null) {
        Log.w(LOG_TAG, "Invalid icon resource " + iconId + " for " + component.flattenToShortString());
        return null;
    }
    return drawable;
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) PackageManager(android.content.pm.PackageManager) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) Drawable(android.graphics.drawable.Drawable) SpannableString(android.text.SpannableString)

Example 95 with ActivityInfo

use of android.content.pm.ActivityInfo in project android_frameworks_base by DirtyUnicorns.

the class PackageManagerService method findPersistentPreferredActivityLP.

private ResolveInfo findPersistentPreferredActivityLP(Intent intent, String resolvedType, int flags, List<ResolveInfo> query, boolean debug, int userId) {
    final int N = query.size();
    PersistentPreferredIntentResolver ppir = mSettings.mPersistentPreferredActivities.get(userId);
    // Get the list of persistent preferred activities that handle the intent
    if (DEBUG_PREFERRED || debug)
        Slog.v(TAG, "Looking for presistent preferred activities...");
    List<PersistentPreferredActivity> pprefs = ppir != null ? ppir.queryIntent(intent, resolvedType, (flags & PackageManager.MATCH_DEFAULT_ONLY) != 0, userId) : null;
    if (pprefs != null && pprefs.size() > 0) {
        final int M = pprefs.size();
        for (int i = 0; i < M; i++) {
            final PersistentPreferredActivity ppa = pprefs.get(i);
            if (DEBUG_PREFERRED || debug) {
                Slog.v(TAG, "Checking PersistentPreferredActivity ds=" + (ppa.countDataSchemes() > 0 ? ppa.getDataScheme(0) : "<none>") + "\n  component=" + ppa.mComponent);
                ppa.dump(new LogPrinter(Log.VERBOSE, TAG, Log.LOG_ID_SYSTEM), "  ");
            }
            final ActivityInfo ai = getActivityInfo(ppa.mComponent, flags | MATCH_DISABLED_COMPONENTS, userId);
            if (DEBUG_PREFERRED || debug) {
                Slog.v(TAG, "Found persistent preferred activity:");
                if (ai != null) {
                    ai.dump(new LogPrinter(Log.VERBOSE, TAG, Log.LOG_ID_SYSTEM), "  ");
                } else {
                    Slog.v(TAG, "  null");
                }
            }
            if (ai == null) {
                // component is no longer known. Ignore it and do NOT remove it.
                continue;
            }
            for (int j = 0; j < N; j++) {
                final ResolveInfo ri = query.get(j);
                if (!ri.activityInfo.applicationInfo.packageName.equals(ai.applicationInfo.packageName)) {
                    continue;
                }
                if (!ri.activityInfo.name.equals(ai.name)) {
                    continue;
                }
                //  Found a persistent preference that can handle the intent.
                if (DEBUG_PREFERRED || debug) {
                    Slog.v(TAG, "Returning persistent preferred activity: " + ri.activityInfo.packageName + "/" + ri.activityInfo.name);
                }
                return ri;
            }
        }
    }
    return null;
}
Also used : EphemeralResolveInfo(android.content.pm.EphemeralResolveInfo) ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) LogPrinter(android.util.LogPrinter)

Aggregations

ActivityInfo (android.content.pm.ActivityInfo)886 ResolveInfo (android.content.pm.ResolveInfo)360 Intent (android.content.Intent)339 ComponentName (android.content.ComponentName)324 PackageManager (android.content.pm.PackageManager)215 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)141 ArrayList (java.util.ArrayList)139 ApplicationInfo (android.content.pm.ApplicationInfo)115 Test (org.junit.Test)113 RemoteException (android.os.RemoteException)82 Bundle (android.os.Bundle)68 PendingIntent (android.app.PendingIntent)62 Drawable (android.graphics.drawable.Drawable)61 IOException (java.io.IOException)60 PackageInfo (android.content.pm.PackageInfo)59 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)54 XmlResourceParser (android.content.res.XmlResourceParser)43 Point (android.graphics.Point)35 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)34 Context (android.content.Context)33