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

Commit b6325f3a authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Android (Google) Code Review
Browse files

Merge "Add an overload of IntentFilter#countActions() to avoid NPE." into main

parents 5cc2247e 3b3d4148
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -822,6 +822,16 @@ public class IntentFilter implements Parcelable {
        return mActions.size();
    }

    /**
     * Returns the number of actions in the filter, or {@code 0} if there are no actions.
     * <p> This method provides a safe alternative to {@link #countActions()}, which
     * may throw an exception if there are no actions.
     * @hide
     */
    public final int safeCountActions() {
        return mActions == null ? 0 : mActions.size();
    }

    /**
     * Return an action in the filter.
     */
+1 −1
Original line number Diff line number Diff line
@@ -14642,7 +14642,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            final StringBuilder sb = new StringBuilder("registerReceiver: ");
            sb.append(Binder.getCallingUid()); sb.append('/');
            sb.append(receiverId == null ? "null" : receiverId); sb.append('/');
            final int actionsCount = filter.countActions();
            final int actionsCount = filter.safeCountActions();
            if (actionsCount > 0) {
                for (int i = 0; i < actionsCount; ++i) {
                    sb.append(filter.getAction(i));