use of android.app.ActivityManager in project android_frameworks_base by ParanoidAndroid.
the class MemoryUsageTest method getPss.
private int getPss(String processName) {
ActivityManager am = (ActivityManager) getInstrumentation().getContext().getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> apps = am.getRunningAppProcesses();
for (RunningAppProcessInfo proc : apps) {
if (!proc.processName.equals(processName)) {
continue;
}
int[] pids = { proc.pid };
MemoryInfo meminfo = am.getProcessMemoryInfo(pids)[0];
return meminfo.getTotalPss();
}
return -1;
}
use of android.app.ActivityManager in project android_frameworks_base by ParanoidAndroid.
the class ExtendedPropertiesUtils method getAppInfoFromPID.
/**
* Returns an {@link ApplicationInfo}, with the given PID.
*
* @param pid the application PID
* @return application info
*/
public static ApplicationInfo getAppInfoFromPID(int pid) {
if (isInitialized()) {
List mProcessList = ((ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE)).getRunningAppProcesses();
Iterator mProcessListIt = mProcessList.iterator();
while (mProcessListIt.hasNext()) {
ActivityManager.RunningAppProcessInfo mAppInfo = (ActivityManager.RunningAppProcessInfo) (mProcessListIt.next());
if (mAppInfo.pid == pid) {
return getAppInfoFromPackageName(mAppInfo.processName);
}
}
}
return null;
}
use of android.app.ActivityManager in project android_frameworks_base by ParanoidAndroid.
the class RecentTasksLoader method loadThumbnailAndIcon.
void loadThumbnailAndIcon(TaskDescription td) {
final ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
final PackageManager pm = mContext.getPackageManager();
Bitmap thumbnail = am.getTaskTopThumbnail(td.persistentTaskId);
Drawable icon = getFullResIcon(td.resolveInfo, pm);
if (DEBUG)
Log.v(TAG, "Loaded bitmap for task " + td + ": " + thumbnail);
synchronized (td) {
if (thumbnail != null) {
td.setThumbnail(thumbnail);
} else {
td.setThumbnail(mDefaultThumbnailBackground);
}
if (icon != null) {
td.setIcon(icon);
}
td.setLoaded(true);
}
}
use of android.app.ActivityManager in project android_frameworks_base by ParanoidAndroid.
the class RecentsPanelView method handleSwipe.
public void handleSwipe(View view) {
TaskDescription ad = ((ViewHolder) view.getTag()).taskDescription;
if (ad == null) {
Log.v(TAG, "Not able to find activity description for swiped task; view=" + view + " tag=" + view.getTag());
return;
}
if (DEBUG)
Log.v(TAG, "Jettison " + ad.getLabel());
mRecentTaskDescriptions.remove(ad);
mRecentTasksLoader.remove(ad);
if (mRecentTaskDescriptions.size() == 0) {
dismissAndGoBack();
}
// Currently, either direction means the same thing, so ignore direction and remove
// the task.
final ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
if (am != null) {
am.removeTask(ad.persistentTaskId, ActivityManager.REMOVE_TASK_KILL_PROCESS);
// Accessibility feedback
setContentDescription(mContext.getString(R.string.accessibility_recents_item_dismissed, ad.getLabel()));
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
setContentDescription(null);
}
}
use of android.app.ActivityManager in project android_frameworks_base by ParanoidAndroid.
the class RecentsPanelView method handleOnClick.
public void handleOnClick(View view) {
ViewHolder holder = (ViewHolder) view.getTag();
TaskDescription ad = holder.taskDescription;
final Context context = view.getContext();
final ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
Bitmap bm = holder.thumbnailViewImageBitmap;
boolean usingDrawingCache;
if (bm.getWidth() == holder.thumbnailViewImage.getWidth() && bm.getHeight() == holder.thumbnailViewImage.getHeight()) {
usingDrawingCache = false;
} else {
holder.thumbnailViewImage.setDrawingCacheEnabled(true);
bm = holder.thumbnailViewImage.getDrawingCache();
usingDrawingCache = true;
}
Bundle opts = (bm == null) ? null : ActivityOptions.makeThumbnailScaleUpAnimation(holder.thumbnailViewImage, bm, 0, 0, null).toBundle();
show(false);
Intent intent = ad.intent;
boolean floating = (intent.getFlags() & Intent.FLAG_FLOATING_WINDOW) == Intent.FLAG_FLOATING_WINDOW;
if (ad.taskId >= 0 && !floating) {
// This is an active task; it should just go to the foreground.
am.moveTaskToFront(ad.taskId, ActivityManager.MOVE_TASK_WITH_HOME, opts);
} else {
boolean backPressed = mRecentsActivity != null && mRecentsActivity.mBackPressed;
if (!floating || !backPressed) {
intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY | Intent.FLAG_ACTIVITY_TASK_ON_HOME | Intent.FLAG_ACTIVITY_NEW_TASK);
}
if (DEBUG)
Log.v(TAG, "Starting activity " + intent);
if (floating && mRecentsActivity != null) {
mRecentsActivity.finish();
}
try {
context.startActivityAsUser(intent, opts, new UserHandle(UserHandle.USER_CURRENT));
} catch (SecurityException e) {
Log.e(TAG, "Recents does not have the permission to launch " + intent, e);
}
}
if (usingDrawingCache) {
holder.thumbnailViewImage.setDrawingCacheEnabled(false);
}
}
Aggregations