code
stringlengths 11
173k
| docstring
stringlengths 2
593k
| func_name
stringlengths 2
189
| language
stringclasses 1
value | repo
stringclasses 833
values | path
stringlengths 11
294
| url
stringlengths 60
339
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public double get(int key, double valueIfKeyNotFound) {
final int index = mValues.indexOfKey(key);
if (index < 0) {
return valueIfKeyNotFound;
}
return valueAt(index);
} |
Gets the double mapped from the specified key, or the specified value
if no such mapping has been made.
| SparseDoubleArray::get | java | Reginer/aosp-android-jar | android-33/src/android/util/SparseDoubleArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/SparseDoubleArray.java | MIT |
public void put(int key, double value) {
mValues.put(key, Double.doubleToRawLongBits(value));
} |
Adds a mapping from the specified key to the specified value,
replacing the previous mapping from the specified key if there
was one.
| SparseDoubleArray::put | java | Reginer/aosp-android-jar | android-33/src/android/util/SparseDoubleArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/SparseDoubleArray.java | MIT |
public void incrementValue(int key, double summand) {
final double oldValue = get(key);
put(key, oldValue + summand);
} |
Adds a mapping from the specified key to the specified value,
<b>adding</b> its value to the previous mapping from the specified key if there
was one.
<p>This differs from {@link #put} because instead of replacing any previous value, it adds
(in the numerical sense) to it.
| SparseDoubleArray::incrementValue | java | Reginer/aosp-android-jar | android-33/src/android/util/SparseDoubleArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/SparseDoubleArray.java | MIT |
public int size() {
return mValues.size();
} |
Adds a mapping from the specified key to the specified value,
<b>adding</b> its value to the previous mapping from the specified key if there
was one.
<p>This differs from {@link #put} because instead of replacing any previous value, it adds
(in the numerical sense) to it.
public void incrementValue(int key, double summand) {
final double oldValue = get(key);
put(key, oldValue + summand);
}
/** Returns the number of key-value mappings that this SparseDoubleArray currently stores. | SparseDoubleArray::size | java | Reginer/aosp-android-jar | android-33/src/android/util/SparseDoubleArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/SparseDoubleArray.java | MIT |
public int indexOfKey(int key) {
return mValues.indexOfKey(key);
} |
Returns the index for which {@link #keyAt} would return the
specified key, or a negative number if the specified
key is not mapped.
| SparseDoubleArray::indexOfKey | java | Reginer/aosp-android-jar | android-33/src/android/util/SparseDoubleArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/SparseDoubleArray.java | MIT |
public int keyAt(int index) {
return mValues.keyAt(index);
} |
Given an index in the range <code>0...size()-1</code>, returns
the key from the <code>index</code>th key-value mapping that this
SparseDoubleArray stores.
@see SparseLongArray#keyAt(int)
| SparseDoubleArray::keyAt | java | Reginer/aosp-android-jar | android-33/src/android/util/SparseDoubleArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/SparseDoubleArray.java | MIT |
public double valueAt(int index) {
return Double.longBitsToDouble(mValues.valueAt(index));
} |
Given an index in the range <code>0...size()-1</code>, returns
the value from the <code>index</code>th key-value mapping that this
SparseDoubleArray stores.
@see SparseLongArray#valueAt(int)
| SparseDoubleArray::valueAt | java | Reginer/aosp-android-jar | android-33/src/android/util/SparseDoubleArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/SparseDoubleArray.java | MIT |
public void setValueAt(int index, double value) {
mValues.setValueAt(index, Double.doubleToRawLongBits(value));
} |
Given an index in the range <code>0...size()-1</code>, sets a new
value for the <code>index</code>th key-value mapping that this
SparseDoubleArray stores.
<p>For indices outside of the range <code>0...size()-1</code>, the behavior is undefined for
apps targeting {@link android.os.Build.VERSION_CODES#P} and earlier, and an
{@link ArrayIndexOutOfBoundsException} is thrown for apps targeting
{@link android.os.Build.VERSION_CODES#Q} and later.</p>
| SparseDoubleArray::setValueAt | java | Reginer/aosp-android-jar | android-33/src/android/util/SparseDoubleArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/SparseDoubleArray.java | MIT |
public void removeAt(int index) {
mValues.removeAt(index);
} |
Removes the mapping at the given index.
| SparseDoubleArray::removeAt | java | Reginer/aosp-android-jar | android-33/src/android/util/SparseDoubleArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/SparseDoubleArray.java | MIT |
public void delete(int key) {
mValues.delete(key);
} |
Removes the mapping from the specified key, if there was any.
| SparseDoubleArray::delete | java | Reginer/aosp-android-jar | android-33/src/android/util/SparseDoubleArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/SparseDoubleArray.java | MIT |
public void clear() {
mValues.clear();
} |
Removes all key-value mappings from this SparseDoubleArray.
| SparseDoubleArray::clear | java | Reginer/aosp-android-jar | android-33/src/android/util/SparseDoubleArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/SparseDoubleArray.java | MIT |
public static File dumpStackTraces(ArrayList<Integer> firstPids,
ProcessCpuTracker processCpuTracker, SparseBooleanArray lastPids,
Future<ArrayList<Integer>> nativePidsFuture, StringWriter logExceptionCreatingFile,
@NonNull Executor auxiliaryTaskExecutor, AnrLatencyTracker latencyTracker) {
return dumpStackTraces(firstPids, processCpuTracker, lastPids, nativePidsFuture,
logExceptionCreatingFile, null, null, null, null, auxiliaryTaskExecutor, null,
latencyTracker);
} |
If a stack trace dump file is configured, dump process stack traces.
@param firstPids of dalvik VM processes to dump stack traces for first
@param lastPids of dalvik VM processes to dump stack traces for last
@param nativePidsFuture optional future for a list of native pids to dump stack crawls
@param logExceptionCreatingFile optional writer to which we log errors creating the file
@param auxiliaryTaskExecutor executor to execute auxiliary tasks on
@param latencyTracker the latency tracker instance of the current ANR.
| StackTracesDumpHelper::dumpStackTraces | java | Reginer/aosp-android-jar | android-34/src/com/android/server/am/StackTracesDumpHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/am/StackTracesDumpHelper.java | MIT |
public static File dumpStackTraces(ArrayList<Integer> firstPids,
ProcessCpuTracker processCpuTracker, SparseBooleanArray lastPids,
Future<ArrayList<Integer>> nativePidsFuture, StringWriter logExceptionCreatingFile,
String subject, String criticalEventSection,
@NonNull Executor auxiliaryTaskExecutor, AnrLatencyTracker latencyTracker) {
return dumpStackTraces(firstPids, processCpuTracker, lastPids, nativePidsFuture,
logExceptionCreatingFile, null, subject, criticalEventSection,
/* memoryHeaders= */ null, auxiliaryTaskExecutor, null, latencyTracker);
} |
@param subject the subject of the dumped traces
@param criticalEventSection the critical event log, passed as a string
| StackTracesDumpHelper::dumpStackTraces | java | Reginer/aosp-android-jar | android-34/src/com/android/server/am/StackTracesDumpHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/am/StackTracesDumpHelper.java | MIT |
/* package */ static File dumpStackTraces(ArrayList<Integer> firstPids,
ProcessCpuTracker processCpuTracker, SparseBooleanArray lastPids,
Future<ArrayList<Integer>> nativePidsFuture, StringWriter logExceptionCreatingFile,
AtomicLong firstPidEndOffset, String subject, String criticalEventSection,
String memoryHeaders, @NonNull Executor auxiliaryTaskExecutor,
Future<File> firstPidFilePromise, AnrLatencyTracker latencyTracker) {
try {
if (latencyTracker != null) {
latencyTracker.dumpStackTracesStarted();
}
Slog.i(TAG, "dumpStackTraces pids=" + lastPids);
// Measure CPU usage as soon as we're called in order to get a realistic sampling
// of the top users at the time of the request.
Supplier<ArrayList<Integer>> extraPidsSupplier = processCpuTracker != null
? () -> getExtraPids(processCpuTracker, lastPids, latencyTracker) : null;
Future<ArrayList<Integer>> extraPidsFuture = null;
if (extraPidsSupplier != null) {
extraPidsFuture =
CompletableFuture.supplyAsync(extraPidsSupplier, auxiliaryTaskExecutor);
}
final File tracesDir = new File(ANR_TRACE_DIR);
// NOTE: We should consider creating the file in native code atomically once we've
// gotten rid of the old scheme of dumping and lot of the code that deals with paths
// can be removed.
File tracesFile;
try {
tracesFile = createAnrDumpFile(tracesDir);
} catch (IOException e) {
Slog.w(TAG, "Exception creating ANR dump file:", e);
if (logExceptionCreatingFile != null) {
logExceptionCreatingFile.append(
"----- Exception creating ANR dump file -----\n");
e.printStackTrace(new PrintWriter(logExceptionCreatingFile));
}
if (latencyTracker != null) {
latencyTracker.anrSkippedDumpStackTraces();
}
return null;
}
if (subject != null || criticalEventSection != null || memoryHeaders != null) {
appendtoANRFile(tracesFile.getAbsolutePath(),
(subject != null ? "Subject: " + subject + "\n" : "")
+ (memoryHeaders != null ? memoryHeaders + "\n\n" : "")
+ (criticalEventSection != null ? criticalEventSection : ""));
}
long firstPidEndPos = dumpStackTraces(
tracesFile.getAbsolutePath(), firstPids, nativePidsFuture,
extraPidsFuture, firstPidFilePromise, latencyTracker);
if (firstPidEndOffset != null) {
firstPidEndOffset.set(firstPidEndPos);
}
// Each set of ANR traces is written to a separate file and dumpstate will process
// all such files and add them to a captured bug report if they're recent enough.
maybePruneOldTraces(tracesDir);
return tracesFile;
} finally {
if (latencyTracker != null) {
latencyTracker.dumpStackTracesEnded();
}
}
} |
@param firstPidEndOffset Optional, when it's set, it receives the start/end offset
of the very first pid to be dumped.
| StackTracesDumpHelper::dumpStackTraces | java | Reginer/aosp-android-jar | android-34/src/com/android/server/am/StackTracesDumpHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/am/StackTracesDumpHelper.java | MIT |
public static long dumpStackTraces(String tracesFile,
ArrayList<Integer> firstPids, Future<ArrayList<Integer>> nativePidsFuture,
Future<ArrayList<Integer>> extraPidsFuture, Future<File> firstPidFilePromise,
AnrLatencyTracker latencyTracker) {
Slog.i(TAG, "Dumping to " + tracesFile);
// We don't need any sort of inotify based monitoring when we're dumping traces via
// tombstoned. Data is piped to an "intercept" FD installed in tombstoned so we're in full
// control of all writes to the file in question.
// We must complete all stack dumps within 20 seconds.
long remainingTime = 20 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
// As applications are usually interested with the ANR stack traces, but we can't share
// with them the stack traces other than their own stacks. So after the very first PID is
// dumped, remember the current file size.
long firstPidEnd = -1;
// Was the first pid copied from the temporary file that was created in the predump phase?
boolean firstPidTempDumpCopied = false;
// First copy the first pid's dump from the temporary file it was dumped into earlier,
// The first pid should always exist in firstPids but we check the size just in case.
if (firstPidFilePromise != null && firstPids != null && firstPids.size() > 0) {
final int primaryPid = firstPids.get(0);
final long start = SystemClock.elapsedRealtime();
firstPidTempDumpCopied = copyFirstPidTempDump(tracesFile, firstPidFilePromise,
remainingTime, latencyTracker);
final long timeTaken = SystemClock.elapsedRealtime() - start;
remainingTime -= timeTaken;
if (remainingTime <= 0) {
Slog.e(TAG, "Aborting stack trace dump (currently copying primary pid" + primaryPid
+ "); deadline exceeded.");
return firstPidEnd;
}
// We don't copy ANR traces from the system_server intentionally.
if (firstPidTempDumpCopied && primaryPid != ActivityManagerService.MY_PID) {
firstPidEnd = new File(tracesFile).length();
}
// Append the Durations/latency comma separated array after the first PID.
if (latencyTracker != null) {
appendtoANRFile(tracesFile,
latencyTracker.dumpAsCommaSeparatedArrayWithHeader());
}
}
// Next collect all of the stacks of the most important pids.
if (firstPids != null) {
if (latencyTracker != null) {
latencyTracker.dumpingFirstPidsStarted();
}
int num = firstPids.size();
for (int i = firstPidTempDumpCopied ? 1 : 0; i < num; i++) {
final int pid = firstPids.get(i);
// We don't copy ANR traces from the system_server intentionally.
final boolean firstPid = i == 0 && ActivityManagerService.MY_PID != pid;
Slog.i(TAG, "Collecting stacks for pid " + pid);
final long timeTaken = dumpJavaTracesTombstoned(pid, tracesFile, remainingTime,
latencyTracker);
remainingTime -= timeTaken;
if (remainingTime <= 0) {
Slog.e(TAG, "Aborting stack trace dump (current firstPid=" + pid
+ "); deadline exceeded.");
return firstPidEnd;
}
if (firstPid) {
firstPidEnd = new File(tracesFile).length();
// Full latency dump
if (latencyTracker != null) {
appendtoANRFile(tracesFile,
latencyTracker.dumpAsCommaSeparatedArrayWithHeader());
}
}
if (DEBUG_ANR) {
Slog.d(TAG, "Done with pid " + firstPids.get(i) + " in " + timeTaken + "ms");
}
}
if (latencyTracker != null) {
latencyTracker.dumpingFirstPidsEnded();
}
}
// Next collect the stacks of the native pids
ArrayList<Integer> nativePids = collectPids(nativePidsFuture, "native pids");
Slog.i(TAG, "dumpStackTraces nativepids=" + nativePids);
if (nativePids != null) {
if (latencyTracker != null) {
latencyTracker.dumpingNativePidsStarted();
}
for (int pid : nativePids) {
Slog.i(TAG, "Collecting stacks for native pid " + pid);
final long nativeDumpTimeoutMs = Math.min(NATIVE_DUMP_TIMEOUT_MS, remainingTime);
if (latencyTracker != null) {
latencyTracker.dumpingPidStarted(pid);
}
final long start = SystemClock.elapsedRealtime();
Debug.dumpNativeBacktraceToFileTimeout(
pid, tracesFile, (int) (nativeDumpTimeoutMs / 1000));
final long timeTaken = SystemClock.elapsedRealtime() - start;
if (latencyTracker != null) {
latencyTracker.dumpingPidEnded();
}
remainingTime -= timeTaken;
if (remainingTime <= 0) {
Slog.e(TAG, "Aborting stack trace dump (current native pid=" + pid
+ "); deadline exceeded.");
return firstPidEnd;
}
if (DEBUG_ANR) {
Slog.d(TAG, "Done with native pid " + pid + " in " + timeTaken + "ms");
}
}
if (latencyTracker != null) {
latencyTracker.dumpingNativePidsEnded();
}
}
// Lastly, dump stacks for all extra PIDs from the CPU tracker.
ArrayList<Integer> extraPids = collectPids(extraPidsFuture, "extra pids");
if (extraPidsFuture != null) {
try {
extraPids = extraPidsFuture.get();
} catch (ExecutionException e) {
Slog.w(TAG, "Failed to collect extra pids", e.getCause());
} catch (InterruptedException e) {
Slog.w(TAG, "Interrupted while collecting extra pids", e);
}
}
Slog.i(TAG, "dumpStackTraces extraPids=" + extraPids);
if (extraPids != null) {
if (latencyTracker != null) {
latencyTracker.dumpingExtraPidsStarted();
}
for (int pid : extraPids) {
Slog.i(TAG, "Collecting stacks for extra pid " + pid);
final long timeTaken = dumpJavaTracesTombstoned(pid, tracesFile, remainingTime,
latencyTracker);
remainingTime -= timeTaken;
if (remainingTime <= 0) {
Slog.e(TAG, "Aborting stack trace dump (current extra pid=" + pid
+ "); deadline exceeded.");
return firstPidEnd;
}
if (DEBUG_ANR) {
Slog.d(TAG, "Done with extra pid " + pid + " in " + timeTaken + "ms");
}
}
if (latencyTracker != null) {
latencyTracker.dumpingExtraPidsEnded();
}
}
// Append the dumping footer with the current uptime
appendtoANRFile(tracesFile, "----- dumping ended at " + SystemClock.uptimeMillis() + "\n");
Slog.i(TAG, "Done dumping");
return firstPidEnd;
} |
@return The end offset of the trace of the very first PID
| StackTracesDumpHelper::dumpStackTraces | java | Reginer/aosp-android-jar | android-34/src/com/android/server/am/StackTracesDumpHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/am/StackTracesDumpHelper.java | MIT |
public static File dumpStackTracesTempFile(int pid, AnrLatencyTracker latencyTracker) {
try {
if (latencyTracker != null) {
latencyTracker.dumpStackTracesTempFileStarted();
}
File tmpTracesFile;
try {
tmpTracesFile = File.createTempFile(ANR_TEMP_FILE_PREFIX, ".txt",
new File(ANR_TRACE_DIR));
Slog.d(TAG, "created ANR temporary file:" + tmpTracesFile.getAbsolutePath());
} catch (IOException e) {
Slog.w(TAG, "Exception creating temporary ANR dump file:", e);
if (latencyTracker != null) {
latencyTracker.dumpStackTracesTempFileCreationFailed();
}
return null;
}
Slog.i(TAG, "Collecting stacks for pid " + pid + " into temporary file "
+ tmpTracesFile.getName());
if (latencyTracker != null) {
latencyTracker.dumpingPidStarted(pid);
}
final long timeTaken = dumpJavaTracesTombstoned(pid, tmpTracesFile.getAbsolutePath(),
TEMP_DUMP_TIME_LIMIT);
if (latencyTracker != null) {
latencyTracker.dumpingPidEnded();
}
if (TEMP_DUMP_TIME_LIMIT <= timeTaken) {
Slog.e(TAG, "Aborted stack trace dump (current primary pid=" + pid
+ "); deadline exceeded.");
tmpTracesFile.delete();
if (latencyTracker != null) {
latencyTracker.dumpStackTracesTempFileTimedOut();
}
return null;
}
if (DEBUG_ANR) {
Slog.d(TAG, "Done with primary pid " + pid + " in " + timeTaken + "ms"
+ " dumped into temporary file " + tmpTracesFile.getName());
}
return tmpTracesFile;
} finally {
if (latencyTracker != null) {
latencyTracker.dumpStackTracesTempFileEnded();
}
}
} |
Dumps the supplied pid to a temporary file.
@param pid the PID to be dumped
@param latencyTracker the latency tracker instance of the current ANR.
| StackTracesDumpHelper::dumpStackTracesTempFile | java | Reginer/aosp-android-jar | android-34/src/com/android/server/am/StackTracesDumpHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/am/StackTracesDumpHelper.java | MIT |
private static void maybePruneOldTraces(File tracesDir) {
final File[] files = tracesDir.listFiles();
if (files == null) return;
final int max = SystemProperties.getInt("tombstoned.max_anr_count", 64);
final long now = System.currentTimeMillis();
try {
Arrays.sort(files, Comparator.comparingLong(File::lastModified).reversed());
for (int i = 0; i < files.length; ++i) {
if (i > max || (now - files[i].lastModified()) > DAY_IN_MILLIS) {
if (!files[i].delete()) {
Slog.w(TAG, "Unable to prune stale trace file: " + files[i]);
}
}
}
} catch (IllegalArgumentException e) {
// The modification times changed while we were sorting. Bail...
// https://issuetracker.google.com/169836837
Slog.w(TAG, "tombstone modification times changed while sorting; not pruning", e);
}
} |
Prune all trace files that are more than a day old.
NOTE: It might make sense to move this functionality to tombstoned eventually, along with a
shift away from anr_XX and tombstone_XX to a more descriptive name. We do it here for now
since it's the system_server that creates trace files for most ANRs.
| StackTracesDumpHelper::maybePruneOldTraces | java | Reginer/aosp-android-jar | android-34/src/com/android/server/am/StackTracesDumpHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/am/StackTracesDumpHelper.java | MIT |
private static long dumpJavaTracesTombstoned(int pid, String fileName, long timeoutMs) {
final long timeStart = SystemClock.elapsedRealtime();
int headerSize = writeUptimeStartHeaderForPid(pid, fileName);
boolean javaSuccess = Debug.dumpJavaBacktraceToFileTimeout(pid, fileName,
(int) (timeoutMs / 1000));
if (javaSuccess) {
// Check that something is in the file, actually. Try-catch should not be necessary,
// but better safe than sorry.
try {
long size = new File(fileName).length();
if ((size - headerSize) < JAVA_DUMP_MINIMUM_SIZE) {
Slog.w(TAG, "Successfully created Java ANR file is empty!");
javaSuccess = false;
}
} catch (Exception e) {
Slog.w(TAG, "Unable to get ANR file size", e);
javaSuccess = false;
}
}
if (!javaSuccess) {
Slog.w(TAG, "Dumping Java threads failed, initiating native stack dump.");
if (!Debug.dumpNativeBacktraceToFileTimeout(pid, fileName,
(NATIVE_DUMP_TIMEOUT_MS / 1000))) {
Slog.w(TAG, "Native stack dump failed!");
}
}
return SystemClock.elapsedRealtime() - timeStart;
} |
Dump java traces for process {@code pid} to the specified file. If java trace dumping
fails, a native backtrace is attempted. Note that the timeout {@code timeoutMs} only applies
to the java section of the trace, a further {@code NATIVE_DUMP_TIMEOUT_MS} might be spent
attempting to obtain native traces in the case of a failure. Returns the total time spent
capturing traces.
| StackTracesDumpHelper::dumpJavaTracesTombstoned | java | Reginer/aosp-android-jar | android-34/src/com/android/server/am/StackTracesDumpHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/am/StackTracesDumpHelper.java | MIT |
private static int writeUptimeStartHeaderForPid(int pid, String fileName) {
return appendtoANRFile(fileName, "----- dumping pid: " + pid + " at "
+ SystemClock.uptimeMillis() + "\n");
} |
Dump java traces for process {@code pid} to the specified file. If java trace dumping
fails, a native backtrace is attempted. Note that the timeout {@code timeoutMs} only applies
to the java section of the trace, a further {@code NATIVE_DUMP_TIMEOUT_MS} might be spent
attempting to obtain native traces in the case of a failure. Returns the total time spent
capturing traces.
private static long dumpJavaTracesTombstoned(int pid, String fileName, long timeoutMs) {
final long timeStart = SystemClock.elapsedRealtime();
int headerSize = writeUptimeStartHeaderForPid(pid, fileName);
boolean javaSuccess = Debug.dumpJavaBacktraceToFileTimeout(pid, fileName,
(int) (timeoutMs / 1000));
if (javaSuccess) {
// Check that something is in the file, actually. Try-catch should not be necessary,
// but better safe than sorry.
try {
long size = new File(fileName).length();
if ((size - headerSize) < JAVA_DUMP_MINIMUM_SIZE) {
Slog.w(TAG, "Successfully created Java ANR file is empty!");
javaSuccess = false;
}
} catch (Exception e) {
Slog.w(TAG, "Unable to get ANR file size", e);
javaSuccess = false;
}
}
if (!javaSuccess) {
Slog.w(TAG, "Dumping Java threads failed, initiating native stack dump.");
if (!Debug.dumpNativeBacktraceToFileTimeout(pid, fileName,
(NATIVE_DUMP_TIMEOUT_MS / 1000))) {
Slog.w(TAG, "Native stack dump failed!");
}
}
return SystemClock.elapsedRealtime() - timeStart;
}
private static int appendtoANRFile(String fileName, String text) {
try (FileOutputStream fos = new FileOutputStream(fileName, true)) {
byte[] header = text.getBytes(StandardCharsets.UTF_8);
fos.write(header);
return header.length;
} catch (IOException e) {
Slog.w(TAG, "Exception writing to ANR dump file:", e);
return 0;
}
}
/*
Writes a header containing the process id and the current system uptime.
| StackTracesDumpHelper::writeUptimeStartHeaderForPid | java | Reginer/aosp-android-jar | android-34/src/com/android/server/am/StackTracesDumpHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/am/StackTracesDumpHelper.java | MIT |
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
{
SubContextList subContextList = xctxt.getCurrentNodeList();
int currentNode = DTM.NULL;
if (null != subContextList) {
if (subContextList instanceof PredicatedNodeTest) {
LocPathIterator iter = ((PredicatedNodeTest)subContextList)
.getLocPathIterator();
currentNode = iter.getCurrentContextNode();
} else if(subContextList instanceof StepPattern) {
throw new RuntimeException(XSLMessages.createMessage(
XSLTErrorResources.ER_PROCESSOR_ERROR,null));
}
} else {
// not predicate => ContextNode == CurrentNode
currentNode = xctxt.getContextNode();
}
return new XNodeSet(currentNode, xctxt.getDTMManager());
} |
Execute the function. The function must return
a valid object.
@param xctxt The current execution context.
@return A valid XObject.
@throws javax.xml.transform.TransformerException
| FuncCurrent::execute | java | Reginer/aosp-android-jar | android-35/src/org/apache/xpath/functions/FuncCurrent.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xpath/functions/FuncCurrent.java | MIT |
public void fixupVariables(java.util.Vector vars, int globalsSize)
{
// no-op
} |
No arguments to process, so this does nothing.
| FuncCurrent::fixupVariables | java | Reginer/aosp-android-jar | android-35/src/org/apache/xpath/functions/FuncCurrent.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xpath/functions/FuncCurrent.java | MIT |
private static int intAbs(short v) {
return v & 0xFFFF;
} |
Converts a signed short value to an unsigned int value. Needed
because Java does not have unsigned types.
| IpUtils::intAbs | java | Reginer/aosp-android-jar | android-33/src/com/android/net/module/util/IpUtils.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/net/module/util/IpUtils.java | MIT |
private static int checksum(ByteBuffer buf, int seed, int start, int end) {
int sum = seed;
final int bufPosition = buf.position();
// set position of original ByteBuffer, so that the ShortBuffer
// will be correctly initialized
buf.position(start);
ShortBuffer shortBuf = buf.asShortBuffer();
// re-set ByteBuffer position
buf.position(bufPosition);
final int numShorts = (end - start) / 2;
for (int i = 0; i < numShorts; i++) {
sum += intAbs(shortBuf.get(i));
}
start += numShorts * 2;
// see if a singleton byte remains
if (end != start) {
short b = buf.get(start);
// make it unsigned
if (b < 0) {
b += 256;
}
sum += b * 256;
}
sum = ((sum >> 16) & 0xFFFF) + (sum & 0xFFFF);
sum = ((sum + ((sum >> 16) & 0xFFFF)) & 0xFFFF);
int negated = ~sum;
return intAbs((short) negated);
} |
Performs an IP checksum (used in IP header and across UDP
payload) on the specified portion of a ByteBuffer. The seed
allows the checksum to commence with a specified value.
| IpUtils::checksum | java | Reginer/aosp-android-jar | android-33/src/com/android/net/module/util/IpUtils.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/net/module/util/IpUtils.java | MIT |
public static short udpChecksum(ByteBuffer buf, int ipOffset, int transportOffset) {
int transportLen = intAbs(buf.getShort(transportOffset + 4));
return transportChecksum(buf, IPPROTO_UDP, ipOffset, transportOffset, transportLen);
} |
Calculate the UDP checksum for an UDP packet.
| IpUtils::udpChecksum | java | Reginer/aosp-android-jar | android-33/src/com/android/net/module/util/IpUtils.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/net/module/util/IpUtils.java | MIT |
public static short tcpChecksum(ByteBuffer buf, int ipOffset, int transportOffset,
int transportLen) {
return transportChecksum(buf, IPPROTO_TCP, ipOffset, transportOffset, transportLen);
} |
Calculate the TCP checksum for a TCP packet.
| IpUtils::tcpChecksum | java | Reginer/aosp-android-jar | android-33/src/com/android/net/module/util/IpUtils.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/net/module/util/IpUtils.java | MIT |
public static short icmpv6Checksum(ByteBuffer buf, int ipOffset, int transportOffset,
int transportLen) {
return transportChecksum(buf, IPPROTO_ICMPV6, ipOffset, transportOffset, transportLen);
} |
Calculate the ICMPv6 checksum for an ICMPv6 packet.
| IpUtils::icmpv6Checksum | java | Reginer/aosp-android-jar | android-33/src/com/android/net/module/util/IpUtils.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/net/module/util/IpUtils.java | MIT |
public static void run(MediaShellCommand cmd) throws Exception {
//----------------------------------------
// Default parameters
int stream = AudioManager.STREAM_MUSIC;
int volIndex = 5;
int mode = 0;
int adjDir = AudioManager.ADJUST_RAISE;
boolean showUi = false;
boolean doGet = false;
//----------------------------------------
// read options
String option;
String adjustment = null;
while ((option = cmd.getNextOption()) != null) {
switch (option) {
case "--show":
showUi = true;
break;
case "--get":
doGet = true;
cmd.log(LOG_V, "will get volume");
break;
case "--stream":
stream = Integer.decode(cmd.getNextArgRequired()).intValue();
cmd.log(LOG_V,
"will control stream=" + stream + " (" + streamName(stream) + ")");
break;
case "--set":
volIndex = Integer.decode(cmd.getNextArgRequired()).intValue();
mode = VOLUME_CONTROL_MODE_SET;
cmd.log(LOG_V, "will set volume to index=" + volIndex);
break;
case "--adj":
mode = VOLUME_CONTROL_MODE_ADJUST;
adjustment = cmd.getNextArgRequired();
cmd.log(LOG_V, "will adjust volume");
break;
default:
throw new IllegalArgumentException("Unknown argument " + option);
}
}
//------------------------------
// Read options: validation
if (mode == VOLUME_CONTROL_MODE_ADJUST) {
if (adjustment == null) {
cmd.showError("Error: no valid volume adjustment (null)");
return;
}
switch (adjustment) {
case ADJUST_RAISE: adjDir = AudioManager.ADJUST_RAISE; break;
case ADJUST_SAME: adjDir = AudioManager.ADJUST_SAME; break;
case ADJUST_LOWER: adjDir = AudioManager.ADJUST_LOWER; break;
default:
cmd.showError("Error: no valid volume adjustment, was " + adjustment
+ ", expected " + ADJUST_LOWER + "|" + ADJUST_SAME + "|"
+ ADJUST_RAISE);
return;
}
}
//----------------------------------------
// Test initialization
cmd.log(LOG_V, "Connecting to AudioService");
IAudioService audioService = IAudioService.Stub.asInterface(ServiceManager.checkService(
Context.AUDIO_SERVICE));
if (audioService == null) {
cmd.log(LOG_E, BaseCommand.NO_SYSTEM_ERROR_CODE);
throw new AndroidException(
"Can't connect to audio service; is the system running?");
}
if (mode == VOLUME_CONTROL_MODE_SET) {
if ((volIndex > audioService.getStreamMaxVolume(stream))
|| (volIndex < audioService.getStreamMinVolume(stream))) {
cmd.showError(String.format("Error: invalid volume index %d for stream %d "
+ "(should be in [%d..%d])", volIndex, stream,
audioService.getStreamMinVolume(stream),
audioService.getStreamMaxVolume(stream)));
return;
}
}
//----------------------------------------
// Non-interactive test
final int flag = showUi ? AudioManager.FLAG_SHOW_UI : 0;
final String pack = cmd.getClass().getPackage().getName();
if (mode == VOLUME_CONTROL_MODE_SET) {
audioService.setStreamVolume(stream, volIndex, flag, pack/*callingPackage*/);
} else if (mode == VOLUME_CONTROL_MODE_ADJUST) {
audioService.adjustStreamVolume(stream, adjDir, flag, pack);
}
if (doGet) {
cmd.log(LOG_V, "volume is " + audioService.getStreamVolume(stream)
+ " in range [" + audioService.getStreamMinVolume(stream)
+ ".." + audioService.getStreamMaxVolume(stream) + "]");
}
} |
Runs a given MediaShellCommand
| VolumeCtrl::run | java | Reginer/aosp-android-jar | android-35/src/com/android/server/media/VolumeCtrl.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/media/VolumeCtrl.java | MIT |
public EventParser(String event) {
super(event);
} |
Creates a new instance of EventParser
@param event the header to parse
| EventParser::EventParser | java | Reginer/aosp-android-jar | android-35/src/gov/nist/javax/sip/parser/EventParser.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/gov/nist/javax/sip/parser/EventParser.java | MIT |
protected EventParser(Lexer lexer) {
super(lexer);
} |
Cosntructor
@param lexer the lexer to use to parse the header
| EventParser::EventParser | java | Reginer/aosp-android-jar | android-35/src/gov/nist/javax/sip/parser/EventParser.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/gov/nist/javax/sip/parser/EventParser.java | MIT |
public SIPHeader parse() throws ParseException {
if (debug)
dbg_enter("EventParser.parse");
try {
headerName(TokenTypes.EVENT);
this.lexer.SPorHT();
Event event = new Event();
this.lexer.match(TokenTypes.ID);
Token token = lexer.getNextToken();
String value = token.getTokenValue();
event.setEventType(value);
super.parse(event);
this.lexer.SPorHT();
this.lexer.match('\n');
return event;
} catch (ParseException ex) {
throw createParseException(ex.getMessage());
} finally {
if (debug)
dbg_leave("EventParser.parse");
}
} |
parse the String message
@return SIPHeader (Event object)
@throws SIPParseException if the message does not respect the spec.
| EventParser::parse | java | Reginer/aosp-android-jar | android-35/src/gov/nist/javax/sip/parser/EventParser.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/gov/nist/javax/sip/parser/EventParser.java | MIT |
public static boolean canCurrentUserBlockNumbers(Context context) {
try {
final Bundle res = context.getContentResolver().call(
AUTHORITY_URI, METHOD_CAN_CURRENT_USER_BLOCK_NUMBERS, null, null);
return res != null && res.getBoolean(RES_CAN_BLOCK_NUMBERS, false);
} catch (NullPointerException | IllegalArgumentException ex) {
// The content resolver can throw an NPE or IAE; we don't want to crash Telecom if
// either of these happen.
Log.w(null, "canCurrentUserBlockNumbers: provider not ready.");
return false;
}
} |
Checks if blocking numbers is supported for the current user.
<p> Typically, blocking numbers is only supported for one user at a time.
@return {@code true} if the current user can block numbers.
| BlockedNumberContract::canCurrentUserBlockNumbers | java | Reginer/aosp-android-jar | android-32/src/android/provider/BlockedNumberContract.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/provider/BlockedNumberContract.java | MIT |
public static void notifyEmergencyContact(Context context) {
try {
Log.i(LOG_TAG, "notifyEmergencyContact; caller=%s", context.getOpPackageName());
context.getContentResolver().call(
AUTHORITY_URI, METHOD_NOTIFY_EMERGENCY_CONTACT, null, null);
} catch (NullPointerException | IllegalArgumentException ex) {
// The content resolver can throw an NPE or IAE; we don't want to crash Telecom if
// either of these happen.
Log.w(null, "notifyEmergencyContact: provider not ready.");
}
} |
Notifies the provider that emergency services were contacted by the user.
<p> This results in {@link #shouldSystemBlockNumber} returning {@code false} independent
of the contents of the provider for a duration defined by
{@link android.telephony.CarrierConfigManager#KEY_DURATION_BLOCKING_DISABLED_AFTER_EMERGENCY_INT}
the provider unless {@link #endBlockSuppression(Context)} is called.
| SystemContract::notifyEmergencyContact | java | Reginer/aosp-android-jar | android-32/src/android/provider/BlockedNumberContract.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/provider/BlockedNumberContract.java | MIT |
public static void endBlockSuppression(Context context) {
String caller = context.getOpPackageName();
Log.i(LOG_TAG, "endBlockSuppression: caller=%s", caller);
context.getContentResolver().call(
AUTHORITY_URI, METHOD_END_BLOCK_SUPPRESSION, null, null);
} |
Notifies the provider to disable suppressing blocking. If emergency services were not
contacted recently at all, calling this method is a no-op.
| SystemContract::endBlockSuppression | java | Reginer/aosp-android-jar | android-32/src/android/provider/BlockedNumberContract.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/provider/BlockedNumberContract.java | MIT |
public static int shouldSystemBlockNumber(Context context, String phoneNumber,
Bundle extras) {
try {
String caller = context.getOpPackageName();
final Bundle res = context.getContentResolver().call(
AUTHORITY_URI, METHOD_SHOULD_SYSTEM_BLOCK_NUMBER, phoneNumber, extras);
int blockResult = res != null ? res.getInt(RES_BLOCK_STATUS, STATUS_NOT_BLOCKED) :
BlockedNumberContract.STATUS_NOT_BLOCKED;
Log.d(LOG_TAG, "shouldSystemBlockNumber: number=%s, caller=%s, result=%s",
Log.piiHandle(phoneNumber), caller, blockStatusToString(blockResult));
return blockResult;
} catch (NullPointerException | IllegalArgumentException ex) {
// The content resolver can throw an NPE or IAE; we don't want to crash Telecom if
// either of these happen.
Log.w(null, "shouldSystemBlockNumber: provider not ready.");
return BlockedNumberContract.STATUS_NOT_BLOCKED;
}
} |
Returns {@code true} if {@code phoneNumber} is blocked taking
{@link #notifyEmergencyContact(Context)} into consideration. If emergency services
have not been contacted recently and enhanced call blocking not been enabled, this
method is equivalent to {@link #isBlocked(Context, String)}.
@param context the context of the caller.
@param phoneNumber the number to check.
@param extras the extra attribute of the number.
@return result code indicating if the number should be blocked, and if so why.
Valid values are: {@link #STATUS_NOT_BLOCKED}, {@link #STATUS_BLOCKED_IN_LIST},
{@link #STATUS_BLOCKED_NOT_IN_CONTACTS}, {@link #STATUS_BLOCKED_PAYPHONE},
{@link #STATUS_BLOCKED_RESTRICTED}, {@link #STATUS_BLOCKED_UNKNOWN_NUMBER}.
| SystemContract::shouldSystemBlockNumber | java | Reginer/aosp-android-jar | android-32/src/android/provider/BlockedNumberContract.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/provider/BlockedNumberContract.java | MIT |
public static BlockSuppressionStatus getBlockSuppressionStatus(Context context) {
final Bundle res = context.getContentResolver().call(
AUTHORITY_URI, METHOD_GET_BLOCK_SUPPRESSION_STATUS, null, null);
BlockSuppressionStatus blockSuppressionStatus = new BlockSuppressionStatus(
res.getBoolean(RES_IS_BLOCKING_SUPPRESSED, false),
res.getLong(RES_BLOCKING_SUPPRESSED_UNTIL_TIMESTAMP, 0));
Log.d(LOG_TAG, "getBlockSuppressionStatus: caller=%s, status=%s",
context.getOpPackageName(), blockSuppressionStatus);
return blockSuppressionStatus;
} |
Returns the current status of block suppression.
| SystemContract::getBlockSuppressionStatus | java | Reginer/aosp-android-jar | android-32/src/android/provider/BlockedNumberContract.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/provider/BlockedNumberContract.java | MIT |
public static boolean shouldShowEmergencyCallNotification(Context context) {
try {
final Bundle res = context.getContentResolver().call(
AUTHORITY_URI, METHOD_SHOULD_SHOW_EMERGENCY_CALL_NOTIFICATION, null, null);
return res != null && res.getBoolean(RES_SHOW_EMERGENCY_CALL_NOTIFICATION, false);
} catch (NullPointerException | IllegalArgumentException ex) {
// The content resolver can throw an NPE or IAE; we don't want to crash Telecom if
// either of these happen.
Log.w(null, "shouldShowEmergencyCallNotification: provider not ready.");
return false;
}
} |
Check whether should show the emergency call notification.
@param context the context of the caller.
@return {@code true} if should show emergency call notification. {@code false} otherwise.
| SystemContract::shouldShowEmergencyCallNotification | java | Reginer/aosp-android-jar | android-32/src/android/provider/BlockedNumberContract.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/provider/BlockedNumberContract.java | MIT |
public static boolean getEnhancedBlockSetting(Context context, String key) {
Bundle extras = new Bundle();
extras.putString(EXTRA_ENHANCED_SETTING_KEY, key);
try {
final Bundle res = context.getContentResolver().call(
AUTHORITY_URI, METHOD_GET_ENHANCED_BLOCK_SETTING, null, extras);
return res != null && res.getBoolean(RES_ENHANCED_SETTING_IS_ENABLED, false);
} catch (NullPointerException | IllegalArgumentException ex) {
// The content resolver can throw an NPE or IAE; we don't want to crash Telecom if
// either of these happen.
Log.w(null, "getEnhancedBlockSetting: provider not ready.");
return false;
}
} |
Check whether the enhanced block setting is enabled.
@param context the context of the caller.
@param key the key of the setting to check, can be
{@link #ENHANCED_SETTING_KEY_BLOCK_UNREGISTERED}
{@link #ENHANCED_SETTING_KEY_BLOCK_PRIVATE}
{@link #ENHANCED_SETTING_KEY_BLOCK_PAYPHONE}
{@link #ENHANCED_SETTING_KEY_BLOCK_UNKNOWN}
{@link #ENHANCED_SETTING_KEY_EMERGENCY_CALL_NOTIFICATION_SHOWING}
@return {@code true} if the setting is enabled. {@code false} otherwise.
| SystemContract::getEnhancedBlockSetting | java | Reginer/aosp-android-jar | android-32/src/android/provider/BlockedNumberContract.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/provider/BlockedNumberContract.java | MIT |
public static void setEnhancedBlockSetting(Context context, String key, boolean value) {
Bundle extras = new Bundle();
extras.putString(EXTRA_ENHANCED_SETTING_KEY, key);
extras.putBoolean(EXTRA_ENHANCED_SETTING_VALUE, value);
context.getContentResolver().call(AUTHORITY_URI, METHOD_SET_ENHANCED_BLOCK_SETTING,
null, extras);
} |
Set the enhanced block setting enabled status.
@param context the context of the caller.
@param key the key of the setting to set, can be
{@link #ENHANCED_SETTING_KEY_BLOCK_UNREGISTERED}
{@link #ENHANCED_SETTING_KEY_BLOCK_PRIVATE}
{@link #ENHANCED_SETTING_KEY_BLOCK_PAYPHONE}
{@link #ENHANCED_SETTING_KEY_BLOCK_UNKNOWN}
{@link #ENHANCED_SETTING_KEY_EMERGENCY_CALL_NOTIFICATION_SHOWING}
@param value the enabled statue of the setting to set.
| SystemContract::setEnhancedBlockSetting | java | Reginer/aosp-android-jar | android-32/src/android/provider/BlockedNumberContract.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/provider/BlockedNumberContract.java | MIT |
public static String blockStatusToString(int blockStatus) {
switch (blockStatus) {
case STATUS_NOT_BLOCKED:
return "not blocked";
case STATUS_BLOCKED_IN_LIST:
return "blocked - in list";
case STATUS_BLOCKED_RESTRICTED:
return "blocked - restricted";
case STATUS_BLOCKED_UNKNOWN_NUMBER:
return "blocked - unknown";
case STATUS_BLOCKED_PAYPHONE:
return "blocked - payphone";
case STATUS_BLOCKED_NOT_IN_CONTACTS:
return "blocked - not in contacts";
}
return "unknown";
} |
Converts a block status constant to a string equivalent for logging.
@hide
| SystemContract::blockStatusToString | java | Reginer/aosp-android-jar | android-32/src/android/provider/BlockedNumberContract.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/provider/BlockedNumberContract.java | MIT |
private AbsSavedState() {
mSuperState = null;
} |
Constructor used to make the EMPTY_STATE singleton
| AbsSavedState::AbsSavedState | java | Reginer/aosp-android-jar | android-32/src/android/view/AbsSavedState.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/view/AbsSavedState.java | MIT |
protected AbsSavedState(Parcelable superState) {
if (superState == null) {
throw new IllegalArgumentException("superState must not be null");
}
mSuperState = superState != EMPTY_STATE ? superState : null;
} |
Constructor called by derived classes when creating their SavedState objects
@param superState The state of the superclass of this view
| AbsSavedState::AbsSavedState | java | Reginer/aosp-android-jar | android-32/src/android/view/AbsSavedState.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/view/AbsSavedState.java | MIT |
protected AbsSavedState(Parcel source) {
this(source, null);
} |
Constructor used when reading from a parcel. Reads the state of the superclass.
@param source parcel to read from
| AbsSavedState::AbsSavedState | java | Reginer/aosp-android-jar | android-32/src/android/view/AbsSavedState.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/view/AbsSavedState.java | MIT |
protected AbsSavedState(Parcel source, ClassLoader loader) {
Parcelable superState = source.readParcelable(loader);
mSuperState = superState != null ? superState : EMPTY_STATE;
} |
Constructor used when reading from a parcel using a given class loader.
Reads the state of the superclass.
@param source parcel to read from
@param loader ClassLoader to use for reading
| AbsSavedState::AbsSavedState | java | Reginer/aosp-android-jar | android-32/src/android/view/AbsSavedState.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/view/AbsSavedState.java | MIT |
Looper getLooper() {
return getBaseContext().getMainLooper();
} |
Returns a {@link Looper} to perform service operations on.
| InstantAppResolverService::getLooper | java | Reginer/aosp-android-jar | android-33/src/android/app/InstantAppResolverService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/InstantAppResolverService.java | MIT |
public synchronized void onDestroy() {
mDestroyed = true;
mDispatcher.onDestroy();
mRequestCoordinators.forEach((taskId, requestCoord) -> requestCoord.onFinish());
mRequestCoordinators.clear();
} |
Clear the collection when the instance is destroyed.
| UceRequestRepository::onDestroy | java | Reginer/aosp-android-jar | android-33/src/com/android/ims/rcs/uce/request/UceRequestRepository.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/ims/rcs/uce/request/UceRequestRepository.java | MIT |
public synchronized void addRequestCoordinator(UceRequestCoordinator coordinator) {
if (mDestroyed) return;
mRequestCoordinators.put(coordinator.getCoordinatorId(), coordinator);
mDispatcher.addRequest(coordinator.getCoordinatorId(),
coordinator.getActivatedRequestTaskIds());
} |
Add new UceRequestCoordinator and notify the RequestDispatcher to check whether the given
requests can be executed or not.
| UceRequestRepository::addRequestCoordinator | java | Reginer/aosp-android-jar | android-33/src/com/android/ims/rcs/uce/request/UceRequestRepository.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/ims/rcs/uce/request/UceRequestRepository.java | MIT |
public synchronized UceRequestCoordinator removeRequestCoordinator(Long coordinatorId) {
return mRequestCoordinators.remove(coordinatorId);
} |
Remove the RequestCoordinator from the RequestCoordinator collection.
| UceRequestRepository::removeRequestCoordinator | java | Reginer/aosp-android-jar | android-33/src/com/android/ims/rcs/uce/request/UceRequestRepository.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/ims/rcs/uce/request/UceRequestRepository.java | MIT |
public synchronized UceRequestCoordinator getRequestCoordinator(Long coordinatorId) {
return mRequestCoordinators.get(coordinatorId);
} |
Retrieve the RequestCoordinator associated with the given coordinatorId.
| UceRequestRepository::getRequestCoordinator | java | Reginer/aosp-android-jar | android-33/src/com/android/ims/rcs/uce/request/UceRequestRepository.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/ims/rcs/uce/request/UceRequestRepository.java | MIT |
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// For ACTION_DEVICE_STORAGE_LOW:
mCachedQuotaUptimeMillis = 0; // Force a re-check of quota size
// Run the initialization in the background (not this main thread).
// The init() and trimToFit() methods are synchronized, so they still
// block other users -- but at least the onReceive() call can finish.
new Thread() {
public void run() {
try {
init();
trimToFit();
} catch (IOException e) {
Slog.e(TAG, "Can't init", e);
}
}
}.start();
}
}; |
Implementation of {@link IDropBoxManagerService} using the filesystem.
Clients use {@link DropBoxManager} to access this service.
public final class DropBoxManagerService extends SystemService {
private static final String TAG = "DropBoxManagerService";
private static final int DEFAULT_AGE_SECONDS = 3 * 86400;
private static final int DEFAULT_MAX_FILES = 1000;
private static final int DEFAULT_MAX_FILES_LOWRAM = 300;
private static final int DEFAULT_QUOTA_KB = 10 * 1024;
private static final int DEFAULT_QUOTA_PERCENT = 10;
private static final int DEFAULT_RESERVE_PERCENT = 10;
private static final int QUOTA_RESCAN_MILLIS = 5000;
private static final boolean PROFILE_DUMP = false;
// Max number of bytes of a dropbox entry to write into protobuf.
private static final int PROTO_MAX_DATA_BYTES = 256 * 1024;
// Size beyond which to force-compress newly added entries.
private static final long COMPRESS_THRESHOLD_BYTES = 16_384;
// TODO: This implementation currently uses one file per entry, which is
// inefficient for smallish entries -- consider using a single queue file
// per tag (or even globally) instead.
// The cached context and derived objects
private final ContentResolver mContentResolver;
private final File mDropBoxDir;
// Accounting of all currently written log files (set in init()).
private FileList mAllFiles = null;
private ArrayMap<String, FileList> mFilesByTag = null;
private long mLowPriorityRateLimitPeriod = 0;
private ArraySet<String> mLowPriorityTags = null;
// Various bits of disk information
private StatFs mStatFs = null;
private int mBlockSize = 0;
private int mCachedQuotaBlocks = 0; // Space we can use: computed from free space, etc.
private long mCachedQuotaUptimeMillis = 0;
private volatile boolean mBooted = false;
// Provide a way to perform sendBroadcast asynchronously to avoid deadlocks.
private final DropBoxManagerBroadcastHandler mHandler;
private int mMaxFiles = -1; // -1 means uninitialized.
/** Receives events that might indicate a need to clean up files. | DropBoxManagerService::BroadcastReceiver | java | Reginer/aosp-android-jar | android-32/src/com/android/server/DropBoxManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/DropBoxManagerService.java | MIT |
public void sendBroadcast(String tag, long time) {
sendMessage(obtainMessage(MSG_SEND_BROADCAST, createIntent(tag, time)));
} |
Schedule a dropbox broadcast to be sent asynchronously.
| DropBoxManagerBroadcastHandler::sendBroadcast | java | Reginer/aosp-android-jar | android-32/src/com/android/server/DropBoxManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/DropBoxManagerService.java | MIT |
public void maybeDeferBroadcast(String tag, long time) {
synchronized (mLock) {
final Intent intent = mDeferredMap.get(tag);
if (intent == null) {
// Schedule new delayed broadcast.
mDeferredMap.put(tag, createIntent(tag, time));
sendMessageDelayed(obtainMessage(MSG_SEND_DEFERRED_BROADCAST, tag),
mLowPriorityRateLimitPeriod);
} else {
// Broadcast is already scheduled. Update intent with new data.
intent.putExtra(DropBoxManager.EXTRA_TIME, time);
final int dropped = intent.getIntExtra(DropBoxManager.EXTRA_DROPPED_COUNT, 0);
intent.putExtra(DropBoxManager.EXTRA_DROPPED_COUNT, dropped + 1);
return;
}
}
} |
Possibly schedule a delayed dropbox broadcast. The broadcast will only be scheduled if
no broadcast is currently scheduled. Otherwise updated the scheduled broadcast with the
new intent information, effectively dropping the previous broadcast.
| DropBoxManagerBroadcastHandler::maybeDeferBroadcast | java | Reginer/aosp-android-jar | android-32/src/com/android/server/DropBoxManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/DropBoxManagerService.java | MIT |
public DropBoxManagerService(final Context context) {
this(context, new File("/data/system/dropbox"), FgThread.get().getLooper());
} |
Creates an instance of managed drop box storage using the default dropbox
directory.
@param context to use for receiving free space & gservices intents
| DropBoxManagerBroadcastHandler::DropBoxManagerService | java | Reginer/aosp-android-jar | android-32/src/com/android/server/DropBoxManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/DropBoxManagerService.java | MIT |
public final int compareTo(FileList o) {
if (blocks != o.blocks) return o.blocks - blocks;
if (this == o) return 0;
if (hashCode() < o.hashCode()) return -1;
if (hashCode() > o.hashCode()) return 1;
return 0;
} |
Simple entry which contains data ready to be written.
public static class SimpleEntrySource implements EntrySource {
private final InputStream in;
private final long length;
private final boolean forceCompress;
public SimpleEntrySource(InputStream in, long length, boolean forceCompress) {
this.in = in;
this.length = length;
this.forceCompress = forceCompress;
}
public long length() {
return length;
}
@Override
public void writeTo(FileDescriptor fd) throws IOException {
// No need to buffer the output here, since data is either coming
// from an in-memory buffer, or another file on disk; if we buffered
// we'd lose out on sendfile() optimizations
if (forceCompress) {
final GZIPOutputStream gzipOutputStream =
new GZIPOutputStream(new FileOutputStream(fd));
FileUtils.copy(in, gzipOutputStream);
gzipOutputStream.close();
} else {
FileUtils.copy(in, new FileOutputStream(fd));
}
}
@Override
public void close() throws IOException {
FileUtils.closeQuietly(in);
}
}
public void addEntry(String tag, EntrySource entry, int flags) {
File temp = null;
try {
Slog.i(TAG, "add tag=" + tag + " isTagEnabled=" + isTagEnabled(tag)
+ " flags=0x" + Integer.toHexString(flags));
if ((flags & DropBoxManager.IS_EMPTY) != 0) throw new IllegalArgumentException();
init();
// Bail early if we know tag is disabled
if (!isTagEnabled(tag)) return;
// Drop entries which are too large for our quota
final long length = entry.length();
final long max = trimToFit();
if (length > max) {
// Log and fall through to create empty tombstone below
Slog.w(TAG, "Dropping: " + tag + " (" + length + " > " + max + " bytes)");
} else {
temp = new File(mDropBoxDir, "drop" + Thread.currentThread().getId() + ".tmp");
try (FileOutputStream out = new FileOutputStream(temp)) {
entry.writeTo(out.getFD());
}
}
// Writing above succeeded, so create the finalized entry
long time = createEntry(temp, tag, flags);
temp = null;
// Call sendBroadcast after returning from this call to avoid deadlock. In particular
// the caller may be holding the WindowManagerService lock but sendBroadcast requires a
// lock in ActivityManagerService. ActivityManagerService has been caught holding that
// very lock while waiting for the WindowManagerService lock.
if (mLowPriorityTags != null && mLowPriorityTags.contains(tag)) {
// Rate limit low priority Dropbox entries
mHandler.maybeDeferBroadcast(tag, time);
} else {
mHandler.sendBroadcast(tag, time);
}
} catch (IOException e) {
Slog.e(TAG, "Can't write: " + tag, e);
} finally {
IoUtils.closeQuietly(entry);
if (temp != null) temp.delete();
}
}
public boolean isTagEnabled(String tag) {
final long token = Binder.clearCallingIdentity();
try {
return !"disabled".equals(Settings.Global.getString(
mContentResolver, Settings.Global.DROPBOX_TAG_PREFIX + tag));
} finally {
Binder.restoreCallingIdentity(token);
}
}
private boolean checkPermission(int callingUid, String callingPackage,
@Nullable String callingAttributionTag) {
// If callers have this permission, then we don't need to check
// USAGE_STATS, because they are part of the system and have agreed to
// check USAGE_STATS before passing the data along.
if (getContext().checkCallingPermission(android.Manifest.permission.PEEK_DROPBOX_DATA)
== PackageManager.PERMISSION_GRANTED) {
return true;
}
// Callers always need this permission
getContext().enforceCallingOrSelfPermission(
android.Manifest.permission.READ_LOGS, TAG);
// Callers also need the ability to read usage statistics
switch (getContext().getSystemService(AppOpsManager.class).noteOp(
AppOpsManager.OP_GET_USAGE_STATS, callingUid, callingPackage, callingAttributionTag,
null)) {
case AppOpsManager.MODE_ALLOWED:
return true;
case AppOpsManager.MODE_DEFAULT:
getContext().enforceCallingOrSelfPermission(
android.Manifest.permission.PACKAGE_USAGE_STATS, TAG);
return true;
default:
return false;
}
}
public synchronized DropBoxManager.Entry getNextEntry(String tag, long millis,
String callingPackage, @Nullable String callingAttributionTag) {
if (!checkPermission(Binder.getCallingUid(), callingPackage, callingAttributionTag)) {
return null;
}
try {
init();
} catch (IOException e) {
Slog.e(TAG, "Can't init", e);
return null;
}
FileList list = tag == null ? mAllFiles : mFilesByTag.get(tag);
if (list == null) return null;
for (EntryFile entry : list.contents.tailSet(new EntryFile(millis + 1))) {
if (entry.tag == null) continue;
if ((entry.flags & DropBoxManager.IS_EMPTY) != 0) {
return new DropBoxManager.Entry(entry.tag, entry.timestampMillis);
}
final File file = entry.getFile(mDropBoxDir);
try {
return new DropBoxManager.Entry(
entry.tag, entry.timestampMillis, file, entry.flags);
} catch (IOException e) {
Slog.wtf(TAG, "Can't read: " + file, e);
// Continue to next file
}
}
return null;
}
private synchronized void setLowPriorityRateLimit(long period) {
mLowPriorityRateLimitPeriod = period;
}
private synchronized void addLowPriorityTag(String tag) {
mLowPriorityTags.add(tag);
}
private synchronized void removeLowPriorityTag(String tag) {
mLowPriorityTags.remove(tag);
}
private synchronized void restoreDefaults() {
getLowPriorityResourceConfigs();
}
public synchronized void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (!DumpUtils.checkDumpAndUsageStatsPermission(getContext(), TAG, pw)) return;
try {
init();
} catch (IOException e) {
pw.println("Can't initialize: " + e);
Slog.e(TAG, "Can't init", e);
return;
}
if (PROFILE_DUMP) Debug.startMethodTracing("/data/trace/dropbox.dump");
StringBuilder out = new StringBuilder();
boolean doPrint = false, doFile = false;
boolean dumpProto = false;
ArrayList<String> searchArgs = new ArrayList<String>();
for (int i = 0; args != null && i < args.length; i++) {
if (args[i].equals("-p") || args[i].equals("--print")) {
doPrint = true;
} else if (args[i].equals("-f") || args[i].equals("--file")) {
doFile = true;
} else if (args[i].equals("--proto")) {
dumpProto = true;
} else if (args[i].equals("-h") || args[i].equals("--help")) {
pw.println("Dropbox (dropbox) dump options:");
pw.println(" [-h|--help] [-p|--print] [-f|--file] [timestamp]");
pw.println(" -h|--help: print this help");
pw.println(" -p|--print: print full contents of each entry");
pw.println(" -f|--file: print path of each entry's file");
pw.println(" --proto: dump data to proto");
pw.println(" [timestamp] optionally filters to only those entries.");
return;
} else if (args[i].startsWith("-")) {
out.append("Unknown argument: ").append(args[i]).append("\n");
} else {
searchArgs.add(args[i]);
}
}
if (dumpProto) {
dumpProtoLocked(fd, searchArgs);
return;
}
out.append("Drop box contents: ").append(mAllFiles.contents.size()).append(" entries\n");
out.append("Max entries: ").append(mMaxFiles).append("\n");
out.append("Low priority rate limit period: ");
out.append(mLowPriorityRateLimitPeriod).append(" ms\n");
out.append("Low priority tags: ").append(mLowPriorityTags).append("\n");
if (!searchArgs.isEmpty()) {
out.append("Searching for:");
for (String a : searchArgs) out.append(" ").append(a);
out.append("\n");
}
int numFound = 0;
out.append("\n");
for (EntryFile entry : mAllFiles.contents) {
if (!matchEntry(entry, searchArgs)) continue;
numFound++;
if (doPrint) out.append("========================================\n");
String date = TimeMigrationUtils.formatMillisWithFixedFormat(entry.timestampMillis);
out.append(date).append(" ").append(entry.tag == null ? "(no tag)" : entry.tag);
final File file = entry.getFile(mDropBoxDir);
if (file == null) {
out.append(" (no file)\n");
continue;
} else if ((entry.flags & DropBoxManager.IS_EMPTY) != 0) {
out.append(" (contents lost)\n");
continue;
} else {
out.append(" (");
if ((entry.flags & DropBoxManager.IS_GZIPPED) != 0) out.append("compressed ");
out.append((entry.flags & DropBoxManager.IS_TEXT) != 0 ? "text" : "data");
out.append(", ").append(file.length()).append(" bytes)\n");
}
if (doFile || (doPrint && (entry.flags & DropBoxManager.IS_TEXT) == 0)) {
if (!doPrint) out.append(" ");
out.append(file.getPath()).append("\n");
}
if ((entry.flags & DropBoxManager.IS_TEXT) != 0 && (doPrint || !doFile)) {
DropBoxManager.Entry dbe = null;
InputStreamReader isr = null;
try {
dbe = new DropBoxManager.Entry(
entry.tag, entry.timestampMillis, file, entry.flags);
if (doPrint) {
isr = new InputStreamReader(dbe.getInputStream());
char[] buf = new char[4096];
boolean newline = false;
for (;;) {
int n = isr.read(buf);
if (n <= 0) break;
out.append(buf, 0, n);
newline = (buf[n - 1] == '\n');
// Flush periodically when printing to avoid out-of-memory.
if (out.length() > 65536) {
pw.write(out.toString());
out.setLength(0);
}
}
if (!newline) out.append("\n");
} else {
String text = dbe.getText(70);
out.append(" ");
if (text == null) {
out.append("[null]");
} else {
boolean truncated = (text.length() == 70);
out.append(text.trim().replace('\n', '/'));
if (truncated) out.append(" ...");
}
out.append("\n");
}
} catch (IOException e) {
out.append("*** ").append(e.toString()).append("\n");
Slog.e(TAG, "Can't read: " + file, e);
} finally {
if (dbe != null) dbe.close();
if (isr != null) {
try {
isr.close();
} catch (IOException unused) {
}
}
}
}
if (doPrint) out.append("\n");
}
if (numFound == 0) out.append("(No entries found.)\n");
if (args == null || args.length == 0) {
if (!doPrint) out.append("\n");
out.append("Usage: dumpsys dropbox [--print|--file] [YYYY-mm-dd] [HH:MM:SS] [tag]\n");
}
pw.write(out.toString());
if (PROFILE_DUMP) Debug.stopMethodTracing();
}
private boolean matchEntry(EntryFile entry, ArrayList<String> searchArgs) {
String date = TimeMigrationUtils.formatMillisWithFixedFormat(entry.timestampMillis);
boolean match = true;
int numArgs = searchArgs.size();
for (int i = 0; i < numArgs && match; i++) {
String arg = searchArgs.get(i);
match = (date.contains(arg) || arg.equals(entry.tag));
}
return match;
}
private void dumpProtoLocked(FileDescriptor fd, ArrayList<String> searchArgs) {
final ProtoOutputStream proto = new ProtoOutputStream(fd);
for (EntryFile entry : mAllFiles.contents) {
if (!matchEntry(entry, searchArgs)) continue;
final File file = entry.getFile(mDropBoxDir);
if ((file == null) || ((entry.flags & DropBoxManager.IS_EMPTY) != 0)) {
continue;
}
final long bToken = proto.start(DropBoxManagerServiceDumpProto.ENTRIES);
proto.write(DropBoxManagerServiceDumpProto.Entry.TIME_MS, entry.timestampMillis);
try (
DropBoxManager.Entry dbe = new DropBoxManager.Entry(
entry.tag, entry.timestampMillis, file, entry.flags);
InputStream is = dbe.getInputStream();
) {
if (is != null) {
byte[] buf = new byte[PROTO_MAX_DATA_BYTES];
int readBytes = 0;
int n = 0;
while (n >= 0 && (readBytes += n) < PROTO_MAX_DATA_BYTES) {
n = is.read(buf, readBytes, PROTO_MAX_DATA_BYTES - readBytes);
}
proto.write(DropBoxManagerServiceDumpProto.Entry.DATA,
Arrays.copyOf(buf, readBytes));
}
} catch (IOException e) {
Slog.e(TAG, "Can't read: " + file, e);
}
proto.end(bToken);
}
proto.flush();
}
///////////////////////////////////////////////////////////////////////////
/** Chronologically sorted list of {@link EntryFile}
private static final class FileList implements Comparable<FileList> {
public int blocks = 0;
public final TreeSet<EntryFile> contents = new TreeSet<EntryFile>();
/** Sorts bigger FileList instances before smaller ones. | FileList::compareTo | java | Reginer/aosp-android-jar | android-32/src/com/android/server/DropBoxManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/DropBoxManagerService.java | MIT |
public final int compareTo(EntryFile o) {
int comp = Long.compare(timestampMillis, o.timestampMillis);
if (comp != 0) return comp;
comp = ObjectUtils.compare(tag, o.tag);
if (comp != 0) return comp;
comp = Integer.compare(flags, o.flags);
if (comp != 0) return comp;
return Integer.compare(hashCode(), o.hashCode());
} |
Metadata describing an on-disk log file.
Note its instances do no have knowledge on what directory they're stored, just to save
4/8 bytes per instance. Instead, {@link #getFile} takes a directory so it can build a
fullpath.
@VisibleForTesting
static final class EntryFile implements Comparable<EntryFile> {
public final String tag;
public final long timestampMillis;
public final int flags;
public final int blocks;
/** Sorts earlier EntryFile instances before later ones. | EntryFile::compareTo | java | Reginer/aosp-android-jar | android-32/src/com/android/server/DropBoxManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/DropBoxManagerService.java | MIT |
public EntryFile(File temp, File dir, String tag,long timestampMillis,
int flags, int blockSize) throws IOException {
if ((flags & DropBoxManager.IS_EMPTY) != 0) throw new IllegalArgumentException();
this.tag = TextUtils.safeIntern(tag);
this.timestampMillis = timestampMillis;
this.flags = flags;
final File file = this.getFile(dir);
if (!temp.renameTo(file)) {
throw new IOException("Can't rename " + temp + " to " + file);
}
this.blocks = (int) ((file.length() + blockSize - 1) / blockSize);
} |
Moves an existing temporary file to a new log filename.
@param temp file to rename
@param dir to store file in
@param tag to use for new log file name
@param timestampMillis of log entry
@param flags for the entry data
@param blockSize to use for space accounting
@throws IOException if the file can't be moved
| EntryFile::EntryFile | java | Reginer/aosp-android-jar | android-32/src/com/android/server/DropBoxManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/DropBoxManagerService.java | MIT |
public EntryFile(File dir, String tag, long timestampMillis) throws IOException {
this.tag = TextUtils.safeIntern(tag);
this.timestampMillis = timestampMillis;
this.flags = DropBoxManager.IS_EMPTY;
this.blocks = 0;
new FileOutputStream(getFile(dir)).close();
} |
Creates a zero-length tombstone for a file whose contents were lost.
@param dir to store file in
@param tag to use for new log file name
@param timestampMillis of log entry
@throws IOException if the file can't be created.
| EntryFile::EntryFile | java | Reginer/aosp-android-jar | android-32/src/com/android/server/DropBoxManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/DropBoxManagerService.java | MIT |
public EntryFile(File file, int blockSize) {
boolean parseFailure = false;
String name = file.getName();
int flags = 0;
String tag = null;
long millis = 0;
final int at = name.lastIndexOf('@');
if (at < 0) {
parseFailure = true;
} else {
tag = Uri.decode(name.substring(0, at));
if (name.endsWith(".gz")) {
flags |= DropBoxManager.IS_GZIPPED;
name = name.substring(0, name.length() - 3);
}
if (name.endsWith(".lost")) {
flags |= DropBoxManager.IS_EMPTY;
name = name.substring(at + 1, name.length() - 5);
} else if (name.endsWith(".txt")) {
flags |= DropBoxManager.IS_TEXT;
name = name.substring(at + 1, name.length() - 4);
} else if (name.endsWith(".dat")) {
name = name.substring(at + 1, name.length() - 4);
} else {
parseFailure = true;
}
if (!parseFailure) {
try {
millis = Long.parseLong(name);
} catch (NumberFormatException e) {
parseFailure = true;
}
}
}
if (parseFailure) {
Slog.wtf(TAG, "Invalid filename: " + file);
// Remove the file and return an empty instance.
file.delete();
this.tag = null;
this.flags = DropBoxManager.IS_EMPTY;
this.timestampMillis = 0;
this.blocks = 0;
return;
}
this.blocks = (int) ((file.length() + blockSize - 1) / blockSize);
this.tag = TextUtils.safeIntern(tag);
this.flags = flags;
this.timestampMillis = millis;
} |
Extracts metadata from an existing on-disk log filename.
Note when a filename is not recognizable, it will create an instance that
{@link #hasFile()} would return false on, and also remove the file.
@param file name of existing log file
@param blockSize to use for space accounting
| EntryFile::EntryFile | java | Reginer/aosp-android-jar | android-32/src/com/android/server/DropBoxManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/DropBoxManagerService.java | MIT |
public EntryFile(long millis) {
this.tag = null;
this.timestampMillis = millis;
this.flags = DropBoxManager.IS_EMPTY;
this.blocks = 0;
} |
Creates a EntryFile object with only a timestamp for comparison purposes.
@param millis to compare with.
| EntryFile::EntryFile | java | Reginer/aosp-android-jar | android-32/src/com/android/server/DropBoxManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/DropBoxManagerService.java | MIT |
public boolean hasFile() {
return tag != null;
} |
@return whether an entry actually has a backing file, or it's an empty "tombstone"
entry.
| EntryFile::hasFile | java | Reginer/aosp-android-jar | android-32/src/com/android/server/DropBoxManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/DropBoxManagerService.java | MIT |
private String getExtension() {
if ((flags & DropBoxManager.IS_EMPTY) != 0) {
return ".lost";
}
return ((flags & DropBoxManager.IS_TEXT) != 0 ? ".txt" : ".dat") +
((flags & DropBoxManager.IS_GZIPPED) != 0 ? ".gz" : "");
} |
@return whether an entry actually has a backing file, or it's an empty "tombstone"
entry.
public boolean hasFile() {
return tag != null;
}
/** @return File extension for the flags. | EntryFile::getExtension | java | Reginer/aosp-android-jar | android-32/src/com/android/server/DropBoxManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/DropBoxManagerService.java | MIT |
public String getFilename() {
return hasFile() ? Uri.encode(tag) + "@" + timestampMillis + getExtension() : null;
} |
@return filename for this entry without the pathname.
| EntryFile::getFilename | java | Reginer/aosp-android-jar | android-32/src/com/android/server/DropBoxManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/DropBoxManagerService.java | MIT |
public File getFile(File dir) {
return hasFile() ? new File(dir, getFilename()) : null;
} |
Get a full-path {@link File} representing this entry.
@param dir Parent directly. The caller needs to pass it because {@link EntryFile}s don't
know in which directory they're stored.
| EntryFile::getFile | java | Reginer/aosp-android-jar | android-32/src/com/android/server/DropBoxManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/DropBoxManagerService.java | MIT |
public void deleteFile(File dir) {
if (hasFile()) {
getFile(dir).delete();
}
} |
If an entry has a backing file, remove it.
| EntryFile::deleteFile | java | Reginer/aosp-android-jar | android-32/src/com/android/server/DropBoxManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/DropBoxManagerService.java | MIT |
protected PKIXCertPathChecker() {} |
Default constructor.
| PKIXCertPathChecker::PKIXCertPathChecker | java | Reginer/aosp-android-jar | android-33/src/java/security/cert/PKIXCertPathChecker.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/java/security/cert/PKIXCertPathChecker.java | MIT |
public V2Form(
ASN1Sequence seq)
{
if (seq.size() > 3)
{
throw new IllegalArgumentException("Bad sequence size: " + seq.size());
}
int index = 0;
if (!(seq.getObjectAt(0) instanceof ASN1TaggedObject))
{
index++;
this.issuerName = GeneralNames.getInstance(seq.getObjectAt(0));
}
for (int i = index; i != seq.size(); i++)
{
ASN1TaggedObject o = ASN1TaggedObject.getInstance(seq.getObjectAt(i));
if (o.getTagNo() == 0)
{
baseCertificateID = IssuerSerial.getInstance(o, false);
}
else if (o.getTagNo() == 1)
{
objectDigestInfo = ObjectDigestInfo.getInstance(o, false);
}
else
{
throw new IllegalArgumentException("Bad tag number: "
+ o.getTagNo());
}
}
} |
@deprecated use getInstance().
| V2Form::V2Form | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/org/bouncycastle/asn1/x509/V2Form.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/org/bouncycastle/asn1/x509/V2Form.java | MIT |
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector(3);
if (issuerName != null)
{
v.add(issuerName);
}
if (baseCertificateID != null)
{
v.add(new DERTaggedObject(false, 0, baseCertificateID));
}
if (objectDigestInfo != null)
{
v.add(new DERTaggedObject(false, 1, objectDigestInfo));
}
return new DERSequence(v);
} |
Produce an object suitable for an ASN1OutputStream.
<pre>
V2Form ::= SEQUENCE {
issuerName GeneralNames OPTIONAL,
baseCertificateID [0] IssuerSerial OPTIONAL,
objectDigestInfo [1] ObjectDigestInfo OPTIONAL
-- issuerName MUST be present in this profile
-- baseCertificateID and objectDigestInfo MUST NOT
-- be present in this profile
}
</pre>
| V2Form::toASN1Primitive | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/org/bouncycastle/asn1/x509/V2Form.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/org/bouncycastle/asn1/x509/V2Form.java | MIT |
public static AtSelectedVersion getSelectedVersion() {
try {
return new AtSelectedVersion(LENGTH, SUPPORTED_VERSION);
} catch (EapSimAkaInvalidAttributeException ex) {
// this should never happen
LOG.wtf(TAG,
"Error thrown while creating AtSelectedVersion with correct length", ex);
throw new AssertionError("Impossible exception encountered", ex);
}
} |
Constructs and returns an AtSelectedVersion for the only supported version of EAP-SIM
@return an AtSelectedVersion for the supported version (1) of EAP-SIM
| getSimpleName::getSelectedVersion | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/net/eap/message/simaka/EapSimAkaAttribute.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/net/eap/message/simaka/EapSimAkaAttribute.java | MIT |
public static AtIdentity getAtIdentity(byte[] identity)
throws EapSimAkaInvalidAttributeException {
int lengthInBytes = MIN_ATTR_LENGTH + identity.length;
if (lengthInBytes % LENGTH_SCALING != 0) {
lengthInBytes += LENGTH_SCALING - (lengthInBytes % LENGTH_SCALING);
}
return new AtIdentity(lengthInBytes, identity);
} |
Creates and returns an AtIdentity instance for the given identity.
@param identity byte-array representing the identity for the AtIdentity
@return AtIdentity instance for the given identity byte-array
| AtIdentity::getAtIdentity | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/net/eap/message/simaka/EapSimAkaAttribute.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/net/eap/message/simaka/EapSimAkaAttribute.java | MIT |
public AtMac getAtMacWithMacCleared() throws EapSimAkaInvalidAttributeException {
return new AtMac(reservedBytes, new byte[MAC_LENGTH]);
} |
Returns a copy of this AtMac with the MAC cleared (and the reserved bytes preserved).
<p>Per RFC 4186 Section 10.14, the MAC should be calculated over the entire packet, with
the value field of the MAC attribute set to zero.
| AtMac::getAtMacWithMacCleared | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/net/eap/message/simaka/EapSimAkaAttribute.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/net/eap/message/simaka/EapSimAkaAttribute.java | MIT |
public static AtRes getAtRes(byte[] res) throws EapSimAkaInvalidAttributeException {
// Attributes must be 4B-aligned, so there can be 0 to 3 padding bytes added
int resLenBytes = MIN_ATTR_LENGTH + res.length;
if (resLenBytes % LENGTH_SCALING != 0) {
resLenBytes += LENGTH_SCALING - (resLenBytes % LENGTH_SCALING);
}
return new AtRes(resLenBytes, res);
} |
Creates and returns an AtRes instance with the given res value.
@param res byte-array RES value to be used for this
@return AtRes instance for the given RES value
@throws EapSimAkaInvalidAttributeException if the given res value has an invalid length
| AtRes::getAtRes | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/net/eap/message/simaka/EapSimAkaAttribute.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/net/eap/message/simaka/EapSimAkaAttribute.java | MIT |
public static boolean isValidResLen(int resLenBytes) {
return resLenBytes >= MIN_RES_LEN_BYTES && resLenBytes <= MAX_RES_LEN_BYTES;
} |
Checks whether the given RES length is valid.
@param resLenBytes the RES length to be checked
@return true iff the given resLen is valid
| AtRes::isValidResLen | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/net/eap/message/simaka/EapSimAkaAttribute.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/net/eap/message/simaka/EapSimAkaAttribute.java | MIT |
public byte[] getDecryptedData(byte[] key, byte[] iv)
throws EapSimAkaInvalidAttributeException {
byte[] decryptedEncr = doCipherOperation(encrData, key, iv, Cipher.DECRYPT_MODE);
return decryptedEncr;
} |
getDecryptedData returns decrypted data of AT_ENCR_DATA.
@param key K_encr with byte array
@parma iv IV from AT_IV
@return decrypted data with byte array
| AtEncrData::getDecryptedData | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/net/eap/message/simaka/EapSimAkaAttribute.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/net/eap/message/simaka/EapSimAkaAttribute.java | MIT |
public Drawable getIcon() {
return mIcon;
} |
Gets the drawable for the icon of app entity.
@return the drawable for the icon of app entity.
| AppEntityInfo::getIcon | java | Reginer/aosp-android-jar | android-34/src/com/android/settingslib/widget/AppEntityInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/settingslib/widget/AppEntityInfo.java | MIT |
public CharSequence getTitle() {
return mTitle;
} |
Gets the text for the title of app enitity.
@return the text for the title of app enitity.
| AppEntityInfo::getTitle | java | Reginer/aosp-android-jar | android-34/src/com/android/settingslib/widget/AppEntityInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/settingslib/widget/AppEntityInfo.java | MIT |
public CharSequence getSummary() {
return mSummary;
} |
Gets the text for the summary of app enitity.
@return the text for the summary of app enitity.
| AppEntityInfo::getSummary | java | Reginer/aosp-android-jar | android-34/src/com/android/settingslib/widget/AppEntityInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/settingslib/widget/AppEntityInfo.java | MIT |
public View.OnClickListener getClickListener() {
return mClickListener;
} |
Gets the click listener for the app entity view.
@return click listener for the app entity view.
| AppEntityInfo::getClickListener | java | Reginer/aosp-android-jar | android-34/src/com/android/settingslib/widget/AppEntityInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/settingslib/widget/AppEntityInfo.java | MIT |
public AppEntityInfo build() {
return new AppEntityInfo(this);
} |
Creates an instance of a {@link AppEntityInfo} based on the current builder settings.
@return The {@link AppEntityInfo}.
| Builder::build | java | Reginer/aosp-android-jar | android-34/src/com/android/settingslib/widget/AppEntityInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/settingslib/widget/AppEntityInfo.java | MIT |
public Builder setIcon(@NonNull Drawable icon) {
mIcon = icon;
return this;
} |
Sets the drawable for the icon.
| Builder::setIcon | java | Reginer/aosp-android-jar | android-34/src/com/android/settingslib/widget/AppEntityInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/settingslib/widget/AppEntityInfo.java | MIT |
public Builder setTitle(@Nullable CharSequence title) {
mTitle = title;
return this;
} |
Sets the text for the title.
| Builder::setTitle | java | Reginer/aosp-android-jar | android-34/src/com/android/settingslib/widget/AppEntityInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/settingslib/widget/AppEntityInfo.java | MIT |
public Builder setSummary(@Nullable CharSequence summary) {
mSummary = summary;
return this;
} |
Sets the text for the summary.
| Builder::setSummary | java | Reginer/aosp-android-jar | android-34/src/com/android/settingslib/widget/AppEntityInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/settingslib/widget/AppEntityInfo.java | MIT |
public Builder setOnClickListener(@Nullable View.OnClickListener clickListener) {
mClickListener = clickListener;
return this;
} |
Sets the click listener for app entity view.
| Builder::setOnClickListener | java | Reginer/aosp-android-jar | android-34/src/com/android/settingslib/widget/AppEntityInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/settingslib/widget/AppEntityInfo.java | MIT |
public CursorLoader(Context context) {
super(context);
mObserver = new ForceLoadContentObserver();
} |
Creates an empty unspecified CursorLoader. You must follow this with
calls to {@link #setUri(Uri)}, {@link #setSelection(String)}, etc
to specify the query to perform.
| CursorLoader::CursorLoader | java | Reginer/aosp-android-jar | android-31/src/android/content/CursorLoader.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/content/CursorLoader.java | MIT |
public CursorLoader(Context context, Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
super(context);
mObserver = new ForceLoadContentObserver();
mUri = uri;
mProjection = projection;
mSelection = selection;
mSelectionArgs = selectionArgs;
mSortOrder = sortOrder;
} |
Creates a fully-specified CursorLoader. See
{@link ContentResolver#query(Uri, String[], String, String[], String)
ContentResolver.query()} for documentation on the meaning of the
parameters. These will be passed as-is to that call.
| CursorLoader::CursorLoader | java | Reginer/aosp-android-jar | android-31/src/android/content/CursorLoader.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/content/CursorLoader.java | MIT |
public static android.se.omapi.ISecureElementReader asInterface(android.os.IBinder obj)
{
if ((obj==null)) {
return null;
}
android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
if (((iin!=null)&&(iin instanceof android.se.omapi.ISecureElementReader))) {
return ((android.se.omapi.ISecureElementReader)iin);
}
return new android.se.omapi.ISecureElementReader.Stub.Proxy(obj);
} |
Cast an IBinder object into an android.se.omapi.ISecureElementReader interface,
generating a proxy if needed.
| Stub::asInterface | java | Reginer/aosp-android-jar | android-35/src/android/se/omapi/ISecureElementReader.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/se/omapi/ISecureElementReader.java | MIT |
public X9FieldID(BigInteger primeP)
{
this.id = prime_field;
this.parameters = new ASN1Integer(primeP);
} |
Constructor for elliptic curves over prime fields
<code>F<sub>2</sub></code>.
@param primeP The prime <code>p</code> defining the prime field.
| X9FieldID::X9FieldID | java | Reginer/aosp-android-jar | android-35/src/com/android/org/bouncycastle/asn1/x9/X9FieldID.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/org/bouncycastle/asn1/x9/X9FieldID.java | MIT |
public X9FieldID(int m, int k1)
{
this(m, k1, 0, 0);
} |
Constructor for elliptic curves over binary fields
<code>F<sub>2<sup>m</sup></sub></code>.
@param m The exponent <code>m</code> of
<code>F<sub>2<sup>m</sup></sub></code>.
@param k1 The integer <code>k1</code> where <code>x<sup>m</sup> +
x<sup>k1</sup> + 1</code>
represents the reduction polynomial <code>f(z)</code>.
| X9FieldID::X9FieldID | java | Reginer/aosp-android-jar | android-35/src/com/android/org/bouncycastle/asn1/x9/X9FieldID.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/org/bouncycastle/asn1/x9/X9FieldID.java | MIT |
public X9FieldID(int m, int k1, int k2, int k3)
{
this.id = characteristic_two_field;
ASN1EncodableVector fieldIdParams = new ASN1EncodableVector(3);
fieldIdParams.add(new ASN1Integer(m));
if (k2 == 0)
{
if (k3 != 0)
{
throw new IllegalArgumentException("inconsistent k values");
}
fieldIdParams.add(tpBasis);
fieldIdParams.add(new ASN1Integer(k1));
}
else
{
if (k2 <= k1 || k3 <= k2)
{
throw new IllegalArgumentException("inconsistent k values");
}
fieldIdParams.add(ppBasis);
ASN1EncodableVector pentanomialParams = new ASN1EncodableVector(3);
pentanomialParams.add(new ASN1Integer(k1));
pentanomialParams.add(new ASN1Integer(k2));
pentanomialParams.add(new ASN1Integer(k3));
fieldIdParams.add(new DERSequence(pentanomialParams));
}
this.parameters = new DERSequence(fieldIdParams);
} |
Constructor for elliptic curves over binary fields
<code>F<sub>2<sup>m</sup></sub></code>.
@param m The exponent <code>m</code> of
<code>F<sub>2<sup>m</sup></sub></code>.
@param k1 The integer <code>k1</code> where <code>x<sup>m</sup> +
x<sup>k3</sup> + x<sup>k2</sup> + x<sup>k1</sup> + 1</code>
represents the reduction polynomial <code>f(z)</code>.
@param k2 The integer <code>k2</code> where <code>x<sup>m</sup> +
x<sup>k3</sup> + x<sup>k2</sup> + x<sup>k1</sup> + 1</code>
represents the reduction polynomial <code>f(z)</code>.
@param k3 The integer <code>k3</code> where <code>x<sup>m</sup> +
x<sup>k3</sup> + x<sup>k2</sup> + x<sup>k1</sup> + 1</code>
represents the reduction polynomial <code>f(z)</code>..
| X9FieldID::X9FieldID | java | Reginer/aosp-android-jar | android-35/src/com/android/org/bouncycastle/asn1/x9/X9FieldID.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/org/bouncycastle/asn1/x9/X9FieldID.java | MIT |
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector(2);
v.add(this.id);
v.add(this.parameters);
return new DERSequence(v);
} |
Produce a DER encoding of the following structure.
<pre>
FieldID ::= SEQUENCE {
fieldType FIELD-ID.&id({IOSet}),
parameters FIELD-ID.&Type({IOSet}{@fieldType})
}
</pre>
| X9FieldID::toASN1Primitive | java | Reginer/aosp-android-jar | android-35/src/com/android/org/bouncycastle/asn1/x9/X9FieldID.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/org/bouncycastle/asn1/x9/X9FieldID.java | MIT |
static int getDefaultDisplayDensity(int displayId) {
try {
final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
return wm.getInitialDisplayDensity(displayId);
} catch (RemoteException exc) {
return -1;
}
} |
Returns the default density for the specified display.
@param displayId the identifier of the display
@return the default density of the specified display, or {@code -1} if the display does not
exist or the density could not be obtained
| DisplayDensityConfiguration::getDefaultDisplayDensity | java | Reginer/aosp-android-jar | android-34/src/com/android/settingslib/display/DisplayDensityConfiguration.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/settingslib/display/DisplayDensityConfiguration.java | MIT |
public static void clearForcedDisplayDensity(final int displayId) {
final int userId = UserHandle.myUserId();
AsyncTask.execute(
() -> {
try {
final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
wm.clearForcedDisplayDensityForUser(displayId, userId);
} catch (RemoteException exc) {
Log.w(LOG_TAG, "Unable to clear forced display density setting");
}
});
} |
Asynchronously applies display density changes to the specified display.
<p>The change will be applied to the user specified by the value of {@link
UserHandle#myUserId()} at the time the method is called.
@param displayId the identifier of the display to modify
| DisplayDensityConfiguration::clearForcedDisplayDensity | java | Reginer/aosp-android-jar | android-34/src/com/android/settingslib/display/DisplayDensityConfiguration.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/settingslib/display/DisplayDensityConfiguration.java | MIT |
public static void setForcedDisplayDensity(final int displayId, final int density) {
final int userId = UserHandle.myUserId();
AsyncTask.execute(
() -> {
try {
final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
wm.setForcedDisplayDensityForUser(displayId, density, userId);
} catch (RemoteException exc) {
Log.w(LOG_TAG, "Unable to save forced display density setting");
}
});
} |
Asynchronously applies display density changes to the specified display.
<p>The change will be applied to the user specified by the value of {@link
UserHandle#myUserId()} at the time the method is called.
@param displayId the identifier of the display to modify
@param density the density to force for the specified display
| DisplayDensityConfiguration::setForcedDisplayDensity | java | Reginer/aosp-android-jar | android-34/src/com/android/settingslib/display/DisplayDensityConfiguration.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/settingslib/display/DisplayDensityConfiguration.java | MIT |
@NonNull default Rect onComputeScrollBounds(@NonNull V view) {
Rect bounds = new Rect(0, 0, view.getWidth(), view.getHeight());
if (view instanceof ViewGroup && ((ViewGroup) view).getClipToPadding()) {
bounds.inset(view.getPaddingLeft(), view.getPaddingTop(),
view.getPaddingRight(), view.getPaddingBottom());
}
return bounds;
} |
Given a scroll capture request for a view, adjust the provided rect to cover the scrollable
content area. The default implementation returns the padded content area of {@code view}.
@param view the view being captured
| ScrollResult::onComputeScrollBounds | java | Reginer/aosp-android-jar | android-33/src/com/android/internal/view/ScrollCaptureViewHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/view/ScrollCaptureViewHelper.java | MIT |
public void updateTracker(long frameNumber, boolean isError, int requestType) {
if (isError) {
mFutureErrorMap.put(frameNumber, requestType);
} else {
try {
updateCompletedFrameNumber(frameNumber, requestType);
} catch (IllegalArgumentException e) {
Log.e(TAG, e.getMessage());
}
}
update();
} |
This function is called every time when a result or an error is received.
@param frameNumber the frame number corresponding to the result or error
@param isError true if it is an error, false if it is not an error
@param requestType the type of capture request: Reprocess, ZslStill, or Regular.
| FrameNumberTracker::updateTracker | java | Reginer/aosp-android-jar | android-34/src/android/hardware/camera2/impl/FrameNumberTracker.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/hardware/camera2/impl/FrameNumberTracker.java | MIT |
public void updateTracker(long frameNumber, CaptureResult result, boolean partial,
int requestType) {
if (!partial) {
// Update the total result's frame status as being successful
updateTracker(frameNumber, /*isError*/false, requestType);
// Don't keep a list of total results, we don't need to track them
return;
}
if (result == null) {
// Do not record blank results; this also means there will be no total result
// so it doesn't matter that the partials were not recorded
return;
}
// Partial results must be aggregated in-order for that frame number
List<CaptureResult> partials = mPartialResults.get(frameNumber);
if (partials == null) {
partials = new ArrayList<>();
mPartialResults.put(frameNumber, partials);
}
partials.add(result);
} |
This function is called every time a result has been completed.
<p>It keeps a track of all the partial results already created for a particular
frame number.</p>
@param frameNumber the frame number corresponding to the result
@param result the total or partial result
@param partial {@true} if the result is partial, {@code false} if total
@param requestType the type of capture request: Reprocess, ZslStill, or Regular.
| FrameNumberTracker::updateTracker | java | Reginer/aosp-android-jar | android-34/src/android/hardware/camera2/impl/FrameNumberTracker.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/hardware/camera2/impl/FrameNumberTracker.java | MIT |
public List<CaptureResult> popPartialResults(long frameNumber) {
return mPartialResults.remove(frameNumber);
} |
Attempt to pop off all of the partial results seen so far for the {@code frameNumber}.
<p>Once popped-off, the partial results are forgotten (unless {@code updateTracker}
is called again with new partials for that frame number).</p>
@param frameNumber the frame number corresponding to the result
@return a list of partial results for that frame with at least 1 element,
or {@code null} if there were no partials recorded for that frame
| FrameNumberTracker::popPartialResults | java | Reginer/aosp-android-jar | android-34/src/android/hardware/camera2/impl/FrameNumberTracker.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/hardware/camera2/impl/FrameNumberTracker.java | MIT |
private void updateCompletedFrameNumber(long frameNumber,
int requestType) throws IllegalArgumentException {
if (frameNumber <= mCompletedFrameNumber[requestType]) {
throw new IllegalArgumentException("frame number " + frameNumber + " is a repeat");
}
// Assume there are only 3 different types of capture requests.
int otherType1 = (requestType + 1) % CaptureRequest.REQUEST_TYPE_COUNT;
int otherType2 = (requestType + 2) % CaptureRequest.REQUEST_TYPE_COUNT;
long maxOtherFrameNumberSeen =
Math.max(mCompletedFrameNumber[otherType1], mCompletedFrameNumber[otherType2]);
if (frameNumber < maxOtherFrameNumberSeen) {
// if frame number is smaller than completed frame numbers of other categories,
// it must be:
// - the head of mPendingFrameNumbers for this category, or
// - in one of other mPendingFrameNumbersWithOtherType
if (!mPendingFrameNumbers[requestType].isEmpty()) {
// frame number must be head of current type of mPendingFrameNumbers if
// mPendingFrameNumbers isn't empty.
Long pendingFrameNumberSameType = mPendingFrameNumbers[requestType].element();
if (frameNumber == pendingFrameNumberSameType) {
// frame number matches the head of the pending frame number queue.
// Do this before the inequality checks since this is likely to be the common
// case.
mPendingFrameNumbers[requestType].remove();
} else if (frameNumber < pendingFrameNumberSameType) {
throw new IllegalArgumentException("frame number " + frameNumber
+ " is a repeat");
} else {
throw new IllegalArgumentException("frame number " + frameNumber
+ " comes out of order. Expecting "
+ pendingFrameNumberSameType);
}
} else {
// frame number must be in one of the other mPendingFrameNumbersWithOtherType.
int index1 = mPendingFrameNumbersWithOtherType[otherType1].indexOf(frameNumber);
int index2 = mPendingFrameNumbersWithOtherType[otherType2].indexOf(frameNumber);
boolean inSkippedOther1 = index1 != -1;
boolean inSkippedOther2 = index2 != -1;
if (!(inSkippedOther1 ^ inSkippedOther2)) {
throw new IllegalArgumentException("frame number " + frameNumber
+ " is a repeat or invalid");
}
// We know the category of frame numbers in pendingFrameNumbersWithOtherType leading
// up to the current frame number. The destination is the type which isn't the
// requestType* and isn't the src. Move them into the correct pendingFrameNumbers.
// * : This is since frameNumber is the first frame of requestType that we've
// received in the 'others' list, since for each request type frames come in order.
// All the frames before frameNumber are of the same type. They're not of
// 'requestType', neither of the type of the 'others' list they were found in. The
// remaining option is the 3rd type.
LinkedList<Long> srcList, dstList;
int index;
if (inSkippedOther1) {
srcList = mPendingFrameNumbersWithOtherType[otherType1];
dstList = mPendingFrameNumbers[otherType2];
index = index1;
} else {
srcList = mPendingFrameNumbersWithOtherType[otherType2];
dstList = mPendingFrameNumbers[otherType1];
index = index2;
}
for (int i = 0; i < index; i++) {
dstList.add(srcList.removeFirst());
}
// Remove current frame number from pendingFrameNumbersWithOtherType
srcList.remove();
}
} else {
// there is a gap of unseen frame numbers which should belong to the other
// 2 categories. Put all the pending frame numbers in the queue.
for (long i =
Math.max(maxOtherFrameNumberSeen, mCompletedFrameNumber[requestType]) + 1;
i < frameNumber; i++) {
mPendingFrameNumbersWithOtherType[requestType].add(i);
}
}
mCompletedFrameNumber[requestType] = frameNumber;
} |
Update the completed frame number for results of 3 categories
(Regular/Reprocess/ZslStill).
It validates that all previous frames of the same category have arrived.
If there is a gap since previous frame number of the same category, assume the frames in
the gap are other categories and store them in the pending frame number queue to check
against when frames of those categories arrive.
| FrameNumberTracker::updateCompletedFrameNumber | java | Reginer/aosp-android-jar | android-34/src/android/hardware/camera2/impl/FrameNumberTracker.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/hardware/camera2/impl/FrameNumberTracker.java | MIT |
public AbsoluteFileBackupHelper(Context context, String... files) {
super(context);
mContext = context;
mFiles = files;
} |
Construct a helper for backing up / restoring the files at the given absolute locations
within the file system.
@param context
@param files
| AbsoluteFileBackupHelper::AbsoluteFileBackupHelper | java | Reginer/aosp-android-jar | android-31/src/android/app/backup/AbsoluteFileBackupHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/backup/AbsoluteFileBackupHelper.java | MIT |
public void performBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
ParcelFileDescriptor newState) {
// use the file paths as the keys, too
performBackup_checked(oldState, data, newState, mFiles, mFiles);
} |
Based on oldState, determine which of the files from the application's data directory
need to be backed up, write them to the data stream, and fill in newState with the
state as it exists now.
| AbsoluteFileBackupHelper::performBackup | java | Reginer/aosp-android-jar | android-31/src/android/app/backup/AbsoluteFileBackupHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/backup/AbsoluteFileBackupHelper.java | MIT |
public void restoreEntity(BackupDataInputStream data) {
if (DEBUG) Log.d(TAG, "got entity '" + data.getKey() + "' size=" + data.size());
String key = data.getKey();
if (isKeyInList(key, mFiles)) {
File f = new File(key);
writeFile(f, data);
}
} |
Restore one absolute file entity from the restore stream
| AbsoluteFileBackupHelper::restoreEntity | java | Reginer/aosp-android-jar | android-31/src/android/app/backup/AbsoluteFileBackupHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/backup/AbsoluteFileBackupHelper.java | MIT |
private PropertyValuesHolder(Property property) {
mProperty = property;
if (property != null) {
mPropertyName = property.getName();
}
} |
Internal utility constructor, used by the factory methods to set the property.
@param property The property for this holder.
| Double::PropertyValuesHolder | java | Reginer/aosp-android-jar | android-33/src/android/animation/PropertyValuesHolder.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/animation/PropertyValuesHolder.java | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.