androidx.annotation.VisibleForTesting#PACKAGE_PRIVATE源码实例Demo

下面列出了androidx.annotation.VisibleForTesting#PACKAGE_PRIVATE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: litho   文件: Component.java
/** Called to install internal state based on a component's parent context. */
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
protected void updateInternalChildState(ComponentContext parentContext) {
  if (ComponentsConfiguration.isDebugModeEnabled || ComponentsConfiguration.useGlobalKeys) {
    if (getGlobalKey() == null) {
      final String globalKey;
      if (ComponentsConfiguration.useNewGenerateMechanismForGlobalKeys) {
        globalKey = LayoutState.generateGlobalKey(parentContext, this);
      } else {
        globalKey = ComponentKeyUtils.generateGlobalKey(parentContext.getComponentScope(), this);
      }
      setGlobalKey(globalKey);
    }
  }

  applyStateUpdates(parentContext);
  generateErrorEventHandler(parentContext);

  // Needed for tests, mocks can run into this.
  if (mLayoutVersionGenerator != null) {
    mLayoutVersionGenerator.set(true);
  }
}
 
源代码2 项目: litho   文件: SectionContext.java
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
public static SectionContext withSectionTree(SectionContext context, SectionTree sectionTree) {
  SectionContext sectionContext = new SectionContext(context);
  sectionContext.mSectionTree = sectionTree;
  sectionContext.mTreeLoadingEventHandler = new SectionTreeLoadingEventHandler(sectionTree);

  return sectionContext;
}
 
源代码3 项目: bitgatt   文件: FitbitGatt.java
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
public synchronized void putConnectionIntoDevices(FitbitBluetoothDevice device, GattConnection conn) {
    // we don't want duplicate connections in the map
    if (!connectionMap.containsKey(device)) {
        connectionMap.put(device, conn);
        // since this directly calls notify listeners of connection added
        // we will need to synchronize around those listeners since
        // someone could be adding or removing a listener while this asynchronous
        // call happens.  To do this easily, we will use a
        // CopyOnWriteArrayList for the {@link FitbitGattCallback}
        FitbitGatt.getInstance().notifyListenersOfConnectionAdded(conn);
    }
}
 
源代码4 项目: FairEmail   文件: InvalidationTracker.java
/**
 * Notifies all the registered {@link Observer}s of table changes.
 * <p>
 * This can be used for notifying invalidation that cannot be detected by this
 * {@link InvalidationTracker}, for example, invalidation from another process.
 *
 * @param tables The invalidated tables.
 * @hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY)
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
public void notifyObserversByTableNames(String... tables) {
    synchronized (mObserverMap) {
        for (Map.Entry<Observer, ObserverWrapper> entry : mObserverMap) {
            if (!entry.getKey().isRemote()) {
                entry.getValue().notifyByTableNames(tables);
            }
        }
    }
}
 
源代码5 项目: litho   文件: ComponentContext.java
/**
 * Creates a new ComponentContext instance and sets the {@link ComponentTree} on the component.
 *
 * @param context context scoped to the parent component
 * @param componentTree component tree associated with the newly created context
 * @return a new ComponentContext instance
 */
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
public static ComponentContext withComponentTree(
    ComponentContext context, ComponentTree componentTree) {
  ComponentContext componentContext =
      new ComponentContext(context, new StateHandler(), null, null);
  componentContext.mComponentTree = componentTree;
  componentContext.mComponentScope = null;

  return componentContext;
}
 
