use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.
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 ResurrectionRemix.
the class DpmTestBase method setUpPackageManagerForFakeAdmin.
/**
* Set up a component in the mock package manager to be an active admin.
*
* @param admin ComponentName that's visible to the test code, which doesn't have to exist.
* @param copyFromAdmin package information for {@code admin} will be built based on this
* component's information.
*/
protected void setUpPackageManagerForFakeAdmin(ComponentName admin, int packageUid, Integer enabledSetting, Integer appTargetSdk, ComponentName copyFromAdmin) throws Exception {
// Set up getApplicationInfo().
final ApplicationInfo ai = DpmTestUtils.cloneParcelable(mRealTestContext.getPackageManager().getApplicationInfo(copyFromAdmin.getPackageName(), PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS));
ai.enabledSetting = enabledSetting == null ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED : enabledSetting;
if (appTargetSdk != null) {
ai.targetSdkVersion = appTargetSdk;
}
ai.uid = packageUid;
ai.packageName = admin.getPackageName();
ai.name = admin.getClassName();
doReturn(ai).when(mMockContext.ipackageManager).getApplicationInfo(eq(admin.getPackageName()), anyInt(), eq(UserHandle.getUserId(packageUid)));
// Set up queryBroadcastReceivers().
final Intent resolveIntent = new Intent();
resolveIntent.setComponent(copyFromAdmin);
final List<ResolveInfo> realResolveInfo = mRealTestContext.getPackageManager().queryBroadcastReceivers(resolveIntent, PackageManager.GET_META_DATA);
assertNotNull(realResolveInfo);
assertEquals(1, realResolveInfo.size());
// We need to change AI, so set a clone.
realResolveInfo.set(0, DpmTestUtils.cloneParcelable(realResolveInfo.get(0)));
// We need to rewrite the UID in the activity info.
final ActivityInfo aci = realResolveInfo.get(0).activityInfo;
aci.applicationInfo = ai;
aci.packageName = admin.getPackageName();
aci.name = admin.getClassName();
// Note we don't set up queryBroadcastReceivers. We don't use it in DPMS.
doReturn(aci).when(mMockContext.ipackageManager).getReceiverInfo(eq(admin), anyInt(), eq(UserHandle.getUserId(packageUid)));
// Set up getPackageInfo().
markPackageAsInstalled(admin.getPackageName(), ai, UserHandle.getUserId(packageUid));
}
use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.
the class ActivityUnitTestCase method startActivity.
/**
* Start the activity under test, in the same way as if it was started by
* {@link android.content.Context#startActivity Context.startActivity()}, providing the
* arguments it supplied. When you use this method to start the activity, it will automatically
* be stopped by {@link #tearDown}.
*
* <p>This method will call onCreate(), but if you wish to further exercise Activity life
* cycle methods, you must call them yourself from your test case.
*
* <p><i>Do not call from your setUp() method. You must call this method from each of your
* test methods.</i>
*
* @param intent The Intent as if supplied to {@link android.content.Context#startActivity}.
* @param savedInstanceState The instance state, if you are simulating this part of the life
* cycle. Typically null.
* @param lastNonConfigurationInstance This Object will be available to the
* Activity if it calls {@link android.app.Activity#getLastNonConfigurationInstance()}.
* Typically null.
* @return Returns the Activity that was created
*/
protected T startActivity(Intent intent, Bundle savedInstanceState, Object lastNonConfigurationInstance) {
assertFalse("Activity already created", mCreated);
if (!mAttached) {
assertNotNull(mActivityClass);
setActivity(null);
T newActivity = null;
try {
IBinder token = null;
if (mApplication == null) {
setApplication(new MockApplication());
}
ComponentName cn = new ComponentName(mActivityClass.getPackage().getName(), mActivityClass.getName());
intent.setComponent(cn);
ActivityInfo info = new ActivityInfo();
CharSequence title = mActivityClass.getName();
mMockParent = new MockParent();
String id = null;
newActivity = (T) getInstrumentation().newActivity(mActivityClass, mActivityContext, token, mApplication, intent, info, title, mMockParent, id, lastNonConfigurationInstance);
} catch (Exception e) {
Log.w(TAG, "Catching exception", e);
assertNotNull(newActivity);
}
assertNotNull(newActivity);
setActivity(newActivity);
mAttached = true;
}
T result = getActivity();
if (result != null) {
getInstrumentation().callActivityOnCreate(getActivity(), savedInstanceState);
mCreated = true;
}
return result;
}
use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.
the class DefaultDialerManager method getInstalledDialerApplications.
/**
* Returns a list of installed and available dialer applications.
*
* In order to appear in the list, a dialer application must implement an intent-filter with
* the DIAL intent for the following schemes:
*
* 1) Empty scheme
* 2) tel Uri scheme
*
* @hide
**/
public static List<String> getInstalledDialerApplications(Context context, int userId) {
PackageManager packageManager = context.getPackageManager();
// Get the list of apps registered for the DIAL intent with empty scheme
Intent intent = new Intent(Intent.ACTION_DIAL);
List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivitiesAsUser(intent, 0, userId);
List<String> packageNames = new ArrayList<>();
for (ResolveInfo resolveInfo : resolveInfoList) {
final ActivityInfo activityInfo = resolveInfo.activityInfo;
if (activityInfo != null && !packageNames.contains(activityInfo.packageName)) {
packageNames.add(activityInfo.packageName);
}
}
final Intent dialIntentWithTelScheme = new Intent(Intent.ACTION_DIAL);
dialIntentWithTelScheme.setData(Uri.fromParts(PhoneAccount.SCHEME_TEL, "", null));
return filterByIntent(context, packageNames, dialIntentWithTelScheme);
}
use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.
the class ActivityStack method findTaskLocked.
/**
* Returns the top activity in any existing task matching the given Intent in the input result.
* Returns null if no such task is found.
*/
void findTaskLocked(ActivityRecord target, FindTaskResult result) {
Intent intent = target.intent;
ActivityInfo info = target.info;
ComponentName cls = intent.getComponent();
if (info.targetActivity != null) {
cls = new ComponentName(info.packageName, info.targetActivity);
}
final int userId = UserHandle.getUserId(info.applicationInfo.uid);
boolean isDocument = intent != null & intent.isDocument();
// If documentData is non-null then it must match the existing task data.
Uri documentData = isDocument ? intent.getData() : null;
if (DEBUG_TASKS)
Slog.d(TAG_TASKS, "Looking for task of " + target + " in " + this);
for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
final TaskRecord task = mTaskHistory.get(taskNdx);
if (task.voiceSession != null) {
// We never match voice sessions; those always run independently.
if (DEBUG_TASKS)
Slog.d(TAG_TASKS, "Skipping " + task + ": voice session");
continue;
}
if (task.userId != userId) {
// Looking for a different task.
if (DEBUG_TASKS)
Slog.d(TAG_TASKS, "Skipping " + task + ": different user");
continue;
}
final ActivityRecord r = task.getTopActivity();
if (r == null || r.finishing || r.userId != userId || r.launchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE) {
if (DEBUG_TASKS)
Slog.d(TAG_TASKS, "Skipping " + task + ": mismatch root " + r);
continue;
}
if (r.mActivityType != target.mActivityType) {
if (DEBUG_TASKS)
Slog.d(TAG_TASKS, "Skipping " + task + ": mismatch activity type");
continue;
}
final Intent taskIntent = task.intent;
final Intent affinityIntent = task.affinityIntent;
final boolean taskIsDocument;
final Uri taskDocumentData;
if (taskIntent != null && taskIntent.isDocument()) {
taskIsDocument = true;
taskDocumentData = taskIntent.getData();
} else if (affinityIntent != null && affinityIntent.isDocument()) {
taskIsDocument = true;
taskDocumentData = affinityIntent.getData();
} else {
taskIsDocument = false;
taskDocumentData = null;
}
if (DEBUG_TASKS)
Slog.d(TAG_TASKS, "Comparing existing cls=" + taskIntent.getComponent().flattenToShortString() + "/aff=" + r.task.rootAffinity + " to new cls=" + intent.getComponent().flattenToShortString() + "/aff=" + info.taskAffinity);
// TODO Refactor to remove duplications. Check if logic can be simplified.
if (taskIntent != null && taskIntent.getComponent() != null && taskIntent.getComponent().compareTo(cls) == 0 && Objects.equals(documentData, taskDocumentData)) {
if (DEBUG_TASKS)
Slog.d(TAG_TASKS, "Found matching class!");
//dump();
if (DEBUG_TASKS)
Slog.d(TAG_TASKS, "For Intent " + intent + " bringing to top: " + r.intent);
result.r = r;
result.matchedByRootAffinity = false;
break;
} else if (affinityIntent != null && affinityIntent.getComponent() != null && affinityIntent.getComponent().compareTo(cls) == 0 && Objects.equals(documentData, taskDocumentData)) {
if (DEBUG_TASKS)
Slog.d(TAG_TASKS, "Found matching class!");
//dump();
if (DEBUG_TASKS)
Slog.d(TAG_TASKS, "For Intent " + intent + " bringing to top: " + r.intent);
result.r = r;
result.matchedByRootAffinity = false;
break;
} else if (!isDocument && !taskIsDocument && result.r == null && task.canMatchRootAffinity()) {
if (task.rootAffinity.equals(target.taskAffinity)) {
if (DEBUG_TASKS)
Slog.d(TAG_TASKS, "Found matching affinity candidate!");
// It is possible for multiple tasks to have the same root affinity especially
// if they are in separate stacks. We save off this candidate, but keep looking
// to see if there is a better candidate.
result.r = r;
result.matchedByRootAffinity = true;
}
} else if (DEBUG_TASKS)
Slog.d(TAG_TASKS, "Not a match: " + task);
}
}
Aggregations