Commit e94adc9b authored by android-build-team Robot's avatar android-build-team Robot

Merge cherrypicks of [4787603, 4787134, 4787604, 4786834, 4787135, 4787488,...

Merge cherrypicks of [4787603, 4787134, 4787604, 4786834, 4787135, 4787488, 4786835, 4787489, 4787490, 4787548, 4787549, 4787550, 4787551, 4787552, 4787553, 4787502, 4786836, 4785839, 4787620, 4787621, 4787622, 4787623, 4787624, 4787625, 4787626, 4787627, 4787628] into oc-m7-release

Change-Id: I601b76d218a5f03fb1506cbd22a2c9d2cec85469
parents 3c2c834a 6033d76b
......@@ -1732,7 +1732,8 @@ public final class SQLiteDatabase extends SQLiteClosable {
executeSql(sql, bindArgs);
}
private int executeSql(String sql, Object[] bindArgs) throws SQLException {
/** {@hide} */
public int executeSql(String sql, Object[] bindArgs) throws SQLException {
acquireReference();
try {
if (DatabaseUtils.getSqlStatementType(sql) == DatabaseUtils.STATEMENT_ATTACH) {
......
This diff is collapsed.
......@@ -368,6 +368,98 @@ class TextLine {
return h;
}
/**
* @see #measure(int, boolean, FontMetricsInt)
* @return The measure results for all possible offsets
*/
float[] measureAllOffsets(boolean[] trailing, FontMetricsInt fmi) {
float[] measurement = new float[mLen + 1];
int[] target = new int[mLen + 1];
for (int offset = 0; offset < target.length; ++offset) {
target[offset] = trailing[offset] ? offset - 1 : offset;
}
if (target[0] < 0) {
measurement[0] = 0;
}
float h = 0;
if (!mHasTabs) {
if (mDirections == Layout.DIRS_ALL_LEFT_TO_RIGHT) {
for (int offset = 0; offset <= mLen; ++offset) {
measurement[offset] = measureRun(0, offset, mLen, false, fmi);
}
return measurement;
}
if (mDirections == Layout.DIRS_ALL_RIGHT_TO_LEFT) {
for (int offset = 0; offset <= mLen; ++offset) {
measurement[offset] = measureRun(0, offset, mLen, true, fmi);
}
return measurement;
}
}
char[] chars = mChars;
int[] runs = mDirections.mDirections;
for (int i = 0; i < runs.length; i += 2) {
int runStart = runs[i];
int runLimit = runStart + (runs[i + 1] & Layout.RUN_LENGTH_MASK);
if (runLimit > mLen) {
runLimit = mLen;
}
boolean runIsRtl = (runs[i + 1] & Layout.RUN_RTL_FLAG) != 0;
int segstart = runStart;
for (int j = mHasTabs ? runStart : runLimit; j <= runLimit; ++j) {
int codept = 0;
if (mHasTabs && j < runLimit) {
codept = chars[j];
if (codept >= 0xD800 && codept < 0xDC00 && j + 1 < runLimit) {
codept = Character.codePointAt(chars, j);
if (codept > 0xFFFF) {
++j;
continue;
}
}
}
if (j == runLimit || codept == '\t') {
float oldh = h;
boolean advance = (mDir == Layout.DIR_RIGHT_TO_LEFT) == runIsRtl;
float w = measureRun(segstart, j, j, runIsRtl, fmi);
h += advance ? w : -w;
float baseh = advance ? oldh : h;
FontMetricsInt crtfmi = advance ? fmi : null;
for (int offset = segstart; offset <= j && offset <= mLen; ++offset) {
if (target[offset] >= segstart && target[offset] < j) {
measurement[offset] =
baseh + measureRun(segstart, offset, j, runIsRtl, crtfmi);
}
}
if (codept == '\t') {
if (target[j] == j) {
measurement[j] = h;
}
h = mDir * nextTab(h * mDir);
if (target[j + 1] == j) {
measurement[j + 1] = h;
}
}
segstart = j + 1;
}
}
}
if (target[mLen] == mLen) {
measurement[mLen] = h;
}
return measurement;
}
/**
* Draws a unidirectional (but possibly multi-styled) run of text.
*
......
......@@ -8841,10 +8841,17 @@ public class ActivityManagerService extends IActivityManager.Stub
}
}
// If we're extending a persistable grant, then we always need to create
// the grant data structure so that take/release APIs work
// Figure out the value returned when access is allowed
final int allowedResult;
if ((modeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0) {
return targetUid;
// If we're extending a persistable grant, then we need to return
// "targetUid" so that we always create a grant data structure to
// support take/release APIs
allowedResult = targetUid;
} else {
// Otherwise, we can return "-1" to indicate that no grant data
// structures need to be created
allowedResult = -1;
}
if (targetUid >= 0) {
......@@ -8853,7 +8860,7 @@ public class ActivityManagerService extends IActivityManager.Stub
// No need to grant the target this permission.
if (DEBUG_URI_PERMISSION) Slog.v(TAG_URI_PERMISSION,
"Target " + targetPkg + " already has full permission to " + grantUri);
return -1;
return allowedResult;
}
} else {
// First... there is no target package, so can anyone access it?
......@@ -8869,7 +8876,7 @@ public class ActivityManagerService extends IActivityManager.Stub
}
}
if (allowed) {
return -1;
return allowedResult;
}
}
......@@ -624,6 +624,8 @@ public class PackageManagerService extends IPackageManager.Stub
*/
private static final boolean DEFAULT_PACKAGE_PARSER_CACHE_ENABLED = true;
private static final int PROTECTION_MASK_BASE = 0xf;
final ServiceThread mHandlerThread;
final PackageHandler mHandler;
......@@ -5761,11 +5763,12 @@ public class PackageManagerService extends IPackageManager.Stub
@Override
public void revokeRuntimePermission(String packageName, String name, int userId) {
revokeRuntimePermission(packageName, name, userId, false /* Only if not fixed by policy */);
revokeRuntimePermission(packageName, name, userId, false /* Only if not fixed by policy */,
mSettings.getPermission(name));
}
private void revokeRuntimePermission(String packageName, String name, int userId,
boolean overridePolicy) {
boolean overridePolicy, BasePermission bp) {
if (!sUserManager.exists(userId)) {
Log.e(TAG, "No such user:" + userId);
return;
......@@ -5791,7 +5794,6 @@ public class PackageManagerService extends IPackageManager.Stub
|| filterAppAccessLPr(ps, Binder.getCallingUid(), userId)) {
throw new IllegalArgumentException("Unknown package: " + packageName);
}
final BasePermission bp = mSettings.mPermissions.get(name);
if (bp == null) {
throw new IllegalArgumentException("Unknown permission: " + name);
}
......@@ -5913,7 +5915,7 @@ public class PackageManagerService extends IPackageManager.Stub
try {
revokeRuntimePermission(packageName, permissionName, userId,
false);
false, mSettings.getPermission(permissionName));
} catch (IllegalArgumentException e) {
Slog.e(TAG, "Could not revoke " + permissionName + " from "
+ packageName, e);
......@@ -12792,7 +12794,10 @@ public class PackageManagerService extends IPackageManager.Stub
if (DEBUG_REMOVE) Log.d(TAG, " Activities: " + r);
}
final ArrayList<String> allPackageNames = new ArrayList<>(mPackages.keySet());
N = pkg.permissions.size();
List<BasePermission> bps = new ArrayList<BasePermission>(N);
r = null;
for (i=0; i<N; i++) {
PackageParser.Permission p = pkg.permissions.get(i);
......@@ -12801,6 +12806,10 @@ public class PackageManagerService extends IPackageManager.Stub
bp = mSettings.mPermissionTrees.get(p.info.name);
}
if (bp != null && bp.perm == p) {
if (((p.info.protectionLevel & PROTECTION_MASK_BASE) &
PermissionInfo.PROTECTION_DANGEROUS) != 0) {
bps.add(bp);
}
bp.perm = null;
if (DEBUG_REMOVE && chatty) {
if (r == null) {
......@@ -12818,6 +12827,45 @@ public class PackageManagerService extends IPackageManager.Stub
}
}
}
AsyncTask.execute(() -> {
final int numRemovedPermissions = bps.size();
for (int permissionNum = 0; permissionNum < numRemovedPermissions; permissionNum++) {
final int[] userIds = mUserManagerInternal.getUserIds();
final int numUserIds = userIds.length;
final int numPackages = allPackageNames.size();
for (int packageNum = 0; packageNum < numPackages; packageNum++) {
final String packageName = allPackageNames.get(packageNum);
final PackageManagerInternal packageManagerInt =
LocalServices.getService(PackageManagerInternal.class);
final ApplicationInfo applicationInfo = packageManagerInt.getApplicationInfo(
packageName, 0, Process.SYSTEM_UID, UserHandle.USER_SYSTEM);
if (applicationInfo != null
&& applicationInfo.targetSdkVersion < Build.VERSION_CODES.M) {
continue;
}
for (int userIdNum = 0; userIdNum < numUserIds; userIdNum++) {
final int userId = userIds[userIdNum];
final String permissionName = bps.get(permissionNum).name;
if (checkPermission(permissionName, packageName,
userId) == PackageManager.PERMISSION_GRANTED) {
try {
revokeRuntimePermission(packageName,
permissionName,
userId,
false,
bps.get(permissionNum));
} catch (IllegalArgumentException e) {
Slog.e(TAG, "Could not revoke " + permissionName + " from "
+ packageName, e);
}
}
}
}
}
});
if (r != null) {
if (DEBUG_REMOVE) Log.d(TAG, " Permissions: " + r);
}
......@@ -25525,7 +25573,7 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
public void revokeRuntimePermission(String packageName, String name, int userId,
boolean overridePolicy) {
PackageManagerService.this.revokeRuntimePermission(packageName, name, userId,
overridePolicy);
overridePolicy, mSettings.getPermission(name));
}
@Override
......@@ -449,6 +449,17 @@ final class Settings {
mBackupStoppedPackagesFilename = new File(mSystemDir, "packages-stopped-backup.xml");
}
public @Nullable BasePermission getPermission(@NonNull String permName) {
synchronized (mLock) {
return getPermissionLocked(permName);
}
}
@GuardedBy("mLock")
@Nullable BasePermission getPermissionLocked(@NonNull String permName) {
return mPermissions.get(permName);
}
PackageSetting getPackageLPr(String pkgName) {
return mPackages.get(pkgName);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment