diff options
| -rw-r--r-- | cmds/statsd/src/atoms.proto | 12 | ||||
| -rw-r--r-- | services/core/java/com/android/server/RescueParty.java | 3 | ||||
| -rw-r--r-- | services/tests/rescueparty/Android.bp | 23 | ||||
| -rw-r--r-- | services/tests/rescueparty/how_to_run.txt | 9 | ||||
| -rw-r--r-- | services/tests/rescueparty/log_rescueparty_reset_event_reported.cpp | 24 |
5 files changed, 70 insertions, 1 deletions
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index 1d3b3841f15e..786d8d1437fc 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -180,6 +180,7 @@ message Atom { DocsUISearchModeReported docs_ui_search_mode_reported = 119; DocsUISearchTypeReported docs_ui_search_type_reported = 120; DataStallEvent data_stall_event = 121; + RescuePartyResetReported rescue_party_reset_reported = 122; } // Pulled events will start at field 10000. @@ -3847,3 +3848,14 @@ message DataStallEvent { // See definition in data_stall_event.proto. optional com.android.server.connectivity.DnsEvent dns_event = 6 [(log_mode) = MODE_BYTES]; } + +/* + * Logs when RescueParty resets some set of experiment flags. + * + * Logged from: + * frameworks/base/services/core/java/com/android/server/RescueParty.java + */ +message RescuePartyResetReported { + // The rescue level of this reset. A value of 0 indicates missing or unknown level information. + optional int32 rescue_level = 1; +} diff --git a/services/core/java/com/android/server/RescueParty.java b/services/core/java/com/android/server/RescueParty.java index a9f190c84cca..62da3f8e01ba 100644 --- a/services/core/java/com/android/server/RescueParty.java +++ b/services/core/java/com/android/server/RescueParty.java @@ -34,9 +34,9 @@ import android.util.Log; import android.util.MathUtils; import android.util.Slog; import android.util.SparseArray; +import android.util.StatsLog; import com.android.internal.util.ArrayUtils; -import com.android.server.pm.PackageManagerService; import java.io.File; @@ -179,6 +179,7 @@ public class RescueParty { } private static void executeRescueLevelInternal(Context context, int level) throws Exception { + StatsLog.write(StatsLog.RESCUE_PARTY_RESET_REPORTED, level); switch (level) { case LEVEL_RESET_SETTINGS_UNTRUSTED_DEFAULTS: resetAllSettings(context, Settings.RESET_MODE_UNTRUSTED_DEFAULTS); diff --git a/services/tests/rescueparty/Android.bp b/services/tests/rescueparty/Android.bp new file mode 100644 index 000000000000..6733af4eb26a --- /dev/null +++ b/services/tests/rescueparty/Android.bp @@ -0,0 +1,23 @@ +// Copyright (C) 2008 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. + +cc_test { + name: "log_rescueparty_reset_event_reported", + srcs: ["log_rescueparty_reset_event_reported.cpp"], + shared_libs: [ + "libbase", + "libstatslog", + ], + gtest: false, +} diff --git a/services/tests/rescueparty/how_to_run.txt b/services/tests/rescueparty/how_to_run.txt new file mode 100644 index 000000000000..9528d39358eb --- /dev/null +++ b/services/tests/rescueparty/how_to_run.txt @@ -0,0 +1,9 @@ +# Per http://go/westworld-local-development#step3-test-atom-and-metric-locally-on-device , +# In one terminal: +make statsd_testdrive +./out/host/linux-x86/bin/statsd_testdrive 122 + +# In another terminal: +mma -j $(nproc) log_rescueparty_reset_event_reported +adb push $OUT/testcases/log_rescueparty_reset_event_reported/arm64/log_rescueparty_reset_event_reported /data +adb shell /data/log_rescueparty_reset_event_reported 1234 diff --git a/services/tests/rescueparty/log_rescueparty_reset_event_reported.cpp b/services/tests/rescueparty/log_rescueparty_reset_event_reported.cpp new file mode 100644 index 000000000000..4aea91784092 --- /dev/null +++ b/services/tests/rescueparty/log_rescueparty_reset_event_reported.cpp @@ -0,0 +1,24 @@ +// Copyright (C) 2008 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. + +#include <statslog.h> +#include <cstdlib> + +int main(int argc, const char** argv) { + int level = 0; + if (argc > 1) { + level = std::atoi(argv[1]); + } + android::util::stats_write(android::util::RESCUE_PARTY_RESET_REPORTED, level); +} |