Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Merge tag 'android-8.1.0_r75' of https://android.googlesource.com/pla…
Browse files Browse the repository at this point in the history
…tform/frameworks/base into staging/lineage-15.1_merge-android-8.1.0_r75

Android 8.1.0 Release 75 (6197208)

* tag 'android-8.1.0_r75' of https://android.googlesource.com/platform/frameworks/base:
  Fix potential double destroy of AssetManager
  Revoke 'always' web handler status when not autoverifying
  Add STATUS_BAR permission to dialer in oc-rm1

Change-Id: I7173663a4ebaaa71ac5e5fccfff7acdbcabd4eda
  • Loading branch information
haggertk committed Apr 7, 2020
2 parents 9f82ba7 + b7a2a33 commit 6aed87b
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 42 deletions.
69 changes: 38 additions & 31 deletions core/java/android/content/res/AssetManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,24 @@ public final class AssetManager implements AutoCloseable {

private static final String TAG = "AssetManager";
private static final boolean localLOGV = false || false;

private static final boolean DEBUG_REFS = false;

private static final Object sSync = new Object();
/*package*/ static AssetManager sSystem = null;

private final TypedValue mValue = new TypedValue();
private final long[] mOffsets = new long[2];

// For communication with native code.
private long mObject;

private StringBlock mStringBlocks[] = null;

private int mNumRefs = 1;
private boolean mOpen = true;
private HashMap<Long, RuntimeException> mRefStacks;

/**
* Create a new AssetManager containing only the basic system assets.
* Applications will not generally use this method, instead retrieving the
Expand Down Expand Up @@ -351,10 +351,10 @@ final StringBlock[] ensureStringBlocks() {
* Open an asset using ACCESS_STREAMING mode. This provides access to
* files that have been bundled with an application as assets -- that is,
* files placed in to the "assets" directory.
*
*
* @param fileName The name of the asset to open. This name can be
* hierarchical.
*
*
* @see #open(String, int)
* @see #list
*/
Expand All @@ -367,11 +367,11 @@ public final InputStream open(String fileName) throws IOException {
* read its contents. This provides access to files that have been bundled
* with an application as assets -- that is, files placed in to the
* "assets" directory.
*
*
* @param fileName The name of the asset to open. This name can be
* hierarchical.
* @param accessMode Desired access mode for retrieving the data.
*
*
* @see #ACCESS_UNKNOWN
* @see #ACCESS_STREAMING
* @see #ACCESS_RANDOM
Expand Down Expand Up @@ -411,14 +411,14 @@ public final AssetFileDescriptor openFd(String fileName)

/**
* Return a String array of all the assets at the given path.
*
*
* @param path A relative path within the assets, i.e., "docs/home.html".
*
*
* @return String[] Array of strings, one for each asset. These file
* names are relative to 'path'. You can open the file by
* concatenating 'path' and a name in the returned string (via
* File) and passing that to open().
*
*
* @see #open
*/
public native final String[] list(String path)
Expand All @@ -430,7 +430,7 @@ public native final String[] list(String path)
* provides direct access to all of the files included in an application
* package (not only its assets). Applications should not normally use
* this.
*
*
* @see #open(String)
*/
public final InputStream openNonAsset(String fileName) throws IOException {
Expand All @@ -443,7 +443,7 @@ public final InputStream openNonAsset(String fileName) throws IOException {
* provides direct access to all of the files included in an application
* package (not only its assets). Applications should not normally use
* this.
*
*
* @see #open(String, int)
*/
public final InputStream openNonAsset(String fileName, int accessMode)
Expand All @@ -454,7 +454,7 @@ public final InputStream openNonAsset(String fileName, int accessMode)
/**
* {@hide}
* Open a non-asset in a specified package. Not for use by applications.
*
*
* @param cookie Identifier of the package to be opened.
* @param fileName Name of the asset to retrieve.
*/
Expand All @@ -466,7 +466,7 @@ public final InputStream openNonAsset(int cookie, String fileName)
/**
* {@hide}
* Open a non-asset in a specified package. Not for use by applications.
*
*
* @param cookie Identifier of the package to be opened.
* @param fileName Name of the asset to retrieve.
* @param accessMode Desired access mode for retrieving the data.
Expand All @@ -491,7 +491,7 @@ public final AssetFileDescriptor openNonAssetFd(String fileName)
throws IOException {
return openNonAssetFd(0, fileName);
}

public final AssetFileDescriptor openNonAssetFd(int cookie,
String fileName) throws IOException {
synchronized (this) {
Expand All @@ -506,20 +506,20 @@ public final AssetFileDescriptor openNonAssetFd(int cookie,
}
throw new FileNotFoundException("Asset absolute file: " + fileName);
}

/**
* Retrieve a parser for a compiled XML file.
*
*
* @param fileName The name of the file to retrieve.
*/
public final XmlResourceParser openXmlResourceParser(String fileName)
throws IOException {
return openXmlResourceParser(0, fileName);
}

/**
* Retrieve a parser for a compiled XML file.
*
*
* @param cookie Identifier of the package to be opened.
* @param fileName The name of the file to retrieve.
*/
Expand All @@ -535,7 +535,7 @@ public final XmlResourceParser openXmlResourceParser(int cookie,
* {@hide}
* Retrieve a non-asset as a compiled XML file. Not for use by
* applications.
*
*
* @param fileName The name of the file to retrieve.
*/
/*package*/ final XmlBlock openXmlBlockAsset(String fileName)
Expand All @@ -547,7 +547,7 @@ public final XmlResourceParser openXmlResourceParser(int cookie,
* {@hide}
* Retrieve a non-asset as a compiled XML file. Not for use by
* applications.
*
*
* @param cookie Identifier of the package to be opened.
* @param fileName Name of the asset to retrieve.
*/
Expand Down Expand Up @@ -602,12 +602,18 @@ protected void finalize() throws Throwable {
}
}
}
destroy();

synchronized (this) {
if (mObject != 0) {
destroy();
mObject = 0;
}
}
} finally {
super.finalize();
}
}

public final class AssetInputStream extends InputStream {
/**
* @hide
Expand Down Expand Up @@ -810,7 +816,7 @@ public native final void setConfiguration(int mcc, int mnc, String locale,
/*package*/ native final String getResourcePackageName(int resid);
/*package*/ native final String getResourceTypeName(int resid);
/*package*/ native final String getResourceEntryName(int resid);

private native final long openAsset(String fileName, int accessMode);
private final native ParcelFileDescriptor openAssetFd(String fileName,
long[] outOffsets) throws IOException;
Expand Down Expand Up @@ -870,17 +876,17 @@ private native final int loadResourceBagValue(int ident, int bagEntryId, TypedVa
* {@hide}
*/
public native static final int getGlobalAssetCount();

/**
* {@hide}
*/
public native static final String getAssetAllocations();

/**
* {@hide}
*/
public native static final int getGlobalAssetManagerCount();

private native final long newTheme();
private native final void deleteTheme(long theme);
/*package*/ native static final void applyThemeStyle(long theme, int styleRes, boolean force);
Expand Down Expand Up @@ -914,16 +920,17 @@ private final void incRefsLocked(long id) {
}
mNumRefs++;
}

private final void decRefsLocked(long id) {
if (DEBUG_REFS && mRefStacks != null) {
mRefStacks.remove(id);
}
mNumRefs--;
//System.out.println("Dec streams: mNumRefs=" + mNumRefs
// + " mReleased=" + mReleased);
if (mNumRefs == 0) {
if (mNumRefs == 0 && mObject != 0) {
destroy();
mObject = 0;
}
}
}
1 change: 1 addition & 0 deletions data/etc/privapp-permissions-platform.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ applications that come with the platform
<permission name="android.permission.CONTROL_INCALL_EXPERIENCE"/>
<permission name="android.permission.GET_ACCOUNTS_PRIVILEGED"/>
<permission name="android.permission.MODIFY_PHONE_STATE"/>
<permission name="android.permission.STATUS_BAR"/>
<permission name="android.permission.STOP_APP_SWITCHES"/>
<permission name="com.android.voicemail.permission.READ_VOICEMAIL"/>
<permission name="com.android.voicemail.permission.WRITE_VOICEMAIL"/>
Expand Down
44 changes: 33 additions & 11 deletions services/core/java/com/android/server/pm/PackageManagerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19106,35 +19106,47 @@ private void verifyIntentFiltersIfNeeded(int userId, int verifierUid, boolean re
int count = 0;
final String packageName = pkg.packageName;

boolean handlesWebUris = false;
final boolean alreadyVerified;
synchronized (mPackages) {
// If this is a new install and we see that we've already run verification for this
// package, we have nothing to do: it means the state was restored from backup.
if (!replacing) {
IntentFilterVerificationInfo ivi =
mSettings.getIntentFilterVerificationLPr(packageName);
if (ivi != null) {
if (DEBUG_DOMAIN_VERIFICATION) {
Slog.i(TAG, "Package " + packageName+ " already verified: status="
+ ivi.getStatusString());
}
return;
final IntentFilterVerificationInfo ivi =
mSettings.getIntentFilterVerificationLPr(packageName);
alreadyVerified = (ivi != null);
if (!replacing && alreadyVerified) {
if (DEBUG_DOMAIN_VERIFICATION) {
Slog.i(TAG, "Package " + packageName + " already verified: status="
+ ivi.getStatusString());
}
return;
}

// If any filters need to be verified, then all need to be.
// If any filters need to be verified, then all need to be. In addition, we need to
// know whether an updating app has any web navigation intent filters, to re-
// examine handling policy even if not re-verifying.
boolean needToVerify = false;
for (PackageParser.Activity a : pkg.activities) {
for (ActivityIntentInfo filter : a.intents) {
if (filter.handlesWebUris(true)) {
handlesWebUris = true;
}
if (filter.needsVerification() && needsNetworkVerificationLPr(filter)) {
if (DEBUG_DOMAIN_VERIFICATION) {
Slog.d(TAG, "Intent filter needs verification, so processing all filters");
}
needToVerify = true;
// It's safe to break out here because filter.needsVerification()
// can only be true if filter.handlesWebUris(true) returns true, so
// we've already noted that.
break;
}
}
}

// Note whether this app publishes any web navigation handling support at all,
// and whether there are any web-nav filters that fit the profile for running
// a verification pass now.
if (needToVerify) {
final int verificationId = mIntentFilterVerificationToken++;
for (PackageParser.Activity a : pkg.activities) {
Expand All @@ -19152,13 +19164,23 @@ private void verifyIntentFiltersIfNeeded(int userId, int verifierUid, boolean re
}

if (count > 0) {
// count > 0 means that we're running a full verification pass
if (DEBUG_DOMAIN_VERIFICATION) Slog.d(TAG, "Starting " + count
+ " IntentFilter verification" + (count > 1 ? "s" : "")
+ " for userId:" + userId);
mIntentFilterVerifier.startVerifications(userId);
} else if (alreadyVerified && handlesWebUris) {
// App used autoVerify in the past, no longer does, but still handles web
// navigation starts.
if (DEBUG_DOMAIN_VERIFICATION) {
Slog.d(TAG, "App changed web filters but no longer verifying - resetting policy");
}
synchronized (mPackages) {
clearIntentFilterVerificationsLPw(packageName, userId);
}
} else {
if (DEBUG_DOMAIN_VERIFICATION) {
Slog.d(TAG, "No filters or not all autoVerify for " + packageName);
Slog.d(TAG, "No web filters or no prior verify policy for " + packageName);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions services/core/java/com/android/server/pm/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,7 @@ boolean removeIntentFilterVerificationLPw(String packageName, int userId) {
return false;
}
ps.clearDomainVerificationStatusForUser(userId);
ps.setIntentFilterVerificationInfo(null);
return true;
}

Expand Down

0 comments on commit 6aed87b

Please sign in to comment.