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 getPhoneStatusFromModem(Phone phone, Message result) {
if (phone == null) {
log("getPhoneStatus failed phone is null");
}
phone.mCi.getModemStatus(result);
} |
Get phone status (enabled/disabled) directly from modem, and use a result Message object
Note: the caller of this method is reponsible to call this in a blocking fashion as well
as read the results and handle the error case.
(In order to be consistent, in error case, we should return default value of true; refer
to #getPhoneStatus method)
@param phone which phone to operate on
@param result message that will be updated with result
| ConfigManagerHandler::getPhoneStatusFromModem | 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 getPhoneStatusFromCache(int phoneId) throws NoSuchElementException {
if (mPhoneStatusMap.containsKey(phoneId)) {
return mPhoneStatusMap.get(phoneId);
} else {
throw new NoSuchElementException("phoneId not found: " + phoneId);
}
} |
return modem status from cache, NoSuchElementException if phoneId not in cache
@param phoneId
| ConfigManagerHandler::getPhoneStatusFromCache | 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 |
private void updatePhoneStatus(Phone phone) {
Message result = Message.obtain(
mHandler, EVENT_GET_MODEM_STATUS_DONE, phone.getPhoneId(), 0 /**dummy arg*/);
phone.mCi.getModemStatus(result);
} |
method to call RIL getModemStatus
| ConfigManagerHandler::updatePhoneStatus | 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 addToPhoneStatusCache(int phoneId, boolean status) {
mPhoneStatusMap.put(phoneId, status);
} |
Add status of the phone to the status HashMap
@param phoneId
@param status
| ConfigManagerHandler::addToPhoneStatusCache | 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 int getPhoneCount() {
return mTelephonyManager.getActiveModemCount();
} |
Returns how many phone objects the device supports.
| ConfigManagerHandler::getPhoneCount | 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 synchronized PhoneCapability getStaticPhoneCapability() {
if (getDefaultCapability().equals(mStaticCapability)) {
log("getStaticPhoneCapability: sending the request for getting PhoneCapability");
Message callback = Message.obtain(
mHandler, EVENT_GET_PHONE_CAPABILITY_DONE);
mRadioConfig.getPhoneCapability(callback);
}
log("getStaticPhoneCapability: mStaticCapability " + mStaticCapability);
return mStaticCapability;
} |
get static overall phone capabilities for all phones.
| ConfigManagerHandler::getStaticPhoneCapability | 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 PhoneCapability getCurrentPhoneCapability() {
return getStaticPhoneCapability();
} |
get configuration related status of each phone.
| ConfigManagerHandler::getCurrentPhoneCapability | 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 switchMultiSimConfig(int numOfSims) {
log("switchMultiSimConfig: with numOfSims = " + numOfSims);
if (getStaticPhoneCapability().getLogicalModemList().size() < numOfSims) {
log("switchMultiSimConfig: Phone is not capable of enabling "
+ numOfSims + " sims, exiting!");
return;
}
if (getPhoneCount() != numOfSims) {
log("switchMultiSimConfig: sending the request for switching");
Message callback = Message.obtain(
mHandler, EVENT_SWITCH_DSDS_CONFIG_DONE, numOfSims, 0 /**dummy arg*/);
mRadioConfig.setModemsConfig(numOfSims, callback);
} else {
log("switchMultiSimConfig: No need to switch. getNumOfActiveSims is already "
+ numOfSims);
}
} |
Switch configs to enable multi-sim or switch back to single-sim
@param numOfSims number of active sims we want to switch to
| ConfigManagerHandler::switchMultiSimConfig | 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 isRebootRequiredForModemConfigChange() {
return mMi.isRebootRequiredForModemConfigChange();
} |
Get whether reboot is required or not after making changes to modem configurations.
Return value defaults to true
| ConfigManagerHandler::isRebootRequiredForModemConfigChange | 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 |
private void setMultiSimProperties(int numOfActiveModems) {
mMi.setMultiSimProperties(numOfActiveModems);
} |
Helper method to set system properties for setting multi sim configs,
as well as doing the phone reboot
NOTE: In order to support more than 3 sims, we need to change this method.
@param numOfActiveModems number of active sims
| ConfigManagerHandler::setMultiSimProperties | 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 void registerForMultiSimConfigChange(Handler h, int what, Object obj) {
sMultiSimConfigChangeRegistrants.addUnique(h, what, obj);
} |
Register for multi-SIM configuration change, for example if the devices switched from single
SIM to dual-SIM mode.
It doesn't trigger callback upon registration as multi-SIM config change is in-frequent.
| ConfigManagerHandler::registerForMultiSimConfigChange | 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 void unregisterForMultiSimConfigChange(Handler h) {
sMultiSimConfigChangeRegistrants.remove(h);
} |
Unregister for multi-SIM configuration change.
| ConfigManagerHandler::unregisterForMultiSimConfigChange | 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 void unregisterAllMultiSimConfigChangeRegistrants() {
sMultiSimConfigChangeRegistrants.removeAll();
} |
Unregister for all multi-SIM configuration change events.
| ConfigManagerHandler::unregisterAllMultiSimConfigChangeRegistrants | 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 hc_characterdatareplacedataend(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException {
super(factory);
//
// check if loaded documents are supported for content type
//
String contentType = getContentType();
preload(contentType, "hc_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
| hc_characterdatareplacedataend::hc_characterdatareplacedataend | java | Reginer/aosp-android-jar | android-33/src/org/w3c/domts/level1/core/hc_characterdatareplacedataend.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/hc_characterdatareplacedataend.java | MIT |
public void runTest() throws Throwable {
Document doc;
NodeList elementList;
Node nameNode;
CharacterData child;
String childData;
doc = (Document) load("hc_staff", true);
elementList = doc.getElementsByTagName("acronym");
nameNode = elementList.item(0);
child = (CharacterData) nameNode.getFirstChild();
child.replaceData(30, 5, "98665");
childData = child.getData();
assertEquals("characterdataReplaceDataEndAssert", "1230 North Ave. Dallas, Texas 98665", childData);
} |
Runs the test case.
@throws Throwable Any uncaught exception causes test to fail
| hc_characterdatareplacedataend::runTest | java | Reginer/aosp-android-jar | android-33/src/org/w3c/domts/level1/core/hc_characterdatareplacedataend.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/hc_characterdatareplacedataend.java | MIT |
public String getTargetURI() {
return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatareplacedataend";
} |
Gets URI that identifies the test.
@return uri identifier of test
| hc_characterdatareplacedataend::getTargetURI | java | Reginer/aosp-android-jar | android-33/src/org/w3c/domts/level1/core/hc_characterdatareplacedataend.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/hc_characterdatareplacedataend.java | MIT |
public static void main(final String[] args) {
DOMTestCase.doMain(hc_characterdatareplacedataend.class, args);
} |
Runs this test from the command line.
@param args command line arguments
| hc_characterdatareplacedataend::main | java | Reginer/aosp-android-jar | android-33/src/org/w3c/domts/level1/core/hc_characterdatareplacedataend.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/org/w3c/domts/level1/core/hc_characterdatareplacedataend.java | MIT |
public boolean isEnabled() {
return mEnabled;
} | /*
Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
package com.android.systemui.statusbar.policy;
import android.app.RemoteInput;
import android.content.Context;
import android.content.res.Resources;
import android.os.Handler;
import android.provider.DeviceConfig;
import android.text.TextUtils;
import android.util.KeyValueListParser;
import android.util.Log;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.systemui.R;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.util.DeviceConfigProxy;
import javax.inject.Inject;
@SysUISingleton
public final class SmartReplyConstants {
private static final String TAG = "SmartReplyConstants";
private final boolean mDefaultEnabled;
private final boolean mDefaultRequiresP;
private final int mDefaultMaxSqueezeRemeasureAttempts;
private final boolean mDefaultEditChoicesBeforeSending;
private final boolean mDefaultShowInHeadsUp;
private final int mDefaultMinNumSystemGeneratedReplies;
private final int mDefaultMaxNumActions;
private final int mDefaultOnClickInitDelay;
// These fields are updated on the UI thread but can be accessed on both the UI thread and
// background threads. We use the volatile keyword here instead of synchronization blocks since
// we only care about variable updates here being visible to other threads (and not for example
// whether the variables we are reading were updated in the same go).
private volatile boolean mEnabled;
private volatile boolean mRequiresTargetingP;
private volatile int mMaxSqueezeRemeasureAttempts;
private volatile boolean mEditChoicesBeforeSending;
private volatile boolean mShowInHeadsUp;
private volatile int mMinNumSystemGeneratedReplies;
private volatile int mMaxNumActions;
private volatile long mOnClickInitDelay;
private final Handler mHandler;
private final Context mContext;
private final DeviceConfigProxy mDeviceConfig;
private final KeyValueListParser mParser = new KeyValueListParser(',');
@Inject
public SmartReplyConstants(
@Main Handler handler,
Context context,
DeviceConfigProxy deviceConfig
) {
mHandler = handler;
mContext = context;
final Resources resources = mContext.getResources();
mDefaultEnabled = resources.getBoolean(
R.bool.config_smart_replies_in_notifications_enabled);
mDefaultRequiresP = resources.getBoolean(
R.bool.config_smart_replies_in_notifications_requires_targeting_p);
mDefaultMaxSqueezeRemeasureAttempts = resources.getInteger(
R.integer.config_smart_replies_in_notifications_max_squeeze_remeasure_attempts);
mDefaultEditChoicesBeforeSending = resources.getBoolean(
R.bool.config_smart_replies_in_notifications_edit_choices_before_sending);
mDefaultShowInHeadsUp = resources.getBoolean(
R.bool.config_smart_replies_in_notifications_show_in_heads_up);
mDefaultMinNumSystemGeneratedReplies = resources.getInteger(
R.integer.config_smart_replies_in_notifications_min_num_system_generated_replies);
mDefaultMaxNumActions = resources.getInteger(
R.integer.config_smart_replies_in_notifications_max_num_actions);
mDefaultOnClickInitDelay = resources.getInteger(
R.integer.config_smart_replies_in_notifications_onclick_init_delay);
mDeviceConfig = deviceConfig;
registerDeviceConfigListener();
updateConstants();
}
private void registerDeviceConfigListener() {
mDeviceConfig.addOnPropertiesChangedListener(
DeviceConfig.NAMESPACE_SYSTEMUI,
this::postToHandler,
mOnPropertiesChangedListener);
}
private void postToHandler(Runnable r) {
this.mHandler.post(r);
}
private final DeviceConfig.OnPropertiesChangedListener mOnPropertiesChangedListener =
new DeviceConfig.OnPropertiesChangedListener() {
@Override
public void onPropertiesChanged(DeviceConfig.Properties properties) {
if (!DeviceConfig.NAMESPACE_SYSTEMUI.equals(properties.getNamespace())) {
Log.e(TAG,
"Received update from DeviceConfig for unrelated namespace: "
+ properties.getNamespace());
return;
}
updateConstants();
}
};
private void updateConstants() {
synchronized (SmartReplyConstants.this) {
mEnabled = readDeviceConfigBooleanOrDefaultIfEmpty(
SystemUiDeviceConfigFlags.SSIN_ENABLED,
mDefaultEnabled);
mRequiresTargetingP = readDeviceConfigBooleanOrDefaultIfEmpty(
SystemUiDeviceConfigFlags.SSIN_REQUIRES_TARGETING_P,
mDefaultRequiresP);
mMaxSqueezeRemeasureAttempts = mDeviceConfig.getInt(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.SSIN_MAX_SQUEEZE_REMEASURE_ATTEMPTS,
mDefaultMaxSqueezeRemeasureAttempts);
mEditChoicesBeforeSending = readDeviceConfigBooleanOrDefaultIfEmpty(
SystemUiDeviceConfigFlags.SSIN_EDIT_CHOICES_BEFORE_SENDING,
mDefaultEditChoicesBeforeSending);
mShowInHeadsUp = readDeviceConfigBooleanOrDefaultIfEmpty(
SystemUiDeviceConfigFlags.SSIN_SHOW_IN_HEADS_UP,
mDefaultShowInHeadsUp);
mMinNumSystemGeneratedReplies = mDeviceConfig.getInt(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.SSIN_MIN_NUM_SYSTEM_GENERATED_REPLIES,
mDefaultMinNumSystemGeneratedReplies);
mMaxNumActions = mDeviceConfig.getInt(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.SSIN_MAX_NUM_ACTIONS,
mDefaultMaxNumActions);
mOnClickInitDelay = mDeviceConfig.getInt(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.SSIN_ONCLICK_INIT_DELAY,
mDefaultOnClickInitDelay);
}
}
private boolean readDeviceConfigBooleanOrDefaultIfEmpty(String propertyName,
boolean defaultValue) {
String value = mDeviceConfig.getProperty(DeviceConfig.NAMESPACE_SYSTEMUI, propertyName);
if (TextUtils.isEmpty(value)) {
return defaultValue;
}
if ("true".equals(value)) {
return true;
}
if ("false".equals(value)) {
return false;
}
// For invalid configs we return the default value.
return defaultValue;
}
/** Returns whether smart replies in notifications are enabled. | SmartReplyConstants::isEnabled | java | Reginer/aosp-android-jar | android-34/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java | MIT |
public boolean requiresTargetingP() {
return mRequiresTargetingP;
} |
Returns whether smart replies in notifications should be disabled when the app targets a
version of Android older than P.
| SmartReplyConstants::requiresTargetingP | java | Reginer/aosp-android-jar | android-34/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java | MIT |
public int getMaxSqueezeRemeasureAttempts() {
return mMaxSqueezeRemeasureAttempts;
} |
Returns the maximum number of times {@link SmartReplyView#onMeasure(int, int)} will try to
find a better (narrower) line-break for a double-line smart reply button.
| SmartReplyConstants::getMaxSqueezeRemeasureAttempts | java | Reginer/aosp-android-jar | android-34/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java | MIT |
public boolean getEffectiveEditChoicesBeforeSending(
@RemoteInput.EditChoicesBeforeSending int remoteInputEditChoicesBeforeSending) {
switch (remoteInputEditChoicesBeforeSending) {
case RemoteInput.EDIT_CHOICES_BEFORE_SENDING_DISABLED:
return false;
case RemoteInput.EDIT_CHOICES_BEFORE_SENDING_ENABLED:
return true;
case RemoteInput.EDIT_CHOICES_BEFORE_SENDING_AUTO:
default:
return mEditChoicesBeforeSending;
}
} |
Returns whether by tapping on a choice should let the user edit the input before it
is sent to the app.
@param remoteInputEditChoicesBeforeSending The value from
{@link RemoteInput#getEditChoicesBeforeSending()}
| SmartReplyConstants::getEffectiveEditChoicesBeforeSending | java | Reginer/aosp-android-jar | android-34/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java | MIT |
public boolean getShowInHeadsUp() {
return mShowInHeadsUp;
} |
Returns whether smart suggestions should be enabled in heads-up notifications.
| SmartReplyConstants::getShowInHeadsUp | java | Reginer/aosp-android-jar | android-34/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java | MIT |
public int getMinNumSystemGeneratedReplies() {
return mMinNumSystemGeneratedReplies;
} |
Returns the minimum number of system generated replies to show in a notification.
If we cannot show at least this many system generated replies we should show none.
| SmartReplyConstants::getMinNumSystemGeneratedReplies | java | Reginer/aosp-android-jar | android-34/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java | MIT |
public int getMaxNumActions() {
return mMaxNumActions;
} |
Returns the maximum number smart actions to show in a notification, or -1 if there shouldn't
be a limit.
| SmartReplyConstants::getMaxNumActions | java | Reginer/aosp-android-jar | android-34/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java | MIT |
public long getOnClickInitDelay() {
return mOnClickInitDelay;
} |
Returns the amount of time (ms) before smart suggestions are clickable, since the suggestions
were added.
| SmartReplyConstants::getOnClickInitDelay | java | Reginer/aosp-android-jar | android-34/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java | MIT |
public Light(int id, int ordinal, int type) {
this(id, "Light", ordinal, type, 0);
} |
Creates a new light with the given data.
@hide
| Light::Light | java | Reginer/aosp-android-jar | android-32/src/android/hardware/lights/Light.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/hardware/lights/Light.java | MIT |
public Light(int id, String name, int ordinal, int type, int capabilities) {
mId = id;
mName = name;
mOrdinal = ordinal;
mType = type;
mCapabilities = capabilities;
} |
Creates a new light with the given data.
@hide
| Light::Light | java | Reginer/aosp-android-jar | android-32/src/android/hardware/lights/Light.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/hardware/lights/Light.java | MIT |
public int getId() {
return mId;
} |
Returns the id of the light.
<p>This is an opaque value used as a unique identifier for the light.
| Light::getId | java | Reginer/aosp-android-jar | android-32/src/android/hardware/lights/Light.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/hardware/lights/Light.java | MIT |
public int getOrdinal() {
return mOrdinal;
} |
Returns the ordinal of the light.
<p>This is a sort key that represents the physical order of lights on the device with the
same type. In the case of multiple lights arranged in a line, for example, the ordinals
could be [1, 2, 3, 4], or [0, 10, 20, 30], or any other values that have the same sort order.
| Light::getOrdinal | java | Reginer/aosp-android-jar | android-32/src/android/hardware/lights/Light.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/hardware/lights/Light.java | MIT |
public @LightType int getType() {
return mType;
} |
Returns the logical type of the light.
| Light::getType | java | Reginer/aosp-android-jar | android-32/src/android/hardware/lights/Light.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/hardware/lights/Light.java | MIT |
public boolean hasBrightnessControl() {
return (mCapabilities & LIGHT_CAPABILITY_BRIGHTNESS) == LIGHT_CAPABILITY_BRIGHTNESS;
} |
Check whether the light has led brightness control.
@return True if the hardware can control the led brightness, otherwise false.
| Light::hasBrightnessControl | java | Reginer/aosp-android-jar | android-32/src/android/hardware/lights/Light.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/hardware/lights/Light.java | MIT |
public boolean hasRgbControl() {
return (mCapabilities & LIGHT_CAPABILITY_RGB) == LIGHT_CAPABILITY_RGB;
} |
Check whether the light has RGB led control.
@return True if the hardware can control the RGB led, otherwise false.
| Light::hasRgbControl | java | Reginer/aosp-android-jar | android-32/src/android/hardware/lights/Light.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/hardware/lights/Light.java | MIT |
public static int addAuthToken(@NonNull HardwareAuthToken authToken) {
try {
getService().addAuthToken(authToken);
return 0;
} catch (RemoteException | NullPointerException e) {
Log.w(TAG, "Can not connect to keystore", e);
return SYSTEM_ERROR;
} catch (ServiceSpecificException e) {
return e.errorCode;
}
} |
Adds an auth token to keystore2.
@param authToken created by Android authenticators.
@return 0 if successful or {@code ResponseCode.SYSTEM_ERROR}.
| Authorization::addAuthToken | java | Reginer/aosp-android-jar | android-33/src/android/security/Authorization.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/security/Authorization.java | MIT |
public static int addAuthToken(@NonNull byte[] authToken) {
return addAuthToken(AuthTokenUtils.toHardwareAuthToken(authToken));
} |
Add an auth token to Keystore 2.0 in the legacy serialized auth token format.
@param authToken
@return 0 if successful or a {@code ResponseCode}.
| Authorization::addAuthToken | java | Reginer/aosp-android-jar | android-33/src/android/security/Authorization.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/security/Authorization.java | MIT |
public static int onLockScreenEvent(@NonNull boolean locked, @NonNull int userId,
@Nullable byte[] syntheticPassword, @Nullable long[] unlockingSids) {
try {
if (locked) {
getService().onLockScreenEvent(LockScreenEvent.LOCK, userId, null, unlockingSids);
} else {
getService().onLockScreenEvent(
LockScreenEvent.UNLOCK, userId, syntheticPassword, unlockingSids);
}
return 0;
} catch (RemoteException | NullPointerException e) {
Log.w(TAG, "Can not connect to keystore", e);
return SYSTEM_ERROR;
} catch (ServiceSpecificException e) {
return e.errorCode;
}
} |
Informs keystore2 about lock screen event.
@param locked - whether it is a lock (true) or unlock (false) event
@param syntheticPassword - if it is an unlock event with the password, pass the synthetic
password provided by the LockSettingService
@param unlockingSids - KeyMint secure user IDs that should be permitted to unlock
UNLOCKED_DEVICE_REQUIRED keys.
@return 0 if successful or a {@code ResponseCode}.
| Authorization::onLockScreenEvent | java | Reginer/aosp-android-jar | android-33/src/android/security/Authorization.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/security/Authorization.java | MIT |
public static byte[] newGetNeighborsRequest(int seqNo) {
final int length = StructNlMsgHdr.STRUCT_SIZE + StructNdMsg.STRUCT_SIZE;
final byte[] bytes = new byte[length];
final ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
byteBuffer.order(ByteOrder.nativeOrder());
final StructNlMsgHdr nlmsghdr = new StructNlMsgHdr();
nlmsghdr.nlmsg_len = length;
nlmsghdr.nlmsg_type = NetlinkConstants.RTM_GETNEIGH;
nlmsghdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
nlmsghdr.nlmsg_seq = seqNo;
nlmsghdr.pack(byteBuffer);
final StructNdMsg ndmsg = new StructNdMsg();
ndmsg.pack(byteBuffer);
return bytes;
} |
A convenience method to create an RTM_GETNEIGH request message.
| RtNetlinkNeighborMessage::newGetNeighborsRequest | java | Reginer/aosp-android-jar | android-33/src/com/android/net/module/util/netlink/RtNetlinkNeighborMessage.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/net/module/util/netlink/RtNetlinkNeighborMessage.java | MIT |
public static byte[] newNewNeighborMessage(
int seqNo, InetAddress ip, short nudState, int ifIndex, byte[] llAddr) {
final StructNlMsgHdr nlmsghdr = new StructNlMsgHdr();
nlmsghdr.nlmsg_type = NetlinkConstants.RTM_NEWNEIGH;
nlmsghdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_REPLACE;
nlmsghdr.nlmsg_seq = seqNo;
final RtNetlinkNeighborMessage msg = new RtNetlinkNeighborMessage(nlmsghdr);
msg.mNdmsg = new StructNdMsg();
msg.mNdmsg.ndm_family =
(byte) ((ip instanceof Inet6Address) ? OsConstants.AF_INET6 : OsConstants.AF_INET);
msg.mNdmsg.ndm_ifindex = ifIndex;
msg.mNdmsg.ndm_state = nudState;
msg.mDestination = ip;
msg.mLinkLayerAddr = llAddr; // might be null
final byte[] bytes = new byte[msg.getRequiredSpace()];
nlmsghdr.nlmsg_len = bytes.length;
final ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
byteBuffer.order(ByteOrder.nativeOrder());
msg.pack(byteBuffer);
return bytes;
} |
A convenience method to create an RTM_NEWNEIGH message, to modify
the kernel's state information for a specific neighbor.
| RtNetlinkNeighborMessage::newNewNeighborMessage | java | Reginer/aosp-android-jar | android-33/src/com/android/net/module/util/netlink/RtNetlinkNeighborMessage.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/net/module/util/netlink/RtNetlinkNeighborMessage.java | MIT |
public void pack(ByteBuffer byteBuffer) {
getHeader().pack(byteBuffer);
mNdmsg.pack(byteBuffer);
if (mDestination != null) {
packNlAttr(NDA_DST, mDestination.getAddress(), byteBuffer);
}
if (mLinkLayerAddr != null) {
packNlAttr(NDA_LLADDR, mLinkLayerAddr, byteBuffer);
}
} |
Write a neighbor discovery netlink message to {@link ByteBuffer}.
| RtNetlinkNeighborMessage::pack | java | Reginer/aosp-android-jar | android-33/src/com/android/net/module/util/netlink/RtNetlinkNeighborMessage.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/net/module/util/netlink/RtNetlinkNeighborMessage.java | MIT |
public Builder setConfigureAutoDetectionEnabledCapability(@CapabilityState int value) {
this.mConfigureAutoDetectionEnabledCapability = value;
return this;
} |
A builder of {@link TimeCapabilities} objects.
@hide
public static class Builder {
@NonNull private final UserHandle mUserHandle;
private @CapabilityState int mConfigureAutoDetectionEnabledCapability;
private @CapabilityState int mSetManualTimeCapability;
public Builder(@NonNull UserHandle userHandle) {
this.mUserHandle = Objects.requireNonNull(userHandle);
}
public Builder(@NonNull TimeCapabilities timeCapabilities) {
Objects.requireNonNull(timeCapabilities);
this.mUserHandle = timeCapabilities.mUserHandle;
this.mConfigureAutoDetectionEnabledCapability =
timeCapabilities.mConfigureAutoDetectionEnabledCapability;
this.mSetManualTimeCapability = timeCapabilities.mSetManualTimeCapability;
}
/** Sets the value for the "configure automatic time detection" capability. | Builder::setConfigureAutoDetectionEnabledCapability | java | Reginer/aosp-android-jar | android-35/src/android/app/time/TimeCapabilities.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/app/time/TimeCapabilities.java | MIT |
public Builder setSetManualTimeCapability(@CapabilityState int value) {
this.mSetManualTimeCapability = value;
return this;
} |
A builder of {@link TimeCapabilities} objects.
@hide
public static class Builder {
@NonNull private final UserHandle mUserHandle;
private @CapabilityState int mConfigureAutoDetectionEnabledCapability;
private @CapabilityState int mSetManualTimeCapability;
public Builder(@NonNull UserHandle userHandle) {
this.mUserHandle = Objects.requireNonNull(userHandle);
}
public Builder(@NonNull TimeCapabilities timeCapabilities) {
Objects.requireNonNull(timeCapabilities);
this.mUserHandle = timeCapabilities.mUserHandle;
this.mConfigureAutoDetectionEnabledCapability =
timeCapabilities.mConfigureAutoDetectionEnabledCapability;
this.mSetManualTimeCapability = timeCapabilities.mSetManualTimeCapability;
}
/** Sets the value for the "configure automatic time detection" capability.
public Builder setConfigureAutoDetectionEnabledCapability(@CapabilityState int value) {
this.mConfigureAutoDetectionEnabledCapability = value;
return this;
}
/** Sets the value for the "set manual time" capability. | Builder::setSetManualTimeCapability | java | Reginer/aosp-android-jar | android-35/src/android/app/time/TimeCapabilities.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/app/time/TimeCapabilities.java | MIT |
public TimeCapabilities build() {
verifyCapabilitySet(mConfigureAutoDetectionEnabledCapability,
"configureAutoDetectionEnabledCapability");
verifyCapabilitySet(mSetManualTimeCapability, "mSetManualTimeCapability");
return new TimeCapabilities(this);
} |
A builder of {@link TimeCapabilities} objects.
@hide
public static class Builder {
@NonNull private final UserHandle mUserHandle;
private @CapabilityState int mConfigureAutoDetectionEnabledCapability;
private @CapabilityState int mSetManualTimeCapability;
public Builder(@NonNull UserHandle userHandle) {
this.mUserHandle = Objects.requireNonNull(userHandle);
}
public Builder(@NonNull TimeCapabilities timeCapabilities) {
Objects.requireNonNull(timeCapabilities);
this.mUserHandle = timeCapabilities.mUserHandle;
this.mConfigureAutoDetectionEnabledCapability =
timeCapabilities.mConfigureAutoDetectionEnabledCapability;
this.mSetManualTimeCapability = timeCapabilities.mSetManualTimeCapability;
}
/** Sets the value for the "configure automatic time detection" capability.
public Builder setConfigureAutoDetectionEnabledCapability(@CapabilityState int value) {
this.mConfigureAutoDetectionEnabledCapability = value;
return this;
}
/** Sets the value for the "set manual time" capability.
public Builder setSetManualTimeCapability(@CapabilityState int value) {
this.mSetManualTimeCapability = value;
return this;
}
/** Returns the {@link TimeCapabilities}. | Builder::build | java | Reginer/aosp-android-jar | android-35/src/android/app/time/TimeCapabilities.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/app/time/TimeCapabilities.java | MIT |
List<ResolveInfo> queryIntentActivities(@NonNull Intent intent) {
return mPackageManager.queryIntentActivitiesAsUser(intent, PackageManager.GET_META_DATA,
mUser.getIdentifier());
} |
Get all activities that can handle the device/accessory attached intent.
@param intent The intent to handle
@return The resolve infos of the activities that can handle the intent
| getSimpleName::queryIntentActivities | java | Reginer/aosp-android-jar | android-32/src/com/android/server/usb/UsbUserSettingsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/usb/UsbUserSettingsManager.java | MIT |
boolean canBeDefault(@NonNull UsbDevice device, String packageName) {
ActivityInfo[] activities = getPackageActivities(packageName);
if (activities != null) {
int numActivities = activities.length;
for (int i = 0; i < numActivities; i++) {
ActivityInfo activityInfo = activities[i];
try (XmlResourceParser parser = activityInfo.loadXmlMetaData(mPackageManager,
UsbManager.ACTION_USB_DEVICE_ATTACHED)) {
if (parser == null) {
continue;
}
XmlUtils.nextElement(parser);
while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
if ("usb-device".equals(parser.getName())) {
DeviceFilter filter = DeviceFilter.read(parser);
if (filter.matches(device)) {
return true;
}
}
XmlUtils.nextElement(parser);
}
} catch (Exception e) {
Slog.w(TAG, "Unable to load component info " + activityInfo.toString(), e);
}
}
}
return false;
} |
Can the app be the default for the USB device. I.e. can the app be launched by default if
the device is plugged in.
@param device The device the app would be default for
@param packageName The package name of the app
@return {@code true} if the app can be default
| getSimpleName::canBeDefault | java | Reginer/aosp-android-jar | android-32/src/com/android/server/usb/UsbUserSettingsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/usb/UsbUserSettingsManager.java | MIT |
boolean canBeDefault(@NonNull UsbAccessory accessory, String packageName) {
ActivityInfo[] activities = getPackageActivities(packageName);
if (activities != null) {
int numActivities = activities.length;
for (int i = 0; i < numActivities; i++) {
ActivityInfo activityInfo = activities[i];
try (XmlResourceParser parser = activityInfo.loadXmlMetaData(mPackageManager,
UsbManager.ACTION_USB_ACCESSORY_ATTACHED)) {
if (parser == null) {
continue;
}
XmlUtils.nextElement(parser);
while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
if ("usb-accessory".equals(parser.getName())) {
AccessoryFilter filter = AccessoryFilter.read(parser);
if (filter.matches(accessory)) {
return true;
}
}
XmlUtils.nextElement(parser);
}
} catch (Exception e) {
Slog.w(TAG, "Unable to load component info " + activityInfo.toString(), e);
}
}
}
return false;
} |
Can the app be the default for the USB accessory. I.e. can the app be launched by default if
the accessory is plugged in.
@param accessory The accessory the app would be default for
@param packageName The package name of the app
@return {@code true} if the app can be default
| getSimpleName::canBeDefault | java | Reginer/aosp-android-jar | android-32/src/com/android/server/usb/UsbUserSettingsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/usb/UsbUserSettingsManager.java | MIT |
protected void assertState(Phaser phaser,
int phase, int parties, int unarrived) {
assertEquals(phase, phaser.getPhase());
assertEquals(parties, phaser.getRegisteredParties());
assertEquals(unarrived, phaser.getUnarrivedParties());
assertEquals(parties - unarrived, phaser.getArrivedParties());
assertFalse(phaser.isTerminated());
} | /*
Written by Doug Lea with assistance from members of JCP JSR-166
Expert Group and released to the public domain, as explained at
http://creativecommons.org/publicdomain/zero/1.0/
Other contributors include John Vint
package jsr166;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Phaser;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import junit.framework.Test;
import junit.framework.TestSuite;
public class PhaserTest extends JSR166TestCase {
// android-note: Removed because the CTS runner does a bad job of
// retrying tests that have suite() declarations.
//
// public static void main(String[] args) {
// main(suite(), args);
// }
// public static Test suite() {
// return new TestSuite(PhaserTest.class);
// }
private static final int maxParties = 65535;
/** Checks state of unterminated phaser. | PhaserTest::assertState | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
protected void assertTerminated(Phaser phaser, int maxPhase, int parties) {
assertTrue(phaser.isTerminated());
int expectedPhase = maxPhase + Integer.MIN_VALUE;
assertEquals(expectedPhase, phaser.getPhase());
assertEquals(parties, phaser.getRegisteredParties());
assertEquals(expectedPhase, phaser.register());
assertEquals(expectedPhase, phaser.arrive());
assertEquals(expectedPhase, phaser.arriveAndDeregister());
} | /*
Written by Doug Lea with assistance from members of JCP JSR-166
Expert Group and released to the public domain, as explained at
http://creativecommons.org/publicdomain/zero/1.0/
Other contributors include John Vint
package jsr166;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Phaser;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import junit.framework.Test;
import junit.framework.TestSuite;
public class PhaserTest extends JSR166TestCase {
// android-note: Removed because the CTS runner does a bad job of
// retrying tests that have suite() declarations.
//
// public static void main(String[] args) {
// main(suite(), args);
// }
// public static Test suite() {
// return new TestSuite(PhaserTest.class);
// }
private static final int maxParties = 65535;
/** Checks state of unterminated phaser.
protected void assertState(Phaser phaser,
int phase, int parties, int unarrived) {
assertEquals(phase, phaser.getPhase());
assertEquals(parties, phaser.getRegisteredParties());
assertEquals(unarrived, phaser.getUnarrivedParties());
assertEquals(parties - unarrived, phaser.getArrivedParties());
assertFalse(phaser.isTerminated());
}
/** Checks state of terminated phaser. | PhaserTest::assertTerminated | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testConstructorDefaultValues() {
Phaser phaser = new Phaser();
assertNull(phaser.getParent());
assertEquals(0, phaser.getRegisteredParties());
assertEquals(0, phaser.getArrivedParties());
assertEquals(0, phaser.getUnarrivedParties());
assertEquals(0, phaser.getPhase());
} |
Empty constructor builds a new Phaser with no parent, no registered
parties and initial phase number of 0
| PhaserTest::testConstructorDefaultValues | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testConstructorNegativeParties() {
try {
new Phaser(-1);
shouldThrow();
} catch (IllegalArgumentException success) {}
} |
Constructing with a negative number of parties throws
IllegalArgumentException
| PhaserTest::testConstructorNegativeParties | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testConstructorNegativeParties2() {
try {
new Phaser(new Phaser(), -1);
shouldThrow();
} catch (IllegalArgumentException success) {}
} |
Constructing with a negative number of parties throws
IllegalArgumentException
| PhaserTest::testConstructorNegativeParties2 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testConstructorPartiesExceedsLimit() {
new Phaser(maxParties);
try {
new Phaser(maxParties + 1);
shouldThrow();
} catch (IllegalArgumentException success) {}
new Phaser(new Phaser(), maxParties);
try {
new Phaser(new Phaser(), maxParties + 1);
shouldThrow();
} catch (IllegalArgumentException success) {}
} |
Constructing with a number of parties > 65535 throws
IllegalArgumentException
| PhaserTest::testConstructorPartiesExceedsLimit | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testConstructor3() {
Phaser parent = new Phaser();
assertSame(parent, new Phaser(parent).getParent());
assertNull(new Phaser(null).getParent());
} |
The parent provided to the constructor should be returned from
a later call to getParent
| PhaserTest::testConstructor3 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testConstructor5() {
Phaser parent = new Phaser();
assertSame(parent, new Phaser(parent, 0).getParent());
assertNull(new Phaser(null, 0).getParent());
} |
The parent being input into the parameter should equal the original
parent when being returned
| PhaserTest::testConstructor5 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testRegister1() {
Phaser phaser = new Phaser();
assertState(phaser, 0, 0, 0);
assertEquals(0, phaser.register());
assertState(phaser, 0, 1, 1);
} |
register() will increment the number of unarrived parties by
one and not affect its arrived parties
| PhaserTest::testRegister1 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testRegister2() {
Phaser phaser = new Phaser(0);
assertState(phaser, 0, 0, 0);
assertEquals(0, phaser.bulkRegister(maxParties - 10));
assertState(phaser, 0, maxParties - 10, maxParties - 10);
for (int i = 0; i < 10; i++) {
assertState(phaser, 0, maxParties - 10 + i, maxParties - 10 + i);
assertEquals(0, phaser.register());
}
assertState(phaser, 0, maxParties, maxParties);
try {
phaser.register();
shouldThrow();
} catch (IllegalStateException success) {}
try {
phaser.bulkRegister(Integer.MAX_VALUE);
shouldThrow();
} catch (IllegalStateException success) {}
assertEquals(0, phaser.bulkRegister(0));
assertState(phaser, 0, maxParties, maxParties);
} |
Registering more than 65536 parties causes IllegalStateException
| PhaserTest::testRegister2 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testRegister3() {
Phaser phaser = new Phaser();
assertEquals(0, phaser.register());
assertEquals(0, phaser.arrive());
assertEquals(1, phaser.register());
assertState(phaser, 1, 2, 2);
} |
register() correctly returns the current barrier phase number
when invoked
| PhaserTest::testRegister3 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testRegister4() {
Phaser phaser = new Phaser(1);
assertEquals(0, phaser.arrive());
assertEquals(1, phaser.register());
assertEquals(1, phaser.arrive());
assertState(phaser, 1, 2, 1);
} |
register causes the next arrive to not increment the phase
rather retain the phase number
| PhaserTest::testRegister4 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testRegisterEmptySubPhaser() {
Phaser root = new Phaser();
Phaser child1 = new Phaser(root, 1);
Phaser child2 = new Phaser(root, 0);
assertEquals(0, child2.register());
assertState(root, 0, 2, 2);
assertState(child1, 0, 1, 1);
assertState(child2, 0, 1, 1);
assertEquals(0, child2.arriveAndDeregister());
assertState(root, 0, 1, 1);
assertState(child1, 0, 1, 1);
assertState(child2, 0, 0, 0);
assertEquals(0, child2.register());
assertEquals(0, child2.arriveAndDeregister());
assertState(root, 0, 1, 1);
assertState(child1, 0, 1, 1);
assertState(child2, 0, 0, 0);
assertEquals(0, child1.arriveAndDeregister());
assertTerminated(root, 1);
assertTerminated(child1, 1);
assertTerminated(child2, 1);
} |
register on a subphaser that is currently empty succeeds, even
in the presence of another non-empty subphaser
| PhaserTest::testRegisterEmptySubPhaser | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testBulkRegister1() {
try {
new Phaser().bulkRegister(-1);
shouldThrow();
} catch (IllegalArgumentException success) {}
} |
Invoking bulkRegister with a negative parameter throws an
IllegalArgumentException
| PhaserTest::testBulkRegister1 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testBulkRegister2() {
Phaser phaser = new Phaser();
assertEquals(0, phaser.bulkRegister(0));
assertState(phaser, 0, 0, 0);
assertEquals(0, phaser.bulkRegister(20));
assertState(phaser, 0, 20, 20);
} |
bulkRegister should correctly record the number of unarrived
parties with the number of parties being registered
| PhaserTest::testBulkRegister2 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testBulkRegister3() {
assertEquals(0, new Phaser().bulkRegister((1 << 16) - 1));
try {
new Phaser().bulkRegister(1 << 16);
shouldThrow();
} catch (IllegalStateException success) {}
try {
new Phaser(2).bulkRegister((1 << 16) - 2);
shouldThrow();
} catch (IllegalStateException success) {}
} |
Registering with a number of parties greater than or equal to 1<<16
throws IllegalStateException.
| PhaserTest::testBulkRegister3 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testPhaseIncrement1() {
for (int size = 1; size < nine; size++) {
final Phaser phaser = new Phaser(size);
for (int index = 0; index <= (1 << size); index++) {
int phase = phaser.arrive();
assertTrue(index % size == 0 ? (index / size) == phase : index - (phase * size) > 0);
}
}
} |
the phase number increments correctly when tripping the barrier
| PhaserTest::testPhaseIncrement1 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testArrive1() {
Phaser phaser = new Phaser(1);
assertState(phaser, 0, 1, 1);
assertEquals(0, phaser.arrive());
assertState(phaser, 1, 1, 1);
} |
arrive() on a registered phaser increments phase.
| PhaserTest::testArrive1 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testArriveAndDeregister() {
final Phaser phaser = new Phaser(1);
for (int i = 0; i < 10; i++) {
assertState(phaser, 0, 1, 1);
assertEquals(0, phaser.register());
assertState(phaser, 0, 2, 2);
assertEquals(0, phaser.arriveAndDeregister());
assertState(phaser, 0, 1, 1);
}
assertEquals(0, phaser.arriveAndDeregister());
assertTerminated(phaser, 1);
} |
arriveAndDeregister does not wait for others to arrive at barrier
| PhaserTest::testArriveAndDeregister | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testArrive2() {
final Phaser phaser = new Phaser();
assertEquals(0, phaser.register());
List<Thread> threads = new ArrayList<Thread>();
for (int i = 0; i < 10; i++) {
assertEquals(0, phaser.register());
threads.add(newStartedThread(new CheckedRunnable() {
public void realRun() {
assertEquals(0, phaser.arriveAndDeregister());
}}));
}
for (Thread thread : threads)
awaitTermination(thread);
assertState(phaser, 0, 1, 1);
assertEquals(0, phaser.arrive());
assertState(phaser, 1, 1, 1);
} |
arriveAndDeregister does not wait for others to arrive at barrier
| PhaserTest::testArrive2 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testArrive3() {
Phaser phaser = new Phaser(1);
phaser.forceTermination();
assertTerminated(phaser, 0, 1);
assertEquals(0, phaser.getPhase() + Integer.MIN_VALUE);
assertTrue(phaser.arrive() < 0);
assertTrue(phaser.register() < 0);
assertTrue(phaser.arriveAndDeregister() < 0);
assertTrue(phaser.awaitAdvance(1) < 0);
assertTrue(phaser.getPhase() < 0);
} |
arrive() returns a negative number if the Phaser is terminated
| PhaserTest::testArrive3 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testArriveAndDeregister1() {
Phaser phaser = new Phaser();
try {
phaser.arriveAndDeregister();
shouldThrow();
} catch (IllegalStateException success) {}
} |
arriveAndDeregister() throws IllegalStateException if number of
registered or unarrived parties would become negative
| PhaserTest::testArriveAndDeregister1 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testArriveAndDeregister2() {
final Phaser phaser = new Phaser(1);
assertEquals(0, phaser.register());
assertEquals(0, phaser.arrive());
assertState(phaser, 0, 2, 1);
assertEquals(0, phaser.arriveAndDeregister());
assertState(phaser, 1, 1, 1);
} |
arriveAndDeregister reduces the number of arrived parties
| PhaserTest::testArriveAndDeregister2 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testArriveAndDeregister3() {
Phaser parent = new Phaser();
Phaser child = new Phaser(parent);
assertState(child, 0, 0, 0);
assertState(parent, 0, 0, 0);
assertEquals(0, child.register());
assertState(child, 0, 1, 1);
assertState(parent, 0, 1, 1);
assertEquals(0, child.arriveAndDeregister());
assertTerminated(child, 1);
assertTerminated(parent, 1);
} |
arriveAndDeregister arrives at the barrier on a phaser with a parent and
when a deregistration occurs and causes the phaser to have zero parties
its parent will be deregistered as well
| PhaserTest::testArriveAndDeregister3 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testArriveAndDeregister4() {
Phaser parent = new Phaser();
Phaser child = new Phaser(parent);
assertEquals(0, parent.register());
assertEquals(0, child.register());
assertState(child, 0, 1, 1);
assertState(parent, 0, 2, 2);
assertEquals(0, child.arriveAndDeregister());
assertState(child, 0, 0, 0);
assertState(parent, 0, 1, 1);
} |
arriveAndDeregister deregisters one party from its parent when
the number of parties of child is zero after deregistration
| PhaserTest::testArriveAndDeregister4 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testArriveAndDeregister5() {
Phaser root = new Phaser();
Phaser parent = new Phaser(root);
Phaser child = new Phaser(parent);
assertState(root, 0, 0, 0);
assertState(parent, 0, 0, 0);
assertState(child, 0, 0, 0);
assertEquals(0, child.register());
assertState(root, 0, 1, 1);
assertState(parent, 0, 1, 1);
assertState(child, 0, 1, 1);
assertEquals(0, child.arriveAndDeregister());
assertTerminated(child, 1);
assertTerminated(parent, 1);
assertTerminated(root, 1);
} |
arriveAndDeregister deregisters one party from its parent when
the number of parties of root is nonzero after deregistration.
| PhaserTest::testArriveAndDeregister5 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testArriveAndDeregister6() {
final Phaser phaser = new Phaser(2);
Thread t = newStartedThread(new CheckedRunnable() {
public void realRun() {
assertEquals(0, phaser.arrive());
}});
assertEquals(1, phaser.arriveAndAwaitAdvance());
assertState(phaser, 1, 2, 2);
assertEquals(1, phaser.arriveAndDeregister());
assertState(phaser, 1, 1, 1);
assertEquals(1, phaser.arriveAndDeregister());
assertTerminated(phaser, 2);
awaitTermination(t);
} |
arriveAndDeregister returns the phase in which it leaves the
phaser in after deregistration
| PhaserTest::testArriveAndDeregister6 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testAwaitAdvance1() {
final Phaser phaser = new Phaser(1);
assertEquals(0, phaser.arrive());
assertEquals(1, phaser.awaitAdvance(0));
} |
awaitAdvance succeeds upon advance
| PhaserTest::testAwaitAdvance1 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testAwaitAdvance2() {
Phaser phaser = new Phaser();
assertTrue(phaser.awaitAdvance(-1) < 0);
assertState(phaser, 0, 0, 0);
} |
awaitAdvance with a negative parameter will return without affecting the
phaser
| PhaserTest::testAwaitAdvance2 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testAwaitAdvanceInterruptibly_interruptible() throws InterruptedException {
final Phaser phaser = new Phaser(1);
final CountDownLatch pleaseInterrupt = new CountDownLatch(2);
Thread t1 = newStartedThread(new CheckedRunnable() {
public void realRun() {
Thread.currentThread().interrupt();
try {
phaser.awaitAdvanceInterruptibly(0);
shouldThrow();
} catch (InterruptedException success) {}
assertFalse(Thread.interrupted());
pleaseInterrupt.countDown();
try {
phaser.awaitAdvanceInterruptibly(0);
shouldThrow();
} catch (InterruptedException success) {}
assertFalse(Thread.interrupted());
}});
Thread t2 = newStartedThread(new CheckedRunnable() {
public void realRun() throws TimeoutException {
Thread.currentThread().interrupt();
try {
phaser.awaitAdvanceInterruptibly(0, 2*LONG_DELAY_MS, MILLISECONDS);
shouldThrow();
} catch (InterruptedException success) {}
assertFalse(Thread.interrupted());
pleaseInterrupt.countDown();
try {
phaser.awaitAdvanceInterruptibly(0, 2*LONG_DELAY_MS, MILLISECONDS);
shouldThrow();
} catch (InterruptedException success) {}
assertFalse(Thread.interrupted());
}});
await(pleaseInterrupt);
assertState(phaser, 0, 1, 1);
assertThreadsStayAlive(t1, t2);
t1.interrupt();
t2.interrupt();
awaitTermination(t1);
awaitTermination(t2);
assertState(phaser, 0, 1, 1);
assertEquals(0, phaser.arrive());
assertState(phaser, 1, 1, 1);
} |
awaitAdvanceInterruptibly blocks interruptibly
| PhaserTest::testAwaitAdvanceInterruptibly_interruptible | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testAwaitAdvanceAfterInterrupt() {
final Phaser phaser = new Phaser();
assertEquals(0, phaser.register());
final CountDownLatch pleaseArrive = new CountDownLatch(1);
Thread t = newStartedThread(new CheckedRunnable() {
public void realRun() {
Thread.currentThread().interrupt();
assertEquals(0, phaser.register());
assertEquals(0, phaser.arrive());
pleaseArrive.countDown();
assertTrue(Thread.currentThread().isInterrupted());
assertEquals(1, phaser.awaitAdvance(0));
assertTrue(Thread.interrupted());
}});
await(pleaseArrive);
waitForThreadToEnterWaitState(t);
assertEquals(0, phaser.arrive());
awaitTermination(t);
Thread.currentThread().interrupt();
assertEquals(1, phaser.awaitAdvance(0));
assertTrue(Thread.interrupted());
} |
awaitAdvance continues waiting if interrupted before waiting
| PhaserTest::testAwaitAdvanceAfterInterrupt | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testAwaitAdvanceBeforeInterrupt() {
final Phaser phaser = new Phaser();
assertEquals(0, phaser.register());
final CountDownLatch pleaseArrive = new CountDownLatch(1);
Thread t = newStartedThread(new CheckedRunnable() {
public void realRun() {
assertEquals(0, phaser.register());
assertEquals(0, phaser.arrive());
assertFalse(Thread.currentThread().isInterrupted());
pleaseArrive.countDown();
assertEquals(1, phaser.awaitAdvance(0));
assertTrue(Thread.interrupted());
}});
await(pleaseArrive);
waitForThreadToEnterWaitState(t);
t.interrupt();
assertEquals(0, phaser.arrive());
awaitTermination(t);
Thread.currentThread().interrupt();
assertEquals(1, phaser.awaitAdvance(0));
assertTrue(Thread.interrupted());
} |
awaitAdvance continues waiting if interrupted while waiting
| PhaserTest::testAwaitAdvanceBeforeInterrupt | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testArriveAndAwaitAdvanceAfterInterrupt() {
final Phaser phaser = new Phaser();
assertEquals(0, phaser.register());
final CountDownLatch pleaseArrive = new CountDownLatch(1);
Thread t = newStartedThread(new CheckedRunnable() {
public void realRun() {
Thread.currentThread().interrupt();
assertEquals(0, phaser.register());
pleaseArrive.countDown();
assertTrue(Thread.currentThread().isInterrupted());
assertEquals(1, phaser.arriveAndAwaitAdvance());
assertTrue(Thread.interrupted());
}});
await(pleaseArrive);
waitForThreadToEnterWaitState(t);
Thread.currentThread().interrupt();
assertEquals(1, phaser.arriveAndAwaitAdvance());
assertTrue(Thread.interrupted());
awaitTermination(t);
} |
arriveAndAwaitAdvance continues waiting if interrupted before waiting
| PhaserTest::testArriveAndAwaitAdvanceAfterInterrupt | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testArriveAndAwaitAdvanceBeforeInterrupt() {
final Phaser phaser = new Phaser();
assertEquals(0, phaser.register());
final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
Thread t = newStartedThread(new CheckedRunnable() {
public void realRun() {
assertEquals(0, phaser.register());
assertFalse(Thread.currentThread().isInterrupted());
pleaseInterrupt.countDown();
assertEquals(1, phaser.arriveAndAwaitAdvance());
assertTrue(Thread.interrupted());
}});
await(pleaseInterrupt);
waitForThreadToEnterWaitState(t);
t.interrupt();
Thread.currentThread().interrupt();
assertEquals(1, phaser.arriveAndAwaitAdvance());
assertTrue(Thread.interrupted());
awaitTermination(t);
} |
arriveAndAwaitAdvance continues waiting if interrupted while waiting
| PhaserTest::testArriveAndAwaitAdvanceBeforeInterrupt | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testAwaitAdvance4() {
final Phaser phaser = new Phaser(4);
final AtomicInteger count = new AtomicInteger(0);
List<Thread> threads = new ArrayList<Thread>();
for (int i = 0; i < 4; i++)
threads.add(newStartedThread(new CheckedRunnable() {
public void realRun() {
for (int k = 0; k < 3; k++) {
assertEquals(2 * k + 1, phaser.arriveAndAwaitAdvance());
count.incrementAndGet();
assertEquals(2 * k + 1, phaser.arrive());
assertEquals(2 * k + 2, phaser.awaitAdvance(2 * k + 1));
assertEquals(4 * (k + 1), count.get());
}}}));
for (Thread thread : threads)
awaitTermination(thread);
} |
awaitAdvance atomically waits for all parties within the same phase to
complete before continuing
| PhaserTest::testAwaitAdvance4 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testAwaitAdvance5() {
final Phaser phaser = new Phaser(1);
assertEquals(1, phaser.awaitAdvance(phaser.arrive()));
assertEquals(1, phaser.getPhase());
assertEquals(1, phaser.register());
List<Thread> threads = new ArrayList<Thread>();
for (int i = 0; i < 8; i++) {
final CountDownLatch latch = new CountDownLatch(1);
final boolean goesFirst = ((i & 1) == 0);
threads.add(newStartedThread(new CheckedRunnable() {
public void realRun() {
if (goesFirst)
latch.countDown();
else
await(latch);
phaser.arrive();
}}));
if (goesFirst)
await(latch);
else
latch.countDown();
assertEquals(i + 2, phaser.awaitAdvance(phaser.arrive()));
assertEquals(i + 2, phaser.getPhase());
}
for (Thread thread : threads)
awaitTermination(thread);
} |
awaitAdvance returns the current phase
| PhaserTest::testAwaitAdvance5 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testAwaitAdvanceTieredPhaser() throws Exception {
final Phaser parent = new Phaser();
final List<Phaser> zeroPartyChildren = new ArrayList<Phaser>(3);
final List<Phaser> onePartyChildren = new ArrayList<Phaser>(3);
for (int i = 0; i < 3; i++) {
zeroPartyChildren.add(new Phaser(parent, 0));
onePartyChildren.add(new Phaser(parent, 1));
}
final List<Phaser> phasers = new ArrayList<Phaser>();
phasers.addAll(zeroPartyChildren);
phasers.addAll(onePartyChildren);
phasers.add(parent);
for (Phaser phaser : phasers) {
assertEquals(-42, phaser.awaitAdvance(-42));
assertEquals(-42, phaser.awaitAdvanceInterruptibly(-42));
assertEquals(-42, phaser.awaitAdvanceInterruptibly(-42, MEDIUM_DELAY_MS, MILLISECONDS));
}
for (Phaser child : onePartyChildren)
assertEquals(0, child.arrive());
for (Phaser phaser : phasers) {
assertEquals(-42, phaser.awaitAdvance(-42));
assertEquals(-42, phaser.awaitAdvanceInterruptibly(-42));
assertEquals(-42, phaser.awaitAdvanceInterruptibly(-42, MEDIUM_DELAY_MS, MILLISECONDS));
assertEquals(1, phaser.awaitAdvance(0));
assertEquals(1, phaser.awaitAdvanceInterruptibly(0));
assertEquals(1, phaser.awaitAdvanceInterruptibly(0, MEDIUM_DELAY_MS, MILLISECONDS));
}
for (Phaser child : onePartyChildren)
assertEquals(1, child.arrive());
for (Phaser phaser : phasers) {
assertEquals(-42, phaser.awaitAdvance(-42));
assertEquals(-42, phaser.awaitAdvanceInterruptibly(-42));
assertEquals(-42, phaser.awaitAdvanceInterruptibly(-42, MEDIUM_DELAY_MS, MILLISECONDS));
assertEquals(2, phaser.awaitAdvance(0));
assertEquals(2, phaser.awaitAdvanceInterruptibly(0));
assertEquals(2, phaser.awaitAdvanceInterruptibly(0, MEDIUM_DELAY_MS, MILLISECONDS));
assertEquals(2, phaser.awaitAdvance(1));
assertEquals(2, phaser.awaitAdvanceInterruptibly(1));
assertEquals(2, phaser.awaitAdvanceInterruptibly(1, MEDIUM_DELAY_MS, MILLISECONDS));
}
} |
awaitAdvance returns the current phase in child phasers
| PhaserTest::testAwaitAdvanceTieredPhaser | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testAwaitAdvance6() {
final Phaser phaser = new Phaser(3);
final CountDownLatch pleaseForceTermination = new CountDownLatch(2);
final List<Thread> threads = new ArrayList<Thread>();
for (int i = 0; i < 2; i++) {
Runnable r = new CheckedRunnable() {
public void realRun() {
assertEquals(0, phaser.arrive());
pleaseForceTermination.countDown();
assertTrue(phaser.awaitAdvance(0) < 0);
assertTrue(phaser.isTerminated());
assertTrue(phaser.getPhase() < 0);
assertEquals(0, phaser.getPhase() + Integer.MIN_VALUE);
assertEquals(3, phaser.getRegisteredParties());
}};
threads.add(newStartedThread(r));
}
await(pleaseForceTermination);
phaser.forceTermination();
assertTrue(phaser.isTerminated());
assertEquals(0, phaser.getPhase() + Integer.MIN_VALUE);
for (Thread thread : threads)
awaitTermination(thread);
assertEquals(3, phaser.getRegisteredParties());
} |
awaitAdvance returns when the phaser is externally terminated
| PhaserTest::testAwaitAdvance6 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testArriveAndAwaitAdvance1() {
Phaser phaser = new Phaser();
try {
phaser.arriveAndAwaitAdvance();
shouldThrow();
} catch (IllegalStateException success) {}
} |
arriveAndAwaitAdvance throws IllegalStateException with no
unarrived parties
| PhaserTest::testArriveAndAwaitAdvance1 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
public void testArriveAndAwaitAdvance3() {
final Phaser phaser = new Phaser(1);
final int THREADS = 3;
final CountDownLatch pleaseArrive = new CountDownLatch(THREADS);
final List<Thread> threads = new ArrayList<Thread>();
for (int i = 0; i < THREADS; i++)
threads.add(newStartedThread(new CheckedRunnable() {
public void realRun() {
assertEquals(0, phaser.register());
pleaseArrive.countDown();
assertEquals(1, phaser.arriveAndAwaitAdvance());
}}));
await(pleaseArrive);
long startTime = System.nanoTime();
while (phaser.getArrivedParties() < THREADS)
Thread.yield();
assertEquals(THREADS, phaser.getArrivedParties());
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
for (Thread thread : threads)
waitForThreadToEnterWaitState(thread);
for (Thread thread : threads)
assertTrue(thread.isAlive());
assertState(phaser, 0, THREADS + 1, 1);
phaser.arriveAndAwaitAdvance();
for (Thread thread : threads)
awaitTermination(thread);
assertState(phaser, 1, THREADS + 1, THREADS + 1);
} |
arriveAndAwaitAdvance waits for all threads to arrive, the
number of arrived parties is the same number that is accounted
for when the main thread awaitsAdvance
| PhaserTest::testArriveAndAwaitAdvance3 | java | Reginer/aosp-android-jar | android-34/src/jsr166/PhaserTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/jsr166/PhaserTest.java | MIT |
default boolean willRunAnimationOnKeyguard() {
return false;
} |
Whether running this action when we are locked will start an animation on the keyguard.
| willRunAnimationOnKeyguard | java | Reginer/aosp-android-jar | android-32/src/com/android/systemui/plugins/ActivityStarter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/systemui/plugins/ActivityStarter.java | MIT |
public UnknownHostException(String message) {
super(message);
} |
Constructs a new {@code UnknownHostException} with the
specified detail message.
@param message the detail message.
| UnknownHostException::UnknownHostException | java | Reginer/aosp-android-jar | android-35/src/java/net/UnknownHostException.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/UnknownHostException.java | MIT |
public UnknownHostException() {
} |
Constructs a new {@code UnknownHostException} with no detail
message.
| UnknownHostException::UnknownHostException | java | Reginer/aosp-android-jar | android-35/src/java/net/UnknownHostException.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/UnknownHostException.java | MIT |
PendingGetCredentialHandle(
@NonNull CredentialManager.GetCredentialTransportPendingUseCase transport,
@Nullable PendingIntent pendingIntent) {
mGetCredentialTransport = transport;
mPendingIntent = pendingIntent;
} |
The pending intent to be launched to finalize the user credential. If null, the callback
will fail with {@link GetCredentialException#TYPE_NO_CREDENTIAL}.
@Nullable
private final PendingIntent mPendingIntent;
/** @hide | PendingGetCredentialHandle::PendingGetCredentialHandle | java | Reginer/aosp-android-jar | android-35/src/android/credentials/PrepareGetCredentialResponse.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/credentials/PrepareGetCredentialResponse.java | MIT |
void show(@NonNull Context context, @Nullable CancellationSignal cancellationSignal,
@CallbackExecutor @NonNull Executor executor,
@NonNull OutcomeReceiver<GetCredentialResponse, GetCredentialException> callback) {
if (mPendingIntent == null) {
executor.execute(() -> callback.onError(
new GetCredentialException(GetCredentialException.TYPE_NO_CREDENTIAL)));
return;
}
mGetCredentialTransport.setCallback(new GetPendingCredentialInternalCallback() {
@Override
public void onPendingIntent(PendingIntent pendingIntent) {
try {
context.startIntentSender(pendingIntent.getIntentSender(), null, 0, 0, 0,
OPTIONS_SENDER_BAL_OPTIN);
} catch (IntentSender.SendIntentException e) {
Log.e(TAG, "startIntentSender() failed for intent for show()", e);
executor.execute(() -> callback.onError(
new GetCredentialException(GetCredentialException.TYPE_UNKNOWN)));
}
}
@Override
public void onResponse(GetCredentialResponse response) {
executor.execute(() -> callback.onResult(response));
}
@Override
public void onError(String errorType, String message) {
executor.execute(
() -> callback.onError(new GetCredentialException(errorType, message)));
}
});
try {
context.startIntentSender(mPendingIntent.getIntentSender(), null, 0, 0, 0,
OPTIONS_SENDER_BAL_OPTIN);
} catch (IntentSender.SendIntentException e) {
Log.e(TAG, "startIntentSender() failed for intent for show()", e);
executor.execute(() -> callback.onError(
new GetCredentialException(GetCredentialException.TYPE_UNKNOWN)));
}
} |
The pending intent to be launched to finalize the user credential. If null, the callback
will fail with {@link GetCredentialException#TYPE_NO_CREDENTIAL}.
@Nullable
private final PendingIntent mPendingIntent;
/** @hide
PendingGetCredentialHandle(
@NonNull CredentialManager.GetCredentialTransportPendingUseCase transport,
@Nullable PendingIntent pendingIntent) {
mGetCredentialTransport = transport;
mPendingIntent = pendingIntent;
}
/** @hide | PendingGetCredentialHandle::show | java | Reginer/aosp-android-jar | android-35/src/android/credentials/PrepareGetCredentialResponse.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/credentials/PrepareGetCredentialResponse.java | MIT |
protected PrepareGetCredentialResponse(
@NonNull PrepareGetCredentialResponseInternal responseInternal,
@NonNull CredentialManager.GetCredentialTransportPendingUseCase
getCredentialTransport) {
mResponseInternal = responseInternal;
mPendingGetCredentialHandle = new PendingGetCredentialHandle(
getCredentialTransport, responseInternal.getPendingIntent());
} |
Constructs a {@link PrepareGetCredentialResponse}.
@param responseInternal whether caller has the permission to query the credential
result metadata
@param getCredentialTransport the transport for the operation to finalaze a credential
@hide
| PendingGetCredentialHandle::PrepareGetCredentialResponse | java | Reginer/aosp-android-jar | android-35/src/android/credentials/PrepareGetCredentialResponse.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/credentials/PrepareGetCredentialResponse.java | MIT |
public Engine() {
this(SystemClock::elapsedRealtime, Handler.getMain());
} |
Default constructor
| WallpaperInputEventReceiver::Engine | java | Reginer/aosp-android-jar | android-35/src/android/service/wallpaper/WallpaperService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/service/wallpaper/WallpaperService.java | MIT |
public SurfaceHolder getSurfaceHolder() {
return mSurfaceHolder;
} |
Provides access to the surface in which this wallpaper is drawn.
| WallpaperInputEventReceiver::getSurfaceHolder | java | Reginer/aosp-android-jar | android-35/src/android/service/wallpaper/WallpaperService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/service/wallpaper/WallpaperService.java | MIT |
@SetWallpaperFlags public int getWallpaperFlags() {
return mIWallpaperEngine.mWhich;
} |
Returns the current wallpaper flags indicating which screen this Engine is rendering to.
| WallpaperInputEventReceiver::getWallpaperFlags | java | Reginer/aosp-android-jar | android-35/src/android/service/wallpaper/WallpaperService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/service/wallpaper/WallpaperService.java | MIT |
public int getDesiredMinimumWidth() {
return mIWallpaperEngine.mReqWidth;
} |
Convenience for {@link WallpaperManager#getDesiredMinimumWidth()
WallpaperManager.getDesiredMinimumWidth()}, returning the width
that the system would like this wallpaper to run in.
| WallpaperInputEventReceiver::getDesiredMinimumWidth | java | Reginer/aosp-android-jar | android-35/src/android/service/wallpaper/WallpaperService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/service/wallpaper/WallpaperService.java | MIT |
public int getDesiredMinimumHeight() {
return mIWallpaperEngine.mReqHeight;
} |
Convenience for {@link WallpaperManager#getDesiredMinimumHeight()
WallpaperManager.getDesiredMinimumHeight()}, returning the height
that the system would like this wallpaper to run in.
| WallpaperInputEventReceiver::getDesiredMinimumHeight | java | Reginer/aosp-android-jar | android-35/src/android/service/wallpaper/WallpaperService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/service/wallpaper/WallpaperService.java | MIT |
public boolean isVisible() {
return mReportedVisible;
} |
Return whether the wallpaper is currently visible to the user,
this is the last value supplied to
{@link #onVisibilityChanged(boolean)}.
| WallpaperInputEventReceiver::isVisible | java | Reginer/aosp-android-jar | android-35/src/android/service/wallpaper/WallpaperService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/service/wallpaper/WallpaperService.java | MIT |
public boolean supportsLocalColorExtraction() {
return false;
} |
Return whether the wallpaper is capable of extracting local colors in a rectangle area,
Must implement without calling super:
{@link #addLocalColorsAreas(List)}
{@link #removeLocalColorsAreas(List)}
When local colors change, call {@link #notifyLocalColorsChanged(List, List)}
See {@link com.android.systemui.wallpapers.ImageWallpaper} for an example
@hide
| WallpaperInputEventReceiver::supportsLocalColorExtraction | java | Reginer/aosp-android-jar | android-35/src/android/service/wallpaper/WallpaperService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/service/wallpaper/WallpaperService.java | MIT |
public boolean isPreview() {
return mIWallpaperEngine.mIsPreview;
} |
Returns true if this engine is running in preview mode -- that is,
it is being shown to the user before they select it as the actual
wallpaper.
| WallpaperInputEventReceiver::isPreview | java | Reginer/aosp-android-jar | android-35/src/android/service/wallpaper/WallpaperService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/service/wallpaper/WallpaperService.java | MIT |
public boolean shouldZoomOutWallpaper() {
return mIsWearOs && !CompatChanges.isChangeEnabled(WEAROS_WALLPAPER_HANDLES_SCALING);
} |
This will be called when the wallpaper is first started. If true is returned, the system
will zoom in the wallpaper by default and zoom it out as the user interacts,
to create depth. Otherwise, zoom will have to be handled manually
in {@link #onZoomChanged(float)}.
@hide
| WallpaperInputEventReceiver::shouldZoomOutWallpaper | java | Reginer/aosp-android-jar | android-35/src/android/service/wallpaper/WallpaperService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/service/wallpaper/WallpaperService.java | MIT |
public boolean shouldWaitForEngineShown() {
return false;
} |
This will be called in the end of {@link #updateSurface(boolean, boolean, boolean)}.
If true is returned, the engine will not report shown until rendering finished is
reported. Otherwise, the engine will report shown immediately right after redraw phase
in {@link #updateSurface(boolean, boolean, boolean)}.
@hide
| WallpaperInputEventReceiver::shouldWaitForEngineShown | java | Reginer/aosp-android-jar | android-35/src/android/service/wallpaper/WallpaperService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/service/wallpaper/WallpaperService.java | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.