Skip to content

Commit

Permalink
Add missing final modifier in :shadows:framework
Browse files Browse the repository at this point in the history
This commit adds the `final` keyword where it was missing.
  • Loading branch information
MGaetan89 committed Jan 24, 2025
1 parent dc56e51 commit ff47b35
Show file tree
Hide file tree
Showing 55 changed files with 106 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.robolectric.util.Logger;

public class ContentProviderController<T extends ContentProvider> {
private T contentProvider;
private final T contentProvider;

private ContentProviderController(T contentProvider) {
this.contentProvider = contentProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/** Robolectric implementation of {@link android.content.IntentSender}. */
public class RoboIntentSender extends IntentSender {
public Intent intent;
private PendingIntent pendingIntent;
private final PendingIntent pendingIntent;

public RoboIntentSender(PendingIntent pendingIntent) {
super((IIntentSender) null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

/** Robolectric implementation of {@link android.view.Menu}. */
public class RoboMenu implements Menu {
private List<MenuItem> menuItems = new ArrayList<>();
private Context context;
private final List<MenuItem> menuItems = new ArrayList<>();
private final Context context;

public RoboMenu() {
this(RuntimeEnvironment.getApplication());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public class CachedPathIterator implements PathIterator {
*
* @see PathIterator
*/
private float[] mCurrentCoords = new float[6];
private final float[] mCurrentCoords = new float[6];

private float mCurrentSegmentLength;

Expand All @@ -293,7 +293,7 @@ public class CachedPathIterator implements PathIterator {
private float mOffsetLength;

/** Point where the current segment started */
private float[] mLastPoint = new float[2];
private final float[] mLastPoint = new float[2];

private boolean isIteratorDone;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

public class LooperShadowPicker<T> implements ShadowPicker<T> {

private Class<? extends T> legacyShadowClass;
private Class<? extends T> pausedShadowClass;
private final Class<? extends T> legacyShadowClass;
private final Class<? extends T> pausedShadowClass;

public LooperShadowPicker(
Class<? extends T> legacyShadowClass, Class<? extends T> pausedShadowClass) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ NativeBitSet64 getBits() {
}

// Values of axes that are stored in this structure
private float[] values = new float[MAX_AXES];
private final float[] values = new float[MAX_AXES];

public void clear() {
bits.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

/** Builder for {@link PolicyState} */
public class PolicyStateBuilder {
private Map<EnforcingAdmin, PolicyValue<?>> policiesSetByAdmins =
private final Map<EnforcingAdmin, PolicyValue<?>> policiesSetByAdmins =
new LinkedHashMap<EnforcingAdmin, PolicyValue<?>>();
private PolicyValue<?> currentResolvedPolicy;

private PolicyStateBuilder() {}

private PolicyState<?> policyState = reflector(PolicyStateReflector.class).newPolicyState();
private final PolicyState<?> policyState = reflector(PolicyStateReflector.class).newPolicyState();

public static PolicyStateBuilder newBuilder() {
return new PolicyStateBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

public class ResourceModeShadowPicker<T> implements ShadowPicker<T> {

private Class<? extends T> binaryShadowClass;
private Class<? extends T> binary9ShadowClass;
private Class<? extends T> binary10ShadowClass;
private Class<? extends T> binary14ShadowClass;
private final Class<? extends T> binaryShadowClass;
private final Class<? extends T> binary9ShadowClass;
private final Class<? extends T> binary10ShadowClass;
private final Class<? extends T> binary14ShadowClass;
private Class<? extends T> nativeShadowClass;

public ResourceModeShadowPicker(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@
@Implements(AccountManager.class)
public class ShadowAccountManager {

private List<Account> accounts = new ArrayList<>();
private Map<Account, Map<String, String>> authTokens = new HashMap<>();
private Map<String, AuthenticatorDescription> authenticators = new LinkedHashMap<>();
private final List<Account> accounts = new ArrayList<>();
private final Map<Account, Map<String, String>> authTokens = new HashMap<>();
private final Map<String, AuthenticatorDescription> authenticators = new LinkedHashMap<>();

/**
* Maps listeners to a set of account types. If null, the listener should be notified for changes
* to accounts of any type. Otherwise, the listener is only notified of changes to accounts of the
* given type.
*/
private Map<OnAccountsUpdateListener, Set<String>> listeners = new LinkedHashMap<>();
private final Map<OnAccountsUpdateListener, Set<String>> listeners = new LinkedHashMap<>();

private Map<Account, Map<String, String>> userData = new HashMap<>();
private Map<Account, String> passwords = new HashMap<>();
private Map<Account, Set<String>> accountFeatures = new HashMap<>();
private Map<Account, Set<String>> packageVisibleAccounts = new HashMap<>();
private final Map<Account, Map<String, String>> userData = new HashMap<>();
private final Map<Account, String> passwords = new HashMap<>();
private final Map<Account, Set<String>> accountFeatures = new HashMap<>();
private final Map<Account, Set<String>> packageVisibleAccounts = new HashMap<>();

private List<Bundle> addAccountOptionsList = new ArrayList<>();
private final List<Bundle> addAccountOptionsList = new ArrayList<>();
private static Handler mainHandler;
private static RoboAccountManagerFuture pendingAddFuture;
private static boolean authenticationErrorOnNextResponse = false;
Expand Down Expand Up @@ -608,7 +608,7 @@ public void addAuthenticator(String type) {
addAuthenticator(AuthenticatorDescription.newKey(type));
}

private Map<Account, String> previousNames = new HashMap<Account, String>();
private final Map<Account, String> previousNames = new HashMap<Account, String>();

/**
* Sets the previous name for an account, which will be returned by {@link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ public class ShadowActivity extends ShadowContextThemeWrapper {
private Integer lastShownDialogId = null;
private int pendingTransitionEnterAnimResId = -1;
private int pendingTransitionExitAnimResId = -1;
private SparseArray<OverriddenActivityTransition> overriddenActivityTransitions =
private final SparseArray<OverriddenActivityTransition> overriddenActivityTransitions =
new SparseArray<>();
private Object lastNonConfigurationInstance;
private Map<Integer, Dialog> dialogForId = new HashMap<>();
private ArrayList<Cursor> managedCursors = new ArrayList<>();
private final Map<Integer, Dialog> dialogForId = new HashMap<>();
private final ArrayList<Cursor> managedCursors = new ArrayList<>();
private int mDefaultKeyMode = Activity.DEFAULT_KEYS_DISABLE;
private SpannableStringBuilder mDefaultKeySsb = null;
private int streamType = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@SuppressWarnings({"UnusedDeclaration"})
@Implements(AdapterView.class)
public class ShadowAdapterView<T extends Adapter> extends ShadowViewGroup {
private static int ignoreRowsAtEndOfList = 0;
private static final int ignoreRowsAtEndOfList = 0;

@RealObject private AdapterView<T> realAdapterView;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/** Bridge between shadows and {@link android.view.animation.Animation}. */
@DoNotInstrument
public class ShadowAnimationBridge {
private Animation realAnimation;
private final Animation realAnimation;

public ShadowAnimationBridge(Animation realAnimation) {
this.realAnimation = realAnimation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class ShadowAppWidgetManager {
private static boolean requestPinAppWidgetSupported = false;
private static boolean validWidgetProviderComponentName = true;
private final ArrayList<AppWidgetProviderInfo> installedProviders = new ArrayList<>();
private Multimap<UserHandle, AppWidgetProviderInfo> installedProvidersForProfile =
private final Multimap<UserHandle, AppWidgetProviderInfo> installedProvidersForProfile =
HashMultimap.create();
private Context context;
private final Map<Integer, WidgetInfo> widgetInfos = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
public class ShadowApplication extends ShadowContextWrapper {
@RealObject private Application realApplication;

private List<android.widget.Toast> shownToasts = new ArrayList<>();
private final List<android.widget.Toast> shownToasts = new ArrayList<>();
private ShadowPopupMenu latestPopupMenu;
private PopupWindow latestPopupWindow;
private ListPopupWindow latestListPopupWindow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class ShadowAudioManager {
private int nextResponseValue = AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
private AudioManager.OnAudioFocusChangeListener lastAbandonedAudioFocusListener;
private android.media.AudioFocusRequest lastAbandonedAudioFocusRequest;
private HashMap<Integer, AudioStream> streamStatus = new HashMap<>();
private final HashMap<Integer, AudioStream> streamStatus = new HashMap<>();
private List<AudioPlaybackConfiguration> activePlaybackConfigurations = Collections.emptyList();
private List<AudioRecordingConfiguration> activeRecordingConfigurations = ImmutableList.of();
private final HashSet<AudioManager.AudioRecordingCallback> audioRecordingCallbacks =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/** Bridge between shadow and {@link android.os.Binder}. */
@DoNotInstrument
public class ShadowBinderBridge {
private Binder realBinder;
private final Binder realBinder;

public ShadowBinderBridge(Binder realBinder) {
this.realBinder = realBinder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
@SuppressWarnings({"UnusedDeclaration"})
@Implements(BitmapFactory.class)
public class ShadowBitmapFactory {
private static Map<String, Point> widthAndHeightMap = new HashMap<>();
private static final Map<String, Point> widthAndHeightMap = new HashMap<>();

// Determines whether BitmapFactory.decode methods should allow invalid bitmap data and always
// return a Bitmap object. Currently defaults to true to preserve legacy behavior. A
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class ShadowBluetoothAdapter {
private static final Map<String, BluetoothDevice> deviceCache = new HashMap<>();
private Set<BluetoothDevice> bondedDevices = new HashSet<BluetoothDevice>();
private List<BluetoothDevice> mostRecentlyConnectedDevices = new ArrayList<>();
private Set<LeScanCallback> leScanCallbacks = new HashSet<LeScanCallback>();
private final Set<LeScanCallback> leScanCallbacks = new HashSet<LeScanCallback>();
private boolean isDiscovering;
private String address;
private int state;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static void reset() {
private boolean isInSilenceMode = false;
private boolean isConnected = false;
@Nullable private BluetoothGattConnectionInterceptor bluetoothGattConnectionInterceptor = null;
private Map<Integer, Integer> connectionHandlesByTransportType = new HashMap<>();
private final Map<Integer, Integer> connectionHandlesByTransportType = new HashMap<>();

/**
* Implements getService() in the same way the original method does, but ignores any Exceptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
public final class ShadowCallScreeningService {
/** Contains the parameters used to call {@link CallScreeningService#respondToCall}. */
public static final class RespondToCallInput {
private Call.Details callDetails;
private CallResponse callResponse;
private final Call.Details callDetails;
private final CallResponse callResponse;

public RespondToCallInput(Call.Details callDetails, CallResponse callResponse) {
this.callDetails = callDetails;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class ShadowCamera {
private boolean released;
private Camera.Parameters parameters;
private Camera.PreviewCallback previewCallback;
private List<byte[]> callbackBuffers = new ArrayList<>();
private final List<byte[]> callbackBuffers = new ArrayList<>();
private SurfaceHolder surfaceHolder;
private int displayOrientation;
private Camera.AutoFocusCallback autoFocusCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ public class ShadowConnectivityManager {
private static int networkPreference = ConnectivityManager.DEFAULT_NETWORK_PREFERENCE;
private static final Map<Integer, NetworkInfo> networkTypeToNetworkInfo = new HashMap<>();

private static HashSet<ConnectivityManager.NetworkCallback> networkCallbacks = new HashSet<>();
private static final HashSet<ConnectivityManager.NetworkCallback> networkCallbacks =
new HashSet<>();
private static final HashSet<PendingIntent> networkCallbackPendingIntents = new HashSet<>();

private static final Map<Integer, Network> netIdToNetwork = new HashMap<>();
private static final Map<Integer, NetworkInfo> netIdToNetworkInfo = new HashMap<>();
private static Network processBoundNetwork;
private static boolean defaultNetworkActive = true;
private static HashSet<ConnectivityManager.OnNetworkActiveListener> onNetworkActiveListeners =
new HashSet<>();
private static Map<Network, Boolean> reportedNetworkConnectivity = new HashMap<>();
private static Map<Network, NetworkCapabilities> networkCapabilitiesMap = new HashMap<>();
private static final HashSet<ConnectivityManager.OnNetworkActiveListener>
onNetworkActiveListeners = new HashSet<>();
private static final Map<Network, Boolean> reportedNetworkConnectivity = new HashMap<>();
private static final Map<Network, NetworkCapabilities> networkCapabilitiesMap = new HashMap<>();
private static String captivePortalServerUrl = "http://10.0.0.2";
private static final Map<Network, LinkProperties> linkPropertiesMap = new HashMap<>();
private static final Map<Network, ProxyInfo> proxyInfoMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
public class ShadowDateIntervalFormat {

private static long address;
private static Map<Long, com.ibm.icu.text.DateIntervalFormat> INTERVAL_CACHE = new HashMap<>();
private static final Map<Long, com.ibm.icu.text.DateIntervalFormat> INTERVAL_CACHE =
new HashMap<>();

@Implementation(maxSdk = LOLLIPOP_MR1)
public static long createDateIntervalFormat(String skeleton, String localeName, String tzName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ public PackageAndPermission(String packageName, String permission) {
this.permission = permission;
}

private String packageName;
private String permission;
private final String packageName;
private final String permission;

@Override
public boolean equals(Object o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
@Implements(className = "android.view.DisplayEventReceiver", isInAndroidSdk = false)
public class ShadowDisplayEventReceiver {

private static NativeObjRegistry<NativeDisplayEventReceiver> nativeObjRegistry =
private static final NativeObjRegistry<NativeDisplayEventReceiver> nativeObjRegistry =
new NativeObjRegistry<>(NativeDisplayEventReceiver.class);

@RealObject protected DisplayEventReceiver realReceiver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public class ShadowDownloadManager {

private static long queueCounter =
-1; // First request starts at 0 just like in the real DownloadManager
private static Map<Long, DownloadManager.Request> requestMap = new TreeMap<>();
private static final Map<Long, DownloadManager.Request> requestMap = new TreeMap<>();

private static long completedCounter = -1;
private static Map<Long, CompletedDownload> completedDownloadsMap = new HashMap<>();
private static final Map<Long, CompletedDownload> completedDownloadsMap = new HashMap<>();

@Resetter
public static void reset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ public class ShadowHttpResponseCache {
private File directory;
private long maxSize;
private int requestCount = 0;

@SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"})
private int hitCount = 0;

private int networkCount = 0;

@Implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public class ShadowLegacyCanvas extends ShadowCanvas {
@ReflectorObject protected CanvasReflector canvasReflector;

private final List<RoundRectPaintHistoryEvent> roundRectPaintEvents = new ArrayList<>();
private List<PathPaintHistoryEvent> pathPaintEvents = new ArrayList<>();
private List<CirclePaintHistoryEvent> circlePaintEvents = new ArrayList<>();
private List<ArcPaintHistoryEvent> arcPaintEvents = new ArrayList<>();
private List<RectPaintHistoryEvent> rectPaintEvents = new ArrayList<>();
private List<LinePaintHistoryEvent> linePaintEvents = new ArrayList<>();
private List<OvalPaintHistoryEvent> ovalPaintEvents = new ArrayList<>();
private List<TextHistoryEvent> drawnTextEventHistory = new ArrayList<>();
private final List<PathPaintHistoryEvent> pathPaintEvents = new ArrayList<>();
private final List<CirclePaintHistoryEvent> circlePaintEvents = new ArrayList<>();
private final List<ArcPaintHistoryEvent> arcPaintEvents = new ArrayList<>();
private final List<RectPaintHistoryEvent> rectPaintEvents = new ArrayList<>();
private final List<LinePaintHistoryEvent> linePaintEvents = new ArrayList<>();
private final List<OvalPaintHistoryEvent> ovalPaintEvents = new ArrayList<>();
private final List<TextHistoryEvent> drawnTextEventHistory = new ArrayList<>();
private Paint drawnPaint;
private Bitmap targetBitmap = ReflectionHelpers.callConstructor(Bitmap.class);
private float translateX;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class ShadowLegacyChoreographer extends ShadowChoreographer {
private static long FRAME_INTERVAL = Duration.ofMillis(10).toNanos();
private static final Thread MAIN_THREAD = Thread.currentThread();
private static SoftThreadLocal<Choreographer> instance = makeThreadLocal();
private Handler handler = new Handler(Looper.myLooper());
private final Handler handler = new Handler(Looper.myLooper());
private static volatile int postCallbackDelayMillis = 0;
private static volatile int postFrameCallbackDelayMillis = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ShadowLegacyLooper extends ShadowLooper {
// is called. This also allows us to implement the useful getLooperForThread() method.
// Note that the main looper is handled differently and is not put in this hash, because we need
// to be able to "switch" the thread that the main looper is associated with.
private static Map<Thread, Looper> loopingLoopers =
private static final Map<Thread, Looper> loopingLoopers =
Collections.synchronizedMap(new WeakHashMap<Thread, Looper>());

private static Looper mainLooper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// turn off shadowOf generation
isInAndroidSdk = false)
public class ShadowLegacySystemClock extends ShadowSystemClock {
private static long bootedAt = 0;
private static final long bootedAt = 0;
private static long nanoTime = 0;
private static final int MILLIS_PER_NANO = 1000000;

Expand Down
Loading

0 comments on commit ff47b35

Please sign in to comment.