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

Commit d0549ae6 authored by Daulet Zhanguzin's avatar Daulet Zhanguzin Committed by Tobias Thierer
Browse files

Replace com.android.internal.util.Preconditions.checkNotNull with

java.util.Objects.requireNonNull

Bug: 126528330

Test: Treehugger
Exempt-From-Owner-Approval: Global refactoring.
Change-Id: Id4ec856dacf5a3310a1d5bfb7c4c56ff34c7f6c4
parent 6aefe5f5
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.systemui.statusbar.policy.RemoteInputView;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * Keeps track of the currently active {@link RemoteInputView}s.
@@ -108,8 +109,8 @@ public class RemoteInputController {
     * @param token a token identifying the view that is managing the remote input
     */
    public void addRemoteInput(NotificationEntry entry, Object token) {
        Preconditions.checkNotNull(entry);
        Preconditions.checkNotNull(token);
        Objects.requireNonNull(entry);
        Objects.requireNonNull(token);

        boolean found = pruneWeakThenRemoveAndContains(
                entry /* contains */, null /* remove */, token /* removeToken */);
@@ -129,7 +130,7 @@ public class RemoteInputController {
     *              entry. If null, the entry is removed regardless.
     */
    public void removeRemoteInput(NotificationEntry entry, Object token) {
        Preconditions.checkNotNull(entry);
        Objects.requireNonNull(entry);

        pruneWeakThenRemoveAndContains(null /* contains */, entry /* remove */, token);

@@ -143,8 +144,8 @@ public class RemoteInputController {
     * @param token the token of the view managing the remote input.
     */
    public void addSpinning(String key, Object token) {
        Preconditions.checkNotNull(key);
        Preconditions.checkNotNull(token);
        Objects.requireNonNull(key);
        Objects.requireNonNull(token);

        mSpinning.put(key, token);
    }
@@ -158,7 +159,7 @@ public class RemoteInputController {
     *              entry. If null, the entry is removed regardless.
     */
    public void removeSpinning(String key, Object token) {
        Preconditions.checkNotNull(key);
        Objects.requireNonNull(key);

        if (token == null || mSpinning.get(key) == token) {
            mSpinning.remove(key);
@@ -237,7 +238,7 @@ public class RemoteInputController {


    public void addCallback(Callback callback) {
        Preconditions.checkNotNull(callback);
        Objects.requireNonNull(callback);
        mCallbacks.add(callback);
    }

+5 −5
Original line number Diff line number Diff line
@@ -16,14 +16,14 @@

package com.android.systemui.statusbar.notification;

import static com.android.internal.util.Preconditions.checkNotNull;

import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener;

import java.util.Objects;

/**
 * Root controller for the list of notifications in the shade.
 *
@@ -39,9 +39,9 @@ public class NotificationListController {
            NotificationEntryManager entryManager,
            NotificationListContainer listContainer,
            DeviceProvisionedController deviceProvisionedController) {
        mEntryManager = checkNotNull(entryManager);
        mListContainer = checkNotNull(listContainer);
        mDeviceProvisionedController = checkNotNull(deviceProvisionedController);
        mEntryManager = Objects.requireNonNull(entryManager);
        mListContainer = Objects.requireNonNull(listContainer);
        mDeviceProvisionedController = Objects.requireNonNull(deviceProvisionedController);
    }

    /**
+2 −3
Original line number Diff line number Diff line
@@ -35,8 +35,6 @@ import static android.service.notification.NotificationListenerService.REASON_TI
import static android.service.notification.NotificationListenerService.REASON_UNAUTOBUNDLED;
import static android.service.notification.NotificationListenerService.REASON_USER_STOPPED;

import static com.android.internal.util.Preconditions.checkNotNull;

import android.annotation.IntDef;
import android.annotation.MainThread;
import android.annotation.NonNull;
@@ -60,6 +58,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import javax.inject.Inject;
import javax.inject.Singleton;
@@ -170,7 +169,7 @@ public class NotifCollection {
            @CancellationReason int reason,
            @NonNull DismissedByUserStats stats) {
        Assert.isMainThread();
        checkNotNull(stats);
        Objects.requireNonNull(stats);
        checkForReentrantCall();

        removeNotification(entry.getKey(), null, reason, stats);
+6 −7
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICAT
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_STATUS_BAR;

import static com.android.internal.util.Preconditions.checkNotNull;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_ALERTING;

import android.annotation.NonNull;
@@ -162,9 +161,9 @@ public final class NotificationEntry extends ListEntry {
    public NotificationEntry(
            @NonNull StatusBarNotification sbn,
            @NonNull Ranking ranking) {
        super(checkNotNull(checkNotNull(sbn).getKey()));
        super(Objects.requireNonNull(Objects.requireNonNull(sbn).getKey()));

        checkNotNull(ranking);
        Objects.requireNonNull(ranking);

        mKey = sbn.getKey();
        setSbn(sbn);
@@ -194,8 +193,8 @@ public final class NotificationEntry extends ListEntry {
     * TODO: Make this package-private
     */
    public void setSbn(@NonNull StatusBarNotification sbn) {
        checkNotNull(sbn);
        checkNotNull(sbn.getKey());
        Objects.requireNonNull(sbn);
        Objects.requireNonNull(sbn.getKey());

        if (!sbn.getKey().equals(mKey)) {
            throw new IllegalArgumentException("New key " + sbn.getKey()
@@ -223,8 +222,8 @@ public final class NotificationEntry extends ListEntry {
     * TODO: Make this package-private
     */
    public void setRanking(@NonNull Ranking ranking) {
        checkNotNull(ranking);
        checkNotNull(ranking.getKey());
        Objects.requireNonNull(ranking);
        Objects.requireNonNull(ranking.getKey());

        if (!ranking.getKey().equals(mKey)) {
            throw new IllegalArgumentException("New key " + ranking.getKey()
+3 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.statusbar.notification.collection;

import static com.android.internal.util.Preconditions.checkNotNull;
import static com.android.systemui.statusbar.NotificationRemoteInputManager.ENABLE_REMOTE_INPUT;
import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_HEADS_UP;

@@ -51,6 +50,8 @@ import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.HeadsUpManager;

import java.util.Objects;

/** Handles inflating and updating views for notifications. */
public class NotificationRowBinderImpl implements NotificationRowBinder {

@@ -265,7 +266,7 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
        row.inflateViews();

        // bind the click event to the content area
        checkNotNull(mNotificationClicker).register(row, sbn);
        Objects.requireNonNull(mNotificationClicker).register(row, sbn);
    }

    private void logNotificationExpansion(String key, boolean userAction, boolean expanded) {
Loading