源代码6 项目: bitgatt   文件: GattPlugin.java
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
String getStringRepresentationOfPropertiesForCharacteristic(BluetoothGattCharacteristic characteristic) {
    StringBuilder propertyBuilder = new StringBuilder();
    ArrayList<Integer> properties = new ArrayList<>(8);
    int characteristicProperties = characteristic.getProperties();
    if ((characteristicProperties & BluetoothGattCharacteristic.PROPERTY_READ) == BluetoothGattCharacteristic.PROPERTY_READ) {
        properties.add(BluetoothGattCharacteristic.PROPERTY_READ);
    }
    if ((characteristicProperties & BluetoothGattCharacteristic.PROPERTY_WRITE) == BluetoothGattCharacteristic.PROPERTY_WRITE) {
        properties.add(BluetoothGattCharacteristic.PROPERTY_WRITE);
    }
    if ((characteristicProperties & BluetoothGattCharacteristic.PROPERTY_BROADCAST) == BluetoothGattCharacteristic.PROPERTY_BROADCAST) {
        properties.add(BluetoothGattCharacteristic.PROPERTY_BROADCAST);
    }
    if ((characteristicProperties & BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS) == BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS) {
        properties.add(BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS);
    }
    if ((characteristicProperties & BluetoothGattCharacteristic.PROPERTY_INDICATE) == BluetoothGattCharacteristic.PROPERTY_INDICATE) {
        properties.add(BluetoothGattCharacteristic.PROPERTY_INDICATE);
    }
    if ((characteristicProperties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) == BluetoothGattCharacteristic.PROPERTY_NOTIFY) {
        properties.add(BluetoothGattCharacteristic.PROPERTY_NOTIFY);
    }
    if ((characteristicProperties & BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE) == BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE) {
        properties.add(BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE);
    }
    if ((characteristicProperties & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) == BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) {
        properties.add(BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE);
    }
    for (int i = 0; i < properties.size(); i++) {
        int property = properties.get(i);
        switch (property) {
            case BluetoothGattCharacteristic.PROPERTY_READ:
                propertyBuilder.append("read");
                break;
            case BluetoothGattCharacteristic.PROPERTY_WRITE:
                propertyBuilder.append("write");
                break;
            case BluetoothGattCharacteristic.PROPERTY_BROADCAST:
                propertyBuilder.append("broadcast");
                break;
            case BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS:
                propertyBuilder.append("extended-props");
                break;
            case BluetoothGattCharacteristic.PROPERTY_NOTIFY:
                propertyBuilder.append("notify");
                break;
            case BluetoothGattCharacteristic.PROPERTY_INDICATE:
                propertyBuilder.append("indicate");
                break;
            case BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE:
                propertyBuilder.append("write-signed");
                break;
            case BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE:
                propertyBuilder.append("write-no-response");
                break;
            default:
                propertyBuilder.append("unknown");
        }
        if (i < properties.size() - 1) {
            propertyBuilder.append(", ");
        }
    }
    return propertyBuilder.toString();
}
 
源代码7 项目: bitgatt   文件: GattPlugin.java
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
String getStringRepresentationOfPermissionsForCharacteristic(BluetoothGattCharacteristic characteristic) {
    StringBuilder permissionBuilder = new StringBuilder();
    ArrayList<Integer> permissions = new ArrayList<>(8);
    int characteristicPermissions = characteristic.getPermissions();
    if ((characteristicPermissions & BluetoothGattCharacteristic.PERMISSION_READ) == BluetoothGattCharacteristic.PERMISSION_READ) {
        permissions.add(BluetoothGattCharacteristic.PERMISSION_READ);
    }
    if ((characteristicPermissions & BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED) == BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED) {
        permissions.add(BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED);
    }
    if ((characteristicPermissions & BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED_MITM) == BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED_MITM) {
        permissions.add(BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED_MITM);
    }
    if ((characteristicPermissions & BluetoothGattCharacteristic.PERMISSION_WRITE) == BluetoothGattCharacteristic.PERMISSION_WRITE) {
        permissions.add(BluetoothGattCharacteristic.PERMISSION_WRITE);
    }
    if ((characteristicPermissions & BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED) == BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED) {
        permissions.add(BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED);
    }
    if ((characteristicPermissions & BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED_MITM) == BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED_MITM) {
        permissions.add(BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED_MITM);
    }
    if ((characteristicPermissions & BluetoothGattCharacteristic.PERMISSION_WRITE_SIGNED) == BluetoothGattCharacteristic.PERMISSION_WRITE_SIGNED) {
        permissions.add(BluetoothGattCharacteristic.PERMISSION_WRITE_SIGNED);
    }
    if ((characteristicPermissions & BluetoothGattCharacteristic.PERMISSION_WRITE_SIGNED_MITM) == BluetoothGattCharacteristic.PERMISSION_WRITE_SIGNED_MITM) {
        permissions.add(BluetoothGattCharacteristic.PERMISSION_WRITE_SIGNED_MITM);
    }
    for (int i = 0; i < permissions.size(); i++) {
        int permission = permissions.get(i);
        switch (permission) {
            case BluetoothGattCharacteristic.PERMISSION_READ:
                permissionBuilder.append("read");
                break;
            case BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED:
                permissionBuilder.append("read-encrypted");
                break;
            case BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED_MITM:
                permissionBuilder.append("read-encrypted-mitm");
                break;
            case BluetoothGattCharacteristic.PERMISSION_WRITE:
                permissionBuilder.append("write");
                break;
            case BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED:
                permissionBuilder.append("write-encrypted");
                break;
            case BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED_MITM:
                permissionBuilder.append("write-encrypted-mitm");
                break;
            case BluetoothGattCharacteristic.PERMISSION_WRITE_SIGNED:
                permissionBuilder.append("write-signed");
                break;
            case BluetoothGattCharacteristic.PERMISSION_WRITE_SIGNED_MITM:
                permissionBuilder.append("write-signed-mitm");
                break;
            default:
                permissionBuilder.append("unknown");
        }
        if (i < permissions.size() - 1) {
            permissionBuilder.append(", ");
        }
    }
    return permissionBuilder.toString();
}
 
