下面列出了怎么用androidx.annotation.RestrictTo的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Removes an AppKey index that was added to the node
*
* @param index AppKey index
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
protected final void removeAddedAppKeyIndex(final int index) {
for (int i = 0; i < mAddedAppKeys.size(); i++) {
final int keyIndex = mAddedAppKeys.get(i).getIndex();
if (keyIndex == index) {
mAddedAppKeys.remove(i);
for (Map.Entry<Integer, Element> elementEntry : getElements().entrySet()) {
final Element element = elementEntry.getValue();
for (Map.Entry<Integer, MeshModel> modelEntry : element.getMeshModels().entrySet()) {
final MeshModel model = modelEntry.getValue();
if (model != null) {
for (int j = 0; j < model.getBoundAppKeyIndexes().size(); j++) {
final int boundKeyIndex = model.getBoundAppKeyIndexes().get(j);
if (boundKeyIndex == index) {
model.mBoundAppKeyIndexes.remove(j);
break;
}
}
}
}
}
break;
}
}
}
/**
* Returns the mesh database
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
static MeshNetworkDb getDatabase(final Context context) {
if (INSTANCE == null) {
synchronized (MeshNetworkDb.class) {
if (INSTANCE == null) {
INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
MeshNetworkDb.class, "mesh_network_database.db")
.addCallback(sRoomDatabaseCallback)
.addMigrations(MIGRATION_1_2)
.addMigrations(MIGRATION_2_3)
.addMigrations(MIGRATION_3_4)
.addMigrations(MIGRATION_4_5)
.addMigrations(MIGRATION_5_6)
.addMigrations(MIGRATION_6_7)
.addMigrations(MIGRATION_7_8)
.addMigrations(MIGRATION_8_9)
.build();
}
}
}
return INSTANCE;
}
/**
* Returns a copy of the context with modified {@link Priority}.
*
* @hide
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public TransportContext withPriority(Priority priority) {
return builder()
.setBackendName(getBackendName())
.setPriority(priority)
.setExtras(getExtras())
.build();
}
/** @hide */
@RestrictTo(LIBRARY)
@MainThread
synchronized void reset() {
if (DEBUG) Log.d(TAG, "Received reset request.");
if (mNumOps > 0) {
Log.w(TAG, "Resetting OperationMonitor with " + mNumOps + " active operations.");
}
mNumOps = 0;
notifyStateChanged();
}
/**
* Asserts that we are not on a suspending transaction.
*
* @hide
*/
@SuppressWarnings("WeakerAccess")
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
// used in generated code
public void assertNotSuspendingTransaction() {
if (!inTransaction() && mSuspendingTransactionId.get() != null) {
throw new IllegalStateException("Cannot access database on a different coroutine"
+ " context inherited from a suspending transaction.");
}
}
/**
* Sets the group address label
*
* @param uuidLabel UUID label of the address
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public void setAddressLabel(@Nullable final UUID uuidLabel) {
addressLabel = uuidLabel;
if (uuidLabel != null) {
address = MeshAddress.generateVirtualAddress(uuidLabel);
}
}
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public DeleteStorageTask(
@NonNull StorageReference storageRef, @NonNull TaskCompletionSource<Void> pendingResult) {
Preconditions.checkNotNull(storageRef);
Preconditions.checkNotNull(pendingResult);
this.mStorageRef = storageRef;
this.mPendingResult = pendingResult;
FirebaseStorage storage = mStorageRef.getStorage();
mSender =
new ExponentialBackoffSender(
storage.getApp().getApplicationContext(),
storage.getAuthProvider(),
storage.getMaxDownloadRetryTimeMillis());
}
/**
* Constructor to be used only by hte library
*
* @param node {@link UnprovisionedMeshNode}
*/
@Ignore
@RestrictTo(RestrictTo.Scope.LIBRARY)
public ProvisionedMeshNode(final UnprovisionedMeshNode node) {
uuid = node.getDeviceUuid().toString();
isConfigured = node.isConfigured();
nodeName = node.getNodeName();
mAddedNetKeys.add(new NodeKey(node.getKeyIndex()));
mFlags = node.getFlags();
unicastAddress = node.getUnicastAddress();
deviceKey = node.getDeviceKey();
ttl = node.getTtl();
final NetworkKey networkKey = new NetworkKey(node.getKeyIndex(), node.getNetworkKey());
mTimeStampInMillis = node.getTimeStamp();
}
/**
* <strong>For internal use</strong>
*
* @hide
* @param code The error code
* @return An error corresponding the to the code
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public static DatabaseError fromCode(int code) {
if (!errorReasons.containsKey(code)) {
throw new IllegalArgumentException("Invalid Firebase Database error code: " + code);
}
String message = errorReasons.get(code);
return new DatabaseError(code, message, null);
}
/**
* Update an app key's updated state
*
* @param index AppKey index
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
protected final void updateAddedAppKey(final int index) {
final NodeKey nodeKey = MeshParserUtils.getNodeKey(mAddedNetKeys, index);
if (nodeKey != null) {
nodeKey.setUpdated(true);
}
}
@RestrictTo(RestrictTo.Scope.LIBRARY)
@NonNull
public static CrashConfig getConfig() {
return config;
}
@VisibleForTesting
@RestrictTo(RestrictTo.Scope.TESTS)
DefaultHeartBeatInfo(HeartBeatInfoStorage testStorage) {
storage = testStorage;
}
/**
* Set security state of the node {@link SecurityState}
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public void setSecurity(@SecurityState final int security) {
this.security = security;
}
/**
* Sets the {@link SecureNetworkBeacon} beacon for this node
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public void setSecureNetworkBeaconSupported(final Boolean secureNetworkBeacon) {
this.secureNetworkBeaconSupported = secureNetworkBeacon;
}
@Inject
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public ImageBindingWrapper(
InAppMessageLayoutConfig config, LayoutInflater inflater, InAppMessage message) {
super(config, inflater, message);
}
@VisibleForTesting
@RestrictTo(RestrictTo.Scope.TESTS)
HeartBeatInfoStorage(SharedPreferences preferences) {
this.sharedPreferences = preferences;
}
@RestrictTo(RestrictTo.Scope.LIBRARY)
synchronized boolean isInitialized() {
return isInitialized.get();
}
@RestrictTo(RestrictTo.Scope.TESTS)
void setStarted(boolean isStarted) {
this.isInitialized.set(isStarted);
}
@RestrictTo(RestrictTo.Scope.TESTS)
void setAppContext(Context context) {
this.appContext = context;
}
@RestrictTo(RestrictTo.Scope.TESTS)
void setGattServerStarted(boolean isStarted) {
this.isGattServerStarted.set(isStarted);
}
@RestrictTo(RestrictTo.Scope.TESTS)
void setGattClientStarted(boolean isStarted) {
this.isGattClientStarted.set(isStarted);
}
@RestrictTo(RestrictTo.Scope.TESTS)
void setConnectionMap(ConcurrentHashMap<FitbitBluetoothDevice, GattConnection> map) {
this.connectionMap.clear();
this.connectionMap.putAll(map);
}
@RestrictTo(RestrictTo.Scope.TESTS)
void setPeripheralScanner(PeripheralScanner scanner) {
this.peripheralScanner = scanner;
}
@RestrictTo(RestrictTo.Scope.TESTS)
void setClientCallback(GattClientCallback callback) {
this.clientCallback = callback;
}
@Inject
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public CardBindingWrapper(
InAppMessageLayoutConfig config, LayoutInflater inflater, InAppMessage message) {
super(config, inflater, message);
}
@RestrictTo(RestrictTo.Scope.TESTS)
void setConnectionCleanup(Handler handler) {
this.connectionCleanup = handler;
}
@RestrictTo(RestrictTo.Scope.TESTS)
void setAsyncOperationThreadWatchdog(LooperWatchdog watchdog) {
this.asyncOperationThreadWatchdog = watchdog;
}
@RestrictTo(RestrictTo.Scope.TESTS)
void clearConnectionsMap() {
connectionMap.clear();
}
/**
* @return true if log statements that may slow down data transfer speeds should be executed
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public boolean isSlowLoggingEnabled() {
return slowLoggingEnabled;
}
@RestrictTo(RestrictTo.Scope.LIBRARY)
public ProvisionedBaseMeshNode() {
}