Search in sources :

Example 86 with ApplicationInfo

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();
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) NotFoundException(android.content.res.Resources.NotFoundException)

Example 87 with ApplicationInfo

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);
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) ArrayList(java.util.ArrayList) UserInfo(android.content.pm.UserInfo) VolumeInfo(android.os.storage.VolumeInfo) CountDownLatch(java.util.concurrent.CountDownLatch) InvocationOnMock(org.mockito.invocation.InvocationOnMock) PackageStats(android.content.pm.PackageStats) IPackageStatsObserver(android.content.pm.IPackageStatsObserver) Test(org.junit.Test)

Example 88 with ApplicationInfo

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);
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo)

Example 89 with ApplicationInfo

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);
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo)

Example 90 with ApplicationInfo

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;
}
Also used : PackageInfo(android.content.pm.PackageInfo) ApplicationInfo(android.content.pm.ApplicationInfo)

Aggregations

ApplicationInfo (android.content.pm.ApplicationInfo)1914 PackageManager (android.content.pm.PackageManager)682 Test (org.junit.Test)366 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)363 ArrayList (java.util.ArrayList)258 Intent (android.content.Intent)231 RemoteException (android.os.RemoteException)229 PackageInfo (android.content.pm.PackageInfo)214 ResolveInfo (android.content.pm.ResolveInfo)177 IOException (java.io.IOException)122 ActivityInfo (android.content.pm.ActivityInfo)114 IPackageManager (android.content.pm.IPackageManager)109 UserHandle (android.os.UserHandle)108 Context (android.content.Context)103 Bundle (android.os.Bundle)103 File (java.io.File)100 Drawable (android.graphics.drawable.Drawable)91 UserInfo (android.content.pm.UserInfo)89 ComponentName (android.content.ComponentName)69 SmallTest (android.support.test.filters.SmallTest)66