code
stringlengths
11
173k
docstring
stringlengths
2
593k
func_name
stringlengths
2
189
language
stringclasses
1 value
repo
stringclasses
844 values
path
stringlengths
11
294
url
stringlengths
60
339
license
stringclasses
4 values
List<MediaDevice> getSelectableMediaDevice() { final List<MediaDevice> deviceList = new ArrayList<>(); if (TextUtils.isEmpty(mPackageName)) { Log.w(TAG, "getSelectableMediaDevice() package name is null or empty!"); return deviceList; } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { for (MediaRoute2Info route : mRouterManager.getSelectableRoutes(info)) { deviceList.add(new InfoMediaDevice(mContext, mRouterManager, route, mPackageName)); } return deviceList; } Log.w(TAG, "getSelectableMediaDevice() cannot found selectable MediaDevice from : " + mPackageName); return deviceList; }
Get the MediaDevice list that can be added to current media. @return list of MediaDevice
InfoMediaManager::getSelectableMediaDevice
java
Reginer/aosp-android-jar
android-33/src/com/android/settingslib/media/InfoMediaManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/media/InfoMediaManager.java
MIT
List<MediaDevice> getDeselectableMediaDevice() { final List<MediaDevice> deviceList = new ArrayList<>(); if (TextUtils.isEmpty(mPackageName)) { Log.d(TAG, "getDeselectableMediaDevice() package name is null or empty!"); return deviceList; } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { for (MediaRoute2Info route : mRouterManager.getDeselectableRoutes(info)) { deviceList.add(new InfoMediaDevice(mContext, mRouterManager, route, mPackageName)); Log.d(TAG, route.getName() + " is deselectable for " + mPackageName); } return deviceList; } Log.d(TAG, "getDeselectableMediaDevice() cannot found deselectable MediaDevice from : " + mPackageName); return deviceList; }
Get the MediaDevice list that can be removed from current media session. @return list of MediaDevice
InfoMediaManager::getDeselectableMediaDevice
java
Reginer/aosp-android-jar
android-33/src/com/android/settingslib/media/InfoMediaManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/media/InfoMediaManager.java
MIT
List<MediaDevice> getSelectedMediaDevice() { final List<MediaDevice> deviceList = new ArrayList<>(); if (TextUtils.isEmpty(mPackageName)) { Log.w(TAG, "getSelectedMediaDevice() package name is null or empty!"); return deviceList; } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { for (MediaRoute2Info route : mRouterManager.getSelectedRoutes(info)) { deviceList.add(new InfoMediaDevice(mContext, mRouterManager, route, mPackageName)); } return deviceList; } Log.w(TAG, "getSelectedMediaDevice() cannot found selectable MediaDevice from : " + mPackageName); return deviceList; }
Get the MediaDevice list that has been selected to current media. @return list of MediaDevice
InfoMediaManager::getSelectedMediaDevice
java
Reginer/aosp-android-jar
android-33/src/com/android/settingslib/media/InfoMediaManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/media/InfoMediaManager.java
MIT
void adjustSessionVolume(int volume) { if (TextUtils.isEmpty(mPackageName)) { Log.w(TAG, "adjustSessionVolume() package name is null or empty!"); return; } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { Log.d(TAG, "adjustSessionVolume() adjust volume : " + volume + ", with : " + mPackageName); mRouterManager.setSessionVolume(info, volume); return; } Log.w(TAG, "adjustSessionVolume() can't found corresponding RoutingSession with : " + mPackageName); }
Adjust the volume of {@link android.media.RoutingSessionInfo}. @param volume the value of volume
InfoMediaManager::adjustSessionVolume
java
Reginer/aosp-android-jar
android-33/src/com/android/settingslib/media/InfoMediaManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/media/InfoMediaManager.java
MIT
public int getSessionVolumeMax() { if (TextUtils.isEmpty(mPackageName)) { Log.w(TAG, "getSessionVolumeMax() package name is null or empty!"); return -1; } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { return info.getVolumeMax(); } Log.w(TAG, "getSessionVolumeMax() can't found corresponding RoutingSession with : " + mPackageName); return -1; }
Gets the maximum volume of the {@link android.media.RoutingSessionInfo}. @return maximum volume of the session, and return -1 if not found.
InfoMediaManager::getSessionVolumeMax
java
Reginer/aosp-android-jar
android-33/src/com/android/settingslib/media/InfoMediaManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/media/InfoMediaManager.java
MIT
public int getSessionVolume() { if (TextUtils.isEmpty(mPackageName)) { Log.w(TAG, "getSessionVolume() package name is null or empty!"); return -1; } final RoutingSessionInfo info = getRoutingSessionInfo(); if (info != null) { return info.getVolume(); } Log.w(TAG, "getSessionVolume() can't found corresponding RoutingSession with : " + mPackageName); return -1; }
Gets the current volume of the {@link android.media.RoutingSessionInfo}. @return current volume of the session, and return -1 if not found.
InfoMediaManager::getSessionVolume
java
Reginer/aosp-android-jar
android-33/src/com/android/settingslib/media/InfoMediaManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/settingslib/media/InfoMediaManager.java
MIT
public static List<String> getAllCodePaths(AndroidPackage aPkg) { PackageImpl pkg = (PackageImpl) aPkg; ArrayList<String> paths = new ArrayList<>(); paths.add(pkg.getBaseApkPath()); String[] splitCodePaths = pkg.getSplitCodePaths(); if (!ArrayUtils.isEmpty(splitCodePaths)) { Collections.addAll(paths, splitCodePaths); } return paths; }
@return a list of the base and split code paths.
AndroidPackageUtils::getAllCodePaths
java
Reginer/aosp-android-jar
android-34/src/com/android/server/pm/parsing/pkg/AndroidPackageUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/pm/parsing/pkg/AndroidPackageUtils.java
MIT
public static Map<String, String> getPackageDexMetadata(AndroidPackage pkg) { return DexMetadataHelper.buildPackageApkToDexMetadataMap (AndroidPackageUtils.getAllCodePaths(pkg)); }
Return the dex metadata files for the given package as a map [code path -> dex metadata path]. NOTE: involves I/O checks.
AndroidPackageUtils::getPackageDexMetadata
java
Reginer/aosp-android-jar
android-34/src/com/android/server/pm/parsing/pkg/AndroidPackageUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/pm/parsing/pkg/AndroidPackageUtils.java
MIT
public static void validatePackageDexMetadata(AndroidPackage pkg) throws PackageManagerException { Collection<String> apkToDexMetadataList = getPackageDexMetadata(pkg).values(); String packageName = pkg.getPackageName(); long versionCode = pkg.getLongVersionCode(); final ParseTypeImpl input = ParseTypeImpl.forDefaultParsing(); for (String dexMetadata : apkToDexMetadataList) { final ParseResult result = DexMetadataHelper.validateDexMetadataFile( input.reset(), dexMetadata, packageName, versionCode); if (result.isError()) { throw new PackageManagerException( result.getErrorCode(), result.getErrorMessage(), result.getException()); } } }
Validate the dex metadata files installed for the given package. @throws PackageManagerException in case of errors.
AndroidPackageUtils::validatePackageDexMetadata
java
Reginer/aosp-android-jar
android-34/src/com/android/server/pm/parsing/pkg/AndroidPackageUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/pm/parsing/pkg/AndroidPackageUtils.java
MIT
public static boolean isMatchForSystemOnly(@NonNull PackageState packageState, long flags) { if ((flags & PackageManager.MATCH_SYSTEM_ONLY) != 0) { return packageState.isSystem(); } return true; }
Returns false iff the provided flags include the {@link PackageManager#MATCH_SYSTEM_ONLY} flag and the provided package is not a system package. Otherwise returns {@code true}.
AndroidPackageUtils::isMatchForSystemOnly
java
Reginer/aosp-android-jar
android-34/src/com/android/server/pm/parsing/pkg/AndroidPackageUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/pm/parsing/pkg/AndroidPackageUtils.java
MIT
public static String getRawPrimaryCpuAbi(AndroidPackage pkg) { return ((AndroidPackageHidden) pkg).getPrimaryCpuAbi(); }
Returns the primary ABI as parsed from the package. Used only during parsing and derivation. Otherwise prefer {@link PackageState#getPrimaryCpuAbi()}.
AndroidPackageUtils::getRawPrimaryCpuAbi
java
Reginer/aosp-android-jar
android-34/src/com/android/server/pm/parsing/pkg/AndroidPackageUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/pm/parsing/pkg/AndroidPackageUtils.java
MIT
public static String getRawSecondaryCpuAbi(@NonNull AndroidPackage pkg) { return ((AndroidPackageHidden) pkg).getSecondaryCpuAbi(); }
Returns the secondary ABI as parsed from the package. Used only during parsing and derivation. Otherwise prefer {@link PackageState#getSecondaryCpuAbi()}.
AndroidPackageUtils::getRawSecondaryCpuAbi
java
Reginer/aosp-android-jar
android-34/src/com/android/server/pm/parsing/pkg/AndroidPackageUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/pm/parsing/pkg/AndroidPackageUtils.java
MIT
public VcnUnderlyingNetworkSpecifier(@NonNull int[] subIds) { mSubIds = Objects.requireNonNull(subIds, "subIds were null"); }
Builds a new VcnUnderlyingNetworkSpecifier with the given list of subIds @hide
VcnUnderlyingNetworkSpecifier::VcnUnderlyingNetworkSpecifier
java
Reginer/aosp-android-jar
android-31/src/android/net/vcn/VcnUnderlyingNetworkSpecifier.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/net/vcn/VcnUnderlyingNetworkSpecifier.java
MIT
public SparseDoubleArray() { this(10); }
The int->double map, but storing the doubles as longs using {@link Double#doubleToRawLongBits(double)}. private SparseLongArray mValues; /** Creates a new SparseDoubleArray containing no mappings.
SparseDoubleArray::SparseDoubleArray
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 SparseDoubleArray(int initialCapacity) { mValues = new SparseLongArray(initialCapacity); }
Creates a new SparseDoubleArray, containing no mappings, that will not require any additional memory allocation to store the specified number of mappings. If you supply an initial capacity of 0, the sparse array will be initialized with a light-weight representation not requiring any additional array allocations.
SparseDoubleArray::SparseDoubleArray
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 get(int key) { return get(key, 0); }
Gets the double mapped from the specified key, or <code>0</code> 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 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 elementcreatenewattribute(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { super(factory); // // check if loaded documents are supported for content type // String contentType = getContentType(); preload(contentType, "staff", true); }
Constructor. @param factory document factory, may not be null @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
elementcreatenewattribute::elementcreatenewattribute
java
Reginer/aosp-android-jar
android-31/src/org/w3c/domts/level1/core/elementcreatenewattribute.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/org/w3c/domts/level1/core/elementcreatenewattribute.java
MIT