源代码8 项目: bitgatt   文件: GattTransaction.java
/**
 * Will execute the transaction's discreet operations, will return before executing all transactions
 * if a transaction status of fail or timeout is returned before the last transaction, transactions
 * will be executed in the order that they were added.
 * <p>
 * All transaction callbacks will occur on the fbgatt thread associated with the connection,
 * unless they are performing GATT operations which will result on the callback being delivered
 * on the main thread.  If the user needs to transition back to the main thread for a non-gatt
 * operation, they will have to make that transition themselves.
 */
@VisibleForTesting( otherwise = VisibleForTesting.PACKAGE_PRIVATE)
public void commit(GattTransactionCallback callback) {
    // get main looper would only be null in a test, unless mocked
    // we have to do all of this null checking for connection because of a contract with fbairlink
    // that makes the transaction connection constructor accept null, we should review this
    // contract after the launch of Golden Gate.
    Looper mainLooper = this.appContext.getMainLooper();
    if(getConnection() != null && getConnection().getClientTransactionQueueController() != null) {
        if (mainLooper != null &&
                (Thread.currentThread().equals(mainLooper.getThread()))) {
            throw new IllegalStateException(String.format(Locale.ENGLISH,
                    "[%s] This transaction %s is not allowed to run on the %s thread",
                    getDevice(),
                    getName(),
                    mainLooper.getThread()));
        }
    } else if(getGattServer() != null && getGattServer().getServerTransactionQueueController() != null) {
        if (mainLooper != null &&
                (Thread.currentThread().equals(mainLooper.getThread()))) {
            throw new IllegalStateException(String.format(Locale.ENGLISH,
                    "[%s] This transaction %s is not allowed to run on the %s thread",
                    getDevice(),
                    getName(),
                    mainLooper.getThread()));
        }
    } else {
        throw new IllegalStateException(String.format(Locale.ENGLISH, "[%s] This transaction can not be run because there is no connection to support it", getDevice()));
    }
    if (taskHasStarted.getAndSet(true)) {
        throw new IllegalStateException(String.format(Locale.ENGLISH, "[%s] This transaction was already started!", getDevice()));
    }
    // let's allocate the array to the proper size ( why let it grow and waste cycles )
    ArrayList<GattTransaction> transactions = new ArrayList<>(preCommitHooks.size() + postCommitHooks.size() + 1);
    // if this is a composite transaction, we will want to make sure that while intermediate callbacks can be called back
    // we hold a reference to the parent tx and call it on tx complete
    synchronized (hookLock) {
        this.callback = callback;
        transactions.addAll(preCommitHooks);
        transactions.add(this);
        transactions.addAll(postCommitHooks);
    }
    // the entire transaction must complete in {@link timeout} time.
    scheduleTransactionTimeout(this, callback);
    while (!transactions.isEmpty()) {
        GattTransaction tx = transactions.remove(0);
        if (!areConditionsValidForExecution(tx)) {
            if (connection != null) {
                Timber.i("[%s] The transaction couldn't be run because the connection is in %s state", getDevice(), connection.getGattState());
            } else {
                Timber.w("[%s] The transaction couldn't be run because there is no connection", getDevice());
            }
            return;
        }
        if (this.haltChain) {
            Timber.w("[%s] We are aborting the chain because a transaction failed", getDevice());
            return;
        }
        executeTransaction(tx, callback);
        // in the case of the composite transaction, this can lead to the composite transaction
        // scheduler being interrupted which will throw on await.  If we are cancelled at this
        // point, we should quietly end.
        if(!Thread.currentThread().isAlive() || Thread.currentThread().isInterrupted()) {
            Timber.i("Already stopped");
            return;
        }
        try {
            cdl.await(timeout, TimeUnit.MILLISECONDS);
        } catch (InterruptedException e) {
            Timber.d("Transaction was interrupted while waiting for result, re-interrupting thread : %s", Thread.currentThread().getName());
            Thread.currentThread().interrupt();
            return;
        }
    }
    if (FitbitGatt.getInstance().isSlowLoggingEnabled()) {
        Timber.v("[%s] Completed running all pre-commit, post-commit, and main transactions", getDevice());
    }
}
 
