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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations