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 resume() {
if(mRS != null) {
mRS.resume();
}
} |
@deprecated in API 16
Inform the view that the activity is resumed. The owner of this view must
call this method when the activity is resumed. Calling this method will
recreate the OpenGL display and resume the rendering
thread.
Must not be called before a renderer has been set.
| RSTextureView::resume | java | Reginer/aosp-android-jar | android-35/src/android/renderscript/RSTextureView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/renderscript/RSTextureView.java | MIT |
public RenderScriptGL createRenderScriptGL(RenderScriptGL.SurfaceConfig sc) {
RenderScriptGL rs = new RenderScriptGL(this.getContext(), sc);
setRenderScriptGL(rs);
if (mSurfaceTexture != null) {
mRS.setSurfaceTexture(mSurfaceTexture, getWidth(), getHeight());
}
return rs;
} |
@deprecated in API 16
Create a new RenderScriptGL object and attach it to the
TextureView if present.
@param sc The RS surface config to create.
@return RenderScriptGL The new object created.
| RSTextureView::createRenderScriptGL | java | Reginer/aosp-android-jar | android-35/src/android/renderscript/RSTextureView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/renderscript/RSTextureView.java | MIT |
public void destroyRenderScriptGL() {
mRS.destroy();
mRS = null;
} |
@deprecated in API 16
Destroy the RenderScriptGL object associated with this
TextureView.
| RSTextureView::destroyRenderScriptGL | java | Reginer/aosp-android-jar | android-35/src/android/renderscript/RSTextureView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/renderscript/RSTextureView.java | MIT |
public void setRenderScriptGL(RenderScriptGL rs) {
mRS = rs;
if (mSurfaceTexture != null) {
mRS.setSurfaceTexture(mSurfaceTexture, getWidth(), getHeight());
}
} |
@deprecated in API 16
Set a new RenderScriptGL object. This also will attach the
new object to the TextureView if present.
@param rs The new RS object.
| RSTextureView::setRenderScriptGL | java | Reginer/aosp-android-jar | android-35/src/android/renderscript/RSTextureView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/renderscript/RSTextureView.java | MIT |
public RenderScriptGL getRenderScriptGL() {
return mRS;
} |
@deprecated in API 16
Returns the previously set RenderScriptGL object.
@return RenderScriptGL
| RSTextureView::getRenderScriptGL | java | Reginer/aosp-android-jar | android-35/src/android/renderscript/RSTextureView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/renderscript/RSTextureView.java | MIT |
default IntStream mapMulti(IntMapMultiConsumer mapper) {
Objects.requireNonNull(mapper);
return flatMap(e -> {
SpinedBuffer.OfInt buffer = new SpinedBuffer.OfInt();
mapper.accept(e, buffer);
return StreamSupport.intStream(buffer.spliterator(), false);
});
} |
Returns a stream consisting of the results of replacing each element of
this stream with multiple elements, specifically zero or more elements.
Replacement is performed by applying the provided mapping function to each
element in conjunction with a {@linkplain IntConsumer consumer} argument
that accepts replacement elements. The mapping function calls the consumer
zero or more times to provide the replacement elements.
<p>This is an <a href="package-summary.html#StreamOps">intermediate
operation</a>.
<p>If the {@linkplain IntConsumer consumer} argument is used outside the scope of
its application to the mapping function, the results are undefined.
@implSpec
The default implementation invokes {@link #flatMap flatMap} on this stream,
passing a function that behaves as follows. First, it calls the mapper function
with an {@code IntConsumer} that accumulates replacement elements into a newly created
internal buffer. When the mapper function returns, it creates an {@code IntStream} from the
internal buffer. Finally, it returns this stream to {@code flatMap}.
@param mapper a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
function that generates replacement elements
@return the new stream
@see Stream#mapMulti Stream.mapMulti
@since 16
| mapMulti | java | Reginer/aosp-android-jar | android-35/src/java/util/stream/IntStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/stream/IntStream.java | MIT |
default IntStream takeWhile(IntPredicate predicate) {
Objects.requireNonNull(predicate);
// Reuses the unordered spliterator, which, when encounter is present,
// is safe to use as long as it configured not to split
return StreamSupport.intStream(
new WhileOps.UnorderedWhileSpliterator.OfInt.Taking(spliterator(), true, predicate),
isParallel()).onClose(this::close);
} |
Returns, if this stream is ordered, a stream consisting of the longest
prefix of elements taken from this stream that match the given predicate.
Otherwise returns, if this stream is unordered, a stream consisting of a
subset of elements taken from this stream that match the given predicate.
<p>If this stream is ordered then the longest prefix is a contiguous
sequence of elements of this stream that match the given predicate. The
first element of the sequence is the first element of this stream, and
the element immediately following the last element of the sequence does
not match the given predicate.
<p>If this stream is unordered, and some (but not all) elements of this
stream match the given predicate, then the behavior of this operation is
nondeterministic; it is free to take any subset of matching elements
(which includes the empty set).
<p>Independent of whether this stream is ordered or unordered if all
elements of this stream match the given predicate then this operation
takes all elements (the result is the same as the input), or if no
elements of the stream match the given predicate then no elements are
taken (the result is an empty stream).
<p>This is a <a href="package-summary.html#StreamOps">short-circuiting
stateful intermediate operation</a>.
@implSpec
The default implementation obtains the {@link #spliterator() spliterator}
of this stream, wraps that spliterator so as to support the semantics
of this operation on traversal, and returns a new stream associated with
the wrapped spliterator. The returned stream preserves the execution
characteristics of this stream (namely parallel or sequential execution
as per {@link #isParallel()}) but the wrapped spliterator may choose to
not support splitting. When the returned stream is closed, the close
handlers for both the returned and this stream are invoked.
@apiNote
While {@code takeWhile()} is generally a cheap operation on sequential
stream pipelines, it can be quite expensive on ordered parallel
pipelines, since the operation is constrained to return not just any
valid prefix, but the longest prefix of elements in the encounter order.
Using an unordered stream source (such as {@link #generate(IntSupplier)})
or removing the ordering constraint with {@link #unordered()} may result
in significant speedups of {@code takeWhile()} in parallel pipelines, if
the semantics of your situation permit. If consistency with encounter
order is required, and you are experiencing poor performance or memory
utilization with {@code takeWhile()} in parallel pipelines, switching to
sequential execution with {@link #sequential()} may improve performance.
@param predicate a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
predicate to apply to elements to determine the longest
prefix of elements.
@return the new stream
@since 9
| takeWhile | java | Reginer/aosp-android-jar | android-35/src/java/util/stream/IntStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/stream/IntStream.java | MIT |
default IntStream dropWhile(IntPredicate predicate) {
Objects.requireNonNull(predicate);
// Reuses the unordered spliterator, which, when encounter is present,
// is safe to use as long as it configured not to split
return StreamSupport.intStream(
new WhileOps.UnorderedWhileSpliterator.OfInt.Dropping(spliterator(), true, predicate),
isParallel()).onClose(this::close);
} |
Returns, if this stream is ordered, a stream consisting of the remaining
elements of this stream after dropping the longest prefix of elements
that match the given predicate. Otherwise returns, if this stream is
unordered, a stream consisting of the remaining elements of this stream
after dropping a subset of elements that match the given predicate.
<p>If this stream is ordered then the longest prefix is a contiguous
sequence of elements of this stream that match the given predicate. The
first element of the sequence is the first element of this stream, and
the element immediately following the last element of the sequence does
not match the given predicate.
<p>If this stream is unordered, and some (but not all) elements of this
stream match the given predicate, then the behavior of this operation is
nondeterministic; it is free to drop any subset of matching elements
(which includes the empty set).
<p>Independent of whether this stream is ordered or unordered if all
elements of this stream match the given predicate then this operation
drops all elements (the result is an empty stream), or if no elements of
the stream match the given predicate then no elements are dropped (the
result is the same as the input).
<p>This is a <a href="package-summary.html#StreamOps">stateful
intermediate operation</a>.
@implSpec
The default implementation obtains the {@link #spliterator() spliterator}
of this stream, wraps that spliterator so as to support the semantics
of this operation on traversal, and returns a new stream associated with
the wrapped spliterator. The returned stream preserves the execution
characteristics of this stream (namely parallel or sequential execution
as per {@link #isParallel()}) but the wrapped spliterator may choose to
not support splitting. When the returned stream is closed, the close
handlers for both the returned and this stream are invoked.
@apiNote
While {@code dropWhile()} is generally a cheap operation on sequential
stream pipelines, it can be quite expensive on ordered parallel
pipelines, since the operation is constrained to return not just any
valid prefix, but the longest prefix of elements in the encounter order.
Using an unordered stream source (such as {@link #generate(IntSupplier)})
or removing the ordering constraint with {@link #unordered()} may result
in significant speedups of {@code dropWhile()} in parallel pipelines, if
the semantics of your situation permit. If consistency with encounter
order is required, and you are experiencing poor performance or memory
utilization with {@code dropWhile()} in parallel pipelines, switching to
sequential execution with {@link #sequential()} may improve performance.
@param predicate a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
predicate to apply to elements to determine the longest
prefix of elements.
@return the new stream
@since 9
| dropWhile | java | Reginer/aosp-android-jar | android-35/src/java/util/stream/IntStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/stream/IntStream.java | MIT |
public static Builder builder() {
return new Streams.IntStreamBuilderImpl();
} |
Returns a builder for an {@code IntStream}.
@return a stream builder
| builder | java | Reginer/aosp-android-jar | android-35/src/java/util/stream/IntStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/stream/IntStream.java | MIT |
public static IntStream empty() {
return StreamSupport.intStream(Spliterators.emptyIntSpliterator(), false);
} |
Returns an empty sequential {@code IntStream}.
@return an empty sequential stream
| empty | java | Reginer/aosp-android-jar | android-35/src/java/util/stream/IntStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/stream/IntStream.java | MIT |
public static IntStream of(int t) {
return StreamSupport.intStream(new Streams.IntStreamBuilderImpl(t), false);
} |
Returns a sequential {@code IntStream} containing a single element.
@param t the single element
@return a singleton sequential stream
| of | java | Reginer/aosp-android-jar | android-35/src/java/util/stream/IntStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/stream/IntStream.java | MIT |
public static IntStream of(int... values) {
return Arrays.stream(values);
} |
Returns a sequential ordered stream whose elements are the specified values.
@param values the elements of the new stream
@return the new stream
| of | java | Reginer/aosp-android-jar | android-35/src/java/util/stream/IntStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/stream/IntStream.java | MIT |
public static IntStream iterate(final int seed, final IntUnaryOperator f) {
Objects.requireNonNull(f);
Spliterator.OfInt spliterator = new Spliterators.AbstractIntSpliterator(Long.MAX_VALUE,
Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL) {
int prev;
boolean started;
@Override
public boolean tryAdvance(IntConsumer action) {
Objects.requireNonNull(action);
int t;
if (started)
t = f.applyAsInt(prev);
else {
t = seed;
started = true;
}
action.accept(prev = t);
return true;
}
};
return StreamSupport.intStream(spliterator, false);
} |
Returns an infinite sequential ordered {@code IntStream} produced by iterative
application of a function {@code f} to an initial element {@code seed},
producing a {@code Stream} consisting of {@code seed}, {@code f(seed)},
{@code f(f(seed))}, etc.
<p>The first element (position {@code 0}) in the {@code IntStream} will be
the provided {@code seed}. For {@code n > 0}, the element at position
{@code n}, will be the result of applying the function {@code f} to the
element at position {@code n - 1}.
<p>The action of applying {@code f} for one element
<a href="../concurrent/package-summary.html#MemoryVisibility"><i>happens-before</i></a>
the action of applying {@code f} for subsequent elements. For any given
element the action may be performed in whatever thread the library
chooses.
@param seed the initial element
@param f a function to be applied to the previous element to produce
a new element
@return a new sequential {@code IntStream}
| iterate | java | Reginer/aosp-android-jar | android-35/src/java/util/stream/IntStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/stream/IntStream.java | MIT |
public static IntStream iterate(int seed, IntPredicate hasNext, IntUnaryOperator next) {
Objects.requireNonNull(next);
Objects.requireNonNull(hasNext);
Spliterator.OfInt spliterator = new Spliterators.AbstractIntSpliterator(Long.MAX_VALUE,
Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL) {
int prev;
boolean started, finished;
@Override
public boolean tryAdvance(IntConsumer action) {
Objects.requireNonNull(action);
if (finished)
return false;
int t;
if (started)
t = next.applyAsInt(prev);
else {
t = seed;
started = true;
}
if (!hasNext.test(t)) {
finished = true;
return false;
}
action.accept(prev = t);
return true;
}
@Override
public void forEachRemaining(IntConsumer action) {
Objects.requireNonNull(action);
if (finished)
return;
finished = true;
int t = started ? next.applyAsInt(prev) : seed;
while (hasNext.test(t)) {
action.accept(t);
t = next.applyAsInt(t);
}
}
};
return StreamSupport.intStream(spliterator, false);
} |
Returns a sequential ordered {@code IntStream} produced by iterative
application of the given {@code next} function to an initial element,
conditioned on satisfying the given {@code hasNext} predicate. The
stream terminates as soon as the {@code hasNext} predicate returns false.
<p>{@code IntStream.iterate} should produce the same sequence of elements as
produced by the corresponding for-loop:
<pre>{@code
for (int index=seed; hasNext.test(index); index = next.applyAsInt(index)) {
...
}
}</pre>
<p>The resulting sequence may be empty if the {@code hasNext} predicate
does not hold on the seed value. Otherwise the first element will be the
supplied {@code seed} value, the next element (if present) will be the
result of applying the {@code next} function to the {@code seed} value,
and so on iteratively until the {@code hasNext} predicate indicates that
the stream should terminate.
<p>The action of applying the {@code hasNext} predicate to an element
<a href="../concurrent/package-summary.html#MemoryVisibility"><i>happens-before</i></a>
the action of applying the {@code next} function to that element. The
action of applying the {@code next} function for one element
<i>happens-before</i> the action of applying the {@code hasNext}
predicate for subsequent elements. For any given element an action may
be performed in whatever thread the library chooses.
@param seed the initial element
@param hasNext a predicate to apply to elements to determine when the
stream must terminate.
@param next a function to be applied to the previous element to produce
a new element
@return a new sequential {@code IntStream}
@since 9
| iterate | java | Reginer/aosp-android-jar | android-35/src/java/util/stream/IntStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/stream/IntStream.java | MIT |
public static IntStream generate(IntSupplier s) {
Objects.requireNonNull(s);
return StreamSupport.intStream(
new StreamSpliterators.InfiniteSupplyingSpliterator.OfInt(Long.MAX_VALUE, s), false);
} |
Returns an infinite sequential unordered stream where each element is
generated by the provided {@code IntSupplier}. This is suitable for
generating constant streams, streams of random elements, etc.
@param s the {@code IntSupplier} for generated elements
@return a new infinite sequential unordered {@code IntStream}
| generate | java | Reginer/aosp-android-jar | android-35/src/java/util/stream/IntStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/stream/IntStream.java | MIT |
public static IntStream range(int startInclusive, int endExclusive) {
if (startInclusive >= endExclusive) {
return empty();
} else {
return StreamSupport.intStream(
new Streams.RangeIntSpliterator(startInclusive, endExclusive, false), false);
}
} |
Returns a sequential ordered {@code IntStream} from {@code startInclusive}
(inclusive) to {@code endExclusive} (exclusive) by an incremental step of
{@code 1}.
@apiNote
<p>An equivalent sequence of increasing values can be produced
sequentially using a {@code for} loop as follows:
<pre>{@code
for (int i = startInclusive; i < endExclusive ; i++) { ... }
}</pre>
@param startInclusive the (inclusive) initial value
@param endExclusive the exclusive upper bound
@return a sequential {@code IntStream} for the range of {@code int}
elements
| range | java | Reginer/aosp-android-jar | android-35/src/java/util/stream/IntStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/stream/IntStream.java | MIT |
public static IntStream rangeClosed(int startInclusive, int endInclusive) {
if (startInclusive > endInclusive) {
return empty();
} else {
return StreamSupport.intStream(
new Streams.RangeIntSpliterator(startInclusive, endInclusive, true), false);
}
} |
Returns a sequential ordered {@code IntStream} from {@code startInclusive}
(inclusive) to {@code endInclusive} (inclusive) by an incremental step of
{@code 1}.
@apiNote
<p>An equivalent sequence of increasing values can be produced
sequentially using a {@code for} loop as follows:
<pre>{@code
for (int i = startInclusive; i <= endInclusive ; i++) { ... }
}</pre>
@param startInclusive the (inclusive) initial value
@param endInclusive the inclusive upper bound
@return a sequential {@code IntStream} for the range of {@code int}
elements
| rangeClosed | java | Reginer/aosp-android-jar | android-35/src/java/util/stream/IntStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/stream/IntStream.java | MIT |
public static IntStream concat(IntStream a, IntStream b) {
Objects.requireNonNull(a);
Objects.requireNonNull(b);
Spliterator.OfInt split = new Streams.ConcatSpliterator.OfInt(
a.spliterator(), b.spliterator());
IntStream stream = StreamSupport.intStream(split, a.isParallel() || b.isParallel());
return stream.onClose(Streams.composedClose(a, b));
} |
Creates a lazily concatenated stream whose elements are all the
elements of the first stream followed by all the elements of the
second stream. The resulting stream is ordered if both
of the input streams are ordered, and parallel if either of the input
streams is parallel. When the resulting stream is closed, the close
handlers for both input streams are invoked.
<p>This method operates on the two input streams and binds each stream
to its source. As a result subsequent modifications to an input stream
source may not be reflected in the concatenated stream result.
@implNote
Use caution when constructing streams from repeated concatenation.
Accessing an element of a deeply concatenated stream can result in deep
call chains, or even {@code StackOverflowError}.
@apiNote
To preserve optimization opportunities this method binds each stream to
its source and accepts only two streams as parameters. For example, the
exact size of the concatenated stream source can be computed if the exact
size of each input stream source is known.
To concatenate more streams without binding, or without nested calls to
this method, try creating a stream of streams and flat-mapping with the
identity function, for example:
<pre>{@code
IntStream concat = Stream.of(s1, s2, s3, s4).flatMapToInt(s -> s);
}</pre>
@param a the first stream
@param b the second stream
@return the concatenation of the two input streams
| concat | java | Reginer/aosp-android-jar | android-35/src/java/util/stream/IntStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/stream/IntStream.java | MIT |
default Builder add(int t) {
accept(t);
return this;
} |
Adds an element to the stream being built.
@implSpec
The default implementation behaves as if:
<pre>{@code
accept(t)
return this;
}</pre>
@param t the element to add
@return {@code this} builder
@throws IllegalStateException if the builder has already transitioned
to the built state
| add | java | Reginer/aosp-android-jar | android-35/src/java/util/stream/IntStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/util/stream/IntStream.java | MIT |
public Letterbox(Supplier<SurfaceControl.Builder> surfaceControlFactory,
Supplier<SurfaceControl.Transaction> transactionFactory,
BooleanSupplier areCornersRounded,
Supplier<Color> colorSupplier,
BooleanSupplier hasWallpaperBackgroundSupplier,
IntSupplier blurRadiusSupplier,
DoubleSupplier darkScrimAlphaSupplier,
IntConsumer doubleTapCallbackX,
IntConsumer doubleTapCallbackY,
Supplier<SurfaceControl> parentSurface) {
mSurfaceControlFactory = surfaceControlFactory;
mTransactionFactory = transactionFactory;
mAreCornersRounded = areCornersRounded;
mColorSupplier = colorSupplier;
mHasWallpaperBackgroundSupplier = hasWallpaperBackgroundSupplier;
mBlurRadiusSupplier = blurRadiusSupplier;
mDarkScrimAlphaSupplier = darkScrimAlphaSupplier;
mDoubleTapCallbackX = doubleTapCallbackX;
mDoubleTapCallbackY = doubleTapCallbackY;
mParentSurfaceSupplier = parentSurface;
} |
Constructs a Letterbox.
@param surfaceControlFactory a factory for creating the managed {@link SurfaceControl}s
| Letterbox::Letterbox | java | Reginer/aosp-android-jar | android-35/src/com/android/server/wm/Letterbox.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/wm/Letterbox.java | MIT |
public void layout(Rect outer, Rect inner, Point surfaceOrigin) {
mOuter.set(outer);
mInner.set(inner);
mTop.layout(outer.left, outer.top, outer.right, inner.top, surfaceOrigin);
mLeft.layout(outer.left, outer.top, inner.left, outer.bottom, surfaceOrigin);
mBottom.layout(outer.left, inner.bottom, outer.right, outer.bottom, surfaceOrigin);
mRight.layout(inner.right, outer.top, outer.right, outer.bottom, surfaceOrigin);
mFullWindowSurface.layout(outer.left, outer.top, outer.right, outer.bottom, surfaceOrigin);
} |
Lays out the letterbox, such that the area between the outer and inner
frames will be covered by black color surfaces.
The caller must use {@link #applySurfaceChanges} to apply the new layout to the surface.
@param outer the outer frame of the letterbox (this frame will be black, except the area
that intersects with the {code inner} frame), in global coordinates
@param inner the inner frame of the letterbox (this frame will be clear), in global
coordinates
@param surfaceOrigin the origin of the surface factory in global coordinates
| Letterbox::layout | java | Reginer/aosp-android-jar | android-35/src/com/android/server/wm/Letterbox.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/wm/Letterbox.java | MIT |
public Rect getInsets() {
return new Rect(
mLeft.getWidth(),
mTop.getHeight(),
mRight.getWidth(),
mBottom.getHeight());
} |
Gets the insets between the outer and inner rects.
| Letterbox::getInsets | java | Reginer/aosp-android-jar | android-35/src/com/android/server/wm/Letterbox.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/wm/Letterbox.java | MIT |
Rect getInnerFrame() {
return mInner;
} |
Gets the insets between the outer and inner rects.
public Rect getInsets() {
return new Rect(
mLeft.getWidth(),
mTop.getHeight(),
mRight.getWidth(),
mBottom.getHeight());
}
/** @return The frame that used to place the content. | Letterbox::getInnerFrame | java | Reginer/aosp-android-jar | android-35/src/com/android/server/wm/Letterbox.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/wm/Letterbox.java | MIT |
Rect getOuterFrame() {
return mOuter;
} |
Gets the insets between the outer and inner rects.
public Rect getInsets() {
return new Rect(
mLeft.getWidth(),
mTop.getHeight(),
mRight.getWidth(),
mBottom.getHeight());
}
/** @return The frame that used to place the content.
Rect getInnerFrame() {
return mInner;
}
/** @return The frame that contains the inner frame and the insets. | Letterbox::getOuterFrame | java | Reginer/aosp-android-jar | android-35/src/com/android/server/wm/Letterbox.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/wm/Letterbox.java | MIT |
boolean notIntersectsOrFullyContains(Rect rect) {
int emptyCount = 0;
int noOverlappingCount = 0;
for (LetterboxSurface surface : mSurfaces) {
final Rect surfaceRect = surface.mLayoutFrameGlobal;
if (surfaceRect.isEmpty()) {
// empty letterbox
emptyCount++;
} else if (!Rect.intersects(surfaceRect, rect)) {
// no overlapping
noOverlappingCount++;
} else if (surfaceRect.contains(rect)) {
// overlapping and covered
return true;
}
}
return (emptyCount + noOverlappingCount) == mSurfaces.length;
} |
Returns {@code true} if the letterbox does not overlap with the bar, or the letterbox can
fully cover the window frame.
@param rect The area of the window frame.
| Letterbox::notIntersectsOrFullyContains | java | Reginer/aosp-android-jar | android-35/src/com/android/server/wm/Letterbox.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/wm/Letterbox.java | MIT |
public void hide() {
layout(EMPTY_RECT, EMPTY_RECT, ZERO_POINT);
} |
Hides the letterbox.
The caller must use {@link #applySurfaceChanges} to apply the new layout to the surface.
| Letterbox::hide | java | Reginer/aosp-android-jar | android-35/src/com/android/server/wm/Letterbox.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/wm/Letterbox.java | MIT |
public void destroy() {
mOuter.setEmpty();
mInner.setEmpty();
for (LetterboxSurface surface : mSurfaces) {
surface.remove();
}
mFullWindowSurface.remove();
} |
Destroys the managed {@link SurfaceControl}s.
| Letterbox::destroy | java | Reginer/aosp-android-jar | android-35/src/com/android/server/wm/Letterbox.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/wm/Letterbox.java | MIT |
public boolean needsApplySurfaceChanges() {
if (useFullWindowSurface()) {
return mFullWindowSurface.needsApplySurfaceChanges();
}
for (LetterboxSurface surface : mSurfaces) {
if (surface.needsApplySurfaceChanges()) {
return true;
}
}
return false;
} |
Destroys the managed {@link SurfaceControl}s.
public void destroy() {
mOuter.setEmpty();
mInner.setEmpty();
for (LetterboxSurface surface : mSurfaces) {
surface.remove();
}
mFullWindowSurface.remove();
}
/** Returns whether a call to {@link #applySurfaceChanges} would change the surface. | Letterbox::needsApplySurfaceChanges | java | Reginer/aosp-android-jar | android-35/src/com/android/server/wm/Letterbox.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/wm/Letterbox.java | MIT |
public void applySurfaceChanges(@NonNull SurfaceControl.Transaction t,
@NonNull SurfaceControl.Transaction inputT) {
if (useFullWindowSurface()) {
mFullWindowSurface.applySurfaceChanges(t, inputT);
for (LetterboxSurface surface : mSurfaces) {
surface.remove();
}
} else {
for (LetterboxSurface surface : mSurfaces) {
surface.applySurfaceChanges(t, inputT);
}
mFullWindowSurface.remove();
}
} |
Destroys the managed {@link SurfaceControl}s.
public void destroy() {
mOuter.setEmpty();
mInner.setEmpty();
for (LetterboxSurface surface : mSurfaces) {
surface.remove();
}
mFullWindowSurface.remove();
}
/** Returns whether a call to {@link #applySurfaceChanges} would change the surface.
public boolean needsApplySurfaceChanges() {
if (useFullWindowSurface()) {
return mFullWindowSurface.needsApplySurfaceChanges();
}
for (LetterboxSurface surface : mSurfaces) {
if (surface.needsApplySurfaceChanges()) {
return true;
}
}
return false;
}
/** Applies surface changes such as colour, window crop, position and input info. | Letterbox::applySurfaceChanges | java | Reginer/aosp-android-jar | android-35/src/com/android/server/wm/Letterbox.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/wm/Letterbox.java | MIT |
void attachInput(WindowState win) {
if (useFullWindowSurface()) {
mFullWindowSurface.attachInput(win);
} else {
for (LetterboxSurface surface : mSurfaces) {
surface.attachInput(win);
}
}
} |
Destroys the managed {@link SurfaceControl}s.
public void destroy() {
mOuter.setEmpty();
mInner.setEmpty();
for (LetterboxSurface surface : mSurfaces) {
surface.remove();
}
mFullWindowSurface.remove();
}
/** Returns whether a call to {@link #applySurfaceChanges} would change the surface.
public boolean needsApplySurfaceChanges() {
if (useFullWindowSurface()) {
return mFullWindowSurface.needsApplySurfaceChanges();
}
for (LetterboxSurface surface : mSurfaces) {
if (surface.needsApplySurfaceChanges()) {
return true;
}
}
return false;
}
/** Applies surface changes such as colour, window crop, position and input info.
public void applySurfaceChanges(@NonNull SurfaceControl.Transaction t,
@NonNull SurfaceControl.Transaction inputT) {
if (useFullWindowSurface()) {
mFullWindowSurface.applySurfaceChanges(t, inputT);
for (LetterboxSurface surface : mSurfaces) {
surface.remove();
}
} else {
for (LetterboxSurface surface : mSurfaces) {
surface.applySurfaceChanges(t, inputT);
}
mFullWindowSurface.remove();
}
}
/** Enables touches to slide into other neighboring surfaces. | Letterbox::attachInput | java | Reginer/aosp-android-jar | android-35/src/com/android/server/wm/Letterbox.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/wm/Letterbox.java | MIT |
private boolean useFullWindowSurface() {
return mAreCornersRounded.getAsBoolean() || mHasWallpaperBackgroundSupplier.getAsBoolean();
} |
Returns {@code true} when using {@link #mFullWindowSurface} instead of {@link mSurfaces}.
| Letterbox::useFullWindowSurface | java | Reginer/aosp-android-jar | android-35/src/com/android/server/wm/Letterbox.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/wm/Letterbox.java | MIT |
Request() {
reset();
} |
Ensure constructed request matches reset instance.
| Request::Request | java | Reginer/aosp-android-jar | android-33/src/com/android/server/wm/ActivityStarter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/wm/ActivityStarter.java | MIT |
void reset() {
caller = null;
intent = null;
intentGrants = null;
ephemeralIntent = null;
resolvedType = null;
activityInfo = null;
resolveInfo = null;
voiceSession = null;
voiceInteractor = null;
resultTo = null;
resultWho = null;
requestCode = 0;
callingPid = DEFAULT_CALLING_PID;
callingUid = DEFAULT_CALLING_UID;
callingPackage = null;
callingFeatureId = null;
realCallingPid = DEFAULT_REAL_CALLING_PID;
realCallingUid = DEFAULT_REAL_CALLING_UID;
startFlags = 0;
activityOptions = null;
ignoreTargetSecurity = false;
componentSpecified = false;
outActivity = null;
inTask = null;
inTaskFragment = null;
reason = null;
profilerInfo = null;
globalConfig = null;
userId = 0;
waitResult = null;
avoidMoveToFront = false;
allowPendingRemoteAnimationRegistryLookup = true;
filterCallingUid = UserHandle.USER_NULL;
originatingPendingIntent = null;
allowBackgroundActivityStart = false;
errorCallbackToken = null;
} |
Sets values back to the initial state, clearing any held references.
| Request::reset | java | Reginer/aosp-android-jar | android-33/src/com/android/server/wm/ActivityStarter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/wm/ActivityStarter.java | MIT |
void set(@NonNull Request request) {
caller = request.caller;
intent = request.intent;
intentGrants = request.intentGrants;
ephemeralIntent = request.ephemeralIntent;
resolvedType = request.resolvedType;
activityInfo = request.activityInfo;
resolveInfo = request.resolveInfo;
voiceSession = request.voiceSession;
voiceInteractor = request.voiceInteractor;
resultTo = request.resultTo;
resultWho = request.resultWho;
requestCode = request.requestCode;
callingPid = request.callingPid;
callingUid = request.callingUid;
callingPackage = request.callingPackage;
callingFeatureId = request.callingFeatureId;
realCallingPid = request.realCallingPid;
realCallingUid = request.realCallingUid;
startFlags = request.startFlags;
activityOptions = request.activityOptions;
ignoreTargetSecurity = request.ignoreTargetSecurity;
componentSpecified = request.componentSpecified;
outActivity = request.outActivity;
inTask = request.inTask;
inTaskFragment = request.inTaskFragment;
reason = request.reason;
profilerInfo = request.profilerInfo;
globalConfig = request.globalConfig;
userId = request.userId;
waitResult = request.waitResult;
avoidMoveToFront = request.avoidMoveToFront;
allowPendingRemoteAnimationRegistryLookup
= request.allowPendingRemoteAnimationRegistryLookup;
filterCallingUid = request.filterCallingUid;
originatingPendingIntent = request.originatingPendingIntent;
allowBackgroundActivityStart = request.allowBackgroundActivityStart;
errorCallbackToken = request.errorCallbackToken;
} |
Adopts all values from passed in request.
| Request::set | java | Reginer/aosp-android-jar | android-33/src/com/android/server/wm/ActivityStarter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/wm/ActivityStarter.java | MIT |
void resolveActivity(ActivityTaskSupervisor supervisor) {
if (realCallingPid == Request.DEFAULT_REAL_CALLING_PID) {
realCallingPid = Binder.getCallingPid();
}
if (realCallingUid == Request.DEFAULT_REAL_CALLING_UID) {
realCallingUid = Binder.getCallingUid();
}
if (callingUid >= 0) {
callingPid = -1;
} else if (caller == null) {
callingPid = realCallingPid;
callingUid = realCallingUid;
} else {
callingPid = callingUid = -1;
}
// To determine the set of needed Uri permission grants, we need the
// "resolved" calling UID, where we try our best to identify the
// actual caller that is starting this activity
int resolvedCallingUid = callingUid;
if (caller != null) {
synchronized (supervisor.mService.mGlobalLock) {
final WindowProcessController callerApp = supervisor.mService
.getProcessController(caller);
if (callerApp != null) {
resolvedCallingUid = callerApp.mInfo.uid;
}
}
}
// Save a copy in case ephemeral needs it
ephemeralIntent = new Intent(intent);
// Don't modify the client's object!
intent = new Intent(intent);
if (intent.getComponent() != null
&& !(Intent.ACTION_VIEW.equals(intent.getAction()) && intent.getData() == null)
&& !Intent.ACTION_INSTALL_INSTANT_APP_PACKAGE.equals(intent.getAction())
&& !Intent.ACTION_RESOLVE_INSTANT_APP_PACKAGE.equals(intent.getAction())
&& supervisor.mService.getPackageManagerInternalLocked()
.isInstantAppInstallerComponent(intent.getComponent())) {
// Intercept intents targeted directly to the ephemeral installer the ephemeral
// installer should never be started with a raw Intent; instead adjust the intent
// so it looks like a "normal" instant app launch.
intent.setComponent(null /* component */);
}
resolveInfo = supervisor.resolveIntent(intent, resolvedType, userId,
0 /* matchFlags */,
computeResolveFilterUid(callingUid, realCallingUid, filterCallingUid));
if (resolveInfo == null) {
final UserInfo userInfo = supervisor.getUserInfo(userId);
if (userInfo != null && userInfo.isManagedProfile()) {
// Special case for managed profiles, if attempting to launch non-cryto aware
// app in a locked managed profile from an unlocked parent allow it to resolve
// as user will be sent via confirm credentials to unlock the profile.
final UserManager userManager = UserManager.get(supervisor.mService.mContext);
boolean profileLockedAndParentUnlockingOrUnlocked = false;
final long token = Binder.clearCallingIdentity();
try {
final UserInfo parent = userManager.getProfileParent(userId);
profileLockedAndParentUnlockingOrUnlocked = (parent != null)
&& userManager.isUserUnlockingOrUnlocked(parent.id)
&& !userManager.isUserUnlockingOrUnlocked(userId);
} finally {
Binder.restoreCallingIdentity(token);
}
if (profileLockedAndParentUnlockingOrUnlocked) {
resolveInfo = supervisor.resolveIntent(intent, resolvedType, userId,
PackageManager.MATCH_DIRECT_BOOT_AWARE
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
computeResolveFilterUid(callingUid, realCallingUid,
filterCallingUid));
}
}
}
// Collect information about the target of the Intent.
activityInfo = supervisor.resolveActivity(intent, resolveInfo, startFlags,
profilerInfo);
// Carefully collect grants without holding lock
if (activityInfo != null) {
intentGrants = supervisor.mService.mUgmInternal.checkGrantUriPermissionFromIntent(
intent, resolvedCallingUid, activityInfo.applicationInfo.packageName,
UserHandle.getUserId(activityInfo.applicationInfo.uid));
}
} |
Resolve activity from the given intent for this launch.
| Request::resolveActivity | java | Reginer/aosp-android-jar | android-33/src/com/android/server/wm/ActivityStarter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/wm/ActivityStarter.java | MIT |
void set(ActivityStarter starter) {
mStartActivity = starter.mStartActivity;
mIntent = starter.mIntent;
mCallingUid = starter.mCallingUid;
mOptions = starter.mOptions;
mRestrictedBgActivity = starter.mRestrictedBgActivity;
mLaunchTaskBehind = starter.mLaunchTaskBehind;
mLaunchFlags = starter.mLaunchFlags;
mLaunchMode = starter.mLaunchMode;
mLaunchParams.set(starter.mLaunchParams);
mNotTop = starter.mNotTop;
mDoResume = starter.mDoResume;
mStartFlags = starter.mStartFlags;
mSourceRecord = starter.mSourceRecord;
mPreferredTaskDisplayArea = starter.mPreferredTaskDisplayArea;
mPreferredWindowingMode = starter.mPreferredWindowingMode;
mInTask = starter.mInTask;
mInTaskFragment = starter.mInTaskFragment;
mAddingToTask = starter.mAddingToTask;
mNewTaskInfo = starter.mNewTaskInfo;
mNewTaskIntent = starter.mNewTaskIntent;
mSourceRootTask = starter.mSourceRootTask;
mTargetTask = starter.mTargetTask;
mTargetRootTask = starter.mTargetRootTask;
mIsTaskCleared = starter.mIsTaskCleared;
mMovedToFront = starter.mMovedToFront;
mNoAnimation = starter.mNoAnimation;
mAvoidMoveToFront = starter.mAvoidMoveToFront;
mFrozeTaskList = starter.mFrozeTaskList;
mVoiceSession = starter.mVoiceSession;
mVoiceInteractor = starter.mVoiceInteractor;
mIntentDelivered = starter.mIntentDelivered;
mLastStartActivityResult = starter.mLastStartActivityResult;
mLastStartActivityTimeMs = starter.mLastStartActivityTimeMs;
mLastStartReason = starter.mLastStartReason;
mRequest.set(starter.mRequest);
} |
Effectively duplicates the starter passed in. All state and request values will be
mirrored.
@param starter
| Request::set | java | Reginer/aosp-android-jar | android-33/src/com/android/server/wm/ActivityStarter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/wm/ActivityStarter.java | MIT |
int execute() {
try {
// Refuse possible leaked file descriptors
if (mRequest.intent != null && mRequest.intent.hasFileDescriptors()) {
throw new IllegalArgumentException("File descriptors passed in Intent");
}
final LaunchingState launchingState;
synchronized (mService.mGlobalLock) {
final ActivityRecord caller = ActivityRecord.forTokenLocked(mRequest.resultTo);
final int callingUid = mRequest.realCallingUid == Request.DEFAULT_REAL_CALLING_UID
? Binder.getCallingUid() : mRequest.realCallingUid;
launchingState = mSupervisor.getActivityMetricsLogger().notifyActivityLaunching(
mRequest.intent, caller, callingUid);
}
// If the caller hasn't already resolved the activity, we're willing
// to do so here. If the caller is already holding the WM lock here,
// and we need to check dynamic Uri permissions, then we're forced
// to assume those permissions are denied to avoid deadlocking.
if (mRequest.activityInfo == null) {
mRequest.resolveActivity(mSupervisor);
}
// Add checkpoint for this shutdown or reboot attempt, so we can record the original
// intent action and package name.
if (mRequest.intent != null) {
String intentAction = mRequest.intent.getAction();
String callingPackage = mRequest.callingPackage;
if (intentAction != null && callingPackage != null
&& (Intent.ACTION_REQUEST_SHUTDOWN.equals(intentAction)
|| Intent.ACTION_SHUTDOWN.equals(intentAction)
|| Intent.ACTION_REBOOT.equals(intentAction))) {
ShutdownCheckPoints.recordCheckPoint(intentAction, callingPackage, null);
}
}
int res;
synchronized (mService.mGlobalLock) {
final boolean globalConfigWillChange = mRequest.globalConfig != null
&& mService.getGlobalConfiguration().diff(mRequest.globalConfig) != 0;
final Task rootTask = mRootWindowContainer.getTopDisplayFocusedRootTask();
if (rootTask != null) {
rootTask.mConfigWillChange = globalConfigWillChange;
}
ProtoLog.v(WM_DEBUG_CONFIGURATION, "Starting activity when config "
+ "will change = %b", globalConfigWillChange);
final long origId = Binder.clearCallingIdentity();
res = resolveToHeavyWeightSwitcherIfNeeded();
if (res != START_SUCCESS) {
return res;
}
res = executeRequest(mRequest);
Binder.restoreCallingIdentity(origId);
if (globalConfigWillChange) {
// If the caller also wants to switch to a new configuration, do so now.
// This allows a clean switch, as we are waiting for the current activity
// to pause (so we will not destroy it), and have not yet started the
// next activity.
mService.mAmInternal.enforceCallingPermission(
android.Manifest.permission.CHANGE_CONFIGURATION,
"updateConfiguration()");
if (rootTask != null) {
rootTask.mConfigWillChange = false;
}
ProtoLog.v(WM_DEBUG_CONFIGURATION,
"Updating to new configuration after starting activity.");
mService.updateConfigurationLocked(mRequest.globalConfig, null, false);
}
// The original options may have additional info about metrics. The mOptions is not
// used here because it may be cleared in setTargetRootTaskIfNeeded.
final ActivityOptions originalOptions = mRequest.activityOptions != null
? mRequest.activityOptions.getOriginalOptions() : null;
// If the new record is the one that started, a new activity has created.
final boolean newActivityCreated = mStartActivity == mLastStartActivityRecord;
// Notify ActivityMetricsLogger that the activity has launched.
// ActivityMetricsLogger will then wait for the windows to be drawn and populate
// WaitResult.
mSupervisor.getActivityMetricsLogger().notifyActivityLaunched(launchingState, res,
newActivityCreated, mLastStartActivityRecord, originalOptions);
if (mRequest.waitResult != null) {
mRequest.waitResult.result = res;
res = waitResultIfNeeded(mRequest.waitResult, mLastStartActivityRecord,
launchingState);
}
return getExternalResult(res);
}
} finally {
onExecutionComplete();
}
} |
Resolve necessary information according the request parameters provided earlier, and execute
the request which begin the journey of starting an activity.
@return The starter result.
| Request::execute | java | Reginer/aosp-android-jar | android-33/src/com/android/server/wm/ActivityStarter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/wm/ActivityStarter.java | MIT |
ActivityStarter setCallingPid(int pid) {
mRequest.callingPid = pid;
return this;
} |
Sets the pid of the caller who originally started the activity.
Normally, the pid/uid would be the calling pid from the binder call.
However, in case of a {@link PendingIntent}, the pid/uid pair of the caller is considered
the original entity that created the pending intent, in contrast to setRealCallingPid/Uid,
which represents the entity who invoked pending intent via {@link PendingIntent#send}.
| Request::setCallingPid | java | Reginer/aosp-android-jar | android-33/src/com/android/server/wm/ActivityStarter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/wm/ActivityStarter.java | MIT |
ActivityStarter setCallingUid(int uid) {
mRequest.callingUid = uid;
return this;
} |
Sets the uid of the caller who originally started the activity.
@see #setCallingPid
| Request::setCallingUid | java | Reginer/aosp-android-jar | android-33/src/com/android/server/wm/ActivityStarter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/wm/ActivityStarter.java | MIT |
ActivityStarter setRealCallingPid(int pid) {
mRequest.realCallingPid = pid;
return this;
} |
Sets the pid of the caller who requested to launch the activity.
The pid/uid represents the caller who launches the activity in this request.
It will almost same as setCallingPid/Uid except when processing {@link PendingIntent}:
the pid/uid will be the caller who called {@link PendingIntent#send()}.
@see #setCallingPid
| Request::setRealCallingPid | java | Reginer/aosp-android-jar | android-33/src/com/android/server/wm/ActivityStarter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/wm/ActivityStarter.java | MIT |
ActivityStarter setRealCallingUid(int uid) {
mRequest.realCallingUid = uid;
return this;
} |
Sets the uid of the caller who requested to launch the activity.
@see #setRealCallingPid
| Request::setRealCallingUid | java | Reginer/aosp-android-jar | android-33/src/com/android/server/wm/ActivityStarter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/wm/ActivityStarter.java | MIT |
private int getColor(float fx, float fy) {
int x = getCoordinate(Math.round(fx), mImage.getWidth(), mTileModeX);
int y = getCoordinate(Math.round(fy), mImage.getHeight(), mTileModeY);
return mImage.getRGB(x, y);
} |
Returns a color for an arbitrary point.
| BitmapShaderContext::getColor | java | Reginer/aosp-android-jar | android-32/src/android/graphics/BitmapShader_Delegate.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/graphics/BitmapShader_Delegate.java | MIT |
public void notifyShortcutTriggered() {
if (DEBUG_ALL) {
Slog.i(mLogTag, "notifyShortcutTriggered():");
}
if (mDetectShortcutTrigger) {
handleShortcutTriggered();
mCallback.onShortcutTriggered(mDisplayId, getMode());
}
} |
Called when the shortcut target is magnification.
| MagnificationGestureHandler::notifyShortcutTriggered | java | Reginer/aosp-android-jar | android-31/src/com/android/server/accessibility/magnification/MagnificationGestureHandler.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/accessibility/magnification/MagnificationGestureHandler.java | MIT |
public FileInputStream(String name) throws FileNotFoundException {
this(name != null ? new File(name) : null);
} |
Creates a <code>FileInputStream</code> by
opening a connection to an actual file,
the file named by the path name <code>name</code>
in the file system. A new <code>FileDescriptor</code>
object is created to represent this file
connection.
<p>
First, if there is a security
manager, its <code>checkRead</code> method
is called with the <code>name</code> argument
as its argument.
<p>
If the named file does not exist, is a directory rather than a regular
file, or for some other reason cannot be opened for reading then a
<code>FileNotFoundException</code> is thrown.
@param name the system-dependent file name.
@exception FileNotFoundException if the file does not exist,
is a directory rather than a regular file,
or for some other reason cannot be opened for
reading.
@exception SecurityException if a security manager exists and its
<code>checkRead</code> method denies read access
to the file.
@see java.lang.SecurityManager#checkRead(java.lang.String)
| FileInputStream::FileInputStream | java | Reginer/aosp-android-jar | android-34/src/java/io/FileInputStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java | MIT |
public FileInputStream(File file) throws FileNotFoundException {
String name = (file != null ? file.getPath() : null);
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(name);
}
if (name == null) {
throw new NullPointerException();
}
if (file.isInvalid()) {
throw new FileNotFoundException("Invalid file path");
}
// BEGIN Android-changed: Open files using IoBridge to share BlockGuard & StrictMode logic.
// http://b/112107427
// fd = new FileDescriptor();
fd = IoBridge.open(name, O_RDONLY);
// END Android-changed: Open files using IoBridge to share BlockGuard & StrictMode logic.
// Android-changed: Tracking mechanism for FileDescriptor sharing.
// fd.attach(this);
isFdOwner = true;
path = name;
// Android-removed: Open files using IoBridge to share BlockGuard & StrictMode logic.
// open(name);
// Android-added: File descriptor ownership tracking.
IoUtils.setFdOwner(this.fd, this);
// Android-added: CloseGuard support.
guard.open("close");
} |
Creates a <code>FileInputStream</code> by
opening a connection to an actual file,
the file named by the <code>File</code>
object <code>file</code> in the file system.
A new <code>FileDescriptor</code> object
is created to represent this file connection.
<p>
First, if there is a security manager,
its <code>checkRead</code> method is called
with the path represented by the <code>file</code>
argument as its argument.
<p>
If the named file does not exist, is a directory rather than a regular
file, or for some other reason cannot be opened for reading then a
<code>FileNotFoundException</code> is thrown.
@param file the file to be opened for reading.
@exception FileNotFoundException if the file does not exist,
is a directory rather than a regular file,
or for some other reason cannot be opened for
reading.
@exception SecurityException if a security manager exists and its
<code>checkRead</code> method denies read access to the file.
@see java.io.File#getPath()
@see java.lang.SecurityManager#checkRead(java.lang.String)
| FileInputStream::FileInputStream | java | Reginer/aosp-android-jar | android-34/src/java/io/FileInputStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java | MIT |
public FileInputStream(FileDescriptor fdObj) {
// Android-changed: Delegate to added hidden constructor.
this(fdObj, false /* isFdOwner */);
} |
Creates a <code>FileInputStream</code> by using the file descriptor
<code>fdObj</code>, which represents an existing connection to an
actual file in the file system.
<p>
If there is a security manager, its <code>checkRead</code> method is
called with the file descriptor <code>fdObj</code> as its argument to
see if it's ok to read the file descriptor. If read access is denied
to the file descriptor a <code>SecurityException</code> is thrown.
<p>
If <code>fdObj</code> is null then a <code>NullPointerException</code>
is thrown.
<p>
This constructor does not throw an exception if <code>fdObj</code>
is {@link java.io.FileDescriptor#valid() invalid}.
However, if the methods are invoked on the resulting stream to attempt
I/O on the stream, an <code>IOException</code> is thrown.
<p>
Android-specific warning: {@link #close()} method doesn't close the {@code fdObj} provided,
because this object doesn't own the file descriptor, but the caller does. The caller can
call {@link android.system.Os#close(FileDescriptor)} to close the fd.
@param fdObj the file descriptor to be opened for reading.
| FileInputStream::FileInputStream | java | Reginer/aosp-android-jar | android-34/src/java/io/FileInputStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java | MIT |
public FileInputStream(FileDescriptor fdObj, boolean isFdOwner) {
if (fdObj == null) {
// Android-changed: Improved NullPointerException message.
throw new NullPointerException("fdObj == null");
}
fd = fdObj;
path = null;
// Android-changed: FileDescriptor ownership tracking mechanism.
/*
/*
* FileDescriptor is being shared by streams.
* Register this stream with FileDescriptor tracker.
*
fd.attach(this);
*/
this.isFdOwner = isFdOwner;
if (isFdOwner) {
IoUtils.setFdOwner(this.fd, this);
}
} |
Creates a <code>FileInputStream</code> by using the file descriptor
<code>fdObj</code>, which represents an existing connection to an
actual file in the file system.
<p>
If there is a security manager, its <code>checkRead</code> method is
called with the file descriptor <code>fdObj</code> as its argument to
see if it's ok to read the file descriptor. If read access is denied
to the file descriptor a <code>SecurityException</code> is thrown.
<p>
If <code>fdObj</code> is null then a <code>NullPointerException</code>
is thrown.
<p>
This constructor does not throw an exception if <code>fdObj</code>
is {@link java.io.FileDescriptor#valid() invalid}.
However, if the methods are invoked on the resulting stream to attempt
I/O on the stream, an <code>IOException</code> is thrown.
<p>
Android-specific warning: {@link #close()} method doesn't close the {@code fdObj} provided,
because this object doesn't own the file descriptor, but the caller does. The caller can
call {@link android.system.Os#close(FileDescriptor)} to close the fd.
@param fdObj the file descriptor to be opened for reading.
public FileInputStream(FileDescriptor fdObj) {
// Android-changed: Delegate to added hidden constructor.
this(fdObj, false /* isFdOwner */);
}
// Android-added: Internal/hidden constructor for specifying FileDescriptor ownership.
// Android-removed: SecurityManager calls.
/** @hide | FileInputStream::FileInputStream | java | Reginer/aosp-android-jar | android-34/src/java/io/FileInputStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java | MIT |
public int read() throws IOException {
// Android-changed: Read methods delegate to read(byte[], int, int) to share Android logic.
byte[] b = new byte[1];
return (read(b, 0, 1) != -1) ? b[0] & 0xff : -1;
} |
Reads a byte of data from this input stream. This method blocks
if no input is yet available.
@return the next byte of data, or <code>-1</code> if the end of the
file is reached.
@exception IOException if an I/O error occurs.
| FileInputStream::read | java | Reginer/aosp-android-jar | android-34/src/java/io/FileInputStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java | MIT |
public int read(byte b[]) throws IOException {
// Android-changed: Read methods delegate to read(byte[], int, int) to share Android logic.
return read(b, 0, b.length);
} |
Reads up to <code>b.length</code> bytes of data from this input
stream into an array of bytes. This method blocks until some input
is available.
@param b the buffer into which the data is read.
@return the total number of bytes read into the buffer, or
<code>-1</code> if there is no more data because the end of
the file has been reached.
@exception IOException if an I/O error occurs.
| FileInputStream::read | java | Reginer/aosp-android-jar | android-34/src/java/io/FileInputStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java | MIT |
public int read(byte b[], int off, int len) throws IOException {
// Android-added: close() check before I/O.
if (closed && len > 0) {
throw new IOException("Stream Closed");
}
// Android-added: Tracking of unbuffered I/O.
tracker.trackIo(len, IoTracker.Mode.READ);
// Android-changed: Use IoBridge instead of calling native method.
return IoBridge.read(fd, b, off, len);
} |
Reads up to <code>len</code> bytes of data from this input stream
into an array of bytes. If <code>len</code> is not zero, the method
blocks until some input is available; otherwise, no
bytes are read and <code>0</code> is returned.
@param b the buffer into which the data is read.
@param off the start offset in the destination array <code>b</code>
@param len the maximum number of bytes read.
@return the total number of bytes read into the buffer, or
<code>-1</code> if there is no more data because the end of
the file has been reached.
@exception NullPointerException If <code>b</code> is <code>null</code>.
@exception IndexOutOfBoundsException If <code>off</code> is negative,
<code>len</code> is negative, or <code>len</code> is greater than
<code>b.length - off</code>
@exception IOException if an I/O error occurs.
| FileInputStream::read | java | Reginer/aosp-android-jar | android-34/src/java/io/FileInputStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java | MIT |
public void close() throws IOException {
synchronized (closeLock) {
if (closed) {
return;
}
closed = true;
}
// Android-added: CloseGuard support.
guard.close();
if (channel != null) {
channel.close();
}
// BEGIN Android-changed: Close handling / notification of blocked threads.
if (isFdOwner) {
IoBridge.closeAndSignalBlockedThreads(fd);
}
// END Android-changed: Close handling / notification of blocked threads.
} |
Closes this file input stream and releases any system resources
associated with the stream.
<p> If this stream has an associated channel then the channel is closed
as well.
@exception IOException if an I/O error occurs.
@revised 1.4
@spec JSR-51
| UseManualSkipException::close | java | Reginer/aosp-android-jar | android-34/src/java/io/FileInputStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java | MIT |
public final FileDescriptor getFD() throws IOException {
if (fd != null) {
return fd;
}
throw new IOException();
} |
Returns the <code>FileDescriptor</code>
object that represents the connection to
the actual file in the file system being
used by this <code>FileInputStream</code>.
@return the file descriptor object associated with this stream.
@exception IOException if an I/O error occurs.
@see java.io.FileDescriptor
| UseManualSkipException::getFD | java | Reginer/aosp-android-jar | android-34/src/java/io/FileInputStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java | MIT |
public FileChannel getChannel() {
synchronized (this) {
if (channel == null) {
channel = FileChannelImpl.open(fd, path, true, false, this);
}
return channel;
}
} |
Returns the unique {@link java.nio.channels.FileChannel FileChannel}
object associated with this file input stream.
<p> The initial {@link java.nio.channels.FileChannel#position()
position} of the returned channel will be equal to the
number of bytes read from the file so far. Reading bytes from this
stream will increment the channel's position. Changing the channel's
position, either explicitly or by reading, will change this stream's
file position.
@return the file channel associated with this file input stream
@since 1.4
@spec JSR-51
| UseManualSkipException::getChannel | java | Reginer/aosp-android-jar | android-34/src/java/io/FileInputStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java | MIT |
protected void finalize() throws IOException {
// Android-added: CloseGuard support.
if (guard != null) {
guard.warnIfOpen();
}
if ((fd != null) && (fd != FileDescriptor.in)) {
// Android-removed: Obsoleted comment about shared FileDescriptor handling.
close();
}
} |
Ensures that the <code>close</code> method of this file input stream is
called when there are no more references to it.
@exception IOException if an I/O error occurs.
@see java.io.FileInputStream#close()
| UseManualSkipException::finalize | java | Reginer/aosp-android-jar | android-34/src/java/io/FileInputStream.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java | MIT |
public synchronized static void setDefault(Authenticator a) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
NetPermission setDefaultPermission
= new NetPermission("setDefaultAuthenticator");
sm.checkPermission(setDefaultPermission);
}
theAuthenticator = a;
} |
Sets the authenticator that will be used by the networking code
when a proxy or an HTTP server asks for authentication.
<p>
First, if there is a security manager, its {@code checkPermission}
method is called with a
{@code NetPermission("setDefaultAuthenticator")} permission.
This may result in a java.lang.SecurityException.
@param a The authenticator to be set. If a is {@code null} then
any previously set authenticator is removed.
@throws SecurityException
if a security manager exists and its
{@code checkPermission} method doesn't allow
setting the default authenticator.
@see SecurityManager#checkPermission
@see java.net.NetPermission
| RequestorType::setDefault | java | Reginer/aosp-android-jar | android-35/src/java/net/Authenticator.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java | MIT |
public static PasswordAuthentication requestPasswordAuthentication(
InetAddress addr,
int port,
String protocol,
String prompt,
String scheme) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
NetPermission requestPermission
= new NetPermission("requestPasswordAuthentication");
sm.checkPermission(requestPermission);
}
Authenticator a = theAuthenticator;
if (a == null) {
return null;
} else {
synchronized(a) {
a.reset();
a.requestingSite = addr;
a.requestingPort = port;
a.requestingProtocol = protocol;
a.requestingPrompt = prompt;
a.requestingScheme = scheme;
return a.getPasswordAuthentication();
}
}
} |
Ask the authenticator that has been registered with the system
for a password.
<p>
First, if there is a security manager, its {@code checkPermission}
method is called with a
{@code NetPermission("requestPasswordAuthentication")} permission.
This may result in a java.lang.SecurityException.
@param addr The InetAddress of the site requesting authorization,
or null if not known.
@param port the port for the requested connection
@param protocol The protocol that's requesting the connection
({@link java.net.Authenticator#getRequestingProtocol()})
@param prompt A prompt string for the user
@param scheme The authentication scheme
@return The username/password, or null if one can't be gotten.
@throws SecurityException
if a security manager exists and its
{@code checkPermission} method doesn't allow
the password authentication request.
@see SecurityManager#checkPermission
@see java.net.NetPermission
| RequestorType::requestPasswordAuthentication | java | Reginer/aosp-android-jar | android-35/src/java/net/Authenticator.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java | MIT |
public static PasswordAuthentication requestPasswordAuthentication(
String host,
InetAddress addr,
int port,
String protocol,
String prompt,
String scheme) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
NetPermission requestPermission
= new NetPermission("requestPasswordAuthentication");
sm.checkPermission(requestPermission);
}
Authenticator a = theAuthenticator;
if (a == null) {
return null;
} else {
synchronized(a) {
a.reset();
a.requestingHost = host;
a.requestingSite = addr;
a.requestingPort = port;
a.requestingProtocol = protocol;
a.requestingPrompt = prompt;
a.requestingScheme = scheme;
return a.getPasswordAuthentication();
}
}
} |
Ask the authenticator that has been registered with the system
for a password. This is the preferred method for requesting a password
because the hostname can be provided in cases where the InetAddress
is not available.
<p>
First, if there is a security manager, its {@code checkPermission}
method is called with a
{@code NetPermission("requestPasswordAuthentication")} permission.
This may result in a java.lang.SecurityException.
@param host The hostname of the site requesting authentication.
@param addr The InetAddress of the site requesting authentication,
or null if not known.
@param port the port for the requested connection.
@param protocol The protocol that's requesting the connection
({@link java.net.Authenticator#getRequestingProtocol()})
@param prompt A prompt string for the user which identifies the authentication realm.
@param scheme The authentication scheme
@return The username/password, or null if one can't be gotten.
@throws SecurityException
if a security manager exists and its
{@code checkPermission} method doesn't allow
the password authentication request.
@see SecurityManager#checkPermission
@see java.net.NetPermission
@since 1.4
| RequestorType::requestPasswordAuthentication | java | Reginer/aosp-android-jar | android-35/src/java/net/Authenticator.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java | MIT |
public static PasswordAuthentication requestPasswordAuthentication(
String host,
InetAddress addr,
int port,
String protocol,
String prompt,
String scheme,
URL url,
RequestorType reqType) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
NetPermission requestPermission
= new NetPermission("requestPasswordAuthentication");
sm.checkPermission(requestPermission);
}
Authenticator a = theAuthenticator;
if (a == null) {
return null;
} else {
synchronized(a) {
a.reset();
a.requestingHost = host;
a.requestingSite = addr;
a.requestingPort = port;
a.requestingProtocol = protocol;
a.requestingPrompt = prompt;
a.requestingScheme = scheme;
a.requestingURL = url;
a.requestingAuthType = reqType;
return a.getPasswordAuthentication();
}
}
} |
Ask the authenticator that has been registered with the system
for a password.
<p>
First, if there is a security manager, its {@code checkPermission}
method is called with a
{@code NetPermission("requestPasswordAuthentication")} permission.
This may result in a java.lang.SecurityException.
@param host The hostname of the site requesting authentication.
@param addr The InetAddress of the site requesting authorization,
or null if not known.
@param port the port for the requested connection
@param protocol The protocol that's requesting the connection
({@link java.net.Authenticator#getRequestingProtocol()})
@param prompt A prompt string for the user
@param scheme The authentication scheme
@param url The requesting URL that caused the authentication
@param reqType The type (server or proxy) of the entity requesting
authentication.
@return The username/password, or null if one can't be gotten.
@throws SecurityException
if a security manager exists and its
{@code checkPermission} method doesn't allow
the password authentication request.
@see SecurityManager#checkPermission
@see java.net.NetPermission
@since 1.5
| RequestorType::requestPasswordAuthentication | java | Reginer/aosp-android-jar | android-35/src/java/net/Authenticator.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java | MIT |
protected final String getRequestingHost() {
return requestingHost;
} |
Gets the {@code hostname} of the
site or proxy requesting authentication, or {@code null}
if not available.
@return the hostname of the connection requiring authentication, or null
if it's not available.
@since 1.4
| RequestorType::getRequestingHost | java | Reginer/aosp-android-jar | android-35/src/java/net/Authenticator.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java | MIT |
protected final InetAddress getRequestingSite() {
return requestingSite;
} |
Gets the {@code InetAddress} of the
site requesting authorization, or {@code null}
if not available.
@return the InetAddress of the site requesting authorization, or null
if it's not available.
| RequestorType::getRequestingSite | java | Reginer/aosp-android-jar | android-35/src/java/net/Authenticator.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java | MIT |
protected final int getRequestingPort() {
return requestingPort;
} |
Gets the port number for the requested connection.
@return an {@code int} indicating the
port for the requested connection.
| RequestorType::getRequestingPort | java | Reginer/aosp-android-jar | android-35/src/java/net/Authenticator.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java | MIT |
protected final String getRequestingProtocol() {
return requestingProtocol;
} |
Give the protocol that's requesting the connection. Often this
will be based on a URL, but in a future JDK it could be, for
example, "SOCKS" for a password-protected SOCKS5 firewall.
@return the protocol, optionally followed by "/version", where
version is a version number.
@see java.net.URL#getProtocol()
| RequestorType::getRequestingProtocol | java | Reginer/aosp-android-jar | android-35/src/java/net/Authenticator.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java | MIT |
protected final String getRequestingPrompt() {
return requestingPrompt;
} |
Gets the prompt string given by the requestor.
@return the prompt string given by the requestor (realm for
http requests)
| RequestorType::getRequestingPrompt | java | Reginer/aosp-android-jar | android-35/src/java/net/Authenticator.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java | MIT |
protected final String getRequestingScheme() {
return requestingScheme;
} |
Gets the scheme of the requestor (the HTTP scheme
for an HTTP firewall, for example).
@return the scheme of the requestor
| RequestorType::getRequestingScheme | java | Reginer/aosp-android-jar | android-35/src/java/net/Authenticator.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java | MIT |
protected PasswordAuthentication getPasswordAuthentication() {
return null;
} |
Called when password authorization is needed. Subclasses should
override the default implementation, which returns null.
@return The PasswordAuthentication collected from the
user, or null if none is provided.
| RequestorType::getPasswordAuthentication | java | Reginer/aosp-android-jar | android-35/src/java/net/Authenticator.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java | MIT |
protected URL getRequestingURL () {
return requestingURL;
} |
Returns the URL that resulted in this
request for authentication.
@since 1.5
@return the requesting URL
| RequestorType::getRequestingURL | java | Reginer/aosp-android-jar | android-35/src/java/net/Authenticator.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java | MIT |
protected RequestorType getRequestorType () {
return requestingAuthType;
} |
Returns whether the requestor is a Proxy or a Server.
@since 1.5
@return the authentication type of the requestor
| RequestorType::getRequestorType | java | Reginer/aosp-android-jar | android-35/src/java/net/Authenticator.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java | MIT |
public GsmCdmaConnection (GsmCdmaPhone phone, DriverCall dc, GsmCdmaCallTracker ct, int index) {
super(phone.getPhoneType());
createWakeLock(phone.getContext());
acquireWakeLock();
mOwner = ct;
mHandler = new MyHandler(mOwner.getLooper());
mAddress = dc.number;
setEmergencyCallInfo(mOwner);
String forwardedNumber = TextUtils.isEmpty(dc.forwardedNumber) ? null : dc.forwardedNumber;
Rlog.i(LOG_TAG, "create, forwardedNumber=" + Rlog.pii(LOG_TAG, forwardedNumber));
mForwardedNumber = forwardedNumber == null ? null :
new ArrayList<>(Collections.singletonList(dc.forwardedNumber));
mIsIncoming = dc.isMT;
mCreateTime = System.currentTimeMillis();
mCnapName = dc.name;
mCnapNamePresentation = dc.namePresentation;
mNumberPresentation = dc.numberPresentation;
mUusInfo = dc.uusInfo;
mIndex = index;
mParent = parentFromDCState(dc.state);
mParent.attach(this, dc);
fetchDtmfToneDelay(phone);
setAudioQuality(getAudioQualityFromDC(dc.audioQuality));
setCallRadioTech(mOwner.getPhone().getCsCallRadioTech());
} |
{@hide}
public class GsmCdmaConnection extends Connection {
private static final String LOG_TAG = "GsmCdmaConnection";
private static final boolean DBG = true;
private static final boolean VDBG = false;
public static final String OTASP_NUMBER = "*22899";
//***** Instance Variables
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
GsmCdmaCallTracker mOwner;
GsmCdmaCall mParent;
boolean mDisconnected;
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
int mIndex; // index in GsmCdmaCallTracker.connections[], -1 if unassigned
// The GsmCdma index is 1 + this
/*
These time/timespan values are based on System.currentTimeMillis(),
i.e., "wall clock" time.
long mDisconnectTime;
UUSInfo mUusInfo;
int mPreciseCause = 0;
String mVendorCause;
Connection mOrigConnection;
Handler mHandler;
private PowerManager.WakeLock mPartialWakeLock;
// The cached delay to be used between DTMF tones fetched from carrier config.
private int mDtmfToneDelay = 0;
private TelephonyMetrics mMetrics = TelephonyMetrics.getInstance();
//***** Event Constants
static final int EVENT_DTMF_DONE = 1;
static final int EVENT_PAUSE_DONE = 2;
static final int EVENT_NEXT_POST_DIAL = 3;
static final int EVENT_WAKE_LOCK_TIMEOUT = 4;
static final int EVENT_DTMF_DELAY_DONE = 5;
//***** Constants
static final int PAUSE_DELAY_MILLIS_GSM = 3 * 1000;
static final int PAUSE_DELAY_MILLIS_CDMA = 2 * 1000;
static final int WAKE_LOCK_TIMEOUT_MILLIS = 60 * 1000;
//***** Inner Classes
class MyHandler extends Handler {
MyHandler(Looper l) {super(l);}
@Override
public void
handleMessage(Message msg) {
switch (msg.what) {
case EVENT_NEXT_POST_DIAL:
case EVENT_DTMF_DELAY_DONE:
case EVENT_PAUSE_DONE:
processNextPostDialChar();
break;
case EVENT_WAKE_LOCK_TIMEOUT:
releaseWakeLock();
break;
case EVENT_DTMF_DONE:
// We may need to add a delay specified by carrier between DTMF tones that are
// sent out.
mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_DTMF_DELAY_DONE),
mDtmfToneDelay);
break;
}
}
}
//***** Constructors
/** This is probably an MT call that we first saw in a CLCC response or a hand over. | MyHandler::GsmCdmaConnection | java | Reginer/aosp-android-jar | android-32/src/com/android/internal/telephony/GsmCdmaConnection.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/GsmCdmaConnection.java | MIT |
public GsmCdmaConnection (GsmCdmaPhone phone, String dialString, GsmCdmaCallTracker ct,
GsmCdmaCall parent, DialArgs dialArgs) {
super(phone.getPhoneType());
createWakeLock(phone.getContext());
acquireWakeLock();
mOwner = ct;
mHandler = new MyHandler(mOwner.getLooper());
mDialString = dialString;
if (!isPhoneTypeGsm()) {
Rlog.d(LOG_TAG, "[GsmCdmaConn] GsmCdmaConnection: dialString=" +
maskDialString(dialString));
dialString = formatDialString(dialString);
Rlog.d(LOG_TAG,
"[GsmCdmaConn] GsmCdmaConnection:formated dialString=" +
maskDialString(dialString));
}
mAddress = PhoneNumberUtils.extractNetworkPortionAlt(dialString);
if (dialArgs.isEmergency) {
setEmergencyCallInfo(mOwner);
// There was no emergency number info found for this call, however it is
// still marked as an emergency number. This may happen if it was a redialed
// non-detectable emergency call from IMS.
if (getEmergencyNumberInfo() == null) {
setNonDetectableEmergencyCallInfo(dialArgs.eccCategory);
}
}
mPostDialString = PhoneNumberUtils.extractPostDialPortion(dialString);
mIndex = -1;
mIsIncoming = false;
mCnapName = null;
mCnapNamePresentation = PhoneConstants.PRESENTATION_ALLOWED;
mNumberPresentation = PhoneConstants.PRESENTATION_ALLOWED;
mCreateTime = System.currentTimeMillis();
if (parent != null) {
mParent = parent;
if (isPhoneTypeGsm()) {
parent.attachFake(this, GsmCdmaCall.State.DIALING);
} else {
//for the three way call case, not change parent state
if (parent.mState == GsmCdmaCall.State.ACTIVE) {
parent.attachFake(this, GsmCdmaCall.State.ACTIVE);
} else {
parent.attachFake(this, GsmCdmaCall.State.DIALING);
}
}
}
fetchDtmfToneDelay(phone);
setCallRadioTech(mOwner.getPhone().getCsCallRadioTech());
} |
{@hide}
public class GsmCdmaConnection extends Connection {
private static final String LOG_TAG = "GsmCdmaConnection";
private static final boolean DBG = true;
private static final boolean VDBG = false;
public static final String OTASP_NUMBER = "*22899";
//***** Instance Variables
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
GsmCdmaCallTracker mOwner;
GsmCdmaCall mParent;
boolean mDisconnected;
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
int mIndex; // index in GsmCdmaCallTracker.connections[], -1 if unassigned
// The GsmCdma index is 1 + this
/*
These time/timespan values are based on System.currentTimeMillis(),
i.e., "wall clock" time.
long mDisconnectTime;
UUSInfo mUusInfo;
int mPreciseCause = 0;
String mVendorCause;
Connection mOrigConnection;
Handler mHandler;
private PowerManager.WakeLock mPartialWakeLock;
// The cached delay to be used between DTMF tones fetched from carrier config.
private int mDtmfToneDelay = 0;
private TelephonyMetrics mMetrics = TelephonyMetrics.getInstance();
//***** Event Constants
static final int EVENT_DTMF_DONE = 1;
static final int EVENT_PAUSE_DONE = 2;
static final int EVENT_NEXT_POST_DIAL = 3;
static final int EVENT_WAKE_LOCK_TIMEOUT = 4;
static final int EVENT_DTMF_DELAY_DONE = 5;
//***** Constants
static final int PAUSE_DELAY_MILLIS_GSM = 3 * 1000;
static final int PAUSE_DELAY_MILLIS_CDMA = 2 * 1000;
static final int WAKE_LOCK_TIMEOUT_MILLIS = 60 * 1000;
//***** Inner Classes
class MyHandler extends Handler {
MyHandler(Looper l) {super(l);}
@Override
public void
handleMessage(Message msg) {
switch (msg.what) {
case EVENT_NEXT_POST_DIAL:
case EVENT_DTMF_DELAY_DONE:
case EVENT_PAUSE_DONE:
processNextPostDialChar();
break;
case EVENT_WAKE_LOCK_TIMEOUT:
releaseWakeLock();
break;
case EVENT_DTMF_DONE:
// We may need to add a delay specified by carrier between DTMF tones that are
// sent out.
mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_DTMF_DELAY_DONE),
mDtmfToneDelay);
break;
}
}
}
//***** Constructors
/** This is probably an MT call that we first saw in a CLCC response or a hand over.
public GsmCdmaConnection (GsmCdmaPhone phone, DriverCall dc, GsmCdmaCallTracker ct, int index) {
super(phone.getPhoneType());
createWakeLock(phone.getContext());
acquireWakeLock();
mOwner = ct;
mHandler = new MyHandler(mOwner.getLooper());
mAddress = dc.number;
setEmergencyCallInfo(mOwner);
String forwardedNumber = TextUtils.isEmpty(dc.forwardedNumber) ? null : dc.forwardedNumber;
Rlog.i(LOG_TAG, "create, forwardedNumber=" + Rlog.pii(LOG_TAG, forwardedNumber));
mForwardedNumber = forwardedNumber == null ? null :
new ArrayList<>(Collections.singletonList(dc.forwardedNumber));
mIsIncoming = dc.isMT;
mCreateTime = System.currentTimeMillis();
mCnapName = dc.name;
mCnapNamePresentation = dc.namePresentation;
mNumberPresentation = dc.numberPresentation;
mUusInfo = dc.uusInfo;
mIndex = index;
mParent = parentFromDCState(dc.state);
mParent.attach(this, dc);
fetchDtmfToneDelay(phone);
setAudioQuality(getAudioQualityFromDC(dc.audioQuality));
setCallRadioTech(mOwner.getPhone().getCsCallRadioTech());
}
/** This is an MO call, created when dialing | MyHandler::GsmCdmaConnection | java | Reginer/aosp-android-jar | android-32/src/com/android/internal/telephony/GsmCdmaConnection.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/GsmCdmaConnection.java | MIT |
public GsmCdmaConnection(Context context, CdmaCallWaitingNotification cw, GsmCdmaCallTracker ct,
GsmCdmaCall parent) {
super(parent.getPhone().getPhoneType());
createWakeLock(context);
acquireWakeLock();
mOwner = ct;
mHandler = new MyHandler(mOwner.getLooper());
mAddress = cw.number;
mNumberPresentation = cw.numberPresentation;
mCnapName = cw.name;
mCnapNamePresentation = cw.namePresentation;
mIndex = -1;
mIsIncoming = true;
mCreateTime = System.currentTimeMillis();
mConnectTime = 0;
mParent = parent;
parent.attachFake(this, GsmCdmaCall.State.WAITING);
setCallRadioTech(mOwner.getPhone().getCsCallRadioTech());
} |
{@hide}
public class GsmCdmaConnection extends Connection {
private static final String LOG_TAG = "GsmCdmaConnection";
private static final boolean DBG = true;
private static final boolean VDBG = false;
public static final String OTASP_NUMBER = "*22899";
//***** Instance Variables
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
GsmCdmaCallTracker mOwner;
GsmCdmaCall mParent;
boolean mDisconnected;
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
int mIndex; // index in GsmCdmaCallTracker.connections[], -1 if unassigned
// The GsmCdma index is 1 + this
/*
These time/timespan values are based on System.currentTimeMillis(),
i.e., "wall clock" time.
long mDisconnectTime;
UUSInfo mUusInfo;
int mPreciseCause = 0;
String mVendorCause;
Connection mOrigConnection;
Handler mHandler;
private PowerManager.WakeLock mPartialWakeLock;
// The cached delay to be used between DTMF tones fetched from carrier config.
private int mDtmfToneDelay = 0;
private TelephonyMetrics mMetrics = TelephonyMetrics.getInstance();
//***** Event Constants
static final int EVENT_DTMF_DONE = 1;
static final int EVENT_PAUSE_DONE = 2;
static final int EVENT_NEXT_POST_DIAL = 3;
static final int EVENT_WAKE_LOCK_TIMEOUT = 4;
static final int EVENT_DTMF_DELAY_DONE = 5;
//***** Constants
static final int PAUSE_DELAY_MILLIS_GSM = 3 * 1000;
static final int PAUSE_DELAY_MILLIS_CDMA = 2 * 1000;
static final int WAKE_LOCK_TIMEOUT_MILLIS = 60 * 1000;
//***** Inner Classes
class MyHandler extends Handler {
MyHandler(Looper l) {super(l);}
@Override
public void
handleMessage(Message msg) {
switch (msg.what) {
case EVENT_NEXT_POST_DIAL:
case EVENT_DTMF_DELAY_DONE:
case EVENT_PAUSE_DONE:
processNextPostDialChar();
break;
case EVENT_WAKE_LOCK_TIMEOUT:
releaseWakeLock();
break;
case EVENT_DTMF_DONE:
// We may need to add a delay specified by carrier between DTMF tones that are
// sent out.
mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_DTMF_DELAY_DONE),
mDtmfToneDelay);
break;
}
}
}
//***** Constructors
/** This is probably an MT call that we first saw in a CLCC response or a hand over.
public GsmCdmaConnection (GsmCdmaPhone phone, DriverCall dc, GsmCdmaCallTracker ct, int index) {
super(phone.getPhoneType());
createWakeLock(phone.getContext());
acquireWakeLock();
mOwner = ct;
mHandler = new MyHandler(mOwner.getLooper());
mAddress = dc.number;
setEmergencyCallInfo(mOwner);
String forwardedNumber = TextUtils.isEmpty(dc.forwardedNumber) ? null : dc.forwardedNumber;
Rlog.i(LOG_TAG, "create, forwardedNumber=" + Rlog.pii(LOG_TAG, forwardedNumber));
mForwardedNumber = forwardedNumber == null ? null :
new ArrayList<>(Collections.singletonList(dc.forwardedNumber));
mIsIncoming = dc.isMT;
mCreateTime = System.currentTimeMillis();
mCnapName = dc.name;
mCnapNamePresentation = dc.namePresentation;
mNumberPresentation = dc.numberPresentation;
mUusInfo = dc.uusInfo;
mIndex = index;
mParent = parentFromDCState(dc.state);
mParent.attach(this, dc);
fetchDtmfToneDelay(phone);
setAudioQuality(getAudioQualityFromDC(dc.audioQuality));
setCallRadioTech(mOwner.getPhone().getCsCallRadioTech());
}
/** This is an MO call, created when dialing
public GsmCdmaConnection (GsmCdmaPhone phone, String dialString, GsmCdmaCallTracker ct,
GsmCdmaCall parent, DialArgs dialArgs) {
super(phone.getPhoneType());
createWakeLock(phone.getContext());
acquireWakeLock();
mOwner = ct;
mHandler = new MyHandler(mOwner.getLooper());
mDialString = dialString;
if (!isPhoneTypeGsm()) {
Rlog.d(LOG_TAG, "[GsmCdmaConn] GsmCdmaConnection: dialString=" +
maskDialString(dialString));
dialString = formatDialString(dialString);
Rlog.d(LOG_TAG,
"[GsmCdmaConn] GsmCdmaConnection:formated dialString=" +
maskDialString(dialString));
}
mAddress = PhoneNumberUtils.extractNetworkPortionAlt(dialString);
if (dialArgs.isEmergency) {
setEmergencyCallInfo(mOwner);
// There was no emergency number info found for this call, however it is
// still marked as an emergency number. This may happen if it was a redialed
// non-detectable emergency call from IMS.
if (getEmergencyNumberInfo() == null) {
setNonDetectableEmergencyCallInfo(dialArgs.eccCategory);
}
}
mPostDialString = PhoneNumberUtils.extractPostDialPortion(dialString);
mIndex = -1;
mIsIncoming = false;
mCnapName = null;
mCnapNamePresentation = PhoneConstants.PRESENTATION_ALLOWED;
mNumberPresentation = PhoneConstants.PRESENTATION_ALLOWED;
mCreateTime = System.currentTimeMillis();
if (parent != null) {
mParent = parent;
if (isPhoneTypeGsm()) {
parent.attachFake(this, GsmCdmaCall.State.DIALING);
} else {
//for the three way call case, not change parent state
if (parent.mState == GsmCdmaCall.State.ACTIVE) {
parent.attachFake(this, GsmCdmaCall.State.ACTIVE);
} else {
parent.attachFake(this, GsmCdmaCall.State.DIALING);
}
}
}
fetchDtmfToneDelay(phone);
setCallRadioTech(mOwner.getPhone().getCsCallRadioTech());
}
//CDMA
/** This is a Call waiting call | MyHandler::GsmCdmaConnection | java | Reginer/aosp-android-jar | android-32/src/com/android/internal/telephony/GsmCdmaConnection.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/GsmCdmaConnection.java | MIT |
void onConnectedConnectionMigrated() {
// We can release the wakelock in this case, the migrated call is not still
// DIALING/ALERTING/INCOMING/WAITING.
releaseWakeLock();
} |
We have completed the migration of another connection to this GsmCdmaConnection (for example,
in the case of SRVCC) and not still DIALING/ALERTING/INCOMING/WAITING.
| MyHandler::onConnectedConnectionMigrated | java | Reginer/aosp-android-jar | android-32/src/com/android/internal/telephony/GsmCdmaConnection.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/GsmCdmaConnection.java | MIT |
private void setPostDialState(PostDialState s) {
if (s == PostDialState.STARTED
|| s == PostDialState.PAUSE) {
synchronized (mPartialWakeLock) {
if (mPartialWakeLock.isHeld()) {
mHandler.removeMessages(EVENT_WAKE_LOCK_TIMEOUT);
} else {
acquireWakeLock();
}
Message msg = mHandler.obtainMessage(EVENT_WAKE_LOCK_TIMEOUT);
mHandler.sendMessageDelayed(msg, WAKE_LOCK_TIMEOUT_MILLIS);
}
} else {
mHandler.removeMessages(EVENT_WAKE_LOCK_TIMEOUT);
releaseWakeLock();
}
mPostDialState = s;
notifyPostDialListeners();
} |
Set post dial state and acquire wake lock while switching to "started" or "pause"
state, the wake lock will be released if state switches out of "started" or "pause"
state or after WAKE_LOCK_TIMEOUT_MILLIS.
@param s new PostDialState
| MyHandler::setPostDialState | java | Reginer/aosp-android-jar | android-32/src/com/android/internal/telephony/GsmCdmaConnection.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/GsmCdmaConnection.java | MIT |
public EmergencyNumberTracker getEmergencyNumberTracker() {
if (mOwner != null) {
Phone phone = mOwner.getPhone();
if (phone != null) {
return phone.getEmergencyNumberTracker();
}
}
return null;
} |
Get the corresponding EmergencyNumberTracker associated with the connection.
@return the EmergencyNumberTracker
| MyHandler::getEmergencyNumberTracker | java | Reginer/aosp-android-jar | android-32/src/com/android/internal/telephony/GsmCdmaConnection.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/GsmCdmaConnection.java | MIT |
public boolean isOtaspCall() {
return mAddress != null && OTASP_NUMBER.equals(mAddress);
} |
@return {@code true} if this call is an OTASP activation call, {@code false} otherwise.
| MyHandler::isOtaspCall | java | Reginer/aosp-android-jar | android-32/src/com/android/internal/telephony/GsmCdmaConnection.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/GsmCdmaConnection.java | MIT |
public int getTag() {
return mTag;
} |
Exception for invalid ASN.1 data in DER encoding which cannot be parsed as a node or a specific
data type.
public class InvalidAsn1DataException extends Exception {
private final int mTag;
public InvalidAsn1DataException(int tag, String message) {
super(message);
mTag = tag;
}
public InvalidAsn1DataException(int tag, String message, Throwable throwable) {
super(message, throwable);
mTag = tag;
}
/** @return The tag which has the invalid data. | InvalidAsn1DataException::getTag | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/uicc/asn1/InvalidAsn1DataException.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/uicc/asn1/InvalidAsn1DataException.java | MIT |
public VCardBuilder(final int vcardType, String charset) {
mVCardType = vcardType;
if (VCardConfig.isVersion40(vcardType)) {
Log.w(LOG_TAG, "Should not use vCard 4.0 when building vCard. " +
"It is not officially published yet.");
}
mIsV30OrV40 = VCardConfig.isVersion30(vcardType) || VCardConfig.isVersion40(vcardType);
mShouldUseQuotedPrintable = VCardConfig.shouldUseQuotedPrintable(vcardType);
mIsDoCoMo = VCardConfig.isDoCoMo(vcardType);
mIsJapaneseMobilePhone = VCardConfig.needsToConvertPhoneticString(vcardType);
mOnlyOneNoteFieldIsAvailable = VCardConfig.onlyOneNoteFieldIsAvailable(vcardType);
mUsesAndroidProperty = VCardConfig.usesAndroidSpecificProperty(vcardType);
mUsesDefactProperty = VCardConfig.usesDefactProperty(vcardType);
mRefrainsQPToNameProperties = VCardConfig.shouldRefrainQPToNameProperties(vcardType);
mAppendTypeParamName = VCardConfig.appendTypeParamName(vcardType);
mNeedsToConvertPhoneticString = VCardConfig.needsToConvertPhoneticString(vcardType);
// vCard 2.1 requires charset.
// vCard 3.0 does not allow it but we found some devices use it to determine
// the exact charset.
// We currently append it only when charset other than UTF_8 is used.
mShouldAppendCharsetParam =
!(VCardConfig.isVersion30(vcardType) && "UTF-8".equalsIgnoreCase(charset));
if (VCardConfig.isDoCoMo(vcardType)) {
if (!SHIFT_JIS.equalsIgnoreCase(charset)) {
/* Log.w(LOG_TAG,
"The charset \"" + charset + "\" is used while "
+ SHIFT_JIS + " is needed to be used."); */
if (TextUtils.isEmpty(charset)) {
mCharset = SHIFT_JIS;
} else {
mCharset = charset;
}
} else {
mCharset = charset;
}
mVCardCharsetParameter = "CHARSET=" + SHIFT_JIS;
} else {
if (TextUtils.isEmpty(charset)) {
Log.i(LOG_TAG,
"Use the charset \"" + VCardConfig.DEFAULT_EXPORT_CHARSET
+ "\" for export.");
mCharset = VCardConfig.DEFAULT_EXPORT_CHARSET;
mVCardCharsetParameter = "CHARSET=" + VCardConfig.DEFAULT_EXPORT_CHARSET;
} else {
mCharset = charset;
mVCardCharsetParameter = "CHARSET=" + charset;
}
}
clear();
} |
@param vcardType
@param charset If null, we use default charset for export.
@hide
| VCardBuilder::VCardBuilder | java | Reginer/aosp-android-jar | android-31/src/com/android/vcard/VCardBuilder.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java | MIT |
private VCardBuilder appendNamePropertiesV40(final List<ContentValues> contentValuesList) {
if (mIsDoCoMo || mNeedsToConvertPhoneticString) {
// Ignore all flags that look stale from the view of vCard 4.0 to
// simplify construction algorithm. Actually we don't have any vCard file
// available from real world yet, so we may need to re-enable some of these
// in the future.
Log.w(LOG_TAG, "Invalid flag is used in vCard 4.0 construction. Ignored.");
}
if (contentValuesList == null || contentValuesList.isEmpty()) {
appendLine(VCardConstants.PROPERTY_FN, "");
return this;
}
// We have difficulty here. How can we appropriately handle StructuredName with
// missing parts necessary for displaying while it has suppremental information.
//
// e.g. How to handle non-empty phonetic names with empty structured names?
final ContentValues contentValues =
getPrimaryContentValueWithStructuredName(contentValuesList);
String familyName = contentValues.getAsString(StructuredName.FAMILY_NAME);
final String middleName = contentValues.getAsString(StructuredName.MIDDLE_NAME);
final String givenName = contentValues.getAsString(StructuredName.GIVEN_NAME);
final String prefix = contentValues.getAsString(StructuredName.PREFIX);
final String suffix = contentValues.getAsString(StructuredName.SUFFIX);
final String formattedName = contentValues.getAsString(StructuredName.DISPLAY_NAME);
if (TextUtils.isEmpty(familyName)
&& TextUtils.isEmpty(givenName)
&& TextUtils.isEmpty(middleName)
&& TextUtils.isEmpty(prefix)
&& TextUtils.isEmpty(suffix)) {
if (TextUtils.isEmpty(formattedName)) {
appendLine(VCardConstants.PROPERTY_FN, "");
return this;
}
familyName = formattedName;
}
final String phoneticFamilyName =
contentValues.getAsString(StructuredName.PHONETIC_FAMILY_NAME);
final String phoneticMiddleName =
contentValues.getAsString(StructuredName.PHONETIC_MIDDLE_NAME);
final String phoneticGivenName =
contentValues.getAsString(StructuredName.PHONETIC_GIVEN_NAME);
final String escapedFamily = escapeCharacters(familyName);
final String escapedGiven = escapeCharacters(givenName);
final String escapedMiddle = escapeCharacters(middleName);
final String escapedPrefix = escapeCharacters(prefix);
final String escapedSuffix = escapeCharacters(suffix);
mBuilder.append(VCardConstants.PROPERTY_N);
if (!(TextUtils.isEmpty(phoneticFamilyName) &&
TextUtils.isEmpty(phoneticMiddleName) &&
TextUtils.isEmpty(phoneticGivenName))) {
mBuilder.append(VCARD_PARAM_SEPARATOR);
final String sortAs = escapeCharacters(phoneticFamilyName)
+ ';' + escapeCharacters(phoneticGivenName)
+ ';' + escapeCharacters(phoneticMiddleName);
mBuilder.append("SORT-AS=").append(
VCardUtils.toStringAsV40ParamValue(sortAs));
}
mBuilder.append(VCARD_DATA_SEPARATOR);
mBuilder.append(escapedFamily);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(escapedGiven);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(escapedMiddle);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(escapedPrefix);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(escapedSuffix);
mBuilder.append(VCARD_END_OF_LINE);
if (TextUtils.isEmpty(formattedName)) {
// Note:
// DISPLAY_NAME doesn't exist while some other elements do, which is usually
// weird in Android, as DISPLAY_NAME should (usually) be constructed
// from the others using locale information and its code points.
Log.w(LOG_TAG, "DISPLAY_NAME is empty.");
final String escaped = escapeCharacters(VCardUtils.constructNameFromElements(
VCardConfig.getNameOrderType(mVCardType),
familyName, middleName, givenName, prefix, suffix));
appendLine(VCardConstants.PROPERTY_FN, escaped);
} else {
final String escapedFormatted = escapeCharacters(formattedName);
mBuilder.append(VCardConstants.PROPERTY_FN);
mBuilder.append(VCARD_DATA_SEPARATOR);
mBuilder.append(escapedFormatted);
mBuilder.append(VCARD_END_OF_LINE);
}
// We may need X- properties for phonetic names.
appendPhoneticNameFields(contentValues);
return this;
} |
To avoid unnecessary complication in logic, we use this method to construct N, FN
properties for vCard 4.0.
| VCardBuilder::appendNamePropertiesV40 | java | Reginer/aosp-android-jar | android-31/src/com/android/vcard/VCardBuilder.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java | MIT |
public VCardBuilder appendNameProperties(final List<ContentValues> contentValuesList) {
if (VCardConfig.isVersion40(mVCardType)) {
return appendNamePropertiesV40(contentValuesList);
}
if (contentValuesList == null || contentValuesList.isEmpty()) {
if (VCardConfig.isVersion30(mVCardType)) {
// vCard 3.0 requires "N" and "FN" properties.
// vCard 4.0 does NOT require N, but we take care of possible backward
// compatibility issues.
appendLine(VCardConstants.PROPERTY_N, "");
appendLine(VCardConstants.PROPERTY_FN, "");
} else if (mIsDoCoMo) {
appendLine(VCardConstants.PROPERTY_N, "");
}
return this;
}
final ContentValues contentValues =
getPrimaryContentValueWithStructuredName(contentValuesList);
final String familyName = contentValues.getAsString(StructuredName.FAMILY_NAME);
final String middleName = contentValues.getAsString(StructuredName.MIDDLE_NAME);
final String givenName = contentValues.getAsString(StructuredName.GIVEN_NAME);
final String prefix = contentValues.getAsString(StructuredName.PREFIX);
final String suffix = contentValues.getAsString(StructuredName.SUFFIX);
final String displayName = contentValues.getAsString(StructuredName.DISPLAY_NAME);
if (!TextUtils.isEmpty(familyName) || !TextUtils.isEmpty(givenName)) {
final boolean reallyAppendCharsetParameterToName =
shouldAppendCharsetParam(familyName, givenName, middleName, prefix, suffix);
final boolean reallyUseQuotedPrintableToName =
(!mRefrainsQPToNameProperties &&
!(VCardUtils.containsOnlyNonCrLfPrintableAscii(familyName) &&
VCardUtils.containsOnlyNonCrLfPrintableAscii(givenName) &&
VCardUtils.containsOnlyNonCrLfPrintableAscii(middleName) &&
VCardUtils.containsOnlyNonCrLfPrintableAscii(prefix) &&
VCardUtils.containsOnlyNonCrLfPrintableAscii(suffix)));
final String formattedName;
if (!TextUtils.isEmpty(displayName)) {
formattedName = displayName;
} else {
formattedName = VCardUtils.constructNameFromElements(
VCardConfig.getNameOrderType(mVCardType),
familyName, middleName, givenName, prefix, suffix);
}
final boolean reallyAppendCharsetParameterToFN =
shouldAppendCharsetParam(formattedName);
final boolean reallyUseQuotedPrintableToFN =
!mRefrainsQPToNameProperties &&
!VCardUtils.containsOnlyNonCrLfPrintableAscii(formattedName);
final String encodedFamily;
final String encodedGiven;
final String encodedMiddle;
final String encodedPrefix;
final String encodedSuffix;
if (reallyUseQuotedPrintableToName) {
encodedFamily = encodeQuotedPrintable(familyName);
encodedGiven = encodeQuotedPrintable(givenName);
encodedMiddle = encodeQuotedPrintable(middleName);
encodedPrefix = encodeQuotedPrintable(prefix);
encodedSuffix = encodeQuotedPrintable(suffix);
} else {
encodedFamily = escapeCharacters(familyName);
encodedGiven = escapeCharacters(givenName);
encodedMiddle = escapeCharacters(middleName);
encodedPrefix = escapeCharacters(prefix);
encodedSuffix = escapeCharacters(suffix);
}
final String encodedFormattedname =
(reallyUseQuotedPrintableToFN ?
encodeQuotedPrintable(formattedName) : escapeCharacters(formattedName));
mBuilder.append(VCardConstants.PROPERTY_N);
if (mIsDoCoMo) {
if (reallyAppendCharsetParameterToName) {
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(mVCardCharsetParameter);
}
if (reallyUseQuotedPrintableToName) {
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(VCARD_PARAM_ENCODING_QP);
}
mBuilder.append(VCARD_DATA_SEPARATOR);
// DoCoMo phones require that all the elements in the "family name" field.
mBuilder.append(formattedName);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(VCARD_ITEM_SEPARATOR);
} else {
if (reallyAppendCharsetParameterToName) {
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(mVCardCharsetParameter);
}
if (reallyUseQuotedPrintableToName) {
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(VCARD_PARAM_ENCODING_QP);
}
mBuilder.append(VCARD_DATA_SEPARATOR);
mBuilder.append(encodedFamily);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(encodedGiven);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(encodedMiddle);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(encodedPrefix);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(encodedSuffix);
}
mBuilder.append(VCARD_END_OF_LINE);
// FN property
mBuilder.append(VCardConstants.PROPERTY_FN);
if (reallyAppendCharsetParameterToFN) {
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(mVCardCharsetParameter);
}
if (reallyUseQuotedPrintableToFN) {
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(VCARD_PARAM_ENCODING_QP);
}
mBuilder.append(VCARD_DATA_SEPARATOR);
mBuilder.append(encodedFormattedname);
mBuilder.append(VCARD_END_OF_LINE);
} else if (!TextUtils.isEmpty(displayName)) {
// N
buildSinglePartNameField(VCardConstants.PROPERTY_N, displayName);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(VCARD_END_OF_LINE);
// FN
buildSinglePartNameField(VCardConstants.PROPERTY_FN, displayName);
mBuilder.append(VCARD_END_OF_LINE);
} else if (VCardConfig.isVersion30(mVCardType)) {
appendLine(VCardConstants.PROPERTY_N, "");
appendLine(VCardConstants.PROPERTY_FN, "");
} else if (mIsDoCoMo) {
appendLine(VCardConstants.PROPERTY_N, "");
}
appendPhoneticNameFields(contentValues);
return this;
} |
For safety, we'll emit just one value around StructuredName, as external importers
may get confused with multiple "N", "FN", etc. properties, though it is valid in
vCard spec.
| VCardBuilder::appendNameProperties | java | Reginer/aosp-android-jar | android-31/src/com/android/vcard/VCardBuilder.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java | MIT |
private void appendPhoneticNameFields(final ContentValues contentValues) {
final String phoneticFamilyName;
final String phoneticMiddleName;
final String phoneticGivenName;
{
final String tmpPhoneticFamilyName =
contentValues.getAsString(StructuredName.PHONETIC_FAMILY_NAME);
final String tmpPhoneticMiddleName =
contentValues.getAsString(StructuredName.PHONETIC_MIDDLE_NAME);
final String tmpPhoneticGivenName =
contentValues.getAsString(StructuredName.PHONETIC_GIVEN_NAME);
if (mNeedsToConvertPhoneticString) {
phoneticFamilyName = VCardUtils.toHalfWidthString(tmpPhoneticFamilyName);
phoneticMiddleName = VCardUtils.toHalfWidthString(tmpPhoneticMiddleName);
phoneticGivenName = VCardUtils.toHalfWidthString(tmpPhoneticGivenName);
} else {
phoneticFamilyName = tmpPhoneticFamilyName;
phoneticMiddleName = tmpPhoneticMiddleName;
phoneticGivenName = tmpPhoneticGivenName;
}
}
if (TextUtils.isEmpty(phoneticFamilyName)
&& TextUtils.isEmpty(phoneticMiddleName)
&& TextUtils.isEmpty(phoneticGivenName)) {
if (mIsDoCoMo) {
mBuilder.append(VCardConstants.PROPERTY_SOUND);
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(VCardConstants.PARAM_TYPE_X_IRMC_N);
mBuilder.append(VCARD_DATA_SEPARATOR);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(VCARD_ITEM_SEPARATOR);
mBuilder.append(VCARD_END_OF_LINE);
}
return;
}
if (VCardConfig.isVersion40(mVCardType)) {
// We don't want SORT-STRING anyway.
} else if (VCardConfig.isVersion30(mVCardType)) {
final String sortString =
VCardUtils.constructNameFromElements(mVCardType,
phoneticFamilyName, phoneticMiddleName, phoneticGivenName);
mBuilder.append(VCardConstants.PROPERTY_SORT_STRING);
if (VCardConfig.isVersion30(mVCardType) && shouldAppendCharsetParam(sortString)) {
// vCard 3.0 does not force us to use UTF-8 and actually we see some
// programs which emit this value. It is incorrect from the view of
// specification, but actually necessary for parsing vCard with non-UTF-8
// charsets, expecting other parsers not get confused with this value.
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(mVCardCharsetParameter);
}
mBuilder.append(VCARD_DATA_SEPARATOR);
mBuilder.append(escapeCharacters(sortString));
mBuilder.append(VCARD_END_OF_LINE);
} else if (mIsJapaneseMobilePhone) {
// Note: There is no appropriate property for expressing
// phonetic name (Yomigana in Japanese) in vCard 2.1, while there is in
// vCard 3.0 (SORT-STRING).
// We use DoCoMo's way when the device is Japanese one since it is already
// supported by a lot of Japanese mobile phones.
// This is "X-" property, so any parser hopefully would not get
// confused with this.
//
// Also, DoCoMo's specification requires vCard composer to use just the first
// column.
// i.e.
// good: SOUND;X-IRMC-N:Miyakawa Daisuke;;;;
// bad : SOUND;X-IRMC-N:Miyakawa;Daisuke;;;
mBuilder.append(VCardConstants.PROPERTY_SOUND);
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(VCardConstants.PARAM_TYPE_X_IRMC_N);
boolean reallyUseQuotedPrintable =
(!mRefrainsQPToNameProperties
&& !(VCardUtils.containsOnlyNonCrLfPrintableAscii(
phoneticFamilyName)
&& VCardUtils.containsOnlyNonCrLfPrintableAscii(
phoneticMiddleName)
&& VCardUtils.containsOnlyNonCrLfPrintableAscii(
phoneticGivenName)));
final String encodedPhoneticFamilyName;
final String encodedPhoneticMiddleName;
final String encodedPhoneticGivenName;
if (reallyUseQuotedPrintable) {
encodedPhoneticFamilyName = encodeQuotedPrintable(phoneticFamilyName);
encodedPhoneticMiddleName = encodeQuotedPrintable(phoneticMiddleName);
encodedPhoneticGivenName = encodeQuotedPrintable(phoneticGivenName);
} else {
encodedPhoneticFamilyName = escapeCharacters(phoneticFamilyName);
encodedPhoneticMiddleName = escapeCharacters(phoneticMiddleName);
encodedPhoneticGivenName = escapeCharacters(phoneticGivenName);
}
if (shouldAppendCharsetParam(encodedPhoneticFamilyName,
encodedPhoneticMiddleName, encodedPhoneticGivenName)) {
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(mVCardCharsetParameter);
}
mBuilder.append(VCARD_DATA_SEPARATOR);
{
boolean first = true;
if (!TextUtils.isEmpty(encodedPhoneticFamilyName)) {
mBuilder.append(encodedPhoneticFamilyName);
first = false;
}
if (!TextUtils.isEmpty(encodedPhoneticMiddleName)) {
if (first) {
first = false;
} else {
mBuilder.append(' ');
}
mBuilder.append(encodedPhoneticMiddleName);
}
if (!TextUtils.isEmpty(encodedPhoneticGivenName)) {
if (!first) {
mBuilder.append(' ');
}
mBuilder.append(encodedPhoneticGivenName);
}
}
mBuilder.append(VCARD_ITEM_SEPARATOR); // family;given
mBuilder.append(VCARD_ITEM_SEPARATOR); // given;middle
mBuilder.append(VCARD_ITEM_SEPARATOR); // middle;prefix
mBuilder.append(VCARD_ITEM_SEPARATOR); // prefix;suffix
mBuilder.append(VCARD_END_OF_LINE);
}
if (mUsesDefactProperty) {
if (!TextUtils.isEmpty(phoneticGivenName)) {
final boolean reallyUseQuotedPrintable =
(mShouldUseQuotedPrintable &&
!VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticGivenName));
final String encodedPhoneticGivenName;
if (reallyUseQuotedPrintable) {
encodedPhoneticGivenName = encodeQuotedPrintable(phoneticGivenName);
} else {
encodedPhoneticGivenName = escapeCharacters(phoneticGivenName);
}
mBuilder.append(VCardConstants.PROPERTY_X_PHONETIC_FIRST_NAME);
if (shouldAppendCharsetParam(phoneticGivenName)) {
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(mVCardCharsetParameter);
}
if (reallyUseQuotedPrintable) {
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(VCARD_PARAM_ENCODING_QP);
}
mBuilder.append(VCARD_DATA_SEPARATOR);
mBuilder.append(encodedPhoneticGivenName);
mBuilder.append(VCARD_END_OF_LINE);
} // if (!TextUtils.isEmpty(phoneticGivenName))
if (!TextUtils.isEmpty(phoneticMiddleName)) {
final boolean reallyUseQuotedPrintable =
(mShouldUseQuotedPrintable &&
!VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticMiddleName));
final String encodedPhoneticMiddleName;
if (reallyUseQuotedPrintable) {
encodedPhoneticMiddleName = encodeQuotedPrintable(phoneticMiddleName);
} else {
encodedPhoneticMiddleName = escapeCharacters(phoneticMiddleName);
}
mBuilder.append(VCardConstants.PROPERTY_X_PHONETIC_MIDDLE_NAME);
if (shouldAppendCharsetParam(phoneticMiddleName)) {
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(mVCardCharsetParameter);
}
if (reallyUseQuotedPrintable) {
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(VCARD_PARAM_ENCODING_QP);
}
mBuilder.append(VCARD_DATA_SEPARATOR);
mBuilder.append(encodedPhoneticMiddleName);
mBuilder.append(VCARD_END_OF_LINE);
} // if (!TextUtils.isEmpty(phoneticGivenName))
if (!TextUtils.isEmpty(phoneticFamilyName)) {
final boolean reallyUseQuotedPrintable =
(mShouldUseQuotedPrintable &&
!VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticFamilyName));
final String encodedPhoneticFamilyName;
if (reallyUseQuotedPrintable) {
encodedPhoneticFamilyName = encodeQuotedPrintable(phoneticFamilyName);
} else {
encodedPhoneticFamilyName = escapeCharacters(phoneticFamilyName);
}
mBuilder.append(VCardConstants.PROPERTY_X_PHONETIC_LAST_NAME);
if (shouldAppendCharsetParam(phoneticFamilyName)) {
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(mVCardCharsetParameter);
}
if (reallyUseQuotedPrintable) {
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(VCARD_PARAM_ENCODING_QP);
}
mBuilder.append(VCARD_DATA_SEPARATOR);
mBuilder.append(encodedPhoneticFamilyName);
mBuilder.append(VCARD_END_OF_LINE);
} // if (!TextUtils.isEmpty(phoneticFamilyName))
}
} |
Emits SOUND;IRMC, SORT-STRING, and de-fact values for phonetic names like X-PHONETIC-FAMILY.
| VCardBuilder::appendPhoneticNameFields | java | Reginer/aosp-android-jar | android-31/src/com/android/vcard/VCardBuilder.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java | MIT |
private List<String> splitPhoneNumbers(final String phoneNumber) {
final List<String> phoneList = new ArrayList<String>();
StringBuilder builder = new StringBuilder();
final int length = phoneNumber.length();
for (int i = 0; i < length; i++) {
final char ch = phoneNumber.charAt(i);
if (ch == '\n' && builder.length() > 0) {
phoneList.add(builder.toString());
builder = new StringBuilder();
} else {
builder.append(ch);
}
}
if (builder.length() > 0) {
phoneList.add(builder.toString());
}
return phoneList;
} |
<p>
Splits a given string expressing phone numbers into several strings, and remove
unnecessary characters inside them. The size of a returned list becomes 1 when
no split is needed.
</p>
<p>
The given number "may" have several phone numbers when the contact entry is corrupted
because of its original source.
e.g. "111-222-3333 (Miami)\n444-555-6666 (Broward; 305-653-6796 (Miami)"
</p>
<p>
This kind of "phone numbers" will not be created with Android vCard implementation,
but we may encounter them if the source of the input data has already corrupted
implementation.
</p>
<p>
To handle this case, this method first splits its input into multiple parts
(e.g. "111-222-3333 (Miami)", "444-555-6666 (Broward", and 305653-6796 (Miami)") and
removes unnecessary strings like "(Miami)".
</p>
<p>
Do not call this method when trimming is inappropriate for its receivers.
</p>
| VCardBuilder::splitPhoneNumbers | java | Reginer/aosp-android-jar | android-31/src/com/android/vcard/VCardBuilder.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java | MIT |
private void appendPostalsForDoCoMo(final List<ContentValues> contentValuesList) {
int currentPriority = Integer.MAX_VALUE;
int currentType = Integer.MAX_VALUE;
ContentValues currentContentValues = null;
for (final ContentValues contentValues : contentValuesList) {
if (contentValues == null) {
continue;
}
final Integer typeAsInteger = contentValues.getAsInteger(StructuredPostal.TYPE);
final Integer priorityAsInteger = sPostalTypePriorityMap.get(typeAsInteger);
final int priority =
(priorityAsInteger != null ? priorityAsInteger : Integer.MAX_VALUE);
if (priority < currentPriority) {
currentPriority = priority;
currentType = typeAsInteger;
currentContentValues = contentValues;
if (priority == 0) {
break;
}
}
}
if (currentContentValues == null) {
Log.w(LOG_TAG, "Should not come here. Must have at least one postal data.");
return;
}
final String label = currentContentValues.getAsString(StructuredPostal.LABEL);
appendPostalLine(currentType, label, currentContentValues, false, true);
} |
Tries to append just one line. If there's no appropriate address
information, append an empty line.
| VCardBuilder::appendPostalsForDoCoMo | java | Reginer/aosp-android-jar | android-31/src/com/android/vcard/VCardBuilder.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java | MIT |
private PostalStruct tryConstructPostalStruct(ContentValues contentValues) {
// adr-value = 0*6(text-value ";") text-value
// ; PO Box, Extended Address, Street, Locality, Region, Postal
// ; Code, Country Name
final String rawPoBox = contentValues.getAsString(StructuredPostal.POBOX);
final String rawNeighborhood = contentValues.getAsString(StructuredPostal.NEIGHBORHOOD);
final String rawStreet = contentValues.getAsString(StructuredPostal.STREET);
final String rawLocality = contentValues.getAsString(StructuredPostal.CITY);
final String rawRegion = contentValues.getAsString(StructuredPostal.REGION);
final String rawPostalCode = contentValues.getAsString(StructuredPostal.POSTCODE);
final String rawCountry = contentValues.getAsString(StructuredPostal.COUNTRY);
final String[] rawAddressArray = new String[]{
rawPoBox, rawNeighborhood, rawStreet, rawLocality,
rawRegion, rawPostalCode, rawCountry};
if (!VCardUtils.areAllEmpty(rawAddressArray)) {
final boolean reallyUseQuotedPrintable =
(mShouldUseQuotedPrintable &&
!VCardUtils.containsOnlyNonCrLfPrintableAscii(rawAddressArray));
final boolean appendCharset =
!VCardUtils.containsOnlyPrintableAscii(rawAddressArray);
final String encodedPoBox;
final String encodedStreet;
final String encodedLocality;
final String encodedRegion;
final String encodedPostalCode;
final String encodedCountry;
final String encodedNeighborhood;
final String rawLocality2;
// This looks inefficient since we encode rawLocality and rawNeighborhood twice,
// but this is intentional.
//
// QP encoding may add line feeds when needed and the result of
// - encodeQuotedPrintable(rawLocality + " " + rawNeighborhood)
// may be different from
// - encodedLocality + " " + encodedNeighborhood.
//
// We use safer way.
if (TextUtils.isEmpty(rawLocality)) {
if (TextUtils.isEmpty(rawNeighborhood)) {
rawLocality2 = "";
} else {
rawLocality2 = rawNeighborhood;
}
} else {
if (TextUtils.isEmpty(rawNeighborhood)) {
rawLocality2 = rawLocality;
} else {
rawLocality2 = rawLocality + " " + rawNeighborhood;
}
}
if (reallyUseQuotedPrintable) {
encodedPoBox = encodeQuotedPrintable(rawPoBox);
encodedStreet = encodeQuotedPrintable(rawStreet);
encodedLocality = encodeQuotedPrintable(rawLocality2);
encodedRegion = encodeQuotedPrintable(rawRegion);
encodedPostalCode = encodeQuotedPrintable(rawPostalCode);
encodedCountry = encodeQuotedPrintable(rawCountry);
} else {
encodedPoBox = escapeCharacters(rawPoBox);
encodedStreet = escapeCharacters(rawStreet);
encodedLocality = escapeCharacters(rawLocality2);
encodedRegion = escapeCharacters(rawRegion);
encodedPostalCode = escapeCharacters(rawPostalCode);
encodedCountry = escapeCharacters(rawCountry);
encodedNeighborhood = escapeCharacters(rawNeighborhood);
}
final StringBuilder addressBuilder = new StringBuilder();
addressBuilder.append(encodedPoBox);
addressBuilder.append(VCARD_ITEM_SEPARATOR); // PO BOX ; Extended Address
addressBuilder.append(VCARD_ITEM_SEPARATOR); // Extended Address : Street
addressBuilder.append(encodedStreet);
addressBuilder.append(VCARD_ITEM_SEPARATOR); // Street : Locality
addressBuilder.append(encodedLocality);
addressBuilder.append(VCARD_ITEM_SEPARATOR); // Locality : Region
addressBuilder.append(encodedRegion);
addressBuilder.append(VCARD_ITEM_SEPARATOR); // Region : Postal Code
addressBuilder.append(encodedPostalCode);
addressBuilder.append(VCARD_ITEM_SEPARATOR); // Postal Code : Country
addressBuilder.append(encodedCountry);
return new PostalStruct(
reallyUseQuotedPrintable, appendCharset, addressBuilder.toString());
} else { // VCardUtils.areAllEmpty(rawAddressArray) == true
// Try to use FORMATTED_ADDRESS instead.
final String rawFormattedAddress =
contentValues.getAsString(StructuredPostal.FORMATTED_ADDRESS);
if (TextUtils.isEmpty(rawFormattedAddress)) {
return null;
}
final boolean reallyUseQuotedPrintable =
(mShouldUseQuotedPrintable &&
!VCardUtils.containsOnlyNonCrLfPrintableAscii(rawFormattedAddress));
final boolean appendCharset =
!VCardUtils.containsOnlyPrintableAscii(rawFormattedAddress);
final String encodedFormattedAddress;
if (reallyUseQuotedPrintable) {
encodedFormattedAddress = encodeQuotedPrintable(rawFormattedAddress);
} else {
encodedFormattedAddress = escapeCharacters(rawFormattedAddress);
}
// We use the second value ("Extended Address") just because Japanese mobile phones
// do so. If the other importer expects the value be in the other field, some flag may
// be needed.
final StringBuilder addressBuilder = new StringBuilder();
addressBuilder.append(VCARD_ITEM_SEPARATOR); // PO BOX ; Extended Address
addressBuilder.append(encodedFormattedAddress);
addressBuilder.append(VCARD_ITEM_SEPARATOR); // Extended Address : Street
addressBuilder.append(VCARD_ITEM_SEPARATOR); // Street : Locality
addressBuilder.append(VCARD_ITEM_SEPARATOR); // Locality : Region
addressBuilder.append(VCARD_ITEM_SEPARATOR); // Region : Postal Code
addressBuilder.append(VCARD_ITEM_SEPARATOR); // Postal Code : Country
return new PostalStruct(
reallyUseQuotedPrintable, appendCharset, addressBuilder.toString());
}
} |
@return null when there's no information available to construct the data.
| PostalStruct::tryConstructPostalStruct | java | Reginer/aosp-android-jar | android-31/src/com/android/vcard/VCardBuilder.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java | MIT |
public void appendPostalLine(final int type, final String label,
final ContentValues contentValues,
final boolean isPrimary, final boolean emitEveryTime) {
final boolean reallyUseQuotedPrintable;
final boolean appendCharset;
final String addressValue;
{
PostalStruct postalStruct = tryConstructPostalStruct(contentValues);
if (postalStruct == null) {
if (emitEveryTime) {
reallyUseQuotedPrintable = false;
appendCharset = false;
addressValue = "";
} else {
return;
}
} else {
reallyUseQuotedPrintable = postalStruct.reallyUseQuotedPrintable;
appendCharset = postalStruct.appendCharset;
addressValue = postalStruct.addressData;
}
}
List<String> parameterList = new ArrayList<String>();
if (isPrimary) {
parameterList.add(VCardConstants.PARAM_TYPE_PREF);
}
switch (type) {
case StructuredPostal.TYPE_HOME: {
parameterList.add(VCardConstants.PARAM_TYPE_HOME);
break;
}
case StructuredPostal.TYPE_WORK: {
parameterList.add(VCardConstants.PARAM_TYPE_WORK);
break;
}
case StructuredPostal.TYPE_CUSTOM: {
if (!TextUtils.isEmpty(label)
&& VCardUtils.containsOnlyAlphaDigitHyphen(label)) {
// We're not sure whether the label is valid in the spec
// ("IANA-token" in the vCard 3.0 is unclear...)
// Just for safety, we add "X-" at the beggining of each label.
// Also checks the label obeys with vCard 3.0 spec.
parameterList.add("X-" + label);
}
break;
}
case StructuredPostal.TYPE_OTHER: {
break;
}
default: {
Log.e(LOG_TAG, "Unknown StructuredPostal type: " + type);
break;
}
}
mBuilder.append(VCardConstants.PROPERTY_ADR);
if (!parameterList.isEmpty()) {
mBuilder.append(VCARD_PARAM_SEPARATOR);
appendTypeParameters(parameterList);
}
if (appendCharset) {
// Strictly, vCard 3.0 does not allow exporters to emit charset information,
// but we will add it since the information should be useful for importers,
//
// Assume no parser does not emit error with this parameter in vCard 3.0.
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(mVCardCharsetParameter);
}
if (reallyUseQuotedPrintable) {
mBuilder.append(VCARD_PARAM_SEPARATOR);
mBuilder.append(VCARD_PARAM_ENCODING_QP);
}
mBuilder.append(VCARD_DATA_SEPARATOR);
mBuilder.append(addressValue);
mBuilder.append(VCARD_END_OF_LINE);
} |
@param emitEveryTime If true, builder builds the line even when there's no entry.
| PostalStruct::appendPostalLine | java | Reginer/aosp-android-jar | android-31/src/com/android/vcard/VCardBuilder.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java | MIT |
private void appendUncommonPhoneType(final StringBuilder builder, final Integer type) {
if (mIsDoCoMo) {
// The previous implementation for DoCoMo had been conservative
// about miscellaneous types.
builder.append(VCardConstants.PARAM_TYPE_VOICE);
} else {
String phoneType = VCardUtils.getPhoneTypeString(type);
if (phoneType != null) {
appendTypeParameter(phoneType);
} else {
Log.e(LOG_TAG, "Unknown or unsupported (by vCard) Phone type: " + type);
}
}
} |
Appends phone type string which may not be available in some devices.
| PostalStruct::appendUncommonPhoneType | java | Reginer/aosp-android-jar | android-31/src/com/android/vcard/VCardBuilder.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java | MIT |
public void appendPhotoLine(final String encodedValue, final String photoType) {
StringBuilder tmpBuilder = new StringBuilder();
tmpBuilder.append(VCardConstants.PROPERTY_PHOTO);
tmpBuilder.append(VCARD_PARAM_SEPARATOR);
if (mIsV30OrV40) {
tmpBuilder.append(VCARD_PARAM_ENCODING_BASE64_AS_B);
} else {
tmpBuilder.append(VCARD_PARAM_ENCODING_BASE64_V21);
}
tmpBuilder.append(VCARD_PARAM_SEPARATOR);
appendTypeParameter(tmpBuilder, photoType);
tmpBuilder.append(VCARD_DATA_SEPARATOR);
tmpBuilder.append(encodedValue);
final String tmpStr = tmpBuilder.toString();
tmpBuilder = new StringBuilder();
int lineCount = 0;
final int length = tmpStr.length();
final int maxNumForFirstLine = VCardConstants.MAX_CHARACTER_NUMS_BASE64_V30
- VCARD_END_OF_LINE.length();
final int maxNumInGeneral = maxNumForFirstLine - VCARD_WS.length();
int maxNum = maxNumForFirstLine;
for (int i = 0; i < length; i++) {
tmpBuilder.append(tmpStr.charAt(i));
lineCount++;
if (lineCount > maxNum) {
tmpBuilder.append(VCARD_END_OF_LINE);
tmpBuilder.append(VCARD_WS);
maxNum = maxNumInGeneral;
lineCount = 0;
}
}
mBuilder.append(tmpBuilder.toString());
mBuilder.append(VCARD_END_OF_LINE);
mBuilder.append(VCARD_END_OF_LINE);
} |
@param encodedValue Must be encoded by BASE64
@param photoType
| PostalStruct::appendPhotoLine | java | Reginer/aosp-android-jar | android-31/src/com/android/vcard/VCardBuilder.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java | MIT |
public VCardBuilder appendSipAddresses(final List<ContentValues> contentValuesList) {
final boolean useXProperty;
if (mIsV30OrV40) {
useXProperty = false;
} else if (mUsesDefactProperty){
useXProperty = true;
} else {
return this;
}
if (contentValuesList != null) {
for (ContentValues contentValues : contentValuesList) {
String sipAddress = contentValues.getAsString(SipAddress.SIP_ADDRESS);
if (TextUtils.isEmpty(sipAddress)) {
continue;
}
if (useXProperty) {
// X-SIP does not contain "sip:" prefix.
if (sipAddress.startsWith("sip:")) {
if (sipAddress.length() == 4) {
continue;
}
sipAddress = sipAddress.substring(4);
}
// No type is available yet.
appendLineWithCharsetAndQPDetection(VCardConstants.PROPERTY_X_SIP, sipAddress);
} else {
if (!sipAddress.startsWith("sip:")) {
sipAddress = "sip:" + sipAddress;
}
final String propertyName;
if (VCardConfig.isVersion40(mVCardType)) {
// We have two ways to emit sip address: TEL and IMPP. Currently (rev.13)
// TEL seems appropriate but may change in the future.
propertyName = VCardConstants.PROPERTY_TEL;
} else {
// RFC 4770 (for vCard 3.0)
propertyName = VCardConstants.PROPERTY_IMPP;
}
appendLineWithCharsetAndQPDetection(propertyName, sipAddress);
}
}
}
return this;
} |
SIP (Session Initiation Protocol) is first supported in RFC 4770 as part of IMPP
support. vCard 2.1 and old vCard 3.0 may not able to parse it, or expect X-SIP
instead of "IMPP;sip:...".
We honor RFC 4770 and don't allow vCard 3.0 to emit X-SIP at all.
| PostalStruct::appendSipAddresses | java | Reginer/aosp-android-jar | android-31/src/com/android/vcard/VCardBuilder.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java | MIT |
public void appendLine(final String propertyName, final String rawValue) {
appendLine(propertyName, rawValue, false, false);
} |
Appends one line with a given property name and value.
| PostalStruct::appendLine | java | Reginer/aosp-android-jar | android-31/src/com/android/vcard/VCardBuilder.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java | MIT |
private void appendTypeParameters(final List<String> types) {
// We may have to make this comma separated form like "TYPE=DOM,WORK" in the future,
// which would be recommended way in vcard 3.0 though not valid in vCard 2.1.
boolean first = true;
for (final String typeValue : types) {
if (VCardConfig.isVersion30(mVCardType) || VCardConfig.isVersion40(mVCardType)) {
final String encoded = (VCardConfig.isVersion40(mVCardType) ?
VCardUtils.toStringAsV40ParamValue(typeValue) :
VCardUtils.toStringAsV30ParamValue(typeValue));
if (TextUtils.isEmpty(encoded)) {
continue;
}
if (first) {
first = false;
} else {
mBuilder.append(VCARD_PARAM_SEPARATOR);
}
appendTypeParameter(encoded);
} else { // vCard 2.1
if (!VCardUtils.isV21Word(typeValue)) {
continue;
}
if (first) {
first = false;
} else {
mBuilder.append(VCARD_PARAM_SEPARATOR);
}
appendTypeParameter(typeValue);
}
}
} |
VCARD_PARAM_SEPARATOR must be appended before this method being called.
| PostalStruct::appendTypeParameters | java | Reginer/aosp-android-jar | android-31/src/com/android/vcard/VCardBuilder.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java | MIT |
private void appendTypeParameter(final String type) {
appendTypeParameter(mBuilder, type);
} |
VCARD_PARAM_SEPARATOR must be appended before this method being called.
| PostalStruct::appendTypeParameter | java | Reginer/aosp-android-jar | android-31/src/com/android/vcard/VCardBuilder.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java | MIT |
private boolean shouldAppendCharsetParam(String...propertyValueList) {
if (!mShouldAppendCharsetParam) {
return false;
}
for (String propertyValue : propertyValueList) {
if (!VCardUtils.containsOnlyPrintableAscii(propertyValue)) {
return true;
}
}
return false;
} |
Returns true when the property line should contain charset parameter
information. This method may return true even when vCard version is 3.0.
Strictly, adding charset information is invalid in VCard 3.0.
However we'll add the info only when charset we use is not UTF-8
in vCard 3.0 format, since parser side may be able to use the charset
via this field, though we may encounter another problem by adding it.
e.g. Japanese mobile phones use Shift_Jis while RFC 2426
recommends UTF-8. By adding this field, parsers may be able
to know this text is NOT UTF-8 but Shift_Jis.
| PostalStruct::shouldAppendCharsetParam | java | Reginer/aosp-android-jar | android-31/src/com/android/vcard/VCardBuilder.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java | MIT |
public PrinterCapabilitiesInfo() {
Arrays.fill(mDefaults, DEFAULT_UNDEFINED);
} |
@hide
| PrinterCapabilitiesInfo::PrinterCapabilitiesInfo | java | Reginer/aosp-android-jar | android-35/src/android/print/PrinterCapabilitiesInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java | MIT |
public PrinterCapabilitiesInfo(PrinterCapabilitiesInfo prototype) {
copyFrom(prototype);
} |
@hide
| PrinterCapabilitiesInfo::PrinterCapabilitiesInfo | java | Reginer/aosp-android-jar | android-35/src/android/print/PrinterCapabilitiesInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java | MIT |
public void copyFrom(PrinterCapabilitiesInfo other) {
if (this == other) {
return;
}
mMinMargins = other.mMinMargins;
if (other.mMediaSizes != null) {
if (mMediaSizes != null) {
mMediaSizes.clear();
mMediaSizes.addAll(other.mMediaSizes);
} else {
mMediaSizes = new ArrayList<MediaSize>(other.mMediaSizes);
}
} else {
mMediaSizes = null;
}
if (other.mResolutions != null) {
if (mResolutions != null) {
mResolutions.clear();
mResolutions.addAll(other.mResolutions);
} else {
mResolutions = new ArrayList<Resolution>(other.mResolutions);
}
} else {
mResolutions = null;
}
mColorModes = other.mColorModes;
mDuplexModes = other.mDuplexModes;
final int defaultCount = other.mDefaults.length;
for (int i = 0; i < defaultCount; i++) {
mDefaults[i] = other.mDefaults[i];
}
} |
@hide
| PrinterCapabilitiesInfo::copyFrom | java | Reginer/aosp-android-jar | android-35/src/android/print/PrinterCapabilitiesInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java | MIT |
public @NonNull List<MediaSize> getMediaSizes() {
return Collections.unmodifiableList(mMediaSizes);
} |
Gets the supported media sizes.
@return The media sizes.
| PrinterCapabilitiesInfo::getMediaSizes | java | Reginer/aosp-android-jar | android-35/src/android/print/PrinterCapabilitiesInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java | MIT |
public @NonNull List<Resolution> getResolutions() {
return Collections.unmodifiableList(mResolutions);
} |
Gets the supported resolutions.
@return The resolutions.
| PrinterCapabilitiesInfo::getResolutions | java | Reginer/aosp-android-jar | android-35/src/android/print/PrinterCapabilitiesInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java | MIT |
public @NonNull Margins getMinMargins() {
return mMinMargins;
} |
Gets the minimal margins. These are the minimal margins
the printer physically supports.
@return The minimal margins.
| PrinterCapabilitiesInfo::getMinMargins | java | Reginer/aosp-android-jar | android-35/src/android/print/PrinterCapabilitiesInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java | MIT |
public @ColorMode int getColorModes() {
return mColorModes;
} |
Gets the bit mask of supported color modes.
@return The bit mask of supported color modes.
@see PrintAttributes#COLOR_MODE_COLOR
@see PrintAttributes#COLOR_MODE_MONOCHROME
| PrinterCapabilitiesInfo::getColorModes | java | Reginer/aosp-android-jar | android-35/src/android/print/PrinterCapabilitiesInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java | MIT |
public @DuplexMode int getDuplexModes() {
return mDuplexModes;
} |
Gets the bit mask of supported duplex modes.
@return The bit mask of supported duplex modes.
@see PrintAttributes#DUPLEX_MODE_NONE
@see PrintAttributes#DUPLEX_MODE_LONG_EDGE
@see PrintAttributes#DUPLEX_MODE_SHORT_EDGE
| PrinterCapabilitiesInfo::getDuplexModes | java | Reginer/aosp-android-jar | android-35/src/android/print/PrinterCapabilitiesInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java | MIT |
public @NonNull PrintAttributes getDefaults() {
PrintAttributes.Builder builder = new PrintAttributes.Builder();
builder.setMinMargins(mMinMargins);
final int mediaSizeIndex = mDefaults[PROPERTY_MEDIA_SIZE];
if (mediaSizeIndex >= 0) {
builder.setMediaSize(mMediaSizes.get(mediaSizeIndex));
}
final int resolutionIndex = mDefaults[PROPERTY_RESOLUTION];
if (resolutionIndex >= 0) {
builder.setResolution(mResolutions.get(resolutionIndex));
}
final int colorMode = mDefaults[PROPERTY_COLOR_MODE];
if (colorMode > 0) {
builder.setColorMode(colorMode);
}
final int duplexMode = mDefaults[PROPERTY_DUPLEX_MODE];
if (duplexMode > 0) {
builder.setDuplexMode(duplexMode);
}
return builder.build();
} |
Gets the default print attributes.
@return The default attributes.
| PrinterCapabilitiesInfo::getDefaults | java | Reginer/aosp-android-jar | android-35/src/android/print/PrinterCapabilitiesInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java | MIT |
private static void enforceValidMask(int mask, IntConsumer enforceSingle) {
int current = mask;
while (current > 0) {
final int currentMode = (1 << Integer.numberOfTrailingZeros(current));
current &= ~currentMode;
enforceSingle.accept(currentMode);
}
} |
Call enforceSingle for each bit in the mask.
@param mask The mask
@param enforceSingle The function to call
| PrinterCapabilitiesInfo::enforceValidMask | java | Reginer/aosp-android-jar | android-35/src/android/print/PrinterCapabilitiesInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java | MIT |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.