Java Code Examples for androidx.annotation.VisibleForTesting#NONE

The following examples show how to use androidx.annotation.VisibleForTesting#NONE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GattConnection.java    From bitgatt with Mozilla Public License 2.0 5 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
public void simulateDisconnect() {
    if (this.mockMode) {
        setState(GattState.DISCONNECTED);
        for (ConnectionEventListener asyncConnListener : getConnectionEventListeners()) {
            asyncConnListener.onClientConnectionStateChanged(new TransactionResult.Builder()
                    .resultStatus(TransactionResult.TransactionResultStatus.FAILURE)
                    .gattState(getGattState())
                    .responseStatus(GattStatus.GATT_UNKNOWN.ordinal()).build(), this);
        }
    } else {
        throw new IllegalStateException(String.format(Locale.ENGLISH, "[%s] You can't simulate a disconnection if you are not in mock mode", getDevice()));
    }
}
 
Example 2
Source File: PeripheralScanner.java    From bitgatt with Mozilla Public License 2.0 5 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
@SuppressWarnings("SameParameterValue")
    // API Method
void populateMockScanResultIndividualValue(int callbackType, ScanResult scanResult) {
    if (callback != null) {
        callback.onScanResult(callbackType, scanResult);
    }
}
 
Example 3
Source File: FitbitGatt.java    From bitgatt with Mozilla Public License 2.0 5 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
FitbitGatt(AlwaysConnectedScanner alwaysConnectedScanner, Handler fitbitGattAsyncOperationHandler, Handler connectionCleanup, LooperWatchdog watchDog) {
    this.overallGattEventListeners = new CopyOnWriteArrayList<>();
    this.alwaysConnectedScanner = alwaysConnectedScanner;
    this.fitbitGattAsyncOperationHandler = fitbitGattAsyncOperationHandler;
    this.connectionCleanup = connectionCleanup;
    this.asyncOperationThreadWatchdog = watchDog;
}
 
Example 4
Source File: FitbitGatt.java    From bitgatt with Mozilla Public License 2.0 5 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
List<FitbitBluetoothDevice> getNewlyScannedDevicesOnly() {
    ArrayList<FitbitBluetoothDevice> devices = new ArrayList<>();
    for (FitbitBluetoothDevice iteratedDevice : getConnectionMap().keySet()) {
        if (iteratedDevice.origin.equals(FitbitBluetoothDevice.DeviceOrigin.SCANNED)) {
            devices.add(iteratedDevice);
        }
    }
    return devices;
}
 
Example 5
Source File: PeripheralScanner.java    From bitgatt with Mozilla Public License 2.0 4 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
void injectMockScanner(ScannerInterface scanner) {
    this.scanner = scanner;
}
 
Example 6
Source File: PeripheralScanner.java    From bitgatt with Mozilla Public License 2.0 4 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
void populateMockScanResultBatchValues(List<ScanResult> scanResults) {
    if (callback != null) {
        callback.onBatchScanResults(scanResults);
    }
}
 
Example 7
Source File: FitbitGatt.java    From bitgatt with Mozilla Public License 2.0 4 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
@SuppressWarnings({"unused", "WeakerAccess"})
    // API Method
List<GattClientListener> getAllGattClientListeners() {
    return getClientCallback().getGattClientListeners();
}
 
Example 8
Source File: FitbitGatt.java    From bitgatt with Mozilla Public License 2.0 4 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
void unregisterAllGattEventListeners() {
    overallGattEventListeners.clear();
}
 
Example 9
Source File: FitbitGatt.java    From bitgatt with Mozilla Public License 2.0 4 votes vote down vote up
/**
 * Do not do this unless you truly know what you are doing, there are very, very few reasons
 * to perform this operation.
 */
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
@SuppressWarnings({"unused", "WeakerAccess"})
// API Method
public void shutdown() {
    Timber.v("Someone wants to shutdown the gatt");
    this.overallGattEventListeners.clear();
    this.servicesToAdd.clear();
    this.connectionMap.clear();
    if (asyncOperationThreadWatchdog != null) {
        this.asyncOperationThreadWatchdog.stopProbing();
    }
    //clean up callbacks and listeners;
    if (serverCallback != null) {
        serverCallback.unregisterAll();
    }
    if (this.appContext != null && this.aclListener != null) {
        this.aclListener.unregister(this.appContext);
    }
    if (this.peripheralScanner != null) {
        this.peripheralScanner.onDestroy(this.appContext);
    }
    if (this.aclListener != null) {
        this.aclListener.unregister(this.appContext);
    }
    if (radioStatusListener != null) {
        radioStatusListener.stopListening();
        radioStatusListener.removeListener();
    }

    if(serverConnection != null) {
        List<ServerConnectionEventListener> serverConnectionEventListeners = serverConnection.getConnectionEventListeners();
        for (ServerConnectionEventListener serverConnectionEventListener : serverConnectionEventListeners) {
            serverConnection.unregisterConnectionEventListener(serverConnectionEventListener);
        }
        serverConnection.close();
        serverConnection = null;
        if(gattServer != null) {
            gattServer.close();
        }
    }
    //clear up all references
    this.gattServer = null;
    this.serverConnection = null;
    this.connectionCleanup = null;
    this.isInitialized.set(false);
    this.isGattClientStarted.set(false);
    this.isGattServerStarted.set(false);
    this.appContext = null;
    this.serverCallback = null;
    this.clientCallback = null;
    this.radioStatusListener = null;
    this.aclListener = null;
    this.peripheralScanner = null;
    this.asyncOperationThreadWatchdog = null;
}
 
Example 10
Source File: ComponentTree.java    From litho with Apache License 2.0 4 votes vote down vote up
@Nullable
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
@GuardedBy("this")
public LayoutState getCommittedLayoutState() {
  return mCommittedLayoutState;
}
 
Example 11
Source File: ParticlesView.java    From ParticlesDrawable with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
void setEmulateOnAttachToWindow(final boolean emulateOnAttachToWindow) {
    mEmulateOnAttachToWindow = emulateOnAttachToWindow;
}
 
Example 12
Source File: EndpointCall.java    From dhis2-android-sdk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
public CallFetcher<P> getFetcher() {
    return fetcher;
}
 
Example 13
Source File: EndpointCall.java    From dhis2-android-sdk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
public CallProcessor<P> getProcessor() {
    return processor;
}