code
stringlengths 11
173k
| docstring
stringlengths 2
593k
| func_name
stringlengths 2
189
| language
stringclasses 1
value | repo
stringclasses 844
values | path
stringlengths 11
294
| url
stringlengths 60
339
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public void init(
boolean encrypting,
CipherParameters params)
{
this.encrypting = encrypting;
if (params instanceof RC2Parameters)
{
RC2Parameters param = (RC2Parameters)params;
workingKey = generateWorkingKey(param.getKey(),
param.getEffectiveKeyBits());
}
else if (params instanceof KeyParameter)
{
byte[] key = ((KeyParameter)params).getKey();
workingKey = generateWorkingKey(key, key.length * 8);
}
else
{
throw new IllegalArgumentException("invalid parameter passed to RC2 init - " + params.getClass().getName());
}
} |
initialise a RC2 cipher.
@param encrypting whether or not we are for encryption.
@param params the parameters required to set up the cipher.
@exception IllegalArgumentException if the params argument is
inappropriate.
| RC2Engine::init | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/org/bouncycastle/crypto/engines/RC2Engine.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/crypto/engines/RC2Engine.java | MIT |
private int rotateWordLeft(
int x,
int y)
{
x &= 0xffff;
return (x << y) | (x >> (16 - y));
} |
return the result rotating the 16 bit number in x left by y
| RC2Engine::rotateWordLeft | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/org/bouncycastle/crypto/engines/RC2Engine.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/crypto/engines/RC2Engine.java | MIT |
public static int getClassification(MotionEvent event) {
return event.getClassification();
} |
Utility class to use new APIs that were added in Q (API level 29). These need to exist in a
separate class so that Android framework can successfully verify classes without
encountering the new APIs.
@RequiresApi(Build.VERSION_CODES.Q)
public final class ApiHelperForQ {
private ApiHelperForQ() {}
/** See {@link TelephonyManager.requestCellInfoUpdate() }.
@RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION)
public static void requestCellInfoUpdate(
TelephonyManager telephonyManager, Callback<List<CellInfo>> callback) {
telephonyManager.requestCellInfoUpdate(
AsyncTask.THREAD_POOL_EXECUTOR,
new TelephonyManager.CellInfoCallback() {
@Override
@SuppressLint("Override")
public void onCellInfo(List<CellInfo> cellInfos) {
callback.onResult(cellInfos);
}
});
}
public static boolean bindIsolatedService(
Context context,
Intent intent,
int flags,
String instanceName,
Executor executor,
ServiceConnection connection) {
return context.bindIsolatedService(intent, flags, instanceName, executor, connection);
}
public static void updateServiceGroup(
Context context, ServiceConnection connection, int group, int importance) {
context.updateServiceGroup(connection, group, importance);
}
/** See {@link MotionEvent#getClassification() }. | ApiHelperForQ::getClassification | java | Reginer/aosp-android-jar | android-35/src/org/chromium/base/compat/ApiHelperForQ.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/chromium/base/compat/ApiHelperForQ.java | MIT |
public static BiometricManager getBiometricManagerSystemService(Context context) {
return context.getSystemService(BiometricManager.class);
} |
Utility class to use new APIs that were added in Q (API level 29). These need to exist in a
separate class so that Android framework can successfully verify classes without
encountering the new APIs.
@RequiresApi(Build.VERSION_CODES.Q)
public final class ApiHelperForQ {
private ApiHelperForQ() {}
/** See {@link TelephonyManager.requestCellInfoUpdate() }.
@RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION)
public static void requestCellInfoUpdate(
TelephonyManager telephonyManager, Callback<List<CellInfo>> callback) {
telephonyManager.requestCellInfoUpdate(
AsyncTask.THREAD_POOL_EXECUTOR,
new TelephonyManager.CellInfoCallback() {
@Override
@SuppressLint("Override")
public void onCellInfo(List<CellInfo> cellInfos) {
callback.onResult(cellInfos);
}
});
}
public static boolean bindIsolatedService(
Context context,
Intent intent,
int flags,
String instanceName,
Executor executor,
ServiceConnection connection) {
return context.bindIsolatedService(intent, flags, instanceName, executor, connection);
}
public static void updateServiceGroup(
Context context, ServiceConnection connection, int group, int importance) {
context.updateServiceGroup(connection, group, importance);
}
/** See {@link MotionEvent#getClassification() }.
public static int getClassification(MotionEvent event) {
return event.getClassification();
}
/** See {@link Context#getSystemService(Class<T>) }. | ApiHelperForQ::getBiometricManagerSystemService | java | Reginer/aosp-android-jar | android-35/src/org/chromium/base/compat/ApiHelperForQ.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/chromium/base/compat/ApiHelperForQ.java | MIT |
private TimeInstantRangeFilter(@Nullable Instant startTime, @Nullable Instant endTime) {
if (startTime == null && endTime == null) {
throw new IllegalArgumentException("Both start time and end time cannot be null.");
}
if (startTime != null && endTime != null) {
if (!endTime.isAfter(startTime)) {
throw new IllegalArgumentException("end time needs to be after start time.");
}
}
mStartTime = startTime != null ? startTime : Instant.EPOCH;
mEndTime = endTime != null ? endTime : Instant.now().plus(1, ChronoUnit.DAYS);
} |
@param startTime represents start time of this filter. If the value is null, Instant.Epoch is
set as default value.
@param endTime represents end time of this filter If the value is null, Instant.now() + 1 day
is set as default value.
@hide
| TimeInstantRangeFilter::TimeInstantRangeFilter | java | Reginer/aosp-android-jar | android-35/src/android/health/connect/TimeInstantRangeFilter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/health/connect/TimeInstantRangeFilter.java | MIT |
public ForegroundColorSpan(@ColorInt int color) {
mColor = color;
} |
Creates a {@link ForegroundColorSpan} from a color integer.
<p>
To get the color integer associated with a particular color resource ID, use
{@link android.content.res.Resources#getColor(int, Resources.Theme)}
@param color color integer that defines the text color
| ForegroundColorSpan::ForegroundColorSpan | java | Reginer/aosp-android-jar | android-31/src/android/text/style/ForegroundColorSpan.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/text/style/ForegroundColorSpan.java | MIT |
public ForegroundColorSpan(@NonNull Parcel src) {
mColor = src.readInt();
} |
Creates a {@link ForegroundColorSpan} from a parcel.
| ForegroundColorSpan::ForegroundColorSpan | java | Reginer/aosp-android-jar | android-31/src/android/text/style/ForegroundColorSpan.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/text/style/ForegroundColorSpan.java | MIT |
void updateBounds(Rect updatedBounds) {
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"%s: updateLayout, width: %s, height: %s", TAG, updatedBounds.width(),
updatedBounds.height());
mCurrentPipBounds = updatedBounds;
if (!mSwitchingOrientation) {
updateButtonGravity(mCurrentPipBounds);
}
updatePipFrameBounds();
} |
Also updates the button gravity.
| TvPipMenuView::updateBounds | java | Reginer/aosp-android-jar | android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | MIT |
private void updateButtonGravity(Rect bounds) {
final boolean vertical = bounds.height() > bounds.width();
// Use Math.max since the possible orientation change might not have been applied yet.
final int buttonsSize = Math.max(mActionButtonsContainer.getHeight(),
mActionButtonsContainer.getWidth());
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"%s: buttons container width: %s, height: %s", TAG,
mActionButtonsContainer.getWidth(), mActionButtonsContainer.getHeight());
final boolean buttonsFit =
vertical ? buttonsSize < bounds.height()
: buttonsSize < bounds.width();
final int buttonGravity = buttonsFit ? Gravity.CENTER
: (vertical ? Gravity.CENTER_HORIZONTAL : Gravity.CENTER_VERTICAL);
final LayoutParams params = (LayoutParams) mActionButtonsContainer.getLayoutParams();
params.gravity = buttonGravity;
mActionButtonsContainer.setLayoutParams(params);
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"%s: vertical: %b, buttonsFit: %b, gravity: %s", TAG, vertical, buttonsFit,
Gravity.toString(buttonGravity));
} |
Change button gravity based on new dimensions
| TvPipMenuView::updateButtonGravity | java | Reginer/aosp-android-jar | android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | MIT |
private void updatePipFrameBounds() {
final ViewGroup.LayoutParams pipFrameParams = mPipFrameView.getLayoutParams();
if (pipFrameParams != null) {
pipFrameParams.width = mCurrentPipBounds.width() + 2 * mPipMenuBorderWidth;
pipFrameParams.height = mCurrentPipBounds.height() + 2 * mPipMenuBorderWidth;
mPipFrameView.setLayoutParams(pipFrameParams);
}
final ViewGroup.LayoutParams pipViewParams = mPipView.getLayoutParams();
if (pipViewParams != null) {
pipViewParams.width = mCurrentPipBounds.width();
pipViewParams.height = mCurrentPipBounds.height();
mPipView.setLayoutParams(pipViewParams);
}
} |
Update mPipFrameView's bounds according to the new pip window bounds. We can't
make mPipFrameView match_parent, because the pip menu might contain other content around
the pip window (e.g. edu text).
TvPipMenuView needs to account for this so that it can draw a white border around the whole
pip menu when it gains focus.
| TvPipMenuView::updatePipFrameBounds | java | Reginer/aosp-android-jar | android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | MIT |
void showMoveMenu(int gravity) {
if (DEBUG) {
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, "%s: showMoveMenu()", TAG);
}
mButtonMenuIsVisible = false;
mMoveMenuIsVisible = true;
showButtonsMenu(false);
showMovementHints(gravity);
setFrameHighlighted(true);
} |
@param gravity for the arrow hints
| TvPipMenuView::showMoveMenu | java | Reginer/aosp-android-jar | android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | MIT |
void hideAllUserControls() {
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"%s: hideAllUserControls()", TAG);
mFocusedButton = null;
mButtonMenuIsVisible = false;
mMoveMenuIsVisible = false;
showButtonsMenu(false);
hideMovementHints();
setFrameHighlighted(false);
} |
Hides all menu views, including the menu frame.
| TvPipMenuView::hideAllUserControls | java | Reginer/aosp-android-jar | android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | MIT |
void setAdditionalActions(List<RemoteAction> actions, RemoteAction closeAction,
Handler mainHandler) {
if (DEBUG) {
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"%s: setAdditionalActions()", TAG);
}
// Replace system close action with custom close action if available
if (closeAction != null) {
setActionForButton(closeAction, mCloseButton, mainHandler);
} else {
mCloseButton.setTextAndDescription(R.string.pip_close);
mCloseButton.setImageResource(R.drawable.pip_ic_close_white);
}
mCloseButton.setIsCustomCloseAction(closeAction != null);
// Make sure the close action is always enabled
mCloseButton.setEnabled(true);
// Make sure we exactly as many additional buttons as we have actions to display.
final int actionsNumber = actions.size();
int buttonsNumber = mAdditionalButtons.size();
if (actionsNumber > buttonsNumber) {
// Add buttons until we have enough to display all the actions.
while (actionsNumber > buttonsNumber) {
TvPipMenuActionButton button = new TvPipMenuActionButton(mContext);
button.setOnClickListener(this);
mActionButtonsContainer.addView(button,
FIRST_CUSTOM_ACTION_POSITION + buttonsNumber);
mAdditionalButtons.add(button);
buttonsNumber++;
}
} else if (actionsNumber < buttonsNumber) {
// Hide buttons until we as many as the actions.
while (actionsNumber < buttonsNumber) {
final View button = mAdditionalButtons.get(buttonsNumber - 1);
button.setVisibility(View.GONE);
button.setTag(null);
buttonsNumber--;
}
}
// "Assign" actions to the buttons.
for (int index = 0; index < actionsNumber; index++) {
final RemoteAction action = actions.get(index);
final TvPipMenuActionButton button = mAdditionalButtons.get(index);
// Remove action if it matches the custom close action.
if (PipUtils.remoteActionsMatch(action, closeAction)) {
button.setVisibility(GONE);
continue;
}
setActionForButton(action, button, mainHandler);
}
if (mCurrentPipBounds != null) {
updateButtonGravity(mCurrentPipBounds);
refocusPreviousButton();
}
} |
Button order:
- Fullscreen
- Close
- Custom actions (app or media actions)
- System actions
| TvPipMenuView::setAdditionalActions | java | Reginer/aosp-android-jar | android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | MIT |
public void showMovementHints(int gravity) {
if (DEBUG) {
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"%s: showMovementHints(), position: %s", TAG, Gravity.toString(gravity));
}
animateAlphaTo(checkGravity(gravity, Gravity.BOTTOM) ? 1f : 0f, mArrowUp);
animateAlphaTo(checkGravity(gravity, Gravity.TOP) ? 1f : 0f, mArrowDown);
animateAlphaTo(checkGravity(gravity, Gravity.RIGHT) ? 1f : 0f, mArrowLeft);
animateAlphaTo(checkGravity(gravity, Gravity.LEFT) ? 1f : 0f, mArrowRight);
} |
Shows user hints for moving the PiP, e.g. arrows.
| TvPipMenuView::showMovementHints | java | Reginer/aosp-android-jar | android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | MIT |
public void hideMovementHints() {
if (DEBUG) {
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"%s: hideMovementHints()", TAG);
}
animateAlphaTo(0, mArrowUp);
animateAlphaTo(0, mArrowRight);
animateAlphaTo(0, mArrowDown);
animateAlphaTo(0, mArrowLeft);
} |
Hides user hints for moving the PiP, e.g. arrows.
| TvPipMenuView::hideMovementHints | java | Reginer/aosp-android-jar | android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | MIT |
public void showButtonsMenu(boolean show) {
if (DEBUG) {
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"%s: showUserActions: %b", TAG, show);
}
if (show) {
mActionButtonsContainer.setVisibility(VISIBLE);
refocusPreviousButton();
}
animateAlphaTo(show ? 1 : 0, mActionButtonsContainer);
} |
Show or hide the pip buttons menu.
| TvPipMenuView::showButtonsMenu | java | Reginer/aosp-android-jar | android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/wm/shell/pip/tv/TvPipMenuView.java | MIT |
public nodetextnodetype(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException {
super(factory);
//
// check if loaded documents are supported for content type
//
String contentType = getContentType();
preload(contentType, "staff", false);
} |
Constructor.
@param factory document factory, may not be null
@throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
| nodetextnodetype::nodetextnodetype | java | Reginer/aosp-android-jar | android-33/src/org/w3c/domts/level1/core/nodetextnodetype.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/nodetextnodetype.java | MIT |
public void runTest() throws Throwable {
Document doc;
NodeList elementList;
Element testAddr;
Node textNode;
int nodeType;
doc = (Document) load("staff", false);
elementList = doc.getElementsByTagName("address");
testAddr = (Element) elementList.item(0);
textNode = testAddr.getFirstChild();
nodeType = (int) textNode.getNodeType();
assertEquals("nodeTextNodeTypeAssert1", 3, nodeType);
} |
Runs the test case.
@throws Throwable Any uncaught exception causes test to fail
| nodetextnodetype::runTest | java | Reginer/aosp-android-jar | android-33/src/org/w3c/domts/level1/core/nodetextnodetype.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/nodetextnodetype.java | MIT |
public String getTargetURI() {
return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodetextnodetype";
} |
Gets URI that identifies the test.
@return uri identifier of test
| nodetextnodetype::getTargetURI | java | Reginer/aosp-android-jar | android-33/src/org/w3c/domts/level1/core/nodetextnodetype.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/nodetextnodetype.java | MIT |
public static void main(final String[] args) {
DOMTestCase.doMain(nodetextnodetype.class, args);
} |
Runs this test from the command line.
@param args command line arguments
| nodetextnodetype::main | java | Reginer/aosp-android-jar | android-33/src/org/w3c/domts/level1/core/nodetextnodetype.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/nodetextnodetype.java | MIT |
public final static String getDefaultAlgorithm() {
String type;
type = AccessController.doPrivileged(new PrivilegedAction<String>() {
@Override
public String run() {
return Security.getProperty(
"ssl.TrustManagerFactory.algorithm");
}
});
if (type == null) {
type = "SunX509";
}
return type;
} |
Obtains the default TrustManagerFactory algorithm name.
<p>The default TrustManager can be changed at runtime by setting
the value of the {@code ssl.TrustManagerFactory.algorithm}
security property to the desired algorithm name.
@see java.security.Security security properties
@return the default algorithm name as specified by the
{@code ssl.TrustManagerFactory.algorithm} security property, or an
implementation-specific default if no such property exists.
| TrustManagerFactory::getDefaultAlgorithm | java | Reginer/aosp-android-jar | android-31/src/javax/net/ssl/TrustManagerFactory.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/javax/net/ssl/TrustManagerFactory.java | MIT |
protected TrustManagerFactory(TrustManagerFactorySpi factorySpi,
Provider provider, String algorithm) {
this.factorySpi = factorySpi;
this.provider = provider;
this.algorithm = algorithm;
} |
Creates a TrustManagerFactory object.
@param factorySpi the delegate
@param provider the provider
@param algorithm the algorithm
| TrustManagerFactory::TrustManagerFactory | java | Reginer/aosp-android-jar | android-31/src/javax/net/ssl/TrustManagerFactory.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/javax/net/ssl/TrustManagerFactory.java | MIT |
public final String getAlgorithm() {
return this.algorithm;
} |
Returns the algorithm name of this <code>TrustManagerFactory</code>
object.
<p>This is the same name that was specified in one of the
<code>getInstance</code> calls that created this
<code>TrustManagerFactory</code> object.
@return the algorithm name of this <code>TrustManagerFactory</code>
object
| TrustManagerFactory::getAlgorithm | java | Reginer/aosp-android-jar | android-31/src/javax/net/ssl/TrustManagerFactory.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/javax/net/ssl/TrustManagerFactory.java | MIT |
public static final TrustManagerFactory getInstance(String algorithm)
throws NoSuchAlgorithmException {
GetInstance.Instance instance = GetInstance.getInstance
("TrustManagerFactory", TrustManagerFactorySpi.class,
algorithm);
return new TrustManagerFactory((TrustManagerFactorySpi)instance.impl,
instance.provider, algorithm);
} |
Returns a <code>TrustManagerFactory</code> object that acts as a
factory for trust managers.
<p> This method traverses the list of registered security Providers,
starting with the most preferred Provider.
A new TrustManagerFactory object encapsulating the
TrustManagerFactorySpi implementation from the first
Provider that supports the specified algorithm is returned.
<p> Note that the list of registered providers may be retrieved via
the {@link Security#getProviders() Security.getProviders()} method.
@param algorithm the standard name of the requested trust management
algorithm. See the <a href=
"https://docs.oracle.com/javase/8/docs/technotes/guides/security/jsse/JSSERefGuide.html">
Java Secure Socket Extension Reference Guide </a>
for information about standard algorithm names.
@return the new <code>TrustManagerFactory</code> object.
@exception NoSuchAlgorithmException if no Provider supports a
TrustManagerFactorySpi implementation for the
specified algorithm.
@exception NullPointerException if algorithm is null.
@see java.security.Provider
| TrustManagerFactory::getInstance | java | Reginer/aosp-android-jar | android-31/src/javax/net/ssl/TrustManagerFactory.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/javax/net/ssl/TrustManagerFactory.java | MIT |
public void init(
boolean forEncryption,
CipherParameters param)
{
core.init(forEncryption, param);
if (param instanceof ParametersWithRandom)
{
ParametersWithRandom rParam = (ParametersWithRandom)param;
this.key = (RSAKeyParameters)rParam.getParameters();
if (key instanceof RSAPrivateCrtKeyParameters)
{
this.random = rParam.getRandom();
}
else
{
this.random = null;
}
}
else
{
this.key = (RSAKeyParameters)param;
if (key instanceof RSAPrivateCrtKeyParameters)
{
this.random = CryptoServicesRegistrar.getSecureRandom();
}
else
{
this.random = null;
}
}
} |
initialise the RSA engine.
@param forEncryption true if we are encrypting, false otherwise.
@param param the necessary RSA key parameters.
| RSABlindedEngine::init | java | Reginer/aosp-android-jar | android-34/src/com/android/org/bouncycastle/crypto/engines/RSABlindedEngine.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/org/bouncycastle/crypto/engines/RSABlindedEngine.java | MIT |
public int getInputBlockSize()
{
return core.getInputBlockSize();
} |
Return the maximum size for an input block to this engine.
For RSA this is always one byte less than the key size on
encryption, and the same length as the key size on decryption.
@return maximum size for an input block.
| RSABlindedEngine::getInputBlockSize | java | Reginer/aosp-android-jar | android-34/src/com/android/org/bouncycastle/crypto/engines/RSABlindedEngine.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/org/bouncycastle/crypto/engines/RSABlindedEngine.java | MIT |
public int getOutputBlockSize()
{
return core.getOutputBlockSize();
} |
Return the maximum size for an output block to this engine.
For RSA this is always one byte less than the key size on
decryption, and the same length as the key size on encryption.
@return maximum size for an output block.
| RSABlindedEngine::getOutputBlockSize | java | Reginer/aosp-android-jar | android-34/src/com/android/org/bouncycastle/crypto/engines/RSABlindedEngine.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/org/bouncycastle/crypto/engines/RSABlindedEngine.java | MIT |
public byte[] processBlock(
byte[] in,
int inOff,
int inLen)
{
if (key == null)
{
throw new IllegalStateException("RSA engine not initialised");
}
BigInteger input = core.convertInput(in, inOff, inLen);
BigInteger result;
if (key instanceof RSAPrivateCrtKeyParameters)
{
RSAPrivateCrtKeyParameters k = (RSAPrivateCrtKeyParameters)key;
BigInteger e = k.getPublicExponent();
if (e != null) // can't do blinding without a public exponent
{
BigInteger m = k.getModulus();
BigInteger r = BigIntegers.createRandomInRange(ONE, m.subtract(ONE), random);
BigInteger blindedInput = r.modPow(e, m).multiply(input).mod(m);
BigInteger blindedResult = core.processBlock(blindedInput);
BigInteger rInv = BigIntegers.modOddInverse(m, r);
result = blindedResult.multiply(rInv).mod(m);
// defence against Arjen Lenstra’s CRT attack
if (!input.equals(result.modPow(e, m)))
{
throw new IllegalStateException("RSA engine faulty decryption/signing detected");
}
}
else
{
result = core.processBlock(input);
}
}
else
{
result = core.processBlock(input);
}
return core.convertOutput(result);
} |
Process a single block using the basic RSA algorithm.
@param in the input array.
@param inOff the offset into the input buffer where the data starts.
@param inLen the length of the data to be processed.
@return the result of the RSA process.
@exception DataLengthException the input block is too large.
| RSABlindedEngine::processBlock | java | Reginer/aosp-android-jar | android-34/src/com/android/org/bouncycastle/crypto/engines/RSABlindedEngine.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/org/bouncycastle/crypto/engines/RSABlindedEngine.java | MIT |
public static EncryptedFullBackupTask newInstance(
Context context,
CryptoBackupServer cryptoBackupServer,
SecureRandom secureRandom,
RecoverableKeyStoreSecondaryKey secondaryKey,
String packageName,
InputStream inputStream)
throws IOException {
EncryptedBackupTask encryptedBackupTask =
new EncryptedBackupTask(
cryptoBackupServer,
secureRandom,
packageName,
new BackupStreamEncrypter(
inputStream,
MIN_CHUNK_SIZE_BYTES,
MAX_CHUNK_SIZE_BYTES,
AVERAGE_CHUNK_SIZE_BYTES));
TertiaryKeyManager tertiaryKeyManager =
new TertiaryKeyManager(
context,
secureRandom,
TertiaryKeyRotationScheduler.getInstance(context),
secondaryKey,
packageName);
return new EncryptedFullBackupTask(
ProtoStore.createChunkListingStore(context),
tertiaryKeyManager,
encryptedBackupTask,
inputStream,
packageName,
new SecureRandom());
} |
Task which reads a stream of plaintext full backup data, chunks it, encrypts it and uploads it to
the server.
<p>Once the backup completes or fails, closes the input stream.
public class EncryptedFullBackupTask implements Callable<Void> {
private static final String TAG = "EncryptedFullBackupTask";
private static final int MIN_CHUNK_SIZE_BYTES = 2 * 1024;
private static final int MAX_CHUNK_SIZE_BYTES = 64 * 1024;
private static final int AVERAGE_CHUNK_SIZE_BYTES = 4 * 1024;
// TODO(b/69350270): Remove this hard-coded salt and related logic once we feel confident that
// incremental backup has happened at least once for all existing packages/users since we moved
// to
// using a randomly generated salt.
//
// The hard-coded fingerprint mixer salt was used for a short time period before replaced by one
// that is randomly generated on initial non-incremental backup and stored in ChunkListing to be
// reused for succeeding incremental backups. If an old ChunkListing does not have a
// fingerprint_mixer_salt, we assume that it was last backed up before a randomly generated salt
// is used so we use the hardcoded salt and set ChunkListing#fingerprint_mixer_salt to this
// value.
// Eventually all backup ChunkListings will have this field set and then we can remove the
// default
// value in the code.
static final byte[] DEFAULT_FINGERPRINT_MIXER_SALT =
Arrays.copyOf(new byte[] {20, 23}, FingerprintMixer.SALT_LENGTH_BYTES);
private final ProtoStore<ChunkListing> mChunkListingStore;
private final TertiaryKeyManager mTertiaryKeyManager;
private final InputStream mInputStream;
private final EncryptedBackupTask mTask;
private final String mPackageName;
private final SecureRandom mSecureRandom;
/** Creates a new instance with the default min, max and average chunk sizes. | EncryptedFullBackupTask::newInstance | java | Reginer/aosp-android-jar | android-33/src/com/android/server/backup/encryption/tasks/EncryptedFullBackupTask.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/backup/encryption/tasks/EncryptedFullBackupTask.java | MIT |
public void cancel() {
mTask.cancel();
} |
Signals to the task that the backup has been cancelled. If the upload has not yet started
then the task will not upload any data to the server or save the new chunk listing.
<p>You must then terminate the input stream.
| EncryptedFullBackupTask::cancel | java | Reginer/aosp-android-jar | android-33/src/com/android/server/backup/encryption/tasks/EncryptedFullBackupTask.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/backup/encryption/tasks/EncryptedFullBackupTask.java | MIT |
public static ProtoOutputStream buildGetTextAfterCursorProto(@IntRange(from = 0) int length,
int flags, @Nullable CharSequence result) {
ProtoOutputStream proto = new ProtoOutputStream();
final long token = proto.start(GET_TEXT_AFTER_CURSOR);
proto.write(GetTextAfterCursor.LENGTH, length);
proto.write(GetTextAfterCursor.FLAGS, flags);
if (result == null) {
proto.write(GetTextAfterCursor.RESULT, "null result");
} else if (DUMP_TEXT) {
proto.write(GetTextAfterCursor.RESULT, result.toString());
}
proto.end(token);
return proto;
} |
Builder for InputConnectionCallProto to hold
{@link android.view.inputmethod.InputConnection#getTextAfterCursor(int, int)} data.
@param length The expected length of the text. This must be non-negative.
@param flags Supplies additional options controlling how the text is
returned. May be either {@code 0} or
{@link android.view.inputmethod.InputConnection#GET_TEXT_WITH_STYLES}.
@param result The text after the cursor position; the length of the
returned text might be less than <var>length</var>.
@return ProtoOutputStream holding the InputConnectionCallProto data.
| InputConnectionHelper::buildGetTextAfterCursorProto | java | Reginer/aosp-android-jar | android-31/src/android/util/imetracing/InputConnectionHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/util/imetracing/InputConnectionHelper.java | MIT |
public static ProtoOutputStream buildGetTextBeforeCursorProto(@IntRange(from = 0) int length,
int flags, @Nullable CharSequence result) {
ProtoOutputStream proto = new ProtoOutputStream();
final long token = proto.start(GET_TEXT_BEFORE_CURSOR);
proto.write(GetTextBeforeCursor.LENGTH, length);
proto.write(GetTextBeforeCursor.FLAGS, flags);
if (result == null) {
proto.write(GetTextBeforeCursor.RESULT, "null result");
} else if (DUMP_TEXT) {
proto.write(GetTextBeforeCursor.RESULT, result.toString());
}
proto.end(token);
return proto;
} |
Builder for InputConnectionCallProto to hold
{@link android.view.inputmethod.InputConnection#getTextBeforeCursor(int, int)} data.
@param length The expected length of the text. This must be non-negative.
@param flags Supplies additional options controlling how the text is
returned. May be either {@code 0} or
{@link android.view.inputmethod.InputConnection#GET_TEXT_WITH_STYLES}.
@param result The text before the cursor position; the length of the
returned text might be less than <var>length</var>.
@return ProtoOutputStream holding the InputConnectionCallProto data.
| InputConnectionHelper::buildGetTextBeforeCursorProto | java | Reginer/aosp-android-jar | android-31/src/android/util/imetracing/InputConnectionHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/util/imetracing/InputConnectionHelper.java | MIT |
public static ProtoOutputStream buildGetSelectedTextProto(int flags,
@Nullable CharSequence result) {
ProtoOutputStream proto = new ProtoOutputStream();
final long token = proto.start(GET_SELECTED_TEXT);
proto.write(GetSelectedText.FLAGS, flags);
if (result == null) {
proto.write(GetSelectedText.RESULT, "null result");
} else if (DUMP_TEXT) {
proto.write(GetSelectedText.RESULT, result.toString());
}
proto.end(token);
return proto;
} |
Builder for InputConnectionCallProto to hold
{@link android.view.inputmethod.InputConnection#getSelectedText(int)} data.
@param flags Supplies additional options controlling how the text is
returned. May be either {@code 0} or
{@link android.view.inputmethod.InputConnection#GET_TEXT_WITH_STYLES}.
@param result the text that is currently selected, if any, or null if
no text is selected. In {@link android.os.Build.VERSION_CODES#N} and
later, returns false when the target application does not implement
this method.
@return ProtoOutputStream holding the InputConnectionCallProto data.
| InputConnectionHelper::buildGetSelectedTextProto | java | Reginer/aosp-android-jar | android-31/src/android/util/imetracing/InputConnectionHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/util/imetracing/InputConnectionHelper.java | MIT |
public static ProtoOutputStream buildGetSurroundingTextProto(@IntRange(from = 0)
int beforeLength, @IntRange(from = 0) int afterLength, int flags,
@Nullable SurroundingText result) {
ProtoOutputStream proto = new ProtoOutputStream();
final long token = proto.start(GET_SURROUNDING_TEXT);
proto.write(GetSurroundingText.BEFORE_LENGTH, beforeLength);
proto.write(GetSurroundingText.AFTER_LENGTH, afterLength);
proto.write(GetSurroundingText.FLAGS, flags);
if (result == null) {
final long token_result = proto.start(GetSurroundingText.RESULT);
proto.write(GetSurroundingText.SurroundingText.TEXT, "null result");
proto.end(token_result);
} else if (DUMP_TEXT) {
final long token_result = proto.start(GetSurroundingText.RESULT);
proto.write(GetSurroundingText.SurroundingText.TEXT, result.getText().toString());
proto.write(GetSurroundingText.SurroundingText.SELECTION_START,
result.getSelectionStart());
proto.write(GetSurroundingText.SurroundingText.SELECTION_END,
result.getSelectionEnd());
proto.write(GetSurroundingText.SurroundingText.OFFSET, result.getOffset());
proto.end(token_result);
}
proto.end(token);
return proto;
} |
Builder for InputConnectionCallProto to hold
{@link android.view.inputmethod.InputConnection#getSurroundingText(int, int, int)} data.
@param beforeLength The expected length of the text before the cursor.
@param afterLength The expected length of the text after the cursor.
@param flags Supplies additional options controlling how the text is
returned. May be either {@code 0} or
{@link android.view.inputmethod.InputConnection#GET_TEXT_WITH_STYLES}.
@param result an {@link android.view.inputmethod.SurroundingText} object describing the
surrounding text and state of selection, or null if the input connection is no longer valid,
or the editor can't comply with the request for some reason, or the application does not
implement this method. The length of the returned text might be less than the sum of
<var>beforeLength</var> and <var>afterLength</var> .
@return ProtoOutputStream holding the InputConnectionCallProto data.
| InputConnectionHelper::buildGetSurroundingTextProto | java | Reginer/aosp-android-jar | android-31/src/android/util/imetracing/InputConnectionHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/util/imetracing/InputConnectionHelper.java | MIT |
public static ProtoOutputStream buildGetCursorCapsModeProto(int reqModes, int result) {
ProtoOutputStream proto = new ProtoOutputStream();
final long token = proto.start(GET_CURSOR_CAPS_MODE);
proto.write(GetCursorCapsMode.REQ_MODES, reqModes);
if (DUMP_TEXT) {
proto.write(GetCursorCapsMode.RESULT, result);
}
proto.end(token);
return proto;
} |
Builder for InputConnectionCallProto to hold
{@link android.view.inputmethod.InputConnection#getCursorCapsMode(int)} data.
@param reqModes The desired modes to retrieve, as defined by
{@link android.text.TextUtils#getCapsMode TextUtils.getCapsMode}.
@param result the caps mode flags that are in effect at the current
cursor position. See TYPE_TEXT_FLAG_CAPS_* in {@link android.text.InputType}.
@return ProtoOutputStream holding the InputConnectionCallProto data.
| InputConnectionHelper::buildGetCursorCapsModeProto | java | Reginer/aosp-android-jar | android-31/src/android/util/imetracing/InputConnectionHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/util/imetracing/InputConnectionHelper.java | MIT |
public static ProtoOutputStream buildGetExtractedTextProto(@NonNull ExtractedTextRequest
request, int flags, @Nullable ExtractedText result) {
ProtoOutputStream proto = new ProtoOutputStream();
final long token = proto.start(GET_EXTRACTED_TEXT);
final long token_request = proto.start(REQUEST);
proto.write(GetExtractedText.ExtractedTextRequest.TOKEN, request.token);
proto.write(GetExtractedText.ExtractedTextRequest.FLAGS, request.flags);
proto.write(GetExtractedText.ExtractedTextRequest.HINT_MAX_LINES, request.hintMaxLines);
proto.write(GetExtractedText.ExtractedTextRequest.HINT_MAX_CHARS, request.hintMaxChars);
proto.end(token_request);
proto.write(GetExtractedText.FLAGS, flags);
if (result == null) {
proto.write(GetExtractedText.RESULT, "null result");
} else if (DUMP_TEXT) {
proto.write(GetExtractedText.RESULT, result.text.toString());
}
proto.end(token);
return proto;
} |
Builder for InputConnectionCallProto to hold
{@link android.view.inputmethod.InputConnection#getExtractedText(ExtractedTextRequest, int)}
data.
@param request Description of how the text should be returned.
{@link android.view.inputmethod.ExtractedTextRequest}
@param flags Additional options to control the client, either {@code 0} or
{@link android.view.inputmethod.InputConnection#GET_EXTRACTED_TEXT_MONITOR}.
@param result an {@link android.view.inputmethod.ExtractedText}
object describing the state of the text view and containing the
extracted text itself, or null if the input connection is no
longer valid of the editor can't comply with the request for
some reason.
@return ProtoOutputStream holding the InputConnectionCallProto data.
| InputConnectionHelper::buildGetExtractedTextProto | java | Reginer/aosp-android-jar | android-31/src/android/util/imetracing/InputConnectionHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/util/imetracing/InputConnectionHelper.java | MIT |
public long getDuration() {
return mCompleted ? mDurationOrStartTimeMs : 0;
} |
Return duration of camera usage event, or 0 if the event is not done
| CameraUsageEvent::getDuration | java | Reginer/aosp-android-jar | android-33/src/com/android/server/camera/CameraServiceProxy.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/camera/CameraServiceProxy.java | MIT |
public static int getCropRotateScale(@NonNull Context ctx, @NonNull String packageName,
@Nullable TaskInfo taskInfo, int displayRotation, int lensFacing,
boolean ignoreResizableAndSdkCheck) {
if (taskInfo == null) {
return CaptureRequest.SCALER_ROTATE_AND_CROP_NONE;
}
// External cameras do not need crop-rotate-scale.
if (lensFacing != CameraMetadata.LENS_FACING_FRONT
&& lensFacing != CameraMetadata.LENS_FACING_BACK) {
Log.v(TAG, "lensFacing=" + lensFacing + ". Crop-rotate-scale is disabled.");
return CaptureRequest.SCALER_ROTATE_AND_CROP_NONE;
}
// In case the activity behavior is not explicitly overridden, enable the
// crop-rotate-scale workaround if the app targets M (or below) or is not
// resizeable.
if (!ignoreResizableAndSdkCheck && !isMOrBelow(ctx, packageName) &&
taskInfo.isResizeable) {
Slog.v(TAG,
"The activity is N or above and claims to support resizeable-activity. "
+ "Crop-rotate-scale is disabled.");
return CaptureRequest.SCALER_ROTATE_AND_CROP_NONE;
}
if (!taskInfo.isFixedOrientationPortrait && !taskInfo.isFixedOrientationLandscape) {
Log.v(TAG, "Non-fixed orientation activity. Crop-rotate-scale is disabled.");
return CaptureRequest.SCALER_ROTATE_AND_CROP_NONE;
}
int rotationDegree;
switch (displayRotation) {
case Surface.ROTATION_0:
rotationDegree = 0;
break;
case Surface.ROTATION_90:
rotationDegree = 90;
break;
case Surface.ROTATION_180:
rotationDegree = 180;
break;
case Surface.ROTATION_270:
rotationDegree = 270;
break;
default:
Log.e(TAG, "Unsupported display rotation: " + displayRotation);
return CaptureRequest.SCALER_ROTATE_AND_CROP_NONE;
}
Slog.v(TAG,
"Display.getRotation()=" + rotationDegree
+ " isFixedOrientationPortrait=" + taskInfo.isFixedOrientationPortrait
+ " isFixedOrientationLandscape=" +
taskInfo.isFixedOrientationLandscape);
// We are trying to estimate the necessary rotation compensation for clients that
// don't handle various display orientations.
// The logic that is missing on client side is similar to the reference code
// in {@link android.hardware.Camera#setDisplayOrientation} where "info.orientation"
// is already applied in "CameraUtils::getRotationTransform".
// Care should be taken to reverse the rotation direction depending on the camera
// lens facing.
if (rotationDegree == 0) {
return CaptureRequest.SCALER_ROTATE_AND_CROP_NONE;
}
if (lensFacing == CameraCharacteristics.LENS_FACING_FRONT) {
// Switch direction for front facing cameras
rotationDegree = 360 - rotationDegree;
}
switch (rotationDegree) {
case 90:
return CaptureRequest.SCALER_ROTATE_AND_CROP_90;
case 270:
return CaptureRequest.SCALER_ROTATE_AND_CROP_270;
case 180:
return CaptureRequest.SCALER_ROTATE_AND_CROP_180;
case 0:
default:
return CaptureRequest.SCALER_ROTATE_AND_CROP_NONE;
}
} |
Estimate the app crop-rotate-scale compensation value.
| TaskInfo::getCropRotateScale | java | Reginer/aosp-android-jar | android-33/src/com/android/server/camera/CameraServiceProxy.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/camera/CameraServiceProxy.java | MIT |
private void logCameraUsageEvent(CameraUsageEvent e) {
int facing = FrameworkStatsLog.CAMERA_ACTION_EVENT__FACING__UNKNOWN;
switch(e.mCameraFacing) {
case CameraSessionStats.CAMERA_FACING_BACK:
facing = FrameworkStatsLog.CAMERA_ACTION_EVENT__FACING__BACK;
break;
case CameraSessionStats.CAMERA_FACING_FRONT:
facing = FrameworkStatsLog.CAMERA_ACTION_EVENT__FACING__FRONT;
break;
case CameraSessionStats.CAMERA_FACING_EXTERNAL:
facing = FrameworkStatsLog.CAMERA_ACTION_EVENT__FACING__EXTERNAL;
break;
default:
Slog.w(TAG, "Unknown camera facing: " + e.mCameraFacing);
}
int streamCount = 0;
if (e.mStreamStats != null) {
streamCount = e.mStreamStats.size();
}
if (CameraServiceProxy.DEBUG) {
Slog.v(TAG, "CAMERA_ACTION_EVENT: action " + e.mAction
+ " clientName " + e.mClientName
+ ", duration " + e.getDuration()
+ ", APILevel " + e.mAPILevel
+ ", cameraId " + e.mCameraId
+ ", facing " + facing
+ ", isNdk " + e.mIsNdk
+ ", latencyMs " + e.mLatencyMs
+ ", operatingMode " + e.mOperatingMode
+ ", internalReconfigure " + e.mInternalReconfigure
+ ", requestCount " + e.mRequestCount
+ ", resultErrorCount " + e.mResultErrorCount
+ ", deviceError " + e.mDeviceError
+ ", streamCount is " + streamCount
+ ", userTag is " + e.mUserTag
+ ", videoStabilizationMode " + e.mVideoStabilizationMode);
}
// Convert from CameraStreamStats to CameraStreamProto
CameraStreamProto[] streamProtos = new CameraStreamProto[MAX_STREAM_STATISTICS];
for (int i = 0; i < MAX_STREAM_STATISTICS; i++) {
streamProtos[i] = new CameraStreamProto();
if (i < streamCount) {
CameraStreamStats streamStats = e.mStreamStats.get(i);
streamProtos[i].width = streamStats.getWidth();
streamProtos[i].height = streamStats.getHeight();
streamProtos[i].format = streamStats.getFormat();
streamProtos[i].dataSpace = streamStats.getDataSpace();
streamProtos[i].usage = streamStats.getUsage();
streamProtos[i].requestCount = streamStats.getRequestCount();
streamProtos[i].errorCount = streamStats.getErrorCount();
streamProtos[i].firstCaptureLatencyMillis = streamStats.getStartLatencyMs();
streamProtos[i].maxHalBuffers = streamStats.getMaxHalBuffers();
streamProtos[i].maxAppBuffers = streamStats.getMaxAppBuffers();
streamProtos[i].histogramType = streamStats.getHistogramType();
streamProtos[i].histogramBins = streamStats.getHistogramBins();
streamProtos[i].histogramCounts = streamStats.getHistogramCounts();
streamProtos[i].dynamicRangeProfile = streamStats.getDynamicRangeProfile();
streamProtos[i].streamUseCase = streamStats.getStreamUseCase();
if (CameraServiceProxy.DEBUG) {
String histogramTypeName =
cameraHistogramTypeToString(streamProtos[i].histogramType);
Slog.v(TAG, "Stream " + i + ": width " + streamProtos[i].width
+ ", height " + streamProtos[i].height
+ ", format " + streamProtos[i].format
+ ", maxPreviewFps " + streamStats.getMaxPreviewFps()
+ ", dataSpace " + streamProtos[i].dataSpace
+ ", usage " + streamProtos[i].usage
+ ", requestCount " + streamProtos[i].requestCount
+ ", errorCount " + streamProtos[i].errorCount
+ ", firstCaptureLatencyMillis "
+ streamProtos[i].firstCaptureLatencyMillis
+ ", maxHalBuffers " + streamProtos[i].maxHalBuffers
+ ", maxAppBuffers " + streamProtos[i].maxAppBuffers
+ ", histogramType " + histogramTypeName
+ ", histogramBins "
+ Arrays.toString(streamProtos[i].histogramBins)
+ ", histogramCounts "
+ Arrays.toString(streamProtos[i].histogramCounts)
+ ", dynamicRangeProfile " + streamProtos[i].dynamicRangeProfile
+ ", streamUseCase " + streamProtos[i].streamUseCase);
}
}
}
FrameworkStatsLog.write(FrameworkStatsLog.CAMERA_ACTION_EVENT, e.getDuration(),
e.mAPILevel, e.mClientName, facing, e.mCameraId, e.mAction, e.mIsNdk,
e.mLatencyMs, e.mOperatingMode, e.mInternalReconfigure,
e.mRequestCount, e.mResultErrorCount, e.mDeviceError,
streamCount, MessageNano.toByteArray(streamProtos[0]),
MessageNano.toByteArray(streamProtos[1]),
MessageNano.toByteArray(streamProtos[2]),
MessageNano.toByteArray(streamProtos[3]),
MessageNano.toByteArray(streamProtos[4]),
e.mUserTag, e.mVideoStabilizationMode);
} |
Write camera usage events to stats log.
Package-private
| EventWriterTask::logCameraUsageEvent | java | Reginer/aosp-android-jar | android-33/src/com/android/server/camera/CameraServiceProxy.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/camera/CameraServiceProxy.java | MIT |
public InputStreamReader(InputStream in) {
super(in);
sd = StreamDecoder.forInputStreamReader(in, this,
Charset.defaultCharset()); // ## check lock object
} |
Creates an InputStreamReader that uses the
{@link Charset#defaultCharset() default charset}.
@param in An InputStream
@see Charset#defaultCharset()
| InputStreamReader::InputStreamReader | java | Reginer/aosp-android-jar | android-35/src/java/io/InputStreamReader.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/io/InputStreamReader.java | MIT |
public InputStreamReader(InputStream in, String charsetName)
throws UnsupportedEncodingException
{
super(in);
if (charsetName == null)
throw new NullPointerException("charsetName");
sd = StreamDecoder.forInputStreamReader(in, this, charsetName);
} |
Creates an InputStreamReader that uses the named charset.
@param in
An InputStream
@param charsetName
The name of a supported
{@link java.nio.charset.Charset charset}
@throws UnsupportedEncodingException
If the named charset is not supported
| InputStreamReader::InputStreamReader | java | Reginer/aosp-android-jar | android-35/src/java/io/InputStreamReader.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/io/InputStreamReader.java | MIT |
public InputStreamReader(InputStream in, Charset cs) {
super(in);
if (cs == null)
throw new NullPointerException("charset");
sd = StreamDecoder.forInputStreamReader(in, this, cs);
} |
Creates an InputStreamReader that uses the given charset.
@param in An InputStream
@param cs A charset
@since 1.4
| InputStreamReader::InputStreamReader | java | Reginer/aosp-android-jar | android-35/src/java/io/InputStreamReader.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/io/InputStreamReader.java | MIT |
public InputStreamReader(InputStream in, CharsetDecoder dec) {
super(in);
if (dec == null)
throw new NullPointerException("charset decoder");
sd = StreamDecoder.forInputStreamReader(in, this, dec);
} |
Creates an InputStreamReader that uses the given charset decoder.
@param in An InputStream
@param dec A charset decoder
@since 1.4
| InputStreamReader::InputStreamReader | java | Reginer/aosp-android-jar | android-35/src/java/io/InputStreamReader.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/io/InputStreamReader.java | MIT |
public String getEncoding() {
return sd.getEncoding();
} |
Returns the name of the character encoding being used by this stream.
<p> If the encoding has an historical name then that name is returned;
otherwise the encoding's canonical name is returned.
<p> If this instance was created with the {@link
#InputStreamReader(InputStream, String)} constructor then the returned
name, being unique for the encoding, may differ from the name passed to
the constructor. This method will return {@code null} if the
stream has been closed.
</p>
@return The historical name of this encoding, or
{@code null} if the stream has been closed
@see java.nio.charset.Charset
@revised 1.4
| InputStreamReader::getEncoding | java | Reginer/aosp-android-jar | android-35/src/java/io/InputStreamReader.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/io/InputStreamReader.java | MIT |
public int read() throws IOException {
return sd.read();
} |
Reads a single character.
@return The character read, or -1 if the end of the stream has been
reached
@throws IOException If an I/O error occurs
| InputStreamReader::read | java | Reginer/aosp-android-jar | android-35/src/java/io/InputStreamReader.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/io/InputStreamReader.java | MIT |
public int read(char[] cbuf, int off, int len) throws IOException {
return sd.read(cbuf, off, len);
} |
{@inheritDoc}
@throws IndexOutOfBoundsException {@inheritDoc}
| InputStreamReader::read | java | Reginer/aosp-android-jar | android-35/src/java/io/InputStreamReader.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/io/InputStreamReader.java | MIT |
public boolean ready() throws IOException {
return sd.ready();
} |
Tells whether this stream is ready to be read. An InputStreamReader is
ready if its input buffer is not empty, or if bytes are available to be
read from the underlying byte stream.
@throws IOException If an I/O error occurs
| InputStreamReader::ready | java | Reginer/aosp-android-jar | android-35/src/java/io/InputStreamReader.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/io/InputStreamReader.java | MIT |
public static String getIconKey(TelephonyDisplayInfo telephonyDisplayInfo) {
if (telephonyDisplayInfo.getOverrideNetworkType()
== TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE) {
return toIconKey(telephonyDisplayInfo.getNetworkType());
} else {
return toDisplayIconKey(telephonyDisplayInfo.getOverrideNetworkType());
}
} |
Generates the RAT key from the TelephonyDisplayInfo.
| MobileMappings::getIconKey | java | Reginer/aosp-android-jar | android-33/src/com/android/settingslib/mobile/MobileMappings.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/mobile/MobileMappings.java | MIT |
public static String toIconKey(@Annotation.NetworkType int networkType) {
return Integer.toString(networkType);
} |
Converts the networkType into the RAT key.
| MobileMappings::toIconKey | java | Reginer/aosp-android-jar | android-33/src/com/android/settingslib/mobile/MobileMappings.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/mobile/MobileMappings.java | MIT |
public static String toDisplayIconKey(@Annotation.OverrideNetworkType int displayNetworkType) {
switch (displayNetworkType) {
case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA:
return toIconKey(TelephonyManager.NETWORK_TYPE_LTE) + "_CA";
case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO:
return toIconKey(TelephonyManager.NETWORK_TYPE_LTE) + "_CA_Plus";
case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA:
return toIconKey(TelephonyManager.NETWORK_TYPE_NR);
case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED:
return toIconKey(TelephonyManager.NETWORK_TYPE_NR) + "_Plus";
default:
return "unsupported";
}
} |
Converts the displayNetworkType into the RAT key.
| MobileMappings::toDisplayIconKey | java | Reginer/aosp-android-jar | android-33/src/com/android/settingslib/mobile/MobileMappings.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/mobile/MobileMappings.java | MIT |
public static MobileIconGroup getDefaultIcons(Config config) {
if (!config.showAtLeast3G) {
return TelephonyIcons.G;
} else {
return TelephonyIcons.THREE_G;
}
} |
Produce the default MobileIconGroup.
| MobileMappings::getDefaultIcons | java | Reginer/aosp-android-jar | android-33/src/com/android/settingslib/mobile/MobileMappings.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/mobile/MobileMappings.java | MIT |
public static Map<String, MobileIconGroup> mapIconSets(Config config) {
final Map<String, MobileIconGroup> networkToIconLookup = new HashMap<>();
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EVDO_0),
TelephonyIcons.THREE_G);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EVDO_A),
TelephonyIcons.THREE_G);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EVDO_B),
TelephonyIcons.THREE_G);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EHRPD),
TelephonyIcons.THREE_G);
if (config.show4gFor3g) {
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_UMTS),
TelephonyIcons.FOUR_G);
} else {
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_UMTS),
TelephonyIcons.THREE_G);
}
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_TD_SCDMA),
TelephonyIcons.THREE_G);
if (!config.showAtLeast3G) {
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_UNKNOWN),
TelephonyIcons.UNKNOWN);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EDGE),
TelephonyIcons.E);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_GPRS),
TelephonyIcons.G);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_CDMA),
TelephonyIcons.ONE_X);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_1xRTT),
TelephonyIcons.ONE_X);
} else {
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_UNKNOWN),
TelephonyIcons.THREE_G);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EDGE),
TelephonyIcons.THREE_G);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_GPRS),
TelephonyIcons.THREE_G);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_CDMA),
TelephonyIcons.THREE_G);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_1xRTT),
TelephonyIcons.THREE_G);
}
MobileIconGroup hGroup = TelephonyIcons.THREE_G;
MobileIconGroup hPlusGroup = TelephonyIcons.THREE_G;
if (config.show4gFor3g) {
hGroup = TelephonyIcons.FOUR_G;
hPlusGroup = TelephonyIcons.FOUR_G;
} else if (config.hspaDataDistinguishable) {
hGroup = TelephonyIcons.H;
hPlusGroup = TelephonyIcons.H_PLUS;
}
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_HSDPA), hGroup);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_HSUPA), hGroup);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_HSPA), hGroup);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_HSPAP), hPlusGroup);
if (config.show4gForLte) {
networkToIconLookup.put(toIconKey(
TelephonyManager.NETWORK_TYPE_LTE),
TelephonyIcons.FOUR_G);
if (config.hideLtePlus) {
networkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA),
TelephonyIcons.FOUR_G);
} else {
networkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA),
TelephonyIcons.FOUR_G_PLUS);
}
} else if (config.show4glteForLte) {
networkToIconLookup.put(toIconKey(
TelephonyManager.NETWORK_TYPE_LTE),
TelephonyIcons.FOUR_G_LTE);
if (config.hideLtePlus) {
networkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA),
TelephonyIcons.FOUR_G_LTE);
} else {
networkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA),
TelephonyIcons.FOUR_G_LTE_PLUS);
}
} else {
networkToIconLookup.put(toIconKey(
TelephonyManager.NETWORK_TYPE_LTE),
TelephonyIcons.LTE);
if (config.hideLtePlus) {
networkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA),
TelephonyIcons.LTE);
} else {
networkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA),
TelephonyIcons.LTE_PLUS);
}
}
networkToIconLookup.put(toIconKey(
TelephonyManager.NETWORK_TYPE_IWLAN),
TelephonyIcons.WFC);
networkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO),
TelephonyIcons.LTE_CA_5G_E);
networkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA),
TelephonyIcons.NR_5G);
networkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED),
TelephonyIcons.NR_5G_PLUS);
networkToIconLookup.put(toIconKey(
TelephonyManager.NETWORK_TYPE_NR),
TelephonyIcons.NR_5G);
return networkToIconLookup;
} |
Produce a mapping of data network types to icon groups for simple and quick use in
updateTelephony.
| MobileMappings::mapIconSets | java | Reginer/aosp-android-jar | android-33/src/com/android/settingslib/mobile/MobileMappings.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/mobile/MobileMappings.java | MIT |
public static Config readConfig(Context context) {
Config config = new Config();
Resources res = context.getResources();
config.showAtLeast3G = res.getBoolean(R.bool.config_showMin3G);
config.alwaysShowCdmaRssi =
res.getBoolean(com.android.internal.R.bool.config_alwaysUseCdmaRssi);
config.hspaDataDistinguishable =
res.getBoolean(R.bool.config_hspa_data_distinguishable);
CarrierConfigManager configMgr = (CarrierConfigManager)
context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
// Handle specific carrier config values for the default data SIM
int defaultDataSubId = SubscriptionManager.from(context)
.getDefaultDataSubscriptionId();
PersistableBundle b = configMgr.getConfigForSubId(defaultDataSubId);
if (b != null) {
config.alwaysShowDataRatIcon = b.getBoolean(
CarrierConfigManager.KEY_ALWAYS_SHOW_DATA_RAT_ICON_BOOL);
config.show4gForLte = b.getBoolean(
CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
config.show4glteForLte = b.getBoolean(
CarrierConfigManager.KEY_SHOW_4GLTE_FOR_LTE_DATA_ICON_BOOL);
config.show4gFor3g = b.getBoolean(
CarrierConfigManager.KEY_SHOW_4G_FOR_3G_DATA_ICON_BOOL);
config.hideLtePlus = b.getBoolean(
CarrierConfigManager.KEY_HIDE_LTE_PLUS_DATA_ICON_BOOL);
}
return config;
} |
Reads the latest configs.
| Config::readConfig | java | Reginer/aosp-android-jar | android-33/src/com/android/settingslib/mobile/MobileMappings.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/mobile/MobileMappings.java | MIT |
public boolean isDeviceAtLeastR() throws DeviceNotAvailableException {
return device.getApiLevel() >= 30;
} |
Utility class to check device SDK level from a host side test.
public final class DeviceSdkLevel {
private final ITestDevice device;
public DeviceSdkLevel(ITestDevice device) {
this.device = device;
}
/** Checks if the device is running on release version of Android R or newer. | DeviceSdkLevel::isDeviceAtLeastR | java | Reginer/aosp-android-jar | android-32/src/com/android/modules/utils/build/testing/DeviceSdkLevel.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/modules/utils/build/testing/DeviceSdkLevel.java | MIT |
public boolean isDeviceAtLeastS() throws DeviceNotAvailableException {
return device.getApiLevel() >= 31 || isDeviceAtLeastPreReleaseCodename("S");
} |
Checks if the device is running on a pre-release version of Android S or a release version of
Android S or newer.
| DeviceSdkLevel::isDeviceAtLeastS | java | Reginer/aosp-android-jar | android-32/src/com/android/modules/utils/build/testing/DeviceSdkLevel.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/modules/utils/build/testing/DeviceSdkLevel.java | MIT |
public boolean isDeviceAtLeastT() throws DeviceNotAvailableException {
return isDeviceAtLeastPreReleaseCodename("T");
} |
Checks if the device is running on a pre-release version of Android T or a release version of
Android T or newer.
| DeviceSdkLevel::isDeviceAtLeastT | java | Reginer/aosp-android-jar | android-32/src/com/android/modules/utils/build/testing/DeviceSdkLevel.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/modules/utils/build/testing/DeviceSdkLevel.java | MIT |
public AccountItemView(Context context) {
this(context, null);
} |
Constructor.
| AccountItemView::AccountItemView | java | Reginer/aosp-android-jar | android-31/src/com/android/internal/widget/AccountItemView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/internal/widget/AccountItemView.java | MIT |
public AccountItemView(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater inflator = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflator.inflate(R.layout.simple_account_item, null);
addView(view);
initViewItem(view);
} |
Constructor.
| AccountItemView::AccountItemView | java | Reginer/aosp-android-jar | android-31/src/com/android/internal/widget/AccountItemView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/internal/widget/AccountItemView.java | MIT |
private final Runnable mUpdateModeRunnable = new Runnable() {
@Override
public void run() {
int automatic;
automatic = Settings.System.getIntForUser(mContext.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL,
mUserTracker.getUserId());
mAutomatic = automatic != Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
}
}; |
Fetch the brightness mode from the system settings and update the icon. Should be called from
background thread.
| BrightnessObserver::Runnable | java | Reginer/aosp-android-jar | android-34/src/com/android/systemui/settings/brightness/BrightnessController.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/settings/brightness/BrightnessController.java | MIT |
private final Runnable mUpdateSliderRunnable = new Runnable() {
@Override
public void run() {
final boolean inVrMode = mIsVrModeEnabled;
final BrightnessInfo info = mContext.getDisplay().getBrightnessInfo();
if (info == null) {
return;
}
mBrightnessMax = info.brightnessMaximum;
mBrightnessMin = info.brightnessMinimum;
// Value is passed as intbits, since this is what the message takes.
final int valueAsIntBits = Float.floatToIntBits(info.brightness);
mHandler.obtainMessage(MSG_UPDATE_SLIDER, valueAsIntBits,
inVrMode ? 1 : 0).sendToTarget();
}
}; |
Fetch the brightness from the system settings and update the slider. Should be called from
background thread.
| BrightnessObserver::Runnable | java | Reginer/aosp-android-jar | android-34/src/com/android/systemui/settings/brightness/BrightnessController.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/settings/brightness/BrightnessController.java | MIT |
public BrightnessController create(ToggleSlider toggleSlider) {
return new BrightnessController(
mContext,
toggleSlider,
mUserTracker,
mDisplayTracker,
mMainExecutor,
mBackgroundHandler);
} |
Fetch the brightness from the system settings and update the slider. Should be called from
background thread.
private final Runnable mUpdateSliderRunnable = new Runnable() {
@Override
public void run() {
final boolean inVrMode = mIsVrModeEnabled;
final BrightnessInfo info = mContext.getDisplay().getBrightnessInfo();
if (info == null) {
return;
}
mBrightnessMax = info.brightnessMaximum;
mBrightnessMin = info.brightnessMinimum;
// Value is passed as intbits, since this is what the message takes.
final int valueAsIntBits = Float.floatToIntBits(info.brightness);
mHandler.obtainMessage(MSG_UPDATE_SLIDER, valueAsIntBits,
inVrMode ? 1 : 0).sendToTarget();
}
};
private final IVrStateCallbacks mVrStateCallbacks = new IVrStateCallbacks.Stub() {
@Override
public void onVrStateChanged(boolean enabled) {
mHandler.obtainMessage(MSG_VR_MODE_CHANGED, enabled ? 1 : 0, 0)
.sendToTarget();
}
};
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
mExternalChange = true;
try {
switch (msg.what) {
case MSG_UPDATE_SLIDER:
updateSlider(Float.intBitsToFloat(msg.arg1), msg.arg2 != 0);
break;
case MSG_ATTACH_LISTENER:
mControl.setOnChangedListener(BrightnessController.this);
break;
case MSG_DETACH_LISTENER:
mControl.setOnChangedListener(null);
break;
case MSG_VR_MODE_CHANGED:
updateVrMode(msg.arg1 != 0);
break;
default:
super.handleMessage(msg);
}
} finally {
mExternalChange = false;
}
}
};
private final UserTracker.Callback mUserChangedCallback =
new UserTracker.Callback() {
@Override
public void onUserChanged(int newUser, @NonNull Context userContext) {
mBackgroundHandler.post(mUpdateModeRunnable);
mBackgroundHandler.post(mUpdateSliderRunnable);
}
};
public BrightnessController(
Context context,
ToggleSlider control,
UserTracker userTracker,
DisplayTracker displayTracker,
@Main Executor mainExecutor,
@Background Handler bgHandler) {
mContext = context;
mControl = control;
mControl.setMax(GAMMA_SPACE_MAX);
mMainExecutor = mainExecutor;
mBackgroundHandler = bgHandler;
mUserTracker = userTracker;
mDisplayTracker = displayTracker;
mBrightnessObserver = new BrightnessObserver(mHandler);
mDisplayId = mContext.getDisplayId();
PowerManager pm = context.getSystemService(PowerManager.class);
mDisplayManager = context.getSystemService(DisplayManager.class);
mVrManager = IVrManager.Stub.asInterface(ServiceManager.getService(
Context.VR_SERVICE));
}
public void registerCallbacks() {
mBackgroundHandler.post(mStartListeningRunnable);
}
/** Unregister all call backs, both to and from the controller
public void unregisterCallbacks() {
mBackgroundHandler.post(mStopListeningRunnable);
mControlValueInitialized = false;
}
@Override
public void onChanged(boolean tracking, int value, boolean stopTracking) {
if (mExternalChange) return;
if (mSliderAnimator != null) {
mSliderAnimator.cancel();
}
final float minBacklight;
final float maxBacklight;
final int metric;
metric = mAutomatic
? MetricsEvent.ACTION_BRIGHTNESS_AUTO
: MetricsEvent.ACTION_BRIGHTNESS;
minBacklight = mBrightnessMin;
maxBacklight = mBrightnessMax;
final float valFloat = MathUtils.min(
convertGammaToLinearFloat(value, minBacklight, maxBacklight),
maxBacklight);
if (stopTracking) {
// TODO(brightnessfloat): change to use float value instead.
MetricsLogger.action(mContext, metric,
BrightnessSynchronizer.brightnessFloatToInt(valFloat));
}
setBrightness(valFloat);
if (!tracking) {
AsyncTask.execute(new Runnable() {
public void run() {
mDisplayManager.setBrightness(mDisplayId, valFloat);
}
});
}
}
public void checkRestrictionAndSetEnabled() {
mBackgroundHandler.post(new Runnable() {
@Override
public void run() {
mControl.setEnforcedAdmin(
RestrictedLockUtilsInternal.checkIfRestrictionEnforced(mContext,
UserManager.DISALLOW_CONFIG_BRIGHTNESS,
mUserTracker.getUserId()));
}
});
}
public void hideSlider() {
mControl.hideView();
}
public void showSlider() {
mControl.showView();
}
private void setBrightness(float brightness) {
mDisplayManager.setTemporaryBrightness(mDisplayId, brightness);
}
private void updateVrMode(boolean isEnabled) {
if (mIsVrModeEnabled != isEnabled) {
mIsVrModeEnabled = isEnabled;
mBackgroundHandler.post(mUpdateSliderRunnable);
}
}
private void updateSlider(float brightnessValue, boolean inVrMode) {
final float min = mBrightnessMin;
final float max = mBrightnessMax;
// Ensure the slider is in a fixed position first, then check if we should animate.
if (mSliderAnimator != null && mSliderAnimator.isStarted()) {
mSliderAnimator.cancel();
}
// convertGammaToLinearFloat returns 0-1
if (BrightnessSynchronizer.floatEquals(brightnessValue,
convertGammaToLinearFloat(mControl.getValue(), min, max))) {
// If the value in the slider is equal to the value on the current brightness
// then the slider does not need to animate, since the brightness will not change.
return;
}
// Returns GAMMA_SPACE_MIN - GAMMA_SPACE_MAX
final int sliderVal = convertLinearToGammaFloat(brightnessValue, min, max);
animateSliderTo(sliderVal);
}
private void animateSliderTo(int target) {
if (!mControlValueInitialized || !mControl.isVisible()) {
// Don't animate the first value since its default state isn't meaningful to users.
// We also don't want to animate slider if it's not visible - especially important when
// two sliders are active at the same time in split shade (one in QS and one in QQS),
// as this negatively affects transition between them and they share mirror slider -
// animating it from two different sources causes janky motion
mControl.setValue(target);
mControlValueInitialized = true;
}
mSliderAnimator = ValueAnimator.ofInt(mControl.getValue(), target);
mSliderAnimator.addUpdateListener((ValueAnimator animation) -> {
mExternalChange = true;
mControl.setValue((int) animation.getAnimatedValue());
mExternalChange = false;
});
final long animationDuration = SLIDER_ANIMATION_DURATION * Math.abs(
mControl.getValue() - target) / GAMMA_SPACE_MAX;
mSliderAnimator.setDuration(animationDuration);
mSliderAnimator.start();
}
/** Factory for creating a {@link BrightnessController}.
public static class Factory {
private final Context mContext;
private final UserTracker mUserTracker;
private final DisplayTracker mDisplayTracker;
private final Executor mMainExecutor;
private final Handler mBackgroundHandler;
@Inject
public Factory(
Context context,
UserTracker userTracker,
DisplayTracker displayTracker,
@Main Executor mainExecutor,
@Background Handler bgHandler) {
mContext = context;
mUserTracker = userTracker;
mDisplayTracker = displayTracker;
mMainExecutor = mainExecutor;
mBackgroundHandler = bgHandler;
}
/** Create a {@link BrightnessController} | Factory::create | java | Reginer/aosp-android-jar | android-34/src/com/android/systemui/settings/brightness/BrightnessController.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/settings/brightness/BrightnessController.java | MIT |
public final MidiReceiver[] getOutputPortReceivers() {
if (mServer == null) {
return null;
} else {
return mServer.getOutputPortReceivers();
}
} |
Returns an array of {@link MidiReceiver} for the device's output ports.
These can be used to send data out the device's output ports.
@return array of MidiReceivers
| MidiDeviceService::getOutputPortReceivers | java | Reginer/aosp-android-jar | android-31/src/android/media/midi/MidiDeviceService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/media/midi/MidiDeviceService.java | MIT |
public final MidiDeviceInfo getDeviceInfo() {
return mDeviceInfo;
} |
returns the {@link MidiDeviceInfo} instance for this service
@return our MidiDeviceInfo
| MidiDeviceService::getDeviceInfo | java | Reginer/aosp-android-jar | android-31/src/android/media/midi/MidiDeviceService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/media/midi/MidiDeviceService.java | MIT |
public void onDeviceStatusChanged(MidiDeviceStatus status) {
} |
Called to notify when an our {@link MidiDeviceStatus} has changed
@param status the number of the port that was opened
| MidiDeviceService::onDeviceStatusChanged | java | Reginer/aosp-android-jar | android-31/src/android/media/midi/MidiDeviceService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/media/midi/MidiDeviceService.java | MIT |
public void onClose() {
} |
Called to notify when our device has been closed by all its clients
| MidiDeviceService::onClose | java | Reginer/aosp-android-jar | android-31/src/android/media/midi/MidiDeviceService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/media/midi/MidiDeviceService.java | MIT |
public static TestSuite suite() throws Exception {
Class testClass =
ClassLoader.getSystemClassLoader().loadClass(
"org.w3c.domts.level2.events.alltests");
Constructor testConstructor =
testClass.getConstructor(
new Class[] { DOMTestDocumentBuilderFactory.class });
DocumentBuilderFactory oracleFactory =
(DocumentBuilderFactory) ClassLoader
.getSystemClassLoader()
.loadClass("oracle.xml.jaxp.JXDocumentBuilderFactory")
.newInstance();
DOMTestDocumentBuilderFactory factory =
new JAXPDOMTestDocumentBuilderFactory(
oracleFactory,
JAXPDOMTestDocumentBuilderFactory.getConfiguration1());
Object test = testConstructor.newInstance(new Object[] { factory });
return new JUnitTestSuiteAdapter((DOMTestSuite) test);
} |
Constructor
@return test suite
@throws Exception
| TestOracle::suite | java | Reginer/aosp-android-jar | android-33/src/org/w3c/domts/level2/events/TestOracle.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level2/events/TestOracle.java | MIT |
public void addView(View view, WindowManager.LayoutParams attrs, int displayId,
@WindowManager.ShellRootLayer int shellRootLayer) {
PerDisplay pd = mPerDisplay.get(displayId);
if (pd == null) {
pd = new PerDisplay(displayId);
mPerDisplay.put(displayId, pd);
}
pd.addView(view, attrs, shellRootLayer);
} |
Adds a view to system-ui window management.
| SystemWindows::addView | java | Reginer/aosp-android-jar | android-32/src/com/android/wm/shell/common/SystemWindows.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/wm/shell/common/SystemWindows.java | MIT |
public void removeView(View view) {
SurfaceControlViewHost root = mViewRoots.remove(view);
root.release();
} |
Removes a view from system-ui window management.
@param view
| SystemWindows::removeView | java | Reginer/aosp-android-jar | android-32/src/com/android/wm/shell/common/SystemWindows.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/wm/shell/common/SystemWindows.java | MIT |
public void updateViewLayout(@NonNull View view, ViewGroup.LayoutParams params) {
SurfaceControlViewHost root = mViewRoots.get(view);
if (root == null || !(params instanceof WindowManager.LayoutParams)) {
return;
}
view.setLayoutParams(params);
root.relayout((WindowManager.LayoutParams) params);
} |
Updates the layout params of a view.
| SystemWindows::updateViewLayout | java | Reginer/aosp-android-jar | android-32/src/com/android/wm/shell/common/SystemWindows.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/wm/shell/common/SystemWindows.java | MIT |
public void setShellRootAccessibilityWindow(int displayId,
@WindowManager.ShellRootLayer int shellRootLayer, View view) {
PerDisplay pd = mPerDisplay.get(displayId);
if (pd == null) {
return;
}
pd.setShellRootAccessibilityWindow(shellRootLayer, view);
} |
Sets the accessibility window for the given {@param shellRootLayer}.
| SystemWindows::setShellRootAccessibilityWindow | java | Reginer/aosp-android-jar | android-32/src/com/android/wm/shell/common/SystemWindows.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/wm/shell/common/SystemWindows.java | MIT |
public void setTouchableRegion(@NonNull View view, Region region) {
SurfaceControlViewHost root = mViewRoots.get(view);
if (root == null) {
return;
}
WindowlessWindowManager wwm = root.getWindowlessWM();
if (!(wwm instanceof SysUiWindowManager)) {
return;
}
((SysUiWindowManager) wwm).setTouchableRegionForWindow(view, region);
} |
Sets the touchable region of a view's window. This will be cropped to the window size.
@param view
@param region
| SystemWindows::setTouchableRegion | java | Reginer/aosp-android-jar | android-32/src/com/android/wm/shell/common/SystemWindows.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/wm/shell/common/SystemWindows.java | MIT |
IWindow getWindow(int displayId, int windowType) {
PerDisplay pd = mPerDisplay.get(displayId);
if (pd == null) {
return null;
}
return pd.getWindow(windowType);
} |
Get the IWindow token for a specific root.
@param windowType A window type from {@link WindowManager}.
| SystemWindows::getWindow | java | Reginer/aosp-android-jar | android-32/src/com/android/wm/shell/common/SystemWindows.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/wm/shell/common/SystemWindows.java | MIT |
public SurfaceControl getViewSurface(View rootView) {
for (int i = 0; i < mPerDisplay.size(); ++i) {
for (int iWm = 0; iWm < mPerDisplay.valueAt(i).mWwms.size(); ++iWm) {
SurfaceControl out = mPerDisplay.valueAt(i).mWwms.valueAt(iWm)
.getSurfaceControlForWindow(rootView);
if (out != null) {
return out;
}
}
}
return null;
} |
Gets the SurfaceControl associated with a root view. This is the same surface that backs the
ViewRootImpl.
| SystemWindows::getViewSurface | java | Reginer/aosp-android-jar | android-32/src/com/android/wm/shell/common/SystemWindows.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/wm/shell/common/SystemWindows.java | MIT |
public static int available(FileDescriptor fd) throws IOException {
try {
int available = Libcore.os.ioctlInt(fd, FIONREAD);
if (available < 0) {
// If the fd refers to a regular file, the result is the difference between
// the file size and the file position. This may be negative if the position
// is past the end of the file. If the fd refers to a special file masquerading
// as a regular file, the result may be negative because the special file
// may appear to have zero size and yet a previous read call may have
// read some amount of data and caused the file position to be advanced.
available = 0;
}
return available;
} catch (ErrnoException errnoException) {
if (errnoException.errno == ENOTTY) {
// The fd is unwilling to opine about its read buffer.
return 0;
}
throw errnoException.rethrowAsIOException();
}
} |
Collection of utility methods to work with blocking and non-blocking I/O that wrap raw POSIX
system calls, e.g. {@link android.system.Os}. These wrappers are to signal other blocked I/O
threads and avoid boilerplate code of routine error checks when using raw system calls.
<p>
For example, when using {@link Os#read(FileDescriptor, byte[], int, int)}, return value can
contain:
<ul>
<li>{@code 0} which means EOF</li>
<li>{@code N > 0} which means number of bytes read</li>
<li>{@code -1} which means error, and {@link ErrnoException} is thrown</li>
</ul>
<p>
{@link ErrnoException} in its turn can be one of:
<ul>
<li>{@link android.system.OsConstants#EAGAIN} which means the file descriptor refers to a file
or a socket, which has been marked nonblocking
({@link android.system.OsConstants#O_NONBLOCK}), and the read would block</li>
<li>{@link android.system.OsConstants#EBADF} which means the file descriptor is not a valid
file descriptor or is not open for reading</li>
<li>{@link android.system.OsConstants#EFAULT} which means given buffer is outside accessible
address space</li>
<li>{@link android.system.OsConstants#EINTR} which means the call was interrupted by a signal
before any data was read</li>
<li>{@link android.system.OsConstants#EINVAL} which means the file descriptor is attached to
an object which is unsuitable for reading; or the file was opened with the
{@link android.system.OsConstants#O_DIRECT} flag, and either the address specified in
{@code buffer}, the value specified in {@code count}, or the file {@code offset} is not
suitably aligned</li>
<li>{@link android.system.OsConstants#EIO} which means I/O error happened</li>
<li>{@link android.system.OsConstants#EISDIR} which means the file descriptor refers to a
directory</li>
</ul>
All these errors require handling, and this class contains some wrapper methods that handle most
common cases, making usage of system calls more user friendly.
@hide
@SystemApi(client = MODULE_LIBRARIES)
public final class IoBridge {
private IoBridge() {
}
/** @hide | IoBridge::available | java | Reginer/aosp-android-jar | android-34/src/libcore/io/IoBridge.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/libcore/io/IoBridge.java | MIT |
public static void bind(FileDescriptor fd, InetAddress address, int port) throws SocketException {
if (address instanceof Inet6Address) {
Inet6Address inet6Address = (Inet6Address) address;
if (inet6Address.getScopeId() == 0 && inet6Address.isLinkLocalAddress()) {
// Linux won't let you bind a link-local address without a scope id.
// Find one.
NetworkInterface nif = NetworkInterface.getByInetAddress(address);
if (nif == null) {
throw new SocketException("Can't bind to a link-local address without a scope id: " + address);
}
try {
address = Inet6Address.getByAddress(address.getHostName(), address.getAddress(), nif.getIndex());
} catch (UnknownHostException ex) {
throw new AssertionError(ex); // Can't happen.
}
}
}
try {
Libcore.os.bind(fd, address, port);
} catch (ErrnoException errnoException) {
if (errnoException.errno == EADDRINUSE || errnoException.errno == EADDRNOTAVAIL ||
errnoException.errno == EPERM || errnoException.errno == EACCES) {
throw new BindException(errnoException.getMessage(), errnoException);
} else {
throw new SocketException(errnoException.getMessage(), errnoException);
}
}
} |
Collection of utility methods to work with blocking and non-blocking I/O that wrap raw POSIX
system calls, e.g. {@link android.system.Os}. These wrappers are to signal other blocked I/O
threads and avoid boilerplate code of routine error checks when using raw system calls.
<p>
For example, when using {@link Os#read(FileDescriptor, byte[], int, int)}, return value can
contain:
<ul>
<li>{@code 0} which means EOF</li>
<li>{@code N > 0} which means number of bytes read</li>
<li>{@code -1} which means error, and {@link ErrnoException} is thrown</li>
</ul>
<p>
{@link ErrnoException} in its turn can be one of:
<ul>
<li>{@link android.system.OsConstants#EAGAIN} which means the file descriptor refers to a file
or a socket, which has been marked nonblocking
({@link android.system.OsConstants#O_NONBLOCK}), and the read would block</li>
<li>{@link android.system.OsConstants#EBADF} which means the file descriptor is not a valid
file descriptor or is not open for reading</li>
<li>{@link android.system.OsConstants#EFAULT} which means given buffer is outside accessible
address space</li>
<li>{@link android.system.OsConstants#EINTR} which means the call was interrupted by a signal
before any data was read</li>
<li>{@link android.system.OsConstants#EINVAL} which means the file descriptor is attached to
an object which is unsuitable for reading; or the file was opened with the
{@link android.system.OsConstants#O_DIRECT} flag, and either the address specified in
{@code buffer}, the value specified in {@code count}, or the file {@code offset} is not
suitably aligned</li>
<li>{@link android.system.OsConstants#EIO} which means I/O error happened</li>
<li>{@link android.system.OsConstants#EISDIR} which means the file descriptor refers to a
directory</li>
</ul>
All these errors require handling, and this class contains some wrapper methods that handle most
common cases, making usage of system calls more user friendly.
@hide
@SystemApi(client = MODULE_LIBRARIES)
public final class IoBridge {
private IoBridge() {
}
/** @hide
public static int available(FileDescriptor fd) throws IOException {
try {
int available = Libcore.os.ioctlInt(fd, FIONREAD);
if (available < 0) {
// If the fd refers to a regular file, the result is the difference between
// the file size and the file position. This may be negative if the position
// is past the end of the file. If the fd refers to a special file masquerading
// as a regular file, the result may be negative because the special file
// may appear to have zero size and yet a previous read call may have
// read some amount of data and caused the file position to be advanced.
available = 0;
}
return available;
} catch (ErrnoException errnoException) {
if (errnoException.errno == ENOTTY) {
// The fd is unwilling to opine about its read buffer.
return 0;
}
throw errnoException.rethrowAsIOException();
}
}
/** @hide | IoBridge::bind | java | Reginer/aosp-android-jar | android-34/src/libcore/io/IoBridge.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/libcore/io/IoBridge.java | MIT |
public static void connect(FileDescriptor fd, InetAddress inetAddress, int port) throws SocketException {
try {
IoBridge.connect(fd, inetAddress, port, 0);
} catch (SocketTimeoutException ex) {
throw new AssertionError(ex); // Can't happen for a connect without a timeout.
}
} |
Connects socket 'fd' to 'inetAddress' on 'port', with no timeout. The lack of a timeout
means this method won't throw SocketTimeoutException.
@hide
| IoBridge::connect | java | Reginer/aosp-android-jar | android-34/src/libcore/io/IoBridge.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/libcore/io/IoBridge.java | MIT |
public static void connect(FileDescriptor fd, InetAddress inetAddress, int port, int timeoutMs) throws SocketException, SocketTimeoutException {
try {
connectErrno(fd, inetAddress, port, timeoutMs);
} catch (ErrnoException errnoException) {
if (errnoException.errno == EHOSTUNREACH) {
throw new NoRouteToHostException("Host unreachable");
}
if (errnoException.errno == EADDRNOTAVAIL) {
throw new NoRouteToHostException("Address not available");
}
throw new ConnectException(createMessageForException(fd, inetAddress, port, timeoutMs,
errnoException), errnoException);
} catch (SocketException ex) {
throw ex; // We don't want to doubly wrap these.
} catch (SocketTimeoutException ex) {
throw ex; // We don't want to doubly wrap these.
} catch (IOException ex) {
throw new SocketException(ex);
}
} |
Connects socket 'fd' to 'inetAddress' on 'port', with a the given 'timeoutMs'.
Use timeoutMs == 0 for a blocking connect with no timeout.
@hide
| IoBridge::connect | java | Reginer/aosp-android-jar | android-34/src/libcore/io/IoBridge.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/libcore/io/IoBridge.java | MIT |
private static String createMessageForException(FileDescriptor fd, InetAddress inetAddress,
int port, int timeoutMs, Exception causeOrNull) {
// Figure out source address from fd.
InetSocketAddress localAddress = null;
try {
localAddress = getLocalInetSocketAddress(fd);
} catch (SocketException ignored) {
// The caller is about to throw an exception, so this one would only distract.
}
StringBuilder sb = new StringBuilder("failed to connect")
.append(" to ")
.append(inetAddress)
.append(" (port ")
.append(port)
.append(")");
if (localAddress != null) {
sb.append(" from ")
.append(localAddress.getAddress())
.append(" (port ")
.append(localAddress.getPort())
.append(")");
}
if (timeoutMs > 0) {
sb.append(" after ")
.append(timeoutMs)
.append("ms");
}
if (causeOrNull != null) {
sb.append(": ")
.append(causeOrNull.getMessage());
}
return sb.toString();
} |
Constructs the message for an exception that the caller is about to throw.
@hide
| IoBridge::createMessageForException | java | Reginer/aosp-android-jar | android-34/src/libcore/io/IoBridge.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/libcore/io/IoBridge.java | MIT |
public static Object getSocketOption(FileDescriptor fd, int option) throws SocketException {
try {
return getSocketOptionErrno(fd, option);
} catch (ErrnoException errnoException) {
throw errnoException.rethrowAsSocketException();
}
} |
java.net has its own socket options similar to the underlying Unix ones. We paper over the
differences here.
@hide
| IoBridge::getSocketOption | java | Reginer/aosp-android-jar | android-34/src/libcore/io/IoBridge.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/libcore/io/IoBridge.java | MIT |
public static void setSocketOption(FileDescriptor fd, int option, Object value) throws SocketException {
try {
setSocketOptionErrno(fd, option, value);
} catch (ErrnoException errnoException) {
throw errnoException.rethrowAsSocketException();
}
} |
java.net has its own socket options similar to the underlying Unix ones. We paper over the
differences here.
@hide
| IoBridge::setSocketOption | java | Reginer/aosp-android-jar | android-34/src/libcore/io/IoBridge.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/libcore/io/IoBridge.java | MIT |
public static int sendto(@NonNull FileDescriptor fd, @NonNull byte[] bytes, int byteOffset, int byteCount, int flags, @Nullable InetAddress inetAddress, int port) throws IOException {
boolean isDatagram = (inetAddress != null);
if (!isDatagram && byteCount <= 0) {
return 0;
}
int result;
try {
result = Libcore.os.sendto(fd, bytes, byteOffset, byteCount, flags, inetAddress, port);
} catch (ErrnoException errnoException) {
result = maybeThrowAfterSendto(isDatagram, errnoException);
}
return result;
} |
Wrapper around {@link Os#sendto(FileDescriptor, byte[], int, int, int, InetAddress, int)}
that allows sending data over both TCP and UDP socket; handles
{@link android.system.OsConstants#EAGAIN} and {@link android.system.OsConstants#ECONNREFUSED}
and behaves similar to and behaves similar to
{@link java.net.DatagramSocket#send(DatagramPacket)} and
{@link Socket#getOutputStream()#write(FileDescriptor, byte[], int, int)}.
<p>See {@link android.system.OsConstants} for available flags.
<p>@see <a href="https://man7.org/linux/man-pages/man2/send.2.html">send(2)</a>.
@param fd {@link FileDescriptor} of the socket to send data over
@param bytes byte buffer containing the data to be sent
@param byteOffset offset in {@code bytes} at which data to be sent starts
@param byteCount number of bytes to be sent
@param flags bitwise OR of zero or more of flags, like {@link android.system.OsConstants#MSG_DONTROUTE}
@param inetAddress destination address
@param port destination port
@return number of bytes sent on success
@throws IOException if underlying system call returned error
@hide
| IoBridge::sendto | java | Reginer/aosp-android-jar | android-34/src/libcore/io/IoBridge.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/libcore/io/IoBridge.java | MIT |
public static int sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port) throws IOException {
boolean isDatagram = (inetAddress != null);
if (!isDatagram && buffer.remaining() == 0) {
return 0;
}
int result;
try {
result = Libcore.os.sendto(fd, buffer, flags, inetAddress, port);
} catch (ErrnoException errnoException) {
result = maybeThrowAfterSendto(isDatagram, errnoException);
}
return result;
} |
Wrapper around {@link Os#sendto(FileDescriptor, byte[], int, int, int, InetAddress, int)}
that allows sending data over both TCP and UDP socket; handles
{@link android.system.OsConstants#EAGAIN} and {@link android.system.OsConstants#ECONNREFUSED}
and behaves similar to and behaves similar to
{@link java.net.DatagramSocket#send(DatagramPacket)} and
{@link Socket#getOutputStream()#write(FileDescriptor, byte[], int, int)}.
<p>See {@link android.system.OsConstants} for available flags.
<p>@see <a href="https://man7.org/linux/man-pages/man2/send.2.html">send(2)</a>.
@param fd {@link FileDescriptor} of the socket to send data over
@param bytes byte buffer containing the data to be sent
@param byteOffset offset in {@code bytes} at which data to be sent starts
@param byteCount number of bytes to be sent
@param flags bitwise OR of zero or more of flags, like {@link android.system.OsConstants#MSG_DONTROUTE}
@param inetAddress destination address
@param port destination port
@return number of bytes sent on success
@throws IOException if underlying system call returned error
@hide
public static int sendto(@NonNull FileDescriptor fd, @NonNull byte[] bytes, int byteOffset, int byteCount, int flags, @Nullable InetAddress inetAddress, int port) throws IOException {
boolean isDatagram = (inetAddress != null);
if (!isDatagram && byteCount <= 0) {
return 0;
}
int result;
try {
result = Libcore.os.sendto(fd, bytes, byteOffset, byteCount, flags, inetAddress, port);
} catch (ErrnoException errnoException) {
result = maybeThrowAfterSendto(isDatagram, errnoException);
}
return result;
}
/** @hide | IoBridge::sendto | java | Reginer/aosp-android-jar | android-34/src/libcore/io/IoBridge.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/libcore/io/IoBridge.java | MIT |
public static int recvfrom(boolean isRead, @NonNull FileDescriptor fd, @NonNull byte[] bytes, int byteOffset, int byteCount, int flags, @Nullable DatagramPacket packet, boolean isConnected) throws IOException {
int result;
try {
InetSocketAddress srcAddress = packet != null ? new InetSocketAddress() : null;
result = Libcore.os.recvfrom(fd, bytes, byteOffset, byteCount, flags, srcAddress);
result = postRecvfrom(isRead, packet, srcAddress, result);
} catch (ErrnoException errnoException) {
result = maybeThrowAfterRecvfrom(isRead, isConnected, errnoException);
}
return result;
} |
Wrapper around {@link Os#recvfrom(FileDescriptor, byte[], int, int, int, InetSocketAddress)}
that receives a message from both TCP and UDP socket; handles
{@link android.system.OsConstants#EAGAIN} and {@link android.system.OsConstants#ECONNREFUSED}
and behaves similar to {@link java.net.DatagramSocket#receive(DatagramPacket)} and
{@link Socket#getInputStream()#recvfrom(boolean, FileDescriptor, byte[], int, int, int, DatagramPacket, boolean)}.
<p>If {@code packet} is not {@code null}, and the underlying protocol provides the source
address of the message, that source address is placed in the {@code packet}.
@see <a href="https://man7.org/linux/man-pages/man2/recv.2.html">recv(2)</a>.
@param isRead {@code true} if some data been read already from {@code fd}
@param fd socket to receive data from
@param bytes buffer to put data read from {@code fd}
@param byteOffset offset in {@code bytes} buffer to put read data at
@param byteCount number of bytes to read from {@code fd}
@param flags bitwise OR of zero or more of flags, like {@link android.system.OsConstants#MSG_DONTROUTE}
@param packet {@link DatagramPacket} to fill with source address
@param isConnected {@code true} if socket {@code fd} is connected
@return number of bytes read, if read operation was successful
@throws IOException if underlying system call returned error
@hide
| IoBridge::recvfrom | java | Reginer/aosp-android-jar | android-34/src/libcore/io/IoBridge.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/libcore/io/IoBridge.java | MIT |
public static int recvfrom(boolean isRead, FileDescriptor fd, ByteBuffer buffer, int flags, DatagramPacket packet, boolean isConnected) throws IOException {
int result;
try {
InetSocketAddress srcAddress = packet != null ? new InetSocketAddress() : null;
result = Libcore.os.recvfrom(fd, buffer, flags, srcAddress);
result = postRecvfrom(isRead, packet, srcAddress, result);
} catch (ErrnoException errnoException) {
result = maybeThrowAfterRecvfrom(isRead, isConnected, errnoException);
}
return result;
} |
Wrapper around {@link Os#recvfrom(FileDescriptor, byte[], int, int, int, InetSocketAddress)}
that receives a message from both TCP and UDP socket; handles
{@link android.system.OsConstants#EAGAIN} and {@link android.system.OsConstants#ECONNREFUSED}
and behaves similar to {@link java.net.DatagramSocket#receive(DatagramPacket)} and
{@link Socket#getInputStream()#recvfrom(boolean, FileDescriptor, byte[], int, int, int, DatagramPacket, boolean)}.
<p>If {@code packet} is not {@code null}, and the underlying protocol provides the source
address of the message, that source address is placed in the {@code packet}.
@see <a href="https://man7.org/linux/man-pages/man2/recv.2.html">recv(2)</a>.
@param isRead {@code true} if some data been read already from {@code fd}
@param fd socket to receive data from
@param bytes buffer to put data read from {@code fd}
@param byteOffset offset in {@code bytes} buffer to put read data at
@param byteCount number of bytes to read from {@code fd}
@param flags bitwise OR of zero or more of flags, like {@link android.system.OsConstants#MSG_DONTROUTE}
@param packet {@link DatagramPacket} to fill with source address
@param isConnected {@code true} if socket {@code fd} is connected
@return number of bytes read, if read operation was successful
@throws IOException if underlying system call returned error
@hide
public static int recvfrom(boolean isRead, @NonNull FileDescriptor fd, @NonNull byte[] bytes, int byteOffset, int byteCount, int flags, @Nullable DatagramPacket packet, boolean isConnected) throws IOException {
int result;
try {
InetSocketAddress srcAddress = packet != null ? new InetSocketAddress() : null;
result = Libcore.os.recvfrom(fd, bytes, byteOffset, byteCount, flags, srcAddress);
result = postRecvfrom(isRead, packet, srcAddress, result);
} catch (ErrnoException errnoException) {
result = maybeThrowAfterRecvfrom(isRead, isConnected, errnoException);
}
return result;
}
/** @hide | IoBridge::recvfrom | java | Reginer/aosp-android-jar | android-34/src/libcore/io/IoBridge.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/libcore/io/IoBridge.java | MIT |
public static @NonNull FileDescriptor socket(int domain, int type, int protocol) throws SocketException {
FileDescriptor fd;
try {
fd = Libcore.os.socket(domain, type, protocol);
return fd;
} catch (ErrnoException errnoException) {
throw errnoException.rethrowAsSocketException();
}
} |
Creates an endpoint for communication and returns a file descriptor that refers
to that endpoint.
<p>The {@code domain} specifies a communication domain; this selects the protocol
family which will be used for communication, e.g. {@link android.system.OsConstants#AF_UNIX}
{@link android.system.OsConstants#AF_INET}.
<p>The socket has the indicated type, which specifies the communication semantics,
e.g. {@link android.system.OsConstants#SOCK_STREAM} or
{@link android.system.OsConstants#SOCK_DGRAM}.
<p>The protocol specifies a particular protocol to be used with the
socket. Normally only a single protocol exists to support a
particular socket type within a given protocol family, in which
case protocol can be specified as {@code 0}.
@see <a href="https://man7.org/linux/man-pages/man2/socket.2.html">socket(2)</a>.
@param domain socket domain
@param type socket type
@param protocol socket protocol
@return {@link FileDescriptor} of an opened socket
@throws SocketException if underlying system call returned error
@hide
| IoBridge::socket | java | Reginer/aosp-android-jar | android-34/src/libcore/io/IoBridge.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/libcore/io/IoBridge.java | MIT |
public static void poll(FileDescriptor fd, int events, int timeout)
throws SocketException, SocketTimeoutException {
StructPollfd[] pollFds = new StructPollfd[]{ new StructPollfd() };
pollFds[0].fd = fd;
pollFds[0].events = (short) events;
try {
int ret = android.system.Os.poll(pollFds, timeout);
if (ret == 0) {
throw new SocketTimeoutException("Poll timed out");
}
} catch (ErrnoException e) {
e.rethrowAsSocketException();
}
} |
Wait for some event on a file descriptor, blocks until the event happened or timeout period
passed. See poll(2) and @link{android.system.Os.Poll}.
@throws SocketException if poll(2) fails.
@throws SocketTimeoutException if the event has not happened before timeout period has passed.
@hide
| IoBridge::poll | java | Reginer/aosp-android-jar | android-34/src/libcore/io/IoBridge.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/libcore/io/IoBridge.java | MIT |
public static @NonNull InetSocketAddress getLocalInetSocketAddress(@NonNull FileDescriptor fd)
throws SocketException {
try {
SocketAddress socketAddress = Libcore.os.getsockname(fd);
// When a Socket is pending closure because socket.close() was called but other threads
// are still using it, the FileDescriptor can be dup2'ed to an AF_UNIX one; see the
// deferred close logic in PlainSocketImpl.socketClose0(true) for details.
// If socketAddress is not the expected type then we assume that the socket is being
// closed, so we throw a SocketException (just like in the case of an ErrnoException).
// http://b/64209834
if ((socketAddress != null) && !(socketAddress instanceof InetSocketAddress)) {
throw new SocketException("Socket assumed to be pending closure: Expected sockname "
+ "to be an InetSocketAddress, got " + socketAddress.getClass());
}
return (InetSocketAddress) socketAddress;
} catch (ErrnoException errnoException) {
throw errnoException.rethrowAsSocketException();
}
} |
Returns the current address to which the socket {@code fd} is bound.
@see <a href="https://man7.org/linux/man-pages/man2/getsockname.2.html">getsockname(2)</a>.
@param fd socket to get the bounded address of
@return current address to which the socket {@code fd} is bound
@throws SocketException if {@code fd} is not currently bound to an {@link InetSocketAddress}
@hide
| IoBridge::getLocalInetSocketAddress | java | Reginer/aosp-android-jar | android-34/src/libcore/io/IoBridge.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/libcore/io/IoBridge.java | MIT |
public elementreplaceexistingattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException {
super(factory);
//
// check if loaded documents are supported for content type
//
String contentType = getContentType();
preload(contentType, "staff", true);
} |
Constructor.
@param factory document factory, may not be null
@throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
| elementreplaceexistingattribute::elementreplaceexistingattribute | java | Reginer/aosp-android-jar | android-33/src/org/w3c/domts/level1/core/elementreplaceexistingattribute.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/elementreplaceexistingattribute.java | MIT |
public void runTest() throws Throwable {
Document doc;
NodeList elementList;
Element testEmployee;
Attr newAttribute;
String name;
Attr setAttr;
doc = (Document) load("staff", true);
elementList = doc.getElementsByTagName("address");
testEmployee = (Element) elementList.item(2);
newAttribute = doc.createAttribute("street");
setAttr = testEmployee.setAttributeNode(newAttribute);
name = testEmployee.getAttribute("street");
assertEquals("elementReplaceExistingAttributeAssert", "", name);
} |
Runs the test case.
@throws Throwable Any uncaught exception causes test to fail
| elementreplaceexistingattribute::runTest | java | Reginer/aosp-android-jar | android-33/src/org/w3c/domts/level1/core/elementreplaceexistingattribute.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/elementreplaceexistingattribute.java | MIT |
public String getTargetURI() {
return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementreplaceexistingattribute";
} |
Gets URI that identifies the test.
@return uri identifier of test
| elementreplaceexistingattribute::getTargetURI | java | Reginer/aosp-android-jar | android-33/src/org/w3c/domts/level1/core/elementreplaceexistingattribute.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/elementreplaceexistingattribute.java | MIT |
public static void main(final String[] args) {
DOMTestCase.doMain(elementreplaceexistingattribute.class, args);
} |
Runs this test from the command line.
@param args command line arguments
| elementreplaceexistingattribute::main | java | Reginer/aosp-android-jar | android-33/src/org/w3c/domts/level1/core/elementreplaceexistingattribute.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/elementreplaceexistingattribute.java | MIT |
public final void setAccountAuthenticatorResult(Bundle result) {
mResultBundle = result;
} |
Set the result that is to be sent as the result of the request that caused this
Activity to be launched. If result is null or this method is never called then
the request will be canceled.
@param result this is returned as the result of the AbstractAccountAuthenticator request
| AccountAuthenticatorActivity::setAccountAuthenticatorResult | java | Reginer/aosp-android-jar | android-33/src/android/accounts/AccountAuthenticatorActivity.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/accounts/AccountAuthenticatorActivity.java | MIT |
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
mAccountAuthenticatorResponse =
getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
if (mAccountAuthenticatorResponse != null) {
mAccountAuthenticatorResponse.onRequestContinued();
}
} |
Retrieves the AccountAuthenticatorResponse from either the intent of the icicle, if the
icicle is non-zero.
@param icicle the save instance data of this Activity, may be null
| AccountAuthenticatorActivity::onCreate | java | Reginer/aosp-android-jar | android-33/src/android/accounts/AccountAuthenticatorActivity.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/accounts/AccountAuthenticatorActivity.java | MIT |
public void finish() {
if (mAccountAuthenticatorResponse != null) {
// send the result bundle back if set, otherwise send an error.
if (mResultBundle != null) {
mAccountAuthenticatorResponse.onResult(mResultBundle);
} else {
mAccountAuthenticatorResponse.onError(AccountManager.ERROR_CODE_CANCELED,
"canceled");
}
mAccountAuthenticatorResponse = null;
}
super.finish();
} |
Sends the result or a Constants.ERROR_CODE_CANCELED error if a result isn't present.
| AccountAuthenticatorActivity::finish | java | Reginer/aosp-android-jar | android-33/src/android/accounts/AccountAuthenticatorActivity.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/accounts/AccountAuthenticatorActivity.java | MIT |
private MidiEvent createScheduledEvent(byte[] msg, int offset, int count,
long timestamp) {
MidiEvent event;
if (count > POOL_EVENT_SIZE) {
event = new MidiEvent(msg, offset, count, timestamp);
} else {
event = (MidiEvent) removeEventfromPool();
if (event == null) {
event = new MidiEvent(POOL_EVENT_SIZE);
}
System.arraycopy(msg, offset, event.data, 0, count);
event.count = count;
event.setTimestamp(timestamp);
}
return event;
} |
Create an event that contains the message.
| MidiEvent::createScheduledEvent | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/midi/MidiEventScheduler.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/midi/MidiEventScheduler.java | MIT |
public MidiReceiver getReceiver() {
return mReceiver;
} |
This MidiReceiver will write date to the scheduling buffer.
@return the MidiReceiver
| MidiEvent::getReceiver | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/midi/MidiEventScheduler.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/midi/MidiEventScheduler.java | MIT |
private PhoneConfigurationManager(Context context) {
mContext = context;
// TODO: send commands to modem once interface is ready.
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
//initialize with default, it'll get updated when RADIO is ON/AVAILABLE
mStaticCapability = getDefaultCapability();
mRadioConfig = RadioConfig.getInstance();
mHandler = new ConfigManagerHandler();
mPhoneStatusMap = new HashMap<>();
notifyCapabilityChanged();
mPhones = PhoneFactory.getPhones();
for (Phone phone : mPhones) {
registerForRadioState(phone);
}
} |
Constructor.
@param context context needed to send broadcast.
| PhoneConfigurationManager::PhoneConfigurationManager | java | Reginer/aosp-android-jar | android-32/src/com/android/internal/telephony/PhoneConfigurationManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/PhoneConfigurationManager.java | MIT |
public static PhoneConfigurationManager getInstance() {
if (sInstance == null) {
Log.wtf(LOG_TAG, "getInstance null");
}
return sInstance;
} |
Static method to get instance.
| PhoneConfigurationManager::getInstance | java | Reginer/aosp-android-jar | android-32/src/com/android/internal/telephony/PhoneConfigurationManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/PhoneConfigurationManager.java | MIT |
public void enablePhone(Phone phone, boolean enable, Message result) {
if (phone == null) {
log("enablePhone failed phone is null");
return;
}
phone.mCi.enableModem(enable, result);
} |
Enable or disable phone
@param phone which phone to operate on
@param enable true or false
@param result the message to sent back when it's done.
| ConfigManagerHandler::enablePhone | java | Reginer/aosp-android-jar | android-32/src/com/android/internal/telephony/PhoneConfigurationManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/PhoneConfigurationManager.java | MIT |
public boolean getPhoneStatus(Phone phone) {
if (phone == null) {
log("getPhoneStatus failed phone is null");
return false;
}
int phoneId = phone.getPhoneId();
//use cache if the status has already been updated/queried
try {
return getPhoneStatusFromCache(phoneId);
} catch (NoSuchElementException ex) {
// Return true if modem status cannot be retrieved. For most cases, modem status
// is on. And for older version modems, GET_MODEM_STATUS and disable modem are not
// supported. Modem is always on.
//TODO: this should be fixed in R to support a third status UNKNOWN b/131631629
return true;
} finally {
//in either case send an asynchronous request to retrieve the phone status
updatePhoneStatus(phone);
}
} |
Get phone status (enabled/disabled)
first query cache, if the status is not in cache,
add it to cache and return a default value true (non-blocking).
@param phone which phone to operate on
| ConfigManagerHandler::getPhoneStatus | java | Reginer/aosp-android-jar | android-32/src/com/android/internal/telephony/PhoneConfigurationManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/PhoneConfigurationManager.java | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.