_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q165200
FileDownloadUtils.isAcceptRange
validation
public static boolean isAcceptRange(int responseCode, FileDownloadConnection connection) { if (responseCode == HttpURLConnection.HTTP_PARTIAL || responseCode == FileDownloadConnection.RESPONSE_CODE_FROM_OFFSET) return true; final String acceptRanges = connection.getResponseHeaderField("Accept-Ranges"); return "bytes".equals(acceptRanges); }
java
{ "resource": "" }
q165201
FileDownloadUtils.findInstanceLengthForTrial
validation
public static long findInstanceLengthForTrial(FileDownloadConnection connection) { long length = findInstanceLengthFromContentRange(connection); if (length < 0) { length = TOTAL_VALUE_IN_CHUNKED_RESOURCE; FileDownloadLog.w(FileDownloadUtils.class, "don't get instance length from" + "Content-Range header"); } // the response of HEAD method is not very canonical sometimes(it depends on server // implementation) // so that it's uncertain the content-length is the same as the response of GET method if // content-length=0, so we have to filter this case in here. if (length == 0 && FileDownloadProperties.getImpl().trialConnectionHeadMethod) { length = TOTAL_VALUE_IN_CHUNKED_RESOURCE; } return length; }
java
{ "resource": "" }
q165202
FloatingActionMenu.setAnimated
validation
public void setAnimated(boolean animated) { mIsAnimated = animated; mOpenAnimatorSet.setDuration(animated ? ANIMATION_DURATION : 0); mCloseAnimatorSet.setDuration(animated ? ANIMATION_DURATION : 0); }
java
{ "resource": "" }
q165203
FloatingActionButton.setElevationCompat
validation
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public void setElevationCompat(float elevation) { mShadowColor = 0x26000000; mShadowRadius = Math.round(elevation / 2); mShadowXOffset = 0; mShadowYOffset = Math.round(mFabSize == SIZE_NORMAL ? elevation : elevation / 2); if (Util.hasLollipop()) { super.setElevation(elevation); mUsingElevationCompat = true; mShowShadow = false; updateBackground(); ViewGroup.LayoutParams layoutParams = getLayoutParams(); if (layoutParams != null) { setLayoutParams(layoutParams); } } else { mShowShadow = true; updateBackground(); } }
java
{ "resource": "" }
q165204
FloatingActionButton.setLabelColors
validation
public void setLabelColors(int colorNormal, int colorPressed, int colorRipple) { Label label = getLabelView(); int left = label.getPaddingLeft(); int top = label.getPaddingTop(); int right = label.getPaddingRight(); int bottom = label.getPaddingBottom(); label.setColors(colorNormal, colorPressed, colorRipple); label.updateBackground(); label.setPadding(left, top, right, bottom); }
java
{ "resource": "" }
q165205
TemplateCommentGenerator.addConfigurationProperties
validation
@Override public void addConfigurationProperties(Properties properties) { suppressDate = isTrue(properties .getProperty(PropertyRegistry.COMMENT_GENERATOR_SUPPRESS_DATE)); suppressAllComments = isTrue(properties .getProperty(PropertyRegistry.COMMENT_GENERATOR_SUPPRESS_ALL_COMMENTS)); }
java
{ "resource": "" }
q165206
TemplateCommentGenerator.addModelClassComment
validation
@Override public void addModelClassComment(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { Map<String, Object> map = new HashMap<>(); map.put("mgb", MergeConstants.NEW_ELEMENT_TAG); map.put("topLevelClass", topLevelClass); map.put("introspectedTable", introspectedTable); // 添加评论 addJavaElementComment(topLevelClass, map, EnumNode.ADD_MODEL_CLASS_COMMENT); }
java
{ "resource": "" }
q165207
TemplateCommentGenerator.addEnumComment
validation
@Override public void addEnumComment(InnerEnum innerEnum, IntrospectedTable introspectedTable) { Map<String, Object> map = new HashMap<>(); map.put("mgb", MergeConstants.NEW_ELEMENT_TAG); map.put("innerEnum", innerEnum); map.put("introspectedTable", introspectedTable); // 添加评论 addJavaElementComment(innerEnum, map, EnumNode.ADD_ENUM_COMMENT); }
java
{ "resource": "" }
q165208
TemplateCommentGenerator.addGetterComment
validation
@Override public void addGetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) { Map<String, Object> map = new HashMap<>(); map.put("mgb", MergeConstants.NEW_ELEMENT_TAG); map.put("method", method); map.put("introspectedTable", introspectedTable); map.put("introspectedColumn", introspectedColumn); // 添加评论 addJavaElementComment(method, map, EnumNode.ADD_GETTER_COMMENT); }
java
{ "resource": "" }
q165209
TemplateCommentGenerator.addGeneralMethodComment
validation
@Override public void addGeneralMethodComment(Method method, IntrospectedTable introspectedTable) { Map<String, Object> map = new HashMap<>(); map.put("mgb", MergeConstants.NEW_ELEMENT_TAG); map.put("method", method); map.put("introspectedTable", introspectedTable); // 添加评论 addJavaElementComment(method, map, EnumNode.ADD_GENERAL_METHOD_COMMENT); }
java
{ "resource": "" }
q165210
TemplateCommentGenerator.addComment
validation
@Override public void addComment(XmlElement xmlElement) { Map<String, Object> map = new HashMap<>(); map.put("mgb", MergeConstants.NEW_ELEMENT_TAG); map.put("xmlElement", xmlElement); // 添加评论 addXmlElementComment(xmlElement, map, EnumNode.ADD_COMMENT); }
java
{ "resource": "" }
q165211
InnerTypeFullyQualifiedJavaType.getFullyQualifiedName
validation
@Override public String getFullyQualifiedName() { String fullyQualifiedName = super.getFullyQualifiedName(); String before = fullyQualifiedName.substring(0, fullyQualifiedName.lastIndexOf(".")); String end = fullyQualifiedName.substring(fullyQualifiedName.lastIndexOf(".")); return before + "." + outerType + end; }
java
{ "resource": "" }
q165212
XmlElementGeneratorTools.getSelectKey
validation
public static Element getSelectKey(IntrospectedColumn introspectedColumn, GeneratedKey generatedKey) { return getSelectKey(introspectedColumn, generatedKey, null); }
java
{ "resource": "" }
q165213
ResourceTableFactory.newFrameworkResourceTable
validation
public PackageResourceTable newFrameworkResourceTable(ResourcePath resourcePath) { return PerfStatsCollector.getInstance() .measure( "load legacy framework resources", () -> { PackageResourceTable resourceTable = new PackageResourceTable("android"); if (resourcePath.getRClass() != null) { addRClassValues(resourceTable, resourcePath.getRClass()); addMissingStyleableAttributes(resourceTable, resourcePath.getRClass()); } if (resourcePath.getInternalRClass() != null) { addRClassValues(resourceTable, resourcePath.getInternalRClass()); addMissingStyleableAttributes(resourceTable, resourcePath.getInternalRClass()); } parseResourceFiles(resourcePath, resourceTable); return resourceTable; }); }
java
{ "resource": "" }
q165214
ResourceTableFactory.newResourceTable
validation
public PackageResourceTable newResourceTable(String packageName, ResourcePath... resourcePaths) { return PerfStatsCollector.getInstance() .measure( "load legacy app resources", () -> { PackageResourceTable resourceTable = new PackageResourceTable(packageName); for (ResourcePath resourcePath : resourcePaths) { if (resourcePath.getRClass() != null) { addRClassValues(resourceTable, resourcePath.getRClass()); } } for (ResourcePath resourcePath : resourcePaths) { parseResourceFiles(resourcePath, resourceTable); } return resourceTable; }); }
java
{ "resource": "" }
q165215
ResourceTableFactory.addMissingStyleableAttributes
validation
private void addMissingStyleableAttributes(PackageResourceTable resourceTable, Class<?> rClass) { for (Class innerClass : rClass.getClasses()) { if (innerClass.getSimpleName().equals("styleable")) { String styleableName = null; // Current styleable name int[] styleableArray = null; // Current styleable value array or references for (Field field : innerClass.getDeclaredFields()) { if (field.getType().equals(int[].class) && Modifier.isStatic(field.getModifiers())) { styleableName = field.getName(); try { styleableArray = (int[]) (field.get(null)); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } else if (field.getType().equals(Integer.TYPE) && Modifier.isStatic(field.getModifiers())) { String attributeName = field.getName().substring(styleableName.length() + 1); try { int styleableIndex = field.getInt(null); int attributeResId = styleableArray[styleableIndex]; resourceTable.addResource(attributeResId, "attr", attributeName); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } } } } }
java
{ "resource": "" }
q165216
ShadowSettings.setWifiOn
validation
public static void setWifiOn(boolean isOn) { Settings.Global.putInt( RuntimeEnvironment.application.getContentResolver(), Settings.Global.WIFI_ON, isOn ? 1 : 0); Settings.System.putInt( RuntimeEnvironment.application.getContentResolver(), Settings.System.WIFI_ON, isOn ? 1 : 0); }
java
{ "resource": "" }
q165217
Qualifiers.addSmallestScreenWidth
validation
@Deprecated public static String addSmallestScreenWidth(String qualifiers, int smallestScreenWidth) { int qualifiersSmallestScreenWidth = Qualifiers.getSmallestScreenWidth(qualifiers); if (qualifiersSmallestScreenWidth == -1) { if (qualifiers.length() > 0) { qualifiers += "-"; } qualifiers += "sw" + smallestScreenWidth + "dp"; } return qualifiers; }
java
{ "resource": "" }
q165218
ClassInstrumentor.instrumentNativeMethod
validation
protected void instrumentNativeMethod(MutableClass mutableClass, MethodNode method) { method.access = method.access & ~Opcodes.ACC_NATIVE; RobolectricGeneratorAdapter generator = new RobolectricGeneratorAdapter(method); Type returnType = generator.getReturnType(); generator.pushDefaultReturnValueToStack(returnType); generator.returnValue(); }
java
{ "resource": "" }
q165219
ClassInstrumentor.rewriteMethodBody
validation
private void rewriteMethodBody(MutableClass mutableClass, MethodNode callingMethod) { ListIterator<AbstractInsnNode> instructions = callingMethod.instructions.iterator(); while (instructions.hasNext()) { AbstractInsnNode node = instructions.next(); switch (node.getOpcode()) { case Opcodes.NEW: TypeInsnNode newInsnNode = (TypeInsnNode) node; newInsnNode.desc = mutableClass.config.mappedTypeName(newInsnNode.desc); break; case Opcodes.GETFIELD: /* falls through */ case Opcodes.PUTFIELD: /* falls through */ case Opcodes.GETSTATIC: /* falls through */ case Opcodes.PUTSTATIC: FieldInsnNode fieldInsnNode = (FieldInsnNode) node; fieldInsnNode.desc = mutableClass.config.mappedTypeName(fieldInsnNode.desc); // todo test break; case Opcodes.INVOKESTATIC: /* falls through */ case Opcodes.INVOKEINTERFACE: /* falls through */ case Opcodes.INVOKESPECIAL: /* falls through */ case Opcodes.INVOKEVIRTUAL: MethodInsnNode targetMethod = (MethodInsnNode) node; targetMethod.desc = mutableClass.config.remapParams(targetMethod.desc); if (isGregorianCalendarBooleanConstructor(targetMethod)) { replaceGregorianCalendarBooleanConstructor(instructions, targetMethod); } else if (mutableClass.config.shouldIntercept(targetMethod)) { interceptInvokeVirtualMethod(mutableClass, instructions, targetMethod); } break; case Opcodes.INVOKEDYNAMIC: /* no unusual behavior */ break; default: break; } } }
java
{ "resource": "" }
q165220
ClassInstrumentor.isGregorianCalendarBooleanConstructor
validation
private boolean isGregorianCalendarBooleanConstructor(MethodInsnNode targetMethod) { return targetMethod.owner.equals("java/util/GregorianCalendar") && targetMethod.name.equals("<init>") && targetMethod.desc.equals("(Z)V"); }
java
{ "resource": "" }
q165221
ClassInstrumentor.makeClassPublic
validation
private void makeClassPublic(ClassNode clazz) { clazz.access = (clazz.access | Opcodes.ACC_PUBLIC) & ~(Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE); }
java
{ "resource": "" }
q165222
ClassInstrumentor.makeMethodPublic
validation
protected void makeMethodPublic(MethodNode method) { method.access = (method.access | Opcodes.ACC_PUBLIC) & ~(Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE); }
java
{ "resource": "" }
q165223
ClassInstrumentor.makeMethodPrivate
validation
protected void makeMethodPrivate(MethodNode method) { method.access = (method.access | Opcodes.ACC_PRIVATE) & ~(Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED); }
java
{ "resource": "" }
q165224
ShadowAccessibilityNodeInfo.setTraversalAfter
validation
public void setTraversalAfter(AccessibilityNodeInfo info) { if (this.traversalAfter != null) { this.traversalAfter.recycle(); } this.traversalAfter = obtain(info); }
java
{ "resource": "" }
q165225
ShadowAccessibilityNodeInfo.setTraversalBefore
validation
public void setTraversalBefore(AccessibilityNodeInfo info) { if (this.traversalBefore != null) { this.traversalBefore.recycle(); } this.traversalBefore = obtain(info); }
java
{ "resource": "" }
q165226
ShadowAccessibilityNodeInfo.addChild
validation
public void addChild(AccessibilityNodeInfo child) { if (children == null) { children = new ArrayList<>(); } children.add(child); ShadowAccessibilityNodeInfo shadowAccessibilityNodeInfo = Shadow.extract(child); shadowAccessibilityNodeInfo.parent = realAccessibilityNodeInfo; }
java
{ "resource": "" }
q165227
RobolectricGeneratorAdapter.pushDefaultReturnValueToStack
validation
public void pushDefaultReturnValueToStack(Type type) { if (type.equals(Type.BOOLEAN_TYPE)) { push(false); } else if (type.equals(Type.INT_TYPE) || type.equals(Type.SHORT_TYPE) || type.equals(Type.BYTE_TYPE) || type.equals(Type.CHAR_TYPE)) { push(0); } else if (type.equals(Type.LONG_TYPE)) { push(0L); } else if (type.equals(Type.FLOAT_TYPE)) { push(0f); } else if (type.equals(Type.DOUBLE_TYPE)) { push(0d); } else if (type.getSort() == ARRAY || type.getSort() == OBJECT) { loadNull(); } }
java
{ "resource": "" }
q165228
OsConstantsValues.getMode
validation
public static int getMode(String path) { if (path == null) { return 0; } File file = new File(path); if (file.isDirectory()) { return S_IFDIR_VALUE; } if (file.isFile()) { return S_IFREG_VALUE; } if (!canonicalize(path).equals(path)) { return S_IFLNK_VALUE; } return 0; }
java
{ "resource": "" }
q165229
ActivityController.setup
validation
public ActivityController<T> setup(Bundle savedInstanceState) { return create(savedInstanceState) .start() .restoreInstanceState(savedInstanceState) .postCreate(savedInstanceState) .resume() .visible(); }
java
{ "resource": "" }
q165230
ActivityController.configurationChange
validation
public ActivityController<T> configurationChange(final Configuration newConfiguration) { final Configuration currentConfig = component.getResources().getConfiguration(); final int changedBits = currentConfig.diff(newConfiguration); currentConfig.setTo(newConfiguration); // TODO: throw on changedBits == 0 since it non-intuitively calls onConfigurationChanged // Can the activity handle itself ALL configuration changes? if ((getActivityInfo(component.getApplication()).configChanges & changedBits) == changedBits) { shadowMainLooper.runPaused(() -> component.onConfigurationChanged(newConfiguration)); return this; } else { @SuppressWarnings("unchecked") final T recreatedActivity = (T) ReflectionHelpers.callConstructor(component.getClass()); final _Activity_ _recreatedActivity_ = reflector(_Activity_.class, recreatedActivity); shadowMainLooper.runPaused( new Runnable() { @Override public void run() { // Set flags ReflectionHelpers.setField( Activity.class, component, "mChangingConfigurations", true); ReflectionHelpers.setField( Activity.class, component, "mConfigChangeFlags", changedBits); // Perform activity destruction final Bundle outState = new Bundle(); // The order of onPause/onStop/onSaveInstanceState is undefined, but is usually: // onPause -> onSaveInstanceState -> onStop _component_.performPause(); _component_.performSaveInstanceState(outState); if (RuntimeEnvironment.getApiLevel() <= M) { _component_.performStop(); } else if (RuntimeEnvironment.getApiLevel() <= O_MR1) { _component_.performStop(true); } else { _component_.performStop(true, "configurationChange"); } // This is the true and complete retained state, including loaders and retained // fragments. final Object nonConfigInstance = _component_.retainNonConfigurationInstances(); // This is the activity's "user" state final Object activityConfigInstance = nonConfigInstance == null ? null // No framework or user state. : reflector(_NonConfigurationInstances_.class, nonConfigInstance) .getActivity(); _component_.performDestroy(); // Restore theme in case it was set in the test manually. // This is not technically what happens but is purely to make this easier to use in // Robolectric. ShadowContextThemeWrapper shadowContextThemeWrapper = Shadow.extract(component); int theme = shadowContextThemeWrapper.callGetThemeResId(); // Setup controller for the new activity attached = false; component = recreatedActivity; _component_ = _recreatedActivity_; // TODO: Pass nonConfigurationInstance here instead of setting // mLastNonConfigurationInstances directly below. This field must be set before // attach. Since current implementation sets it after attach(), initialization is not // done correctly. For instance, fragment marked as retained is not retained. attach(/*lastNonConfigurationInstances=*/ null); if (theme != 0) { recreatedActivity.setTheme(theme); } // Set saved non config instance _recreatedActivity_.setLastNonConfigurationInstances(nonConfigInstance); ShadowActivity shadowActivity = Shadow.extract(recreatedActivity); shadowActivity.setLastNonConfigurationInstance(activityConfigInstance); // Create lifecycle _recreatedActivity_.performCreate(outState); if (RuntimeEnvironment.getApiLevel() <= O_MR1) { _recreatedActivity_.performStart(); } else { _recreatedActivity_.performStart("configurationChange"); } _recreatedActivity_.performRestoreInstanceState(outState); _recreatedActivity_.onPostCreate(outState); if (RuntimeEnvironment.getApiLevel() <= O_MR1) { _recreatedActivity_.performResume(); } else { _recreatedActivity_.performResume(true, "configurationChange"); } _recreatedActivity_.onPostResume(); // TODO: Call visible() too. } }); } return this; }
java
{ "resource": "" }
q165231
ActivityController.recreate
validation
@SuppressWarnings("unchecked") public ActivityController<T> recreate() { Stage originalStage = ActivityLifecycleMonitorRegistry.getInstance().getLifecycleStageOf(component); switch (originalStage) { case PRE_ON_CREATE: create(); // fall through case CREATED: case RESTARTED: start(); postCreate(null); // fall through case STARTED: resume(); // fall through case RESUMED: pause(); // fall through case PAUSED: stop(); // fall through case STOPPED: break; default: throw new IllegalStateException("Cannot recreate activity since it's destroyed already"); } // Activity#mChangingConfigurations flag should be set prior to Activity recreation process // starts. ActivityThread does set it on real device but here we simulate the Activity // recreation process on behalf of ActivityThread so set the flag here. Note we don't need to // reset the flag to false because this Activity instance is going to be destroyed and disposed. // https://android.googlesource.com/platform/frameworks/base/+/55418eada51d4f5e6532ae9517af66c50 // ea495c4/core/java/android/app/ActivityThread.java#4806 ReflectionHelpers.setField(component, "mChangingConfigurations", true); Bundle outState = new Bundle(); saveInstanceState(outState); Object lastNonConfigurationInstances = ReflectionHelpers.callInstanceMethod(component, "retainNonConfigurationInstances"); destroy(); component = (T) ReflectionHelpers.callConstructor(component.getClass()); _component_ = reflector(_Activity_.class, component); attached = false; attach(lastNonConfigurationInstances); create(outState); start(); restoreInstanceState(outState); postCreate(outState); resume(); postResume(); visible(); windowFocusChanged(true); // Move back to the original stage. If the original stage was transient stage, it will bring it // to resumed state to match the on device behavior. switch (originalStage) { case PAUSED: pause(); return this; case STOPPED: pause(); stop(); return this; default: return this; } }
java
{ "resource": "" }
q165232
ShadowTelephonyManager.setCallState
validation
public void setCallState(int callState, String incomingPhoneNumber) { if (callState != CALL_STATE_RINGING) { incomingPhoneNumber = null; } this.callState = callState; this.incomingPhoneNumber = incomingPhoneNumber; for (PhoneStateListener listener : getListenersForFlags(LISTEN_CALL_STATE)) { listener.onCallStateChanged(callState, incomingPhoneNumber); } }
java
{ "resource": "" }
q165233
ExpectedLogMessagesRule.expectLogMessage
validation
public void expectLogMessage(int level, String tag, String message) { checkTag(tag); expectedLogs.add(new LogItem(level, tag, message, null)); }
java
{ "resource": "" }
q165234
ServiceData.isExported
validation
public boolean isExported() { boolean defaultValue = !intentFilters.isEmpty(); return (attributes.containsKey(EXPORTED) ? Boolean.parseBoolean(attributes.get(EXPORTED)) : defaultValue); }
java
{ "resource": "" }
q165235
CachedPathIteratorFactory.getShapeEndPoint
validation
private static void getShapeEndPoint(int type, float[] coords, float[] point) { // start index of the end point for the segment type int pointIndex = (getNumberOfPoints(type) - 1) * 2; point[0] = coords[pointIndex]; point[1] = coords[pointIndex + 1]; }
java
{ "resource": "" }
q165236
CachedPathIteratorFactory.getPointAtLength
validation
private void getPointAtLength( int type, float[] coords, float lastX, float lastY, float t, float[] point) { if (type == PathIterator.SEG_LINETO) { point[0] = lastX + (coords[0] - lastX) * t; point[1] = lastY + (coords[1] - lastY) * t; // Return here, since we do not need a shape to estimate return; } float[] curve = new float[8]; int lastPointIndex = (getNumberOfPoints(type) - 1) * 2; System.arraycopy(coords, 0, curve, 2, coords.length); curve[0] = lastX; curve[1] = lastY; if (type == PathIterator.SEG_CUBICTO) { cubicCurveSegment(curve, 0f, t); } else { quadCurveSegment(curve, 0f, t); } point[0] = curve[2 + lastPointIndex]; point[1] = curve[2 + lastPointIndex + 1]; }
java
{ "resource": "" }
q165237
ResTable_config.createConfig
validation
static ResTable_config createConfig(ByteBuffer buffer) { int startPosition = buffer.position(); // The starting buffer position to calculate bytes read. int size = buffer.getInt(); int mcc = buffer.getShort() & 0xFFFF; int mnc = buffer.getShort() & 0xFFFF; byte[] language = new byte[2]; buffer.get(language); byte[] region = new byte[2]; buffer.get(region); int orientation = UnsignedBytes.toInt(buffer.get()); int touchscreen = UnsignedBytes.toInt(buffer.get()); int density = buffer.getShort() & 0xFFFF; int keyboard = UnsignedBytes.toInt(buffer.get()); int navigation = UnsignedBytes.toInt(buffer.get()); int inputFlags = UnsignedBytes.toInt(buffer.get()); buffer.get(); // 1 byte of padding int screenWidth = buffer.getShort() & 0xFFFF; int screenHeight = buffer.getShort() & 0xFFFF; int sdkVersion = buffer.getShort() & 0xFFFF; int minorVersion = buffer.getShort() & 0xFFFF; // At this point, the configuration's size needs to be taken into account as not all // configurations have all values. int screenLayout = 0; int uiMode = 0; int smallestScreenWidthDp = 0; int screenWidthDp = 0; int screenHeightDp = 0; byte[] localeScript = new byte[4]; byte[] localeVariant = new byte[8]; byte screenLayout2 = 0; byte screenConfigPad1 = 0; short screenConfigPad2 = 0; if (size >= SCREEN_CONFIG_MIN_SIZE) { screenLayout = UnsignedBytes.toInt(buffer.get()); uiMode = UnsignedBytes.toInt(buffer.get()); smallestScreenWidthDp = buffer.getShort() & 0xFFFF; } if (size >= SCREEN_DP_MIN_SIZE) { screenWidthDp = buffer.getShort() & 0xFFFF; screenHeightDp = buffer.getShort() & 0xFFFF; } if (size >= LOCALE_MIN_SIZE) { buffer.get(localeScript); buffer.get(localeVariant); } if (size >= SCREEN_CONFIG_EXTENSION_MIN_SIZE) { screenLayout2 = (byte) UnsignedBytes.toInt(buffer.get()); screenConfigPad1 = buffer.get(); // Reserved padding screenConfigPad2 = buffer.getShort(); // More reserved padding } // After parsing everything that's known, account for anything that's unknown. int bytesRead = buffer.position() - startPosition; byte[] unknown = new byte[size - bytesRead]; buffer.get(unknown); return new ResTable_config(size, mcc, mnc, language, region, orientation, touchscreen, density, keyboard, navigation, inputFlags, screenWidth, screenHeight, sdkVersion, minorVersion, screenLayout, uiMode, smallestScreenWidthDp, screenWidthDp, screenHeightDp, localeScript, localeVariant, screenLayout2, screenConfigPad1, screenConfigPad2, unknown); }
java
{ "resource": "" }
q165238
ResTable_config.diff
validation
int diff(final ResTable_config o) { int diffs = 0; if (mcc != o.mcc) diffs |= CONFIG_MCC; if (mnc != o.mnc) diffs |= CONFIG_MNC; if (orientation != o.orientation) diffs |= CONFIG_ORIENTATION; if (density != o.density) diffs |= CONFIG_DENSITY; if (touchscreen != o.touchscreen) diffs |= CONFIG_TOUCHSCREEN; if (((inputFlags^o.inputFlags)&(MASK_KEYSHIDDEN|MASK_NAVHIDDEN)) != 0) diffs |= CONFIG_KEYBOARD_HIDDEN; if (keyboard != o.keyboard) diffs |= CONFIG_KEYBOARD; if (navigation != o.navigation) diffs |= CONFIG_NAVIGATION; if (screenSize() != o.screenSize()) diffs |= CONFIG_SCREEN_SIZE; if (version() != o.version()) diffs |= CONFIG_VERSION; if ((screenLayout & MASK_LAYOUTDIR) != (o.screenLayout & MASK_LAYOUTDIR)) diffs |= CONFIG_LAYOUTDIR; if ((screenLayout & ~MASK_LAYOUTDIR) != (o.screenLayout & ~MASK_LAYOUTDIR)) diffs |= CONFIG_SCREEN_LAYOUT; if ((screenLayout2 & MASK_SCREENROUND) != (o.screenLayout2 & MASK_SCREENROUND)) diffs |= CONFIG_SCREEN_ROUND; if ((colorMode & MASK_WIDE_COLOR_GAMUT) != (o.colorMode & MASK_WIDE_COLOR_GAMUT)) diffs |= CONFIG_COLOR_MODE; if ((colorMode & MASK_HDR) != (o.colorMode & MASK_HDR)) diffs |= CONFIG_COLOR_MODE; if (uiMode != o.uiMode) diffs |= CONFIG_UI_MODE; if (smallestScreenWidthDp != o.smallestScreenWidthDp) diffs |= CONFIG_SMALLEST_SCREEN_SIZE; if (screenSizeDp() != o.screenSizeDp()) diffs |= CONFIG_SCREEN_SIZE; int diff = compareLocales(this, o); if (isTruthy(diff)) diffs |= CONFIG_LOCALE; return diffs; }
java
{ "resource": "" }
q165239
ResTable_config.isDefault
validation
public final boolean isDefault() { return mcc == 0 && mnc == 0 && isZeroes(language) && isZeroes(country) && orientation == 0 && touchscreen == 0 && density == 0 && keyboard == 0 && navigation == 0 && inputFlags == 0 && screenWidth == 0 && screenHeight == 0 && sdkVersion == 0 && minorVersion == 0 && screenLayout == 0 && uiMode == 0 && smallestScreenWidthDp == 0 && screenWidthDp == 0 && screenHeightDp == 0 && isZeroes(localeScript) && isZeroes(localeVariant) && screenLayout2 == 0 && colorMode == 0 ; }
java
{ "resource": "" }
q165240
ShadowUserManager.getApplicationRestrictions
validation
@Implementation(minSdk = JELLY_BEAN_MR2) protected Bundle getApplicationRestrictions(String packageName) { Bundle bundle = applicationRestrictions.get(packageName); return bundle != null ? bundle : new Bundle(); }
java
{ "resource": "" }
q165241
ShadowUserManager.addUserProfile
validation
public long addUserProfile(UserHandle userHandle) { long serialNumber = nextUserSerial++; userProfiles.put(userHandle, serialNumber); return serialNumber; }
java
{ "resource": "" }
q165242
ShadowUserManager.addUser
validation
public UserHandle addUser(int id, String name, int flags) { UserHandle userHandle = id == UserHandle.USER_SYSTEM ? Process.myUserHandle() : new UserHandle(id); addUserProfile(userHandle); setSerialNumberForUser(userHandle, (long) id); userInfoMap.put(id, new UserInfo(id, name, flags)); userPidMap.put( id, id == UserHandle.USER_SYSTEM ? Process.myUid() : id * UserHandle.PER_USER_RANGE + ShadowProcess.getRandomApplicationUid()); return userHandle; }
java
{ "resource": "" }
q165243
ShadowBluetoothSocket.connect
validation
@Implementation protected void connect() throws IOException { if (state == SocketState.CLOSED) { throw new IOException("socket closed"); } state = SocketState.CONNECTED; }
java
{ "resource": "" }
q165244
InvokeDynamicClassInstrumentor.interceptInvokeVirtualMethodWithInvokeDynamic
validation
private void interceptInvokeVirtualMethodWithInvokeDynamic( ListIterator<AbstractInsnNode> instructions, MethodInsnNode targetMethod) { instructions.remove(); // remove the method invocation Type type = Type.getObjectType(targetMethod.owner); String description = targetMethod.desc; String owner = type.getClassName(); if (targetMethod.getOpcode() != Opcodes.INVOKESTATIC) { String thisType = type.getDescriptor(); description = "(" + thisType + description.substring(1); } instructions.add(new InvokeDynamicInsnNode(targetMethod.name, description, BOOTSTRAP_INTRINSIC, owner)); }
java
{ "resource": "" }
q165245
DynamicRefTable.addMappings
validation
int addMappings(final DynamicRefTable other) { if (mAssignedPackageId != other.mAssignedPackageId) { return UNKNOWN_ERROR; } // final int entryCount = other.mEntries.size(); // for (size_t i = 0; i < entryCount; i++) { // ssize_t index = mEntries.indexOfKey(other.mEntries.keyAt(i)); // if (index < 0) { // mEntries.add(other.mEntries.keyAt(i), other.mEntries[i]); // } else { // if (other.mEntries[i] != mEntries[index]) { // return UNKNOWN_ERROR; // } // } // } for (Entry<String, Byte> otherEntry : other.mEntries.entrySet()) { String key = otherEntry.getKey(); Byte curValue = mEntries.get(key); if (curValue == null) { mEntries.put(key, otherEntry.getValue()); } else { if (!Objects.equals(otherEntry.getValue(), curValue)) { return UNKNOWN_ERROR; } } } // Merge the lookup table. No entry can conflict // (value of 0 means not set). for (int i = 0; i < 256; i++) { if (mLookupTable[i] != other.mLookupTable[i]) { if (mLookupTable[i] == 0) { mLookupTable[i] = other.mLookupTable[i]; } else if (other.mLookupTable[i] != 0) { return UNKNOWN_ERROR; } } } return NO_ERROR; }
java
{ "resource": "" }
q165246
DynamicRefTable.addMapping
validation
int addMapping(final String packageName, byte packageId) { Byte index = mEntries.get(packageName); if (index == null) { return UNKNOWN_ERROR; } mLookupTable[index] = packageId; return NO_ERROR; }
java
{ "resource": "" }
q165247
ShadowContextWrapper.grantPermissions
validation
public void grantPermissions(int pid, int uid, String... permissions) { getShadowInstrumentation().grantPermissions(pid, uid, permissions); }
java
{ "resource": "" }
q165248
ShadowContextWrapper.denyPermissions
validation
public void denyPermissions(int pid, int uid, String... permissions) { getShadowInstrumentation().denyPermissions(pid, uid, permissions); }
java
{ "resource": "" }
q165249
DefaultSdkPicker.selectSdks
validation
@Override @Nonnull public List<Sdk> selectSdks(Configuration configuration, UsesSdk usesSdk) { Config config = configuration.get(Config.class); Set<Sdk> sdks = new TreeSet<>(configuredSdks(config, usesSdk)); if (enabledSdks != null) { sdks = Sets.intersection(sdks, enabledSdks); } return Lists.newArrayList(sdks); }
java
{ "resource": "" }
q165250
ShadowLegacyAssetManager.getFileFromZip
validation
private static Path getFileFromZip(Path path) { byte[] buffer = new byte[1024]; try { Path outputDir = new TempDirectory("robolectric_assets").create("fromzip"); try (InputStream zis = Fs.getInputStream(path)) { Path fileFromZip = outputDir.resolve(path.getFileName().toString()); try (OutputStream fos = Files.newOutputStream(fileFromZip)) { int len; while ((len = zis.read(buffer)) > 0) { fos.write(buffer, 0, len); } } return fileFromZip; } } catch (IOException e) { throw new RuntimeException(e); } }
java
{ "resource": "" }
q165251
FakeHttp.getNextSentHttpRequest
validation
public static HttpRequest getNextSentHttpRequest() { HttpRequestInfo httpRequestInfo = getFakeHttpLayer().getNextSentHttpRequestInfo(); return httpRequestInfo == null ? null : httpRequestInfo.getHttpRequest(); }
java
{ "resource": "" }
q165252
FakeHttp.addHttpResponseRule
validation
public static void addHttpResponseRule(String method, String uri, HttpResponse response) { getFakeHttpLayer().addHttpResponseRule(method, uri, response); }
java
{ "resource": "" }
q165253
FakeHttp.addHttpResponseRule
validation
public static void addHttpResponseRule(RequestMatcher requestMatcher, List<? extends HttpResponse> responses) { getFakeHttpLayer().addHttpResponseRule(requestMatcher, responses); }
java
{ "resource": "" }
q165254
ShadowMediaMuxer.nativeStop
validation
@Implementation protected static void nativeStop(long nativeObject) { try { // Close the output stream. getStream(nativeObject).close(); // Clear the stream from both internal caches. fdToStream.remove(outputStreams.remove(nativeObject).getFD()); } catch (IOException e) { throw new RuntimeException("Unable to close temporary file.", e); } }
java
{ "resource": "" }
q165255
FakeHttpLayer.addHttpResponseRule
validation
public void addHttpResponseRule(RequestMatcher requestMatcher, List<? extends HttpResponse> responses) { addHttpResponseRule(new RequestMatcherResponseRule(requestMatcher, responses)); }
java
{ "resource": "" }
q165256
ShadowMediaRouter.addBluetoothRoute
validation
public void addBluetoothRoute() { updateBluetoothAudioRoute(BLUETOOTH_DEVICE_NAME); if (RuntimeEnvironment.getApiLevel() <= JELLY_BEAN_MR1) { ReflectionHelpers.callInstanceMethod( MediaRouter.class, realObject, "selectRouteInt", ClassParameter.from(int.class, MediaRouter.ROUTE_TYPE_LIVE_AUDIO), ClassParameter.from(RouteInfo.class, getBluetoothA2dpRoute())); } else { realObject.selectRoute(MediaRouter.ROUTE_TYPE_LIVE_AUDIO, getBluetoothA2dpRoute()); } }
java
{ "resource": "" }
q165257
ShadowProcess.setThreadPriority
validation
@Implementation protected static final void setThreadPriority(int tid, int priority) { checkArgument( priority >= android.os.Process.THREAD_PRIORITY_URGENT_AUDIO && priority <= android.os.Process.THREAD_PRIORITY_LOWEST, "priority %s out of range. Use a Process.THREAD_PRIORITY_* constant.", priority); if (tid == 0) { tid = ShadowProcess.myTid(); } synchronized (threadPrioritiesLock) { threadPriorities.put(tid, priority); } }
java
{ "resource": "" }
q165258
ShadowProcess.getThreadPriority
validation
@Implementation protected static final int getThreadPriority(int tid) { if (tid == 0) { tid = ShadowProcess.myTid(); } synchronized (threadPrioritiesLock) { return threadPriorities.getOrDefault(tid, 0); } }
java
{ "resource": "" }
q165259
NativeBitSet64.getIndexOfBit
validation
int getIndexOfBit(int n) { // return __builtin_popcountll(value & ~(0xffffffffffffffffULL >> n)); int numMarkedBits = 0; for (int i = 0; i < n; i++) { if (hasBit(i)) { numMarkedBits++; } } return numMarkedBits; }
java
{ "resource": "" }
q165260
ShadowAppOpsManager.setMode
validation
@Implementation(minSdk = P) @HiddenApi @SystemApi @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) public void setMode(String op, int uid, String packageName, int mode) { setMode(AppOpsManager.strOpToOp(op), uid, packageName, mode); }
java
{ "resource": "" }
q165261
ResourceHelper.getColor
validation
public static int getColor(String value) { if (value != null) { if (value.startsWith("#") == false) { throw new NumberFormatException( String.format("Color value '%s' must start with #", value)); } value = value.substring(1); // make sure it's not longer than 32bit if (value.length() > 8) { throw new NumberFormatException(String.format( "Color value '%s' is too long. Format is either" + "#AARRGGBB, #RRGGBB, #RGB, or #ARGB", value)); } if (value.length() == 3) { // RGB format char[] color = new char[8]; color[0] = color[1] = 'F'; color[2] = color[3] = value.charAt(0); color[4] = color[5] = value.charAt(1); color[6] = color[7] = value.charAt(2); value = new String(color); } else if (value.length() == 4) { // ARGB format char[] color = new char[8]; color[0] = color[1] = value.charAt(0); color[2] = color[3] = value.charAt(1); color[4] = color[5] = value.charAt(2); color[6] = color[7] = value.charAt(3); value = new String(color); } else if (value.length() == 6) { value = "FF" + value; } // this is a RRGGBB or AARRGGBB value // Integer.parseInt will fail to inferFromValue strings like "ff191919", so we use // a Long, but cast the result back into an int, since we know that we're only // dealing with 32 bit values. return (int)Long.parseLong(value, 16); } throw new NumberFormatException(); }
java
{ "resource": "" }
q165262
ResourceHelper.getColorType
validation
public static int getColorType(String value) { if (value != null && value.startsWith("#")) { switch (value.length()) { case 4: return TypedValue.TYPE_INT_COLOR_RGB4; case 5: return TypedValue.TYPE_INT_COLOR_ARGB4; case 7: return TypedValue.TYPE_INT_COLOR_RGB8; case 9: return TypedValue.TYPE_INT_COLOR_ARGB8; } } return TypedValue.TYPE_INT_COLOR_ARGB8; }
java
{ "resource": "" }
q165263
ResourceHelper.parseFloatAttribute
validation
public static boolean parseFloatAttribute(String attribute, String value, TypedValue outValue, boolean requireUnit) { assert requireUnit == false || attribute != null; // remove the space before and after value = value.trim(); int len = value.length(); if (len <= 0) { return false; } // check that there's no non ascii characters. char[] buf = value.toCharArray(); for (int i = 0 ; i < len ; i++) { if (buf[i] > 255) { return false; } } // check the first character if (buf[0] < '0' && buf[0] > '9' && buf[0] != '.' && buf[0] != '-') { return false; } // now look for the string that is after the float... Matcher m = sFloatPattern.matcher(value); if (m.matches()) { String f_str = m.group(1); String end = m.group(2); float f; try { f = Float.parseFloat(f_str); } catch (NumberFormatException e) { // this shouldn't happen with the regexp above. return false; } if (end.length() > 0 && end.charAt(0) != ' ') { // Might be a unit... if (parseUnit(end, outValue, sFloatOut)) { computeTypedValue(outValue, f, sFloatOut[0]); return true; } return false; } // make sure it's only spaces at the end. end = end.trim(); if (end.length() == 0) { if (outValue != null) { outValue.assetCookie = 0; outValue.string = null; if (requireUnit == false) { outValue.type = TypedValue.TYPE_FLOAT; outValue.data = Float.floatToIntBits(f); } else { // no unit when required? Use dp and out an error. applyUnit(sUnitNames[1], outValue, sFloatOut); computeTypedValue(outValue, f, sFloatOut[0]); System.out.println(String.format( "Dimension \"%1$s\" in attribute \"%2$s\" is missing unit!", value, attribute)); } return true; } } } return false; }
java
{ "resource": "" }
q165264
ShadowImageDecoder.nCreate
validation
@Implementation protected static ImageDecoder nCreate(long asset, Source source) throws IOException { return ImageDecoder_nCreateAsset(asset, source); }
java
{ "resource": "" }
q165265
ShadowImageDecoder.nCreate
validation
@Implementation protected static ImageDecoder nCreate(FileDescriptor fd, Source src) throws IOException { return ImageDecoder_nCreateFd(fd, src); }
java
{ "resource": "" }
q165266
ShadowActivity.clickMenuItem
validation
public boolean clickMenuItem(int menuItemResId) { final RoboMenuItem item = new RoboMenuItem(menuItemResId); return realActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item); }
java
{ "resource": "" }
q165267
ShadowActivity.callOnActivityResult
validation
public void callOnActivityResult(int requestCode, int resultCode, Intent resultData) { final ActivityInvoker invoker = new ActivityInvoker(); invoker .call("onActivityResult", Integer.TYPE, Integer.TYPE, Intent.class) .with(requestCode, resultCode, resultData); }
java
{ "resource": "" }
q165268
ShadowActivity.startLockTask
validation
@Implementation(minSdk = LOLLIPOP) protected void startLockTask() { Shadow.<ShadowActivityManager>extract(getActivityManager()) .setLockTaskModeState(ActivityManager.LOCK_TASK_MODE_LOCKED); }
java
{ "resource": "" }
q165269
ShadowActivity.stopLockTask
validation
@Implementation(minSdk = LOLLIPOP) protected void stopLockTask() { Shadow.<ShadowActivityManager>extract(getActivityManager()) .setLockTaskModeState(ActivityManager.LOCK_TASK_MODE_NONE); }
java
{ "resource": "" }
q165270
Scheduler.postDelayed
validation
public synchronized void postDelayed(Runnable runnable, long delay, TimeUnit unit) { long delayMillis = unit.toMillis(delay); if ((idleState != CONSTANT_IDLE && (isPaused() || delayMillis > 0)) || Thread.currentThread() != associatedThread) { runnables.add(new ScheduledRunnable(runnable, currentTime + delayMillis)); } else { runOrQueueRunnable(runnable, currentTime + delayMillis); } }
java
{ "resource": "" }
q165271
Scheduler.postAtFrontOfQueue
validation
public synchronized void postAtFrontOfQueue(Runnable runnable) { if (isPaused() || Thread.currentThread() != associatedThread) { final long timeDisambiguator; if (runnables.isEmpty()) { timeDisambiguator = nextTimeDisambiguator++; } else { timeDisambiguator = runnables.peek().timeDisambiguator - 1; } runnables.add(new ScheduledRunnable(runnable, 0, timeDisambiguator)); } else { runOrQueueRunnable(runnable, currentTime); } }
java
{ "resource": "" }
q165272
Scheduler.remove
validation
public synchronized void remove(Runnable runnable) { Iterator<ScheduledRunnable> iterator = runnables.iterator(); while (iterator.hasNext()) { if (iterator.next().runnable == runnable) { iterator.remove(); } } }
java
{ "resource": "" }
q165273
Scheduler.advanceToLastPostedRunnable
validation
public synchronized boolean advanceToLastPostedRunnable() { long currentMaxTime = currentTime; for (ScheduledRunnable scheduled : runnables) { if (currentMaxTime < scheduled.scheduledTime) { currentMaxTime = scheduled.scheduledTime; } } return advanceTo(currentMaxTime); }
java
{ "resource": "" }
q165274
Scheduler.advanceBy
validation
public synchronized boolean advanceBy(long amount, TimeUnit unit) { long endingTime = currentTime + unit.toMillis(amount); return advanceTo(endingTime); }
java
{ "resource": "" }
q165275
Scheduler.advanceTo
validation
public synchronized boolean advanceTo(long endTime) { if (endTime < currentTime || runnables.isEmpty()) { currentTime = endTime; return false; } int runCount = 0; while (nextTaskIsScheduledBefore(endTime)) { runOneTask(); ++runCount; } currentTime = endTime; return runCount > 0; }
java
{ "resource": "" }
q165276
Scheduler.runOneTask
validation
public synchronized boolean runOneTask() { ScheduledRunnable postedRunnable = runnables.poll(); if (postedRunnable != null) { if (postedRunnable.scheduledTime > currentTime) { currentTime = postedRunnable.scheduledTime; } postedRunnable.run(); return true; } return false; }
java
{ "resource": "" }
q165277
ShadowContextImpl.bindServiceAsUser
validation
@Implementation(minSdk = LOLLIPOP) protected boolean bindServiceAsUser( Intent intent, final ServiceConnection serviceConnection, int i, UserHandle userHandle) { return getShadowInstrumentation().bindService(intent, serviceConnection, i); }
java
{ "resource": "" }
q165278
ShadowPausedSystemClock.setCurrentTimeMillis
validation
@Implementation protected static boolean setCurrentTimeMillis(long millis) { if (currentTimeMillis > millis) { return false; } currentTimeMillis = millis; for (Listener listener : listeners) { listener.clockUpdated(currentTimeMillis); } return true; }
java
{ "resource": "" }
q165279
ShadowPausedMessageQueue.isIdle
validation
@Implementation(minSdk = 23) public boolean isIdle() { if (Build.VERSION.SDK_INT >= M) { return directlyOn(realQueue, MessageQueue.class).isIdle(); } else { ReflectorMessageQueue internalQueue = reflector(ReflectorMessageQueue.class, realQueue); // this is a copy of the implementation from P synchronized (realQueue) { final long now = SystemClock.uptimeMillis(); Message headMsg = internalQueue.getMessages(); if (headMsg == null) { return true; } long when = shadowOfMsg(headMsg).getWhen(); return now < when; } } }
java
{ "resource": "" }
q165280
ShadowPausedMessageQueue.reset
validation
@Override public void reset() { ReflectorMessageQueue msgQueue = reflector(ReflectorMessageQueue.class, realQueue); msgQueue.setMessages(null); msgQueue.setIdleHandlers(new ArrayList<>()); msgQueue.setNextBarrierToken(0); }
java
{ "resource": "" }
q165281
Robolectric.buildActivity
validation
public static <T extends Activity> ActivityController<T> buildActivity(Class<T> activityClass) { return buildActivity(activityClass, null); }
java
{ "resource": "" }
q165282
Robolectric.buildActivity
validation
public static <T extends Activity> ActivityController<T> buildActivity( Class<T> activityClass, Intent intent) { return ActivityController.of(ReflectionHelpers.callConstructor(activityClass), intent); }
java
{ "resource": "" }
q165283
Robolectric.setupActivity
validation
@Deprecated public static <T extends Activity> T setupActivity(Class<T> activityClass) { return buildActivity(activityClass).setup().get(); }
java
{ "resource": "" }
q165284
Robolectric.buildFragment
validation
@Deprecated public static <T extends Fragment> FragmentController<T> buildFragment(Class<T> fragmentClass) { return FragmentController.of(ReflectionHelpers.callConstructor(fragmentClass)); }
java
{ "resource": "" }
q165285
ShadowTextToSpeech.speak
validation
@Implementation protected int speak( final String text, final int queueMode, final HashMap<String, String> params) { if (RuntimeEnvironment.getApiLevel() >= LOLLIPOP) { return Shadow.directlyOn(tts, TextToSpeech.class).speak(text, queueMode, params); } return speak( text, queueMode, null, params == null ? null : params.get(Engine.KEY_PARAM_UTTERANCE_ID)); }
java
{ "resource": "" }
q165286
ShadowDisplayManagerGlobal.getStableDisplaySize
validation
@Implementation(minSdk = O_MR1) public Point getStableDisplaySize() throws RemoteException { DisplayInfo defaultDisplayInfo = mDm.getDisplayInfo(Display.DEFAULT_DISPLAY); return new Point(defaultDisplayInfo.getNaturalWidth(), defaultDisplayInfo.getNaturalHeight()); }
java
{ "resource": "" }
q165287
Fs.getJarFs
validation
private static FileSystem getJarFs(Path jarFile) throws IOException { Path key = jarFile.toAbsolutePath(); synchronized (ZIP_FILESYSTEMS) { FsWrapper fs = ZIP_FILESYSTEMS.get(key); if (fs == null) { fs = new FsWrapper(FileSystems.newFileSystem(key, null), key); fs.incrRefCount(); ZIP_FILESYSTEMS.put(key, fs); } else { fs.incrRefCount(); } return fs; } }
java
{ "resource": "" }
q165288
ShadowLog.getLogsForTag
validation
public static List<LogItem> getLogsForTag(String tag) { Queue<LogItem> logs = logsByTag.get(tag); return logs == null ? Collections.emptyList() : new ArrayList<>(logs); }
java
{ "resource": "" }
q165289
AndroidManifest.getAllManifests
validation
public List<AndroidManifest> getAllManifests() { Set<AndroidManifest> seenManifests = new HashSet<>(); List<AndroidManifest> uniqueManifests = new ArrayList<>(); addTransitiveManifests(seenManifests, uniqueManifests); return uniqueManifests; }
java
{ "resource": "" }
q165290
AndroidManifest.getBroadcastReceiver
validation
public @Nullable BroadcastReceiverData getBroadcastReceiver(String className) { parseAndroidManifest(); for (BroadcastReceiverData receiver : receivers) { if (receiver.getName().equals(className)) { return receiver; } } return null; }
java
{ "resource": "" }
q165291
ShadowNotificationManager.deleteNotificationChannelGroup
validation
@Implementation(minSdk = Build.VERSION_CODES.O) protected void deleteNotificationChannelGroup(String channelGroupId) { if (getNotificationChannelGroup(channelGroupId) != null) { // Deleting a channel group also deleted all associated channels. See // https://developer.android.com/reference/android/app/NotificationManager.html#deleteNotificationChannelGroup%28java.lang.String%29 // for more info. for (/* NotificationChannel */ Object channel : getNotificationChannels()) { String groupId = ReflectionHelpers.callInstanceMethod(channel, "getGroup"); if (channelGroupId.equals(groupId)) { String channelId = ReflectionHelpers.callInstanceMethod(channel, "getId"); deleteNotificationChannel(channelId); } } notificationChannelGroups.remove(channelGroupId); } }
java
{ "resource": "" }
q165292
UnsafeAccess.getJavaVersion
validation
private static int getJavaVersion() { String version = System.getProperty("java.version"); assert version != null; if (version.startsWith("1.")) { version = version.substring(2); } // Allow these formats: // 1.8.0_72-ea // 9-ea // 9 // 9.0.1 int dotPos = version.indexOf('.'); int dashPos = version.indexOf('-'); return Integer.parseInt( version.substring(0, dotPos > -1 ? dotPos : dashPos > -1 ? dashPos : 1)); }
java
{ "resource": "" }
q165293
ShadowMotionEvent.transform
validation
@Implementation protected final void transform(Matrix matrix) { checkNotNull(matrix); NativeInput.MotionEvent event = getNativeMotionEvent(); ShadowMatrix shadowMatrix = Shadow.extract(matrix); float[] m = new float[9]; shadowMatrix.getValues(m); event.transform(m); }
java
{ "resource": "" }
q165294
ShadowCaptureResult.get
validation
@Implementation @Nullable @SuppressWarnings("unchecked") protected <T> T get(Key<T> key) { return (T) resultsKeyToValue.get(key); }
java
{ "resource": "" }
q165295
ShadowArscAssetManager.loadResourceBagValue
validation
@Implementation @HiddenApi protected final int loadResourceBagValue(int ident, int bagEntryId, TypedValue outValue, boolean resolve) { CppAssetManager am = assetManagerForJavaObject(); if (am == null) { return 0; } final ResTable res = am.getResources(); return loadResourceBagValueInternal(ident, bagEntryId, outValue, resolve, res); }
java
{ "resource": "" }
q165296
ShadowLegacyLooper.post
validation
@Override @Deprecated public boolean post(Runnable runnable, long delayMillis) { if (!quit) { getScheduler().postDelayed(runnable, delayMillis, TimeUnit.MILLISECONDS); return true; } else { return false; } }
java
{ "resource": "" }
q165297
ShadowLegacyLooper.postAtFrontOfQueue
validation
@Override @Deprecated public boolean postAtFrontOfQueue(Runnable runnable) { if (!quit) { getScheduler().postAtFrontOfQueue(runnable); return true; } else { return false; } }
java
{ "resource": "" }
q165298
ShadowPackageManager.addActivityIfNotPresent
validation
public ActivityInfo addActivityIfNotPresent(ComponentName componentName) { return addComponent( activityFilters, p -> p.activities, (p, a) -> p.activities = a, updateName(componentName, new ActivityInfo()), false); }
java
{ "resource": "" }
q165299
ShadowPackageManager.addServiceIfNotPresent
validation
public ServiceInfo addServiceIfNotPresent(ComponentName componentName) { return addComponent( serviceFilters, p -> p.services, (p, a) -> p.services = a, updateName(componentName, new ServiceInfo()), false); }
java
{ "resource": "" }