diff options
| author | Ruchir Rastogi <ruchirr@google.com> | 2019-11-27 15:26:03 -0800 |
|---|---|---|
| committer | Ruchir Rastogi <ruchirr@google.com> | 2019-12-06 14:08:27 -0800 |
| commit | cd9dd94fb152d2187f386cdd1efb1c8efa4192e9 (patch) | |
| tree | 3d05af75e50f253ebe95a476aa3e8c4860ff32d9 /core/java/android | |
| parent | 45665b5fe8135b958dc9cf7e0aa444bf20c997c6 (diff) | |
StatsEventParcel impl.; move AIDL files
This implementation continue to uses libbinder, as opposed to
libbinder_ndk.
We also move many (but not all) statsd aidl files from
frameworks/base/core into the apex.
Test: m -j128 && bit statsd_test:*
Change-Id: I95f06e937e50c1e2a638163b13587682402956a7
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/StatsManager.java | 9 | ||||
| -rw-r--r-- | core/java/android/os/IPullAtomCallback.aidl | 31 | ||||
| -rw-r--r-- | core/java/android/os/IPullAtomResultReceiver.aidl | 32 | ||||
| -rw-r--r-- | core/java/android/os/IStatsCompanionService.aidl | 93 | ||||
| -rw-r--r-- | core/java/android/os/IStatsManager.aidl | 249 | ||||
| -rw-r--r-- | core/java/android/os/IStatsPullerCallback.aidl | 36 | ||||
| -rw-r--r-- | core/java/android/util/StatsEvent.java | 37 |
7 files changed, 7 insertions, 480 deletions
diff --git a/core/java/android/app/StatsManager.java b/core/java/android/app/StatsManager.java index 2ef05105825a..90cd51f8649f 100644 --- a/core/java/android/app/StatsManager.java +++ b/core/java/android/app/StatsManager.java @@ -34,6 +34,7 @@ import android.os.ServiceManager; import android.util.AndroidException; import android.util.Slog; import android.util.StatsEvent; +import android.util.StatsEventParcel; import com.android.internal.annotations.GuardedBy; @@ -540,10 +541,12 @@ public final class StatsManager { mExecutor.execute(() -> { List<StatsEvent> data = new ArrayList<>(); boolean success = mCallback.onPullAtom(atomTag, data); - StatsEvent[] arr = new StatsEvent[data.size()]; - arr = data.toArray(arr); + StatsEventParcel[] parcels = new StatsEventParcel[data.size()]; + for (int i = 0; i < data.size(); i++) { + parcels[i].buffer = data.get(i).getBytes(); + } try { - resultReceiver.pullFinished(atomTag, success, arr); + resultReceiver.pullFinished(atomTag, success, parcels); } catch (RemoteException e) { Slog.w(TAG, "StatsPullResultReceiver failed for tag " + mAtomId); } diff --git a/core/java/android/os/IPullAtomCallback.aidl b/core/java/android/os/IPullAtomCallback.aidl deleted file mode 100644 index 88d3c3e46ff5..000000000000 --- a/core/java/android/os/IPullAtomCallback.aidl +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2019 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 android.os; - -import android.os.IPullAtomResultReceiver; - -/** - * Binder interface to pull atoms for the stats service. - * {@hide} - */ -interface IPullAtomCallback { - /** - * Initiate a request for a pull for an atom. - */ - void onPullAtom(int atomTag, IPullAtomResultReceiver resultReceiver); - -} diff --git a/core/java/android/os/IPullAtomResultReceiver.aidl b/core/java/android/os/IPullAtomResultReceiver.aidl deleted file mode 100644 index bfb35ff0c9d1..000000000000 --- a/core/java/android/os/IPullAtomResultReceiver.aidl +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2019 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 android.os; - -import android.util.StatsEvent; - -/** - * Binder interface to pull atoms for the stats service. - * {@hide} - */ -interface IPullAtomResultReceiver { - - /** - * Indicate that a pull request for an atom is complete. - */ - oneway void pullFinished(int atomTag, boolean success, in StatsEvent[] output); - -} diff --git a/core/java/android/os/IStatsCompanionService.aidl b/core/java/android/os/IStatsCompanionService.aidl deleted file mode 100644 index 22a25374e064..000000000000 --- a/core/java/android/os/IStatsCompanionService.aidl +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2017 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 android.os; - -import android.os.IPullAtomCallback; -import android.os.StatsDimensionsValue; -import android.os.StatsLogEventWrapper; - -/** - * Binder interface to communicate with the Java-based statistics service helper. - * {@hide} - */ -interface IStatsCompanionService { - /** - * Tell statscompanion that stastd is up and running. - */ - oneway void statsdReady(); - - /** - * Register an alarm for anomaly detection to fire at the given timestamp (ms since epoch). - * If anomaly alarm had already been registered, it will be replaced with the new timestamp. - * Uses AlarmManager.set API, so if the timestamp is in the past, alarm fires immediately, and - * alarm is inexact. - */ - oneway void setAnomalyAlarm(long timestampMs); - - /** Cancel any anomaly detection alarm. */ - oneway void cancelAnomalyAlarm(); - - /** - * Register a repeating alarm for pulling to fire at the given timestamp and every - * intervalMs thereafter (in ms since epoch). - * If polling alarm had already been registered, it will be replaced by new one. - * Uses AlarmManager.setRepeating API, so if the timestamp is in past, alarm fires immediately, - * and alarm is inexact. - */ - oneway void setPullingAlarm(long nextPullTimeMs); - - /** Cancel any repeating pulling alarm. */ - oneway void cancelPullingAlarm(); - - /** - * Register an alarm when we want to trigger subscribers at the given - * timestamp (in ms since epoch). - * If an alarm had already been registered, it will be replaced by new one. - */ - oneway void setAlarmForSubscriberTriggering(long timestampMs); - - /** Cancel any alarm for the purpose of subscriber triggering. */ - oneway void cancelAlarmForSubscriberTriggering(); - - /** Pull the specified data. Results will be sent to statsd when complete. */ - StatsLogEventWrapper[] pullData(int pullCode); - - /** Send a broadcast to the specified PendingIntent's as IBinder that it should getData now. */ - oneway void sendDataBroadcast(in IBinder intentSender, long lastReportTimeNs); - - /** - * Send a broadcast to the specified PendingIntent's as IBinder notifying it that the list - * of active configs has changed. - */ - oneway void sendActiveConfigsChangedBroadcast(in IBinder intentSender, in long[] configIds); - - /** - * Requests StatsCompanionService to send a broadcast using the given intentSender - * (which should cast to an IIntentSender), along with the other information specified. - */ - oneway void sendSubscriberBroadcast(in IBinder intentSender, long configUid, long configId, - long subscriptionId, long subscriptionRuleId, - in String[] cookies, - in StatsDimensionsValue dimensionsValue); - - /** Tells StatsCompaionService to grab the uid map snapshot and send it to statsd. */ - oneway void triggerUidSnapshot(); - - /** Tells StatsCompanionService to tell statsd to register a puller for the given atom id */ - oneway void registerPullAtomCallback(int atomTag, long coolDownNs, long timeoutNs, - in int[] additiveFields, IPullAtomCallback pullerCallback); -} diff --git a/core/java/android/os/IStatsManager.aidl b/core/java/android/os/IStatsManager.aidl deleted file mode 100644 index 5ebb9f2e4e90..000000000000 --- a/core/java/android/os/IStatsManager.aidl +++ /dev/null @@ -1,249 +0,0 @@ -/** - * Copyright (c) 2017, 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 android.os; - -import android.os.IStatsPullerCallback; -import android.os.IPullAtomCallback; -import android.os.ParcelFileDescriptor; - -/** - * Binder interface to communicate with the statistics management service. - * {@hide} - */ -interface IStatsManager { - /** - * Tell the stats daemon that the android system server is up and running. - */ - oneway void systemRunning(); - - /** - * Tell the stats daemon that the StatsCompanionService is up and running. - * Two-way binder call so that caller knows message received. - */ - void statsCompanionReady(); - - /** - * Tells statsd that an anomaly may have occurred, so statsd can check whether this is so and - * act accordingly. - * Two-way binder call so that caller's method (and corresponding wakelocks) will linger. - */ - void informAnomalyAlarmFired(); - - /** - * Tells statsd that it is time to poll some stats. Statsd will be responsible for determing - * what stats to poll and initiating the polling. - * Two-way binder call so that caller's method (and corresponding wakelocks) will linger. - */ - void informPollAlarmFired(); - - /** - * Tells statsd that it is time to handle periodic alarms. Statsd will be responsible for - * determing what alarm subscriber to trigger. - * Two-way binder call so that caller's method (and corresponding wakelocks) will linger. - */ - void informAlarmForSubscriberTriggeringFired(); - - /** - * Tells statsd that the device is about to shutdown. - */ - void informDeviceShutdown(); - - /** - * Inform statsd about a file descriptor for a pipe through which we will pipe version - * and package information for each uid. - * Versions and package information are supplied via UidData proto where info for each app - * is captured in its own element of a repeated ApplicationInfo message. - */ - oneway void informAllUidData(in ParcelFileDescriptor fd); - - /** - * Inform statsd what the uid, version, version_string, and installer are for one app that was - * updated. - */ - oneway void informOnePackage(in String app, in int uid, in long version, - in String version_string, in String installer); - - /** - * Inform stats that an app was removed. - */ - oneway void informOnePackageRemoved(in String app, in int uid); - - /** - * Fetches data for the specified configuration key. Returns a byte array representing proto - * wire-encoded of ConfigMetricsReportList. - * - * Requires Manifest.permission.DUMP. - */ - byte[] getData(in long key, in String packageName); - - /** - * Fetches metadata across statsd. Returns byte array representing wire-encoded proto. - * - * Requires Manifest.permission.DUMP. - */ - byte[] getMetadata(in String packageName); - - /** - * Sets a configuration with the specified config key and subscribes to updates for this - * configuration key. Broadcasts will be sent if this configuration needs to be collected. - * The configuration must be a wire-encoded StatsdConfig. The receiver for this data is - * registered in a separate function. - * - * Requires Manifest.permission.DUMP. - */ - void addConfiguration(in long configKey, in byte[] config, in String packageName); - - /** - * Registers the given pending intent for this config key. This intent is invoked when the - * memory consumed by the metrics for this configuration approach the pre-defined limits. There - * can be at most one listener per config key. - * - * Requires Manifest.permission.DUMP. - */ - void setDataFetchOperation(long configKey, in IBinder intentSender, in String packageName); - - /** - * Removes the data fetch operation for the specified configuration. - * - * Requires Manifest.permission.DUMP. - */ - void removeDataFetchOperation(long configKey, in String packageName); - - /** - * Registers the given pending intent for this packagename. This intent is invoked when the - * active status of any of the configs sent by this package changes and will contain a list of - * config ids that are currently active. It also returns the list of configs that are currently - * active. There can be at most one active configs changed listener per package. - * - * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS. - */ - long[] setActiveConfigsChangedOperation(in IBinder intentSender, in String packageName); - - /** - * Removes the active configs changed operation for the specified package name. - * - * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS. - */ - void removeActiveConfigsChangedOperation(in String packageName); - - /** - * Removes the configuration with the matching config key. No-op if this config key does not - * exist. - * - * Requires Manifest.permission.DUMP. - */ - void removeConfiguration(in long configKey, in String packageName); - - /** - * Set the IIntentSender (i.e. PendingIntent) to be used when broadcasting subscriber - * information to the given subscriberId within the given config. - * - * Suppose that the calling uid has added a config with key configKey, and that in this config - * it is specified that when a particular anomaly is detected, a broadcast should be sent to - * a BroadcastSubscriber with id subscriberId. This function links the given intentSender with - * that subscriberId (for that config), so that this intentSender is used to send the broadcast - * when the anomaly is detected. - * - * This function can only be called by the owner (uid) of the config. It must be called each - * time statsd starts. Later calls overwrite previous calls; only one intentSender is stored. - * - * intentSender must be convertible into an IntentSender using IntentSender(IBinder) - * and cannot be null. - * - * Requires Manifest.permission.DUMP. - */ - void setBroadcastSubscriber(long configKey, long subscriberId, in IBinder intentSender, - in String packageName); - - /** - * Undoes setBroadcastSubscriber() for the (configKey, subscriberId) pair. - * Any broadcasts associated with subscriberId will henceforth not be sent. - * No-op if this (configKey, subsriberId) pair was not associated with an IntentSender. - * - * Requires Manifest.permission.DUMP. - */ - void unsetBroadcastSubscriber(long configKey, long subscriberId, in String packageName); - - /** - * Apps can send an atom via this application breadcrumb with the specified label and state for - * this label. This allows building custom metrics and predicates. - */ - void sendAppBreadcrumbAtom(int label, int state); - - /** - * Registers a puller callback function that, when invoked, pulls the data - * for the specified vendor atom tag. - * - * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS - * @deprecated please use registerPullAtomCallback. - */ - oneway void registerPullerCallback(int atomTag, IStatsPullerCallback pullerCallback, - String packageName); - - /** - * Registers a puller callback function that, when invoked, pulls the data - * for the specified atom tag. - */ - oneway void registerPullAtomCallback(int uid, int atomTag, long coolDownNs, long timeoutNs, - in int[] additiveFields, IPullAtomCallback pullerCallback); - - /** - * Registers a puller callback function that, when invoked, pulls the data - * for the specified atom tag. - */ - oneway void registerNativePullAtomCallback(int atomTag, long coolDownNs, long timeoutNs, - in int[] additiveFields, IPullAtomCallback pullerCallback); - - /** - * Unregisters a puller callback function for the given vendor atom. - * - * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS - */ - oneway void unregisterPullerCallback(int atomTag, String packageName); - - /** - * The install requires staging. - */ - const int FLAG_REQUIRE_STAGING = 0x01; - - /** - * Rollback is enabled with this install. - */ - const int FLAG_ROLLBACK_ENABLED = 0x02; - - /** - * Requires low latency monitoring. - */ - const int FLAG_REQUIRE_LOW_LATENCY_MONITOR = 0x04; - - /** - * Logs an event for binary push for module updates. - */ - oneway void sendBinaryPushStateChangedAtom(in String trainName, in long trainVersionCode, - in int options, in int state, in long[] experimentId); - - /** - * Logs an event for watchdog rollbacks. - */ - oneway void sendWatchdogRollbackOccurredAtom(in int rollbackType, in String packageName, - in long packageVersionCode); - - /** - * Returns the most recently registered experiment IDs. - */ - long[] getRegisteredExperimentIds(); -} diff --git a/core/java/android/os/IStatsPullerCallback.aidl b/core/java/android/os/IStatsPullerCallback.aidl deleted file mode 100644 index c3e1e55dde06..000000000000 --- a/core/java/android/os/IStatsPullerCallback.aidl +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2019 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 android.os; - -import android.os.StatsLogEventWrapper; - -/** - * DEPRECATED - * Binder interface to pull atoms for the stats service. - * {@hide} - */ -interface IStatsPullerCallback { - /** - * Pull data for the specified atom tag. Returns an array of StatsLogEventWrapper containing - * the data. - * - * Note: These pulled atoms should not have uid/attribution chain. Additionally, the event - * timestamps will be truncated to the nearest 5 minutes. - */ - StatsLogEventWrapper[] pullData(int atomTag, long elapsedNanos, long wallClocknanos); - -} diff --git a/core/java/android/util/StatsEvent.java b/core/java/android/util/StatsEvent.java index 0a4069d15706..7e7164042781 100644 --- a/core/java/android/util/StatsEvent.java +++ b/core/java/android/util/StatsEvent.java @@ -20,8 +20,6 @@ import static java.nio.charset.StandardCharsets.UTF_8; import android.annotation.NonNull; import android.annotation.Nullable; -import android.os.Parcel; -import android.os.Parcelable; import android.os.SystemClock; import com.android.internal.annotations.GuardedBy; @@ -44,7 +42,7 @@ import com.android.internal.annotations.VisibleForTesting; * </pre> * @hide **/ -public final class StatsEvent implements Parcelable { +public final class StatsEvent { // Type Ids. /** * @hide @@ -265,39 +263,6 @@ public final class StatsEvent implements Parcelable { } /** - * Boilerplate for Parcel. - */ - public static final @NonNull Parcelable.Creator<StatsEvent> CREATOR = - new Parcelable.Creator<StatsEvent>() { - public StatsEvent createFromParcel(Parcel in) { - // Purposefully leaving this method not implemented. - throw new RuntimeException("Not implemented"); - } - - public StatsEvent[] newArray(int size) { - // Purposefully leaving this method not implemented. - throw new RuntimeException("Not implemented"); - } - }; - - /** - * Boilerplate for Parcel. - */ - public void writeToParcel(Parcel out, int flags) { - out.writeInt(mAtomId); - out.writeInt(getNumBytes()); - out.writeByteArray(getBytes()); - } - - /** - * Boilerplate for Parcel. - */ - public int describeContents() { - return 0; - } - - - /** * Builder for constructing a StatsEvent object. * * <p>This class defines and encapsulates the socket encoding for the buffer. |
