From 04881f8184023031f670fe6397cbf2ec68640097 Mon Sep 17 00:00:00 2001 From: Nathan Harold Date: Fri, 8 Mar 2019 11:51:56 -0800 Subject: [PATCH] [API Feedback] Rename DebugEventReporter To address concerns that the DebugEventReporter would be misconstrued as a generic logging mechanism, for which use of system broadcasts is inappropriate, this component and the accompanying broadcast are renamed as AnomalyReporter and the event renamed from ACTION_DEBUG_EVENT to ACTION_ANOMALY_REPORTED. Bug: 126178766 Test: manual (fire event from PhoneGlobals at boot). Change-Id: I13381d6c551db161d9858601df8be98f5c25976c --- api/system-current.txt | 6 ++-- ...ebugEventReporter.java => AnomalyReporter.java} | 39 +++++++++++----------- telephony/java/android/telephony/CellIdentity.java | 2 +- .../java/android/telephony/TelephonyManager.java | 25 +++++++------- 4 files changed, 36 insertions(+), 36 deletions(-) rename telephony/java/android/telephony/{DebugEventReporter.java => AnomalyReporter.java} (82%) diff --git a/api/system-current.txt b/api/system-current.txt index 24df5f1ecb16..f2cab43228f2 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -6423,7 +6423,7 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean switchSlots(int[]); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void toggleRadioOnOff(); method public void updateServiceLocation(); - field @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public static final String ACTION_DEBUG_EVENT = "android.telephony.action.DEBUG_EVENT"; + field @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public static final String ACTION_ANOMALY_REPORTED = "android.telephony.action.ANOMALY_REPORTED"; field public static final String ACTION_SIM_APPLICATION_STATE_CHANGED = "android.telephony.action.SIM_APPLICATION_STATE_CHANGED"; field public static final String ACTION_SIM_CARD_STATE_CHANGED = "android.telephony.action.SIM_CARD_STATE_CHANGED"; field public static final String ACTION_SIM_SLOT_STATUS_CHANGED = "android.telephony.action.SIM_SLOT_STATUS_CHANGED"; @@ -6431,8 +6431,8 @@ package android.telephony { field public static final int CARRIER_PRIVILEGE_STATUS_HAS_ACCESS = 1; // 0x1 field public static final int CARRIER_PRIVILEGE_STATUS_NO_ACCESS = 0; // 0x0 field public static final int CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED = -1; // 0xffffffff - field public static final String EXTRA_DEBUG_EVENT_DESCRIPTION = "android.telephony.extra.DEBUG_EVENT_DESCRIPTION"; - field public static final String EXTRA_DEBUG_EVENT_ID = "android.telephony.extra.DEBUG_EVENT_ID"; + field public static final String EXTRA_ANOMALY_DESCRIPTION = "android.telephony.extra.ANOMALY_DESCRIPTION"; + field public static final String EXTRA_ANOMALY_ID = "android.telephony.extra.ANOMALY_ID"; field public static final String EXTRA_SIM_STATE = "android.telephony.extra.SIM_STATE"; field public static final String EXTRA_VISUAL_VOICEMAIL_ENABLED_BY_USER_BOOL = "android.telephony.extra.VISUAL_VOICEMAIL_ENABLED_BY_USER_BOOL"; field public static final String EXTRA_VOICEMAIL_SCRAMBLED_PIN_STRING = "android.telephony.extra.VOICEMAIL_SCRAMBLED_PIN_STRING"; diff --git a/telephony/java/android/telephony/DebugEventReporter.java b/telephony/java/android/telephony/AnomalyReporter.java similarity index 82% rename from telephony/java/android/telephony/DebugEventReporter.java rename to telephony/java/android/telephony/AnomalyReporter.java index 14b7dd6d1b72..9753d8be4065 100644 --- a/telephony/java/android/telephony/DebugEventReporter.java +++ b/telephony/java/android/telephony/AnomalyReporter.java @@ -29,7 +29,6 @@ import com.android.internal.util.IndentingPrintWriter; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.List; -import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -37,7 +36,7 @@ import java.util.concurrent.ConcurrentHashMap; /** * A Simple Surface for Telephony to notify a loosely-coupled debugger of particular issues. * - * DebugEventReporter allows an optional external logging component to receive events detected by + * AnomalyReporter allows an optional external logging component to receive events detected by * the framework and take action. This log surface is designed to provide maximium flexibility * to the receiver of these events. Envisioned use cases of this include notifying a vendor * component of: an event that necessitates (timely) log collection on non-AOSP components; @@ -49,8 +48,8 @@ import java.util.concurrent.ConcurrentHashMap; * * @hide */ -public final class DebugEventReporter { - private static final String TAG = "DebugEventReporter"; +public final class AnomalyReporter { + private static final String TAG = "AnomalyReporter"; private static Context sContext = null; @@ -63,12 +62,12 @@ public final class DebugEventReporter { */ private static String sDebugPackageName = null; - private DebugEventReporter() {}; + private AnomalyReporter() {}; /** * If enabled, build and send an intent to a Debug Service for logging. * - * This method sends the {@link TelephonyManager#DEBUG_EVENT DEBUG_EVENT} broadcast, which is + * This method sends the {@link TelephonyManager#ACTION_ANOMALY_REPORTED} broadcast, which is * system protected. Invoking this method unless you are the system will result in an error. * * @param eventId a fixed event ID that will be sent for each instance of the same event. This @@ -77,9 +76,9 @@ public final class DebugEventReporter { * identification and discussion of this event. This description should ideally be * static and must not contain any sensitive information (especially PII). */ - public static void sendEvent(@NonNull UUID eventId, String description) { + public static void reportAnomaly(@NonNull UUID eventId, String description) { if (sContext == null) { - Rlog.w(TAG, "DebugEventReporter not yet initialized, dropping event=" + eventId); + Rlog.w(TAG, "AnomalyReporter not yet initialized, dropping event=" + eventId); return; } @@ -94,28 +93,28 @@ public final class DebugEventReporter { // so drop these events silently. if (sDebugPackageName == null) return; - Intent dbgIntent = new Intent(TelephonyManager.ACTION_DEBUG_EVENT); - dbgIntent.putExtra(TelephonyManager.EXTRA_DEBUG_EVENT_ID, new ParcelUuid(eventId)); + Intent dbgIntent = new Intent(TelephonyManager.ACTION_ANOMALY_REPORTED); + dbgIntent.putExtra(TelephonyManager.EXTRA_ANOMALY_ID, new ParcelUuid(eventId)); if (description != null) { - dbgIntent.putExtra(TelephonyManager.EXTRA_DEBUG_EVENT_DESCRIPTION, description); + dbgIntent.putExtra(TelephonyManager.EXTRA_ANOMALY_DESCRIPTION, description); } dbgIntent.setPackage(sDebugPackageName); sContext.sendBroadcast(dbgIntent, android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE); } /** - * Initialize the DebugEventReporter with the current context. + * Initialize the AnomalyReporter with the current context. * - * This method must be invoked before any calls to sendEvent() will succeed. This method should - * only be invoked at most once. + * This method must be invoked before any calls to reportAnomaly() will succeed. This method + * should only be invoked at most once. * - * @param context a Context object used to initialize this singleton DebugEventReporter in + * @param context a Context object used to initialize this singleton AnomalyReporter in * the current process. */ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public static void initialize(@NonNull Context context) { if (context == null) { - throw new IllegalArgumentException("DebugEventReporter needs a non-null context."); + throw new IllegalArgumentException("AnomalyReporter needs a non-null context."); } // Ensure that this context has sufficient permissions to send debug events. @@ -129,13 +128,13 @@ public final class DebugEventReporter { PackageManager pm = sContext.getPackageManager(); if (pm == null) return; List packages = pm.queryBroadcastReceivers( - new Intent(TelephonyManager.ACTION_DEBUG_EVENT), + new Intent(TelephonyManager.ACTION_ANOMALY_REPORTED), PackageManager.MATCH_SYSTEM_ONLY | PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE); if (packages == null || packages.isEmpty()) return; if (packages.size() > 1) { - Rlog.e(TAG, "Multiple DebugEvent Receivers installed."); + Rlog.e(TAG, "Multiple Anomaly Receivers installed."); } for (ResolveInfo r : packages) { @@ -156,14 +155,14 @@ public final class DebugEventReporter { // Initialization may only be performed once. } - /** Dump the contents of the DebugEventReporter */ + /** Dump the contents of the AnomalyReporter */ public static void dump(FileDescriptor fd, PrintWriter printWriter, String[] args) { if (sContext == null) return; IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, " "); sContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, "Requires DUMP"); pw.println("Initialized=" + (sContext != null ? "Yes" : "No")); pw.println("Debug Package=" + sDebugPackageName); - pw.println("Event Counts:"); + pw.println("Anomaly Counts:"); pw.increaseIndent(); for (UUID event : sEvents.keySet()) { pw.println(event + ": " + sEvents.get(event)); diff --git a/telephony/java/android/telephony/CellIdentity.java b/telephony/java/android/telephony/CellIdentity.java index 7655834445b2..bda881293434 100644 --- a/telephony/java/android/telephony/CellIdentity.java +++ b/telephony/java/android/telephony/CellIdentity.java @@ -86,7 +86,7 @@ public abstract class CellIdentity implements Parcelable { } if ((mMccStr != null && mMncStr == null) || (mMccStr == null && mMncStr != null)) { - DebugEventReporter.sendEvent( + AnomalyReporter.reportAnomaly( UUID.fromString("a3ab0b9d-f2aa-4baf-911d-7096c0d4645a"), "CellIdentity Missing Half of PLMN ID"); } diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index ff9ae2237be4..8af6982dc466 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -1364,41 +1364,42 @@ public class TelephonyManager { * in the application manifest. For performance reasons, if no application to receive these * events is detected at boot, then these events will not be sent. * - *

Each event will include an {@link EXTRA_DEBUG_EVENT_ID} that will uniquely identify the + *

Each event will include an {@link EXTRA_ANOMALY_ID} that will uniquely identify the * event that has occurred. Each event will be sent to the diagnostic monitor only once per * boot cycle (as another optimization). * - * @see #EXTRA_DEBUG_EVENT_ID - * @see #EXTRA_DEBUG_EVENT_DESCRIPTION + * @see #EXTRA_ANOMALY_ID + * @see #EXTRA_ANOMALY_DESCRIPTION * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) - public static final String ACTION_DEBUG_EVENT = "android.telephony.action.DEBUG_EVENT"; + public static final String ACTION_ANOMALY_REPORTED = + "android.telephony.action.ANOMALY_REPORTED"; /** * An arbitrary ParcelUuid which should be consistent for each occurrence of a DebugEvent. * - * This field must be included in all {@link ACTION_DEBUG_EVENT} events. + * This field must be included in all {@link ACTION_ANOMALY_REPORTED} events. * - * @see #ACTION_DEBUG_EVENT + * @see #ACTION_ANOMALY_REPORTED * @hide */ @SystemApi - public static final String EXTRA_DEBUG_EVENT_ID = "android.telephony.extra.DEBUG_EVENT_ID"; + public static final String EXTRA_ANOMALY_ID = "android.telephony.extra.ANOMALY_ID"; /** - * A freeform string description of the DebugEvent. + * A freeform string description of the Anomaly. * - * This field is optional for all {@link ACTION_DEBUG_EVENT}s, as a guideline should not + * This field is optional for all {@link ACTION_ANOMALY_REPORTED}s, as a guideline should not * exceed 80 characters, and should be as short as possible to convey the essence of the event. * - * @see #ACTION_DEBUG_EVENT + * @see #ACTION_ANOMALY_REPORTED * @hide */ @SystemApi - public static final String EXTRA_DEBUG_EVENT_DESCRIPTION = - "android.telephony.extra.DEBUG_EVENT_DESCRIPTION"; + public static final String EXTRA_ANOMALY_DESCRIPTION = + "android.telephony.extra.ANOMALY_DESCRIPTION"; // // -- 2.11.0