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 |
---|---|---|---|---|---|---|---|
private JsonWriter close(JsonScope empty, JsonScope nonempty, String closeBracket)
throws IOException {
JsonScope context = peek();
if (context != nonempty && context != empty) {
throw new IllegalStateException("Nesting problem: " + stack);
}
stack.remove(stack.size() - 1);
if (context == nonempty) {
newline();
}
out.write(closeBracket);
return this;
} |
Closes the current scope by appending any necessary whitespace and the
given bracket.
| JsonWriter::close | java | Reginer/aosp-android-jar | android-33/src/android/util/JsonWriter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/JsonWriter.java | MIT |
private JsonScope peek() {
return stack.get(stack.size() - 1);
} |
Returns the value on the top of the stack.
| JsonWriter::peek | java | Reginer/aosp-android-jar | android-33/src/android/util/JsonWriter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/JsonWriter.java | MIT |
private void replaceTop(JsonScope topOfStack) {
stack.set(stack.size() - 1, topOfStack);
} |
Replace the value on the top of the stack with the given value.
| JsonWriter::replaceTop | java | Reginer/aosp-android-jar | android-33/src/android/util/JsonWriter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/JsonWriter.java | MIT |
public JsonWriter name(String name) throws IOException {
if (name == null) {
throw new NullPointerException("name == null");
}
beforeName();
string(name);
return this;
} |
Encodes the property name.
@param name the name of the forthcoming value. May not be null.
@return this writer.
| JsonWriter::name | java | Reginer/aosp-android-jar | android-33/src/android/util/JsonWriter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/JsonWriter.java | MIT |
public JsonWriter value(String value) throws IOException {
if (value == null) {
return nullValue();
}
beforeValue(false);
string(value);
return this;
} |
Encodes {@code value}.
@param value the literal string value, or null to encode a null literal.
@return this writer.
| JsonWriter::value | java | Reginer/aosp-android-jar | android-33/src/android/util/JsonWriter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/JsonWriter.java | MIT |
public JsonWriter nullValue() throws IOException {
beforeValue(false);
out.write("null");
return this;
} |
Encodes {@code null}.
@return this writer.
| JsonWriter::nullValue | java | Reginer/aosp-android-jar | android-33/src/android/util/JsonWriter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/JsonWriter.java | MIT |
public JsonWriter value(boolean value) throws IOException {
beforeValue(false);
out.write(value ? "true" : "false");
return this;
} |
Encodes {@code value}.
@return this writer.
| JsonWriter::value | java | Reginer/aosp-android-jar | android-33/src/android/util/JsonWriter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/JsonWriter.java | MIT |
public JsonWriter value(double value) throws IOException {
if (!lenient && (Double.isNaN(value) || Double.isInfinite(value))) {
throw new IllegalArgumentException("Numeric values must be finite, but was " + value);
}
beforeValue(false);
out.append(Double.toString(value));
return this;
} |
Encodes {@code value}.
@param value a finite value. May not be {@link Double#isNaN() NaNs} or
{@link Double#isInfinite() infinities} unless this writer is lenient.
@return this writer.
| JsonWriter::value | java | Reginer/aosp-android-jar | android-33/src/android/util/JsonWriter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/JsonWriter.java | MIT |
public JsonWriter value(long value) throws IOException {
beforeValue(false);
out.write(Long.toString(value));
return this;
} |
Encodes {@code value}.
@return this writer.
| JsonWriter::value | java | Reginer/aosp-android-jar | android-33/src/android/util/JsonWriter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/JsonWriter.java | MIT |
public JsonWriter value(Number value) throws IOException {
if (value == null) {
return nullValue();
}
String string = value.toString();
if (!lenient &&
(string.equals("-Infinity") || string.equals("Infinity") || string.equals("NaN"))) {
throw new IllegalArgumentException("Numeric values must be finite, but was " + value);
}
beforeValue(false);
out.append(string);
return this;
} |
Encodes {@code value}.
@param value a finite value. May not be {@link Double#isNaN() NaNs} or
{@link Double#isInfinite() infinities} unless this writer is lenient.
@return this writer.
| JsonWriter::value | java | Reginer/aosp-android-jar | android-33/src/android/util/JsonWriter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/JsonWriter.java | MIT |
public void flush() throws IOException {
out.flush();
} |
Ensures all buffered data is written to the underlying {@link Writer}
and flushes that writer.
| JsonWriter::flush | java | Reginer/aosp-android-jar | android-33/src/android/util/JsonWriter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/JsonWriter.java | MIT |
public void close() throws IOException {
out.close();
if (peek() != JsonScope.NONEMPTY_DOCUMENT) {
throw new IOException("Incomplete document");
}
} |
Flushes and closes this writer and the underlying {@link Writer}.
@throws IOException if the JSON document is incomplete.
| JsonWriter::close | java | Reginer/aosp-android-jar | android-33/src/android/util/JsonWriter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/JsonWriter.java | MIT |
private void beforeName() throws IOException {
JsonScope context = peek();
if (context == JsonScope.NONEMPTY_OBJECT) { // first in object
out.write(',');
} else if (context != JsonScope.EMPTY_OBJECT) { // not in an object!
throw new IllegalStateException("Nesting problem: " + stack);
}
newline();
replaceTop(JsonScope.DANGLING_NAME);
} |
Inserts any necessary separators and whitespace before a name. Also
adjusts the stack to expect the name's value.
| JsonWriter::beforeName | java | Reginer/aosp-android-jar | android-33/src/android/util/JsonWriter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/JsonWriter.java | MIT |
private void beforeValue(boolean root) throws IOException {
switch (peek()) {
case EMPTY_DOCUMENT: // first in document
if (!lenient && !root) {
throw new IllegalStateException(
"JSON must start with an array or an object.");
}
replaceTop(JsonScope.NONEMPTY_DOCUMENT);
break;
case EMPTY_ARRAY: // first in array
replaceTop(JsonScope.NONEMPTY_ARRAY);
newline();
break;
case NONEMPTY_ARRAY: // another in array
out.append(',');
newline();
break;
case DANGLING_NAME: // value for name
out.append(separator);
replaceTop(JsonScope.NONEMPTY_OBJECT);
break;
case NONEMPTY_DOCUMENT:
throw new IllegalStateException(
"JSON must have only one top-level value.");
default:
throw new IllegalStateException("Nesting problem: " + stack);
}
} |
Inserts any necessary separators and whitespace before a literal value,
inline array, or inline object. Also adjusts the stack to expect either a
closing bracket or another element.
@param root true if the value is a new array or object, the two values
permitted as top-level elements.
| JsonWriter::beforeValue | java | Reginer/aosp-android-jar | android-33/src/android/util/JsonWriter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/JsonWriter.java | MIT |
ScheduledFutureTask(Runnable r, V result, long triggerTime,
long sequenceNumber) {
super(r, result);
this.time = triggerTime;
this.period = 0;
this.sequenceNumber = sequenceNumber;
} |
Creates a one-shot action with given nanoTime-based trigger time.
| ScheduledFutureTask::ScheduledFutureTask | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
ScheduledFutureTask(Runnable r, V result, long triggerTime,
long period, long sequenceNumber) {
super(r, result);
this.time = triggerTime;
this.period = period;
this.sequenceNumber = sequenceNumber;
} |
Creates a periodic action with given nanoTime-based initial
trigger time and period.
| ScheduledFutureTask::ScheduledFutureTask | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
ScheduledFutureTask(Callable<V> callable, long triggerTime,
long sequenceNumber) {
super(callable);
this.time = triggerTime;
this.period = 0;
this.sequenceNumber = sequenceNumber;
} |
Creates a one-shot action with given nanoTime-based trigger time.
| ScheduledFutureTask::ScheduledFutureTask | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public boolean isPeriodic() {
return period != 0;
} |
Returns {@code true} if this is a periodic (not a one-shot) action.
@return {@code true} if periodic
| ScheduledFutureTask::isPeriodic | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
private void setNextRunTime() {
long p = period;
if (p > 0)
time += p;
else
time = triggerTime(-p);
} |
Sets the next time to run for a periodic task.
| ScheduledFutureTask::setNextRunTime | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public void run() {
if (!canRunInCurrentRunState(this))
cancel(false);
else if (!isPeriodic())
super.run();
else if (super.runAndReset()) {
setNextRunTime();
reExecutePeriodic(outerTask);
}
} |
Overrides FutureTask version so as to reset/requeue if periodic.
| ScheduledFutureTask::run | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
boolean canRunInCurrentRunState(RunnableScheduledFuture<?> task) {
if (!isShutdown())
return true;
if (isStopped())
return false;
return task.isPeriodic()
? continueExistingPeriodicTasksAfterShutdown
: (executeExistingDelayedTasksAfterShutdown
// Android-changed: Preserving behaviour on expired tasks (b/202927404)
// || task.getDelay(NANOSECONDS) <= 0);
);
} |
Returns true if can run a task given current run state and
run-after-shutdown parameters.
| ScheduledFutureTask::canRunInCurrentRunState | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
private void delayedExecute(RunnableScheduledFuture<?> task) {
if (isShutdown())
reject(task);
else {
super.getQueue().add(task);
if (!canRunInCurrentRunState(task) && remove(task))
task.cancel(false);
else
ensurePrestart();
}
} |
Main execution method for delayed or periodic tasks. If pool
is shut down, rejects the task. Otherwise adds task to queue
and starts a thread, if necessary, to run it. (We cannot
prestart the thread to run the task because the task (probably)
shouldn't be run yet.) If the pool is shut down while the task
is being added, cancel and remove it if required by state and
run-after-shutdown parameters.
@param task the task
| ScheduledFutureTask::delayedExecute | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
void reExecutePeriodic(RunnableScheduledFuture<?> task) {
if (canRunInCurrentRunState(task)) {
super.getQueue().add(task);
if (canRunInCurrentRunState(task) || !remove(task)) {
ensurePrestart();
return;
}
}
task.cancel(false);
} |
Requeues a periodic task unless current run state precludes it.
Same idea as delayedExecute except drops task rather than rejecting.
@param task the task
| ScheduledFutureTask::reExecutePeriodic | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
@Override void onShutdown() {
BlockingQueue<Runnable> q = super.getQueue();
boolean keepDelayed =
getExecuteExistingDelayedTasksAfterShutdownPolicy();
boolean keepPeriodic =
getContinueExistingPeriodicTasksAfterShutdownPolicy();
// Traverse snapshot to avoid iterator exceptions
// TODO: implement and use efficient removeIf
// super.getQueue().removeIf(...);
for (Object e : q.toArray()) {
if (e instanceof RunnableScheduledFuture) {
RunnableScheduledFuture<?> t = (RunnableScheduledFuture<?>)e;
if ((t.isPeriodic()
? !keepPeriodic
// Android-changed: Preserving behaviour on expired tasks (b/202927404)
// : (!keepDelayed && t.getDelay(NANOSECONDS) > 0))
: !keepDelayed)
|| t.isCancelled()) { // also remove if already cancelled
if (q.remove(t))
t.cancel(false);
}
}
}
tryTerminate();
} |
Cancels and clears the queue of all tasks that should not be run
due to shutdown policy. Invoked within super.shutdown.
| ScheduledFutureTask::onShutdown | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
protected <V> RunnableScheduledFuture<V> decorateTask(
Runnable runnable, RunnableScheduledFuture<V> task) {
return task;
} |
Modifies or replaces the task used to execute a runnable.
This method can be used to override the concrete
class used for managing internal tasks.
The default implementation simply returns the given task.
@param runnable the submitted Runnable
@param task the task created to execute the runnable
@param <V> the type of the task's result
@return a task that can execute the runnable
@since 1.6
| ScheduledFutureTask::decorateTask | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
protected <V> RunnableScheduledFuture<V> decorateTask(
Callable<V> callable, RunnableScheduledFuture<V> task) {
return task;
} |
Modifies or replaces the task used to execute a callable.
This method can be used to override the concrete
class used for managing internal tasks.
The default implementation simply returns the given task.
@param callable the submitted Callable
@param task the task created to execute the callable
@param <V> the type of the task's result
@return a task that can execute the callable
@since 1.6
| ScheduledFutureTask::decorateTask | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public ScheduledThreadPoolExecutor(int corePoolSize) {
super(corePoolSize, Integer.MAX_VALUE,
DEFAULT_KEEPALIVE_MILLIS, MILLISECONDS,
new DelayedWorkQueue());
} |
Creates a new {@code ScheduledThreadPoolExecutor} with the
given core pool size.
@param corePoolSize the number of threads to keep in the pool, even
if they are idle, unless {@code allowCoreThreadTimeOut} is set
@throws IllegalArgumentException if {@code corePoolSize < 0}
| ScheduledFutureTask::ScheduledThreadPoolExecutor | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public ScheduledThreadPoolExecutor(int corePoolSize,
ThreadFactory threadFactory) {
super(corePoolSize, Integer.MAX_VALUE,
DEFAULT_KEEPALIVE_MILLIS, MILLISECONDS,
new DelayedWorkQueue(), threadFactory);
} |
Creates a new {@code ScheduledThreadPoolExecutor} with the
given initial parameters.
@param corePoolSize the number of threads to keep in the pool, even
if they are idle, unless {@code allowCoreThreadTimeOut} is set
@param threadFactory the factory to use when the executor
creates a new thread
@throws IllegalArgumentException if {@code corePoolSize < 0}
@throws NullPointerException if {@code threadFactory} is null
| ScheduledFutureTask::ScheduledThreadPoolExecutor | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public ScheduledThreadPoolExecutor(int corePoolSize,
RejectedExecutionHandler handler) {
super(corePoolSize, Integer.MAX_VALUE,
DEFAULT_KEEPALIVE_MILLIS, MILLISECONDS,
new DelayedWorkQueue(), handler);
} |
Creates a new {@code ScheduledThreadPoolExecutor} with the
given initial parameters.
@param corePoolSize the number of threads to keep in the pool, even
if they are idle, unless {@code allowCoreThreadTimeOut} is set
@param handler the handler to use when execution is blocked
because the thread bounds and queue capacities are reached
@throws IllegalArgumentException if {@code corePoolSize < 0}
@throws NullPointerException if {@code handler} is null
| ScheduledFutureTask::ScheduledThreadPoolExecutor | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public ScheduledThreadPoolExecutor(int corePoolSize,
ThreadFactory threadFactory,
RejectedExecutionHandler handler) {
super(corePoolSize, Integer.MAX_VALUE,
DEFAULT_KEEPALIVE_MILLIS, MILLISECONDS,
new DelayedWorkQueue(), threadFactory, handler);
} |
Creates a new {@code ScheduledThreadPoolExecutor} with the
given initial parameters.
@param corePoolSize the number of threads to keep in the pool, even
if they are idle, unless {@code allowCoreThreadTimeOut} is set
@param threadFactory the factory to use when the executor
creates a new thread
@param handler the handler to use when execution is blocked
because the thread bounds and queue capacities are reached
@throws IllegalArgumentException if {@code corePoolSize < 0}
@throws NullPointerException if {@code threadFactory} or
{@code handler} is null
| ScheduledFutureTask::ScheduledThreadPoolExecutor | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
private long triggerTime(long delay, TimeUnit unit) {
return triggerTime(unit.toNanos((delay < 0) ? 0 : delay));
} |
Returns the nanoTime-based trigger time of a delayed action.
| ScheduledFutureTask::triggerTime | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
long triggerTime(long delay) {
return System.nanoTime() +
((delay < (Long.MAX_VALUE >> 1)) ? delay : overflowFree(delay));
} |
Returns the nanoTime-based trigger time of a delayed action.
| ScheduledFutureTask::triggerTime | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
private long overflowFree(long delay) {
Delayed head = (Delayed) super.getQueue().peek();
if (head != null) {
long headDelay = head.getDelay(NANOSECONDS);
if (headDelay < 0 && (delay - headDelay < 0))
delay = Long.MAX_VALUE + headDelay;
}
return delay;
} |
Constrains the values of all delays in the queue to be within
Long.MAX_VALUE of each other, to avoid overflow in compareTo.
This may occur if a task is eligible to be dequeued, but has
not yet been, while some other task is added with a delay of
Long.MAX_VALUE.
| ScheduledFutureTask::overflowFree | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public ScheduledFuture<?> schedule(Runnable command,
long delay,
TimeUnit unit) {
if (command == null || unit == null)
throw new NullPointerException();
RunnableScheduledFuture<Void> t = decorateTask(command,
new ScheduledFutureTask<Void>(command, null,
triggerTime(delay, unit),
sequencer.getAndIncrement()));
delayedExecute(t);
return t;
} |
@throws RejectedExecutionException {@inheritDoc}
@throws NullPointerException {@inheritDoc}
| ScheduledFutureTask::schedule | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public <V> ScheduledFuture<V> schedule(Callable<V> callable,
long delay,
TimeUnit unit) {
if (callable == null || unit == null)
throw new NullPointerException();
RunnableScheduledFuture<V> t = decorateTask(callable,
new ScheduledFutureTask<V>(callable,
triggerTime(delay, unit),
sequencer.getAndIncrement()));
delayedExecute(t);
return t;
} |
@throws RejectedExecutionException {@inheritDoc}
@throws NullPointerException {@inheritDoc}
| ScheduledFutureTask::schedule | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
long initialDelay,
long period,
TimeUnit unit) {
if (command == null || unit == null)
throw new NullPointerException();
if (period <= 0L)
throw new IllegalArgumentException();
ScheduledFutureTask<Void> sft =
new ScheduledFutureTask<Void>(command,
null,
triggerTime(initialDelay, unit),
unit.toNanos(period),
sequencer.getAndIncrement());
RunnableScheduledFuture<Void> t = decorateTask(command, sft);
sft.outerTask = t;
delayedExecute(t);
return t;
} |
Submits a periodic action that becomes enabled first after the
given initial delay, and subsequently with the given period;
that is, executions will commence after
{@code initialDelay}, then {@code initialDelay + period}, then
{@code initialDelay + 2 * period}, and so on.
<p>The sequence of task executions continues indefinitely until
one of the following exceptional completions occur:
<ul>
<li>The task is {@linkplain Future#cancel explicitly cancelled}
via the returned future.
<li>Method {@link #shutdown} is called and the {@linkplain
#getContinueExistingPeriodicTasksAfterShutdownPolicy policy on
whether to continue after shutdown} is not set true, or method
{@link #shutdownNow} is called; also resulting in task
cancellation.
<li>An execution of the task throws an exception. In this case
calling {@link Future#get() get} on the returned future will throw
{@link ExecutionException}, holding the exception as its cause.
</ul>
Subsequent executions are suppressed. Subsequent calls to
{@link Future#isDone isDone()} on the returned future will
return {@code true}.
<p>If any execution of this task takes longer than its period, then
subsequent executions may start late, but will not concurrently
execute.
@throws RejectedExecutionException {@inheritDoc}
@throws NullPointerException {@inheritDoc}
@throws IllegalArgumentException {@inheritDoc}
| ScheduledFutureTask::scheduleAtFixedRate | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command,
long initialDelay,
long delay,
TimeUnit unit) {
if (command == null || unit == null)
throw new NullPointerException();
if (delay <= 0L)
throw new IllegalArgumentException();
ScheduledFutureTask<Void> sft =
new ScheduledFutureTask<Void>(command,
null,
triggerTime(initialDelay, unit),
-unit.toNanos(delay),
sequencer.getAndIncrement());
RunnableScheduledFuture<Void> t = decorateTask(command, sft);
sft.outerTask = t;
delayedExecute(t);
return t;
} |
Submits a periodic action that becomes enabled first after the
given initial delay, and subsequently with the given delay
between the termination of one execution and the commencement of
the next.
<p>The sequence of task executions continues indefinitely until
one of the following exceptional completions occur:
<ul>
<li>The task is {@linkplain Future#cancel explicitly cancelled}
via the returned future.
<li>Method {@link #shutdown} is called and the {@linkplain
#getContinueExistingPeriodicTasksAfterShutdownPolicy policy on
whether to continue after shutdown} is not set true, or method
{@link #shutdownNow} is called; also resulting in task
cancellation.
<li>An execution of the task throws an exception. In this case
calling {@link Future#get() get} on the returned future will throw
{@link ExecutionException}, holding the exception as its cause.
</ul>
Subsequent executions are suppressed. Subsequent calls to
{@link Future#isDone isDone()} on the returned future will
return {@code true}.
@throws RejectedExecutionException {@inheritDoc}
@throws NullPointerException {@inheritDoc}
@throws IllegalArgumentException {@inheritDoc}
| ScheduledFutureTask::scheduleWithFixedDelay | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public void execute(Runnable command) {
schedule(command, 0, NANOSECONDS);
} |
Executes {@code command} with zero required delay.
This has effect equivalent to
{@link #schedule(Runnable,long,TimeUnit) schedule(command, 0, anyUnit)}.
Note that inspections of the queue and of the list returned by
{@code shutdownNow} will access the zero-delayed
{@link ScheduledFuture}, not the {@code command} itself.
<p>A consequence of the use of {@code ScheduledFuture} objects is
that {@link ThreadPoolExecutor#afterExecute afterExecute} is always
called with a null second {@code Throwable} argument, even if the
{@code command} terminated abruptly. Instead, the {@code Throwable}
thrown by such a task can be obtained via {@link Future#get}.
@throws RejectedExecutionException at discretion of
{@code RejectedExecutionHandler}, if the task
cannot be accepted for execution because the
executor has been shut down
@throws NullPointerException {@inheritDoc}
| ScheduledFutureTask::execute | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public Future<?> submit(Runnable task) {
return schedule(task, 0, NANOSECONDS);
} |
@throws RejectedExecutionException {@inheritDoc}
@throws NullPointerException {@inheritDoc}
| ScheduledFutureTask::submit | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public <T> Future<T> submit(Runnable task, T result) {
return schedule(Executors.callable(task, result), 0, NANOSECONDS);
} |
@throws RejectedExecutionException {@inheritDoc}
@throws NullPointerException {@inheritDoc}
| ScheduledFutureTask::submit | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public <T> Future<T> submit(Callable<T> task) {
return schedule(task, 0, NANOSECONDS);
} |
@throws RejectedExecutionException {@inheritDoc}
@throws NullPointerException {@inheritDoc}
| ScheduledFutureTask::submit | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public void setContinueExistingPeriodicTasksAfterShutdownPolicy(boolean value) {
continueExistingPeriodicTasksAfterShutdown = value;
if (!value && isShutdown())
onShutdown();
} |
Sets the policy on whether to continue executing existing
periodic tasks even when this executor has been {@code shutdown}.
In this case, executions will continue until {@code shutdownNow}
or the policy is set to {@code false} when already shutdown.
This value is by default {@code false}.
@param value if {@code true}, continue after shutdown, else don't
@see #getContinueExistingPeriodicTasksAfterShutdownPolicy
| ScheduledFutureTask::setContinueExistingPeriodicTasksAfterShutdownPolicy | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public boolean getContinueExistingPeriodicTasksAfterShutdownPolicy() {
return continueExistingPeriodicTasksAfterShutdown;
} |
Gets the policy on whether to continue executing existing
periodic tasks even when this executor has been {@code shutdown}.
In this case, executions will continue until {@code shutdownNow}
or the policy is set to {@code false} when already shutdown.
This value is by default {@code false}.
@return {@code true} if will continue after shutdown
@see #setContinueExistingPeriodicTasksAfterShutdownPolicy
| ScheduledFutureTask::getContinueExistingPeriodicTasksAfterShutdownPolicy | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public void setExecuteExistingDelayedTasksAfterShutdownPolicy(boolean value) {
executeExistingDelayedTasksAfterShutdown = value;
if (!value && isShutdown())
onShutdown();
} |
Sets the policy on whether to execute existing delayed
tasks even when this executor has been {@code shutdown}.
In this case, these tasks will only terminate upon
{@code shutdownNow}, or after setting the policy to
{@code false} when already shutdown.
This value is by default {@code true}.
@param value if {@code true}, execute after shutdown, else don't
@see #getExecuteExistingDelayedTasksAfterShutdownPolicy
| ScheduledFutureTask::setExecuteExistingDelayedTasksAfterShutdownPolicy | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public boolean getExecuteExistingDelayedTasksAfterShutdownPolicy() {
return executeExistingDelayedTasksAfterShutdown;
} |
Gets the policy on whether to execute existing delayed
tasks even when this executor has been {@code shutdown}.
In this case, these tasks will only terminate upon
{@code shutdownNow}, or after setting the policy to
{@code false} when already shutdown.
This value is by default {@code true}.
@return {@code true} if will execute after shutdown
@see #setExecuteExistingDelayedTasksAfterShutdownPolicy
| ScheduledFutureTask::getExecuteExistingDelayedTasksAfterShutdownPolicy | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public void setRemoveOnCancelPolicy(boolean value) {
removeOnCancel = value;
} |
Sets the policy on whether cancelled tasks should be immediately
removed from the work queue at time of cancellation. This value is
by default {@code false}.
@param value if {@code true}, remove on cancellation, else don't
@see #getRemoveOnCancelPolicy
@since 1.7
| ScheduledFutureTask::setRemoveOnCancelPolicy | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public boolean getRemoveOnCancelPolicy() {
return removeOnCancel;
} |
Gets the policy on whether cancelled tasks should be immediately
removed from the work queue at time of cancellation. This value is
by default {@code false}.
@return {@code true} if cancelled tasks are immediately removed
from the queue
@see #setRemoveOnCancelPolicy
@since 1.7
| ScheduledFutureTask::getRemoveOnCancelPolicy | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
public BlockingQueue<Runnable> getQueue() {
return super.getQueue();
} |
Returns the task queue used by this executor. Access to the
task queue is intended primarily for debugging and monitoring.
This queue may be in active use. Retrieving the task queue
does not prevent queued tasks from executing.
<p>Each element of this queue is a {@link ScheduledFuture}.
For tasks submitted via one of the {@code schedule} methods, the
element will be identical to the returned {@code ScheduledFuture}.
For tasks submitted using {@link #execute execute}, the element
will be a zero-delay {@code ScheduledFuture}.
<p>Iteration over this queue is <em>not</em> guaranteed to traverse
tasks in the order in which they will execute.
@return the task queue
| ScheduledFutureTask::getQueue | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
private static void setIndex(RunnableScheduledFuture<?> f, int idx) {
if (f instanceof ScheduledFutureTask)
((ScheduledFutureTask)f).heapIndex = idx;
} |
Sets f's heapIndex if it is a ScheduledFutureTask.
| DelayedWorkQueue::setIndex | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
private void siftUp(int k, RunnableScheduledFuture<?> key) {
while (k > 0) {
int parent = (k - 1) >>> 1;
RunnableScheduledFuture<?> e = queue[parent];
if (key.compareTo(e) >= 0)
break;
queue[k] = e;
setIndex(e, k);
k = parent;
}
queue[k] = key;
setIndex(key, k);
} |
Sifts element added at bottom up to its heap-ordered spot.
Call only when holding lock.
| DelayedWorkQueue::siftUp | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
private void siftDown(int k, RunnableScheduledFuture<?> key) {
int half = size >>> 1;
while (k < half) {
int child = (k << 1) + 1;
RunnableScheduledFuture<?> c = queue[child];
int right = child + 1;
if (right < size && c.compareTo(queue[right]) > 0)
c = queue[child = right];
if (key.compareTo(c) <= 0)
break;
queue[k] = c;
setIndex(c, k);
k = child;
}
queue[k] = key;
setIndex(key, k);
} |
Sifts element added at top down to its heap-ordered spot.
Call only when holding lock.
| DelayedWorkQueue::siftDown | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
private void grow() {
int oldCapacity = queue.length;
int newCapacity = oldCapacity + (oldCapacity >> 1); // grow 50%
if (newCapacity < 0) // overflow
newCapacity = Integer.MAX_VALUE;
queue = Arrays.copyOf(queue, newCapacity);
} |
Resizes the heap array. Call only when holding lock.
| DelayedWorkQueue::grow | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
private int indexOf(Object x) {
if (x != null) {
if (x instanceof ScheduledFutureTask) {
int i = ((ScheduledFutureTask) x).heapIndex;
// Sanity check; x could conceivably be a
// ScheduledFutureTask from some other pool.
if (i >= 0 && i < size && queue[i] == x)
return i;
} else {
for (int i = 0; i < size; i++)
if (x.equals(queue[i]))
return i;
}
}
return -1;
} |
Finds index of given object, or -1 if absent.
| DelayedWorkQueue::indexOf | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
private RunnableScheduledFuture<?> finishPoll(RunnableScheduledFuture<?> f) {
int s = --size;
RunnableScheduledFuture<?> x = queue[s];
queue[s] = null;
if (s != 0)
siftDown(0, x);
setIndex(f, -1);
return f;
} |
Performs common bookkeeping for poll and take: Replaces
first element with last and sifts it down. Call only when
holding lock.
@param f the task to remove and return
| DelayedWorkQueue::finishPoll | java | Reginer/aosp-android-jar | android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/concurrent/ScheduledThreadPoolExecutor.java | MIT |
private void maybeScheduleMessageSend() {
synchronized (mDigitSendLock) {
if (mMessageToSend == null && mDigitSendScheduledFuture == null) {
mMessageToSend = mPendingMessages.poll();
mCharToSend = 0;
if (mMessageToSend != null) {
Log.i(this, "maybeScheduleMessageSend: toSend=%s",
String.valueOf(mMessageToSend));
// Schedule the message to send; the inital delay will be
// mDurationOfDtmfMessageMillis to ensure we separate messages with an
// adequate padding of space, and mIntervalBetweenDigitsMillis will be used to
// ensure there is enough time between each digit.
mDigitSendScheduledFuture = mScheduledExecutorService.scheduleAtFixedRate(
() -> {
handleDtmfSend();
}, mDurationOfDtmfMessageMillis + getDtmfDurationFuzzMillis(),
mIntervalBetweenDigitsMillis,
TimeUnit.MILLISECONDS);
}
}
}
} |
Checks for pending messages and schedules send of a pending message if one is available.
| DtmfTransport::maybeScheduleMessageSend | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
private long getDtmfDurationFuzzMillis() {
if (mDtmfDurationFuzzMillis == 0) {
return 0;
}
return mRandom.nextLong() % mDtmfDurationFuzzMillis;
} |
@return random fuzz factor to add when delaying initial send of a DTMF message.
| DtmfTransport::getDtmfDurationFuzzMillis | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
private void handleDtmfSend() {
if (mCharToSend < mMessageToSend.length) {
if (mDtmfAdapter != null) {
Log.i(this, "handleDtmfSend: char=%c", mMessageToSend[mCharToSend]);
mDtmfAdapter.sendDtmf(mMessageToSend[mCharToSend]);
}
mCharToSend++;
if (mCharToSend == mMessageToSend.length) {
Log.i(this, "handleDtmfSend: done");
synchronized (mDigitSendLock) {
mMessageToSend = null;
mDigitSendScheduledFuture.cancel(false);
mDigitSendScheduledFuture = null;
// If we're still in the negotiation phase, we can hold off on sending any other
// pending messages queued up.
if (mTransportState == STATE_NEGOTIATED) {
maybeScheduleMessageSend();
}
}
}
}
} |
Runs at fixed {@link #mIntervalBetweenDigitsMillis} intervals to send the individual DTMF
digits in {@link #mMessageToSend}. When sending completes, the scheduled task is cancelled
and {@link #maybeScheduleMessageSend()} is called to schedule send of any other pending
message.
| DtmfTransport::handleDtmfSend | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
public int getTransportState() {
return mTransportState;
} |
@return the current state of the transport.
| DtmfTransport::getTransportState | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
public void onDtmfReceived(char digit) {
if (!(digit >= 'A' && digit <= 'D')) {
Log.i(this, "onDtmfReceived: digit = %c ; invalid digit; not in A-D");
return;
}
if (mTransportState == STATE_NEGOTIATING) {
synchronized(mProbeLock) {
mProbeDigits.append(digit);
}
if (digit == DTMF_MESSAGE_DELIMITER) {
Log.i(this, "onDtmfReceived: received message %s", mProbeDigits);
handleProbeMessage();
}
} else {
handleReceivedDigit(digit);
}
} |
Called by Telephony when a DTMF digit is received from the network.
@param digit The received DTMF digit.
| DtmfTransport::onDtmfReceived | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
private void handleProbeMessage() {
String probe;
synchronized(mProbeLock) {
probe = mProbeDigits.toString();
if (mProbeDigits.length() > 0) {
mProbeDigits.delete(0, mProbeDigits.length());
}
}
cancelNegotiationTimeout();
if (probe.startsWith(String.valueOf(DTMF_MESSAGE_START))
&& probe.endsWith(String.valueOf(DTMF_MESSAGE_DELIMITER))
&& probe.length() > 2) {
mProtocolVersion = probe.substring(1,probe.length() - 1);
Log.i(this, "handleProbeMessage: got valid probe, remote version %s negotiated.",
probe);
negotiationSucceeded();
} else {
Log.i(this, "handleProbeMessage: got invalid probe %s - negotiation failed.", probe);
negotiationFailed();
}
cancelNegotiationTimeout();
} |
Handles a received probe message by verifying that it is in a valid format and caching the
version number indicated.
| DtmfTransport::handleProbeMessage | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
private void scheduleNegotiationTimeout() {
synchronized (mNegotiationLock) {
mNegotiationFuture = mScheduledExecutorService.schedule(() -> {
handleNegotiationTimeout();
},
mNegotiationTimeoutMillis, TimeUnit.MILLISECONDS);
}
} |
Upon initiation of negotiation, schedule a timeout within which we expect to receive the
incoming probe.
| DtmfTransport::scheduleNegotiationTimeout | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
private void cancelNegotiationTimeout() {
Log.i(this, "cancelNegotiationTimeout");
synchronized (mNegotiationLock) {
if (mNegotiationFuture != null) {
mNegotiationFuture.cancel(false);
}
mNegotiationFuture = null;
}
} |
Cancels a pending timeout for negotiation.
| DtmfTransport::cancelNegotiationTimeout | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
private void handleNegotiationTimeout() {
Log.i(this, "handleNegotiationTimeout: no probe received, negotiation timeout.");
synchronized (mNegotiationLock) {
mNegotiationFuture = null;
}
negotiationFailed();
} |
Handle scheduled negotiation timeout.
| DtmfTransport::handleNegotiationTimeout | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
private void negotiationFailed() {
mTransportState = STATE_NEGOTIATION_FAILED;
Log.i(this, "notifyNegotiationFailed");
if (mCallback != null) {
mCallback.onNegotiationFailed(this);
}
} |
Handle failed negotiation by changing state and informing listeners.
| DtmfTransport::negotiationFailed | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
private void negotiationSucceeded() {
mTransportState = STATE_NEGOTIATED;
Log.i(this, "negotiationSucceeded");
if (mCallback != null) {
mCallback.onNegotiationSuccess(this);
}
} |
Handle successful negotiation by changing state and informing listeners.
| DtmfTransport::negotiationSucceeded | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
private void handleReceivedDigit(char digit) {
if (mMessageReceiveState == RECEIVE_STATE_IDLE) {
if (digit == DTMF_MESSAGE_START) {
// First digit; start the timer
Log.i(this, "handleReceivedDigit: digit = %c ; message timeout started.", digit);
mMessageReceiveState = RECEIVE_STATE_MESSAGE_TYPE;
scheduleDtmfMessageTimeout();
} else {
Log.w(this, "handleReceivedDigit: digit = %c ; unexpected start digit, ignoring.",
digit);
}
} else if (digit == DTMF_MESSAGE_DELIMITER) {
if (mMessageReceiveState == RECEIVE_STATE_MESSAGE_TYPE) {
Log.i(this, "handleReceivedDigit: digit = %c ; msg = %s ; awaiting value.", digit,
mMessageTypeDigits.toString());
mMessageReceiveState = RECEIVE_STATE_MESSAGE_VALUE;
} else if (mMessageReceiveState == RECEIVE_STATE_MESSAGE_VALUE) {
maybeCancelDtmfMessageTimeout();
String messageType;
String messageValue;
synchronized(mDigitsLock) {
messageType = mMessageTypeDigits.toString();
messageValue = mMessageValueDigits.toString();
}
Log.i(this, "handleReceivedDigit: digit = %c ; msg = %s ; value = %s ; full msg",
digit, messageType, messageValue);
handleIncomingMessage(messageType, messageValue);
resetIncomingMessage();
}
} else {
synchronized(mDigitsLock) {
if (mMessageReceiveState == RECEIVE_STATE_MESSAGE_TYPE) {
mMessageTypeDigits.append(digit);
Log.i(this, "handleReceivedDigit: typeDigit = %c ; msg = %s",
digit, mMessageTypeDigits.toString());
} else if (mMessageReceiveState == RECEIVE_STATE_MESSAGE_VALUE) {
mMessageValueDigits.append(digit);
Log.i(this, "handleReceivedDigit: valueDigit = %c ; value = %s",
digit, mMessageValueDigits.toString());
}
}
}
} |
Handle received DTMF digits, taking into account current protocol state.
@param digit the received digit.
| DtmfTransport::handleReceivedDigit | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
private void scheduleDtmfMessageTimeout() {
synchronized (mDtmfMessageTimeoutLock) {
maybeCancelDtmfMessageTimeout();
mDtmfMessageTimeoutFuture = mScheduledExecutorService.schedule(() -> {
handleDtmfMessageTimeout();
},
mDurationOfDtmfMessageMillis, TimeUnit.MILLISECONDS);
}
} |
Schedule a timeout for receiving a complete DTMF message.
| DtmfTransport::scheduleDtmfMessageTimeout | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
private void maybeCancelDtmfMessageTimeout() {
synchronized (mDtmfMessageTimeoutLock) {
if (mDtmfMessageTimeoutFuture != null) {
Log.i(this, "scheduleDtmfMessageTimeout: timeout pending; cancelling");
mDtmfMessageTimeoutFuture.cancel(false);
mDtmfMessageTimeoutFuture = null;
}
}
} |
Cancels any pending DTMF message timeout scheduled with
{@link #scheduleDtmfMessageTimeout()}.
| DtmfTransport::maybeCancelDtmfMessageTimeout | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
private void handleDtmfMessageTimeout() {
maybeCancelDtmfMessageTimeout();
Log.i(this, "handleDtmfMessageTimeout: timeout receiving DTMF string; got %s/%s so far",
mMessageTypeDigits.toString(), mMessageValueDigits.toString());
resetIncomingMessage();
} |
Called when a scheduled DTMF message timeout occurs to cleanup the incoming message and
prepare for receiving a new message.
| DtmfTransport::handleDtmfMessageTimeout | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
private void handleIncomingMessage(String message, String value) {
Communicator.Message msg = extractMessage(message, value);
if (msg == null) {
Log.w(this, "handleIncomingMessage: msgDigits = %s, msgValueDigits = %s; invalid msg",
message, value);
return;
}
Log.i(this, "handleIncomingMessage: msgDigits = %s, msgValueDigits = %s", message, value);
Set<Communicator.Message> msgs = new ArraySet<>(1);
msgs.add(msg);
if (mCallback != null) {
mCallback.onMessagesReceived(msgs);
}
} |
Handles an incoming message received via DTMF digits; notifies interested parties of the
message using the associated callback.
| DtmfTransport::handleIncomingMessage | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
private void resetIncomingMessage() {
mMessageReceiveState = RECEIVE_STATE_IDLE;
synchronized(mDigitsLock) {
if (mMessageTypeDigits.length() != 0) {
mMessageTypeDigits.delete(0, mMessageTypeDigits.length());
}
if (mMessageValueDigits.length() != 0) {
mMessageValueDigits.delete(0, mMessageValueDigits.length());
}
}
} |
Moves message receive state back to idle and clears received digits.
| DtmfTransport::resetIncomingMessage | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/d2d/DtmfTransport.java | MIT |
static long allocatePollArray(int count) {
return unsafe.allocateMemory(count * SIZEOF_EPOLLEVENT);
} |
Allocates a poll array to handle up to {@code count} events.
| EPoll::allocatePollArray | java | Reginer/aosp-android-jar | android-35/src/sun/nio/ch/EPoll.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/nio/ch/EPoll.java | MIT |
static void freePollArray(long address) {
unsafe.freeMemory(address);
} |
Free a poll array
| EPoll::freePollArray | java | Reginer/aosp-android-jar | android-35/src/sun/nio/ch/EPoll.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/nio/ch/EPoll.java | MIT |
static long getEvent(long address, int i) {
return address + (SIZEOF_EPOLLEVENT*i);
} |
Returns event[i];
| EPoll::getEvent | java | Reginer/aosp-android-jar | android-35/src/sun/nio/ch/EPoll.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/nio/ch/EPoll.java | MIT |
static int getDescriptor(long eventAddress) {
return unsafe.getInt(eventAddress + OFFSETOF_FD);
} |
Returns event->data.fd
| EPoll::getDescriptor | java | Reginer/aosp-android-jar | android-35/src/sun/nio/ch/EPoll.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/nio/ch/EPoll.java | MIT |
static int getEvents(long eventAddress) {
return unsafe.getInt(eventAddress + OFFSETOF_EVENTS);
} |
Returns event->events
| EPoll::getEvents | java | Reginer/aosp-android-jar | android-35/src/sun/nio/ch/EPoll.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/nio/ch/EPoll.java | MIT |
public elementhasattribute03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException {
super(factory);
//
// check if loaded documents are supported for content type
//
String contentType = getContentType();
preload(contentType, "staff", false);
} |
Constructor.
@param factory document factory, may not be null
@throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
| elementhasattribute03::elementhasattribute03 | java | Reginer/aosp-android-jar | android-32/src/org/w3c/domts/level2/core/elementhasattribute03.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level2/core/elementhasattribute03.java | MIT |
public void runTest() throws Throwable {
Document doc;
Element element;
boolean state;
Attr attribute;
Attr newAttribute;
doc = (Document) load("staff", false);
element = doc.createElement("address");
attribute = doc.createAttribute("domestic");
state = element.hasAttribute("domestic");
assertFalse("elementhasattribute03_False", state);
newAttribute = element.setAttributeNode(attribute);
state = element.hasAttribute("domestic");
assertTrue("elementhasattribute03_True", state);
} |
Runs the test case.
@throws Throwable Any uncaught exception causes test to fail
| elementhasattribute03::runTest | java | Reginer/aosp-android-jar | android-32/src/org/w3c/domts/level2/core/elementhasattribute03.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level2/core/elementhasattribute03.java | MIT |
public String getTargetURI() {
return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementhasattribute03";
} |
Gets URI that identifies the test.
@return uri identifier of test
| elementhasattribute03::getTargetURI | java | Reginer/aosp-android-jar | android-32/src/org/w3c/domts/level2/core/elementhasattribute03.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level2/core/elementhasattribute03.java | MIT |
public static void main(final String[] args) {
DOMTestCase.doMain(elementhasattribute03.class, args);
} |
Runs this test from the command line.
@param args command line arguments
| elementhasattribute03::main | java | Reginer/aosp-android-jar | android-32/src/org/w3c/domts/level2/core/elementhasattribute03.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level2/core/elementhasattribute03.java | MIT |
public NeighboringCellInfo(final CellInfoGsm info) {
mNetworkType = TelephonyManager.NETWORK_TYPE_GPRS;
mRssi = info.getCellSignalStrength().getAsuLevel();
if (mRssi == Integer.MAX_VALUE) mRssi = UNKNOWN_RSSI;
mLac = info.getCellIdentity().getLac();
if (mLac == Integer.MAX_VALUE) mLac = UNKNOWN_CID;
mCid = info.getCellIdentity().getCid();
if (mCid == Integer.MAX_VALUE) mCid = UNKNOWN_CID;
mPsc = UNKNOWN_CID;
} |
Initialize the object from rssi and cid.
NeighboringCellInfo is one time shot for the neighboring cells based on
the radio network type at that moment. Its constructor needs radio network
type.
@deprecated by {@link #NeighboringCellInfo(int, String, int)}
@Deprecated
public NeighboringCellInfo(int rssi, int cid) {
mRssi = rssi;
mCid = cid;
}
/** @hide | NeighboringCellInfo::NeighboringCellInfo | java | Reginer/aosp-android-jar | android-33/src/android/telephony/NeighboringCellInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/telephony/NeighboringCellInfo.java | MIT |
public NeighboringCellInfo(final CellInfoWcdma info) {
mNetworkType = TelephonyManager.NETWORK_TYPE_UMTS;
mRssi = info.getCellSignalStrength().getAsuLevel();
if (mRssi == Integer.MAX_VALUE) mRssi = UNKNOWN_RSSI;
mLac = info.getCellIdentity().getLac();
if (mLac == Integer.MAX_VALUE) mLac = UNKNOWN_CID;
mCid = info.getCellIdentity().getCid();
if (mCid == Integer.MAX_VALUE) mCid = UNKNOWN_CID;
mPsc = info.getCellIdentity().getPsc();
if (mPsc == Integer.MAX_VALUE) mPsc = UNKNOWN_CID;
} |
Initialize the object from rssi and cid.
NeighboringCellInfo is one time shot for the neighboring cells based on
the radio network type at that moment. Its constructor needs radio network
type.
@deprecated by {@link #NeighboringCellInfo(int, String, int)}
@Deprecated
public NeighboringCellInfo(int rssi, int cid) {
mRssi = rssi;
mCid = cid;
}
/** @hide
public NeighboringCellInfo(final CellInfoGsm info) {
mNetworkType = TelephonyManager.NETWORK_TYPE_GPRS;
mRssi = info.getCellSignalStrength().getAsuLevel();
if (mRssi == Integer.MAX_VALUE) mRssi = UNKNOWN_RSSI;
mLac = info.getCellIdentity().getLac();
if (mLac == Integer.MAX_VALUE) mLac = UNKNOWN_CID;
mCid = info.getCellIdentity().getCid();
if (mCid == Integer.MAX_VALUE) mCid = UNKNOWN_CID;
mPsc = UNKNOWN_CID;
}
/** @hide | NeighboringCellInfo::NeighboringCellInfo | java | Reginer/aosp-android-jar | android-33/src/android/telephony/NeighboringCellInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/telephony/NeighboringCellInfo.java | MIT |
public NeighboringCellInfo(int rssi, String location, int radioType) {
// set default value
mRssi = rssi;
mNetworkType = NETWORK_TYPE_UNKNOWN;
mPsc = UNKNOWN_CID;
mLac = UNKNOWN_CID;
mCid = UNKNOWN_CID;
// pad location string with leading "0"
int l = location.length();
if (l > 8) return;
if (l < 8) {
for (int i = 0; i < (8-l); i++) {
location = "0" + location;
}
}
// TODO - handle LTE and eHRPD (or find they can't be supported)
try {// set LAC/CID or PSC based on radioType
switch (radioType) {
case NETWORK_TYPE_GPRS:
case NETWORK_TYPE_EDGE:
mNetworkType = radioType;
// check if 0xFFFFFFFF for UNKNOWN_CID
if (!location.equalsIgnoreCase("FFFFFFFF")) {
mCid = Integer.parseInt(location.substring(4), 16);
mLac = Integer.parseInt(location.substring(0, 4), 16);
}
break;
case NETWORK_TYPE_UMTS:
case NETWORK_TYPE_HSDPA:
case NETWORK_TYPE_HSUPA:
case NETWORK_TYPE_HSPA:
mNetworkType = radioType;
mPsc = Integer.parseInt(location, 16);
break;
}
} catch (NumberFormatException e) {
// parsing location error
mPsc = UNKNOWN_CID;
mLac = UNKNOWN_CID;
mCid = UNKNOWN_CID;
mNetworkType = NETWORK_TYPE_UNKNOWN;
}
} |
Initialize the object from rssi, location string, and radioType
radioType is one of following
{@link TelephonyManager#NETWORK_TYPE_GPRS TelephonyManager.NETWORK_TYPE_GPRS},
{@link TelephonyManager#NETWORK_TYPE_EDGE TelephonyManager.NETWORK_TYPE_EDGE},
{@link TelephonyManager#NETWORK_TYPE_UMTS TelephonyManager.NETWORK_TYPE_UMTS},
{@link TelephonyManager#NETWORK_TYPE_HSDPA TelephonyManager.NETWORK_TYPE_HSDPA},
{@link TelephonyManager#NETWORK_TYPE_HSUPA TelephonyManager.NETWORK_TYPE_HSUPA},
and {@link TelephonyManager#NETWORK_TYPE_HSPA TelephonyManager.NETWORK_TYPE_HSPA}.
| NeighboringCellInfo::NeighboringCellInfo | java | Reginer/aosp-android-jar | android-33/src/android/telephony/NeighboringCellInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/telephony/NeighboringCellInfo.java | MIT |
public NeighboringCellInfo(Parcel in) {
mRssi = in.readInt();
mLac = in.readInt();
mCid = in.readInt();
mPsc = in.readInt();
mNetworkType = in.readInt();
} |
Initialize the object from a parcel.
| NeighboringCellInfo::NeighboringCellInfo | java | Reginer/aosp-android-jar | android-33/src/android/telephony/NeighboringCellInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/telephony/NeighboringCellInfo.java | MIT |
public int getRssi() {
return mRssi;
} |
@return received signal strength or UNKNOWN_RSSI if unknown
For GSM, it is in "asu" ranging from 0 to 31 (dBm = -113 + 2*asu)
0 means "-113 dBm or less" and 31 means "-51 dBm or greater"
For UMTS, it is the Level index of CPICH RSCP defined in TS 25.125
| NeighboringCellInfo::getRssi | java | Reginer/aosp-android-jar | android-33/src/android/telephony/NeighboringCellInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/telephony/NeighboringCellInfo.java | MIT |
public int getLac() {
return mLac;
} |
@return LAC in GSM, 0xffff max legal value
UNKNOWN_CID if in UMTS or CMDA or unknown
| NeighboringCellInfo::getLac | java | Reginer/aosp-android-jar | android-33/src/android/telephony/NeighboringCellInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/telephony/NeighboringCellInfo.java | MIT |
public int getCid() {
return mCid;
} |
@return cell id in GSM, 0xffff max legal value
UNKNOWN_CID if in UMTS or CDMA or unknown
| NeighboringCellInfo::getCid | java | Reginer/aosp-android-jar | android-33/src/android/telephony/NeighboringCellInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/telephony/NeighboringCellInfo.java | MIT |
public int getPsc() {
return mPsc;
} |
@return Primary Scrambling Code in 9 bits format in UMTS, 0x1ff max value
UNKNOWN_CID if in GSM or CMDA or unknown
| NeighboringCellInfo::getPsc | java | Reginer/aosp-android-jar | android-33/src/android/telephony/NeighboringCellInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/telephony/NeighboringCellInfo.java | MIT |
public int getNetworkType() {
return mNetworkType;
} |
@return Radio network type while neighboring cell location is stored.
Return {@link TelephonyManager#NETWORK_TYPE_UNKNOWN TelephonyManager.NETWORK_TYPE_UNKNOWN}
means that the location information is unavailable.
Return {@link TelephonyManager#NETWORK_TYPE_GPRS TelephonyManager.NETWORK_TYPE_GPRS} or
{@link TelephonyManager#NETWORK_TYPE_EDGE TelephonyManager.NETWORK_TYPE_EDGE}
means that Neighboring Cell information is stored for GSM network, in
which {@link NeighboringCellInfo#getLac NeighboringCellInfo.getLac} and
{@link NeighboringCellInfo#getCid NeighboringCellInfo.getCid} should be
called to access location.
Return {@link TelephonyManager#NETWORK_TYPE_UMTS TelephonyManager.NETWORK_TYPE_UMTS},
{@link TelephonyManager#NETWORK_TYPE_HSDPA TelephonyManager.NETWORK_TYPE_HSDPA},
{@link TelephonyManager#NETWORK_TYPE_HSUPA TelephonyManager.NETWORK_TYPE_HSUPA},
or {@link TelephonyManager#NETWORK_TYPE_HSPA TelephonyManager.NETWORK_TYPE_HSPA}
means that Neighboring Cell information is stored for UMTS network, in
which {@link NeighboringCellInfo#getPsc NeighboringCellInfo.getPsc}
should be called to access location.
| NeighboringCellInfo::getNetworkType | java | Reginer/aosp-android-jar | android-33/src/android/telephony/NeighboringCellInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/telephony/NeighboringCellInfo.java | MIT |
private void hideViewInternal(View child) {
mHiddenViews.add(child);
mCallback.onEnteredHiddenState(child);
} |
Marks a child view as hidden
@param child View to hide.
| ChildHelper::hideViewInternal | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/widget/ChildHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/widget/ChildHelper.java | MIT |
private boolean unhideViewInternal(View child) {
if (mHiddenViews.remove(child)) {
mCallback.onLeftHiddenState(child);
return true;
} else {
return false;
}
} |
Unmarks a child view as hidden.
@param child View to hide.
| ChildHelper::unhideViewInternal | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/widget/ChildHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/widget/ChildHelper.java | MIT |
void addView(View child, boolean hidden) {
addView(child, -1, hidden);
} |
Adds a view to the ViewGroup
@param child View to add.
@param hidden If set to true, this item will be invisible from regular methods.
| ChildHelper::addView | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/widget/ChildHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/widget/ChildHelper.java | MIT |
void addView(View child, int index, boolean hidden) {
final int offset;
if (index < 0) {
offset = mCallback.getChildCount();
} else {
offset = getOffset(index);
}
mBucket.insert(offset, hidden);
if (hidden) {
hideViewInternal(child);
}
mCallback.addView(child, offset);
if (DEBUG) {
Log.d(TAG, "addViewAt " + index + ",h:" + hidden + ", " + this);
}
} |
Add a view to the ViewGroup at an index
@param child View to add.
@param index Index of the child from the regular perspective (excluding hidden views).
ChildHelper offsets this index to actual ViewGroup index.
@param hidden If set to true, this item will be invisible from regular methods.
| ChildHelper::addView | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/widget/ChildHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/widget/ChildHelper.java | MIT |
void removeView(View view) {
int index = mCallback.indexOfChild(view);
if (index < 0) {
return;
}
if (mBucket.remove(index)) {
unhideViewInternal(view);
}
mCallback.removeViewAt(index);
if (DEBUG) {
Log.d(TAG, "remove View off:" + index + "," + this);
}
} |
Removes the provided View from underlying RecyclerView.
@param view The view to remove.
| ChildHelper::removeView | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/widget/ChildHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/widget/ChildHelper.java | MIT |
void removeViewAt(int index) {
final int offset = getOffset(index);
final View view = mCallback.getChildAt(offset);
if (view == null) {
return;
}
if (mBucket.remove(offset)) {
unhideViewInternal(view);
}
mCallback.removeViewAt(offset);
if (DEBUG) {
Log.d(TAG, "removeViewAt " + index + ", off:" + offset + ", " + this);
}
} |
Removes the view at the provided index from RecyclerView.
@param index Index of the child from the regular perspective (excluding hidden views).
ChildHelper offsets this index to actual ViewGroup index.
| ChildHelper::removeViewAt | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/widget/ChildHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/widget/ChildHelper.java | MIT |
View getChildAt(int index) {
final int offset = getOffset(index);
return mCallback.getChildAt(offset);
} |
Returns the child at provided index.
@param index Index of the child to return in regular perspective.
| ChildHelper::getChildAt | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/widget/ChildHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/widget/ChildHelper.java | MIT |
void removeAllViewsUnfiltered() {
mBucket.reset();
for (int i = mHiddenViews.size() - 1; i >= 0; i--) {
mCallback.onLeftHiddenState(mHiddenViews.get(i));
mHiddenViews.remove(i);
}
mCallback.removeAllViews();
if (DEBUG) {
Log.d(TAG, "removeAllViewsUnfiltered");
}
} |
Removes all views from the ViewGroup including the hidden ones.
| ChildHelper::removeAllViewsUnfiltered | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/widget/ChildHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/widget/ChildHelper.java | MIT |
View findHiddenNonRemovedView(int position) {
final int count = mHiddenViews.size();
for (int i = 0; i < count; i++) {
final View view = mHiddenViews.get(i);
RecyclerView.ViewHolder holder = mCallback.getChildViewHolder(view);
if (holder.getLayoutPosition() == position
&& !holder.isInvalid()
&& !holder.isRemoved()) {
return view;
}
}
return null;
} |
This can be used to find a disappearing view by position.
@param position The adapter position of the item.
@return A hidden view with a valid ViewHolder that matches the position.
| ChildHelper::findHiddenNonRemovedView | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/widget/ChildHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/widget/ChildHelper.java | MIT |
void attachViewToParent(View child, int index, ViewGroup.LayoutParams layoutParams,
boolean hidden) {
final int offset;
if (index < 0) {
offset = mCallback.getChildCount();
} else {
offset = getOffset(index);
}
mBucket.insert(offset, hidden);
if (hidden) {
hideViewInternal(child);
}
mCallback.attachViewToParent(child, offset, layoutParams);
if (DEBUG) {
Log.d(TAG, "attach view to parent index:" + index + ",off:" + offset + ","
+ "h:" + hidden + ", " + this);
}
} |
Attaches the provided view to the underlying ViewGroup.
@param child Child to attach.
@param index Index of the child to attach in regular perspective.
@param layoutParams LayoutParams for the child.
@param hidden If set to true, this item will be invisible to the regular methods.
| ChildHelper::attachViewToParent | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/widget/ChildHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/widget/ChildHelper.java | MIT |
int getChildCount() {
return mCallback.getChildCount() - mHiddenViews.size();
} |
Returns the number of children that are not hidden.
@return Number of children that are not hidden.
@see #getChildAt(int)
| ChildHelper::getChildCount | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/widget/ChildHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/widget/ChildHelper.java | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.