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 HistoricalPackageOps(@NonNull String packageName) {
mPackageName = packageName;
} |
This class represents historical app op information about a package.
@hide
@SystemApi
public static final class HistoricalPackageOps implements Parcelable {
private final @NonNull String mPackageName;
private @Nullable ArrayMap<String, AttributedHistoricalOps> mAttributedHistoricalOps;
/** @hide | HistoricalPackageOps::HistoricalPackageOps | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public @NonNull String getPackageName() {
return mPackageName;
} |
Gets the package name which the data represents.
@return The package name which the data represents.
| HistoricalPackageOps::getPackageName | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public @IntRange(from = 0) int getOpCount() {
int numOps = 0;
int numAttributions = getAttributedOpsCount();
for (int code = 0; code < _NUM_OP; code++) {
String opName = opToPublicName(code);
for (int attributionNum = 0; attributionNum < numAttributions; attributionNum++) {
if (getAttributedOpsAt(attributionNum).getOp(opName) != null) {
numOps++;
break;
}
}
}
return numOps;
} |
Gets number historical app ops.
@return The number historical app ops.
@see #getOpAt(int)
| HistoricalPackageOps::getOpCount | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public @NonNull HistoricalOp getOpAt(@IntRange(from = 0) int index) {
int numOpsFound = 0;
int numAttributions = getAttributedOpsCount();
for (int code = 0; code < _NUM_OP; code++) {
String opName = opToPublicName(code);
for (int attributionNum = 0; attributionNum < numAttributions; attributionNum++) {
if (getAttributedOpsAt(attributionNum).getOp(opName) != null) {
if (numOpsFound == index) {
return getOp(opName);
} else {
numOpsFound++;
break;
}
}
}
}
throw new IndexOutOfBoundsException();
} |
Gets the historical op at a given index.
<p>This combines the counts from all attributions.
@param index The index to lookup.
@return The op at the given index.
@see #getOpCount()
| HistoricalPackageOps::getOpAt | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public @Nullable HistoricalOp getOp(@NonNull String opName) {
if (mAttributedHistoricalOps == null) {
return null;
}
HistoricalOp combinedOp = null;
int numAttributions = getAttributedOpsCount();
for (int i = 0; i < numAttributions; i++) {
HistoricalOp attributionOp = getAttributedOpsAt(i).getOp(opName);
if (attributionOp != null) {
if (combinedOp == null) {
combinedOp = new HistoricalOp(attributionOp);
} else {
combinedOp.merge(attributionOp);
}
}
}
return combinedOp;
} |
Gets the historical entry for a given op name.
<p>This combines the counts from all attributions.
@param opName The op name.
@return The historical entry for that op name.
| HistoricalPackageOps::getOp | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public @IntRange(from = 0) int getAttributedOpsCount() {
if (mAttributedHistoricalOps == null) {
return 0;
}
return mAttributedHistoricalOps.size();
} |
Gets number of attributed historical ops.
@return The number of attribution with historical ops.
@see #getAttributedOpsAt(int)
| HistoricalPackageOps::getAttributedOpsCount | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public @NonNull AttributedHistoricalOps getAttributedOpsAt(@IntRange(from = 0) int index) {
if (mAttributedHistoricalOps == null) {
throw new IndexOutOfBoundsException();
}
return mAttributedHistoricalOps.valueAt(index);
} |
Gets the attributed historical ops at a given index.
@param index The index.
@return The historical attribution ops at the given index.
@see #getAttributedOpsCount()
| HistoricalPackageOps::getAttributedOpsAt | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public @Nullable AttributedHistoricalOps getAttributedOps(@Nullable String attributionTag) {
if (mAttributedHistoricalOps == null) {
return null;
}
return mAttributedHistoricalOps.get(attributionTag);
} |
Gets the attributed historical ops for a given attribution tag.
@param attributionTag The attribution tag.
@return The historical ops for the attribution.
| HistoricalPackageOps::getAttributedOps | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public AttributedHistoricalOps(@NonNull String tag) {
mTag = tag;
} |
This class represents historical app op information about a attribution in a package.
@hide
@SystemApi
/* codegen verifier cannot deal with nested class parameters
@DataClass(genHiddenConstructor = true,
genEqualsHashCode = true, genHiddenCopyConstructor = true)
@DataClass.Suppress("getHistoricalOps")
public static final class AttributedHistoricalOps implements Parcelable {
/** {@link Context#createAttributionContext attribution} tag
private final @Nullable String mTag;
/** Ops for this attribution
private @Nullable ArrayMap<String, HistoricalOp> mHistoricalOps;
/** @hide | AttributedHistoricalOps::AttributedHistoricalOps | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public @IntRange(from = 0) int getOpCount() {
if (mHistoricalOps == null) {
return 0;
}
return mHistoricalOps.size();
} |
Gets number historical app ops.
@return The number historical app ops.
@see #getOpAt(int)
| AttributedHistoricalOps::getOpCount | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public @NonNull HistoricalOp getOpAt(@IntRange(from = 0) int index) {
if (mHistoricalOps == null) {
throw new IndexOutOfBoundsException();
}
return mHistoricalOps.valueAt(index);
} |
Gets the historical op at a given index.
@param index The index to lookup.
@return The op at the given index.
@see #getOpCount()
| AttributedHistoricalOps::getOpAt | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public @Nullable HistoricalOp getOp(@NonNull String opName) {
if (mHistoricalOps == null) {
return null;
}
return mHistoricalOps.get(opName);
} |
Gets the historical entry for a given op name.
@param opName The op name.
@return The historical entry for that op name.
| AttributedHistoricalOps::getOp | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public HistoricalOp(int op) {
mOp = op;
} |
This class represents historical information about an app op.
@hide
@SystemApi
public static final class HistoricalOp implements Parcelable {
private final int mOp;
private @Nullable LongSparseLongArray mAccessCount;
private @Nullable LongSparseLongArray mRejectCount;
private @Nullable LongSparseLongArray mAccessDuration;
/** Discrete Ops for this Op
private @Nullable List<AttributedOpEntry> mDiscreteAccesses;
/** @hide | HistoricalOp::HistoricalOp | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public @NonNull String getOpName() {
return sOpToString[mOp];
} |
Gets the op name.
@return The op name.
| HistoricalOp::getOpName | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public int getOpCode() {
return mOp;
} |
Gets the op name.
@return The op name.
public @NonNull String getOpName() {
return sOpToString[mOp];
}
/** @hide | HistoricalOp::getOpCode | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public @IntRange(from = 0) int getDiscreteAccessCount() {
if (mDiscreteAccesses == null) {
return 0;
}
return mDiscreteAccesses.size();
} |
Gets number of discrete historical app ops.
@return The number historical app ops.
@see #getDiscreteAccessAt(int)
| HistoricalOp::getDiscreteAccessCount | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public @NonNull AttributedOpEntry getDiscreteAccessAt(@IntRange(from = 0) int index) {
if (mDiscreteAccesses == null) {
throw new IndexOutOfBoundsException();
}
return mDiscreteAccesses.get(index);
} |
Gets the historical op at a given index.
@param index The index to lookup.
@return The op at the given index.
@see #getDiscreteAccessCount()
| HistoricalOp::getDiscreteAccessAt | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public long getForegroundAccessCount(@OpFlags int flags) {
return sumForFlagsInStates(mAccessCount, MAX_PRIORITY_UID_STATE,
resolveFirstUnrestrictedUidState(mOp), flags);
} |
Gets the number times the op was accessed (performed) in the foreground.
@param flags The flags which are any combination of
{@link #OP_FLAG_SELF}, {@link #OP_FLAG_TRUSTED_PROXY},
{@link #OP_FLAG_UNTRUSTED_PROXY}, {@link #OP_FLAG_TRUSTED_PROXIED},
{@link #OP_FLAG_UNTRUSTED_PROXIED}. You can use {@link #OP_FLAGS_ALL}
for any flag.
@return The times the op was accessed in the foreground.
@see #getBackgroundAccessCount(int)
@see #getAccessCount(int, int, int)
| HistoricalOp::getForegroundAccessCount | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public long getBackgroundAccessCount(@OpFlags int flags) {
return sumForFlagsInStates(mAccessCount, resolveLastRestrictedUidState(mOp),
MIN_PRIORITY_UID_STATE, flags);
} |
Gets the number times the op was accessed (performed) in the background.
@param flags The flags which are any combination of
{@link #OP_FLAG_SELF}, {@link #OP_FLAG_TRUSTED_PROXY},
{@link #OP_FLAG_UNTRUSTED_PROXY}, {@link #OP_FLAG_TRUSTED_PROXIED},
{@link #OP_FLAG_UNTRUSTED_PROXIED}. You can use {@link #OP_FLAGS_ALL}
for any flag.
@return The times the op was accessed in the background.
@see #getForegroundAccessCount(int)
@see #getAccessCount(int, int, int)
| HistoricalOp::getBackgroundAccessCount | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public long getAccessCount(@UidState int fromUidState, @UidState int toUidState,
@OpFlags int flags) {
return sumForFlagsInStates(mAccessCount, fromUidState, toUidState, flags);
} |
Gets the number times the op was accessed (performed) for a
range of uid states.
@param fromUidState The UID state from which to query. Could be one of
{@link #UID_STATE_PERSISTENT}, {@link #UID_STATE_TOP},
{@link #UID_STATE_FOREGROUND_SERVICE}, {@link #UID_STATE_FOREGROUND},
{@link #UID_STATE_BACKGROUND}, {@link #UID_STATE_CACHED}.
@param toUidState The UID state to which to query.
@param flags The flags which are any combination of
{@link #OP_FLAG_SELF}, {@link #OP_FLAG_TRUSTED_PROXY},
{@link #OP_FLAG_UNTRUSTED_PROXY}, {@link #OP_FLAG_TRUSTED_PROXIED},
{@link #OP_FLAG_UNTRUSTED_PROXIED}. You can use {@link #OP_FLAGS_ALL}
for any flag.
@return The times the op was accessed for the given UID state.
@see #getForegroundAccessCount(int)
@see #getBackgroundAccessCount(int)
| HistoricalOp::getAccessCount | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public long getForegroundRejectCount(@OpFlags int flags) {
return sumForFlagsInStates(mRejectCount, MAX_PRIORITY_UID_STATE,
resolveFirstUnrestrictedUidState(mOp), flags);
} |
Gets the number times the op was rejected in the foreground.
@param flags The flags which are any combination of
{@link #OP_FLAG_SELF}, {@link #OP_FLAG_TRUSTED_PROXY},
{@link #OP_FLAG_UNTRUSTED_PROXY}, {@link #OP_FLAG_TRUSTED_PROXIED},
{@link #OP_FLAG_UNTRUSTED_PROXIED}. You can use {@link #OP_FLAGS_ALL}
for any flag.
@return The times the op was rejected in the foreground.
@see #getBackgroundRejectCount(int)
@see #getRejectCount(int, int, int)
| HistoricalOp::getForegroundRejectCount | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public long getBackgroundRejectCount(@OpFlags int flags) {
return sumForFlagsInStates(mRejectCount, resolveLastRestrictedUidState(mOp),
MIN_PRIORITY_UID_STATE, flags);
} |
Gets the number times the op was rejected in the background.
@param flags The flags which are any combination of
{@link #OP_FLAG_SELF}, {@link #OP_FLAG_TRUSTED_PROXY},
{@link #OP_FLAG_UNTRUSTED_PROXY}, {@link #OP_FLAG_TRUSTED_PROXIED},
{@link #OP_FLAG_UNTRUSTED_PROXIED}. You can use {@link #OP_FLAGS_ALL}
for any flag.
@return The times the op was rejected in the background.
@see #getForegroundRejectCount(int)
@see #getRejectCount(int, int, int)
| HistoricalOp::getBackgroundRejectCount | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public long getRejectCount(@UidState int fromUidState, @UidState int toUidState,
@OpFlags int flags) {
return sumForFlagsInStates(mRejectCount, fromUidState, toUidState, flags);
} |
Gets the number times the op was rejected for a given range of UID states.
@param fromUidState The UID state from which to query. Could be one of
{@link #UID_STATE_PERSISTENT}, {@link #UID_STATE_TOP},
{@link #UID_STATE_FOREGROUND_SERVICE}, {@link #UID_STATE_FOREGROUND},
{@link #UID_STATE_BACKGROUND}, {@link #UID_STATE_CACHED}.
@param toUidState The UID state to which to query.
@param flags The flags which are any combination of
{@link #OP_FLAG_SELF}, {@link #OP_FLAG_TRUSTED_PROXY},
{@link #OP_FLAG_UNTRUSTED_PROXY}, {@link #OP_FLAG_TRUSTED_PROXIED},
{@link #OP_FLAG_UNTRUSTED_PROXIED}. You can use {@link #OP_FLAGS_ALL}
for any flag.
@return The times the op was rejected for the given UID state.
@see #getForegroundRejectCount(int)
@see #getBackgroundRejectCount(int)
| HistoricalOp::getRejectCount | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public long getForegroundAccessDuration(@OpFlags int flags) {
return sumForFlagsInStates(mAccessDuration, MAX_PRIORITY_UID_STATE,
resolveFirstUnrestrictedUidState(mOp), flags);
} |
Gets the total duration the app op was accessed (performed) in the foreground.
The duration is in wall time.
@param flags The flags which are any combination of
{@link #OP_FLAG_SELF}, {@link #OP_FLAG_TRUSTED_PROXY},
{@link #OP_FLAG_UNTRUSTED_PROXY}, {@link #OP_FLAG_TRUSTED_PROXIED},
{@link #OP_FLAG_UNTRUSTED_PROXIED}. You can use {@link #OP_FLAGS_ALL}
for any flag.
@return The total duration the app op was accessed in the foreground.
@see #getBackgroundAccessDuration(int)
@see #getAccessDuration(int, int, int)
| HistoricalOp::getForegroundAccessDuration | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public long getBackgroundAccessDuration(@OpFlags int flags) {
return sumForFlagsInStates(mAccessDuration, resolveLastRestrictedUidState(mOp),
MIN_PRIORITY_UID_STATE, flags);
} |
Gets the total duration the app op was accessed (performed) in the background.
The duration is in wall time.
@param flags The flags which are any combination of
{@link #OP_FLAG_SELF}, {@link #OP_FLAG_TRUSTED_PROXY},
{@link #OP_FLAG_UNTRUSTED_PROXY}, {@link #OP_FLAG_TRUSTED_PROXIED},
{@link #OP_FLAG_UNTRUSTED_PROXIED}. You can use {@link #OP_FLAGS_ALL}
for any flag.
@return The total duration the app op was accessed in the background.
@see #getForegroundAccessDuration(int)
@see #getAccessDuration(int, int, int)
| HistoricalOp::getBackgroundAccessDuration | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public long getAccessDuration(@UidState int fromUidState, @UidState int toUidState,
@OpFlags int flags) {
return sumForFlagsInStates(mAccessDuration, fromUidState, toUidState, flags);
} |
Gets the total duration the app op was accessed (performed) for a given
range of UID states. The duration is in wall time.
@param fromUidState The UID state from which to query. Could be one of
{@link #UID_STATE_PERSISTENT}, {@link #UID_STATE_TOP},
{@link #UID_STATE_FOREGROUND_SERVICE}, {@link #UID_STATE_FOREGROUND},
{@link #UID_STATE_BACKGROUND}, {@link #UID_STATE_CACHED}.
@param toUidState The UID state from which to query.
@param flags The flags which are any combination of
{@link #OP_FLAG_SELF}, {@link #OP_FLAG_TRUSTED_PROXY},
{@link #OP_FLAG_UNTRUSTED_PROXY}, {@link #OP_FLAG_TRUSTED_PROXIED},
{@link #OP_FLAG_UNTRUSTED_PROXIED}. You can use {@link #OP_FLAGS_ALL}
for any flag.
@return The total duration the app op was accessed for the given UID state.
@see #getForegroundAccessDuration(int)
@see #getBackgroundAccessDuration(int)
| HistoricalOp::getAccessDuration | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
private static void scale(@NonNull LongSparseLongArray data, double scaleFactor) {
if (data != null) {
final int size = data.size();
for (int i = 0; i < size; i++) {
data.put(data.keyAt(i), (long) HistoricalOps.round(
(double) data.valueAt(i) * scaleFactor));
}
}
} |
Multiplies the entries in the array with the passed in scale factor and
rounds the result at up 0.5 boundary.
@param data The data to scale.
@param scaleFactor The scale factor.
| HistoricalOp::scale | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
private static void merge(@NonNull Supplier<LongSparseLongArray> thisSupplier,
@Nullable LongSparseLongArray other) {
if (other != null) {
final int otherSize = other.size();
for (int i = 0; i < otherSize; i++) {
final LongSparseLongArray that = thisSupplier.get();
final long otherKey = other.keyAt(i);
final long otherValue = other.valueAt(i);
that.put(otherKey, that.get(otherKey) + otherValue);
}
}
} |
Merges two arrays while lazily acquiring the destination.
@param thisSupplier The destination supplier.
@param other The array to merge in.
| HistoricalOp::merge | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public @Nullable LongSparseArray<Object> collectKeys() {
LongSparseArray<Object> result = AppOpsManager.collectKeys(mAccessCount,
null /*result*/);
result = AppOpsManager.collectKeys(mRejectCount, result);
result = AppOpsManager.collectKeys(mAccessDuration, result);
return result;
} |
Merges two arrays while lazily acquiring the destination.
@param thisSupplier The destination supplier.
@param other The array to merge in.
private static void merge(@NonNull Supplier<LongSparseLongArray> thisSupplier,
@Nullable LongSparseLongArray other) {
if (other != null) {
final int otherSize = other.size();
for (int i = 0; i < otherSize; i++) {
final LongSparseLongArray that = thisSupplier.get();
final long otherKey = other.keyAt(i);
final long otherValue = other.valueAt(i);
that.put(otherKey, that.get(otherKey) + otherValue);
}
}
}
/** @hide | HistoricalOp::collectKeys | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
private final IAppOpsAsyncNotedCallback mAsyncCb = new IAppOpsAsyncNotedCallback.Stub() {
@Override
public void opNoted(AsyncNotedAppOp op) {
Objects.requireNonNull(op);
final long token = Binder.clearCallingIdentity();
try {
getAsyncNotedExecutor().execute(() -> onAsyncNoted(op));
} finally {
Binder.restoreCallingIdentity(token);
}
}
}; |
Callback an app can {@link #setOnOpNotedCallback set} to monitor the app-ops the
system has tracked for it. I.e. each time any app calls {@link #noteOp} or {@link #startOp}
one of a method of this object is called.
<p><b>There will be a call for all app-ops related to runtime permissions, but not
necessarily for all other app-ops.
<pre>
setOnOpNotedCallback(getMainExecutor(), new OnOpNotedCallback() {
ArraySet<Pair<String, String>> opsNotedForThisProcess = new ArraySet<>();
private synchronized void addAccess(String op, String accessLocation) {
// Ops are often noted when runtime permission protected APIs were called.
// In this case permissionToOp() allows to resolve the permission<->op
opsNotedForThisProcess.add(new Pair(accessType, accessLocation));
}
public void onNoted(SyncNotedAppOp op) {
// Accesses is currently happening, hence stack trace describes location of access
addAccess(op.getOp(), Arrays.toString(Thread.currentThread().getStackTrace()));
}
public void onSelfNoted(SyncNotedAppOp op) {
onNoted(op);
}
public void onAsyncNoted(AsyncNotedAppOp asyncOp) {
// Stack trace is not useful for async ops as accessed happened on different thread
addAccess(asyncOp.getOp(), asyncOp.getMessage());
}
});
</pre>
@see #setOnOpNotedCallback
public abstract static class OnOpNotedCallback {
private @NonNull Executor mAsyncExecutor;
/** Callback registered with the system. This will receive the async notes ops | OnOpNotedCallback::Stub | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
protected @NonNull Executor getAsyncNotedExecutor() {
return mAsyncExecutor;
} |
Will be removed before R ships.
@return The executor for the system to use when calling {@link #onAsyncNoted}.
@hide
| OnOpNotedCallback::getAsyncNotedExecutor | java | Reginer/aosp-android-jar | android-33/src/android/app/AppOpsManager.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/AppOpsManager.java | MIT |
public MlBreakEngine(UnicodeSet digitOrOpenPunctuationOrAlphabetSet,
UnicodeSet closePunctuationSet) {
fDigitOrOpenPunctuationOrAlphabetSet = digitOrOpenPunctuationOrAlphabetSet;
fClosePunctuationSet = closePunctuationSet;
fModel = new ArrayList<HashMap<String, Integer>>(MAX_FEATURE);
for (int i = 0; i < MAX_FEATURE; i++) {
fModel.add(new HashMap<String, Integer>());
}
fNegativeSum = 0;
loadMLModel();
} |
Constructor for Chinese and Japanese phrase breaking.
@param digitOrOpenPunctuationOrAlphabetSet An unicode set with the digit and open punctuation
and alphabet.
@param closePunctuationSet An unicode set with the close punctuation.
| MlBreakEngine::MlBreakEngine | java | Reginer/aosp-android-jar | android-34/src/android/icu/impl/breakiter/MlBreakEngine.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/icu/impl/breakiter/MlBreakEngine.java | MIT |
public int divideUpRange(CharacterIterator inText, int startPos, int endPos,
CharacterIterator inString, int codePointLength, int[] charPositions,
DictionaryBreakEngine.DequeI foundBreaks) {
if (startPos >= endPos) {
return 0;
}
ArrayList<Integer> boundary = new ArrayList<Integer>(codePointLength);
String inputStr = transform(inString);
// The ML algorithm groups six char and evaluates whether the 4th char is a breakpoint.
// In each iteration, it evaluates the 4th char and then moves forward one char like
// sliding window. Initially, the first six values in the indexList are
// [-1, -1, 0, 1, 2, 3]. After moving forward, finally the last six values in the indexList
// are [length-4, length-3, length-2, length-1, -1, -1]. The "+4" here means four extra
// "-1".
int indexSize = codePointLength + 4;
int indexList[] = new int[indexSize];
int numCodeUnits = initIndexList(inString, indexList, codePointLength);
// Add a break for the start.
boundary.add(0, 0);
for (int idx = 0; idx + 1 < codePointLength; idx++) {
evaluateBreakpoint(inputStr, indexList, idx, numCodeUnits, boundary);
if (idx + 4 < codePointLength) {
indexList[idx + 6] = numCodeUnits;
numCodeUnits += Character.charCount(next32(inString));
}
}
// Add a break for the end if there is not one there already.
if (boundary.get(boundary.size() - 1) != codePointLength) {
boundary.add(codePointLength);
}
int correctedNumBreaks = 0;
int previous = -1;
int numBreaks = boundary.size();
for (int i = 0; i < numBreaks; i++) {
int pos = charPositions[boundary.get(i)] + startPos;
// In phrase breaking, there has to be a breakpoint between Cj character and close
// punctuation.
// E.g.[携帯電話]正しい選択 -> [携帯▁電話]▁正しい▁選択 -> breakpoint between ] and 正
inText.setIndex(pos);
if (pos > previous) {
if (pos != startPos
|| (pos > 0
&& fClosePunctuationSet.contains(previous32(inText)))) {
foundBreaks.push(pos);
correctedNumBreaks++;
}
}
previous = pos;
}
if (!foundBreaks.isEmpty() && foundBreaks.peek() == endPos) {
// In phrase breaking, there has to be a breakpoint between Cj character and
// the number/open punctuation.
// E.g. る文字「そうだ、京都」->る▁文字▁「そうだ、▁京都」-> breakpoint between 字 and「
// E.g. 乗車率90%程度だろうか -> 乗車▁率▁90%▁程度だろうか -> breakpoint between 率 and 9
// E.g. しかもロゴがUnicode! -> しかも▁ロゴが▁Unicode!-> breakpoint between が and U
inText.setIndex(endPos);
int current = current32(inText);
if (current != DONE32 && !fDigitOrOpenPunctuationOrAlphabetSet.contains(current)) {
foundBreaks.pop();
correctedNumBreaks--;
}
}
if (!foundBreaks.isEmpty()) {
inText.setIndex(foundBreaks.peek());
}
return correctedNumBreaks;
} |
Divide up a range of characters handled by this break engine.
@param inText An input text.
@param startPos The start index of the input text.
@param endPos The end index of the input text.
@param inString A input string normalized from inText from startPos to endPos
@param codePointLength The number of code points of inString
@param charPositions A map that transforms inString's code point index to code unit index.
@param foundBreaks A list to store the breakpoint.
@return The number of breakpoints
| MlBreakEngine::divideUpRange | java | Reginer/aosp-android-jar | android-34/src/android/icu/impl/breakiter/MlBreakEngine.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/icu/impl/breakiter/MlBreakEngine.java | MIT |
private String transform(CharacterIterator inString) {
StringBuilder sb = new StringBuilder();
inString.setIndex(0);
for (char c = inString.first(); c != CharacterIterator.DONE; c = inString.next()) {
sb.append(c);
}
return sb.toString();
} |
Transform a CharacterIterator into a String.
| MlBreakEngine::transform | java | Reginer/aosp-android-jar | android-34/src/android/icu/impl/breakiter/MlBreakEngine.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/icu/impl/breakiter/MlBreakEngine.java | MIT |
private void evaluateBreakpoint(String inputStr, int[] indexList, int startIdx,
int numCodeUnits, ArrayList<Integer> boundary) {
int start = 0, end = 0;
int score = fNegativeSum;
for (int i = 0; i < 6; i++) {
// UW1 ~ UW6
start = startIdx + i;
if (indexList[start] != -1) {
end = (indexList[start + 1] != -1) ? indexList[start + 1] : numCodeUnits;
score += fModel.get(ModelIndex.kUWStart.getValue() + i).getOrDefault(
inputStr.substring(indexList[start], end), 0);
}
}
for (int i = 0; i < 3; i++) {
// BW1 ~ BW3
start = startIdx + i + 1;
if (indexList[start] != -1 && indexList[start + 1] != -1) {
end = (indexList[start + 2] != -1) ? indexList[start + 2] : numCodeUnits;
score += fModel.get(ModelIndex.kBWStart.getValue() + i).getOrDefault(
inputStr.substring(indexList[start], end), 0);
}
}
for (int i = 0; i < 4; i++) {
// TW1 ~ TW4
start = startIdx + i;
if (indexList[start] != -1
&& indexList[start + 1] != -1
&& indexList[start + 2] != -1) {
end = (indexList[start + 3] != -1) ? indexList[start + 3] : numCodeUnits;
score += fModel.get(ModelIndex.kTWStart.getValue() + i).getOrDefault(
inputStr.substring(indexList[start], end), 0);
}
}
if (score > 0) {
boundary.add(startIdx + 1);
}
} |
Evaluate whether the breakpointIdx is a potential breakpoint.
@param inputStr An input string to be segmented.
@param indexList A code unit index list of the inputStr.
@param startIdx The start index of the indexList.
@param numCodeUnits The current code unit boundary of the indexList.
@param boundary A list including the index of the breakpoint.
| MlBreakEngine::evaluateBreakpoint | java | Reginer/aosp-android-jar | android-34/src/android/icu/impl/breakiter/MlBreakEngine.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/icu/impl/breakiter/MlBreakEngine.java | MIT |
private int initIndexList(CharacterIterator inString, int[] indexList, int codePointLength) {
int index = 0;
inString.setIndex(index);
Arrays.fill(indexList, -1);
if (codePointLength > 0) {
indexList[2] = 0;
index += Character.charCount(current32(inString));
if (codePointLength > 1) {
indexList[3] = index;
index += Character.charCount(next32(inString));
if (codePointLength > 2) {
indexList[4] = index;
index += Character.charCount(next32(inString));
if (codePointLength > 3) {
indexList[5] = index;
index += Character.charCount(next32(inString));
}
}
}
}
return index;
} |
Initialize the index list from the input string.
@param inString An input string to be segmented.
@param indexList A code unit index list of the inString.
@param codePointLength The number of code points of the input string
@return The number of the code units of the first six characters in inString.
| MlBreakEngine::initIndexList | java | Reginer/aosp-android-jar | android-34/src/android/icu/impl/breakiter/MlBreakEngine.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/icu/impl/breakiter/MlBreakEngine.java | MIT |
private void loadMLModel() {
int index = 0;
UResourceBundle rb = UResourceBundle.getBundleInstance(ICUData.ICU_BRKITR_BASE_NAME,
"jaml");
initKeyValue(rb, "UW1Keys", "UW1Values", fModel.get(index++));
initKeyValue(rb, "UW2Keys", "UW2Values", fModel.get(index++));
initKeyValue(rb, "UW3Keys", "UW3Values", fModel.get(index++));
initKeyValue(rb, "UW4Keys", "UW4Values", fModel.get(index++));
initKeyValue(rb, "UW5Keys", "UW5Values", fModel.get(index++));
initKeyValue(rb, "UW6Keys", "UW6Values", fModel.get(index++));
initKeyValue(rb, "BW1Keys", "BW1Values", fModel.get(index++));
initKeyValue(rb, "BW2Keys", "BW2Values", fModel.get(index++));
initKeyValue(rb, "BW3Keys", "BW3Values", fModel.get(index++));
initKeyValue(rb, "TW1Keys", "TW1Values", fModel.get(index++));
initKeyValue(rb, "TW2Keys", "TW2Values", fModel.get(index++));
initKeyValue(rb, "TW3Keys", "TW3Values", fModel.get(index++));
initKeyValue(rb, "TW4Keys", "TW4Values", fModel.get(index++));
fNegativeSum /= 2;
} |
Load the machine learning's model file.
| MlBreakEngine::loadMLModel | java | Reginer/aosp-android-jar | android-34/src/android/icu/impl/breakiter/MlBreakEngine.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/icu/impl/breakiter/MlBreakEngine.java | MIT |
private void initKeyValue(UResourceBundle rb, String keyName, String valueName,
HashMap<String, Integer> map) {
int idx = 0;
UResourceBundle keyBundle = rb.get(keyName);
UResourceBundle valueBundle = rb.get(valueName);
int[] value = valueBundle.getIntVector();
UResourceBundleIterator iterator = keyBundle.getIterator();
while (iterator.hasNext()) {
fNegativeSum -= value[idx];
map.put(iterator.nextString(), value[idx++]);
}
} |
In the machine learning's model file, specify the name of the key and value to load the
corresponding feature and its score.
@param rb A RedouceBundle corresponding to the model file.
@param keyName The kay name in the model file.
@param valueName The value name in the model file.
@param map A HashMap to store the pairs of the feature and its score.
| MlBreakEngine::initKeyValue | java | Reginer/aosp-android-jar | android-34/src/android/icu/impl/breakiter/MlBreakEngine.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/icu/impl/breakiter/MlBreakEngine.java | MIT |
public HeavyHitterContainer() {
} |
Default constructor
| HeavyHitterContainer::HeavyHitterContainer | java | Reginer/aosp-android-jar | android-31/src/com/android/internal/os/BinderCallHeavyHitterWatcher.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/internal/os/BinderCallHeavyHitterWatcher.java | MIT |
public HeavyHitterContainer(@NonNull final HeavyHitterContainer other) {
this.mUid = other.mUid;
this.mClass = other.mClass;
this.mCode = other.mCode;
this.mFrequency = other.mFrequency;
} |
Copy constructor
| HeavyHitterContainer::HeavyHitterContainer | java | Reginer/aosp-android-jar | android-31/src/com/android/internal/os/BinderCallHeavyHitterWatcher.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/internal/os/BinderCallHeavyHitterWatcher.java | MIT |
static int hashCode(int uid, @NonNull Class clazz, int code) {
int hash = uid;
hash = 31 * hash + clazz.hashCode();
hash = 31 * hash + code;
return hash;
} |
Compute the hashcode with given parameters.
| HeavyHitterContainer::hashCode | java | Reginer/aosp-android-jar | android-31/src/com/android/internal/os/BinderCallHeavyHitterWatcher.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/internal/os/BinderCallHeavyHitterWatcher.java | MIT |
public static BinderCallHeavyHitterWatcher getInstance() {
synchronized (sLock) {
if (sInstance == null) {
sInstance = new BinderCallHeavyHitterWatcher();
}
return sInstance;
}
} |
Return the instance of the watcher
| HeavyHitterContainer::getInstance | java | Reginer/aosp-android-jar | android-31/src/com/android/internal/os/BinderCallHeavyHitterWatcher.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/internal/os/BinderCallHeavyHitterWatcher.java | MIT |
public void setConfig(final boolean enable, final int batchSize, final float threshold,
@Nullable final BinderCallHeavyHitterListener listener) {
synchronized (mLock) {
if (!enable) {
if (mEnabled) {
resetInternalLocked(null, null, 0, 0, 0.0f, 0);
mEnabled = false;
}
return;
}
mEnabled = true;
// Validate the threshold, which is expected to be within (0.0f, 1.0f]
if (threshold < EPSILON || threshold > 1.0f) {
return;
}
if (batchSize == mTotalInputSize && Math.abs(threshold - mThreshold) < EPSILON) {
// Shortcut: just update the listener, no need to reset the watcher itself.
mListener = listener;
return;
}
final int capacity = (int) (1.0f / threshold);
final HeavyHitterSketch<Integer> sketch = HeavyHitterSketch.<Integer>newDefault();
final float validationRatio = sketch.getRequiredValidationInputRatio();
int inputSize = batchSize;
if (!Float.isNaN(validationRatio)) {
inputSize = (int) (batchSize * (1 - validationRatio));
}
try {
sketch.setConfig(batchSize, capacity);
} catch (IllegalArgumentException e) {
// invalid parameter, ignore the config.
Log.w(TAG, "Invalid parameter to heavy hitter watcher: "
+ batchSize + ", " + capacity);
return;
}
// Reset the watcher to start over with the new configuration.
resetInternalLocked(listener, sketch, inputSize, batchSize, threshold, capacity);
}
} |
Configure the parameters.
@param enable Whether or not to enable the watcher
@param batchSize The number of binder transactions it needs to receive before the conclusion
@param threshold The threshold to determine if some type of transactions are too many, it
should be a value between (0.0f, 1.0f]
@param listener The callback interface
| HeavyHitterContainer::setConfig | java | Reginer/aosp-android-jar | android-31/src/com/android/internal/os/BinderCallHeavyHitterWatcher.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/internal/os/BinderCallHeavyHitterWatcher.java | MIT |
public void onTransaction(final int callerUid, @NonNull final Class clazz,
final int code) {
synchronized (mLock) {
if (!mEnabled) {
return;
}
final HeavyHitterSketch<Integer> sketch = mHeavyHitterSketch;
if (sketch == null) {
return;
}
// To reduce memory fragmentation, we only feed the hashcode to the sketch,
// and keep the mapping from the hashcode to the sketch locally.
// However, the mapping will not be built until the validation pass, by then
// we will know the potential heavy hitters, so the mapping can focus on
// those ones, which will significantly reduce the memory overhead.
final int hashCode = HeavyHitterContainer.hashCode(callerUid, clazz, code);
sketch.add(hashCode);
mCurrentInputSize++;
if (mCurrentInputSize == mInputSize) {
// Retrieve the candidates
sketch.getCandidates(mCachedCandidateList);
mCachedCandidateSet.addAll(mCachedCandidateList);
mCachedCandidateList.clear();
} else if (mCurrentInputSize > mInputSize && mCurrentInputSize < mTotalInputSize) {
// validation pass
if (mCachedCandidateSet.contains(hashCode)) {
// It's one of the candidates
final int index = mHeavyHitterCandiates.indexOfKey(hashCode);
if (index < 0) {
// We got another hit, now write down its information
final HeavyHitterContainer container =
acquireHeavyHitterContainerLocked();
container.mUid = callerUid;
container.mClass = clazz;
container.mCode = code;
mHeavyHitterCandiates.put(hashCode, container);
}
}
} else if (mCurrentInputSize == mTotalInputSize) {
// Reached the expected number of input, check top ones
if (mListener != null) {
final List<Integer> result = sketch.getTopHeavyHitters(0,
mCachedCandidateList, mCachedCandidateFrequencies);
if (result != null) {
final int size = result.size();
if (size > 0) {
final ArrayList<HeavyHitterContainer> hitters = new ArrayList<>();
for (int i = 0; i < size; i++) {
final HeavyHitterContainer container = mHeavyHitterCandiates.get(
result.get(i));
if (container != null) {
final HeavyHitterContainer cont =
new HeavyHitterContainer(container);
cont.mFrequency = mCachedCandidateFrequencies.get(i);
hitters.add(cont);
}
}
mListener.onHeavyHit(hitters, mTotalInputSize, mThreshold,
SystemClock.elapsedRealtime() - mBatchStartTimeStamp);
}
}
}
// reset
mHeavyHitterSketch.reset();
mHeavyHitterCandiates.clear();
mCachedCandidateList.clear();
mCachedCandidateFrequencies.clear();
mCachedCandidateSet.clear();
mCachedCandidateContainersIndex = 0;
mCurrentInputSize = 0;
mBatchStartTimeStamp = SystemClock.elapsedRealtime();
}
}
} |
Called on incoming binder transaction
@param callerUid The UID of the binder transaction's caller
@param clazz The class of the Binder object serving the transaction
@param code The binder transaction code
| HeavyHitterContainer::onTransaction | java | Reginer/aosp-android-jar | android-31/src/com/android/internal/os/BinderCallHeavyHitterWatcher.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/internal/os/BinderCallHeavyHitterWatcher.java | MIT |
public static View initSnippetForInstalledApp(Context pContext,
ApplicationInfo appInfo, View snippetView) {
return initSnippetForInstalledApp(pContext, appInfo, snippetView, null);
} |
Utility method to display a snippet of an installed application.
The content view should have been set on context before invoking this method.
appSnippet view should include R.id.app_icon and R.id.app_name
defined on it.
@param pContext context of package that can load the resources
@param componentInfo ComponentInfo object whose resources are to be loaded
@param snippetView the snippet view
| PackageUtil::initSnippetForInstalledApp | java | Reginer/aosp-android-jar | android-32/src/com/android/packageinstaller/PackageUtil.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/packageinstaller/PackageUtil.java | MIT |
public static View initSnippetForInstalledApp(Context pContext,
ApplicationInfo appInfo, View snippetView, UserHandle user) {
final PackageManager pm = pContext.getPackageManager();
Drawable icon = appInfo.loadIcon(pm);
if (user != null) {
icon = pContext.getPackageManager().getUserBadgedIcon(icon, user);
}
return initSnippet(
snippetView,
appInfo.loadLabel(pm),
icon);
} |
Utility method to display a snippet of an installed application.
The content view should have been set on context before invoking this method.
appSnippet view should include R.id.app_icon and R.id.app_name
defined on it.
@param pContext context of package that can load the resources
@param componentInfo ComponentInfo object whose resources are to be loaded
@param snippetView the snippet view
@param UserHandle user that the app si installed for.
| PackageUtil::initSnippetForInstalledApp | java | Reginer/aosp-android-jar | android-32/src/com/android/packageinstaller/PackageUtil.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/packageinstaller/PackageUtil.java | MIT |
public static AppSnippet getAppSnippet(
Activity pContext, ApplicationInfo appInfo, File sourceFile) {
final String archiveFilePath = sourceFile.getAbsolutePath();
Resources pRes = pContext.getResources();
AssetManager assmgr = new AssetManager();
assmgr.addAssetPath(archiveFilePath);
Resources res = new Resources(assmgr, pRes.getDisplayMetrics(), pRes.getConfiguration());
CharSequence label = null;
// Try to load the label from the package's resources. If an app has not explicitly
// specified any label, just use the package name.
if (appInfo.labelRes != 0) {
try {
label = res.getText(appInfo.labelRes);
} catch (Resources.NotFoundException e) {
}
}
if (label == null) {
label = (appInfo.nonLocalizedLabel != null) ?
appInfo.nonLocalizedLabel : appInfo.packageName;
}
Drawable icon = null;
// Try to load the icon from the package's resources. If an app has not explicitly
// specified any resource, just use the default icon for now.
try {
if (appInfo.icon != 0) {
try {
icon = res.getDrawable(appInfo.icon);
} catch (Resources.NotFoundException e) {
}
}
if (icon == null) {
icon = pContext.getPackageManager().getDefaultActivityIcon();
}
} catch (OutOfMemoryError e) {
Log.i(LOG_TAG, "Could not load app icon", e);
}
return new PackageUtil.AppSnippet(label, icon);
} |
Utility method to load application label
@param pContext context of package that can load the resources
@param appInfo ApplicationInfo object of package whose resources are to be loaded
@param sourceFile File the package is in
| AppSnippet::getAppSnippet | java | Reginer/aosp-android-jar | android-32/src/com/android/packageinstaller/PackageUtil.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/packageinstaller/PackageUtil.java | MIT |
static int getMaxTargetSdkVersionForUid(@NonNull Context context, int uid) {
PackageManager pm = context.getPackageManager();
final String[] packages = pm.getPackagesForUid(uid);
int targetSdkVersion = -1;
if (packages != null) {
for (String packageName : packages) {
try {
ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
targetSdkVersion = Math.max(targetSdkVersion, info.targetSdkVersion);
} catch (PackageManager.NameNotFoundException e) {
// Ignore and try the next package
}
}
}
return targetSdkVersion;
} |
Get the maximum target sdk for a UID.
@param context The context to use
@param uid The UID requesting the install/uninstall
@return The maximum target SDK or -1 if the uid does not match any packages.
| AppSnippet::getMaxTargetSdkVersionForUid | java | Reginer/aosp-android-jar | android-32/src/com/android/packageinstaller/PackageUtil.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/packageinstaller/PackageUtil.java | MIT |
public static String getAbsoluteURIFromRelative(String localPath)
{
if (localPath == null || localPath.length() == 0)
return "";
// If the local path is a relative path, then it is resolved against
// the "user.dir" system property.
String absolutePath = localPath;
if (!isAbsolutePath(localPath))
{
try
{
absolutePath = getAbsolutePathFromRelativePath(localPath);
}
// user.dir not accessible from applet
catch (SecurityException se)
{
return "file:" + localPath;
}
}
String urlString;
if (null != absolutePath)
{
if (absolutePath.startsWith(File.separator))
urlString = "file://" + absolutePath;
else
urlString = "file:///" + absolutePath;
}
else
urlString = "file:" + localPath;
return replaceChars(urlString);
} |
Get an absolute URI from a given relative URI (local path).
<p>The relative URI is a local filesystem path. The path can be
absolute or relative. If it is a relative path, it is resolved relative
to the system property "user.dir" if it is available; if not (i.e. in an
Applet perhaps which throws SecurityException) then we just return the
relative path. The space and backslash characters are also replaced to
generate a good absolute URI.</p>
@param localPath The relative URI to resolve
@return Resolved absolute URI
| SystemIDResolver::getAbsoluteURIFromRelative | java | Reginer/aosp-android-jar | android-34/src/org/apache/xml/serializer/utils/SystemIDResolver.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/utils/SystemIDResolver.java | MIT |
private static String getAbsolutePathFromRelativePath(String relativePath)
{
return new File(relativePath).getAbsolutePath();
} |
Return an absolute path from a relative path.
@param relativePath A relative path
@return The absolute path
| SystemIDResolver::getAbsolutePathFromRelativePath | java | Reginer/aosp-android-jar | android-34/src/org/apache/xml/serializer/utils/SystemIDResolver.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/utils/SystemIDResolver.java | MIT |
public static boolean isAbsoluteURI(String systemId)
{
/** http://www.ietf.org/rfc/rfc2396.txt
* Authors should be aware that a path segment which contains a colon
* character cannot be used as the first segment of a relative URI path
* (e.g., "this:that"), because it would be mistaken for a scheme name.
**/
/**
* %REVIEW% Can we assume here that systemId is a valid URI?
* It looks like we cannot ( See discussion of this common problem in
* Bugzilla Bug 22777 ).
**/
//"fix" for Bugzilla Bug 22777
if(isWindowsAbsolutePath(systemId)){
return false;
}
final int fragmentIndex = systemId.indexOf('#');
final int queryIndex = systemId.indexOf('?');
final int slashIndex = systemId.indexOf('/');
final int colonIndex = systemId.indexOf(':');
//finding substring before '#', '?', and '/'
int index = systemId.length() -1;
if(fragmentIndex > 0)
index = fragmentIndex;
if((queryIndex > 0) && (queryIndex <index))
index = queryIndex;
if((slashIndex > 0) && (slashIndex <index))
index = slashIndex;
// return true if there is ':' before '#', '?', and '/'
return ((colonIndex >0) && (colonIndex<index));
} |
Return true if the systemId denotes an absolute URI .
@param systemId The systemId string
@return true if the systemId is an an absolute URI
| SystemIDResolver::isAbsoluteURI | java | Reginer/aosp-android-jar | android-34/src/org/apache/xml/serializer/utils/SystemIDResolver.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/utils/SystemIDResolver.java | MIT |
public static boolean isAbsolutePath(String systemId)
{
if(systemId == null)
return false;
final File file = new File(systemId);
return file.isAbsolute();
} |
Return true if the local path is an absolute path.
@param systemId The path string
@return true if the path is absolute
| SystemIDResolver::isAbsolutePath | java | Reginer/aosp-android-jar | android-34/src/org/apache/xml/serializer/utils/SystemIDResolver.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/utils/SystemIDResolver.java | MIT |
private static boolean isWindowsAbsolutePath(String systemId)
{
if(!isAbsolutePath(systemId))
return false;
// On Windows, an absolute path starts with "[drive_letter]:\".
if (systemId.length() > 2
&& systemId.charAt(1) == ':'
&& Character.isLetter(systemId.charAt(0))
&& (systemId.charAt(2) == '\\' || systemId.charAt(2) == '/'))
return true;
else
return false;
} |
Return true if the local path is a Windows absolute path.
@param systemId The path string
@return true if the path is a Windows absolute path
| SystemIDResolver::isWindowsAbsolutePath | java | Reginer/aosp-android-jar | android-34/src/org/apache/xml/serializer/utils/SystemIDResolver.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/utils/SystemIDResolver.java | MIT |
private static String replaceChars(String str)
{
StringBuffer buf = new StringBuffer(str);
int length = buf.length();
for (int i = 0; i < length; i++)
{
char currentChar = buf.charAt(i);
// Replace space with "%20"
if (currentChar == ' ')
{
buf.setCharAt(i, '%');
buf.insert(i+1, "20");
length = length + 2;
i = i + 2;
}
// Replace backslash with forward slash
else if (currentChar == '\\')
{
buf.setCharAt(i, '/');
}
}
return buf.toString();
} |
Replace spaces with "%20" and backslashes with forward slashes in
the input string to generate a well-formed URI string.
@param str The input string
@return The string after conversion
| SystemIDResolver::replaceChars | java | Reginer/aosp-android-jar | android-34/src/org/apache/xml/serializer/utils/SystemIDResolver.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/utils/SystemIDResolver.java | MIT |
public static String getAbsoluteURI(String systemId)
{
String absoluteURI = systemId;
if (isAbsoluteURI(systemId))
{
// Only process the systemId if it starts with "file:".
if (systemId.startsWith("file:"))
{
String str = systemId.substring(5);
// Resolve the absolute path if the systemId starts with "file:///"
// or "file:/". Don't do anything if it only starts with "file://".
if (str != null && str.startsWith("/"))
{
if (str.startsWith("///") || !str.startsWith("//"))
{
// A Windows path containing a drive letter can be relative.
// A Unix path starting with "file:/" is always absolute.
int secondColonIndex = systemId.indexOf(':', 5);
if (secondColonIndex > 0)
{
String localPath = systemId.substring(secondColonIndex-1);
try {
if (!isAbsolutePath(localPath))
absoluteURI = systemId.substring(0, secondColonIndex-1) +
getAbsolutePathFromRelativePath(localPath);
}
catch (SecurityException se) {
return systemId;
}
}
}
}
else
{
return getAbsoluteURIFromRelative(systemId.substring(5));
}
return replaceChars(absoluteURI);
}
else
return systemId;
}
else
return getAbsoluteURIFromRelative(systemId);
} |
Take a SystemID string and try to turn it into a good absolute URI.
@param systemId A URI string, which may be absolute or relative.
@return The resolved absolute URI
| SystemIDResolver::getAbsoluteURI | java | Reginer/aosp-android-jar | android-34/src/org/apache/xml/serializer/utils/SystemIDResolver.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/utils/SystemIDResolver.java | MIT |
public static String getAbsoluteURI(String urlString, String base)
throws TransformerException
{
if (base == null)
return getAbsoluteURI(urlString);
String absoluteBase = getAbsoluteURI(base);
URI uri = null;
try
{
URI baseURI = new URI(absoluteBase);
uri = new URI(baseURI, urlString);
}
catch (MalformedURIException mue)
{
throw new TransformerException(mue);
}
return replaceChars(uri.toString());
} |
Take a SystemID string and try to turn it into a good absolute URI.
@param urlString SystemID string
@param base The URI string used as the base for resolving the systemID
@return The resolved absolute URI
@throws TransformerException thrown if the string can't be turned into a URI.
| SystemIDResolver::getAbsoluteURI | java | Reginer/aosp-android-jar | android-34/src/org/apache/xml/serializer/utils/SystemIDResolver.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/utils/SystemIDResolver.java | MIT |
public static CellLocation getEmpty() {
// TelephonyManager.getDefault().getCurrentPhoneType() handles the case when
// ITelephony interface is not up yet.
switch(TelephonyManager.getDefault().getCurrentPhoneType()) {
case PhoneConstants.PHONE_TYPE_CDMA:
return new CdmaCellLocation();
case PhoneConstants.PHONE_TYPE_GSM:
return new GsmCellLocation();
default:
return null;
}
} |
Return a new CellLocation object representing an unknown
location, or null for unknown/none phone radio types.
| CellLocation::getEmpty | java | Reginer/aosp-android-jar | android-34/src/android/telephony/CellLocation.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/telephony/CellLocation.java | MIT |
public @BytesLong long getAppBytes() {
return codeBytes;
} |
Return the size of app. This includes {@code APK} files, optimized
compiler output, and unpacked native libraries.
<p>
If the primary external/shared storage is hosted on this storage device,
then this includes files stored under {@link Context#getObbDir()}.
<p>
Code is shared between all users on a multiuser device.
| StorageStats::getAppBytes | java | Reginer/aosp-android-jar | android-35/src/android/app/usage/StorageStats.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/app/usage/StorageStats.java | MIT |
public @BytesLong long getDataBytes() {
return dataBytes;
} |
Return the size of all data. This includes files stored under
{@link Context#getDataDir()}, {@link Context#getCacheDir()},
{@link Context#getCodeCacheDir()}.
<p>
If the primary external/shared storage is hosted on this storage device,
then this includes files stored under
{@link Context#getExternalFilesDir(String)},
{@link Context#getExternalCacheDir()}, and
{@link Context#getExternalMediaDirs()}.
<p>
Data is isolated for each user on a multiuser device.
| StorageStats::getDataBytes | java | Reginer/aosp-android-jar | android-35/src/android/app/usage/StorageStats.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/app/usage/StorageStats.java | MIT |
public @BytesLong long getCacheBytes() {
return cacheBytes;
} |
Return the size of all cached data. This includes files stored under
{@link Context#getCacheDir()} and {@link Context#getCodeCacheDir()}.
<p>
If the primary external/shared storage is hosted on this storage device,
then this includes files stored under
{@link Context#getExternalCacheDir()}.
<p>
Cached data is isolated for each user on a multiuser device.
| StorageStats::getCacheBytes | java | Reginer/aosp-android-jar | android-35/src/android/app/usage/StorageStats.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/app/usage/StorageStats.java | MIT |
public @BytesLong long getExternalCacheBytes() {
return externalCacheBytes;
} |
Return the size of all cached data in the primary external/shared storage.
This includes files stored under
{@link Context#getExternalCacheDir()}.
<p>
Cached data is isolated for each user on a multiuser device.
| StorageStats::getExternalCacheBytes | java | Reginer/aosp-android-jar | android-35/src/android/app/usage/StorageStats.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/app/usage/StorageStats.java | MIT |
public StorageStats() {
} |
Return the size of all cached data in the primary external/shared storage.
This includes files stored under
{@link Context#getExternalCacheDir()}.
<p>
Cached data is isolated for each user on a multiuser device.
public @BytesLong long getExternalCacheBytes() {
return externalCacheBytes;
}
/** {@hide} | StorageStats::StorageStats | java | Reginer/aosp-android-jar | android-35/src/android/app/usage/StorageStats.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/app/usage/StorageStats.java | MIT |
public StorageStats(Parcel in) {
this.codeBytes = in.readLong();
this.dataBytes = in.readLong();
this.cacheBytes = in.readLong();
this.dexoptBytes = in.readLong();
this.refProfBytes = in.readLong();
this.curProfBytes = in.readLong();
this.apkBytes = in.readLong();
this.libBytes = in.readLong();
this.dmBytes = in.readLong();
this.externalCacheBytes = in.readLong();
} |
Return the size of all cached data in the primary external/shared storage.
This includes files stored under
{@link Context#getExternalCacheDir()}.
<p>
Cached data is isolated for each user on a multiuser device.
public @BytesLong long getExternalCacheBytes() {
return externalCacheBytes;
}
/** {@hide}
public StorageStats() {
}
/** {@hide} | StorageStats::StorageStats | java | Reginer/aosp-android-jar | android-35/src/android/app/usage/StorageStats.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/app/usage/StorageStats.java | MIT |
private void onAirplaneModeChanged(boolean isAirplaneModeOn) {
Rlog.d(TAG, "Airplane mode change. Value: " + isAirplaneModeOn);
long currentTime = SystemClock.elapsedRealtime();
if (currentTime < GRACE_PERIOD_MILLIS) {
return;
}
boolean isShortToggle = calculateShortToggle(currentTime, isAirplaneModeOn);
int carrierId = getCarrierId();
Rlog.d(TAG, "Airplane mode: " + isAirplaneModeOn + ", short=" + isShortToggle
+ ", carrierId=" + carrierId);
TelephonyStatsLog.write(AIRPLANE_MODE, isAirplaneModeOn, isShortToggle, carrierId);
} | /*
Copyright (C) 2020 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
package com.android.internal.telephony.metrics;
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
import static android.telephony.TelephonyManager.UNKNOWN_CARRIER_ID;
import static com.android.internal.telephony.TelephonyStatsLog.AIRPLANE_MODE;
import android.content.Context;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.provider.Settings;
import android.telephony.SubscriptionManager;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.TelephonyStatsLog;
import com.android.telephony.Rlog;
/** Metrics for the usage of airplane mode.
public class AirplaneModeStats extends ContentObserver {
private static final String TAG = AirplaneModeStats.class.getSimpleName();
/** Ignore airplane mode events occurring in the first 30 seconds.
private static final long GRACE_PERIOD_MILLIS = 30000L;
/** An airplane mode toggle is considered short if under 10 seconds.
private static final long SHORT_TOGGLE_MILLIS = 10000L;
private long mLastActivationTime = 0L;
private final Context mContext;
private final Uri mAirplaneModeSettingUri;
public AirplaneModeStats(Context context) {
super(new Handler(Looper.getMainLooper()));
mContext = context;
mAirplaneModeSettingUri = Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON);
context.getContentResolver().registerContentObserver(mAirplaneModeSettingUri, false, this);
}
@Override
public void onChange(boolean selfChange, Uri uri) {
if (uri.equals(mAirplaneModeSettingUri)) {
onAirplaneModeChanged(isAirplaneModeOn());
}
}
private boolean isAirplaneModeOn() {
return Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
}
/** Generate metrics when airplane mode is enabled or disabled. | getSimpleName::onAirplaneModeChanged | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/metrics/AirplaneModeStats.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/metrics/AirplaneModeStats.java | MIT |
private boolean calculateShortToggle(long currentTime, boolean isAirplaneModeOn) {
boolean isShortToggle = false;
if (isAirplaneModeOn) {
// When airplane mode is enabled, track the time.
if (mLastActivationTime == 0L) {
mLastActivationTime = currentTime;
}
return false;
} else {
// When airplane mode is disabled, reset the time and check if it was a short toggle.
long duration = currentTime - mLastActivationTime;
mLastActivationTime = 0L;
return duration > 0 && duration < SHORT_TOGGLE_MILLIS;
}
} | /*
Copyright (C) 2020 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
package com.android.internal.telephony.metrics;
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
import static android.telephony.TelephonyManager.UNKNOWN_CARRIER_ID;
import static com.android.internal.telephony.TelephonyStatsLog.AIRPLANE_MODE;
import android.content.Context;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.provider.Settings;
import android.telephony.SubscriptionManager;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.TelephonyStatsLog;
import com.android.telephony.Rlog;
/** Metrics for the usage of airplane mode.
public class AirplaneModeStats extends ContentObserver {
private static final String TAG = AirplaneModeStats.class.getSimpleName();
/** Ignore airplane mode events occurring in the first 30 seconds.
private static final long GRACE_PERIOD_MILLIS = 30000L;
/** An airplane mode toggle is considered short if under 10 seconds.
private static final long SHORT_TOGGLE_MILLIS = 10000L;
private long mLastActivationTime = 0L;
private final Context mContext;
private final Uri mAirplaneModeSettingUri;
public AirplaneModeStats(Context context) {
super(new Handler(Looper.getMainLooper()));
mContext = context;
mAirplaneModeSettingUri = Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON);
context.getContentResolver().registerContentObserver(mAirplaneModeSettingUri, false, this);
}
@Override
public void onChange(boolean selfChange, Uri uri) {
if (uri.equals(mAirplaneModeSettingUri)) {
onAirplaneModeChanged(isAirplaneModeOn());
}
}
private boolean isAirplaneModeOn() {
return Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
}
/** Generate metrics when airplane mode is enabled or disabled.
private void onAirplaneModeChanged(boolean isAirplaneModeOn) {
Rlog.d(TAG, "Airplane mode change. Value: " + isAirplaneModeOn);
long currentTime = SystemClock.elapsedRealtime();
if (currentTime < GRACE_PERIOD_MILLIS) {
return;
}
boolean isShortToggle = calculateShortToggle(currentTime, isAirplaneModeOn);
int carrierId = getCarrierId();
Rlog.d(TAG, "Airplane mode: " + isAirplaneModeOn + ", short=" + isShortToggle
+ ", carrierId=" + carrierId);
TelephonyStatsLog.write(AIRPLANE_MODE, isAirplaneModeOn, isShortToggle, carrierId);
}
/* Keep tracks of time and returns if it was a short toggle. | getSimpleName::calculateShortToggle | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/metrics/AirplaneModeStats.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/metrics/AirplaneModeStats.java | MIT |
private static int getCarrierId() {
int dataSubId = SubscriptionManager.getActiveDataSubscriptionId();
int phoneId = dataSubId != INVALID_SUBSCRIPTION_ID
? SubscriptionManager.getPhoneId(dataSubId) : 0;
Phone phone = PhoneFactory.getPhone(phoneId);
return phone != null ? phone.getCarrierId() : UNKNOWN_CARRIER_ID;
} |
Returns the carrier ID of the active data subscription. If this is not available,
it returns the carrier ID of the first phone.
| getSimpleName::getCarrierId | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/telephony/metrics/AirplaneModeStats.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/telephony/metrics/AirplaneModeStats.java | MIT |
private CervicalMucusRecord(
@NonNull Metadata metadata,
@NonNull Instant time,
@NonNull ZoneOffset zoneOffset,
@CervicalMucusSensation.CervicalMucusSensations int sensation,
@CervicalMucusAppearance.CervicalMucusAppearances int appearance,
boolean skipValidation) {
super(metadata, time, zoneOffset, skipValidation);
Objects.requireNonNull(metadata);
Objects.requireNonNull(time);
Objects.requireNonNull(zoneOffset);
validateIntDefValue(
sensation,
CervicalMucusSensation.VALID_TYPES,
CervicalMucusSensation.class.getSimpleName());
validateIntDefValue(
appearance,
CervicalMucusAppearance.VALID_TYPES,
CervicalMucusAppearance.class.getSimpleName());
mSensation = sensation;
mAppearance = appearance;
} |
@param metadata Metadata to be associated with the record. See {@link Metadata}.
@param time Start time of this activity
@param zoneOffset Zone offset of the user when the activity started
@param sensation Sensation of this activity
@param appearance Appearance of this activity
@param skipValidation Boolean flag to skip validation of record values.
| CervicalMucusRecord::CervicalMucusRecord | java | Reginer/aosp-android-jar | android-34/src/android/health/connect/datatypes/CervicalMucusRecord.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/health/connect/datatypes/CervicalMucusRecord.java | MIT |
public Builder(
@NonNull Metadata metadata,
@NonNull Instant time,
@CervicalMucusSensation.CervicalMucusSensations int sensation,
@CervicalMucusAppearance.CervicalMucusAppearances int appearance) {
Objects.requireNonNull(metadata);
Objects.requireNonNull(time);
mMetadata = metadata;
mTime = time;
mSensation = sensation;
mAppearance = appearance;
mZoneOffset = ZoneOffset.systemDefault().getRules().getOffset(time);
} |
@param metadata Metadata to be associated with the record. See {@link Metadata}.
@param time Start time of this activity
@param sensation The feel of the user's cervical mucus. Optional field. Allowed values:
{@link CervicalMucusSensation}.
@param appearance The consistency of the user's cervical mucus. Optional field. Allowed
values: {@link CervicalMucusAppearance}.
| Builder::Builder | java | Reginer/aosp-android-jar | android-34/src/android/health/connect/datatypes/CervicalMucusRecord.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/health/connect/datatypes/CervicalMucusRecord.java | MIT |
default void onPreExecute() {} |
Called before this operation is to be run. An operation may be canceled before it is run,
in which case this method may not be invoked. {@link #onPostExecute(boolean)} will only
be invoked if this method was previously invoked. This callback is invoked on the
calling thread.
| onPreExecute | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/listeners/ListenerExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/listeners/ListenerExecutor.java | MIT |
default void onFailure(Exception e) {} |
Called if the operation fails while running. Will not be invoked in the event of a
unchecked exception, which will propagate normally. This callback is invoked on the
executor thread.
| onFailure | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/listeners/ListenerExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/listeners/ListenerExecutor.java | MIT |
default void onPostExecute(boolean success) {} |
Called after the operation may have been run. Will always be invoked for every operation
which has previously had {@link #onPreExecute()} invoked. Success implies that the
operation was run to completion with no failures. If {@code success} is true, this
callback will always be invoked on the executor thread. If {@code success} is false, this
callback may be invoked on the calling thread or executor thread.
| onPostExecute | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/listeners/ListenerExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/listeners/ListenerExecutor.java | MIT |
default void onComplete(boolean success) {} |
Will always be called once for every operation submitted to
{@link #executeSafely(Executor, Supplier, ListenerOperation)}, no matter if the operation
was run or not. This method is always invoked last, after every other callback. Success
implies that the operation was run to completion with no failures. If {@code success}
is true, this callback will always be invoked on the executor thread. If {@code success}
is false, this callback may be invoked on the calling thread or executor thread.
| onComplete | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/listeners/ListenerExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/listeners/ListenerExecutor.java | MIT |
default <TListener> void executeSafely(Executor executor, Supplier<TListener> listenerSupplier,
@Nullable ListenerOperation<TListener> operation) {
executeSafely(executor, listenerSupplier, operation, null);
} |
See {@link #executeSafely(Executor, Supplier, ListenerOperation, FailureCallback)}.
| executeSafely | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/listeners/ListenerExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/listeners/ListenerExecutor.java | MIT |
default <TListener, TListenerOperation extends ListenerOperation<TListener>> void executeSafely(
Executor executor, Supplier<TListener> listenerSupplier,
@Nullable TListenerOperation operation,
@Nullable FailureCallback<TListenerOperation> failureCallback) {
if (operation == null) {
return;
}
TListener listener = listenerSupplier.get();
if (listener == null) {
return;
}
boolean executing = false;
boolean preexecute = false;
try {
operation.onPreExecute();
preexecute = true;
executor.execute(() -> {
boolean success = false;
try {
if (listener == listenerSupplier.get()) {
operation.operate(listener);
success = true;
}
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
operation.onFailure(e);
if (failureCallback != null) {
failureCallback.onFailure(operation, e);
}
}
} finally {
operation.onPostExecute(success);
operation.onComplete(success);
}
});
executing = true;
} finally {
if (!executing) {
if (preexecute) {
operation.onPostExecute(false);
}
operation.onComplete(false);
}
}
} |
Executes the given listener operation on the given executor, using the provided listener
supplier. If the supplier returns a null value, or a value during the operation that does not
match the value prior to the operation, then the operation is considered canceled. If a null
operation is supplied, nothing happens. If a failure callback is supplied, this will be
invoked on the executor thread in the event a checked exception is thrown from the listener
operation.
| executeSafely | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/listeners/ListenerExecutor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/listeners/ListenerExecutor.java | MIT |
public ContentProviderClient(ContentResolver contentResolver, IContentProvider contentProvider,
String authority, boolean stable) {
mContentResolver = contentResolver;
mContentProvider = contentProvider;
mPackageName = contentResolver.mPackageName;
mAttributionSource = contentResolver.getAttributionSource();
mAuthority = authority;
mStable = stable;
mCloseGuard.open("ContentProviderClient.close");
} |
The public interface object used to interact with a specific
{@link ContentProvider}.
<p>
Instances can be obtained by calling
{@link ContentResolver#acquireContentProviderClient} or
{@link ContentResolver#acquireUnstableContentProviderClient}. Instances must
be released using {@link #close()} in order to indicate to the system that
the underlying {@link ContentProvider} is no longer needed and can be killed
to free up resources.
<p>
Note that you should generally create a new ContentProviderClient instance
for each thread that will be performing operations. Unlike
{@link ContentResolver}, the methods here such as {@link #query} and
{@link #openFile} are not thread safe -- you must not call {@link #close()}
on the ContentProviderClient those calls are made from until you are finished
with the data they have returned.
public class ContentProviderClient implements ContentInterface, AutoCloseable {
private static final String TAG = "ContentProviderClient";
@GuardedBy("ContentProviderClient.class")
private static Handler sAnrHandler;
private final ContentResolver mContentResolver;
@UnsupportedAppUsage
private final IContentProvider mContentProvider;
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
private final String mPackageName;
private final @NonNull AttributionSource mAttributionSource;
private final String mAuthority;
private final boolean mStable;
private final AtomicBoolean mClosed = new AtomicBoolean();
private final CloseGuard mCloseGuard = CloseGuard.get();
private long mAnrTimeout;
private NotRespondingRunnable mAnrRunnable;
/** {@hide}
@VisibleForTesting
public ContentProviderClient(ContentResolver contentResolver, IContentProvider contentProvider,
boolean stable) {
// Only used for testing, so use a fake authority
this(contentResolver, contentProvider, "unknown", stable);
}
/** {@hide} | ContentProviderClient::ContentProviderClient | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentProviderClient.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentProviderClient.java | MIT |
public @Nullable Cursor query(@NonNull Uri url, @Nullable String[] projection,
@Nullable String selection, @Nullable String[] selectionArgs,
@Nullable String sortOrder) throws RemoteException {
return query(url, projection, selection, selectionArgs, sortOrder, null);
} |
Configure this client to automatically detect and kill the remote
provider when an "application not responding" event is detected.
@param timeoutMillis the duration for which a pending call is allowed
block before the remote provider is considered to be
unresponsive. Set to {@code 0} to allow pending calls to block
indefinitely with no action taken.
@hide
@SystemApi
@RequiresPermission(android.Manifest.permission.REMOVE_TASKS)
public void setDetectNotResponding(@DurationMillisLong long timeoutMillis) {
synchronized (ContentProviderClient.class) {
mAnrTimeout = timeoutMillis;
if (timeoutMillis > 0) {
if (mAnrRunnable == null) {
mAnrRunnable = new NotRespondingRunnable();
}
if (sAnrHandler == null) {
sAnrHandler = new Handler(Looper.getMainLooper(), null, true /* async */);
}
// If the remote process hangs, we're going to kill it, so we're
// technically okay doing blocking calls.
Binder.allowBlocking(mContentProvider.asBinder());
} else {
mAnrRunnable = null;
// If we're no longer watching for hangs, revert back to default
// blocking behavior.
Binder.defaultBlocking(mContentProvider.asBinder());
}
}
}
private void beforeRemote() {
if (mAnrRunnable != null) {
sAnrHandler.postDelayed(mAnrRunnable, mAnrTimeout);
}
}
private void afterRemote() {
if (mAnrRunnable != null) {
sAnrHandler.removeCallbacks(mAnrRunnable);
}
}
/** See {@link ContentProvider#query ContentProvider.query} | ContentProviderClient::query | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentProviderClient.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentProviderClient.java | MIT |
public @Nullable Cursor query(@NonNull Uri uri, @Nullable String[] projection,
@Nullable String selection, @Nullable String[] selectionArgs,
@Nullable String sortOrder, @Nullable CancellationSignal cancellationSignal)
throws RemoteException {
Bundle queryArgs =
ContentResolver.createSqlQueryBundle(selection, selectionArgs, sortOrder);
return query(uri, projection, queryArgs, cancellationSignal);
} |
Configure this client to automatically detect and kill the remote
provider when an "application not responding" event is detected.
@param timeoutMillis the duration for which a pending call is allowed
block before the remote provider is considered to be
unresponsive. Set to {@code 0} to allow pending calls to block
indefinitely with no action taken.
@hide
@SystemApi
@RequiresPermission(android.Manifest.permission.REMOVE_TASKS)
public void setDetectNotResponding(@DurationMillisLong long timeoutMillis) {
synchronized (ContentProviderClient.class) {
mAnrTimeout = timeoutMillis;
if (timeoutMillis > 0) {
if (mAnrRunnable == null) {
mAnrRunnable = new NotRespondingRunnable();
}
if (sAnrHandler == null) {
sAnrHandler = new Handler(Looper.getMainLooper(), null, true /* async */);
}
// If the remote process hangs, we're going to kill it, so we're
// technically okay doing blocking calls.
Binder.allowBlocking(mContentProvider.asBinder());
} else {
mAnrRunnable = null;
// If we're no longer watching for hangs, revert back to default
// blocking behavior.
Binder.defaultBlocking(mContentProvider.asBinder());
}
}
}
private void beforeRemote() {
if (mAnrRunnable != null) {
sAnrHandler.postDelayed(mAnrRunnable, mAnrTimeout);
}
}
private void afterRemote() {
if (mAnrRunnable != null) {
sAnrHandler.removeCallbacks(mAnrRunnable);
}
}
/** See {@link ContentProvider#query ContentProvider.query}
public @Nullable Cursor query(@NonNull Uri url, @Nullable String[] projection,
@Nullable String selection, @Nullable String[] selectionArgs,
@Nullable String sortOrder) throws RemoteException {
return query(url, projection, selection, selectionArgs, sortOrder, null);
}
/** See {@link ContentProvider#query ContentProvider.query} | ContentProviderClient::query | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentProviderClient.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentProviderClient.java | MIT |
public @Nullable Uri insert(@NonNull Uri url, @Nullable ContentValues initialValues)
throws RemoteException {
return insert(url, initialValues, null);
} |
Configure this client to automatically detect and kill the remote
provider when an "application not responding" event is detected.
@param timeoutMillis the duration for which a pending call is allowed
block before the remote provider is considered to be
unresponsive. Set to {@code 0} to allow pending calls to block
indefinitely with no action taken.
@hide
@SystemApi
@RequiresPermission(android.Manifest.permission.REMOVE_TASKS)
public void setDetectNotResponding(@DurationMillisLong long timeoutMillis) {
synchronized (ContentProviderClient.class) {
mAnrTimeout = timeoutMillis;
if (timeoutMillis > 0) {
if (mAnrRunnable == null) {
mAnrRunnable = new NotRespondingRunnable();
}
if (sAnrHandler == null) {
sAnrHandler = new Handler(Looper.getMainLooper(), null, true /* async */);
}
// If the remote process hangs, we're going to kill it, so we're
// technically okay doing blocking calls.
Binder.allowBlocking(mContentProvider.asBinder());
} else {
mAnrRunnable = null;
// If we're no longer watching for hangs, revert back to default
// blocking behavior.
Binder.defaultBlocking(mContentProvider.asBinder());
}
}
}
private void beforeRemote() {
if (mAnrRunnable != null) {
sAnrHandler.postDelayed(mAnrRunnable, mAnrTimeout);
}
}
private void afterRemote() {
if (mAnrRunnable != null) {
sAnrHandler.removeCallbacks(mAnrRunnable);
}
}
/** See {@link ContentProvider#query ContentProvider.query}
public @Nullable Cursor query(@NonNull Uri url, @Nullable String[] projection,
@Nullable String selection, @Nullable String[] selectionArgs,
@Nullable String sortOrder) throws RemoteException {
return query(url, projection, selection, selectionArgs, sortOrder, null);
}
/** See {@link ContentProvider#query ContentProvider.query}
public @Nullable Cursor query(@NonNull Uri uri, @Nullable String[] projection,
@Nullable String selection, @Nullable String[] selectionArgs,
@Nullable String sortOrder, @Nullable CancellationSignal cancellationSignal)
throws RemoteException {
Bundle queryArgs =
ContentResolver.createSqlQueryBundle(selection, selectionArgs, sortOrder);
return query(uri, projection, queryArgs, cancellationSignal);
}
/** See {@link ContentProvider#query ContentProvider.query}
@Override
public @Nullable Cursor query(@NonNull Uri uri, @Nullable String[] projection,
Bundle queryArgs, @Nullable CancellationSignal cancellationSignal)
throws RemoteException {
Objects.requireNonNull(uri, "url");
beforeRemote();
try {
ICancellationSignal remoteCancellationSignal = null;
if (cancellationSignal != null) {
cancellationSignal.throwIfCanceled();
remoteCancellationSignal = mContentProvider.createCancellationSignal();
cancellationSignal.setRemote(remoteCancellationSignal);
}
final Cursor cursor = mContentProvider.query(
mAttributionSource, uri, projection, queryArgs,
remoteCancellationSignal);
if (cursor == null) {
return null;
}
return new CursorWrapperInner(cursor);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#getType ContentProvider.getType}
@Override
public @Nullable String getType(@NonNull Uri url) throws RemoteException {
Objects.requireNonNull(url, "url");
beforeRemote();
try {
return mContentProvider.getType(mAttributionSource, url);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#getStreamTypes ContentProvider.getStreamTypes}
@Override
public @Nullable String[] getStreamTypes(@NonNull Uri url, @NonNull String mimeTypeFilter)
throws RemoteException {
Objects.requireNonNull(url, "url");
Objects.requireNonNull(mimeTypeFilter, "mimeTypeFilter");
beforeRemote();
try {
return mContentProvider.getStreamTypes(mAttributionSource, url, mimeTypeFilter);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#canonicalize}
@Override
public final @Nullable Uri canonicalize(@NonNull Uri url) throws RemoteException {
Objects.requireNonNull(url, "url");
beforeRemote();
try {
return mContentProvider.canonicalize(mAttributionSource, url);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#uncanonicalize}
@Override
public final @Nullable Uri uncanonicalize(@NonNull Uri url) throws RemoteException {
Objects.requireNonNull(url, "url");
beforeRemote();
try {
return mContentProvider.uncanonicalize(mAttributionSource, url);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#refresh}
@Override
public boolean refresh(Uri url, @Nullable Bundle extras,
@Nullable CancellationSignal cancellationSignal) throws RemoteException {
Objects.requireNonNull(url, "url");
beforeRemote();
try {
ICancellationSignal remoteCancellationSignal = null;
if (cancellationSignal != null) {
cancellationSignal.throwIfCanceled();
remoteCancellationSignal = mContentProvider.createCancellationSignal();
cancellationSignal.setRemote(remoteCancellationSignal);
}
return mContentProvider.refresh(mAttributionSource, url, extras,
remoteCancellationSignal);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** {@hide}
@Override
public int checkUriPermission(@NonNull Uri uri, int uid, @Intent.AccessUriMode int modeFlags)
throws RemoteException {
Objects.requireNonNull(uri, "uri");
beforeRemote();
try {
return mContentProvider.checkUriPermission(mAttributionSource, uri, uid,
modeFlags);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#insert ContentProvider.insert} | ContentProviderClient::insert | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentProviderClient.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentProviderClient.java | MIT |
public int delete(@NonNull Uri url, @Nullable String selection,
@Nullable String[] selectionArgs) throws RemoteException {
return delete(url, ContentResolver.createSqlQueryBundle(selection, selectionArgs));
} |
Configure this client to automatically detect and kill the remote
provider when an "application not responding" event is detected.
@param timeoutMillis the duration for which a pending call is allowed
block before the remote provider is considered to be
unresponsive. Set to {@code 0} to allow pending calls to block
indefinitely with no action taken.
@hide
@SystemApi
@RequiresPermission(android.Manifest.permission.REMOVE_TASKS)
public void setDetectNotResponding(@DurationMillisLong long timeoutMillis) {
synchronized (ContentProviderClient.class) {
mAnrTimeout = timeoutMillis;
if (timeoutMillis > 0) {
if (mAnrRunnable == null) {
mAnrRunnable = new NotRespondingRunnable();
}
if (sAnrHandler == null) {
sAnrHandler = new Handler(Looper.getMainLooper(), null, true /* async */);
}
// If the remote process hangs, we're going to kill it, so we're
// technically okay doing blocking calls.
Binder.allowBlocking(mContentProvider.asBinder());
} else {
mAnrRunnable = null;
// If we're no longer watching for hangs, revert back to default
// blocking behavior.
Binder.defaultBlocking(mContentProvider.asBinder());
}
}
}
private void beforeRemote() {
if (mAnrRunnable != null) {
sAnrHandler.postDelayed(mAnrRunnable, mAnrTimeout);
}
}
private void afterRemote() {
if (mAnrRunnable != null) {
sAnrHandler.removeCallbacks(mAnrRunnable);
}
}
/** See {@link ContentProvider#query ContentProvider.query}
public @Nullable Cursor query(@NonNull Uri url, @Nullable String[] projection,
@Nullable String selection, @Nullable String[] selectionArgs,
@Nullable String sortOrder) throws RemoteException {
return query(url, projection, selection, selectionArgs, sortOrder, null);
}
/** See {@link ContentProvider#query ContentProvider.query}
public @Nullable Cursor query(@NonNull Uri uri, @Nullable String[] projection,
@Nullable String selection, @Nullable String[] selectionArgs,
@Nullable String sortOrder, @Nullable CancellationSignal cancellationSignal)
throws RemoteException {
Bundle queryArgs =
ContentResolver.createSqlQueryBundle(selection, selectionArgs, sortOrder);
return query(uri, projection, queryArgs, cancellationSignal);
}
/** See {@link ContentProvider#query ContentProvider.query}
@Override
public @Nullable Cursor query(@NonNull Uri uri, @Nullable String[] projection,
Bundle queryArgs, @Nullable CancellationSignal cancellationSignal)
throws RemoteException {
Objects.requireNonNull(uri, "url");
beforeRemote();
try {
ICancellationSignal remoteCancellationSignal = null;
if (cancellationSignal != null) {
cancellationSignal.throwIfCanceled();
remoteCancellationSignal = mContentProvider.createCancellationSignal();
cancellationSignal.setRemote(remoteCancellationSignal);
}
final Cursor cursor = mContentProvider.query(
mAttributionSource, uri, projection, queryArgs,
remoteCancellationSignal);
if (cursor == null) {
return null;
}
return new CursorWrapperInner(cursor);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#getType ContentProvider.getType}
@Override
public @Nullable String getType(@NonNull Uri url) throws RemoteException {
Objects.requireNonNull(url, "url");
beforeRemote();
try {
return mContentProvider.getType(mAttributionSource, url);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#getStreamTypes ContentProvider.getStreamTypes}
@Override
public @Nullable String[] getStreamTypes(@NonNull Uri url, @NonNull String mimeTypeFilter)
throws RemoteException {
Objects.requireNonNull(url, "url");
Objects.requireNonNull(mimeTypeFilter, "mimeTypeFilter");
beforeRemote();
try {
return mContentProvider.getStreamTypes(mAttributionSource, url, mimeTypeFilter);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#canonicalize}
@Override
public final @Nullable Uri canonicalize(@NonNull Uri url) throws RemoteException {
Objects.requireNonNull(url, "url");
beforeRemote();
try {
return mContentProvider.canonicalize(mAttributionSource, url);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#uncanonicalize}
@Override
public final @Nullable Uri uncanonicalize(@NonNull Uri url) throws RemoteException {
Objects.requireNonNull(url, "url");
beforeRemote();
try {
return mContentProvider.uncanonicalize(mAttributionSource, url);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#refresh}
@Override
public boolean refresh(Uri url, @Nullable Bundle extras,
@Nullable CancellationSignal cancellationSignal) throws RemoteException {
Objects.requireNonNull(url, "url");
beforeRemote();
try {
ICancellationSignal remoteCancellationSignal = null;
if (cancellationSignal != null) {
cancellationSignal.throwIfCanceled();
remoteCancellationSignal = mContentProvider.createCancellationSignal();
cancellationSignal.setRemote(remoteCancellationSignal);
}
return mContentProvider.refresh(mAttributionSource, url, extras,
remoteCancellationSignal);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** {@hide}
@Override
public int checkUriPermission(@NonNull Uri uri, int uid, @Intent.AccessUriMode int modeFlags)
throws RemoteException {
Objects.requireNonNull(uri, "uri");
beforeRemote();
try {
return mContentProvider.checkUriPermission(mAttributionSource, uri, uid,
modeFlags);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#insert ContentProvider.insert}
public @Nullable Uri insert(@NonNull Uri url, @Nullable ContentValues initialValues)
throws RemoteException {
return insert(url, initialValues, null);
}
/** See {@link ContentProvider#insert ContentProvider.insert}
@Override
public @Nullable Uri insert(@NonNull Uri url, @Nullable ContentValues initialValues,
@Nullable Bundle extras) throws RemoteException {
Objects.requireNonNull(url, "url");
beforeRemote();
try {
return mContentProvider.insert(mAttributionSource, url, initialValues,
extras);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#bulkInsert ContentProvider.bulkInsert}
@Override
public int bulkInsert(@NonNull Uri url, @NonNull ContentValues[] initialValues)
throws RemoteException {
Objects.requireNonNull(url, "url");
Objects.requireNonNull(initialValues, "initialValues");
beforeRemote();
try {
return mContentProvider.bulkInsert(mAttributionSource, url, initialValues);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#delete ContentProvider.delete} | ContentProviderClient::delete | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentProviderClient.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentProviderClient.java | MIT |
public int update(@NonNull Uri url, @Nullable ContentValues values, @Nullable String selection,
@Nullable String[] selectionArgs) throws RemoteException {
return update(url, values, ContentResolver.createSqlQueryBundle(selection, selectionArgs));
} |
Configure this client to automatically detect and kill the remote
provider when an "application not responding" event is detected.
@param timeoutMillis the duration for which a pending call is allowed
block before the remote provider is considered to be
unresponsive. Set to {@code 0} to allow pending calls to block
indefinitely with no action taken.
@hide
@SystemApi
@RequiresPermission(android.Manifest.permission.REMOVE_TASKS)
public void setDetectNotResponding(@DurationMillisLong long timeoutMillis) {
synchronized (ContentProviderClient.class) {
mAnrTimeout = timeoutMillis;
if (timeoutMillis > 0) {
if (mAnrRunnable == null) {
mAnrRunnable = new NotRespondingRunnable();
}
if (sAnrHandler == null) {
sAnrHandler = new Handler(Looper.getMainLooper(), null, true /* async */);
}
// If the remote process hangs, we're going to kill it, so we're
// technically okay doing blocking calls.
Binder.allowBlocking(mContentProvider.asBinder());
} else {
mAnrRunnable = null;
// If we're no longer watching for hangs, revert back to default
// blocking behavior.
Binder.defaultBlocking(mContentProvider.asBinder());
}
}
}
private void beforeRemote() {
if (mAnrRunnable != null) {
sAnrHandler.postDelayed(mAnrRunnable, mAnrTimeout);
}
}
private void afterRemote() {
if (mAnrRunnable != null) {
sAnrHandler.removeCallbacks(mAnrRunnable);
}
}
/** See {@link ContentProvider#query ContentProvider.query}
public @Nullable Cursor query(@NonNull Uri url, @Nullable String[] projection,
@Nullable String selection, @Nullable String[] selectionArgs,
@Nullable String sortOrder) throws RemoteException {
return query(url, projection, selection, selectionArgs, sortOrder, null);
}
/** See {@link ContentProvider#query ContentProvider.query}
public @Nullable Cursor query(@NonNull Uri uri, @Nullable String[] projection,
@Nullable String selection, @Nullable String[] selectionArgs,
@Nullable String sortOrder, @Nullable CancellationSignal cancellationSignal)
throws RemoteException {
Bundle queryArgs =
ContentResolver.createSqlQueryBundle(selection, selectionArgs, sortOrder);
return query(uri, projection, queryArgs, cancellationSignal);
}
/** See {@link ContentProvider#query ContentProvider.query}
@Override
public @Nullable Cursor query(@NonNull Uri uri, @Nullable String[] projection,
Bundle queryArgs, @Nullable CancellationSignal cancellationSignal)
throws RemoteException {
Objects.requireNonNull(uri, "url");
beforeRemote();
try {
ICancellationSignal remoteCancellationSignal = null;
if (cancellationSignal != null) {
cancellationSignal.throwIfCanceled();
remoteCancellationSignal = mContentProvider.createCancellationSignal();
cancellationSignal.setRemote(remoteCancellationSignal);
}
final Cursor cursor = mContentProvider.query(
mAttributionSource, uri, projection, queryArgs,
remoteCancellationSignal);
if (cursor == null) {
return null;
}
return new CursorWrapperInner(cursor);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#getType ContentProvider.getType}
@Override
public @Nullable String getType(@NonNull Uri url) throws RemoteException {
Objects.requireNonNull(url, "url");
beforeRemote();
try {
return mContentProvider.getType(mAttributionSource, url);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#getStreamTypes ContentProvider.getStreamTypes}
@Override
public @Nullable String[] getStreamTypes(@NonNull Uri url, @NonNull String mimeTypeFilter)
throws RemoteException {
Objects.requireNonNull(url, "url");
Objects.requireNonNull(mimeTypeFilter, "mimeTypeFilter");
beforeRemote();
try {
return mContentProvider.getStreamTypes(mAttributionSource, url, mimeTypeFilter);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#canonicalize}
@Override
public final @Nullable Uri canonicalize(@NonNull Uri url) throws RemoteException {
Objects.requireNonNull(url, "url");
beforeRemote();
try {
return mContentProvider.canonicalize(mAttributionSource, url);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#uncanonicalize}
@Override
public final @Nullable Uri uncanonicalize(@NonNull Uri url) throws RemoteException {
Objects.requireNonNull(url, "url");
beforeRemote();
try {
return mContentProvider.uncanonicalize(mAttributionSource, url);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#refresh}
@Override
public boolean refresh(Uri url, @Nullable Bundle extras,
@Nullable CancellationSignal cancellationSignal) throws RemoteException {
Objects.requireNonNull(url, "url");
beforeRemote();
try {
ICancellationSignal remoteCancellationSignal = null;
if (cancellationSignal != null) {
cancellationSignal.throwIfCanceled();
remoteCancellationSignal = mContentProvider.createCancellationSignal();
cancellationSignal.setRemote(remoteCancellationSignal);
}
return mContentProvider.refresh(mAttributionSource, url, extras,
remoteCancellationSignal);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** {@hide}
@Override
public int checkUriPermission(@NonNull Uri uri, int uid, @Intent.AccessUriMode int modeFlags)
throws RemoteException {
Objects.requireNonNull(uri, "uri");
beforeRemote();
try {
return mContentProvider.checkUriPermission(mAttributionSource, uri, uid,
modeFlags);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#insert ContentProvider.insert}
public @Nullable Uri insert(@NonNull Uri url, @Nullable ContentValues initialValues)
throws RemoteException {
return insert(url, initialValues, null);
}
/** See {@link ContentProvider#insert ContentProvider.insert}
@Override
public @Nullable Uri insert(@NonNull Uri url, @Nullable ContentValues initialValues,
@Nullable Bundle extras) throws RemoteException {
Objects.requireNonNull(url, "url");
beforeRemote();
try {
return mContentProvider.insert(mAttributionSource, url, initialValues,
extras);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#bulkInsert ContentProvider.bulkInsert}
@Override
public int bulkInsert(@NonNull Uri url, @NonNull ContentValues[] initialValues)
throws RemoteException {
Objects.requireNonNull(url, "url");
Objects.requireNonNull(initialValues, "initialValues");
beforeRemote();
try {
return mContentProvider.bulkInsert(mAttributionSource, url, initialValues);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#delete ContentProvider.delete}
public int delete(@NonNull Uri url, @Nullable String selection,
@Nullable String[] selectionArgs) throws RemoteException {
return delete(url, ContentResolver.createSqlQueryBundle(selection, selectionArgs));
}
/** See {@link ContentProvider#delete ContentProvider.delete}
@Override
public int delete(@NonNull Uri url, @Nullable Bundle extras) throws RemoteException {
Objects.requireNonNull(url, "url");
beforeRemote();
try {
return mContentProvider.delete(mAttributionSource, url, extras);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#update ContentProvider.update} | ContentProviderClient::update | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentProviderClient.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentProviderClient.java | MIT |
public @Nullable ParcelFileDescriptor openFile(@NonNull Uri url, @NonNull String mode)
throws RemoteException, FileNotFoundException {
return openFile(url, mode, null);
} |
See {@link ContentProvider#openFile ContentProvider.openFile}. Note that
this <em>does not</em>
take care of non-content: URIs such as file:. It is strongly recommended
you use the {@link ContentResolver#openFileDescriptor
ContentResolver.openFileDescriptor} API instead.
| ContentProviderClient::openFile | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentProviderClient.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentProviderClient.java | MIT |
public @Nullable AssetFileDescriptor openAssetFile(@NonNull Uri url, @NonNull String mode)
throws RemoteException, FileNotFoundException {
return openAssetFile(url, mode, null);
} |
See {@link ContentProvider#openAssetFile ContentProvider.openAssetFile}.
Note that this <em>does not</em>
take care of non-content: URIs such as file:. It is strongly recommended
you use the {@link ContentResolver#openAssetFileDescriptor
ContentResolver.openAssetFileDescriptor} API instead.
| ContentProviderClient::openAssetFile | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentProviderClient.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentProviderClient.java | MIT |
public final @Nullable AssetFileDescriptor openTypedAssetFileDescriptor(@NonNull Uri uri,
@NonNull String mimeType, @Nullable Bundle opts)
throws RemoteException, FileNotFoundException {
return openTypedAssetFileDescriptor(uri, mimeType, opts, null);
} |
See {@link ContentProvider#openAssetFile ContentProvider.openAssetFile}.
Note that this <em>does not</em>
take care of non-content: URIs such as file:. It is strongly recommended
you use the {@link ContentResolver#openAssetFileDescriptor
ContentResolver.openAssetFileDescriptor} API instead.
@Override
public @Nullable AssetFileDescriptor openAssetFile(@NonNull Uri url, @NonNull String mode,
@Nullable CancellationSignal signal) throws RemoteException, FileNotFoundException {
Objects.requireNonNull(url, "url");
Objects.requireNonNull(mode, "mode");
beforeRemote();
try {
ICancellationSignal remoteSignal = null;
if (signal != null) {
signal.throwIfCanceled();
remoteSignal = mContentProvider.createCancellationSignal();
signal.setRemote(remoteSignal);
}
return mContentProvider.openAssetFile(mAttributionSource, url, mode,
remoteSignal);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#openTypedAssetFile ContentProvider.openTypedAssetFile} | ContentProviderClient::openTypedAssetFileDescriptor | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentProviderClient.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentProviderClient.java | MIT |
public final @Nullable AssetFileDescriptor openTypedAssetFileDescriptor(@NonNull Uri uri,
@NonNull String mimeType, @Nullable Bundle opts, @Nullable CancellationSignal signal)
throws RemoteException, FileNotFoundException {
return openTypedAssetFile(uri, mimeType, opts, signal);
} |
See {@link ContentProvider#openAssetFile ContentProvider.openAssetFile}.
Note that this <em>does not</em>
take care of non-content: URIs such as file:. It is strongly recommended
you use the {@link ContentResolver#openAssetFileDescriptor
ContentResolver.openAssetFileDescriptor} API instead.
@Override
public @Nullable AssetFileDescriptor openAssetFile(@NonNull Uri url, @NonNull String mode,
@Nullable CancellationSignal signal) throws RemoteException, FileNotFoundException {
Objects.requireNonNull(url, "url");
Objects.requireNonNull(mode, "mode");
beforeRemote();
try {
ICancellationSignal remoteSignal = null;
if (signal != null) {
signal.throwIfCanceled();
remoteSignal = mContentProvider.createCancellationSignal();
signal.setRemote(remoteSignal);
}
return mContentProvider.openAssetFile(mAttributionSource, url, mode,
remoteSignal);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#openTypedAssetFile ContentProvider.openTypedAssetFile}
public final @Nullable AssetFileDescriptor openTypedAssetFileDescriptor(@NonNull Uri uri,
@NonNull String mimeType, @Nullable Bundle opts)
throws RemoteException, FileNotFoundException {
return openTypedAssetFileDescriptor(uri, mimeType, opts, null);
}
/** See {@link ContentProvider#openTypedAssetFile ContentProvider.openTypedAssetFile} | ContentProviderClient::openTypedAssetFileDescriptor | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentProviderClient.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentProviderClient.java | MIT |
public @NonNull ContentProviderResult[] applyBatch(
@NonNull ArrayList<ContentProviderOperation> operations)
throws RemoteException, OperationApplicationException {
return applyBatch(mAuthority, operations);
} |
See {@link ContentProvider#openAssetFile ContentProvider.openAssetFile}.
Note that this <em>does not</em>
take care of non-content: URIs such as file:. It is strongly recommended
you use the {@link ContentResolver#openAssetFileDescriptor
ContentResolver.openAssetFileDescriptor} API instead.
@Override
public @Nullable AssetFileDescriptor openAssetFile(@NonNull Uri url, @NonNull String mode,
@Nullable CancellationSignal signal) throws RemoteException, FileNotFoundException {
Objects.requireNonNull(url, "url");
Objects.requireNonNull(mode, "mode");
beforeRemote();
try {
ICancellationSignal remoteSignal = null;
if (signal != null) {
signal.throwIfCanceled();
remoteSignal = mContentProvider.createCancellationSignal();
signal.setRemote(remoteSignal);
}
return mContentProvider.openAssetFile(mAttributionSource, url, mode,
remoteSignal);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#openTypedAssetFile ContentProvider.openTypedAssetFile}
public final @Nullable AssetFileDescriptor openTypedAssetFileDescriptor(@NonNull Uri uri,
@NonNull String mimeType, @Nullable Bundle opts)
throws RemoteException, FileNotFoundException {
return openTypedAssetFileDescriptor(uri, mimeType, opts, null);
}
/** See {@link ContentProvider#openTypedAssetFile ContentProvider.openTypedAssetFile}
public final @Nullable AssetFileDescriptor openTypedAssetFileDescriptor(@NonNull Uri uri,
@NonNull String mimeType, @Nullable Bundle opts, @Nullable CancellationSignal signal)
throws RemoteException, FileNotFoundException {
return openTypedAssetFile(uri, mimeType, opts, signal);
}
@Override
public final @Nullable AssetFileDescriptor openTypedAssetFile(@NonNull Uri uri,
@NonNull String mimeTypeFilter, @Nullable Bundle opts,
@Nullable CancellationSignal signal) throws RemoteException, FileNotFoundException {
Objects.requireNonNull(uri, "uri");
Objects.requireNonNull(mimeTypeFilter, "mimeTypeFilter");
beforeRemote();
try {
ICancellationSignal remoteSignal = null;
if (signal != null) {
signal.throwIfCanceled();
remoteSignal = mContentProvider.createCancellationSignal();
signal.setRemote(remoteSignal);
}
return mContentProvider.openTypedAssetFile(
mAttributionSource, uri, mimeTypeFilter, opts, remoteSignal);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#applyBatch ContentProvider.applyBatch} | ContentProviderClient::applyBatch | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentProviderClient.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentProviderClient.java | MIT |
public @Nullable Bundle call(@NonNull String method, @Nullable String arg,
@Nullable Bundle extras) throws RemoteException {
return call(mAuthority, method, arg, extras);
} |
See {@link ContentProvider#openAssetFile ContentProvider.openAssetFile}.
Note that this <em>does not</em>
take care of non-content: URIs such as file:. It is strongly recommended
you use the {@link ContentResolver#openAssetFileDescriptor
ContentResolver.openAssetFileDescriptor} API instead.
@Override
public @Nullable AssetFileDescriptor openAssetFile(@NonNull Uri url, @NonNull String mode,
@Nullable CancellationSignal signal) throws RemoteException, FileNotFoundException {
Objects.requireNonNull(url, "url");
Objects.requireNonNull(mode, "mode");
beforeRemote();
try {
ICancellationSignal remoteSignal = null;
if (signal != null) {
signal.throwIfCanceled();
remoteSignal = mContentProvider.createCancellationSignal();
signal.setRemote(remoteSignal);
}
return mContentProvider.openAssetFile(mAttributionSource, url, mode,
remoteSignal);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#openTypedAssetFile ContentProvider.openTypedAssetFile}
public final @Nullable AssetFileDescriptor openTypedAssetFileDescriptor(@NonNull Uri uri,
@NonNull String mimeType, @Nullable Bundle opts)
throws RemoteException, FileNotFoundException {
return openTypedAssetFileDescriptor(uri, mimeType, opts, null);
}
/** See {@link ContentProvider#openTypedAssetFile ContentProvider.openTypedAssetFile}
public final @Nullable AssetFileDescriptor openTypedAssetFileDescriptor(@NonNull Uri uri,
@NonNull String mimeType, @Nullable Bundle opts, @Nullable CancellationSignal signal)
throws RemoteException, FileNotFoundException {
return openTypedAssetFile(uri, mimeType, opts, signal);
}
@Override
public final @Nullable AssetFileDescriptor openTypedAssetFile(@NonNull Uri uri,
@NonNull String mimeTypeFilter, @Nullable Bundle opts,
@Nullable CancellationSignal signal) throws RemoteException, FileNotFoundException {
Objects.requireNonNull(uri, "uri");
Objects.requireNonNull(mimeTypeFilter, "mimeTypeFilter");
beforeRemote();
try {
ICancellationSignal remoteSignal = null;
if (signal != null) {
signal.throwIfCanceled();
remoteSignal = mContentProvider.createCancellationSignal();
signal.setRemote(remoteSignal);
}
return mContentProvider.openTypedAssetFile(
mAttributionSource, uri, mimeTypeFilter, opts, remoteSignal);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#applyBatch ContentProvider.applyBatch}
public @NonNull ContentProviderResult[] applyBatch(
@NonNull ArrayList<ContentProviderOperation> operations)
throws RemoteException, OperationApplicationException {
return applyBatch(mAuthority, operations);
}
/** See {@link ContentProvider#applyBatch ContentProvider.applyBatch}
@Override
public @NonNull ContentProviderResult[] applyBatch(@NonNull String authority,
@NonNull ArrayList<ContentProviderOperation> operations)
throws RemoteException, OperationApplicationException {
Objects.requireNonNull(operations, "operations");
beforeRemote();
try {
return mContentProvider.applyBatch(mAttributionSource, authority,
operations);
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
}
throw e;
} finally {
afterRemote();
}
}
/** See {@link ContentProvider#call(String, String, Bundle)} | ContentProviderClient::call | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentProviderClient.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentProviderClient.java | MIT |
public @Nullable ContentProvider getLocalContentProvider() {
return ContentProvider.coerceToLocalContentProvider(mContentProvider);
} |
Get a reference to the {@link ContentProvider} that is associated with this
client. If the {@link ContentProvider} is running in a different process then
null will be returned. This can be used if you know you are running in the same
process as a provider, and want to get direct access to its implementation details.
@return If the associated {@link ContentProvider} is local, returns it.
Otherwise returns null.
| ContentProviderClient::getLocalContentProvider | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentProviderClient.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentProviderClient.java | MIT |
public RSAPublicKeySpec(BigInteger modulus, BigInteger publicExponent) {
this.modulus = modulus;
this.publicExponent = publicExponent;
} |
Creates a new RSAPublicKeySpec.
@param modulus the modulus
@param publicExponent the public exponent
| RSAPublicKeySpec::RSAPublicKeySpec | java | Reginer/aosp-android-jar | android-33/src/java/security/spec/RSAPublicKeySpec.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/java/security/spec/RSAPublicKeySpec.java | MIT |
public BigInteger getModulus() {
return this.modulus;
} |
Returns the modulus.
@return the modulus
| RSAPublicKeySpec::getModulus | java | Reginer/aosp-android-jar | android-33/src/java/security/spec/RSAPublicKeySpec.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/java/security/spec/RSAPublicKeySpec.java | MIT |
public BigInteger getPublicExponent() {
return this.publicExponent;
} |
Returns the public exponent.
@return the public exponent
| RSAPublicKeySpec::getPublicExponent | java | Reginer/aosp-android-jar | android-33/src/java/security/spec/RSAPublicKeySpec.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/java/security/spec/RSAPublicKeySpec.java | MIT |
public TestOnlyInsecureCertificateHelper() {
} |
Constructor for the helper class.
| TestOnlyInsecureCertificateHelper::TestOnlyInsecureCertificateHelper | java | Reginer/aosp-android-jar | android-35/src/com/android/server/locksettings/recoverablekeystore/TestOnlyInsecureCertificateHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/locksettings/recoverablekeystore/TestOnlyInsecureCertificateHelper.java | MIT |
public @Nullable Date getValidationDate(String rootCertificateAlias) {
if (isTestOnlyCertificateAlias(rootCertificateAlias)) {
// Certificate used for e2e test is expired.
return new Date(2019 - 1900, 1, 30);
} else {
return null; // Use current time
}
} |
Returns hardcoded validation date for e2e tests.
| TestOnlyInsecureCertificateHelper::getValidationDate | java | Reginer/aosp-android-jar | android-35/src/com/android/server/locksettings/recoverablekeystore/TestOnlyInsecureCertificateHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/locksettings/recoverablekeystore/TestOnlyInsecureCertificateHelper.java | MIT |
public boolean doesCredentialSupportInsecureMode(int credentialType, byte[] credential) {
if (credential == null) {
return false;
}
if (credentialType != LockPatternUtils.CREDENTIAL_TYPE_PASSWORD
&& credentialType != LockPatternUtils.CREDENTIAL_TYPE_PIN) {
return false;
}
byte[] insecurePasswordPrefixBytes =
TrustedRootCertificates.INSECURE_PASSWORD_PREFIX.getBytes();
if (credential.length < insecurePasswordPrefixBytes.length) {
return false;
}
for (int i = 0; i < insecurePasswordPrefixBytes.length; i++) {
if (credential[i] != insecurePasswordPrefixBytes[i]) {
return false;
}
}
return true;
} |
Checks whether a password is in "Insecure mode"
@param credentialType the type of credential, e.g. pattern and password
@param credential the pattern or password
@return true, if the credential is in "Insecure mode"
| TestOnlyInsecureCertificateHelper::doesCredentialSupportInsecureMode | java | Reginer/aosp-android-jar | android-35/src/com/android/server/locksettings/recoverablekeystore/TestOnlyInsecureCertificateHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/locksettings/recoverablekeystore/TestOnlyInsecureCertificateHelper.java | MIT |
public void copyConnectionFrom(Call other) {
mConnections = other.getConnections();
} |
Get mConnections field from another Call instance.
@param other
| SrvccState::copyConnectionFrom | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/Call.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/Call.java | MIT |
public int getConnectionsCount() {
synchronized (mLock) {
return mConnections.size();
}
} |
Get connections count of this instance.
@return the count to return
| SrvccState::getConnectionsCount | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/Call.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/Call.java | MIT |
public String getConnectionSummary() {
synchronized (mLock) {
return mConnections.stream()
.map(c -> c.getTelecomCallId() + "/objId:" + System.identityHashCode(c))
.collect(Collectors.joining(", "));
}
} |
@return returns a summary of the connections held in this call.
| SrvccState::getConnectionSummary | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/Call.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/Call.java | MIT |
public boolean hasConnection(Connection c) {
return c.getCall() == this;
} |
hasConnection
@param c a Connection object
@return true if the call contains the connection object passed in
| SrvccState::hasConnection | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/Call.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/Call.java | MIT |
public boolean hasConnections() {
List<Connection> connections = getConnections();
if (connections == null) {
return false;
}
return connections.size() > 0;
} |
hasConnections
@return true if the call contains one or more connections
| SrvccState::hasConnections | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/Call.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/Call.java | MIT |
public void removeConnection(Connection conn) {
synchronized (mLock) {
mConnections.remove(conn);
}
} |
removeConnection
@param conn the connection to be removed
| SrvccState::removeConnection | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/Call.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/Call.java | MIT |
public void addConnection(Connection conn) {
synchronized (mLock) {
mConnections.add(conn);
}
} |
addConnection
@param conn the connection to be added
| SrvccState::addConnection | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/Call.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/Call.java | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.