summaryrefslogtreecommitdiffstats
path: root/core/java/android/app
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2009-08-31 21:31:47 -0700
committerDianne Hackborn <hackbod@google.com>2009-09-01 11:16:25 -0700
commit3025ef332c29e255388f74b2afefe05f64bce07c (patch)
treeb7982d9ebe8a578b5b439c564c014a9af8be952f /core/java/android/app
parentd9942b5cb1662638bb6fb57c12a06976e3c34651 (diff)
downloadframeworks_base-3025ef332c29e255388f74b2afefe05f64bce07c.zip
frameworks_base-3025ef332c29e255388f74b2afefe05f64bce07c.tar.gz
frameworks_base-3025ef332c29e255388f74b2afefe05f64bce07c.tar.bz2
Various infrastructure to support a running services UI.
Some of this is temporary (in particular the two approaches for getting process memory, one working but horrible, the other not working but preferred) until I figure out the best way to do it. Change-Id: I8c8f25062d481fcea22a47d459b083d2fd8a5040
Diffstat (limited to 'core/java/android/app')
-rw-r--r--core/java/android/app/ActivityManager.java40
-rw-r--r--core/java/android/app/ActivityManagerNative.java26
-rw-r--r--core/java/android/app/ActivityThread.java4
-rw-r--r--core/java/android/app/ApplicationThreadNative.java22
-rw-r--r--core/java/android/app/IActivityManager.java5
-rw-r--r--core/java/android/app/IApplicationThread.java3
6 files changed, 98 insertions, 2 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 07520c9d..ad06fa9 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -289,6 +289,11 @@ public class ActivityManager {
public int pid;
/**
+ * The UID that owns this service.
+ */
+ public int uid;
+
+ /**
* The name of the process this service runs in.
*/
public String process;
@@ -299,7 +304,7 @@ public class ActivityManager {
public boolean foreground;
/**
- * The time when the service was first made activity, either by someone
+ * The time when the service was first made active, either by someone
* starting or binding to it.
*/
public long activeSince;
@@ -332,6 +337,35 @@ public class ActivityManager {
*/
public long restarting;
+ /**
+ * Bit for {@link #flags}: set if this service has been
+ * explicitly started.
+ */
+ public static final int FLAG_STARTED = 1<<0;
+
+ /**
+ * Bit for {@link #flags}: set if the service has asked to
+ * run as a foreground process.
+ */
+ public static final int FLAG_FOREGROUND = 1<<1;
+
+ /**
+ * Bit for {@link #flags): set if the service is running in a
+ * core system process.
+ */
+ public static final int FLAG_SYSTEM_PROCESS = 1<<2;
+
+ /**
+ * Bit for {@link #flags): set if the service is running in a
+ * persistent process.
+ */
+ public static final int FLAG_PERSISTENT_PROCESS = 1<<3;
+
+ /**
+ * Running flags.
+ */
+ public int flags;
+
public RunningServiceInfo() {
}
@@ -342,6 +376,7 @@ public class ActivityManager {
public void writeToParcel(Parcel dest, int flags) {
ComponentName.writeToParcel(service, dest);
dest.writeInt(pid);
+ dest.writeInt(uid);
dest.writeString(process);
dest.writeInt(foreground ? 1 : 0);
dest.writeLong(activeSince);
@@ -350,11 +385,13 @@ public class ActivityManager {
dest.writeInt(crashCount);
dest.writeLong(lastActivityTime);
dest.writeLong(restarting);
+ dest.writeInt(this.flags);
}
public void readFromParcel(Parcel source) {
service = ComponentName.readFromParcel(source);
pid = source.readInt();
+ uid = source.readInt();
process = source.readString();
foreground = source.readInt() != 0;
activeSince = source.readLong();
@@ -363,6 +400,7 @@ public class ActivityManager {
crashCount = source.readInt();
lastActivityTime = source.readLong();
restarting = source.readLong();
+ flags = source.readInt();
}
public static final Creator<RunningServiceInfo> CREATOR = new Creator<RunningServiceInfo>() {
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index d14ec15..1bb21b9 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -29,6 +29,7 @@ import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
+import android.os.Debug;
import android.os.Parcelable;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
@@ -1107,6 +1108,16 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
reply.writeNoException();
return true;
}
+
+ case GET_PROCESS_MEMORY_INFO_TRANSACTION: {
+ data.enforceInterface(IActivityManager.descriptor);
+ int pid = data.readInt();
+ Debug.MemoryInfo mi = new Debug.MemoryInfo();
+ getProcessMemoryInfo(pid, mi);
+ reply.writeNoException();
+ mi.writeToParcel(reply, 0);
+ return true;
+ }
}
return super.onTransact(code, data, reply, flags);
@@ -2424,6 +2435,19 @@ class ActivityManagerProxy implements IActivityManager
data.recycle();
reply.recycle();
}
-
+
+ public void getProcessMemoryInfo(int pid, Debug.MemoryInfo outInfo)
+ throws RemoteException {
+ Parcel data = Parcel.obtain();
+ Parcel reply = Parcel.obtain();
+ data.writeInterfaceToken(IActivityManager.descriptor);
+ data.writeInt(pid);
+ mRemote.transact(GET_PROCESS_MEMORY_INFO_TRANSACTION, data, reply, 0);
+ reply.readException();
+ outInfo.readFromParcel(reply);
+ data.recycle();
+ reply.recycle();
+ }
+
private IBinder mRemote;
}
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 1e915b4..b4e57e0 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -1546,6 +1546,10 @@ public final class ActivityThread {
}
}
+ public void getMemoryInfo(Debug.MemoryInfo outInfo) {
+ Debug.getMemoryInfo(outInfo);
+ }
+
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
long nativeMax = Debug.getNativeHeapSize() / 1024;
diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java
index ad64465..15bf9ed 100644
--- a/core/java/android/app/ApplicationThreadNative.java
+++ b/core/java/android/app/ApplicationThreadNative.java
@@ -26,6 +26,7 @@ import android.content.pm.ServiceInfo;
import android.content.res.Configuration;
import android.os.Binder;
import android.os.Bundle;
+import android.os.Debug;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.IBinder;
@@ -370,6 +371,16 @@ public abstract class ApplicationThreadNative extends Binder
scheduleDestroyBackupAgent(appInfo);
return true;
}
+
+ case GET_MEMORY_INFO_TRANSACTION:
+ {
+ data.enforceInterface(IApplicationThread.descriptor);
+ Debug.MemoryInfo mi = new Debug.MemoryInfo();
+ getMemoryInfo(mi);
+ reply.writeNoException();
+ mi.writeToParcel(reply, 0);
+ return true;
+ }
}
return super.onTransact(code, data, reply, flags);
@@ -756,5 +767,16 @@ class ApplicationThreadProxy implements IApplicationThread {
IBinder.FLAG_ONEWAY);
data.recycle();
}
+
+ public void getMemoryInfo(Debug.MemoryInfo outInfo) throws RemoteException {
+ Parcel data = Parcel.obtain();
+ Parcel reply = Parcel.obtain();
+ data.writeInterfaceToken(IApplicationThread.descriptor);
+ mRemote.transact(GET_MEMORY_INFO_TRANSACTION, data, reply, 0);
+ reply.readException();
+ outInfo.readFromParcel(reply);
+ data.recycle();
+ reply.recycle();
+ }
}
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index c3e7224..64daea9 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -30,6 +30,7 @@ import android.content.pm.ProviderInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.net.Uri;
+import android.os.Debug;
import android.os.RemoteException;
import android.os.IBinder;
import android.os.IInterface;
@@ -272,6 +273,9 @@ public interface IActivityManager extends IInterface {
public void closeSystemDialogs(String reason) throws RemoteException;
+ public void getProcessMemoryInfo(int pid, Debug.MemoryInfo outInfo)
+ throws RemoteException;
+
/*
* Private non-Binder interfaces
*/
@@ -428,4 +432,5 @@ public interface IActivityManager extends IInterface {
int START_ACTIVITY_IN_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+94;
int KILL_APPLICATION_WITH_UID_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+95;
int CLOSE_SYSTEM_DIALOGS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+96;
+ int GET_PROCESS_MEMORY_INFO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+97;
}
diff --git a/core/java/android/app/IApplicationThread.java b/core/java/android/app/IApplicationThread.java
index 6faaa34..da9a957 100644
--- a/core/java/android/app/IApplicationThread.java
+++ b/core/java/android/app/IApplicationThread.java
@@ -25,6 +25,7 @@ import android.content.pm.ProviderInfo;
import android.content.pm.ServiceInfo;
import android.content.res.Configuration;
import android.os.Bundle;
+import android.os.Debug;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.IBinder;
@@ -97,6 +98,7 @@ public interface IApplicationThread extends IInterface {
void profilerControl(boolean start, String path, ParcelFileDescriptor fd)
throws RemoteException;
void setSchedulingGroup(int group) throws RemoteException;
+ void getMemoryInfo(Debug.MemoryInfo outInfo) throws RemoteException;
String descriptor = "android.app.IApplicationThread";
@@ -130,4 +132,5 @@ public interface IApplicationThread extends IInterface {
int SET_SCHEDULING_GROUP_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+28;
int SCHEDULE_CREATE_BACKUP_AGENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+29;
int SCHEDULE_DESTROY_BACKUP_AGENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+30;
+ int GET_MEMORY_INFO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+31;
}