use of android.content.pm.ApplicationInfo in project android_frameworks_base by ResurrectionRemix.
the class WallpaperInfo method loadContextDescription.
/**
* Retrieves a title of the URI that specifies a link for further context about this wallpaper.
*
* @param pm An instance of {@link PackageManager} to retrieve the title.
* @return The title.
*/
public CharSequence loadContextDescription(PackageManager pm) throws NotFoundException {
if (mContextDescriptionResource <= 0)
throw new NotFoundException();
String packageName = mService.resolvePackageName;
ApplicationInfo applicationInfo = null;
if (packageName == null) {
packageName = mService.serviceInfo.packageName;
applicationInfo = mService.serviceInfo.applicationInfo;
}
return pm.getText(packageName, mContextDescriptionResource, applicationInfo).toString();
}
use of android.content.pm.ApplicationInfo in project android_frameworks_base by ResurrectionRemix.
the class AppCollectorTest method testMultipleUsersOneApp.
@Test
public void testMultipleUsersOneApp() throws Exception {
addApplication("com.test.app", "testuuid");
ApplicationInfo otherUsersApp = new ApplicationInfo();
otherUsersApp.packageName = "com.test.app";
otherUsersApp.volumeUuid = "testuuid";
otherUsersApp.uid = 1;
mUsers.add(new UserInfo(1, "", 0));
VolumeInfo volume = new VolumeInfo("testuuid", 0, null, null);
volume.fsUuid = "testuuid";
AppCollector collector = new AppCollector(mContext, volume);
PackageStats stats = new PackageStats("com.test.app");
PackageStats otherStats = new PackageStats("com.test.app");
otherStats.userHandle = 1;
// Set up this to handle the asynchronous call to the PackageManager. This returns the
// package info for our packages.
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) {
try {
((IPackageStatsObserver.Stub) invocation.getArguments()[2]).onGetStatsCompleted(stats, true);
// Now callback for the other uid.
((IPackageStatsObserver.Stub) invocation.getArguments()[2]).onGetStatsCompleted(otherStats, true);
} catch (Exception e) {
// We fail instead of just letting the exception fly because throwing
// out of the callback like this on the background thread causes the test
// runner to crash, rather than reporting the failure.
fail();
}
return null;
}
}).when(mPm).getPackageSizeInfoAsUser(eq("com.test.app"), eq(0), any());
// Because getPackageStats is a blocking call, we block execution of the test until the
// call finishes. In order to finish the call, we need the above answer to execute.
List<PackageStats> myStats = new ArrayList<>();
CountDownLatch latch = new CountDownLatch(1);
new Thread(new Runnable() {
@Override
public void run() {
myStats.addAll(collector.getPackageStats(TIMEOUT));
latch.countDown();
}
}).start();
latch.await();
assertThat(myStats).containsAllOf(stats, otherStats);
}
use of android.content.pm.ApplicationInfo in project android_frameworks_base by ResurrectionRemix.
the class AppCollectorTest method addApplication.
private void addApplication(String packageName, String uuid) {
ApplicationInfo info = new ApplicationInfo();
info.packageName = packageName;
info.volumeUuid = uuid;
mApps.add(info);
}
use of android.content.pm.ApplicationInfo in project android_frameworks_base by ResurrectionRemix.
the class ShortcutManagerTest5 method testGetApplicationInfo.
public void testGetApplicationInfo() {
ApplicationInfo ai = mShortcutService.getApplicationInfo(mMyPackage, mMyUserId);
assertEquals(mMyPackage, ai.packageName);
ai = mShortcutService.getApplicationInfo("no.such.package", mMyUserId);
assertNull(ai);
}
use of android.content.pm.ApplicationInfo in project android_frameworks_base by ResurrectionRemix.
the class BackupUtilsTest method genPackage.
private PackageInfo genPackage(String... signatures) {
final PackageInfo pi = new PackageInfo();
pi.packageName = "package";
pi.applicationInfo = new ApplicationInfo();
pi.signatures = genSignatures(signatures);
return pi;
}
Aggregations