Loading Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -197,6 +197,7 @@ LOCAL_SRC_FILES += \ core/java/com/android/internal/app/IAppOpsCallback.aidl \ core/java/com/android/internal/app/IAppOpsService.aidl \ core/java/com/android/internal/app/IBatteryStats.aidl \ core/java/com/android/internal/app/IProcessStats.aidl \ core/java/com/android/internal/app/IUsageStats.aidl \ core/java/com/android/internal/app/IMediaContainerService.aidl \ core/java/com/android/internal/appwidget/IAppWidgetService.aidl \ Loading core/java/com/android/internal/app/IProcessStats.aidl 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.app; import android.content.ComponentName; import android.os.ParcelFileDescriptor; import com.android.internal.app.ProcessStats; interface IProcessStats { byte[] getCurrentStats(out List<ParcelFileDescriptor> historic); } core/java/com/android/internal/app/ProcessStats.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* ** Copyright 2013, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ package com.android.internal.app; parcelable ProcessStats; services/java/com/android/internal/app/ProcessStats.java +26 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.app; import android.os.Parcel; import android.os.Parcelable; import android.os.SystemClock; import android.os.SystemProperties; import android.os.UserHandle; Loading @@ -38,7 +39,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.Objects; final public class ProcessStats { final public class ProcessStats implements Parcelable { static final String TAG = "ProcessStats"; static final boolean DEBUG = false; Loading Loading @@ -198,6 +199,22 @@ final public class ProcessStats { reset(); } public ProcessStats(Parcel in) { reset(); readFromParcel(in); } public static final Parcelable.Creator<ProcessStats> CREATOR = new Parcelable.Creator<ProcessStats>() { public ProcessStats createFromParcel(Parcel in) { return new ProcessStats(in); } public ProcessStats[] newArray(int size) { return new ProcessStats[size]; } }; static private void printScreenLabel(PrintWriter pw, int offset) { switch (offset) { case ADJ_NOTHING: Loading Loading @@ -947,7 +964,13 @@ final public class ProcessStats { return table; } public void writeToParcel(Parcel out) { @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel out, int flags) { long now = SystemClock.uptimeMillis(); out.writeInt(MAGIC); out.writeInt(PARCEL_VERSION); Loading Loading @@ -2272,6 +2295,7 @@ final public class ProcessStats { if (mDurationsTable == BAD_TABLE) { return false; } mDurationsTableSize = mDurationsTable != null ? mDurationsTable.length : 0; mStartedCount = in.readInt(); mBoundCount = in.readInt(); mExecCount = in.readInt(); Loading services/java/com/android/server/am/ProcessStatsService.java +32 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.am; import android.app.AppGlobals; import android.content.pm.IPackageManager; import android.os.Parcel; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemProperties; Loading @@ -27,6 +28,7 @@ import android.util.ArrayMap; import android.util.AtomicFile; import android.util.Slog; import android.util.SparseArray; import com.android.internal.app.IProcessStats; import com.android.internal.app.ProcessStats; import com.android.internal.os.BackgroundThread; Loading @@ -38,9 +40,10 @@ import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.locks.ReentrantLock; public final class ProcessStatsService { public final class ProcessStatsService extends IProcessStats.Stub { static final String TAG = "ProcessStatsService"; static final boolean DEBUG = false; Loading Loading @@ -204,7 +207,7 @@ public final class ProcessStatsService { if (commit) { mProcessStats.mFlags |= ProcessStats.FLAG_COMPLETE; } mProcessStats.writeToParcel(mPendingWrite); mProcessStats.writeToParcel(mPendingWrite, 0); mPendingWriteFile = new AtomicFile(mFile.getBaseFile()); mPendingWriteCommitted = commit; } Loading Loading @@ -442,6 +445,33 @@ public final class ProcessStatsService { return finalRes; } public byte[] getCurrentStats(List<ParcelFileDescriptor> historic) { Parcel current = Parcel.obtain(); mWriteLock.lock(); try { synchronized (mLock) { mProcessStats.writeToParcel(current, 0); } if (historic != null) { ArrayList<String> files = getCommittedFiles(0, true); if (files != null) { for (int i=files.size()-1; i>=0; i--) { try { ParcelFileDescriptor pfd = ParcelFileDescriptor.open( new File(files.get(i)), ParcelFileDescriptor.MODE_READ_ONLY); historic.add(pfd); } catch (IOException e) { Slog.w(TAG, "Failure opening procstat file " + files.get(i), e); } } } } } finally { mWriteLock.unlock(); } return current.marshall(); } static private void dumpHelp(PrintWriter pw) { pw.println("Process stats (procstats) dump options:"); pw.println(" [--checkin|-c|--csv] [--csv-screen] [--csv-proc] [--csv-mem]"); Loading Loading
Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -197,6 +197,7 @@ LOCAL_SRC_FILES += \ core/java/com/android/internal/app/IAppOpsCallback.aidl \ core/java/com/android/internal/app/IAppOpsService.aidl \ core/java/com/android/internal/app/IBatteryStats.aidl \ core/java/com/android/internal/app/IProcessStats.aidl \ core/java/com/android/internal/app/IUsageStats.aidl \ core/java/com/android/internal/app/IMediaContainerService.aidl \ core/java/com/android/internal/appwidget/IAppWidgetService.aidl \ Loading
core/java/com/android/internal/app/IProcessStats.aidl 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.app; import android.content.ComponentName; import android.os.ParcelFileDescriptor; import com.android.internal.app.ProcessStats; interface IProcessStats { byte[] getCurrentStats(out List<ParcelFileDescriptor> historic); }
core/java/com/android/internal/app/ProcessStats.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* ** Copyright 2013, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ package com.android.internal.app; parcelable ProcessStats;
services/java/com/android/internal/app/ProcessStats.java +26 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.app; import android.os.Parcel; import android.os.Parcelable; import android.os.SystemClock; import android.os.SystemProperties; import android.os.UserHandle; Loading @@ -38,7 +39,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.Objects; final public class ProcessStats { final public class ProcessStats implements Parcelable { static final String TAG = "ProcessStats"; static final boolean DEBUG = false; Loading Loading @@ -198,6 +199,22 @@ final public class ProcessStats { reset(); } public ProcessStats(Parcel in) { reset(); readFromParcel(in); } public static final Parcelable.Creator<ProcessStats> CREATOR = new Parcelable.Creator<ProcessStats>() { public ProcessStats createFromParcel(Parcel in) { return new ProcessStats(in); } public ProcessStats[] newArray(int size) { return new ProcessStats[size]; } }; static private void printScreenLabel(PrintWriter pw, int offset) { switch (offset) { case ADJ_NOTHING: Loading Loading @@ -947,7 +964,13 @@ final public class ProcessStats { return table; } public void writeToParcel(Parcel out) { @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel out, int flags) { long now = SystemClock.uptimeMillis(); out.writeInt(MAGIC); out.writeInt(PARCEL_VERSION); Loading Loading @@ -2272,6 +2295,7 @@ final public class ProcessStats { if (mDurationsTable == BAD_TABLE) { return false; } mDurationsTableSize = mDurationsTable != null ? mDurationsTable.length : 0; mStartedCount = in.readInt(); mBoundCount = in.readInt(); mExecCount = in.readInt(); Loading
services/java/com/android/server/am/ProcessStatsService.java +32 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.am; import android.app.AppGlobals; import android.content.pm.IPackageManager; import android.os.Parcel; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemProperties; Loading @@ -27,6 +28,7 @@ import android.util.ArrayMap; import android.util.AtomicFile; import android.util.Slog; import android.util.SparseArray; import com.android.internal.app.IProcessStats; import com.android.internal.app.ProcessStats; import com.android.internal.os.BackgroundThread; Loading @@ -38,9 +40,10 @@ import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.locks.ReentrantLock; public final class ProcessStatsService { public final class ProcessStatsService extends IProcessStats.Stub { static final String TAG = "ProcessStatsService"; static final boolean DEBUG = false; Loading Loading @@ -204,7 +207,7 @@ public final class ProcessStatsService { if (commit) { mProcessStats.mFlags |= ProcessStats.FLAG_COMPLETE; } mProcessStats.writeToParcel(mPendingWrite); mProcessStats.writeToParcel(mPendingWrite, 0); mPendingWriteFile = new AtomicFile(mFile.getBaseFile()); mPendingWriteCommitted = commit; } Loading Loading @@ -442,6 +445,33 @@ public final class ProcessStatsService { return finalRes; } public byte[] getCurrentStats(List<ParcelFileDescriptor> historic) { Parcel current = Parcel.obtain(); mWriteLock.lock(); try { synchronized (mLock) { mProcessStats.writeToParcel(current, 0); } if (historic != null) { ArrayList<String> files = getCommittedFiles(0, true); if (files != null) { for (int i=files.size()-1; i>=0; i--) { try { ParcelFileDescriptor pfd = ParcelFileDescriptor.open( new File(files.get(i)), ParcelFileDescriptor.MODE_READ_ONLY); historic.add(pfd); } catch (IOException e) { Slog.w(TAG, "Failure opening procstat file " + files.get(i), e); } } } } } finally { mWriteLock.unlock(); } return current.marshall(); } static private void dumpHelp(PrintWriter pw) { pw.println("Process stats (procstats) dump options:"); pw.println(" [--checkin|-c|--csv] [--csv-screen] [--csv-proc] [--csv-mem]"); Loading