Search in sources :

Example 51 with ApplicationInfo

use of android.content.pm.ApplicationInfo in project android_frameworks_base by ResurrectionRemix.

the class UsageStatsService method getIdleUidsForUser.

int[] getIdleUidsForUser(int userId) {
    if (!mAppIdleEnabled) {
        return new int[0];
    }
    final long elapsedRealtime = SystemClock.elapsedRealtime();
    List<ApplicationInfo> apps;
    try {
        ParceledListSlice<ApplicationInfo> slice = AppGlobals.getPackageManager().getInstalledApplications(/* flags= */
        0, userId);
        if (slice == null) {
            return new int[0];
        }
        apps = slice.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
    // State of each uid.  Key is the uid.  Value lower 16 bits is the number of apps
    // associated with that uid, upper 16 bits is the number of those apps that is idle.
    SparseIntArray uidStates = new SparseIntArray();
    // we find for each uid and how many of those are idle.
    for (int i = apps.size() - 1; i >= 0; i--) {
        ApplicationInfo ai = apps.get(i);
        // Check whether this app is idle.
        boolean idle = isAppIdleFiltered(ai.packageName, UserHandle.getAppId(ai.uid), userId, elapsedRealtime);
        int index = uidStates.indexOfKey(ai.uid);
        if (index < 0) {
            uidStates.put(ai.uid, 1 + (idle ? 1 << 16 : 0));
        } else {
            int value = uidStates.valueAt(index);
            uidStates.setValueAt(index, value + 1 + (idle ? 1 << 16 : 0));
        }
    }
    if (DEBUG) {
        Slog.d(TAG, "getIdleUids took " + (SystemClock.elapsedRealtime() - elapsedRealtime));
    }
    int numIdle = 0;
    for (int i = uidStates.size() - 1; i >= 0; i--) {
        int value = uidStates.valueAt(i);
        if ((value & 0x7fff) == (value >> 16)) {
            numIdle++;
        }
    }
    int[] res = new int[numIdle];
    numIdle = 0;
    for (int i = uidStates.size() - 1; i >= 0; i--) {
        int value = uidStates.valueAt(i);
        if ((value & 0x7fff) == (value >> 16)) {
            res[numIdle] = uidStates.keyAt(i);
            numIdle++;
        }
    }
    return res;
}
Also used : SparseIntArray(android.util.SparseIntArray) ApplicationInfo(android.content.pm.ApplicationInfo) RemoteException(android.os.RemoteException)

Example 52 with ApplicationInfo

use of android.content.pm.ApplicationInfo in project android_frameworks_base by ResurrectionRemix.

the class DpiTestActivity method init.

public void init(boolean noCompat) {
    try {
        // This is all a dirty hack.  Don't think a real application should
        // be doing it.
        Application app = ActivityThread.currentActivityThread().getApplication();
        ApplicationInfo ai = app.getPackageManager().getApplicationInfo("com.google.android.test.dpi", 0);
        if (noCompat) {
            ai.flags |= ApplicationInfo.FLAG_SUPPORTS_XLARGE_SCREENS | ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS | ApplicationInfo.FLAG_SUPPORTS_NORMAL_SCREENS | ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS | ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS | ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES;
            app.getResources().setCompatibilityInfo(new CompatibilityInfo(ai, getResources().getConfiguration().screenLayout, getResources().getConfiguration().smallestScreenWidthDp, false));
        }
    } catch (PackageManager.NameNotFoundException e) {
        throw new RuntimeException("ouch", e);
    }
}
Also used : PackageManager(android.content.pm.PackageManager) ApplicationInfo(android.content.pm.ApplicationInfo) CompatibilityInfo(android.content.res.CompatibilityInfo) Application(android.app.Application)

Example 53 with ApplicationInfo

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

Example 54 with ApplicationInfo

use of android.content.pm.ApplicationInfo in project LshUtils by SenhLinsh.

the class LshLogUtils method checkDebugMode.

private static boolean checkDebugMode() {
    ApplicationInfo applicationInfo = LshApplicationUtils.getContext().getApplicationInfo();
    boolean debug = applicationInfo != null && (applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
    Log.i("LshLog", "checkDebugMode: " + debug);
    return debug;
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo)

Example 55 with ApplicationInfo

use of android.content.pm.ApplicationInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ExpandedDesktop method handleAppEntries.

private void handleAppEntries(List<ApplicationsState.AppEntry> entries) {
    String lastSectionIndex = null;
    ArrayList<String> sections = new ArrayList<String>();
    ArrayList<Integer> positions = new ArrayList<Integer>();
    PackageManager pm = getPackageManager();
    int count = entries.size(), offset = 0;
    for (int i = 0; i < count; i++) {
        ApplicationInfo info = entries.get(i).info;
        String label = (String) info.loadLabel(pm);
        String sectionIndex;
        if (!info.enabled) {
            sectionIndex = "--";
        } else if (TextUtils.isEmpty(label)) {
            sectionIndex = "";
        } else {
            sectionIndex = label.substring(0, 1).toUpperCase();
        }
        if (lastSectionIndex == null || !TextUtils.equals(sectionIndex, lastSectionIndex)) {
            sections.add(sectionIndex);
            positions.add(offset);
            lastSectionIndex = sectionIndex;
        }
        offset++;
    }
    mAllPackagesAdapter.setEntries(entries, sections, positions);
    mEntryMap.clear();
    for (ApplicationsState.AppEntry e : entries) {
        mEntryMap.put(e.info.packageName, e);
    }
    if (mProgressBar != null) {
        mProgressBar.setVisibility(View.GONE);
    }
    if (mExpandedDesktopState != STATE_USER_CONFIGURABLE) {
        hideListView();
    }
}
Also used : PackageManager(android.content.pm.PackageManager) ApplicationsState(com.android.settingslib.applications.ApplicationsState) ArrayList(java.util.ArrayList) ApplicationInfo(android.content.pm.ApplicationInfo) AppEntry(com.android.settingslib.applications.ApplicationsState.AppEntry)

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