Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1016587 authored by Jack Richardson's avatar Jack Richardson
Browse files

Prevent crash due to missing CUJ type.

Wear sysui is released from google3 and accesses jank monitor through reflection. This makes it harder to ensure we never install a apk that tries logging a CUJ that doenst exist on the platform yet due to it being an old build. If this ever happens, we should log the error instead of crashing.

Change-Id: I05cb432273b5cee5569b402f48cf2c9de3e07d30
Flag: NONE catching uncaught exception to reduce crashes in Wear
Bug: 429180834
parent 176292a1
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.internal.jank;

import android.annotation.IntDef;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.FrameworkStatsLog;
@@ -28,6 +29,8 @@ import java.util.Arrays;
/** @hide */
public class Cuj {
    @VisibleForTesting
    private static final String TAG = "Cuj";

    public static final int MAX_LENGTH_OF_CUJ_NAME = 82;

    // Every value must have a corresponding entry in CUJ_STATSD_INTERACTION_TYPE.
@@ -985,6 +988,10 @@ public class Cuj {
    }

    public static int getStatsdInteractionType(@CujType int cujType) {
      if (cujType < 0 || cujType >= CUJ_TO_STATSD_INTERACTION_TYPE.length) {
        Log.e(TAG, "getStatsdInteractionType: cujType: " + cujType + " is out of range.");
        return NO_STATSD_LOGGING;
      }
      return CUJ_TO_STATSD_INTERACTION_TYPE[cujType];
    }