code
stringlengths
11
173k
docstring
stringlengths
2
593k
func_name
stringlengths
2
189
language
stringclasses
1 value
repo
stringclasses
844 values
path
stringlengths
11
294
url
stringlengths
60
339
license
stringclasses
4 values
public void setWorkSource(WorkSource ws) { synchronized (mToken) { if (ws != null && ws.isEmpty()) { ws = null; } final boolean changed; if (ws == null) { changed = mWorkSource != null; mWorkSource = null; } else if (mWorkSource == null) { changed = true; mWorkSource = new WorkSource(ws); } else { changed = !mWorkSource.equals(ws); if (changed) { mWorkSource.set(ws); } } if (changed && mHeld) { try { mService.updateWakeLockWorkSource(mToken, mWorkSource, mHistoryTag); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } }
Sets the work source associated with the wake lock. <p> The work source is used to determine on behalf of which application the wake lock is being held. This is useful in the case where a service is performing work on behalf of an application so that the cost of that work can be accounted to the application. </p> <p> Make sure to follow the tag naming convention when using WorkSource to make it easier for app developers to understand wake locks attributed to them. See {@link PowerManager#newWakeLock(int, String)} documentation. </p> @param ws The work source, or null if none.
WakeLock::setWorkSource
java
Reginer/aosp-android-jar
android-32/src/android/os/PowerManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/os/PowerManager.java
MIT
public void setTag(String tag) { mTag = tag; }
Sets the work source associated with the wake lock. <p> The work source is used to determine on behalf of which application the wake lock is being held. This is useful in the case where a service is performing work on behalf of an application so that the cost of that work can be accounted to the application. </p> <p> Make sure to follow the tag naming convention when using WorkSource to make it easier for app developers to understand wake locks attributed to them. See {@link PowerManager#newWakeLock(int, String)} documentation. </p> @param ws The work source, or null if none. public void setWorkSource(WorkSource ws) { synchronized (mToken) { if (ws != null && ws.isEmpty()) { ws = null; } final boolean changed; if (ws == null) { changed = mWorkSource != null; mWorkSource = null; } else if (mWorkSource == null) { changed = true; mWorkSource = new WorkSource(ws); } else { changed = !mWorkSource.equals(ws); if (changed) { mWorkSource.set(ws); } } if (changed && mHeld) { try { mService.updateWakeLockWorkSource(mToken, mWorkSource, mHistoryTag); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } } /** @hide
WakeLock::setTag
java
Reginer/aosp-android-jar
android-32/src/android/os/PowerManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/os/PowerManager.java
MIT
public String getTag() { return mTag; }
Sets the work source associated with the wake lock. <p> The work source is used to determine on behalf of which application the wake lock is being held. This is useful in the case where a service is performing work on behalf of an application so that the cost of that work can be accounted to the application. </p> <p> Make sure to follow the tag naming convention when using WorkSource to make it easier for app developers to understand wake locks attributed to them. See {@link PowerManager#newWakeLock(int, String)} documentation. </p> @param ws The work source, or null if none. public void setWorkSource(WorkSource ws) { synchronized (mToken) { if (ws != null && ws.isEmpty()) { ws = null; } final boolean changed; if (ws == null) { changed = mWorkSource != null; mWorkSource = null; } else if (mWorkSource == null) { changed = true; mWorkSource = new WorkSource(ws); } else { changed = !mWorkSource.equals(ws); if (changed) { mWorkSource.set(ws); } } if (changed && mHeld) { try { mService.updateWakeLockWorkSource(mToken, mWorkSource, mHistoryTag); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } } /** @hide public void setTag(String tag) { mTag = tag; } /** @hide
WakeLock::getTag
java
Reginer/aosp-android-jar
android-32/src/android/os/PowerManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/os/PowerManager.java
MIT
public void setHistoryTag(String tag) { mHistoryTag = tag; }
Sets the work source associated with the wake lock. <p> The work source is used to determine on behalf of which application the wake lock is being held. This is useful in the case where a service is performing work on behalf of an application so that the cost of that work can be accounted to the application. </p> <p> Make sure to follow the tag naming convention when using WorkSource to make it easier for app developers to understand wake locks attributed to them. See {@link PowerManager#newWakeLock(int, String)} documentation. </p> @param ws The work source, or null if none. public void setWorkSource(WorkSource ws) { synchronized (mToken) { if (ws != null && ws.isEmpty()) { ws = null; } final boolean changed; if (ws == null) { changed = mWorkSource != null; mWorkSource = null; } else if (mWorkSource == null) { changed = true; mWorkSource = new WorkSource(ws); } else { changed = !mWorkSource.equals(ws); if (changed) { mWorkSource.set(ws); } } if (changed && mHeld) { try { mService.updateWakeLockWorkSource(mToken, mWorkSource, mHistoryTag); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } } /** @hide public void setTag(String tag) { mTag = tag; } /** @hide public String getTag() { return mTag; } /** @hide
WakeLock::setHistoryTag
java
Reginer/aosp-android-jar
android-32/src/android/os/PowerManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/os/PowerManager.java
MIT
public void setUnimportantForLogging(boolean state) { if (state) mFlags |= UNIMPORTANT_FOR_LOGGING; else mFlags &= ~UNIMPORTANT_FOR_LOGGING; }
Sets the work source associated with the wake lock. <p> The work source is used to determine on behalf of which application the wake lock is being held. This is useful in the case where a service is performing work on behalf of an application so that the cost of that work can be accounted to the application. </p> <p> Make sure to follow the tag naming convention when using WorkSource to make it easier for app developers to understand wake locks attributed to them. See {@link PowerManager#newWakeLock(int, String)} documentation. </p> @param ws The work source, or null if none. public void setWorkSource(WorkSource ws) { synchronized (mToken) { if (ws != null && ws.isEmpty()) { ws = null; } final boolean changed; if (ws == null) { changed = mWorkSource != null; mWorkSource = null; } else if (mWorkSource == null) { changed = true; mWorkSource = new WorkSource(ws); } else { changed = !mWorkSource.equals(ws); if (changed) { mWorkSource.set(ws); } } if (changed && mHeld) { try { mService.updateWakeLockWorkSource(mToken, mWorkSource, mHistoryTag); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } } /** @hide public void setTag(String tag) { mTag = tag; } /** @hide public String getTag() { return mTag; } /** @hide public void setHistoryTag(String tag) { mHistoryTag = tag; } /** @hide
WakeLock::setUnimportantForLogging
java
Reginer/aosp-android-jar
android-32/src/android/os/PowerManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/os/PowerManager.java
MIT
public void dumpDebug(ProtoOutputStream proto, long fieldId) { synchronized (mToken) { final long token = proto.start(fieldId); proto.write(PowerManagerProto.WakeLock.TAG, mTag); proto.write(PowerManagerProto.WakeLock.PACKAGE_NAME, mPackageName); proto.write(PowerManagerProto.WakeLock.HELD, mHeld); proto.write(PowerManagerProto.WakeLock.INTERNAL_COUNT, mInternalCount); if (mWorkSource != null) { mWorkSource.dumpDebug(proto, PowerManagerProto.WakeLock.WORK_SOURCE); } proto.end(token); } }
Sets the work source associated with the wake lock. <p> The work source is used to determine on behalf of which application the wake lock is being held. This is useful in the case where a service is performing work on behalf of an application so that the cost of that work can be accounted to the application. </p> <p> Make sure to follow the tag naming convention when using WorkSource to make it easier for app developers to understand wake locks attributed to them. See {@link PowerManager#newWakeLock(int, String)} documentation. </p> @param ws The work source, or null if none. public void setWorkSource(WorkSource ws) { synchronized (mToken) { if (ws != null && ws.isEmpty()) { ws = null; } final boolean changed; if (ws == null) { changed = mWorkSource != null; mWorkSource = null; } else if (mWorkSource == null) { changed = true; mWorkSource = new WorkSource(ws); } else { changed = !mWorkSource.equals(ws); if (changed) { mWorkSource.set(ws); } } if (changed && mHeld) { try { mService.updateWakeLockWorkSource(mToken, mWorkSource, mHistoryTag); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } } /** @hide public void setTag(String tag) { mTag = tag; } /** @hide public String getTag() { return mTag; } /** @hide public void setHistoryTag(String tag) { mHistoryTag = tag; } /** @hide public void setUnimportantForLogging(boolean state) { if (state) mFlags |= UNIMPORTANT_FOR_LOGGING; else mFlags &= ~UNIMPORTANT_FOR_LOGGING; } @Override public String toString() { synchronized (mToken) { return "WakeLock{" + Integer.toHexString(System.identityHashCode(this)) + " held=" + mHeld + ", refCount=" + mInternalCount + "}"; } } /** @hide
WakeLock::dumpDebug
java
Reginer/aosp-android-jar
android-32/src/android/os/PowerManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/os/PowerManager.java
MIT
public Runnable wrap(Runnable r) { acquire(); return () -> { try { r.run(); } finally { release(); } }; }
Wraps a Runnable such that this method immediately acquires the wake lock and then once the Runnable is done the wake lock is released. <p>Example: <pre> mHandler.post(mWakeLock.wrap(() -> { // do things on handler, lock is held while we're waiting for this // to get scheduled and until the runnable is done executing. }); </pre> <p>Note: you must make sure that the Runnable eventually gets executed, otherwise you'll leak the wakelock! @hide
WakeLock::wrap
java
Reginer/aosp-android-jar
android-32/src/android/os/PowerManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/os/PowerManager.java
MIT
public void attach(GroupCoalescer groupCoalescer) { Assert.isMainThread(); if (mAttached) { throw new RuntimeException("attach() called twice"); } mAttached = true; groupCoalescer.setNotificationHandler(mNotifHandler); }
Keeps a record of all of the "active" notifications, i.e. the notifications that are currently posted to the phone. This collection is unsorted, ungrouped, and unfiltered. Just because a notification appears in this collection doesn't mean that it's currently present in the shade (notifications can be hidden for a variety of reasons). Code that cares about what notifications are *visible* right now should register listeners later in the pipeline. Each notification is represented by a {@link NotificationEntry}, which is itself made up of two parts: a {@link StatusBarNotification} and a {@link Ranking}. When notifications are updated, their underlying SBNs and Rankings are swapped out, but the enclosing NotificationEntry (and its associated key) remain the same. In general, an SBN can only be updated when the notification is reposted by the source app; Rankings are updated much more often, usually every time there is an update from any kind from NotificationManager. In general, this collection closely mirrors the list maintained by NotificationManager, but it can occasionally diverge due to lifetime extenders (see {@link #addNotificationLifetimeExtender(NotifLifetimeExtender)}). Interested parties can register listeners ({@link #addCollectionListener(NotifCollectionListener)}) to be informed when notifications events occur. @MainThread @SysUISingleton public class NotifCollection implements Dumpable { private final IStatusBarService mStatusBarService; private final SystemClock mClock; private final FeatureFlags mFeatureFlags; private final NotifCollectionLogger mLogger; private final Handler mMainHandler; private final LogBufferEulogizer mEulogizer; private final Map<String, NotificationEntry> mNotificationSet = new ArrayMap<>(); private final Collection<NotificationEntry> mReadOnlyNotificationSet = Collections.unmodifiableCollection(mNotificationSet.values()); @Nullable private CollectionReadyForBuildListener mBuildListener; private final List<NotifCollectionListener> mNotifCollectionListeners = new ArrayList<>(); private final List<NotifLifetimeExtender> mLifetimeExtenders = new ArrayList<>(); private final List<NotifDismissInterceptor> mDismissInterceptors = new ArrayList<>(); private Queue<NotifEvent> mEventQueue = new ArrayDeque<>(); private boolean mAttached = false; private boolean mAmDispatchingToOtherCode; private long mInitializedTimestamp = 0; @Inject public NotifCollection( IStatusBarService statusBarService, SystemClock clock, FeatureFlags featureFlags, NotifCollectionLogger logger, @Main Handler mainHandler, LogBufferEulogizer logBufferEulogizer, DumpManager dumpManager) { Assert.isMainThread(); mStatusBarService = statusBarService; mClock = clock; mFeatureFlags = featureFlags; mLogger = logger; mMainHandler = mainHandler; mEulogizer = logBufferEulogizer; dumpManager.registerDumpable(TAG, this); } /** Initializes the NotifCollection and registers it to receive notification events.
NotifCollection::attach
java
Reginer/aosp-android-jar
android-32/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
MIT
void setBuildListener(CollectionReadyForBuildListener buildListener) { Assert.isMainThread(); mBuildListener = buildListener; }
Sets the class responsible for converting the collection into the list of currently-visible notifications.
NotifCollection::setBuildListener
java
Reginer/aosp-android-jar
android-32/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
MIT
NotificationEntry getEntry(String key) { return mNotificationSet.get(key); }
Sets the class responsible for converting the collection into the list of currently-visible notifications. void setBuildListener(CollectionReadyForBuildListener buildListener) { Assert.isMainThread(); mBuildListener = buildListener; } /** @see NotifPipeline#getEntry(String) ()
NotifCollection::getEntry
java
Reginer/aosp-android-jar
android-32/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
MIT
Collection<NotificationEntry> getAllNotifs() { Assert.isMainThread(); return mReadOnlyNotificationSet; }
Sets the class responsible for converting the collection into the list of currently-visible notifications. void setBuildListener(CollectionReadyForBuildListener buildListener) { Assert.isMainThread(); mBuildListener = buildListener; } /** @see NotifPipeline#getEntry(String) () NotificationEntry getEntry(String key) { return mNotificationSet.get(key); } /** @see NotifPipeline#getAllNotifs()
NotifCollection::getAllNotifs
java
Reginer/aosp-android-jar
android-32/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
MIT
void addCollectionListener(NotifCollectionListener listener) { Assert.isMainThread(); mNotifCollectionListeners.add(listener); }
Sets the class responsible for converting the collection into the list of currently-visible notifications. void setBuildListener(CollectionReadyForBuildListener buildListener) { Assert.isMainThread(); mBuildListener = buildListener; } /** @see NotifPipeline#getEntry(String) () NotificationEntry getEntry(String key) { return mNotificationSet.get(key); } /** @see NotifPipeline#getAllNotifs() Collection<NotificationEntry> getAllNotifs() { Assert.isMainThread(); return mReadOnlyNotificationSet; } /** @see NotifPipeline#addCollectionListener(NotifCollectionListener)
NotifCollection::addCollectionListener
java
Reginer/aosp-android-jar
android-32/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
MIT
void addNotificationLifetimeExtender(NotifLifetimeExtender extender) { Assert.isMainThread(); checkForReentrantCall(); if (mLifetimeExtenders.contains(extender)) { throw new IllegalArgumentException("Extender " + extender + " already added."); } mLifetimeExtenders.add(extender); extender.setCallback(this::onEndLifetimeExtension); }
Sets the class responsible for converting the collection into the list of currently-visible notifications. void setBuildListener(CollectionReadyForBuildListener buildListener) { Assert.isMainThread(); mBuildListener = buildListener; } /** @see NotifPipeline#getEntry(String) () NotificationEntry getEntry(String key) { return mNotificationSet.get(key); } /** @see NotifPipeline#getAllNotifs() Collection<NotificationEntry> getAllNotifs() { Assert.isMainThread(); return mReadOnlyNotificationSet; } /** @see NotifPipeline#addCollectionListener(NotifCollectionListener) void addCollectionListener(NotifCollectionListener listener) { Assert.isMainThread(); mNotifCollectionListeners.add(listener); } /** @see NotifPipeline#addNotificationLifetimeExtender(NotifLifetimeExtender)
NotifCollection::addNotificationLifetimeExtender
java
Reginer/aosp-android-jar
android-32/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
MIT
void addNotificationDismissInterceptor(NotifDismissInterceptor interceptor) { Assert.isMainThread(); checkForReentrantCall(); if (mDismissInterceptors.contains(interceptor)) { throw new IllegalArgumentException("Interceptor " + interceptor + " already added."); } mDismissInterceptors.add(interceptor); interceptor.setCallback(this::onEndDismissInterception); }
Sets the class responsible for converting the collection into the list of currently-visible notifications. void setBuildListener(CollectionReadyForBuildListener buildListener) { Assert.isMainThread(); mBuildListener = buildListener; } /** @see NotifPipeline#getEntry(String) () NotificationEntry getEntry(String key) { return mNotificationSet.get(key); } /** @see NotifPipeline#getAllNotifs() Collection<NotificationEntry> getAllNotifs() { Assert.isMainThread(); return mReadOnlyNotificationSet; } /** @see NotifPipeline#addCollectionListener(NotifCollectionListener) void addCollectionListener(NotifCollectionListener listener) { Assert.isMainThread(); mNotifCollectionListeners.add(listener); } /** @see NotifPipeline#addNotificationLifetimeExtender(NotifLifetimeExtender) void addNotificationLifetimeExtender(NotifLifetimeExtender extender) { Assert.isMainThread(); checkForReentrantCall(); if (mLifetimeExtenders.contains(extender)) { throw new IllegalArgumentException("Extender " + extender + " already added."); } mLifetimeExtenders.add(extender); extender.setCallback(this::onEndLifetimeExtension); } /** @see NotifPipeline#addNotificationDismissInterceptor(NotifDismissInterceptor)
NotifCollection::addNotificationDismissInterceptor
java
Reginer/aosp-android-jar
android-32/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
MIT
public void register(BroadcastDispatcher broadcastDispatcher) { IntentFilter f = new IntentFilter(Intent.ACTION_USER_SWITCHED); broadcastDispatcher.registerReceiver(this, f, null /* handler */, UserHandle.SYSTEM); }
Register this receiver with the {@link BroadcastDispatcher} @param broadcastDispatcher to register the receiver.
GuestResumeSessionReceiver::register
java
Reginer/aosp-android-jar
android-32/src/com/android/systemui/GuestResumeSessionReceiver.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/systemui/GuestResumeSessionReceiver.java
MIT
public boolean hasSufficientCaps(int desiredCaps) { return desiredCaps == (desiredCaps & mFilterTypes); }
Returns true if the desired {@link DemuxFilterMainTypes} is supported.
DemuxResource::hasSufficientCaps
java
Reginer/aosp-android-jar
android-34/src/com/android/server/tv/tunerresourcemanager/DemuxResource.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/tv/tunerresourcemanager/DemuxResource.java
MIT
public int getNumOfCaps() { int mask = 1; int numOfCaps = 0; for (int i = 0; i < Integer.SIZE; i++) { if ((mFilterTypes & mask) == mask) { numOfCaps = numOfCaps + 1; } mask = mask << 1; } return numOfCaps; }
Returns the number of supported {@link DemuxFilterMainTypes}.
DemuxResource::getNumOfCaps
java
Reginer/aosp-android-jar
android-34/src/com/android/server/tv/tunerresourcemanager/DemuxResource.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/tv/tunerresourcemanager/DemuxResource.java
MIT
public Builder filterTypes(int filterTypes) { this.mFilterTypes = filterTypes; return this; }
Builder for {@link DemuxResource}. @param filterTypes the supported {@link DemuxFilterMainTypes}
Builder::filterTypes
java
Reginer/aosp-android-jar
android-34/src/com/android/server/tv/tunerresourcemanager/DemuxResource.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/tv/tunerresourcemanager/DemuxResource.java
MIT
public static PBKDF2Params getInstance( Object obj) { if (obj instanceof PBKDF2Params) { return (PBKDF2Params)obj; } if (obj != null) { return new PBKDF2Params(ASN1Sequence.getInstance(obj)); } return null; }
Create PBKDF2Params from the passed in object, @param obj either PBKDF2Params or an ASN1Sequence. @return a PBKDF2Params instance.
PBKDF2Params::getInstance
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
MIT
public PBKDF2Params( byte[] salt, int iterationCount) { this(salt, iterationCount, 0); }
Create a PBKDF2Params with the specified salt, iteration count, and algid-hmacWithSHA1 for the prf. @param salt input salt. @param iterationCount input iteration count.
PBKDF2Params::PBKDF2Params
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
MIT
public PBKDF2Params( byte[] salt, int iterationCount, int keyLength) { this(salt, iterationCount, keyLength, null); }
Create a PBKDF2Params with the specified salt, iteration count, keyLength, and algid-hmacWithSHA1 for the prf. @param salt input salt. @param iterationCount input iteration count. @param keyLength intended key length to be produced.
PBKDF2Params::PBKDF2Params
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
MIT
public PBKDF2Params( byte[] salt, int iterationCount, int keyLength, AlgorithmIdentifier prf) { this.octStr = new DEROctetString(Arrays.clone(salt)); this.iterationCount = new ASN1Integer(iterationCount); if (keyLength > 0) { this.keyLength = new ASN1Integer(keyLength); } else { this.keyLength = null; } this.prf = prf; }
Create a PBKDF2Params with the specified salt, iteration count, keyLength, and a defined prf. @param salt input salt. @param iterationCount input iteration count. @param keyLength intended key length to be produced. @param prf the pseudo-random function to use.
PBKDF2Params::PBKDF2Params
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
MIT
public PBKDF2Params( byte[] salt, int iterationCount, AlgorithmIdentifier prf) { this(salt, iterationCount, 0, prf); }
Create a PBKDF2Params with the specified salt, iteration count, and a defined prf. @param salt input salt. @param iterationCount input iteration count. @param prf the pseudo-random function to use.
PBKDF2Params::PBKDF2Params
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
MIT
public byte[] getSalt() { return octStr.getOctets(); }
Return the salt to use. @return the input salt.
PBKDF2Params::getSalt
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
MIT
public BigInteger getIterationCount() { return iterationCount.getValue(); }
Return the iteration count to use. @return the input iteration count.
PBKDF2Params::getIterationCount
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
MIT
public BigInteger getKeyLength() { if (keyLength != null) { return keyLength.getValue(); } return null; }
Return the intended length in octets of the derived key. @return length in octets for derived key, if specified.
PBKDF2Params::getKeyLength
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
MIT
public boolean isDefaultPrf() { return prf == null || prf.equals(algid_hmacWithSHA1); }
Return true if the PRF is the default (hmacWithSHA1) @return true if PRF is default, false otherwise.
PBKDF2Params::isDefaultPrf
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
MIT
public AlgorithmIdentifier getPrf() { if (prf != null) { return prf; } return algid_hmacWithSHA1; }
Return the algId of the underlying pseudo random function to use. @return the prf algorithm identifier.
PBKDF2Params::getPrf
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
MIT
public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(4); v.add(octStr); v.add(iterationCount); if (keyLength != null) { v.add(keyLength); } if (prf != null && !prf.equals(algid_hmacWithSHA1)) { v.add(prf); } return new DERSequence(v); }
Return an ASN.1 structure suitable for encoding. @return the object as an ASN.1 encodable structure.
PBKDF2Params::toASN1Primitive
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/org/bouncycastle/asn1/pkcs/PBKDF2Params.java
MIT
public void bootstrap(PackageManagerService pm) { this.mPackageManager = pm; }
Bootstraps this injector with the {@link PackageManagerService instance to which it belongs.
Singleton::bootstrap
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
public final void use() { mUsed++; }
Record that the snapshot was used.
ComputerEngine::use
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
public final int getUsed() { return mUsed; }
Return the usage counter.
ComputerEngine::getUsed
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
private @Nullable ComponentName findInstallFailureActivity( String packageName, int filterCallingUid, int userId) { final Intent failureActivityIntent = new Intent(Intent.ACTION_INSTALL_FAILURE); failureActivityIntent.setPackage(packageName); // IMPORTANT: disallow dynamic splits to avoid an infinite loop final List<ResolveInfo> result = queryIntentActivitiesInternal( failureActivityIntent, null /*resolvedType*/, 0 /*flags*/, 0 /*privateResolveFlags*/, filterCallingUid, userId, false /*resolveForStart*/, false /*allowDynamicSplits*/); final int NR = result.size(); if (NR > 0) { for (int i = 0; i < NR; i++) { final ResolveInfo info = result.get(i); if (info.activityInfo.splitName != null) { continue; } return new ComponentName(packageName, info.activityInfo.name); } } return null; }
Returns the activity component that can handle install failures. <p>By default, the instant application installer handles failures. However, an application may want to handle failures on its own. Applications do this by creating an activity with an intent filter that handles the action {@link Intent#ACTION_INSTALL_FAILURE}.
ComputerEngine::findInstallFailureActivity
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
public final ActivityInfo getActivityInfoInternal(ComponentName component, int flags, int filterCallingUid, int userId) { if (!mUserManager.exists(userId)) return null; flags = updateFlagsForComponent(flags, userId); if (!isRecentsAccessingChildProfiles(Binder.getCallingUid(), userId)) { enforceCrossUserPermission(Binder.getCallingUid(), userId, false /* requireFullPermission */, false /* checkShell */, "get activity info"); } return getActivityInfoInternalBody(component, flags, filterCallingUid, userId); }
Important: The provided filterCallingUid is used exclusively to filter out activities that can be seen based on user state. It's typically the original caller uid prior to clearing. Because it can only be provided by trusted code, its value can be trusted and will be used as-is; unlike userId which will be validated by this method.
ComputerEngine::getActivityInfoInternal
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
public final ApplicationInfo getApplicationInfoInternal(String packageName, int flags, int filterCallingUid, int userId) { if (!mUserManager.exists(userId)) return null; flags = updateFlagsForApplication(flags, userId); if (!isRecentsAccessingChildProfiles(Binder.getCallingUid(), userId)) { enforceCrossUserPermission(Binder.getCallingUid(), userId, false /* requireFullPermission */, false /* checkShell */, "get application info"); } return getApplicationInfoInternalBody(packageName, flags, filterCallingUid, userId); }
Important: The provided filterCallingUid is used exclusively to filter out applications that can be seen based on user state. It's typically the original caller uid prior to clearing. Because it can only be provided by trusted code, its value can be trusted and will be used as-is; unlike userId which will be validated by this method.
ComputerEngine::getApplicationInfoInternal
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
public final ComponentName getDefaultHomeActivity(int userId) { List<ResolveInfo> allHomeCandidates = new ArrayList<>(); ComponentName cn = getHomeActivitiesAsUser(allHomeCandidates, userId); if (cn != null) { return cn; } // TODO: This should not happen since there should always be a default package set for // ROLE_HOME in RoleManager. Continue with a warning log for now. Slog.w(TAG, "Default package for ROLE_HOME is not set in RoleManager"); // Find the launcher with the highest priority and return that component if there are no // other home activity with the same priority. int lastPriority = Integer.MIN_VALUE; ComponentName lastComponent = null; final int size = allHomeCandidates.size(); for (int i = 0; i < size; i++) { final ResolveInfo ri = allHomeCandidates.get(i); if (ri.priority > lastPriority) { lastComponent = ri.activityInfo.getComponentName(); lastPriority = ri.priority; } else if (ri.priority == lastPriority) { // Two components found with same priority. lastComponent = null; } } return lastComponent; }
Report the 'Home' activity which is currently set as "always use this one". If non is set then reports the most likely home activity or null if there are more than one.
ComputerEngine::getDefaultHomeActivity
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
public final List<ResolveInfo> applyPostResolutionFilter( @NonNull List<ResolveInfo> resolveInfos, String ephemeralPkgName, boolean allowDynamicSplits, int filterCallingUid, boolean resolveForStart, int userId, Intent intent) { final boolean blockInstant = intent.isWebIntent() && areWebInstantAppsDisabled(userId); for (int i = resolveInfos.size() - 1; i >= 0; i--) { final ResolveInfo info = resolveInfos.get(i); // remove locally resolved instant app web results when disabled if (info.isInstantAppAvailable && blockInstant) { resolveInfos.remove(i); continue; } // allow activities that are defined in the provided package if (allowDynamicSplits && info.activityInfo != null && info.activityInfo.splitName != null && !ArrayUtils.contains(info.activityInfo.applicationInfo.splitNames, info.activityInfo.splitName)) { if (instantAppInstallerActivity() == null) { if (DEBUG_INSTALL) { Slog.v(TAG, "No installer - not adding it to the ResolveInfo list"); } resolveInfos.remove(i); continue; } if (blockInstant && isInstantApp(info.activityInfo.packageName, userId)) { resolveInfos.remove(i); continue; } // requested activity is defined in a split that hasn't been installed yet. // add the installer to the resolve list if (DEBUG_INSTALL) { Slog.v(TAG, "Adding installer to the ResolveInfo list"); } final ResolveInfo installerInfo = new ResolveInfo( mInstantAppInstallerInfo); final ComponentName installFailureActivity = findInstallFailureActivity( info.activityInfo.packageName, filterCallingUid, userId); installerInfo.auxiliaryInfo = new AuxiliaryResolveInfo( installFailureActivity, info.activityInfo.packageName, info.activityInfo.applicationInfo.longVersionCode, info.activityInfo.splitName); // add a non-generic filter installerInfo.filter = new IntentFilter(); // This resolve info may appear in the chooser UI, so let us make it // look as the one it replaces as far as the user is concerned which // requires loading the correct label and icon for the resolve info. installerInfo.resolvePackageName = info.getComponentInfo().packageName; installerInfo.labelRes = info.resolveLabelResId(); installerInfo.icon = info.resolveIconResId(); installerInfo.isInstantAppAvailable = true; resolveInfos.set(i, installerInfo); continue; } if (ephemeralPkgName == null) { // caller is a full app SettingBase callingSetting = mSettings.getSettingLPr(UserHandle.getAppId(filterCallingUid)); PackageSetting resolvedSetting = getPackageSettingInternal(info.activityInfo.packageName, 0); if (resolveForStart || !mAppsFilter.shouldFilterApplication( filterCallingUid, callingSetting, resolvedSetting, userId)) { continue; } } else if (ephemeralPkgName.equals(info.activityInfo.packageName)) { // caller is same app; don't need to apply any other filtering continue; } else if (resolveForStart && (intent.isWebIntent() || (intent.getFlags() & Intent.FLAG_ACTIVITY_MATCH_EXTERNAL) != 0) && intent.getPackage() == null && intent.getComponent() == null) { // ephemeral apps can launch other ephemeral apps indirectly continue; } else if (((info.activityInfo.flags & ActivityInfo.FLAG_VISIBLE_TO_INSTANT_APP) != 0) && !info.activityInfo.applicationInfo.isInstantApp()) { // allow activities that have been explicitly exposed to ephemeral apps continue; } resolveInfos.remove(i); } return resolveInfos; }
Filters out ephemeral activities. <p>When resolving for an ephemeral app, only activities that 1) are defined in the ephemeral app or 2) marked with {@code visibleToEphemeral} are returned. @param resolveInfos The pre-filtered list of resolved activities @param ephemeralPkgName The ephemeral package name. If {@code null}, no filtering is performed. @param intent @return A filtered list of resolved activities.
ComputerEngine::applyPostResolutionFilter
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
private List<ResolveInfo> filterIfNotSystemUser(List<ResolveInfo> resolveInfos, int userId) { if (userId == UserHandle.USER_SYSTEM) { return resolveInfos; } for (int i = resolveInfos.size() - 1; i >= 0; i--) { ResolveInfo info = resolveInfos.get(i); if ((info.activityInfo.flags & ActivityInfo.FLAG_SYSTEM_USER_ONLY) != 0) { resolveInfos.remove(i); } } return resolveInfos; }
Filter out activities with systemUserOnly flag set, when current user is not System. @return filtered list
ComputerEngine::filterIfNotSystemUser
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
public final PackageInfo getPackageInfoInternal(String packageName, long versionCode, int flags, int filterCallingUid, int userId) { if (!mUserManager.exists(userId)) return null; flags = updateFlagsForPackage(flags, userId); enforceCrossUserPermission(Binder.getCallingUid(), userId, false /* requireFullPermission */, false /* checkShell */, "get package info"); return getPackageInfoInternalBody(packageName, versionCode, flags, filterCallingUid, userId); }
Important: The provided filterCallingUid is used exclusively to filter out packages that can be seen based on user state. It's typically the original caller uid prior to clearing. Because it can only be provided by trusted code, its value can be trusted and will be used as-is; unlike userId which will be validated by this method.
ComputerEngine::getPackageInfoInternal
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
public String getInstantAppPackageName(int callingUid) { // If the caller is an isolated app use the owner's uid for the lookup. if (Process.isIsolated(callingUid)) { callingUid = getIsolatedOwner(callingUid); } final int appId = UserHandle.getAppId(callingUid); final Object obj = mSettings.getSettingLPr(appId); if (obj instanceof PackageSetting) { final PackageSetting ps = (PackageSetting) obj; final boolean isInstantApp = ps.getInstantApp(UserHandle.getUserId(callingUid)); return isInstantApp ? ps.pkg.getPackageName() : null; } return null; }
Returns the package name of the calling Uid if it's an instant app. If it isn't instant, returns {@code null}.
ComputerEngine::getInstantAppPackageName
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
private int getIsolatedOwner(int isolatedUid) { final int ownerUid = mIsolatedOwners.get(isolatedUid, -1); if (ownerUid == -1) { throw new IllegalStateException( "No owner UID found for isolated UID " + isolatedUid); } return ownerUid; }
Finds the owner for the provided isolated UID. Throws IllegalStateException if no such isolated UID is found.
ComputerEngine::getIsolatedOwner
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
public final String[] getPackagesForUid(int uid) { return getPackagesForUidInternal(uid, Binder.getCallingUid()); }
<em>IMPORTANT:</em> Not all packages returned by this method may be known to the system. There are two conditions in which this may occur: <ol> <li>The package is on adoptable storage and the device has been removed</li> <li>The package is being removed and the internal structures are partially updated</li> </ol> The second is an artifact of the current data structures and should be fixed. See b/111075456 for one such instance. This binder API is cached. If the algorithm in this method changes, or if the underlying objecs (as returned by getSettingLPr()) change then the logic that invalidates the cache must be revisited. See calls to invalidateGetPackagesForUidCache() to locate the points at which the cache is invalidated.
ComputerEngine::getPackagesForUid
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
private boolean areWebInstantAppsDisabled(int userId) { return mWebInstantAppsDisabled.get(userId); }
Returns whether or not instant apps have been disabled remotely.
ComputerEngine::areWebInstantAppsDisabled
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
public final boolean canViewInstantApps(int callingUid, int userId) { if (callingUid < Process.FIRST_APPLICATION_UID) { return true; } if (mContext.checkCallingOrSelfPermission( android.Manifest.permission.ACCESS_INSTANT_APPS) == PERMISSION_GRANTED) { return true; } if (mContext.checkCallingOrSelfPermission( android.Manifest.permission.VIEW_INSTANT_APPS) == PERMISSION_GRANTED) { final ComponentName homeComponent = getDefaultHomeActivity(userId); if (homeComponent != null && isCallerSameApp(homeComponent.getPackageName(), callingUid)) { return true; } // TODO(b/122900055) Change/Remove this and replace with new permission role. if (mAppPredictionServicePackage != null && isCallerSameApp(mAppPredictionServicePackage, callingUid)) { return true; } } return false; }
Returns whether or not a full application can see an instant application. <p> Currently, there are four cases in which this can occur: <ol> <li>The calling application is a "special" process. Special processes are those with a UID < {@link Process#FIRST_APPLICATION_UID}.</li> <li>The calling application has the permission {@link android.Manifest.permission#ACCESS_INSTANT_APPS}.</li> <li>The calling application is the default launcher on the system partition.</li> <li>The calling application is the default app prediction service.</li> </ol>
ComputerEngine::canViewInstantApps
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
private boolean hasNonNegativePriority(List<ResolveInfo> resolveInfos) { return resolveInfos.size() > 0 && resolveInfos.get(0).priority >= 0; }
@param resolveInfos list of resolve infos in descending priority order @return if the list contains a resolve info with non-negative priority
ComputerEngine::hasNonNegativePriority
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
public final boolean isImplicitImageCaptureIntentAndNotSetByDpcLocked(Intent intent, int userId, String resolvedType, int flags) { return intent.isImplicitImageCaptureIntent() && !isPersistentPreferredActivitySetByDpm( intent, userId, resolvedType, flags); }
From Android R, camera intents have to match system apps. The only exception to this is if the DPC has set the camera persistent preferred activity. This case was introduced because it is important that the DPC has the ability to set both system and non-system camera persistent preferred activities. @return {@code true} if the intent is a camera intent and the persistent preferred activity was not set by the DPC.
ComputerEngine::isImplicitImageCaptureIntentAndNotSetByDpcLocked
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
private Computer liveComputer() { return mLiveComputer; }
Return the live computer.
ThreadComputer::liveComputer
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
private Computer snapshotComputer() { if (!mSnapshotEnabled) { return mLiveComputer; } if (Thread.holdsLock(mLock)) { // If the current thread holds mLock then it may have modified state but not // yet invalidated the snapshot. Always give the thread the live computer. return mLiveComputer; } else if (sSnapshotCorked.get() > 0) { // Snapshots are corked, which means new ones should not be built right now. mSnapshotStatistics.corked(); return mLiveComputer; } synchronized (mSnapshotLock) { // This synchronization block serializes access to the snapshot computer and // to the code that samples mSnapshotInvalid. Computer c = mSnapshotComputer; if (sSnapshotInvalid.getAndSet(false) || (c == null)) { // The snapshot is invalid if it is marked as invalid or if it is null. If it // is null, then it is currently being rebuilt by rebuildSnapshot(). synchronized (mLock) { // Rebuild the snapshot if it is invalid. Note that the snapshot might be // invalidated as it is rebuilt. However, the snapshot is still // self-consistent (the lock is being held) and is current as of the time // this function is entered. rebuildSnapshot(); // Guaranteed to be non-null. mSnapshotComputer is only be set to null // temporarily in rebuildSnapshot(), which is guarded by mLock(). Since // the mLock is held in this block and since rebuildSnapshot() is // complete, the attribute can not now be null. c = mSnapshotComputer; } } c.use(); return c; } }
Return the cached computer. The method will rebuild the cached computer if necessary. The live computer will be returned if snapshots are disabled.
ThreadComputer::snapshotComputer
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
private Computer createNewSnapshot() { synchronized (mLock) { final Snapshot args = new Snapshot(Snapshot.SNAPPED); return new ComputerEngine(args); } }
Create a new snapshot. Used for testing only. This does collect statistics or update the snapshot used by other actors. It does not alter the invalidation flag. This method takes the mLock internally.
DomainVerificationConnection::createNewSnapshot
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
private void corkSnapshots(int multiplier) { int corking = sSnapshotCorked.getAndIncrement(); if (TRACE_SNAPSHOTS && corking == 0) { Log.i(TAG, "snapshot: corking goes positive"); } Message message = mHandler.obtainMessage(SNAPSHOT_UNCORK); mHandler.sendMessageDelayed(message, SNAPSHOT_AUTOCORK_DELAY_MS * multiplier); }
Cork snapshots. This times out after the programmed delay.
DomainVerificationConnection::corkSnapshots
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
private ComputerLocked createLiveComputer() { return new ComputerLocked(new Snapshot(Snapshot.LIVE)); }
Create a live computer
DomainVerificationConnection::createLiveComputer
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
public static void onChange(@Nullable Watchable what) { if (TRACE_SNAPSHOTS) { Log.i(TAG, "snapshot: onChange(" + what + ")"); } sSnapshotInvalid.set(true); }
This method is called when the state of PackageManagerService changes so as to invalidate the current snapshot. @param what The {@link Watchable} that reported the change @hide
DomainVerificationConnection::onChange
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
private static void onChanged() { onChange(null); }
Report a locally-detected change to observers. The <what> parameter is left null, but it signifies that the change was detected by PackageManagerService itself.
DomainVerificationConnection::onChanged
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
public ScanPartition(@NonNull File folder, @NonNull ScanPartition original, @ScanFlags int additionalScanFlag) { super(folder, original); this.scanFlag = original.scanFlag | additionalScanFlag; }
Creates a partition containing the same folders as the original partition but with a different root folder. The new partition will include the scan flags of the original partition along with any specified additional scan flags.
ScanPartition::ScanPartition
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
private int overrideInstallLocation(PackageInfoLite pkgLite) { final boolean ephemeral = (installFlags & PackageManager.INSTALL_INSTANT_APP) != 0; if (DEBUG_INSTANT && ephemeral) { Slog.v(TAG, "pkgLite for install: " + pkgLite); } if (origin.staged) { // If we're already staged, we've firmly committed to an install location if (origin.file != null) { installFlags |= PackageManager.INSTALL_INTERNAL; } else { throw new IllegalStateException("Invalid stage location"); } } else if (pkgLite.recommendedInstallLocation == PackageHelper.RECOMMEND_FAILED_INSUFFICIENT_STORAGE) { /* * If we are not staged and have too little free space, try to free cache * before giving up. */ // TODO: focus freeing disk space on the target device final StorageManager storage = StorageManager.from(mContext); final long lowThreshold = storage.getStorageLowBytes( Environment.getDataDirectory()); final long sizeBytes = PackageManagerServiceUtils.calculateInstalledSize( origin.resolvedPath, packageAbiOverride); if (sizeBytes >= 0) { try { mInstaller.freeCache(null, sizeBytes + lowThreshold, 0, 0); pkgLite = PackageManagerServiceUtils.getMinimalPackageInfo(mContext, mPackageLite, origin.resolvedPath, installFlags, packageAbiOverride); } catch (InstallerException e) { Slog.w(TAG, "Failed to free cache", e); } } /* * The cache free must have deleted the file we downloaded to install. * * TODO: fix the "freeCache" call to not delete the file we care about. */ if (pkgLite.recommendedInstallLocation == PackageHelper.RECOMMEND_FAILED_INVALID_URI) { pkgLite.recommendedInstallLocation = PackageHelper.RECOMMEND_FAILED_INSUFFICIENT_STORAGE; } } int ret = INSTALL_SUCCEEDED; int loc = pkgLite.recommendedInstallLocation; if (loc == PackageHelper.RECOMMEND_FAILED_INVALID_LOCATION) { ret = PackageManager.INSTALL_FAILED_INVALID_INSTALL_LOCATION; } else if (loc == PackageHelper.RECOMMEND_FAILED_ALREADY_EXISTS) { ret = PackageManager.INSTALL_FAILED_ALREADY_EXISTS; } else if (loc == PackageHelper.RECOMMEND_FAILED_INSUFFICIENT_STORAGE) { ret = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE; } else if (loc == PackageHelper.RECOMMEND_FAILED_INVALID_APK) { ret = PackageManager.INSTALL_FAILED_INVALID_APK; } else if (loc == PackageHelper.RECOMMEND_FAILED_INVALID_URI) { ret = PackageManager.INSTALL_FAILED_INVALID_URI; } else if (loc == PackageHelper.RECOMMEND_MEDIA_UNAVAILABLE) { ret = PackageManager.INSTALL_FAILED_MEDIA_UNAVAILABLE; } else { // Override with defaults if needed. loc = installLocationPolicy(pkgLite); final boolean onInt = (installFlags & PackageManager.INSTALL_INTERNAL) != 0; if (!onInt) { // Override install location with flags if (loc == PackageHelper.RECOMMEND_INSTALL_EXTERNAL) { // Set the flag to install on external media. installFlags &= ~PackageManager.INSTALL_INTERNAL; } else { // Make sure the flag for installing on external // media is unset installFlags |= PackageManager.INSTALL_INTERNAL; } } } return ret; }
Override install location based on default policy if needed. Only {@link #installFlags} may mutate in this method. Only {@link PackageManager#INSTALL_INTERNAL} flag may mutate in {@link #installFlags}
InstallParams::overrideInstallLocation
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
public void handleStartCopy() { if ((installFlags & PackageManager.INSTALL_APEX) != 0) { mRet = INSTALL_SUCCEEDED; return; } PackageInfoLite pkgLite = PackageManagerServiceUtils.getMinimalPackageInfo(mContext, mPackageLite, origin.resolvedPath, installFlags, packageAbiOverride); // For staged session, there is a delay between its verification and install. Device // state can change within this delay and hence we need to re-verify certain conditions. boolean isStaged = (installFlags & INSTALL_STAGED) != 0; if (isStaged) { mRet = verifyReplacingVersionCode( pkgLite, requiredInstalledVersionCode, installFlags); if (mRet != INSTALL_SUCCEEDED) { return; } } mRet = overrideInstallLocation(pkgLite); }
Override install location based on default policy if needed. Only {@link #installFlags} may mutate in this method. Only {@link PackageManager#INSTALL_INTERNAL} flag may mutate in {@link #installFlags} private int overrideInstallLocation(PackageInfoLite pkgLite) { final boolean ephemeral = (installFlags & PackageManager.INSTALL_INSTANT_APP) != 0; if (DEBUG_INSTANT && ephemeral) { Slog.v(TAG, "pkgLite for install: " + pkgLite); } if (origin.staged) { // If we're already staged, we've firmly committed to an install location if (origin.file != null) { installFlags |= PackageManager.INSTALL_INTERNAL; } else { throw new IllegalStateException("Invalid stage location"); } } else if (pkgLite.recommendedInstallLocation == PackageHelper.RECOMMEND_FAILED_INSUFFICIENT_STORAGE) { /* If we are not staged and have too little free space, try to free cache before giving up. // TODO: focus freeing disk space on the target device final StorageManager storage = StorageManager.from(mContext); final long lowThreshold = storage.getStorageLowBytes( Environment.getDataDirectory()); final long sizeBytes = PackageManagerServiceUtils.calculateInstalledSize( origin.resolvedPath, packageAbiOverride); if (sizeBytes >= 0) { try { mInstaller.freeCache(null, sizeBytes + lowThreshold, 0, 0); pkgLite = PackageManagerServiceUtils.getMinimalPackageInfo(mContext, mPackageLite, origin.resolvedPath, installFlags, packageAbiOverride); } catch (InstallerException e) { Slog.w(TAG, "Failed to free cache", e); } } /* The cache free must have deleted the file we downloaded to install. TODO: fix the "freeCache" call to not delete the file we care about. if (pkgLite.recommendedInstallLocation == PackageHelper.RECOMMEND_FAILED_INVALID_URI) { pkgLite.recommendedInstallLocation = PackageHelper.RECOMMEND_FAILED_INSUFFICIENT_STORAGE; } } int ret = INSTALL_SUCCEEDED; int loc = pkgLite.recommendedInstallLocation; if (loc == PackageHelper.RECOMMEND_FAILED_INVALID_LOCATION) { ret = PackageManager.INSTALL_FAILED_INVALID_INSTALL_LOCATION; } else if (loc == PackageHelper.RECOMMEND_FAILED_ALREADY_EXISTS) { ret = PackageManager.INSTALL_FAILED_ALREADY_EXISTS; } else if (loc == PackageHelper.RECOMMEND_FAILED_INSUFFICIENT_STORAGE) { ret = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE; } else if (loc == PackageHelper.RECOMMEND_FAILED_INVALID_APK) { ret = PackageManager.INSTALL_FAILED_INVALID_APK; } else if (loc == PackageHelper.RECOMMEND_FAILED_INVALID_URI) { ret = PackageManager.INSTALL_FAILED_INVALID_URI; } else if (loc == PackageHelper.RECOMMEND_MEDIA_UNAVAILABLE) { ret = PackageManager.INSTALL_FAILED_MEDIA_UNAVAILABLE; } else { // Override with defaults if needed. loc = installLocationPolicy(pkgLite); final boolean onInt = (installFlags & PackageManager.INSTALL_INTERNAL) != 0; if (!onInt) { // Override install location with flags if (loc == PackageHelper.RECOMMEND_INSTALL_EXTERNAL) { // Set the flag to install on external media. installFlags &= ~PackageManager.INSTALL_INTERNAL; } else { // Make sure the flag for installing on external // media is unset installFlags |= PackageManager.INSTALL_INTERNAL; } } } return ret; } /* Invoke remote method to get package information and install location values. Override install location based on default policy if needed and then create install arguments based on the install location.
InstallParams::handleStartCopy
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
void sendIntegrityVerificationRequest( int verificationId, PackageInfoLite pkgLite, PackageVerificationState verificationState) { if (!isIntegrityVerificationEnabled()) { // Consider the integrity check as passed. verificationState.setIntegrityVerificationResult( PackageManagerInternal.INTEGRITY_VERIFICATION_ALLOW); return; } final Intent integrityVerification = new Intent(Intent.ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION); integrityVerification.setDataAndType(Uri.fromFile(new File(origin.resolvedPath)), PACKAGE_MIME_TYPE); final int flags = Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND; integrityVerification.addFlags(flags); integrityVerification.putExtra(EXTRA_VERIFICATION_ID, verificationId); integrityVerification.putExtra(EXTRA_PACKAGE_NAME, pkgLite.packageName); integrityVerification.putExtra(EXTRA_VERSION_CODE, pkgLite.versionCode); integrityVerification.putExtra(EXTRA_LONG_VERSION_CODE, pkgLite.getLongVersionCode()); populateInstallerExtras(integrityVerification); // send to integrity component only. integrityVerification.setPackage("android"); final BroadcastOptions options = BroadcastOptions.makeBasic(); mContext.sendOrderedBroadcastAsUser(integrityVerification, UserHandle.SYSTEM, /* receiverPermission= */ null, /* appOp= */ AppOpsManager.OP_NONE, /* options= */ options.toBundle(), new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final Message msg = mHandler.obtainMessage(CHECK_PENDING_INTEGRITY_VERIFICATION); msg.arg1 = verificationId; mHandler.sendMessageDelayed(msg, getIntegrityVerificationTimeout()); } }, /* scheduler= */ null, /* initialCode= */ 0, /* initialData= */ null, /* initialExtras= */ null); Trace.asyncTraceBegin( TRACE_TAG_PACKAGE_MANAGER, "integrity_verification", verificationId); // stop the copy until verification succeeds. mWaitForIntegrityVerificationToComplete = true; }
Send a request to check the integrity of the package.
VerificationParams::sendIntegrityVerificationRequest
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
int sendPackageVerificationRequest( int verificationId, PackageInfoLite pkgLite, PackageVerificationState verificationState) { int ret = INSTALL_SUCCEEDED; // TODO: http://b/22976637 // Apps installed for "all" users use the device owner to verify the app UserHandle verifierUser = getUser(); if (verifierUser == UserHandle.ALL) { verifierUser = UserHandle.SYSTEM; } /* * Determine if we have any installed package verifiers. If we * do, then we'll defer to them to verify the packages. */ final int requiredUid = mRequiredVerifierPackage == null ? -1 : getPackageUid(mRequiredVerifierPackage, MATCH_DEBUG_TRIAGED_MISSING, verifierUser.getIdentifier()); verificationState.setRequiredVerifierUid(requiredUid); final int installerUid = verificationInfo == null ? -1 : verificationInfo.installerUid; final boolean isVerificationEnabled = isVerificationEnabled( pkgLite, verifierUser.getIdentifier(), installFlags, installerUid); final boolean isV4Signed = (signingDetails.signatureSchemeVersion == SIGNING_BLOCK_V4); final boolean isIncrementalInstall = (mDataLoaderType == DataLoaderType.INCREMENTAL); // NOTE: We purposefully skip verification for only incremental installs when there's // a v4 signature block. Otherwise, proceed with verification as usual. if (!origin.existing && isVerificationEnabled && (!isIncrementalInstall || !isV4Signed)) { final Intent verification = new Intent( Intent.ACTION_PACKAGE_NEEDS_VERIFICATION); verification.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); verification.setDataAndType(Uri.fromFile(new File(origin.resolvedPath)), PACKAGE_MIME_TYPE); verification.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // Query all live verifiers based on current user state final List<ResolveInfo> receivers = queryIntentReceiversInternal(verification, PACKAGE_MIME_TYPE, 0, verifierUser.getIdentifier(), false /*allowDynamicSplits*/); if (DEBUG_VERIFY) { Slog.d(TAG, "Found " + receivers.size() + " verifiers for intent " + verification.toString() + " with " + pkgLite.verifiers.length + " optional verifiers"); } verification.putExtra(PackageManager.EXTRA_VERIFICATION_ID, verificationId); verification.putExtra( PackageManager.EXTRA_VERIFICATION_INSTALL_FLAGS, installFlags); verification.putExtra( PackageManager.EXTRA_VERIFICATION_PACKAGE_NAME, pkgLite.packageName); verification.putExtra( PackageManager.EXTRA_VERIFICATION_VERSION_CODE, pkgLite.versionCode); verification.putExtra( PackageManager.EXTRA_VERIFICATION_LONG_VERSION_CODE, pkgLite.getLongVersionCode()); populateInstallerExtras(verification); final List<ComponentName> sufficientVerifiers = matchVerifiers(pkgLite, receivers, verificationState); DeviceIdleInternal idleController = mInjector.getLocalService(DeviceIdleInternal.class); final long idleDuration = getVerificationTimeout(); final BroadcastOptions options = BroadcastOptions.makeBasic(); options.setTemporaryAppAllowlist(idleDuration, TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED, REASON_PACKAGE_VERIFIER, ""); /* * If any sufficient verifiers were listed in the package * manifest, attempt to ask them. */ if (sufficientVerifiers != null) { final int n = sufficientVerifiers.size(); if (n == 0) { Slog.i(TAG, "Additional verifiers required, but none installed."); ret = PackageManager.INSTALL_FAILED_VERIFICATION_FAILURE; } else { for (int i = 0; i < n; i++) { final ComponentName verifierComponent = sufficientVerifiers.get(i); idleController.addPowerSaveTempWhitelistApp(Process.myUid(), verifierComponent.getPackageName(), idleDuration, verifierUser.getIdentifier(), false, REASON_PACKAGE_VERIFIER,"package verifier"); final Intent sufficientIntent = new Intent(verification); sufficientIntent.setComponent(verifierComponent); mContext.sendBroadcastAsUser(sufficientIntent, verifierUser, /* receiverPermission= */ null, options.toBundle()); } } } if (mRequiredVerifierPackage != null) { final ComponentName requiredVerifierComponent = matchComponentForVerifier( mRequiredVerifierPackage, receivers); /* * Send the intent to the required verification agent, * but only start the verification timeout after the * target BroadcastReceivers have run. */ verification.setComponent(requiredVerifierComponent); idleController.addPowerSaveTempWhitelistApp(Process.myUid(), mRequiredVerifierPackage, idleDuration, verifierUser.getIdentifier(), false, REASON_PACKAGE_VERIFIER, "package verifier"); mContext.sendOrderedBroadcastAsUser(verification, verifierUser, android.Manifest.permission.PACKAGE_VERIFICATION_AGENT, /* appOp= */ AppOpsManager.OP_NONE, /* options= */ options.toBundle(), new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final Message msg = mHandler .obtainMessage(CHECK_PENDING_VERIFICATION); msg.arg1 = verificationId; mHandler.sendMessageDelayed(msg, getVerificationTimeout()); } }, null, 0, null, null); Trace.asyncTraceBegin( TRACE_TAG_PACKAGE_MANAGER, "verification", verificationId); /* * We don't want the copy to proceed until verification * succeeds. */ mWaitForVerificationToComplete = true; } } else { verificationState.setVerifierResponse( requiredUid, PackageManager.VERIFICATION_ALLOW); } return ret; }
Send a request to verifier(s) to verify the package if necessary, and return {@link PackageManager#INSTALL_SUCCEEDED} if succeeded.
VerificationParams::sendPackageVerificationRequest
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
InstallArgs(InstallParams params) { this(params.origin, params.move, params.observer, params.installFlags, params.installSource, params.volumeUuid, params.getUser(), null /*instructionSets*/, params.packageAbiOverride, params.grantedRuntimePermissions, params.whitelistedRestrictedPermissions, params.autoRevokePermissionsMode, params.traceMethod, params.traceCookie, params.signingDetails, params.installReason, params.mInstallScenario, params.forceQueryableOverride, params.mDataLoaderType); }
Create args that describe an existing installed package. Typically used when cleaning up old installs, or used as a move source. private InstallArgs createInstallArgsForExisting(String codePath, String[] instructionSets) { return new FileInstallArgs(codePath, instructionSets); } static abstract class InstallArgs { /** @see InstallParams#origin final OriginInfo origin; /** @see InstallParams#move final MoveInfo move; final IPackageInstallObserver2 observer; // Always refers to PackageManager flags only final int installFlags; @NonNull final InstallSource installSource; final String volumeUuid; final UserHandle user; final String abiOverride; final String[] installGrantPermissions; final List<String> whitelistedRestrictedPermissions; final int autoRevokePermissionsMode; /** If non-null, drop an async trace when the install completes final String traceMethod; final int traceCookie; final PackageParser.SigningDetails signingDetails; final int installReason; final int mInstallScenario; final boolean forceQueryableOverride; final int mDataLoaderType; // The list of instruction sets supported by this app. This is currently // only used during the rmdex() phase to clean up resources. We can get rid of this // if we move dex files under the common app path. /* nullable */ String[] instructionSets; InstallArgs(OriginInfo origin, MoveInfo move, IPackageInstallObserver2 observer, int installFlags, InstallSource installSource, String volumeUuid, UserHandle user, String[] instructionSets, String abiOverride, String[] installGrantPermissions, List<String> whitelistedRestrictedPermissions, int autoRevokePermissionsMode, String traceMethod, int traceCookie, SigningDetails signingDetails, int installReason, int installScenario, boolean forceQueryableOverride, int dataLoaderType) { this.origin = origin; this.move = move; this.installFlags = installFlags; this.observer = observer; this.installSource = Preconditions.checkNotNull(installSource); this.volumeUuid = volumeUuid; this.user = user; this.instructionSets = instructionSets; this.abiOverride = abiOverride; this.installGrantPermissions = installGrantPermissions; this.whitelistedRestrictedPermissions = whitelistedRestrictedPermissions; this.autoRevokePermissionsMode = autoRevokePermissionsMode; this.traceMethod = traceMethod; this.traceCookie = traceCookie; this.signingDetails = signingDetails; this.installReason = installReason; this.mInstallScenario = installScenario; this.forceQueryableOverride = forceQueryableOverride; this.mDataLoaderType = dataLoaderType; } /** New install
InstallArgs::InstallArgs
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
int doPreCopy() { return PackageManager.INSTALL_SUCCEEDED; }
Called before the source arguments are copied. This is used mostly for MoveParams when it needs to read the source file to put it in the destination.
InstallArgs::doPreCopy
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
int doPostCopy(int uid) { return PackageManager.INSTALL_SUCCEEDED; }
Called after the source arguments are copied. This is used mostly for MoveParams when it needs to read the source file to put it in the destination.
InstallArgs::doPostCopy
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
FileInstallArgs(InstallParams params) { super(params); }
Logic to handle installation of new applications, including copying and renaming logic. class FileInstallArgs extends InstallArgs { private File codeFile; private File resourceFile; // Example topology: // /data/app/com.example/base.apk // /data/app/com.example/split_foo.apk // /data/app/com.example/lib/arm/libfoo.so // /data/app/com.example/lib/arm64/libfoo.so // /data/app/com.example/dalvik/arm/[email protected] /** New install
FileInstallArgs::FileInstallArgs
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
FileInstallArgs(String codePath, String[] instructionSets) { super(OriginInfo.fromNothing(), null, null, 0, InstallSource.EMPTY, null, null, instructionSets, null, null, null, MODE_DEFAULT, null, 0, PackageParser.SigningDetails.UNKNOWN, PackageManager.INSTALL_REASON_UNKNOWN, PackageManager.INSTALL_SCENARIO_DEFAULT, false, DataLoaderType.NONE); this.codeFile = (codePath != null) ? new File(codePath) : null; }
Logic to handle installation of new applications, including copying and renaming logic. class FileInstallArgs extends InstallArgs { private File codeFile; private File resourceFile; // Example topology: // /data/app/com.example/base.apk // /data/app/com.example/split_foo.apk // /data/app/com.example/lib/arm/libfoo.so // /data/app/com.example/lib/arm64/libfoo.so // /data/app/com.example/dalvik/arm/[email protected] /** New install FileInstallArgs(InstallParams params) { super(params); } /** Existing install
FileInstallArgs::FileInstallArgs
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
MoveInstallArgs(InstallParams params) { super(params); }
Logic to handle movement of existing installed applications. class MoveInstallArgs extends InstallArgs { private File codeFile; /** New install
MoveInstallArgs::MoveInstallArgs
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
private Map<String, AndroidPackage> getCombinedAvailablePackages() { final ArrayMap<String, AndroidPackage> combined = new ArrayMap<>(request.allPackages.size() + request.scannedPackages.size()); combined.putAll(request.allPackages); for (ScanResult scanResult : request.scannedPackages.values()) { combined.put(scanResult.pkgSetting.name, scanResult.request.parsedPackage); } return combined; }
Returns a combined set of packages containing the packages already installed combined with the package(s) currently being installed. The to-be installed packages take precedence and may shadow already installed packages.
ReconciledPackage::getCombinedAvailablePackages
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
public PackageFreezer() { mPackageName = null; mWeFroze = false; mCloseGuard.open("close"); }
Create and return a stub freezer that doesn't actually do anything, typically used when someone requested {@link PackageManager#INSTALL_DONT_KILL_APP} or {@link PackageManager#DELETE_DONT_KILL_APP}.
PackageFreezer::PackageFreezer
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
private @NonNull String[] filterOnlySystemPackages(@Nullable String... pkgNames) { if (pkgNames == null) { return ArrayUtils.emptyArray(String.class); } ArrayList<String> systemPackageNames = new ArrayList<>(pkgNames.length); for (String pkgName: pkgNames) { synchronized (mLock) { if (pkgName == null) { continue; } AndroidPackage pkg = getPackage(pkgName); if (pkg == null) { Log.w(TAG, "Could not find package " + pkgName); continue; } if (!pkg.isSystem()) { Log.w(TAG, pkgName + " is not system"); continue; } systemPackageNames.add(pkgName); } } return systemPackageNames.toArray(new String[]{}); }
Only keep package names that refer to {@link PackageParser.Package#isSystem system} packages. @param pkgNames The packages to filter @return The filtered packages
PackageManagerInternalImpl::filterOnlySystemPackages
java
Reginer/aosp-android-jar
android-31/src/com/android/server/pm/PackageManagerService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/pm/PackageManagerService.java
MIT
public nodedocumentnodename(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { super(factory); // // check if loaded documents are supported for content type // String contentType = getContentType(); preload(contentType, "staff", false); }
Constructor. @param factory document factory, may not be null @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
nodedocumentnodename::nodedocumentnodename
java
Reginer/aosp-android-jar
android-32/src/org/w3c/domts/level1/core/nodedocumentnodename.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level1/core/nodedocumentnodename.java
MIT
public void runTest() throws Throwable { Document doc; String documentName; doc = (Document) load("staff", false); documentName = doc.getNodeName(); assertEquals("documentNodeName", "#document", documentName); }
Runs the test case. @throws Throwable Any uncaught exception causes test to fail
nodedocumentnodename::runTest
java
Reginer/aosp-android-jar
android-32/src/org/w3c/domts/level1/core/nodedocumentnodename.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level1/core/nodedocumentnodename.java
MIT
public String getTargetURI() { return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodedocumentnodename"; }
Gets URI that identifies the test. @return uri identifier of test
nodedocumentnodename::getTargetURI
java
Reginer/aosp-android-jar
android-32/src/org/w3c/domts/level1/core/nodedocumentnodename.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level1/core/nodedocumentnodename.java
MIT
public static void main(final String[] args) { DOMTestCase.doMain(nodedocumentnodename.class, args); }
Runs this test from the command line. @param args command line arguments
nodedocumentnodename::main
java
Reginer/aosp-android-jar
android-32/src/org/w3c/domts/level1/core/nodedocumentnodename.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level1/core/nodedocumentnodename.java
MIT
public documentgetelementsbytagnameNS05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { super(factory); // // check if loaded documents are supported for content type // String contentType = getContentType(); preload(contentType, "staffNS", false); }
Constructor. @param factory document factory, may not be null @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
documentgetelementsbytagnameNS05::documentgetelementsbytagnameNS05
java
Reginer/aosp-android-jar
android-32/src/org/w3c/domts/level2/core/documentgetelementsbytagnameNS05.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level2/core/documentgetelementsbytagnameNS05.java
MIT
public void runTest() throws Throwable { Document doc; NodeList childList; doc = (Document) load("staffNS", false); childList = doc.getElementsByTagNameNS("null", "elementId"); assertSize("documentgetelementsbytagnameNS05", 0, childList); }
Runs the test case. @throws Throwable Any uncaught exception causes test to fail
documentgetelementsbytagnameNS05::runTest
java
Reginer/aosp-android-jar
android-32/src/org/w3c/domts/level2/core/documentgetelementsbytagnameNS05.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level2/core/documentgetelementsbytagnameNS05.java
MIT
public String getTargetURI() { return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentgetelementsbytagnameNS05"; }
Gets URI that identifies the test. @return uri identifier of test
documentgetelementsbytagnameNS05::getTargetURI
java
Reginer/aosp-android-jar
android-32/src/org/w3c/domts/level2/core/documentgetelementsbytagnameNS05.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level2/core/documentgetelementsbytagnameNS05.java
MIT
public static void main(final String[] args) { DOMTestCase.doMain(documentgetelementsbytagnameNS05.class, args); }
Runs this test from the command line. @param args command line arguments
documentgetelementsbytagnameNS05::main
java
Reginer/aosp-android-jar
android-32/src/org/w3c/domts/level2/core/documentgetelementsbytagnameNS05.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level2/core/documentgetelementsbytagnameNS05.java
MIT
public static HevcConfig parse(ParsableByteArray data) throws ParserException { try { data.skipBytes(21); // Skip to the NAL unit length size field. int lengthSizeMinusOne = data.readUnsignedByte() & 0x03; // Calculate the combined size of all VPS/SPS/PPS bitstreams. int numberOfArrays = data.readUnsignedByte(); int csdLength = 0; int csdStartPosition = data.getPosition(); for (int i = 0; i < numberOfArrays; i++) { data.skipBytes(1); // completeness (1), nal_unit_type (7) int numberOfNalUnits = data.readUnsignedShort(); for (int j = 0; j < numberOfNalUnits; j++) { int nalUnitLength = data.readUnsignedShort(); csdLength += 4 + nalUnitLength; // Start code and NAL unit. data.skipBytes(nalUnitLength); } } // Concatenate the codec-specific data into a single buffer. data.setPosition(csdStartPosition); byte[] buffer = new byte[csdLength]; int bufferPosition = 0; int width = Format.NO_VALUE; int height = Format.NO_VALUE; float pixelWidthHeightRatio = 1; @Nullable String codecs = null; for (int i = 0; i < numberOfArrays; i++) { int nalUnitType = data.readUnsignedByte() & 0x7F; // completeness (1), nal_unit_type (7) int numberOfNalUnits = data.readUnsignedShort(); for (int j = 0; j < numberOfNalUnits; j++) { int nalUnitLength = data.readUnsignedShort(); System.arraycopy( NalUnitUtil.NAL_START_CODE, 0, buffer, bufferPosition, NalUnitUtil.NAL_START_CODE.length); bufferPosition += NalUnitUtil.NAL_START_CODE.length; System.arraycopy( data.getData(), data.getPosition(), buffer, bufferPosition, nalUnitLength); if (nalUnitType == SPS_NAL_UNIT_TYPE && j == 0) { NalUnitUtil.H265SpsData spsData = NalUnitUtil.parseH265SpsNalUnit( buffer, bufferPosition, bufferPosition + nalUnitLength); width = spsData.width; height = spsData.height; pixelWidthHeightRatio = spsData.pixelWidthHeightRatio; codecs = CodecSpecificDataUtil.buildHevcCodecString( spsData.generalProfileSpace, spsData.generalTierFlag, spsData.generalProfileIdc, spsData.generalProfileCompatibilityFlags, spsData.constraintBytes, spsData.generalLevelIdc); } bufferPosition += nalUnitLength; data.skipBytes(nalUnitLength); } } List<byte[]> initializationData = csdLength == 0 ? Collections.emptyList() : Collections.singletonList(buffer); return new HevcConfig( initializationData, lengthSizeMinusOne + 1, width, height, pixelWidthHeightRatio, codecs); } catch (ArrayIndexOutOfBoundsException e) { throw ParserException.createForMalformedContainer("Error parsing HEVC config", e); } }
Parses HEVC configuration data. @param data A {@link ParsableByteArray}, whose position is set to the start of the HEVC configuration data to parse. @return A parsed representation of the HEVC configuration data. @throws ParserException If an error occurred parsing the data.
HevcConfig::parse
java
Reginer/aosp-android-jar
android-34/src/com/google/android/exoplayer2/video/HevcConfig.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/google/android/exoplayer2/video/HevcConfig.java
MIT
public OFBBlockCipher( BlockCipher cipher, int bitBlockSize) { super(cipher); if (bitBlockSize > (cipher.getBlockSize() * 8) || bitBlockSize < 8 || bitBlockSize % 8 != 0) { throw new IllegalArgumentException("0FB" + bitBlockSize + " not supported"); } this.cipher = cipher; this.blockSize = bitBlockSize / 8; this.IV = new byte[cipher.getBlockSize()]; this.ofbV = new byte[cipher.getBlockSize()]; this.ofbOutV = new byte[cipher.getBlockSize()]; }
Basic constructor. @param cipher the block cipher to be used as the basis of the feedback mode. @param bitBlockSize the block size in bits (note: a multiple of 8)
OFBBlockCipher::OFBBlockCipher
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/crypto/modes/OFBBlockCipher.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/crypto/modes/OFBBlockCipher.java
MIT
public void init( boolean encrypting, //ignored by this OFB mode CipherParameters params) throws IllegalArgumentException { if (params instanceof ParametersWithIV) { ParametersWithIV ivParam = (ParametersWithIV)params; byte[] iv = ivParam.getIV(); if (iv.length < IV.length) { // prepend the supplied IV with zeros (per FIPS PUB 81) System.arraycopy(iv, 0, IV, IV.length - iv.length, iv.length); for (int i = 0; i < IV.length - iv.length; i++) { IV[i] = 0; } } else { System.arraycopy(iv, 0, IV, 0, IV.length); } reset(); // if null it's an IV changed only. if (ivParam.getParameters() != null) { cipher.init(true, ivParam.getParameters()); } } else { reset(); // if it's null, key is to be reused. if (params != null) { cipher.init(true, params); } } }
Initialise the cipher and, possibly, the initialisation vector (IV). If an IV isn't passed as part of the parameter, the IV will be all zeros. An IV which is too short is handled in FIPS compliant fashion. @param encrypting if true the cipher is initialised for encryption, if false for decryption. @param params the key and other data required by the cipher. @exception IllegalArgumentException if the params argument is inappropriate.
OFBBlockCipher::init
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/crypto/modes/OFBBlockCipher.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/crypto/modes/OFBBlockCipher.java
MIT
public String getAlgorithmName() { return cipher.getAlgorithmName() + "/OFB" + (blockSize * 8); }
return the algorithm name and mode. @return the name of the underlying algorithm followed by "/OFB" and the block size in bits
OFBBlockCipher::getAlgorithmName
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/crypto/modes/OFBBlockCipher.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/crypto/modes/OFBBlockCipher.java
MIT
public int getBlockSize() { return blockSize; }
return the block size we are operating at (in bytes). @return the block size we are operating at (in bytes).
OFBBlockCipher::getBlockSize
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/crypto/modes/OFBBlockCipher.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/crypto/modes/OFBBlockCipher.java
MIT
public int processBlock( byte[] in, int inOff, byte[] out, int outOff) throws DataLengthException, IllegalStateException { processBytes(in, inOff, blockSize, out, outOff); return blockSize; }
Process one block of input from the array in and write it to the out array. @param in the array containing the input data. @param inOff offset into the in array the data starts at. @param out the array the output data will be copied into. @param outOff the offset into the out array the output will start at. @exception DataLengthException if there isn't enough data in in, or space in out. @exception IllegalStateException if the cipher isn't initialised. @return the number of bytes processed and produced.
OFBBlockCipher::processBlock
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/crypto/modes/OFBBlockCipher.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/crypto/modes/OFBBlockCipher.java
MIT
public void reset() { System.arraycopy(IV, 0, ofbV, 0, IV.length); byteCount = 0; cipher.reset(); }
reset the feedback vector back to the IV and reset the underlying cipher.
OFBBlockCipher::reset
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/crypto/modes/OFBBlockCipher.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/crypto/modes/OFBBlockCipher.java
MIT
public GeneralSubtrees() { trees = new ArrayList<GeneralSubtree>(); }
The default constructor for the class.
GeneralSubtrees::GeneralSubtrees
java
Reginer/aosp-android-jar
android-35/src/sun/security/x509/GeneralSubtrees.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/security/x509/GeneralSubtrees.java
MIT
public GeneralSubtrees(DerValue val) throws IOException { this(); if (val.tag != DerValue.tag_Sequence) { throw new IOException("Invalid encoding of GeneralSubtrees."); } while (val.data.available() != 0) { DerValue opt = val.data.getDerValue(); GeneralSubtree tree = new GeneralSubtree(opt); add(tree); } }
Create the object from the passed DER encoded form. @param val the DER encoded form of the same.
GeneralSubtrees::GeneralSubtrees
java
Reginer/aosp-android-jar
android-35/src/sun/security/x509/GeneralSubtrees.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/security/x509/GeneralSubtrees.java
MIT
public String toString() { String s = " GeneralSubtrees:\n" + trees.toString() + "\n"; return s; }
Return a printable string of the GeneralSubtree.
GeneralSubtrees::toString
java
Reginer/aosp-android-jar
android-35/src/sun/security/x509/GeneralSubtrees.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/security/x509/GeneralSubtrees.java
MIT
public void encode(DerOutputStream out) throws IOException { DerOutputStream seq = new DerOutputStream(); for (int i = 0, n = size(); i < n; i++) { get(i).encode(seq); } out.write(DerValue.tag_Sequence, seq); }
Encode the GeneralSubtrees. @params out the DerOutputStrean to encode this object to.
GeneralSubtrees::encode
java
Reginer/aosp-android-jar
android-35/src/sun/security/x509/GeneralSubtrees.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/security/x509/GeneralSubtrees.java
MIT
public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof GeneralSubtrees == false) { return false; } GeneralSubtrees other = (GeneralSubtrees)obj; return this.trees.equals(other.trees); }
Compare two general subtrees by comparing the subtrees of each. @param other GeneralSubtrees to compare to this @returns true if match
GeneralSubtrees::equals
java
Reginer/aosp-android-jar
android-35/src/sun/security/x509/GeneralSubtrees.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/security/x509/GeneralSubtrees.java
MIT
private GeneralNameInterface getGeneralNameInterface(int ndx) { return getGeneralNameInterface(get(ndx)); }
Return the GeneralNameInterface form of the GeneralName in one of the GeneralSubtrees. @param ndx index of the GeneralSubtree from which to obtain the name
GeneralSubtrees::getGeneralNameInterface
java
Reginer/aosp-android-jar
android-35/src/sun/security/x509/GeneralSubtrees.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/security/x509/GeneralSubtrees.java
MIT
private void minimize() { // Algorithm: compare each entry n to all subsequent entries in // the list: if any subsequent entry matches or widens entry n, // remove entry n. If any subsequent entries narrow entry n, remove // the subsequent entries. for (int i = 0; i < (size() - 1); i++) { GeneralNameInterface current = getGeneralNameInterface(i); boolean remove1 = false; /* compare current to subsequent elements */ for (int j = i + 1; j < size(); j++) { GeneralNameInterface subsequent = getGeneralNameInterface(j); switch (current.constrains(subsequent)) { case GeneralNameInterface.NAME_DIFF_TYPE: /* not comparable; different name types; keep checking */ continue; case GeneralNameInterface.NAME_MATCH: /* delete one of the duplicates */ remove1 = true; break; case GeneralNameInterface.NAME_NARROWS: /* subsequent narrows current */ /* remove narrower name (subsequent) */ remove(j); j--; /* continue check with new subsequent */ continue; case GeneralNameInterface.NAME_WIDENS: /* subsequent widens current */ /* remove narrower name current */ remove1 = true; break; case GeneralNameInterface.NAME_SAME_TYPE: /* keep both for now; keep checking */ continue; } break; } /* end of this pass of subsequent elements */ if (remove1) { remove(i); i--; /* check the new i value */ } } }
minimize this GeneralSubtrees by removing all redundant entries. Internal method used by intersect and reduce.
GeneralSubtrees::minimize
java
Reginer/aosp-android-jar
android-35/src/sun/security/x509/GeneralSubtrees.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/security/x509/GeneralSubtrees.java
MIT
private GeneralSubtree createWidestSubtree(GeneralNameInterface name) { try { GeneralName newName; switch (name.getType()) { case GeneralNameInterface.NAME_ANY: // Create new OtherName with same OID as baseName, but // empty value ObjectIdentifier otherOID = ((OtherName)name).getOID(); newName = new GeneralName(new OtherName(otherOID, null)); break; case GeneralNameInterface.NAME_RFC822: newName = new GeneralName(new RFC822Name("")); break; case GeneralNameInterface.NAME_DNS: newName = new GeneralName(new DNSName("")); break; case GeneralNameInterface.NAME_X400: newName = new GeneralName(new X400Address((byte[])null)); break; case GeneralNameInterface.NAME_DIRECTORY: newName = new GeneralName(new X500Name("")); break; case GeneralNameInterface.NAME_EDI: newName = new GeneralName(new EDIPartyName("")); break; case GeneralNameInterface.NAME_URI: newName = new GeneralName(new URIName("")); break; case GeneralNameInterface.NAME_IP: newName = new GeneralName(new IPAddressName((byte[])null)); break; case GeneralNameInterface.NAME_OID: newName = new GeneralName (new OIDName(new ObjectIdentifier((int[])null))); break; default: throw new IOException ("Unsupported GeneralNameInterface type: " + name.getType()); } return new GeneralSubtree(newName, 0, -1); } catch (IOException e) { throw new RuntimeException("Unexpected error: " + e, e); } }
create a subtree containing an instance of the input name type that widens all other names of that type. @params name GeneralNameInterface name @returns GeneralSubtree containing widest name of that type @throws RuntimeException on error (should not occur)
GeneralSubtrees::createWidestSubtree
java
Reginer/aosp-android-jar
android-35/src/sun/security/x509/GeneralSubtrees.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/security/x509/GeneralSubtrees.java
MIT
public GeneralSubtrees intersect(GeneralSubtrees other) { if (other == null) { throw new NullPointerException("other GeneralSubtrees must not be null"); } GeneralSubtrees newThis = new GeneralSubtrees(); GeneralSubtrees newExcluded = null; // Step 1: If this is empty, just add everything in other to this and // return no new excluded entries if (size() == 0) { union(other); return null; } // Step 2: For ease of checking the subtrees, minimize them by // constructing versions that contain only the widest instance of // each type this.minimize(); other.minimize(); // Step 3: Check each entry in this to see whether we keep it or // remove it, and whether we add anything to newExcluded or newThis. // We keep an entry in this unless it is narrowed by all entries in // other. We add an entry to newExcluded if there is at least one // entry of the same nameType in other, but this entry does // not share the same subtree with any of the entries in other. // We add an entry from other to newThis if there is no name of the // same type in this. for (int i = 0; i < size(); i++) { GeneralNameInterface thisEntry = getGeneralNameInterface(i); boolean removeThisEntry = false; // Step 3a: If the widest name of this type in other narrows // thisEntry, remove thisEntry and add widest other to newThis. // Simultaneously, check for situation where there is a name of // this type in other, but no name in other matches, narrows, // or widens thisEntry. boolean sameType = false; for (int j = 0; j < other.size(); j++) { GeneralSubtree otherEntryGS = other.get(j); GeneralNameInterface otherEntry = getGeneralNameInterface(otherEntryGS); switch (thisEntry.constrains(otherEntry)) { case NAME_NARROWS: remove(i); i--; newThis.add(otherEntryGS); sameType = false; break; case NAME_SAME_TYPE: sameType = true; continue; case NAME_MATCH: case NAME_WIDENS: sameType = false; break; case NAME_DIFF_TYPE: default: continue; } break; } // Step 3b: If sameType is still true, we have the situation // where there was a name of the same type as thisEntry in // other, but no name in other widened, matched, or narrowed // thisEntry. if (sameType) { // Step 3b.1: See if there are any entries in this and other // with this type that match, widen, or narrow each other. // If not, then we need to add a "widest subtree" of this // type to excluded. boolean intersection = false; for (int j = 0; j < size(); j++) { GeneralNameInterface thisAltEntry = getGeneralNameInterface(j); if (thisAltEntry.getType() == thisEntry.getType()) { for (int k = 0; k < other.size(); k++) { GeneralNameInterface othAltEntry = other.getGeneralNameInterface(k); int constraintType = thisAltEntry.constrains(othAltEntry); if (constraintType == NAME_MATCH || constraintType == NAME_WIDENS || constraintType == NAME_NARROWS) { intersection = true; break; } } } } if (intersection == false) { if (newExcluded == null) { newExcluded = new GeneralSubtrees(); } GeneralSubtree widestSubtree = createWidestSubtree(thisEntry); if (!newExcluded.contains(widestSubtree)) { newExcluded.add(widestSubtree); } } // Step 3b.2: Remove thisEntry from this remove(i); i--; } } // Step 4: Add all entries in newThis to this if (newThis.size() > 0) { union(newThis); } // Step 5: Add all entries in other that do not have any entry of the // same type in this to this for (int i = 0; i < other.size(); i++) { GeneralSubtree otherEntryGS = other.get(i); GeneralNameInterface otherEntry = getGeneralNameInterface(otherEntryGS); boolean diffType = false; for (int j = 0; j < size(); j++) { GeneralNameInterface thisEntry = getGeneralNameInterface(j); switch (thisEntry.constrains(otherEntry)) { case NAME_DIFF_TYPE: diffType = true; // continue to see if we find something later of the // same type continue; case NAME_NARROWS: case NAME_SAME_TYPE: case NAME_MATCH: case NAME_WIDENS: diffType = false; // we found an entry of the same type // break because we know we won't be adding it to // this now break; default: continue; } break; } if (diffType) { add(otherEntryGS); } } // Step 6: Return the newExcluded GeneralSubtrees return newExcluded; }
intersect this GeneralSubtrees with other. This function is used in merging permitted NameConstraints. The operation is performed as follows: <ul> <li>If a name in other narrows all names of the same type in this, the result will contain the narrower name and none of the names it narrows. <li>If a name in other widens all names of the same type in this, the result will not contain the wider name. <li>If a name in other does not share the same subtree with any name of the same type in this, then the name is added to the list of GeneralSubtrees returned. These names should be added to the list of names that are specifically excluded. The reason is that, if the intersection is empty, then no names of that type are permitted, and the only way to express this in NameConstraints is to include the name in excludedNames. <li>If a name in this has no name of the same type in other, then the result contains the name in this. No name of a given type means the name type is completely permitted. <li>If a name in other has no name of the same type in this, then the result contains the name in other. This means that the name is now constrained in some way, whereas before it was completely permitted. <ul> @param other GeneralSubtrees to be intersected with this @returns GeneralSubtrees to be merged with excluded; these are empty-valued name types corresponding to entries that were of the same type but did not share the same subtree between this and other. Returns null if no such.
GeneralSubtrees::intersect
java
Reginer/aosp-android-jar
android-35/src/sun/security/x509/GeneralSubtrees.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/security/x509/GeneralSubtrees.java
MIT
public void union(GeneralSubtrees other) { if (other != null) { for (int i = 0, n = other.size(); i < n; i++) { add(other.get(i)); } // Minimize this minimize(); } }
construct union of this GeneralSubtrees with other. @param other GeneralSubtrees to be united with this
GeneralSubtrees::union
java
Reginer/aosp-android-jar
android-35/src/sun/security/x509/GeneralSubtrees.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/security/x509/GeneralSubtrees.java
MIT
public void reduce(GeneralSubtrees excluded) { if (excluded == null) { return; } for (int i = 0, n = excluded.size(); i < n; i++) { GeneralNameInterface excludedName = excluded.getGeneralNameInterface(i); for (int j = 0; j < size(); j++) { GeneralNameInterface permitted = getGeneralNameInterface(j); switch (excludedName.constrains(permitted)) { case GeneralNameInterface.NAME_DIFF_TYPE: break; case GeneralNameInterface.NAME_MATCH: remove(j); j--; break; case GeneralNameInterface.NAME_NARROWS: /* permitted narrows excluded */ remove(j); j--; break; case GeneralNameInterface.NAME_WIDENS: /* permitted widens excluded */ break; case GeneralNameInterface.NAME_SAME_TYPE: break; } } /* end of this pass of permitted */ } /* end of pass of excluded */ }
reduce this GeneralSubtrees by contents of another. This function is used in merging excluded NameConstraints with permitted NameConstraints to obtain a minimal form of permitted NameConstraints. It is an optimization, and does not affect correctness of the results. @param excluded GeneralSubtrees
GeneralSubtrees::reduce
java
Reginer/aosp-android-jar
android-35/src/sun/security/x509/GeneralSubtrees.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/security/x509/GeneralSubtrees.java
MIT
public static int copyNativeBinaries(Handle handle, File sharedLibraryDir, String abi) { for (long apkHandle : handle.apkHandles) { int res = nativeCopyNativeBinaries(apkHandle, sharedLibraryDir.getPath(), abi, handle.extractNativeLibs, handle.debuggable); if (res != INSTALL_SUCCEEDED) { return res; } } return INSTALL_SUCCEEDED; }
Copies native binaries to a shared library directory. @param handle APK file to scan for native libraries @param sharedLibraryDir directory for libraries to be copied to @return {@link PackageManager#INSTALL_SUCCEEDED} if successful or another error code from that class if not
Handle::copyNativeBinaries
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/content/NativeLibraryHelper.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/content/NativeLibraryHelper.java
MIT
public static int findSupportedAbi(Handle handle, String[] supportedAbis) { int finalRes = NO_NATIVE_LIBRARIES; for (long apkHandle : handle.apkHandles) { final int res = nativeFindSupportedAbi(apkHandle, supportedAbis, handle.debuggable); if (res == NO_NATIVE_LIBRARIES) { // No native code, keep looking through all APKs. } else if (res == INSTALL_FAILED_NO_MATCHING_ABIS) { // Found some native code, but no ABI match; update our final // result if we haven't found other valid code. if (finalRes < 0) { finalRes = INSTALL_FAILED_NO_MATCHING_ABIS; } } else if (res >= 0) { // Found valid native code, track the best ABI match if (finalRes < 0 || res < finalRes) { finalRes = res; } } else { // Unexpected error; bail return res; } } return finalRes; }
Checks if a given APK contains native code for any of the provided {@code supportedAbis}. Returns an index into {@code supportedAbis} if a matching ABI is found, {@link PackageManager#NO_NATIVE_LIBRARIES} if the APK doesn't contain any native code, and {@link PackageManager#INSTALL_FAILED_NO_MATCHING_ABIS} if none of the ABIs match.
Handle::findSupportedAbi
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/content/NativeLibraryHelper.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/content/NativeLibraryHelper.java
MIT
public static void removeNativeBinariesFromDirLI(File nativeLibraryRoot, boolean deleteRootDir) { if (DEBUG_NATIVE) { Slog.w(TAG, "Deleting native binaries from: " + nativeLibraryRoot.getPath()); } /* * Just remove any file in the directory. Since the directory is owned * by the 'system' UID, the application is not supposed to have written * anything there. */ if (nativeLibraryRoot.exists()) { final File[] files = nativeLibraryRoot.listFiles(); if (files != null) { for (int nn = 0; nn < files.length; nn++) { if (DEBUG_NATIVE) { Slog.d(TAG, " Deleting " + files[nn].getName()); } if (files[nn].isDirectory()) { removeNativeBinariesFromDirLI(files[nn], true /* delete root dir */); } else if (!files[nn].delete()) { Slog.w(TAG, "Could not delete native binary: " + files[nn].getPath()); } } } // Do not delete 'lib' directory itself, unless we're specifically // asked to or this will prevent installation of future updates. if (deleteRootDir) { if (!nativeLibraryRoot.delete()) { Slog.w(TAG, "Could not delete native binary directory: " + nativeLibraryRoot.getPath()); } } } }
Remove the native binaries of a given package. This deletes the files
Handle::removeNativeBinariesFromDirLI
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/content/NativeLibraryHelper.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/content/NativeLibraryHelper.java
MIT
public static void createNativeLibrarySubdir(File path) throws IOException { if (!path.isDirectory()) { path.delete(); if (!path.mkdir()) { throw new IOException("Cannot create " + path.getPath()); } try { Os.chmod(path.getPath(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); } catch (ErrnoException e) { throw new IOException("Cannot chmod native library directory " + path.getPath(), e); } } else if (!SELinux.restorecon(path)) { throw new IOException("Cannot set SELinux context for " + path.getPath()); } }
@hide
Handle::createNativeLibrarySubdir
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/content/NativeLibraryHelper.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/content/NativeLibraryHelper.java
MIT
private static int incrementalConfigureNativeBinariesForSupportedAbi(Handle handle, File libSubDir, String abi) { final String[] apkPaths = handle.apkPaths; if (apkPaths == null || apkPaths.length == 0) { Slog.e(TAG, "No apks to extract native libraries from."); return PackageManager.INSTALL_FAILED_INTERNAL_ERROR; } final IBinder incrementalService = ServiceManager.getService(Context.INCREMENTAL_SERVICE); if (incrementalService == null) { //TODO(b/133435829): add incremental specific error codes return PackageManager.INSTALL_FAILED_INTERNAL_ERROR; } final IncrementalManager incrementalManager = new IncrementalManager( IIncrementalService.Stub.asInterface(incrementalService)); final File apkParent = new File(apkPaths[0]).getParentFile(); IncrementalStorage incrementalStorage = incrementalManager.openStorage(apkParent.getAbsolutePath()); if (incrementalStorage == null) { Slog.e(TAG, "Failed to find incremental storage"); return PackageManager.INSTALL_FAILED_INTERNAL_ERROR; } String libRelativeDir = getRelativePath(apkParent, libSubDir); if (libRelativeDir == null) { return PackageManager.INSTALL_FAILED_INTERNAL_ERROR; } for (int i = 0; i < apkPaths.length; i++) { if (!incrementalStorage.configureNativeBinaries(apkPaths[i], libRelativeDir, abi, handle.extractNativeLibs)) { return PackageManager.INSTALL_FAILED_INTERNAL_ERROR; } } return PackageManager.INSTALL_SUCCEEDED; }
Configure the native library files managed by Incremental Service. Makes sure Incremental Service will create native library directories and set up native library binary files in the same structure as they are in non-incremental installations. @param handle The Handle object that contains all apk paths. @param libSubDir The target directory to put the native library files, e.g., lib/ or lib/arm @param abi The abi that is supported by the current device. @return Integer code if installation succeeds or fails.
Handle::incrementalConfigureNativeBinariesForSupportedAbi
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/content/NativeLibraryHelper.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/content/NativeLibraryHelper.java
MIT
protected static void invokeFromTransform(MethodHandle target, EmulatedStackFrame stackFrame) throws Throwable { if (target instanceof Transformer) { ((Transformer) target).transform(stackFrame); } else { final MethodHandle adaptedTarget = target.asType(stackFrame.getMethodType()); adaptedTarget.invokeExactWithFrame(stackFrame); } }
Performs a MethodHandle.invoke() call with arguments held in an EmulatedStackFrame. @param target the method handle to invoke @param stackFrame the stack frame containing arguments for the invocation
Transformer::invokeFromTransform
java
Reginer/aosp-android-jar
android-34/src/java/lang/invoke/Transformers.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/lang/invoke/Transformers.java
MIT
protected void invokeExactFromTransform(MethodHandle target, EmulatedStackFrame stackFrame) throws Throwable { if (target instanceof Transformer) { ((Transformer) target).transform(stackFrame); } else { target.invokeExactWithFrame(stackFrame); } }
Performs a MethodHandle.invokeExact() call with arguments held in an EmulatedStackFrame. @param target the method handle to invoke @param stackFrame the stack frame containing arguments for the invocation
Transformer::invokeExactFromTransform
java
Reginer/aosp-android-jar
android-34/src/java/lang/invoke/Transformers.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/lang/invoke/Transformers.java
MIT