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