android.support.annotation.RestrictTo Java Examples
The following examples show how to use
android.support.annotation.RestrictTo.
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 Project: VectorChildFinder Author: devendroid File: VectorDrawableCompat.java License: Apache License 2.0 | 6 votes |
/** * The size of a pixel when scaled from the intrinsic dimension to the viewport dimension. This * is used to calculate the path animation accuracy. * * @hide */ @RestrictTo(LIBRARY_GROUP) public float getPixelSize() { if (mVectorState == null && mVectorState.mVPathRenderer == null || mVectorState.mVPathRenderer.mBaseWidth == 0 || mVectorState.mVPathRenderer.mBaseHeight == 0 || mVectorState.mVPathRenderer.mViewportHeight == 0 || mVectorState.mVPathRenderer.mViewportWidth == 0) { return 1; // fall back to 1:1 pixel mapping. } float intrinsicWidth = mVectorState.mVPathRenderer.mBaseWidth; float intrinsicHeight = mVectorState.mVPathRenderer.mBaseHeight; float viewportWidth = mVectorState.mVPathRenderer.mViewportWidth; float viewportHeight = mVectorState.mVPathRenderer.mViewportHeight; float scaleX = viewportWidth / intrinsicWidth; float scaleY = viewportHeight / intrinsicHeight; return Math.min(scaleX, scaleY); }
Example #2
Source Project: android-perftracking Author: rakutentech File: Util.java License: MIT License | 6 votes |
/** * Check if the application is debuggable. * * <p>This method check if the application is signed by a debug key. * https://stackoverflow.com/questions/7085644/how-to-check-if-apk-is-signed-or-debug-build * * @param context application context * @return true if app is debuggable, false otherwise */ @RestrictTo(LIBRARY) @VisibleForTesting(otherwise = PACKAGE_PRIVATE) static boolean isAppDebuggable(@NonNull final Context context) { try { PackageManager packageManager = context.getPackageManager(); PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES); Signature[] signatures = packageInfo.signatures; CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); for (Signature signature : signatures) { ByteArrayInputStream stream = new ByteArrayInputStream(signature.toByteArray()); X509Certificate cert = (X509Certificate) certificateFactory.generateCertificate(stream); String principal = cert.getSubjectX500Principal().toString().toUpperCase(); return principal.contains("C=US") && principal.contains("O=ANDROID") && principal.contains("CN=ANDROID DEBUG"); } } catch (Exception e) { // Things went south, anyway the app is not debuggable. } return false; }
Example #3
Source Project: Android-BLE Author: aicareles File: ConnectRequest.java License: Apache License 2.0 | 6 votes |
/** * 兼容原生android系统直接断开系统蓝牙导致的异常 * 直接断开系统蓝牙不回调onConnectionStateChange接口问题 */ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public void disconnectBluetooth(){ if (!connectedDevices.isEmpty()){ for (T device: connectedDevices) { if (null != connectCallback){ device.setConnectionState(BleDevice.DISCONNECT); BleLog.e(TAG, "System Bluetooth is disconnected>>>> "+device.getBleName()); connectCallback.onConnectionChanged(device); } } bleRequest.close(); connectedDevices.clear(); devices.clear(); } }
Example #4
Source Project: custom-tabs-client Author: GoogleChrome File: BrowserActionsIntent.java License: Apache License 2.0 | 6 votes |
/** @hide */ @RestrictTo(LIBRARY_GROUP) @VisibleForTesting static void launchIntent(Context context, Intent intent, List<ResolveInfo> handlers) { if (handlers == null || handlers.size() == 0) { openFallbackBrowserActionsMenu(context, intent); return; } else if (handlers.size() == 1) { intent.setPackage(handlers.get(0).activityInfo.packageName); } else { Intent viewIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(TEST_URL)); PackageManager pm = context.getPackageManager(); ResolveInfo defaultHandler = pm.resolveActivity(viewIntent, PackageManager.MATCH_DEFAULT_ONLY); if (defaultHandler != null) { String defaultPackageName = defaultHandler.activityInfo.packageName; for (int i = 0; i < handlers.size(); i++) { if (defaultPackageName.equals(handlers.get(i).activityInfo.packageName)) { intent.setPackage(defaultPackageName); break; } } } } ContextCompat.startActivity(context, intent, null); }
Example #5
Source Project: TelePlus-Android Author: TelePlusDev File: LinearLayoutManager.java License: GNU General Public License v2.0 | 5 votes |
/** * @hide This method should be called by ItemTouchHelper only. */ @RestrictTo(LIBRARY_GROUP) @Override public void prepareForDrop(View view, View target, int x, int y) { assertNotInLayoutOrScroll("Cannot drop a view during a scroll or layout calculation"); ensureLayoutState(); resolveShouldLayoutReverse(); final int myPos = getPosition(view); final int targetPos = getPosition(target); final int dropDirection = myPos < targetPos ? LayoutState.ITEM_DIRECTION_TAIL : LayoutState.ITEM_DIRECTION_HEAD; if (mShouldReverseLayout) { if (dropDirection == LayoutState.ITEM_DIRECTION_TAIL) { scrollToPositionWithOffset(targetPos, mOrientationHelper.getEndAfterPadding() - (mOrientationHelper.getDecoratedStart(target) + mOrientationHelper.getDecoratedMeasurement(view))); } else { scrollToPositionWithOffset(targetPos, mOrientationHelper.getEndAfterPadding() - mOrientationHelper.getDecoratedEnd(target)); } } else { if (dropDirection == LayoutState.ITEM_DIRECTION_HEAD) { scrollToPositionWithOffset(targetPos, mOrientationHelper.getDecoratedStart(target)); } else { scrollToPositionWithOffset(targetPos, mOrientationHelper.getDecoratedEnd(target) - mOrientationHelper.getDecoratedMeasurement(view)); } } }
Example #6
Source Project: TelePlus-Android Author: TelePlusDev File: LinearLayoutManager.java License: GNU General Public License v2.0 | 5 votes |
/** * @hide This method should be called by ItemTouchHelper only. */ @RestrictTo(LIBRARY_GROUP) @Override public void prepareForDrop(View view, View target, int x, int y) { assertNotInLayoutOrScroll("Cannot drop a view during a scroll or layout calculation"); ensureLayoutState(); resolveShouldLayoutReverse(); final int myPos = getPosition(view); final int targetPos = getPosition(target); final int dropDirection = myPos < targetPos ? LayoutState.ITEM_DIRECTION_TAIL : LayoutState.ITEM_DIRECTION_HEAD; if (mShouldReverseLayout) { if (dropDirection == LayoutState.ITEM_DIRECTION_TAIL) { scrollToPositionWithOffset(targetPos, mOrientationHelper.getEndAfterPadding() - (mOrientationHelper.getDecoratedStart(target) + mOrientationHelper.getDecoratedMeasurement(view))); } else { scrollToPositionWithOffset(targetPos, mOrientationHelper.getEndAfterPadding() - mOrientationHelper.getDecoratedEnd(target)); } } else { if (dropDirection == LayoutState.ITEM_DIRECTION_HEAD) { scrollToPositionWithOffset(targetPos, mOrientationHelper.getDecoratedStart(target)); } else { scrollToPositionWithOffset(targetPos, mOrientationHelper.getDecoratedEnd(target) - mOrientationHelper.getDecoratedMeasurement(view)); } } }
Example #7
Source Project: MiPushFramework Author: MiPushFramework File: ControllerImpl.java License: GNU General Public License v3.0 | 5 votes |
@SuppressLint("MissingPermission") @NonNull @RestrictTo(RestrictTo.Scope.LIBRARY) public static PushController getConnected(@NonNull Context context, @Nullable final AbstractConnectionStatusListener disconnectListener) { PushController controller = new ControllerImpl(context); if (disconnectListener != null) new Handler(Looper.getMainLooper()) .postDelayed(disconnectListener::onReady, 300); return controller; }
Example #8
Source Project: custom-tabs-client Author: GoogleChrome File: BrowserActionItem.java License: Apache License 2.0 | 5 votes |
/** @hide */ @RestrictTo(LIBRARY_GROUP) public BrowserActionItem( @NonNull String title, @NonNull PendingIntent action, @NonNull Uri iconUri) { mTitle = title; mAction = action; mIconUri = iconUri; }
Example #9
Source Project: spark-setup-android Author: particle-iot File: SetupStepsFactory.java License: Apache License 2.0 | 5 votes |
@RestrictTo(RestrictTo.Scope.LIBRARY) public ConfigureAPStep newConfigureApStep(CommandClient commandClient, SetupStepApReconnector reconnector, ScanApCommand.Scan networkToConnectTo, String networkSecretPlaintext, PublicKey publicKey) { return new ConfigureAPStep( StepConfig.newBuilder() .setMaxAttempts(MAX_RETRIES_CONFIGURE_AP) .setResultCode(SuccessActivity.RESULT_FAILURE_CONFIGURE) .setStepId(R.id.configure_device_wifi_credentials) .build(), commandClient, reconnector, networkToConnectTo, networkSecretPlaintext, publicKey); }
Example #10
Source Project: spark-setup-android Author: particle-iot File: SetupStepsFactory.java License: Apache License 2.0 | 5 votes |
@RestrictTo(RestrictTo.Scope.LIBRARY) public ConnectDeviceToNetworkStep newConnectDeviceToNetworkStep(CommandClient commandClient, SetupStepApReconnector reconnector) { return new ConnectDeviceToNetworkStep( StepConfig.newBuilder() .setMaxAttempts(MAX_RETRIES_CONNECT_AP) .setResultCode(SuccessActivity.RESULT_FAILURE_CONFIGURE) .setStepId(R.id.connect_to_wifi_network) .build(), commandClient, reconnector); }
Example #11
Source Project: spark-setup-android Author: particle-iot File: SetupStepsFactory.java License: Apache License 2.0 | 5 votes |
@RestrictTo(RestrictTo.Scope.LIBRARY) public WaitForDisconnectionFromDeviceStep newWaitForDisconnectionFromDeviceStep(SSID deviceSoftApSsid, WifiFacade wifiFacade) { return new WaitForDisconnectionFromDeviceStep( StepConfig.newBuilder() .setMaxAttempts(MAX_RETRIES_DISCONNECT_FROM_DEVICE) .setResultCode(SuccessActivity.RESULT_FAILURE_NO_DISCONNECT) .setStepId(R.id.reconnect_to_wifi_network) .build(), deviceSoftApSsid, wifiFacade); }
Example #12
Source Project: spark-setup-android Author: particle-iot File: SetupStepsFactory.java License: Apache License 2.0 | 5 votes |
@RestrictTo(RestrictTo.Scope.LIBRARY) public EnsureSoftApNotVisible newEnsureSoftApNotVisible(SSID deviceSoftApSsid, WifiFacade wifiFacade) { return new EnsureSoftApNotVisible( StepConfig.newBuilder() .setMaxAttempts(MAX_RETRIES_DISCONNECT_FROM_DEVICE) .setResultCode(SuccessActivity.RESULT_FAILURE_CONFIGURE) .setStepId(R.id.wait_for_device_cloud_connection) .build(), deviceSoftApSsid, wifiFacade); }
Example #13
Source Project: spark-setup-android Author: particle-iot File: SetupStepsFactory.java License: Apache License 2.0 | 5 votes |
@RestrictTo(RestrictTo.Scope.LIBRARY) public WaitForCloudConnectivityStep newWaitForCloudConnectivityStep(Context context) { return new WaitForCloudConnectivityStep( StepConfig.newBuilder() .setMaxAttempts(MAX_RETRIES_DISCONNECT_FROM_DEVICE) .setResultCode(SuccessActivity.RESULT_FAILURE_NO_DISCONNECT) .setStepId(R.id.check_for_internet_connectivity) .build(), context.getApplicationContext()); }
Example #14
Source Project: spark-setup-android Author: particle-iot File: SetupStepsFactory.java License: Apache License 2.0 | 5 votes |
@RestrictTo(RestrictTo.Scope.LIBRARY) public CheckIfDeviceClaimedStep newCheckIfDeviceClaimedStep(ParticleCloud sparkCloud, String deviceId) { return new CheckIfDeviceClaimedStep( StepConfig.newBuilder() .setMaxAttempts(MAX_RETRIES_CLAIM) .setResultCode(SuccessActivity.RESULT_FAILURE_CLAIMING) .setStepId(R.id.verify_product_ownership) .build(), sparkCloud, deviceId); }
Example #15
Source Project: sdl_java_suite Author: smartdevicelink File: LifecycleManager.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * This method is used to ensure all of the methods in this class can remain private and no grantees can be made * to the developer what methods are available or not. * * @param sdlManager this must be a working manager instance * @return the internal interface that hooks into this manager */ @RestrictTo(RestrictTo.Scope.LIBRARY) public ISdl getInternalInterface(SdlManager sdlManager) { if (sdlManager != null) { return internalInterface; } return null; }
Example #16
Source Project: TelePlus-Android Author: TelePlusDev File: StaggeredGridLayoutManager.java License: GNU General Public License v2.0 | 4 votes |
/** @hide */ @Override @RestrictTo(LIBRARY) public void collectAdjacentPrefetchPositions(int dx, int dy, RecyclerView.State state, LayoutPrefetchRegistry layoutPrefetchRegistry) { /* This method uses the simplifying assumption that the next N items (where N = span count) * will be assigned, one-to-one, to spans, where ordering is based on which span extends * least beyond the viewport. * * While this simplified model will be incorrect in some cases, it's difficult to know * item heights, or whether individual items will be full span prior to construction. * * While this greedy estimation approach may underestimate the distance to prefetch items, * it's very unlikely to overestimate them, so distances can be conservatively used to know * the soonest (in terms of scroll distance) a prefetched view may come on screen. */ int delta = (mOrientation == HORIZONTAL) ? dx : dy; if (getChildCount() == 0 || delta == 0) { // can't support this scroll, so don't bother prefetching return; } prepareLayoutStateForDelta(delta, state); // build sorted list of distances to end of each span (though we don't care which is which) if (mPrefetchDistances == null || mPrefetchDistances.length < mSpanCount) { mPrefetchDistances = new int[mSpanCount]; } int itemPrefetchCount = 0; for (int i = 0; i < mSpanCount; i++) { // compute number of pixels past the edge of the viewport that the current span extends int distance = mLayoutState.mItemDirection == LAYOUT_START ? mLayoutState.mStartLine - mSpans[i].getStartLine(mLayoutState.mStartLine) : mSpans[i].getEndLine(mLayoutState.mEndLine) - mLayoutState.mEndLine; if (distance >= 0) { // span extends to the edge, so prefetch next item mPrefetchDistances[itemPrefetchCount] = distance; itemPrefetchCount++; } } Arrays.sort(mPrefetchDistances, 0, itemPrefetchCount); // then assign them in order to the next N views (where N = span count) for (int i = 0; i < itemPrefetchCount && mLayoutState.hasMore(state); i++) { layoutPrefetchRegistry.addPosition(mLayoutState.mCurrentPosition, mPrefetchDistances[i]); mLayoutState.mCurrentPosition += mLayoutState.mItemDirection; } }
Example #17
Source Project: TelePlus-Android Author: TelePlusDev File: StaggeredGridLayoutManager.java License: GNU General Public License v2.0 | 4 votes |
/** @hide */ @Override @RestrictTo(LIBRARY) public void collectAdjacentPrefetchPositions(int dx, int dy, RecyclerView.State state, LayoutPrefetchRegistry layoutPrefetchRegistry) { /* This method uses the simplifying assumption that the next N items (where N = span count) * will be assigned, one-to-one, to spans, where ordering is based on which span extends * least beyond the viewport. * * While this simplified model will be incorrect in some cases, it's difficult to know * item heights, or whether individual items will be full span prior to construction. * * While this greedy estimation approach may underestimate the distance to prefetch items, * it's very unlikely to overestimate them, so distances can be conservatively used to know * the soonest (in terms of scroll distance) a prefetched view may come on screen. */ int delta = (mOrientation == HORIZONTAL) ? dx : dy; if (getChildCount() == 0 || delta == 0) { // can't support this scroll, so don't bother prefetching return; } prepareLayoutStateForDelta(delta, state); // build sorted list of distances to end of each span (though we don't care which is which) if (mPrefetchDistances == null || mPrefetchDistances.length < mSpanCount) { mPrefetchDistances = new int[mSpanCount]; } int itemPrefetchCount = 0; for (int i = 0; i < mSpanCount; i++) { // compute number of pixels past the edge of the viewport that the current span extends int distance = mLayoutState.mItemDirection == LAYOUT_START ? mLayoutState.mStartLine - mSpans[i].getStartLine(mLayoutState.mStartLine) : mSpans[i].getEndLine(mLayoutState.mEndLine) - mLayoutState.mEndLine; if (distance >= 0) { // span extends to the edge, so prefetch next item mPrefetchDistances[itemPrefetchCount] = distance; itemPrefetchCount++; } } Arrays.sort(mPrefetchDistances, 0, itemPrefetchCount); // then assign them in order to the next N views (where N = span count) for (int i = 0; i < itemPrefetchCount && mLayoutState.hasMore(state); i++) { layoutPrefetchRegistry.addPosition(mLayoutState.mCurrentPosition, mPrefetchDistances[i]); mLayoutState.mCurrentPosition += mLayoutState.mItemDirection; } }
Example #18
Source Project: BiometricPromptCompat Author: fython File: BiometricPromptCompat.java License: Apache License 2.0 | 4 votes |
@RestrictTo({RestrictTo.Scope.LIBRARY, RestrictTo.Scope.LIBRARY_GROUP}) static boolean isApiPSupported() { return (IS_PREVIEW_SDK_SUPPORTED && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && Build.VERSION.PREVIEW_SDK_INT >= 1) || Build.VERSION.SDK_INT >= Build.VERSION_CODES.P; }
Example #19
Source Project: ResourceInspector Author: nekocode File: ResourceInspector.java License: Apache License 2.0 | 4 votes |
@RestrictTo(RestrictTo.Scope.LIBRARY) public static boolean isViewBeingInspected(@Nullable View view) { return view != null && view.getTag(ResourceInspector.TAG_RES_NAME) instanceof String; }
Example #20
Source Project: ResourceInspector Author: nekocode File: ResourceInspector.java License: Apache License 2.0 | 4 votes |
@RestrictTo(RestrictTo.Scope.LIBRARY) @Nullable public static String getViewLayoutResName(@Nullable View view) { return view != null ? (String) view.getTag(ResourceInspector.TAG_RES_NAME) : null; }
Example #21
Source Project: ResourceInspector Author: nekocode File: ResourceInspector.java License: Apache License 2.0 | 4 votes |
@RestrictTo(RestrictTo.Scope.LIBRARY) public static boolean isViewBeingInspected(@Nullable View view) { return false; }
Example #22
Source Project: ResourceInspector Author: nekocode File: ResourceInspector.java License: Apache License 2.0 | 4 votes |
@RestrictTo(RestrictTo.Scope.LIBRARY) @Nullable public static String getViewLayoutResName(@Nullable View view) { return null; }
Example #23
Source Project: neatle Author: inovait File: OperationBuilder.java License: MIT License | 4 votes |
@RestrictTo(RestrictTo.Scope.LIBRARY) public OperationBuilder(Context context) { this.context = context.getApplicationContext(); }
Example #24
Source Project: neatle Author: inovait File: CommandResult.java License: MIT License | 4 votes |
@RestrictTo(RestrictTo.Scope.LIBRARY) public static CommandResult createCharacteristicRead(BluetoothGattCharacteristic characteristic, int status) { long when = System.currentTimeMillis(); return new CommandResult(characteristic.getUuid(), characteristic.getValue(), status, when); }
Example #25
Source Project: neatle Author: inovait File: CommandResult.java License: MIT License | 4 votes |
@RestrictTo(RestrictTo.Scope.LIBRARY) public static CommandResult createErrorResult(UUID characteristicUUID, int error) { long when = System.currentTimeMillis(); return new CommandResult(characteristicUUID, null, error, when); }
Example #26
Source Project: neatle Author: inovait File: CommandResult.java License: MIT License | 4 votes |
@RestrictTo(RestrictTo.Scope.LIBRARY) public static CommandResult createEmptySuccess(UUID characteristicUUID) { long when = System.currentTimeMillis(); return new CommandResult(characteristicUUID, null, BluetoothGatt.GATT_SUCCESS, when); }
Example #27
Source Project: neatle Author: inovait File: CommandResult.java License: MIT License | 4 votes |
@RestrictTo(RestrictTo.Scope.LIBRARY) public static CommandResult createCharacteristicChanged(BluetoothGattCharacteristic characteristic) { long when = System.currentTimeMillis(); return new CommandResult(characteristic.getUuid(), characteristic.getValue(), BluetoothGatt.GATT_SUCCESS, when); }
Example #28
Source Project: neatle Author: inovait File: OperationImpl.java License: MIT License | 4 votes |
@RestrictTo(RestrictTo.Scope.TESTS) LinkedList<Command> getCommands() { return commands; }
Example #29
Source Project: neatle Author: inovait File: OperationImpl.java License: MIT License | 4 votes |
@RestrictTo(RestrictTo.Scope.TESTS) OperationObserver getOperationObserver() { return operationObserver; }
Example #30
Source Project: neatle Author: inovait File: OperationImpl.java License: MIT License | 4 votes |
@RestrictTo(RestrictTo.Scope.TESTS) int getRetryCount() { return retryCount; }