use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowAudioManager method registerAudioPolicy.
/**
* Registers an {@link AudioPolicy} to allow that policy to control audio routing and audio focus.
*
* <p>Note: this implementation does NOT ensure that we have the permissions necessary to register
* the given {@link AudioPolicy}.
*
* @return {@link AudioManager.ERROR} if the given policy has already been registered, and {@link
* AudioManager.SUCCESS} otherwise.
*/
@HiddenApi
@Implementation(minSdk = P)
@RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING)
protected int registerAudioPolicy(@NonNull Object audioPolicy) {
Preconditions.checkNotNull(audioPolicy, "Illegal null AudioPolicy argument");
AudioPolicy policy = (AudioPolicy) audioPolicy;
String id = getIdForAudioPolicy(audioPolicy);
if (registeredAudioPolicies.containsKey(id)) {
return AudioManager.ERROR;
}
registeredAudioPolicies.put(id, policy);
policy.setRegistration(id);
return AudioManager.SUCCESS;
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowAudioManager method unregisterAudioPolicy.
@HiddenApi
@Implementation(minSdk = Q)
protected void unregisterAudioPolicy(@NonNull Object audioPolicy) {
Preconditions.checkNotNull(audioPolicy, "Illegal null AudioPolicy argument");
AudioPolicy policy = (AudioPolicy) audioPolicy;
registeredAudioPolicies.remove(getIdForAudioPolicy(policy));
policy.setRegistration(null);
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowMotionEvent method nativeInitialize.
@Implementation(minSdk = LOLLIPOP, maxSdk = P)
@HiddenApi
protected static long nativeInitialize(long nativePtr, int deviceId, int source, int action, int flags, int edgeFlags, int metaState, int buttonState, float xOffset, float yOffset, float xPrecision, float yPrecision, long downTimeNanos, long eventTimeNanos, int pointerCount, PointerProperties[] pointerPropertiesObjArray, PointerCoords[] pointerCoordsObjArray) {
validatePointerCount(pointerCount);
validatePointerPropertiesArray(pointerPropertiesObjArray, pointerCount);
validatePointerCoordsObjArray(pointerCoordsObjArray, pointerCount);
NativeInput.MotionEvent event;
if (nativePtr > 0) {
event = nativeMotionEventRegistry.getNativeObject(nativePtr);
} else {
event = new NativeInput.MotionEvent();
nativePtr = nativeMotionEventRegistry.register(event);
}
NativeInput.PointerCoords[] rawPointerCoords = new NativeInput.PointerCoords[pointerCount];
for (int i = 0; i < pointerCount; i++) {
PointerCoords pointerCoordsObj = pointerCoordsObjArray[i];
checkNotNull(pointerCoordsObj);
rawPointerCoords[i] = pointerCoordsToNative(pointerCoordsObj, xOffset, yOffset);
}
event.initialize(deviceId, source, action, 0, flags, edgeFlags, metaState, buttonState, xOffset, yOffset, xPrecision, yPrecision, downTimeNanos, eventTimeNanos, pointerCount, pointerPropertiesObjArray, rawPointerCoords);
return nativePtr;
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowLegacyAssetManager method getResourceStringArray.
@HiddenApi
@Implementation
public String[] getResourceStringArray(final int id) {
CharSequence[] resourceTextArray = getResourceTextArray(id);
if (resourceTextArray == null)
return null;
String[] strings = new String[resourceTextArray.length];
for (int i = 0; i < strings.length; i++) {
strings[i] = resourceTextArray[i].toString();
}
return strings;
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowLegacyAssetManager method setApkAssets.
@HiddenApi
@Implementation(minSdk = P)
public void setApkAssets(Object apkAssetsObject, Object invalidateCachesObject) {
ApkAssets[] apkAssets = (ApkAssets[]) apkAssetsObject;
boolean invalidateCaches = (boolean) invalidateCachesObject;
for (ApkAssets apkAsset : apkAssets) {
assetDirs.add(Fs.fromUrl(apkAsset.getAssetPath()));
}
reflector(AssetManagerReflector.class, realObject).setApkAssets(apkAssets, invalidateCaches);
}
Aggregations