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 sendGamepadKey(IBinder token, int keyCode, boolean down) { if (isTokenValid(token)) { nativeSendGamepadKey(mPtr, keyCode, down); } }
Send a gamepad key @param keyIndex - the index of the w3-spec key @param down - is the key pressed ?
UinputBridge::sendGamepadKey
java
Reginer/aosp-android-jar
android-32/src/com/android/server/tv/UinputBridge.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/tv/UinputBridge.java
MIT
public void sendGamepadAxisValue(IBinder token, int axis, float value) { if (isTokenValid(token)) { nativeSendGamepadAxisValue(mPtr, axis, value); } }
Send a gamepad axis value. @param axis is the axis code (MotionEvent.AXIS_*) @param value is the value to set for that axis in [-1, 1]
UinputBridge::sendGamepadAxisValue
java
Reginer/aosp-android-jar
android-32/src/com/android/server/tv/UinputBridge.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/tv/UinputBridge.java
MIT
public void testNewCachedThreadPool1() { final ExecutorService e = Executors.newCachedThreadPool(); try (PoolCleaner cleaner = cleaner(e)) { e.execute(new NoOpRunnable()); e.execute(new NoOpRunnable()); e.execute(new NoOpRunnable()); } }
A newCachedThreadPool can execute runnables
ExecutorsTest::testNewCachedThreadPool1
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testNewCachedThreadPool2() { final ExecutorService e = Executors.newCachedThreadPool(new SimpleThreadFactory()); try (PoolCleaner cleaner = cleaner(e)) { e.execute(new NoOpRunnable()); e.execute(new NoOpRunnable()); e.execute(new NoOpRunnable()); } }
A newCachedThreadPool with given ThreadFactory can execute runnables
ExecutorsTest::testNewCachedThreadPool2
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testNewCachedThreadPool3() { try { ExecutorService e = Executors.newCachedThreadPool(null); shouldThrow(); } catch (NullPointerException success) {} }
A newCachedThreadPool with null ThreadFactory throws NPE
ExecutorsTest::testNewCachedThreadPool3
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testNewSingleThreadExecutor1() { final ExecutorService e = Executors.newSingleThreadExecutor(); try (PoolCleaner cleaner = cleaner(e)) { e.execute(new NoOpRunnable()); e.execute(new NoOpRunnable()); e.execute(new NoOpRunnable()); } }
A new SingleThreadExecutor can execute runnables
ExecutorsTest::testNewSingleThreadExecutor1
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testNewSingleThreadExecutor2() { final ExecutorService e = Executors.newSingleThreadExecutor(new SimpleThreadFactory()); try (PoolCleaner cleaner = cleaner(e)) { e.execute(new NoOpRunnable()); e.execute(new NoOpRunnable()); e.execute(new NoOpRunnable()); } }
A new SingleThreadExecutor with given ThreadFactory can execute runnables
ExecutorsTest::testNewSingleThreadExecutor2
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testNewSingleThreadExecutor3() { try { ExecutorService e = Executors.newSingleThreadExecutor(null); shouldThrow(); } catch (NullPointerException success) {} }
A new SingleThreadExecutor with null ThreadFactory throws NPE
ExecutorsTest::testNewSingleThreadExecutor3
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testCastNewSingleThreadExecutor() { final ExecutorService e = Executors.newSingleThreadExecutor(); try (PoolCleaner cleaner = cleaner(e)) { try { ThreadPoolExecutor tpe = (ThreadPoolExecutor)e; shouldThrow(); } catch (ClassCastException success) {} } }
A new SingleThreadExecutor cannot be casted to concrete implementation
ExecutorsTest::testCastNewSingleThreadExecutor
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testNewFixedThreadPool1() { final ExecutorService e = Executors.newFixedThreadPool(2); try (PoolCleaner cleaner = cleaner(e)) { e.execute(new NoOpRunnable()); e.execute(new NoOpRunnable()); e.execute(new NoOpRunnable()); } }
A new newFixedThreadPool can execute runnables
ExecutorsTest::testNewFixedThreadPool1
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testNewFixedThreadPool2() { final ExecutorService e = Executors.newFixedThreadPool(2, new SimpleThreadFactory()); try (PoolCleaner cleaner = cleaner(e)) { e.execute(new NoOpRunnable()); e.execute(new NoOpRunnable()); e.execute(new NoOpRunnable()); } }
A new newFixedThreadPool with given ThreadFactory can execute runnables
ExecutorsTest::testNewFixedThreadPool2
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testNewFixedThreadPool3() { try { ExecutorService e = Executors.newFixedThreadPool(2, null); shouldThrow(); } catch (NullPointerException success) {} }
A new newFixedThreadPool with null ThreadFactory throws NPE
ExecutorsTest::testNewFixedThreadPool3
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testNewFixedThreadPool4() { try { ExecutorService e = Executors.newFixedThreadPool(0); shouldThrow(); } catch (IllegalArgumentException success) {} }
A new newFixedThreadPool with 0 threads throws IAE
ExecutorsTest::testNewFixedThreadPool4
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testUnconfigurableExecutorService() { final ExecutorService e = Executors.unconfigurableExecutorService(Executors.newFixedThreadPool(2)); try (PoolCleaner cleaner = cleaner(e)) { e.execute(new NoOpRunnable()); e.execute(new NoOpRunnable()); e.execute(new NoOpRunnable()); } }
An unconfigurable newFixedThreadPool can execute runnables
ExecutorsTest::testUnconfigurableExecutorService
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testUnconfigurableExecutorServiceNPE() { try { ExecutorService e = Executors.unconfigurableExecutorService(null); shouldThrow(); } catch (NullPointerException success) {} }
unconfigurableExecutorService(null) throws NPE
ExecutorsTest::testUnconfigurableExecutorServiceNPE
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testUnconfigurableScheduledExecutorServiceNPE() { try { ExecutorService e = Executors.unconfigurableScheduledExecutorService(null); shouldThrow(); } catch (NullPointerException success) {} }
unconfigurableScheduledExecutorService(null) throws NPE
ExecutorsTest::testUnconfigurableScheduledExecutorServiceNPE
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testNewSingleThreadScheduledExecutor() throws Exception { final ScheduledExecutorService p = Executors.newSingleThreadScheduledExecutor(); try (PoolCleaner cleaner = cleaner(p)) { final CountDownLatch proceed = new CountDownLatch(1); final Runnable task = new CheckedRunnable() { public void realRun() { await(proceed); }}; long startTime = System.nanoTime(); Future f = p.schedule(Executors.callable(task, Boolean.TRUE), timeoutMillis(), MILLISECONDS); assertFalse(f.isDone()); proceed.countDown(); assertSame(Boolean.TRUE, f.get(LONG_DELAY_MS, MILLISECONDS)); assertSame(Boolean.TRUE, f.get()); assertTrue(f.isDone()); assertFalse(f.isCancelled()); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); } }
a newSingleThreadScheduledExecutor successfully runs delayed task
ExecutorsTest::testNewSingleThreadScheduledExecutor
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testNewScheduledThreadPool() throws Exception { final ScheduledExecutorService p = Executors.newScheduledThreadPool(2); try (PoolCleaner cleaner = cleaner(p)) { final CountDownLatch proceed = new CountDownLatch(1); final Runnable task = new CheckedRunnable() { public void realRun() { await(proceed); }}; long startTime = System.nanoTime(); Future f = p.schedule(Executors.callable(task, Boolean.TRUE), timeoutMillis(), MILLISECONDS); assertFalse(f.isDone()); proceed.countDown(); assertSame(Boolean.TRUE, f.get(LONG_DELAY_MS, MILLISECONDS)); assertSame(Boolean.TRUE, f.get()); assertTrue(f.isDone()); assertFalse(f.isCancelled()); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); } }
a newScheduledThreadPool successfully runs delayed task
ExecutorsTest::testNewScheduledThreadPool
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testUnconfigurableScheduledExecutorService() throws Exception { final ScheduledExecutorService p = Executors.unconfigurableScheduledExecutorService (Executors.newScheduledThreadPool(2)); try (PoolCleaner cleaner = cleaner(p)) { final CountDownLatch proceed = new CountDownLatch(1); final Runnable task = new CheckedRunnable() { public void realRun() { await(proceed); }}; long startTime = System.nanoTime(); Future f = p.schedule(Executors.callable(task, Boolean.TRUE), timeoutMillis(), MILLISECONDS); assertFalse(f.isDone()); proceed.countDown(); assertSame(Boolean.TRUE, f.get(LONG_DELAY_MS, MILLISECONDS)); assertSame(Boolean.TRUE, f.get()); assertTrue(f.isDone()); assertFalse(f.isCancelled()); assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); } }
an unconfigurable newScheduledThreadPool successfully runs delayed task
ExecutorsTest::testUnconfigurableScheduledExecutorService
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testTimedCallable() throws Exception { final ExecutorService[] executors = { Executors.newSingleThreadExecutor(), Executors.newCachedThreadPool(), Executors.newFixedThreadPool(2), Executors.newScheduledThreadPool(2), }; final Runnable sleeper = new CheckedInterruptedRunnable() { public void realRun() throws InterruptedException { delay(LONG_DELAY_MS); }}; List<Thread> threads = new ArrayList<Thread>(); for (final ExecutorService executor : executors) { threads.add(newStartedThread(new CheckedRunnable() { public void realRun() { Future future = executor.submit(sleeper); assertFutureTimesOut(future); }})); } for (Thread thread : threads) awaitTermination(thread); for (ExecutorService executor : executors) joinPool(executor); }
Future.get on submitted tasks will time out if they compute too long.
ExecutorsTest::testTimedCallable
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testDefaultThreadFactory() throws Exception { final ThreadGroup egroup = Thread.currentThread().getThreadGroup(); final CountDownLatch done = new CountDownLatch(1); Runnable r = new CheckedRunnable() { public void realRun() { try { Thread current = Thread.currentThread(); assertTrue(!current.isDaemon()); assertTrue(current.getPriority() <= Thread.NORM_PRIORITY); ThreadGroup g = current.getThreadGroup(); SecurityManager s = System.getSecurityManager(); if (s != null) assertTrue(g == s.getThreadGroup()); else assertTrue(g == egroup); String name = current.getName(); assertTrue(name.endsWith("thread-1")); } catch (SecurityException ok) { // Also pass if not allowed to change setting } done.countDown(); }}; ExecutorService e = Executors.newSingleThreadExecutor(Executors.defaultThreadFactory()); try (PoolCleaner cleaner = cleaner(e)) { e.execute(r); await(done); } }
ThreadPoolExecutor using defaultThreadFactory has specified group, priority, daemon status, and name
ExecutorsTest::testDefaultThreadFactory
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testPrivilegedThreadFactory() throws Exception { final CountDownLatch done = new CountDownLatch(1); Runnable r = new CheckedRunnable() { public void realRun() throws Exception { final ThreadGroup egroup = Thread.currentThread().getThreadGroup(); final ClassLoader thisccl = Thread.currentThread().getContextClassLoader(); // android-note: Removed unsupported access controller check. // final AccessControlContext thisacc = AccessController.getContext(); Runnable r = new CheckedRunnable() { public void realRun() { Thread current = Thread.currentThread(); assertTrue(!current.isDaemon()); assertTrue(current.getPriority() <= Thread.NORM_PRIORITY); ThreadGroup g = current.getThreadGroup(); SecurityManager s = System.getSecurityManager(); if (s != null) assertTrue(g == s.getThreadGroup()); else assertTrue(g == egroup); String name = current.getName(); assertTrue(name.endsWith("thread-1")); assertSame(thisccl, current.getContextClassLoader()); //assertEquals(thisacc, AccessController.getContext()); done.countDown(); }}; ExecutorService e = Executors.newSingleThreadExecutor(Executors.privilegedThreadFactory()); try (PoolCleaner cleaner = cleaner(e)) { e.execute(r); await(done); } }}; runWithPermissions(r, new RuntimePermission("getClassLoader"), new RuntimePermission("setContextClassLoader"), new RuntimePermission("modifyThread")); }
ThreadPoolExecutor using privilegedThreadFactory has specified group, priority, daemon status, name, access control context and context class loader
ExecutorsTest::testPrivilegedThreadFactory
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testCreatePrivilegedCallableUsingCCLWithNoPrivs() { Runnable r = new CheckedRunnable() { public void realRun() throws Exception { if (System.getSecurityManager() == null) return; try { Executors.privilegedCallableUsingCurrentClassLoader(new NoOpCallable()); shouldThrow(); } catch (AccessControlException success) {} }}; runWithoutPermissions(r); }
Without class loader permissions, creating privilegedCallableUsingCurrentClassLoader throws ACE
CheckCCL::testCreatePrivilegedCallableUsingCCLWithNoPrivs
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testPrivilegedCallableUsingCCLWithPrivs() throws Exception { Runnable r = new CheckedRunnable() { public void realRun() throws Exception { Executors.privilegedCallableUsingCurrentClassLoader (new NoOpCallable()) .call(); }}; runWithPermissions(r, new RuntimePermission("getClassLoader"), new RuntimePermission("setContextClassLoader")); }
With class loader permissions, calling privilegedCallableUsingCurrentClassLoader does not throw ACE
CheckCCL::testPrivilegedCallableUsingCCLWithPrivs
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testPrivilegedCallableWithNoPrivs() throws Exception { // Avoid classloader-related SecurityExceptions in swingui.TestRunner Executors.privilegedCallable(new CheckCCL()); Runnable r = new CheckedRunnable() { public void realRun() throws Exception { if (System.getSecurityManager() == null) return; Callable task = Executors.privilegedCallable(new CheckCCL()); try { task.call(); shouldThrow(); } catch (AccessControlException success) {} }}; runWithoutPermissions(r); // It seems rather difficult to test that the // AccessControlContext of the privilegedCallable is used // instead of its caller. Below is a failed attempt to do // that, which does not work because the AccessController // cannot capture the internal state of the current Policy. // It would be much more work to differentiate based on, // e.g. CodeSource. // final AccessControlContext[] noprivAcc = new AccessControlContext[1]; // final Callable[] task = new Callable[1]; // runWithPermissions // (new CheckedRunnable() { // public void realRun() { // if (System.getSecurityManager() == null) // return; // noprivAcc[0] = AccessController.getContext(); // task[0] = Executors.privilegedCallable(new CheckCCL()); // try { // AccessController.doPrivileged(new PrivilegedAction<Void>() { // public Void run() { // checkCCL(); // return null; // }}, noprivAcc[0]); // shouldThrow(); // } catch (AccessControlException success) {} // }}); // runWithPermissions // (new CheckedRunnable() { // public void realRun() throws Exception { // if (System.getSecurityManager() == null) // return; // // Verify that we have an underprivileged ACC // try { // AccessController.doPrivileged(new PrivilegedAction<Void>() { // public Void run() { // checkCCL(); // return null; // }}, noprivAcc[0]); // shouldThrow(); // } catch (AccessControlException success) {} // try { // task[0].call(); // shouldThrow(); // } catch (AccessControlException success) {} // }}, // new RuntimePermission("getClassLoader"), // new RuntimePermission("setContextClassLoader")); }
Without permissions, calling privilegedCallable throws ACE
CheckCCL::testPrivilegedCallableWithNoPrivs
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testPrivilegedCallableWithPrivs() throws Exception { Runnable r = new CheckedRunnable() { public void realRun() throws Exception { Executors.privilegedCallable(new CheckCCL()).call(); }}; runWithPermissions(r, new RuntimePermission("getClassLoader"), new RuntimePermission("setContextClassLoader")); }
With permissions, calling privilegedCallable succeeds
CheckCCL::testPrivilegedCallableWithPrivs
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testCallable1() throws Exception { Callable c = Executors.callable(new NoOpRunnable()); assertNull(c.call()); }
callable(Runnable) returns null when called
CheckCCL::testCallable1
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testCallable2() throws Exception { Callable c = Executors.callable(new NoOpRunnable(), one); assertSame(one, c.call()); }
callable(Runnable, result) returns result when called
CheckCCL::testCallable2
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testCallable3() throws Exception { Callable c = Executors.callable(new PrivilegedAction() { public Object run() { return one; }}); assertSame(one, c.call()); }
callable(PrivilegedAction) returns its result when called
CheckCCL::testCallable3
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testCallable4() throws Exception { Callable c = Executors.callable(new PrivilegedExceptionAction() { public Object run() { return one; }}); assertSame(one, c.call()); }
callable(PrivilegedExceptionAction) returns its result when called
CheckCCL::testCallable4
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testCallableNPE1() { try { Callable c = Executors.callable((Runnable) null); shouldThrow(); } catch (NullPointerException success) {} }
callable(null Runnable) throws NPE
CheckCCL::testCallableNPE1
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testCallableNPE2() { try { Callable c = Executors.callable((Runnable) null, one); shouldThrow(); } catch (NullPointerException success) {} }
callable(null, result) throws NPE
CheckCCL::testCallableNPE2
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testCallableNPE3() { try { Callable c = Executors.callable((PrivilegedAction) null); shouldThrow(); } catch (NullPointerException success) {} }
callable(null PrivilegedAction) throws NPE
CheckCCL::testCallableNPE3
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public void testCallableNPE4() { try { Callable c = Executors.callable((PrivilegedExceptionAction) null); shouldThrow(); } catch (NullPointerException success) {} }
callable(null PrivilegedExceptionAction) throws NPE
CheckCCL::testCallableNPE4
java
Reginer/aosp-android-jar
android-33/src/jsr166/ExecutorsTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/jsr166/ExecutorsTest.java
MIT
public static String referenceKindToString(int referenceKind) { if (!MethodHandleNatives.refKindIsValid(referenceKind)) throw newIllegalArgumentException("invalid reference kind", referenceKind); return MethodHandleNatives.refKindName((byte)referenceKind); }
Returns the descriptive name of the given reference kind, as defined in the <a href="MethodHandleInfo.html#refkinds">table above</a>. The conventional prefix "REF_" is omitted. @param referenceKind an integer code for a kind of reference used to access a class member @return a mixed-case string such as {@code "getField"} @exception IllegalArgumentException if the argument is not a valid <a href="MethodHandleInfo.html#refkinds">reference kind number</a>
referenceKindToString
java
Reginer/aosp-android-jar
android-33/src/java/lang/invoke/MethodHandleInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/java/lang/invoke/MethodHandleInfo.java
MIT
public static String toString(int kind, Class<?> defc, String name, MethodType type) { Objects.requireNonNull(name); Objects.requireNonNull(type); return String.format("%s %s.%s:%s", referenceKindToString(kind), defc.getName(), name, type); }
Returns a string representation for a {@code MethodHandleInfo}, given the four parts of its symbolic reference. This is defined to be of the form {@code "RK C.N:MT"}, where {@code RK} is the {@linkplain #referenceKindToString reference kind string} for {@code kind}, {@code C} is the {@linkplain java.lang.Class#getName name} of {@code defc} {@code N} is the {@code name}, and {@code MT} is the {@code type}. These four values may be obtained from the {@linkplain #getReferenceKind reference kind}, {@linkplain #getDeclaringClass declaring class}, {@linkplain #getName member name}, and {@linkplain #getMethodType method type} of a {@code MethodHandleInfo} object. @implSpec This produces a result equivalent to: <pre>{@code String.format("%s %s.%s:%s", referenceKindToString(kind), defc.getName(), name, type) }</pre> @param kind the {@linkplain #getReferenceKind reference kind} part of the symbolic reference @param defc the {@linkplain #getDeclaringClass declaring class} part of the symbolic reference @param name the {@linkplain #getName member name} part of the symbolic reference @param type the {@linkplain #getMethodType method type} part of the symbolic reference @return a string of the form {@code "RK C.N:MT"} @exception IllegalArgumentException if the first argument is not a valid <a href="MethodHandleInfo.html#refkinds">reference kind number</a> @exception NullPointerException if any reference argument is {@code null}
toString
java
Reginer/aosp-android-jar
android-33/src/java/lang/invoke/MethodHandleInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/java/lang/invoke/MethodHandleInfo.java
MIT
public void close() { synchronized (mLock) { if (mIsClosed) { return; } int res = nativeClose(); if (res != Tuner.RESULT_SUCCESS) { TunerUtils.throwExceptionForResult(res, "Failed to close LNB"); } else { mIsClosed = true; mTuner.releaseLnb(); } } }
Releases the LNB instance.
Lnb::close
java
Reginer/aosp-android-jar
android-31/src/android/media/tv/tuner/Lnb.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/media/tv/tuner/Lnb.java
MIT
public SettingInjectorService(String name) { mName = name; }
Constructor. @param name used to identify your subclass in log messages
SettingInjectorService::SettingInjectorService
java
Reginer/aosp-android-jar
android-31/src/android/location/SettingInjectorService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/location/SettingInjectorService.java
MIT
private void sendStatus(Intent intent, String summary, boolean enabled) { Messenger messenger = intent.getParcelableExtra(MESSENGER_KEY); // Bail out to avoid crashing GmsCore with incoming malicious Intent. if (messenger == null) { return; } Message message = Message.obtain(); Bundle bundle = new Bundle(); bundle.putString(SUMMARY_KEY, summary); bundle.putBoolean(ENABLED_KEY, enabled); message.setData(bundle); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, mName + ": received " + intent + ", summary=" + summary + ", enabled=" + enabled + ", sending message: " + message); } try { messenger.send(message); } catch (RemoteException e) { Log.e(TAG, mName + ": sending dynamic status failed", e); } }
Send the enabled values back to the caller via the messenger encoded in the intent.
SettingInjectorService::sendStatus
java
Reginer/aosp-android-jar
android-31/src/android/location/SettingInjectorService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/location/SettingInjectorService.java
MIT
public static final void refreshSettings(@NonNull Context context) { Intent intent = new Intent(ACTION_INJECTED_SETTING_CHANGED); context.sendBroadcast(intent); }
Sends a broadcast to refresh the injected settings on location settings page.
SettingInjectorService::refreshSettings
java
Reginer/aosp-android-jar
android-31/src/android/location/SettingInjectorService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/location/SettingInjectorService.java
MIT
public static void initialize() { SystemServiceRegistry.registerContextAwareService( Context.ROLLBACK_SERVICE, RollbackManager.class, (context, b) -> new RollbackManager(context, IRollbackManager.Stub.asInterface(b))); }
Called by {@link SystemServiceRegistry}'s static initializer and registers RollbackManager to {@link Context}, so that {@link Context#getSystemService} can return it. @throws IllegalStateException if this is called from anywhere besides {@link SystemServiceRegistry}
RollbackManagerFrameworkInitializer::initialize
java
Reginer/aosp-android-jar
android-32/src/android/content/rollback/RollbackManagerFrameworkInitializer.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/content/rollback/RollbackManagerFrameworkInitializer.java
MIT
public static EncryptedChunk create(ChunkHash key, byte[] nonce, byte[] encryptedBytes) { Preconditions.checkArgument( nonce.length == NONCE_LENGTH_BYTES, "Nonce does not have the correct length."); return new EncryptedChunk(key, nonce, encryptedBytes); }
Constructs a new instance with the given key, nonce, and encrypted bytes. @param key SHA-256 Hmac of the chunk plaintext. @param nonce Nonce with which the bytes of the chunk were encrypted. @param encryptedBytes Encrypted bytes of the chunk.
EncryptedChunk::create
java
Reginer/aosp-android-jar
android-31/src/com/android/server/backup/encryption/chunking/EncryptedChunk.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/backup/encryption/chunking/EncryptedChunk.java
MIT
public ChunkHash key() { return mKey; }
Constructs a new instance with the given key, nonce, and encrypted bytes. @param key SHA-256 Hmac of the chunk plaintext. @param nonce Nonce with which the bytes of the chunk were encrypted. @param encryptedBytes Encrypted bytes of the chunk. public static EncryptedChunk create(ChunkHash key, byte[] nonce, byte[] encryptedBytes) { Preconditions.checkArgument( nonce.length == NONCE_LENGTH_BYTES, "Nonce does not have the correct length."); return new EncryptedChunk(key, nonce, encryptedBytes); } private ChunkHash mKey; private byte[] mNonce; private byte[] mEncryptedBytes; private EncryptedChunk(ChunkHash key, byte[] nonce, byte[] encryptedBytes) { mKey = key; mNonce = nonce; mEncryptedBytes = encryptedBytes; } /** The SHA-256 Hmac of the plaintext bytes of the chunk.
EncryptedChunk::key
java
Reginer/aosp-android-jar
android-31/src/com/android/server/backup/encryption/chunking/EncryptedChunk.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/backup/encryption/chunking/EncryptedChunk.java
MIT
public byte[] nonce() { return mNonce; }
Constructs a new instance with the given key, nonce, and encrypted bytes. @param key SHA-256 Hmac of the chunk plaintext. @param nonce Nonce with which the bytes of the chunk were encrypted. @param encryptedBytes Encrypted bytes of the chunk. public static EncryptedChunk create(ChunkHash key, byte[] nonce, byte[] encryptedBytes) { Preconditions.checkArgument( nonce.length == NONCE_LENGTH_BYTES, "Nonce does not have the correct length."); return new EncryptedChunk(key, nonce, encryptedBytes); } private ChunkHash mKey; private byte[] mNonce; private byte[] mEncryptedBytes; private EncryptedChunk(ChunkHash key, byte[] nonce, byte[] encryptedBytes) { mKey = key; mNonce = nonce; mEncryptedBytes = encryptedBytes; } /** The SHA-256 Hmac of the plaintext bytes of the chunk. public ChunkHash key() { return mKey; } /** The nonce with which the chunk was encrypted.
EncryptedChunk::nonce
java
Reginer/aosp-android-jar
android-31/src/com/android/server/backup/encryption/chunking/EncryptedChunk.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/backup/encryption/chunking/EncryptedChunk.java
MIT
public byte[] encryptedBytes() { return mEncryptedBytes; }
Constructs a new instance with the given key, nonce, and encrypted bytes. @param key SHA-256 Hmac of the chunk plaintext. @param nonce Nonce with which the bytes of the chunk were encrypted. @param encryptedBytes Encrypted bytes of the chunk. public static EncryptedChunk create(ChunkHash key, byte[] nonce, byte[] encryptedBytes) { Preconditions.checkArgument( nonce.length == NONCE_LENGTH_BYTES, "Nonce does not have the correct length."); return new EncryptedChunk(key, nonce, encryptedBytes); } private ChunkHash mKey; private byte[] mNonce; private byte[] mEncryptedBytes; private EncryptedChunk(ChunkHash key, byte[] nonce, byte[] encryptedBytes) { mKey = key; mNonce = nonce; mEncryptedBytes = encryptedBytes; } /** The SHA-256 Hmac of the plaintext bytes of the chunk. public ChunkHash key() { return mKey; } /** The nonce with which the chunk was encrypted. public byte[] nonce() { return mNonce; } /** The encrypted bytes of the chunk.
EncryptedChunk::encryptedBytes
java
Reginer/aosp-android-jar
android-31/src/com/android/server/backup/encryption/chunking/EncryptedChunk.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/backup/encryption/chunking/EncryptedChunk.java
MIT
public void dumpDebug(ProtoOutputStream proto, long fieldId) { long token = proto.start(fieldId); proto.write(PatternMatcherProto.PATTERN, mPattern); proto.write(PatternMatcherProto.TYPE, mType); // PatternMatcherProto.PARSED_PATTERN is too much to dump, but the field is reserved to // match the current data structure. proto.end(token); }
Pattern type: the given pattern must match the end of the string it is tested against. public static final int PATTERN_SUFFIX = 4; // token types for advanced matching private static final int TOKEN_TYPE_LITERAL = 0; private static final int TOKEN_TYPE_ANY = 1; private static final int TOKEN_TYPE_SET = 2; private static final int TOKEN_TYPE_INVERSE_SET = 3; // Return for no match private static final int NO_MATCH = -1; private static final String TAG = "PatternMatcher"; // Parsed placeholders for advanced patterns private static final int PARSED_TOKEN_CHAR_SET_START = -1; private static final int PARSED_TOKEN_CHAR_SET_INVERSE_START = -2; private static final int PARSED_TOKEN_CHAR_SET_STOP = -3; private static final int PARSED_TOKEN_CHAR_ANY = -4; private static final int PARSED_MODIFIER_RANGE_START = -5; private static final int PARSED_MODIFIER_RANGE_STOP = -6; private static final int PARSED_MODIFIER_ZERO_OR_MORE = -7; private static final int PARSED_MODIFIER_ONE_OR_MORE = -8; private final String mPattern; private final int mType; private final int[] mParsedPattern; private static final int MAX_PATTERN_STORAGE = 2048; // workspace to use for building a parsed advanced pattern; private static final int[] sParsedPatternScratch = new int[MAX_PATTERN_STORAGE]; public PatternMatcher(String pattern, int type) { mPattern = pattern; mType = type; if (mType == PATTERN_ADVANCED_GLOB) { mParsedPattern = parseAndVerifyAdvancedPattern(pattern); } else { mParsedPattern = null; } } public final String getPath() { return mPattern; } public final int getType() { return mType; } public boolean match(String str) { return matchPattern(str, mPattern, mParsedPattern, mType); } public String toString() { String type = "? "; switch (mType) { case PATTERN_LITERAL: type = "LITERAL: "; break; case PATTERN_PREFIX: type = "PREFIX: "; break; case PATTERN_SIMPLE_GLOB: type = "GLOB: "; break; case PATTERN_ADVANCED_GLOB: type = "ADVANCED: "; break; case PATTERN_SUFFIX: type = "SUFFIX: "; break; } return "PatternMatcher{" + type + mPattern + "}"; } /** @hide
PatternMatcher::dumpDebug
java
Reginer/aosp-android-jar
android-31/src/android/os/PatternMatcher.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/os/PatternMatcher.java
MIT
synchronized static int[] parseAndVerifyAdvancedPattern(String pattern) { int ip = 0; final int LP = pattern.length(); int it = 0; boolean inSet = false; boolean inRange = false; boolean inCharClass = false; boolean addToParsedPattern; while (ip < LP) { if (it > MAX_PATTERN_STORAGE - 3) { throw new IllegalArgumentException("Pattern is too large!"); } char c = pattern.charAt(ip); addToParsedPattern = false; switch (c) { case '[': if (inSet) { addToParsedPattern = true; // treat as literal or char class in set } else { if (pattern.charAt(ip + 1) == '^') { sParsedPatternScratch[it++] = PARSED_TOKEN_CHAR_SET_INVERSE_START; ip++; // skip over the '^' } else { sParsedPatternScratch[it++] = PARSED_TOKEN_CHAR_SET_START; } ip++; // move to the next pattern char inSet = true; continue; } break; case ']': if (!inSet) { addToParsedPattern = true; // treat as literal outside of set } else { int parsedToken = sParsedPatternScratch[it - 1]; if (parsedToken == PARSED_TOKEN_CHAR_SET_START || parsedToken == PARSED_TOKEN_CHAR_SET_INVERSE_START) { throw new IllegalArgumentException( "You must define characters in a set."); } sParsedPatternScratch[it++] = PARSED_TOKEN_CHAR_SET_STOP; inSet = false; inCharClass = false; } break; case '{': if (!inSet) { if (it == 0 || isParsedModifier(sParsedPatternScratch[it - 1])) { throw new IllegalArgumentException("Modifier must follow a token."); } sParsedPatternScratch[it++] = PARSED_MODIFIER_RANGE_START; ip++; inRange = true; } break; case '}': if (inRange) { // only terminate the range if we're currently in one sParsedPatternScratch[it++] = PARSED_MODIFIER_RANGE_STOP; inRange = false; } break; case '*': if (!inSet) { if (it == 0 || isParsedModifier(sParsedPatternScratch[it - 1])) { throw new IllegalArgumentException("Modifier must follow a token."); } sParsedPatternScratch[it++] = PARSED_MODIFIER_ZERO_OR_MORE; } break; case '+': if (!inSet) { if (it == 0 || isParsedModifier(sParsedPatternScratch[it - 1])) { throw new IllegalArgumentException("Modifier must follow a token."); } sParsedPatternScratch[it++] = PARSED_MODIFIER_ONE_OR_MORE; } break; case '.': if (!inSet) { sParsedPatternScratch[it++] = PARSED_TOKEN_CHAR_ANY; } break; case '\\': // escape if (ip + 1 >= LP) { throw new IllegalArgumentException("Escape found at end of pattern!"); } c = pattern.charAt(++ip); addToParsedPattern = true; break; default: addToParsedPattern = true; break; } if (inSet) { if (inCharClass) { sParsedPatternScratch[it++] = c; inCharClass = false; } else { // look forward for character class if (ip + 2 < LP && pattern.charAt(ip + 1) == '-' && pattern.charAt(ip + 2) != ']') { inCharClass = true; sParsedPatternScratch[it++] = c; // set first token as lower end of range ip++; // advance past dash } else { // literal sParsedPatternScratch[it++] = c; // set first token as literal sParsedPatternScratch[it++] = c; // set second set as literal } } } else if (inRange) { int endOfSet = pattern.indexOf('}', ip); if (endOfSet < 0) { throw new IllegalArgumentException("Range not ended with '}'"); } String rangeString = pattern.substring(ip, endOfSet); int commaIndex = rangeString.indexOf(','); try { final int rangeMin; final int rangeMax; if (commaIndex < 0) { int parsedRange = Integer.parseInt(rangeString); rangeMin = rangeMax = parsedRange; } else { rangeMin = Integer.parseInt(rangeString.substring(0, commaIndex)); if (commaIndex == rangeString.length() - 1) { // e.g. {n,} (n or more) rangeMax = Integer.MAX_VALUE; } else { rangeMax = Integer.parseInt(rangeString.substring(commaIndex + 1)); } } if (rangeMin > rangeMax) { throw new IllegalArgumentException( "Range quantifier minimum is greater than maximum"); } sParsedPatternScratch[it++] = rangeMin; sParsedPatternScratch[it++] = rangeMax; } catch (NumberFormatException e) { throw new IllegalArgumentException("Range number format incorrect", e); } ip = endOfSet; continue; // don't increment ip } else if (addToParsedPattern) { sParsedPatternScratch[it++] = c; } ip++; } if (inSet) { throw new IllegalArgumentException("Set was not terminated!"); } return Arrays.copyOf(sParsedPatternScratch, it); }
Parses the advanced pattern and returns an integer array representation of it. The integer array treats each field as a character if positive and a unique token placeholder if negative. This method will throw on any pattern structure violations.
PatternMatcher::parseAndVerifyAdvancedPattern
java
Reginer/aosp-android-jar
android-31/src/android/os/PatternMatcher.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/os/PatternMatcher.java
MIT
public ConfigParser() {}
@hide
MimeHeader::ConfigParser
java
Reginer/aosp-android-jar
android-31/src/android/net/wifi/hotspot2/ConfigParser.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/net/wifi/hotspot2/ConfigParser.java
MIT
public static PasspointConfiguration parsePasspointConfig(String mimeType, byte[] data) { // Verify MIME type. if (!TextUtils.equals(mimeType, TYPE_WIFI_CONFIG)) { Log.e(TAG, "Unexpected MIME type: " + mimeType); return null; } try { // Decode the data. byte[] decodedData = Base64.decode(new String(data, StandardCharsets.ISO_8859_1), Base64.DEFAULT); Map<String, byte[]> mimeParts = parseMimeMultipartMessage(new LineNumberReader( new InputStreamReader(new ByteArrayInputStream(decodedData), StandardCharsets.ISO_8859_1))); return createPasspointConfig(mimeParts); } catch (IOException | IllegalArgumentException e) { Log.e(TAG, "Failed to parse installation file: " + e.getMessage()); return null; } }
Parse the Hotspot 2.0 Release 1 configuration data into a {@link PasspointConfiguration} object. The configuration data is a base64 encoded MIME multipart data. Below is the format of the decoded message: Content-Type: multipart/mixed; boundary={boundary} Content-Transfer-Encoding: base64 [Skip uninterested headers] --{boundary} Content-Type: application/x-passpoint-profile Content-Transfer-Encoding: base64 [base64 encoded Passpoint profile data] --{boundary} Content-Type: application/x-x509-ca-cert Content-Transfer-Encoding: base64 [base64 encoded X509 CA certificate data] --{boundary} Content-Type: application/x-pkcs12 Content-Transfer-Encoding: base64 [base64 encoded PKCS#12 ASN.1 structure containing client certificate chain] --{boundary} @param mimeType MIME type of the encoded data. @param data A base64 encoded MIME multipart message containing the Passpoint profile (required), CA (Certificate Authority) certificate (optional), and client certificate chain (optional). @return {@link PasspointConfiguration}
MimeHeader::parsePasspointConfig
java
Reginer/aosp-android-jar
android-31/src/android/net/wifi/hotspot2/ConfigParser.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/net/wifi/hotspot2/ConfigParser.java
MIT
private static PasspointConfiguration createPasspointConfig(Map<String, byte[]> mimeParts) throws IOException { byte[] profileData = mimeParts.get(TYPE_PASSPOINT_PROFILE); if (profileData == null) { throw new IOException("Missing Passpoint Profile"); } PasspointConfiguration config = PpsMoParser.parseMoText(new String(profileData)); if (config == null) { throw new IOException("Failed to parse Passpoint profile"); } // Credential is needed for storing the certificates and private client key. if (config.getCredential() == null) { throw new IOException("Passpoint profile missing credential"); } // Don't allow the installer to make changes to the update identifier. This is an // indicator of an R2 (or newer) network. if (config.getUpdateIdentifier() != Integer.MIN_VALUE) { config.setUpdateIdentifier(Integer.MIN_VALUE); } // Parse CA (Certificate Authority) certificate. byte[] caCertData = mimeParts.get(TYPE_CA_CERT); if (caCertData != null) { try { config.getCredential().setCaCertificate(parseCACert(caCertData)); } catch (CertificateException e) { throw new IOException("Failed to parse CA Certificate"); } } // Parse PKCS12 data for client private key and certificate chain. byte[] pkcs12Data = mimeParts.get(TYPE_PKCS12); if (pkcs12Data != null) { try { Pair<PrivateKey, List<X509Certificate>> clientKey = parsePkcs12(pkcs12Data); config.getCredential().setClientPrivateKey(clientKey.first); config.getCredential().setClientCertificateChain( clientKey.second.toArray(new X509Certificate[clientKey.second.size()])); } catch(GeneralSecurityException | IOException e) { throw new IOException("Failed to parse PCKS12 string"); } } return config; }
Create a {@link PasspointConfiguration} object from list of MIME (Multipurpose Internet Mail Extension) parts. @param mimeParts Map of content type and content data. @return {@link PasspointConfiguration} @throws IOException
MimeHeader::createPasspointConfig
java
Reginer/aosp-android-jar
android-31/src/android/net/wifi/hotspot2/ConfigParser.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/net/wifi/hotspot2/ConfigParser.java
MIT
private static Map<String, byte[]> parseMimeMultipartMessage(LineNumberReader in) throws IOException { // Parse the outer MIME header. MimeHeader header = parseHeaders(in); if (!TextUtils.equals(header.contentType, TYPE_MULTIPART_MIXED)) { throw new IOException("Invalid content type: " + header.contentType); } if (TextUtils.isEmpty(header.boundary)) { throw new IOException("Missing boundary string"); } if (!TextUtils.equals(header.encodingType, ENCODING_BASE64)) { throw new IOException("Unexpected encoding: " + header.encodingType); } // Read pass the first boundary string. for (;;) { String line = in.readLine(); if (line == null) { throw new IOException("Unexpected EOF before first boundary @ " + in.getLineNumber()); } if (line.equals("--" + header.boundary)) { break; } } // Parse each MIME part. Map<String, byte[]> mimeParts = new HashMap<>(); boolean isLast = false; do { MimePart mimePart = parseMimePart(in, header.boundary); mimeParts.put(mimePart.type, mimePart.data); isLast = mimePart.isLast; } while(!isLast); return mimeParts; }
Parse a MIME (Multipurpose Internet Mail Extension) multipart message from the given input stream. @param in The input stream for reading the message data @return A map of a content type and content data pair @throws IOException
MimeHeader::parseMimeMultipartMessage
java
Reginer/aosp-android-jar
android-31/src/android/net/wifi/hotspot2/ConfigParser.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/net/wifi/hotspot2/ConfigParser.java
MIT
private static MimePart parseMimePart(LineNumberReader in, String boundary) throws IOException { MimeHeader header = parseHeaders(in); // Expect encoding type to be base64. if (!TextUtils.equals(header.encodingType, ENCODING_BASE64)) { throw new IOException("Unexpected encoding type: " + header.encodingType); } // Check for a valid content type. if (!TextUtils.equals(header.contentType, TYPE_PASSPOINT_PROFILE) && !TextUtils.equals(header.contentType, TYPE_CA_CERT) && !TextUtils.equals(header.contentType, TYPE_PKCS12)) { throw new IOException("Unexpected content type: " + header.contentType); } StringBuilder text = new StringBuilder(); boolean isLast = false; String partBoundary = "--" + boundary; String endBoundary = partBoundary + "--"; for (;;) { String line = in.readLine(); if (line == null) { throw new IOException("Unexpected EOF file in body @ " + in.getLineNumber()); } // Check for boundary line. if (line.startsWith(partBoundary)) { if (line.equals(endBoundary)) { isLast = true; } break; } text.append(line); } MimePart part = new MimePart(); part.type = header.contentType; part.data = Base64.decode(text.toString(), Base64.DEFAULT); part.isLast = isLast; return part; }
Parse a MIME (Multipurpose Internet Mail Extension) part. We expect the data to be encoded in base64. @param in Input stream to read the data from @param boundary Boundary string indicate the end of the part @return {@link MimePart} @throws IOException
MimeHeader::parseMimePart
java
Reginer/aosp-android-jar
android-31/src/android/net/wifi/hotspot2/ConfigParser.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/net/wifi/hotspot2/ConfigParser.java
MIT
private static MimeHeader parseHeaders(LineNumberReader in) throws IOException { MimeHeader header = new MimeHeader(); // Read the header from the input stream. Map<String, String> headers = readHeaders(in); // Parse each header. for (Map.Entry<String, String> entry : headers.entrySet()) { switch (entry.getKey()) { case CONTENT_TYPE: Pair<String, String> value = parseContentType(entry.getValue()); header.contentType = value.first; header.boundary = value.second; break; case CONTENT_TRANSFER_ENCODING: header.encodingType = entry.getValue(); break; default: Log.d(TAG, "Ignore header: " + entry.getKey()); break; } } return header; }
Parse a MIME (Multipurpose Internet Mail Extension) header from the input stream. @param in Input stream to read from. @return {@link MimeHeader} @throws IOException
MimeHeader::parseHeaders
java
Reginer/aosp-android-jar
android-31/src/android/net/wifi/hotspot2/ConfigParser.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/net/wifi/hotspot2/ConfigParser.java
MIT
private static Pair<String, String> parseContentType(String contentType) throws IOException { String[] attributes = contentType.split(";"); String type = null; String boundary = null; if (attributes.length < 1) { throw new IOException("Invalid Content-Type: " + contentType); } // The type is always the first attribute. type = attributes[0].trim(); // Look for boundary string from the rest of the attributes. for (int i = 1; i < attributes.length; i++) { String attribute = attributes[i].trim(); if (!attribute.startsWith(BOUNDARY)) { Log.d(TAG, "Ignore Content-Type attribute: " + attributes[i]); continue; } boundary = attribute.substring(BOUNDARY.length()); // Remove the leading and trailing quote if present. if (boundary.length() > 1 && boundary.startsWith("\"") && boundary.endsWith("\"")) { boundary = boundary.substring(1, boundary.length()-1); } } return new Pair<String, String>(type, boundary); }
Parse the Content-Type header value. The value will contain the content type string and an optional boundary string separated by a ";". Below are examples of valid Content-Type header value: multipart/mixed; boundary={boundary} application/x-passpoint-profile @param contentType The Content-Type value string @return A pair of content type and boundary string @throws IOException
MimeHeader::parseContentType
java
Reginer/aosp-android-jar
android-31/src/android/net/wifi/hotspot2/ConfigParser.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/net/wifi/hotspot2/ConfigParser.java
MIT
private static Map<String, String> readHeaders(LineNumberReader in) throws IOException { Map<String, String> headers = new HashMap<>(); String line; String name = null; StringBuilder value = null; for (;;) { line = in.readLine(); if (line == null) { throw new IOException("Missing line @ " + in.getLineNumber()); } // End of headers section. if (line.length() == 0 || line.trim().length() == 0) { // Save the previous header line. if (name != null) { headers.put(name, value.toString()); } break; } int nameEnd = line.indexOf(':'); if (nameEnd < 0) { if (value != null) { // Continuation line for the header value. value.append(' ').append(line.trim()); } else { throw new IOException("Bad header line: '" + line + "' @ " + in.getLineNumber()); } } else { // New header line detected, make sure it doesn't start with a whitespace. if (Character.isWhitespace(line.charAt(0))) { throw new IOException("Illegal blank prefix in header line '" + line + "' @ " + in.getLineNumber()); } if (name != null) { // Save the previous header line. headers.put(name, value.toString()); } // Setup the current header line. name = line.substring(0, nameEnd).trim(); value = new StringBuilder(); value.append(line.substring(nameEnd+1).trim()); } } return headers; }
Read the headers from the given input stream. The header section is terminated by an empty line. @param in The input stream to read from @return Map of key-value pairs. @throws IOException
MimeHeader::readHeaders
java
Reginer/aosp-android-jar
android-31/src/android/net/wifi/hotspot2/ConfigParser.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/net/wifi/hotspot2/ConfigParser.java
MIT
private static X509Certificate parseCACert(byte[] octets) throws CertificateException { CertificateFactory factory = CertificateFactory.getInstance("X.509"); return (X509Certificate) factory.generateCertificate(new ByteArrayInputStream(octets)); }
Parse a CA (Certificate Authority) certificate data and convert it to a X509Certificate object. @param octets Certificate data @return X509Certificate @throws CertificateException
MimeHeader::parseCACert
java
Reginer/aosp-android-jar
android-31/src/android/net/wifi/hotspot2/ConfigParser.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/net/wifi/hotspot2/ConfigParser.java
MIT
public PendingUi(@NonNull IBinder token, int sessionId, @NonNull IAutoFillManagerClient client) { mToken = token; mState = STATE_CREATED; this.sessionId = sessionId; this.client = client; }
Default constructor. @param token token used to identify this pending UI.
PendingUi::PendingUi
java
Reginer/aosp-android-jar
android-31/src/com/android/server/autofill/ui/PendingUi.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/autofill/ui/PendingUi.java
MIT
public void setState(int state) { mState = state; }
Sets the current lifecycle state.
PendingUi::setState
java
Reginer/aosp-android-jar
android-31/src/com/android/server/autofill/ui/PendingUi.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/autofill/ui/PendingUi.java
MIT
public int getState() { return mState; }
Gets the current lifecycle state.
PendingUi::getState
java
Reginer/aosp-android-jar
android-31/src/com/android/server/autofill/ui/PendingUi.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/autofill/ui/PendingUi.java
MIT
public boolean matches(IBinder token) { return mToken.equals(token); }
Determines whether the given token matches the token used to identify this pending UI.
PendingUi::matches
java
Reginer/aosp-android-jar
android-31/src/com/android/server/autofill/ui/PendingUi.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/autofill/ui/PendingUi.java
MIT
public static float getAnimatableValueForScaleFactor(float scale) { return scale * (1f / DynamicAnimation.MIN_VISIBLE_CHANGE_SCALE); }
Return the value to animate SCALE_X or SCALE_Y to in order to achieve the desired scale factor.
AnimatableScaleMatrix::getAnimatableValueForScaleFactor
java
Reginer/aosp-android-jar
android-33/src/com/android/wm/shell/bubbles/animation/AnimatableScaleMatrix.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/wm/shell/bubbles/animation/AnimatableScaleMatrix.java
MIT
public final CancellationSignal requestRebind( @NonNull NotificationEntry entry, @Nullable BindCallback callback) { CancellationSignal signal = new CancellationSignal(); if (mBindRequestListener != null) { mBindRequestListener.onBindRequest(entry, signal, callback); } return signal; }
Notifies the listener that some parameters/state has changed for some notification and that content needs to be bound again. The caller can also specify a callback for when the entire bind pipeline completes, i.e. when the change is fully propagated to the final view. The caller can cancel this callback with the returned cancellation signal. @param callback callback after bind completely finishes @return cancellation signal to cancel callback
BindRequester::requestRebind
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/statusbar/notification/row/BindRequester.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/statusbar/notification/row/BindRequester.java
MIT
private void assertSetEnabled(Context context, String overlayPackage, boolean eanabled) throws Exception { sOverlayManager.setEnabled(overlayPackage, true, UserHandle.SYSTEM); // Wait for the overlay changes to propagate FutureTask<Boolean> task = new FutureTask<>(() -> { while (true) { for (String path : context.getAssets().getApkPaths()) { if (eanabled == path.contains(overlayPackage)) { return true; } } } }); sExecutor.execute(task); assertTrue("Failed to load overlay " + overlayPackage, task.get(20, TimeUnit.SECONDS)); }
Enables the overlay and waits for the APK path change sto be propagated to the context AssetManager.
OverlayManagerPerfTest::assertSetEnabled
java
Reginer/aosp-android-jar
android-33/src/android/app/OverlayManagerPerfTest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/OverlayManagerPerfTest.java
MIT
public WifiBatteryStats(long loggingDurationMillis, long kernelActiveTimeMillis, long numPacketsTx, long numBytesTx, long numPacketsRx, long numBytesRx, long sleepTimeMillis, long scanTimeMillis, long idleTimeMillis, long rxTimeMillis, long txTimeMillis, long energyConsumedMaMillis, long appScanRequestCount, @NonNull long[] timeInStateMillis, @NonNull long [] timeInRxSignalStrengthLevelMillis, @NonNull long[] timeInSupplicantStateMillis, long monitoredRailChargeConsumedMaMillis) { mLoggingDurationMillis = loggingDurationMillis; mKernelActiveTimeMillis = kernelActiveTimeMillis; mNumPacketsTx = numPacketsTx; mNumBytesTx = numBytesTx; mNumPacketsRx = numPacketsRx; mNumBytesRx = numBytesRx; mSleepTimeMillis = sleepTimeMillis; mScanTimeMillis = scanTimeMillis; mIdleTimeMillis = idleTimeMillis; mRxTimeMillis = rxTimeMillis; mTxTimeMillis = txTimeMillis; mEnergyConsumedMaMillis = energyConsumedMaMillis; mAppScanRequestCount = appScanRequestCount; mTimeInStateMillis = Arrays.copyOfRange( timeInStateMillis, 0, Math.min(timeInStateMillis.length, NUM_WIFI_STATES)); mTimeInRxSignalStrengthLevelMillis = Arrays.copyOfRange( timeInRxSignalStrengthLevelMillis, 0, Math.min(timeInRxSignalStrengthLevelMillis.length, NUM_WIFI_SIGNAL_STRENGTH_BINS)); mTimeInSupplicantStateMillis = Arrays.copyOfRange( timeInSupplicantStateMillis, 0, Math.min(timeInSupplicantStateMillis.length, NUM_WIFI_SUPPL_STATES)); mMonitoredRailChargeConsumedMaMillis = monitoredRailChargeConsumedMaMillis; }
Class for holding Wifi related battery stats @hide @SystemApi public final class WifiBatteryStats implements Parcelable { private final long mLoggingDurationMillis; private final long mKernelActiveTimeMillis; private final long mNumPacketsTx; private final long mNumBytesTx; private final long mNumPacketsRx; private final long mNumBytesRx; private final long mSleepTimeMillis; private final long mScanTimeMillis; private final long mIdleTimeMillis; private final long mRxTimeMillis; private final long mTxTimeMillis; private final long mEnergyConsumedMaMillis; private final long mAppScanRequestCount; private final long[] mTimeInStateMillis; private final long[] mTimeInSupplicantStateMillis; private final long[] mTimeInRxSignalStrengthLevelMillis; private final long mMonitoredRailChargeConsumedMaMillis; public static final @NonNull Parcelable.Creator<WifiBatteryStats> CREATOR = new Parcelable.Creator<WifiBatteryStats>() { public WifiBatteryStats createFromParcel(Parcel in) { long loggingDurationMillis = in.readLong(); long kernelActiveTimeMillis = in.readLong(); long numPacketsTx = in.readLong(); long numBytesTx = in.readLong(); long numPacketsRx = in.readLong(); long numBytesRx = in.readLong(); long sleepTimeMillis = in.readLong(); long scanTimeMillis = in.readLong(); long idleTimeMillis = in.readLong(); long rxTimeMillis = in.readLong(); long txTimeMillis = in.readLong(); long energyConsumedMaMillis = in.readLong(); long appScanRequestCount = in.readLong(); long[] timeInStateMillis = in.createLongArray(); long[] timeInRxSignalStrengthLevelMillis = in.createLongArray(); long[] timeInSupplicantStateMillis = in.createLongArray(); long monitoredRailChargeConsumedMaMillis = in.readLong(); return new WifiBatteryStats(loggingDurationMillis, kernelActiveTimeMillis, numPacketsTx, numBytesTx, numPacketsRx, numBytesRx, sleepTimeMillis, scanTimeMillis, idleTimeMillis, rxTimeMillis, txTimeMillis, energyConsumedMaMillis, appScanRequestCount, timeInStateMillis, timeInRxSignalStrengthLevelMillis, timeInSupplicantStateMillis, monitoredRailChargeConsumedMaMillis); } public WifiBatteryStats[] newArray(int size) { return new WifiBatteryStats[size]; } }; @Override public int describeContents() { return 0; } @Override public void writeToParcel(@NonNull Parcel out, int flags) { out.writeLong(mLoggingDurationMillis); out.writeLong(mKernelActiveTimeMillis); out.writeLong(mNumPacketsTx); out.writeLong(mNumBytesTx); out.writeLong(mNumPacketsRx); out.writeLong(mNumBytesRx); out.writeLong(mSleepTimeMillis); out.writeLong(mScanTimeMillis); out.writeLong(mIdleTimeMillis); out.writeLong(mRxTimeMillis); out.writeLong(mTxTimeMillis); out.writeLong(mEnergyConsumedMaMillis); out.writeLong(mAppScanRequestCount); out.writeLongArray(mTimeInStateMillis); out.writeLongArray(mTimeInRxSignalStrengthLevelMillis); out.writeLongArray(mTimeInSupplicantStateMillis); out.writeLong(mMonitoredRailChargeConsumedMaMillis); } @Override public boolean equals(@Nullable Object other) { if (!(other instanceof WifiBatteryStats)) return false; if (other == this) return true; WifiBatteryStats otherStats = (WifiBatteryStats) other; return this.mLoggingDurationMillis == otherStats.mLoggingDurationMillis && this.mKernelActiveTimeMillis == otherStats.mKernelActiveTimeMillis && this.mNumPacketsTx == otherStats.mNumPacketsTx && this.mNumBytesTx == otherStats.mNumBytesTx && this.mNumPacketsRx == otherStats.mNumPacketsRx && this.mNumBytesRx == otherStats.mNumBytesRx && this.mSleepTimeMillis == otherStats.mSleepTimeMillis && this.mScanTimeMillis == otherStats.mScanTimeMillis && this.mIdleTimeMillis == otherStats.mIdleTimeMillis && this.mRxTimeMillis == otherStats.mRxTimeMillis && this.mTxTimeMillis == otherStats.mTxTimeMillis && this.mEnergyConsumedMaMillis == otherStats.mEnergyConsumedMaMillis && this.mAppScanRequestCount == otherStats.mAppScanRequestCount && Arrays.equals(this.mTimeInStateMillis, otherStats.mTimeInStateMillis) && Arrays.equals(this.mTimeInSupplicantStateMillis, otherStats.mTimeInSupplicantStateMillis) && Arrays.equals(this.mTimeInRxSignalStrengthLevelMillis, otherStats.mTimeInRxSignalStrengthLevelMillis) && this.mMonitoredRailChargeConsumedMaMillis == otherStats.mMonitoredRailChargeConsumedMaMillis; } @Override public int hashCode() { return Objects.hash(mLoggingDurationMillis, mKernelActiveTimeMillis, mNumPacketsTx, mNumBytesTx, mNumPacketsRx, mNumBytesRx, mSleepTimeMillis, mScanTimeMillis, mIdleTimeMillis, mRxTimeMillis, mTxTimeMillis, mEnergyConsumedMaMillis, mAppScanRequestCount, Arrays.hashCode(mTimeInStateMillis), Arrays.hashCode(mTimeInSupplicantStateMillis), Arrays.hashCode(mTimeInRxSignalStrengthLevelMillis), mMonitoredRailChargeConsumedMaMillis); } /** @hide
WifiBatteryStats::WifiBatteryStats
java
Reginer/aosp-android-jar
android-33/src/android/os/connectivity/WifiBatteryStats.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/connectivity/WifiBatteryStats.java
MIT
public long getLoggingDurationMillis() { return mLoggingDurationMillis; }
Returns the duration for which these wifi stats were collected. @return Duration of stats collection in millis.
WifiBatteryStats::getLoggingDurationMillis
java
Reginer/aosp-android-jar
android-33/src/android/os/connectivity/WifiBatteryStats.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/connectivity/WifiBatteryStats.java
MIT
public long getKernelActiveTimeMillis() { return mKernelActiveTimeMillis; }
Returns the duration for which the kernel was active within {@link #getLoggingDurationMillis()}. @return Duration of kernel active time in millis.
WifiBatteryStats::getKernelActiveTimeMillis
java
Reginer/aosp-android-jar
android-33/src/android/os/connectivity/WifiBatteryStats.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/connectivity/WifiBatteryStats.java
MIT
public long getNumPacketsTx() { return mNumPacketsTx; }
Returns the number of packets transmitted over wifi within {@link #getLoggingDurationMillis()}. @return Number of packets transmitted.
WifiBatteryStats::getNumPacketsTx
java
Reginer/aosp-android-jar
android-33/src/android/os/connectivity/WifiBatteryStats.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/connectivity/WifiBatteryStats.java
MIT
public long getNumBytesTx() { return mNumBytesTx; }
Returns the number of bytes transmitted over wifi within {@link #getLoggingDurationMillis()}. @return Number of bytes transmitted.
WifiBatteryStats::getNumBytesTx
java
Reginer/aosp-android-jar
android-33/src/android/os/connectivity/WifiBatteryStats.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/connectivity/WifiBatteryStats.java
MIT
public long getNumPacketsRx() { return mNumPacketsRx; }
Returns the number of packets received over wifi within {@link #getLoggingDurationMillis()}. @return Number of packets received.
WifiBatteryStats::getNumPacketsRx
java
Reginer/aosp-android-jar
android-33/src/android/os/connectivity/WifiBatteryStats.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/connectivity/WifiBatteryStats.java
MIT
public long getNumBytesRx() { return mNumBytesRx; }
Returns the number of bytes received over wifi within {@link #getLoggingDurationMillis()}. @return Number of bytes received.
WifiBatteryStats::getNumBytesRx
java
Reginer/aosp-android-jar
android-33/src/android/os/connectivity/WifiBatteryStats.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/connectivity/WifiBatteryStats.java
MIT
public long getSleepTimeMillis() { return mSleepTimeMillis; }
Returns the duration for which the device was sleeping within {@link #getLoggingDurationMillis()}. @return Duration of sleep time in millis.
WifiBatteryStats::getSleepTimeMillis
java
Reginer/aosp-android-jar
android-33/src/android/os/connectivity/WifiBatteryStats.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/connectivity/WifiBatteryStats.java
MIT
public long getScanTimeMillis() { return mScanTimeMillis; }
Returns the duration for which the device was wifi scanning within {@link #getLoggingDurationMillis()}. @return Duration of wifi scanning time in millis.
WifiBatteryStats::getScanTimeMillis
java
Reginer/aosp-android-jar
android-33/src/android/os/connectivity/WifiBatteryStats.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/connectivity/WifiBatteryStats.java
MIT
public long getIdleTimeMillis() { return mIdleTimeMillis; }
Returns the duration for which the device was idle within {@link #getLoggingDurationMillis()}. @return Duration of idle time in millis.
WifiBatteryStats::getIdleTimeMillis
java
Reginer/aosp-android-jar
android-33/src/android/os/connectivity/WifiBatteryStats.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/connectivity/WifiBatteryStats.java
MIT
public long getRxTimeMillis() { return mRxTimeMillis; }
Returns the duration for which the device was receiving over wifi within {@link #getLoggingDurationMillis()}. @return Duration of wifi reception time in millis.
WifiBatteryStats::getRxTimeMillis
java
Reginer/aosp-android-jar
android-33/src/android/os/connectivity/WifiBatteryStats.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/connectivity/WifiBatteryStats.java
MIT
public long getTxTimeMillis() { return mTxTimeMillis; }
Returns the duration for which the device was transmitting over wifi within {@link #getLoggingDurationMillis()}. @return Duration of wifi transmission time in millis.
WifiBatteryStats::getTxTimeMillis
java
Reginer/aosp-android-jar
android-33/src/android/os/connectivity/WifiBatteryStats.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/connectivity/WifiBatteryStats.java
MIT
public long getEnergyConsumedMaMillis() { return mEnergyConsumedMaMillis; }
Returns an estimation of energy consumed in millis by wifi chip within {@link #getLoggingDurationMillis()}. @return Energy consumed in millis.
WifiBatteryStats::getEnergyConsumedMaMillis
java
Reginer/aosp-android-jar
android-33/src/android/os/connectivity/WifiBatteryStats.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/connectivity/WifiBatteryStats.java
MIT
public long getAppScanRequestCount() { return mAppScanRequestCount; }
Returns the number of app initiated wifi scans within {@link #getLoggingDurationMillis()}. @return Number of app scans.
WifiBatteryStats::getAppScanRequestCount
java
Reginer/aosp-android-jar
android-33/src/android/os/connectivity/WifiBatteryStats.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/connectivity/WifiBatteryStats.java
MIT
public long getMonitoredRailChargeConsumedMaMillis() { return mMonitoredRailChargeConsumedMaMillis; }
Returns the energy consumed by wifi chip within {@link #getLoggingDurationMillis()}. @return Energy consumed in millis.
WifiBatteryStats::getMonitoredRailChargeConsumedMaMillis
java
Reginer/aosp-android-jar
android-33/src/android/os/connectivity/WifiBatteryStats.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/connectivity/WifiBatteryStats.java
MIT
public LocusId(@NonNull String id) { mId = Preconditions.checkStringNotEmpty(id, "id cannot be empty"); }
Default constructor. @throws IllegalArgumentException if {@code id} is empty or {@code null}.
LocusId::LocusId
java
Reginer/aosp-android-jar
android-34/src/android/content/LocusId.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/LocusId.java
MIT
public void dump(@NonNull PrintWriter pw) { pw.print("id:"); pw.println(getSanitizedId()); }
Gets the canonical {@code id} associated with the locus. @NonNull public String getId() { return mId; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((mId == null) ? 0 : mId.hashCode()); return result; } @Override public boolean equals(@Nullable Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final LocusId other = (LocusId) obj; if (mId == null) { if (other.mId != null) return false; } else { if (!mId.equals(other.mId)) return false; } return true; } @Override public String toString() { return "LocusId[" + getSanitizedId() + "]"; } /** @hide
LocusId::dump
java
Reginer/aosp-android-jar
android-34/src/android/content/LocusId.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/LocusId.java
MIT
public int getVendorId() { return mVendorId; }
The vendor id uniquely identifies the company who manufactured the device.
VirtualInputDeviceConfig::getVendorId
java
Reginer/aosp-android-jar
android-34/src/android/hardware/input/VirtualInputDeviceConfig.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/hardware/input/VirtualInputDeviceConfig.java
MIT
public int getProductId() { return mProductId; }
The product id uniquely identifies which product within the address space of a given vendor, identified by the device's vendor id.
VirtualInputDeviceConfig::getProductId
java
Reginer/aosp-android-jar
android-34/src/android/hardware/input/VirtualInputDeviceConfig.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/hardware/input/VirtualInputDeviceConfig.java
MIT
public int getAssociatedDisplayId() { return mAssociatedDisplayId; }
The associated display ID of the virtual input device.
VirtualInputDeviceConfig::getAssociatedDisplayId
java
Reginer/aosp-android-jar
android-34/src/android/hardware/input/VirtualInputDeviceConfig.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/hardware/input/VirtualInputDeviceConfig.java
MIT
T self() { return (T) this; }
Each subclass should return itself to allow the builder to chain properly
Builder::self
java
Reginer/aosp-android-jar
android-34/src/android/hardware/input/VirtualInputDeviceConfig.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/hardware/input/VirtualInputDeviceConfig.java
MIT
void onBackupFinished(int status) { BackupObserverUtils.sendBackupFinished(mObserver, status); }
This is a bit different from {@link #onTaskFinished()}, it's only called if there is no full-backup requests associated with the key-value task.
KeyValueBackupReporter::onBackupFinished
java
Reginer/aosp-android-jar
android-32/src/com/android/server/backup/keyvalue/KeyValueBackupReporter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/backup/keyvalue/KeyValueBackupReporter.java
MIT
Striped64() { }
Package-private default constructor.
Striped64::Striped64
java
Reginer/aosp-android-jar
android-34/src/java/util/concurrent/atomic/Striped64.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/concurrent/atomic/Striped64.java
MIT
final boolean casBase(long cmp, long val) { return BASE.weakCompareAndSetRelease(this, cmp, val); }
CASes the base field.
Striped64::casBase
java
Reginer/aosp-android-jar
android-34/src/java/util/concurrent/atomic/Striped64.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/concurrent/atomic/Striped64.java
MIT
final boolean casCellsBusy() { return CELLSBUSY.compareAndSet(this, 0, 1); }
CASes the cellsBusy field from 0 to 1 to acquire lock.
Striped64::casCellsBusy
java
Reginer/aosp-android-jar
android-34/src/java/util/concurrent/atomic/Striped64.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/concurrent/atomic/Striped64.java
MIT
static final int getProbe() { return (int) THREAD_PROBE.get(Thread.currentThread()); }
Returns the probe value for the current thread. Duplicated from ThreadLocalRandom because of packaging restrictions.
Striped64::getProbe
java
Reginer/aosp-android-jar
android-34/src/java/util/concurrent/atomic/Striped64.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/concurrent/atomic/Striped64.java
MIT
static final int advanceProbe(int probe) { probe ^= probe << 13; // xorshift probe ^= probe >>> 17; probe ^= probe << 5; THREAD_PROBE.set(Thread.currentThread(), probe); return probe; }
Pseudo-randomly advances and records the given probe value for the given thread. Duplicated from ThreadLocalRandom because of packaging restrictions.
Striped64::advanceProbe
java
Reginer/aosp-android-jar
android-34/src/java/util/concurrent/atomic/Striped64.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/concurrent/atomic/Striped64.java
MIT
final void longAccumulate(long x, LongBinaryOperator fn, boolean wasUncontended, int index) { if (index == 0) { ThreadLocalRandom.current(); // force initialization index = getProbe(); wasUncontended = true; } for (boolean collide = false;;) { // True if last slot nonempty Cell[] cs; Cell c; int n; long v; if ((cs = cells) != null && (n = cs.length) > 0) { if ((c = cs[(n - 1) & index]) == null) { if (cellsBusy == 0) { // Try to attach new Cell Cell r = new Cell(x); // Optimistically create if (cellsBusy == 0 && casCellsBusy()) { try { // Recheck under lock Cell[] rs; int m, j; if ((rs = cells) != null && (m = rs.length) > 0 && rs[j = (m - 1) & index] == null) { rs[j] = r; break; } } finally { cellsBusy = 0; } continue; // Slot is now non-empty } } collide = false; } else if (!wasUncontended) // CAS already known to fail wasUncontended = true; // Continue after rehash else if (c.cas(v = c.value, (fn == null) ? v + x : fn.applyAsLong(v, x))) break; else if (n >= NCPU || cells != cs) collide = false; // At max size or stale else if (!collide) collide = true; else if (cellsBusy == 0 && casCellsBusy()) { try { if (cells == cs) // Expand table unless stale cells = Arrays.copyOf(cs, n << 1); } finally { cellsBusy = 0; } collide = false; continue; // Retry with expanded table } index = advanceProbe(index); } else if (cellsBusy == 0 && cells == cs && casCellsBusy()) { try { // Initialize table if (cells == cs) { Cell[] rs = new Cell[2]; rs[index & 1] = new Cell(x); cells = rs; break; } } finally { cellsBusy = 0; } } // Fall back on using base else if (casBase(v = base, (fn == null) ? v + x : fn.applyAsLong(v, x))) break; } }
Handles cases of updates involving initialization, resizing, creating new Cells, and/or contention. See above for explanation. This method suffers the usual non-modularity problems of optimistic retry code, relying on rechecked sets of reads. @param x the value @param fn the update function, or null for add (this convention avoids the need for an extra field or function in LongAdder). @param wasUncontended false if CAS failed before call @param index thread index from getProbe
Striped64::longAccumulate
java
Reginer/aosp-android-jar
android-34/src/java/util/concurrent/atomic/Striped64.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/concurrent/atomic/Striped64.java
MIT
final void doubleAccumulate(double x, DoubleBinaryOperator fn, boolean wasUncontended, int index) { if (index == 0) { ThreadLocalRandom.current(); // force initialization index = getProbe(); wasUncontended = true; } for (boolean collide = false;;) { // True if last slot nonempty Cell[] cs; Cell c; int n; long v; if ((cs = cells) != null && (n = cs.length) > 0) { if ((c = cs[(n - 1) & index]) == null) { if (cellsBusy == 0) { // Try to attach new Cell Cell r = new Cell(Double.doubleToRawLongBits(x)); if (cellsBusy == 0 && casCellsBusy()) { try { // Recheck under lock Cell[] rs; int m, j; if ((rs = cells) != null && (m = rs.length) > 0 && rs[j = (m - 1) & index] == null) { rs[j] = r; break; } } finally { cellsBusy = 0; } continue; // Slot is now non-empty } } collide = false; } else if (!wasUncontended) // CAS already known to fail wasUncontended = true; // Continue after rehash else if (c.cas(v = c.value, apply(fn, v, x))) break; else if (n >= NCPU || cells != cs) collide = false; // At max size or stale else if (!collide) collide = true; else if (cellsBusy == 0 && casCellsBusy()) { try { if (cells == cs) // Expand table unless stale cells = Arrays.copyOf(cs, n << 1); } finally { cellsBusy = 0; } collide = false; continue; // Retry with expanded table } index = advanceProbe(index); } else if (cellsBusy == 0 && cells == cs && casCellsBusy()) { try { // Initialize table if (cells == cs) { Cell[] rs = new Cell[2]; rs[index & 1] = new Cell(Double.doubleToRawLongBits(x)); cells = rs; break; } } finally { cellsBusy = 0; } } // Fall back on using base else if (casBase(v = base, apply(fn, v, x))) break; } }
Same as longAccumulate, but injecting long/double conversions in too many places to sensibly merge with long version, given the low-overhead requirements of this class. So must instead be maintained by copy/paste/adapt.
Striped64::doubleAccumulate
java
Reginer/aosp-android-jar
android-34/src/java/util/concurrent/atomic/Striped64.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/concurrent/atomic/Striped64.java
MIT
public @Nullable String onChoosePrivateKeyAlias(@NonNull Context context, @NonNull Intent intent, int uid, @Nullable Uri uri, @Nullable String alias) { throw new UnsupportedOperationException("onChoosePrivateKeyAlias should be implemented"); }
Allows this receiver to select the alias for a private key and certificate pair for authentication. If this method returns null, the default {@link android.app.Activity} will be shown that lets the user pick a private key and certificate pair. If this method returns {@link KeyChain#KEY_ALIAS_SELECTION_DENIED}, the default {@link android.app.Activity} will not be shown and the user will not be allowed to pick anything. And the app, that called {@link KeyChain#choosePrivateKeyAlias}, will receive {@code null} back. <p> This callback is only applicable if the delegated app has {@link DevicePolicyManager#DELEGATION_CERT_SELECTION} capability. Additionally, it must declare an intent filter for {@link DeviceAdminReceiver#ACTION_CHOOSE_PRIVATE_KEY_ALIAS} in the receiver's manifest in order to receive this callback. The default implementation simply throws {@link UnsupportedOperationException}. @param context The running context as per {@link #onReceive}. @param intent The received intent as per {@link #onReceive}. @param uid The uid of the app asking for the private key and certificate pair. @param uri The URI to authenticate, may be null. @param alias The alias preselected by the client, or null. @return The private key alias to return and grant access to. @see KeyChain#choosePrivateKeyAlias
DelegatedAdminReceiver::onChoosePrivateKeyAlias
java
Reginer/aosp-android-jar
android-35/src/android/app/admin/DelegatedAdminReceiver.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/app/admin/DelegatedAdminReceiver.java
MIT
public void onNetworkLogsAvailable(@NonNull Context context, @NonNull Intent intent, long batchToken, @IntRange(from = 1) int networkLogsCount) { throw new UnsupportedOperationException("onNetworkLogsAvailable should be implemented"); }
Called each time a new batch of network logs can be retrieved. This callback method will only ever be called when network logging is enabled. The logs can only be retrieved while network logging is enabled. <p>If a secondary user or profile is created, this callback won't be received until all users become affiliated again (even if network logging is enabled). It will also no longer be possible to retrieve the network logs batch with the most recent {@code batchToken} provided by this callback. See {@link DevicePolicyManager#setAffiliationIds}. <p> This callback is only applicable if the delegated app has {@link DevicePolicyManager#DELEGATION_NETWORK_LOGGING} capability. Additionally, it must declare an intent filter for {@link DeviceAdminReceiver#ACTION_NETWORK_LOGS_AVAILABLE} in the receiver's manifest in order to receive this callback. The default implementation simply throws {@link UnsupportedOperationException}. <p> This callback is triggered by a foreground broadcast and the app should ensure that any long-running work is not executed synchronously inside the callback. @param context The running context as per {@link #onReceive}. @param intent The received intent as per {@link #onReceive}. @param batchToken The token representing the current batch of network logs. @param networkLogsCount The total count of events in the current batch of network logs. @see DevicePolicyManager#retrieveNetworkLogs
DelegatedAdminReceiver::onNetworkLogsAvailable
java
Reginer/aosp-android-jar
android-35/src/android/app/admin/DelegatedAdminReceiver.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/app/admin/DelegatedAdminReceiver.java
MIT
public void onSecurityLogsAvailable(@NonNull Context context, @NonNull Intent intent) { throw new UnsupportedOperationException("onSecurityLogsAvailable should be implemented"); }
Called each time a new batch of security logs can be retrieved. This callback method will only ever be called when security logging is enabled. The logs can only be retrieved while security logging is enabled. <p>If a secondary user or profile is created, this callback won't be received until all users become affiliated again (even if security logging is enabled). It will also no longer be possible to retrieve the security logs. See {@link DevicePolicyManager#setAffiliationIds}. <p> This callback is only applicable if the delegated app has {@link DevicePolicyManager#DELEGATION_SECURITY_LOGGING} capability. Additionally, it must declare an intent filter for {@link DeviceAdminReceiver#ACTION_SECURITY_LOGS_AVAILABLE} in the receiver's manifest in order to receive this callback. The default implementation simply throws {@link UnsupportedOperationException}. <p> This callback is triggered by a foreground broadcast and the app should ensure that any long-running work is not executed synchronously inside the callback. @param context The running context as per {@link #onReceive}. @param intent The received intent as per {@link #onReceive}. @see DevicePolicyManager#retrieveSecurityLogs
DelegatedAdminReceiver::onSecurityLogsAvailable
java
Reginer/aosp-android-jar
android-35/src/android/app/admin/DelegatedAdminReceiver.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/app/admin/DelegatedAdminReceiver.java
MIT
MediaDevice getCurrentConnectedDevice() { return mCurrentConnectedDevice; }
Get current device that played media. @return MediaDevice
InfoMediaManager::getCurrentConnectedDevice
java
Reginer/aosp-android-jar
android-33/src/com/android/settingslib/media/InfoMediaManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/media/InfoMediaManager.java
MIT
boolean connectDeviceWithoutPackageName(MediaDevice device) { boolean isConnected = false; final RoutingSessionInfo info = mRouterManager.getSystemRoutingSession(null); if (info != null) { mRouterManager.transfer(info, device.mRouteInfo); isConnected = true; } return isConnected; }
Transfer MediaDevice for media without package name.
InfoMediaManager::connectDeviceWithoutPackageName
java
Reginer/aosp-android-jar
android-33/src/com/android/settingslib/media/InfoMediaManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/media/InfoMediaManager.java
MIT
boolean addDeviceToPlayMedia(MediaDevice device) { if (TextUtils.isEmpty(mPackageName)) { Log.w(TAG, "addDeviceToPlayMedia() package name is null or empty!"); return false; } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null && info.getSelectableRoutes().contains(device.mRouteInfo.getId())) { mRouterManager.selectRoute(info, device.mRouteInfo); return true; } Log.w(TAG, "addDeviceToPlayMedia() Ignoring selecting a non-selectable device : " + device.getName()); return false; }
Add a MediaDevice to let it play current media. @param device MediaDevice @return If add device successful return {@code true}, otherwise return {@code false}
InfoMediaManager::addDeviceToPlayMedia
java
Reginer/aosp-android-jar
android-33/src/com/android/settingslib/media/InfoMediaManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/media/InfoMediaManager.java
MIT
boolean removeDeviceFromPlayMedia(MediaDevice device) { if (TextUtils.isEmpty(mPackageName)) { Log.w(TAG, "removeDeviceFromMedia() package name is null or empty!"); return false; } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null && info.getSelectedRoutes().contains(device.mRouteInfo.getId())) { mRouterManager.deselectRoute(info, device.mRouteInfo); return true; } Log.w(TAG, "removeDeviceFromMedia() Ignoring deselecting a non-deselectable device : " + device.getName()); return false; }
Remove a {@code device} from current media. @param device MediaDevice @return If device stop successful return {@code true}, otherwise return {@code false}
InfoMediaManager::removeDeviceFromPlayMedia
java
Reginer/aosp-android-jar
android-33/src/com/android/settingslib/media/InfoMediaManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/media/InfoMediaManager.java
MIT
boolean releaseSession() { if (TextUtils.isEmpty(mPackageName)) { Log.w(TAG, "releaseSession() package name is null or empty!"); return false; } final RoutingSessionInfo sessionInfo = getRoutingSessionInfo(); if (sessionInfo != null) { mRouterManager.releaseSession(sessionInfo); return true; } Log.w(TAG, "releaseSession() Ignoring release session : " + mPackageName); return false; }
Release session to stop playing media on MediaDevice.
InfoMediaManager::releaseSession
java
Reginer/aosp-android-jar
android-33/src/com/android/settingslib/media/InfoMediaManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/media/InfoMediaManager.java
MIT