源代码9 项目: firebase-android-sdk   文件: AbtComponent.java
/** Firebase ABT Component constructor. */
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
protected AbtComponent(Context appContext, AnalyticsConnector analyticsConnector) {
  this.appContext = appContext;
  this.analyticsConnector = analyticsConnector;
}
 
源代码10 项目: react-native-navigation   文件: ViewController.java
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
public void ensureViewIsCreated() {
    getView();
}
 
源代码11 项目: litho   文件: Children.java
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
public List<Section> getChildren() {
  return mSections;
}
 
源代码12 项目: litho   文件: Section.java
/** @return a unique key for this {@link Section} within its tree. */
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
public String getGlobalKey() {
  return mGlobalKey;
}
 
源代码13 项目: litho   文件: Section.java
/** Set a unique key for this {@link Section} within its tree. */
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
public void setGlobalKey(String key) {
  mGlobalKey = key;
}
 
源代码14 项目: litho   文件: Section.java
/**
 * Sets the key for this Section. This is only used for testing as the key will be set from the
 * {@link Builder}
 */
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
public void setKey(String key) {
  mKey = key;
}
 
源代码15 项目: litho   文件: Section.java
/**
 * @return te total number of {@link com.facebook.litho.Component} that the subtree of {@link
 *     Section}s having its root in this {@link Section} generated.
 */
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
int getCount() {
  return mCount;
}
 
源代码16 项目: litho   文件: Section.java
/**
 * Sets the total number of {@link com.facebook.litho.Component} that the subtree of {@link
 * Section}s having its root in this {@link Section} generated.
 */
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
public void setCount(int count) {
  mCount = count;
}
 
源代码17 项目: litho   文件: Section.java
/** @return the direct children of this {@link Section}. */
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
public List<Section> getChildren() {
  return mChildren;
}
 
源代码18 项目: litho   文件: Section.java
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
public void setChildren(Children children) {
  mChildren = children == null ? new ArrayList<Section>() : children.getChildren();
}
 
源代码19 项目: litho   文件: Change.java
/**
 * @return the Component that will render this Change (if this Change is either an INSERT or an
 *     UPDATE).
 */
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
public RenderInfo getRenderInfo() {
  return mRenderInfo;
}
 
源代码20 项目: braintree_android   文件: BraintreeFragment.java
/**
 * Check if this Braintree fragment is still active.
 *
 * @return {@code true} if still active and process can proceed, {@code false} otherwise.
 */
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
public boolean isActive() {
    return isAdded();
}