Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 201bfd62 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8479861 from 225f760c to tm-qpr1-release

Change-Id: I8f965c84ebc642f099e2c0f8ee94086096ba00bf
parents 2d274052 225f760c
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,14 @@
    }
    }
  ],
  ],
  "presubmit": [
  "presubmit": [
    {
      "name": "ManagedProvisioningTests",
      "options": [
        {
          "exclude-annotation": "androidx.test.filters.FlakyTest"
        }
      ]
    },
    {
    {
      "file_patterns": [
      "file_patterns": [
        "ApexManager\\.java",
        "ApexManager\\.java",
+16 −0
Original line number Original line Diff line number Diff line
@@ -506,6 +506,22 @@ public class BlobStoreManager {
        }
        }
    }
    }


    /**
     * Release all the leases which are currently held by the caller.
     *
     * @hide
     */
    public void releaseAllLeases() throws Exception {
        try {
            mService.releaseAllLeases(mContext.getOpPackageName());
        } catch (ParcelableException e) {
            e.maybeRethrow(IOException.class);
            throw new RuntimeException(e);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
    /**
     * Return the remaining quota size for acquiring a lease (in bytes) which indicates the
     * Return the remaining quota size for acquiring a lease (in bytes) which indicates the
     * remaining amount of data that an app can acquire a lease on before the System starts
     * remaining amount of data that an app can acquire a lease on before the System starts
+1 −0
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@ interface IBlobStoreManager {
    void acquireLease(in BlobHandle handle, int descriptionResId, in CharSequence description,
    void acquireLease(in BlobHandle handle, int descriptionResId, in CharSequence description,
            long leaseTimeoutMillis, in String packageName);
            long leaseTimeoutMillis, in String packageName);
    void releaseLease(in BlobHandle handle, in String packageName);
    void releaseLease(in BlobHandle handle, in String packageName);
    void releaseAllLeases(in String packageName);
    long getRemainingLeaseQuotaBytes(String packageName);
    long getRemainingLeaseQuotaBytes(String packageName);


    void waitForIdle(in RemoteCallback callback);
    void waitForIdle(in RemoteCallback callback);
+36 −6
Original line number Original line Diff line number Diff line
@@ -554,6 +554,21 @@ public class BlobStoreManagerService extends SystemService {
        }
        }
    }
    }


    private void releaseAllLeasesInternal(int callingUid, String callingPackage) {
        synchronized (mBlobsLock) {
            // Remove the package from the leasee list
            mBlobsMap.forEach((blobHandle, blobMetadata) -> {
                blobMetadata.removeLeasee(callingPackage, callingUid);
            });
            writeBlobsInfoAsync();

            if (LOGV) {
                Slog.v(TAG, "Release all leases associated with pkg="
                        + callingPackage + ", uid=" + callingUid);
            }
        }
    }

    private long getRemainingLeaseQuotaBytesInternal(int callingUid, String callingPackage) {
    private long getRemainingLeaseQuotaBytesInternal(int callingUid, String callingPackage) {
        synchronized (mBlobsLock) {
        synchronized (mBlobsLock) {
            final long remainingQuota = BlobStoreConfig.getAppDataBytesLimit()
            final long remainingQuota = BlobStoreConfig.getAppDataBytesLimit()
@@ -1376,7 +1391,7 @@ public class BlobStoreManagerService extends SystemService {
        }
        }
    }
    }


    private boolean isAllowedBlobAccess(int uid, String packageName) {
    private boolean isAllowedBlobStoreAccess(int uid, String packageName) {
        return (!Process.isSdkSandboxUid(uid) && !Process.isIsolated(uid)
        return (!Process.isSdkSandboxUid(uid) && !Process.isIsolated(uid)
                && !mPackageManagerInternal.isInstantApp(packageName, UserHandle.getUserId(uid)));
                && !mPackageManagerInternal.isInstantApp(packageName, UserHandle.getUserId(uid)));
    }
    }
@@ -1442,7 +1457,7 @@ public class BlobStoreManagerService extends SystemService {
            final int callingUid = Binder.getCallingUid();
            final int callingUid = Binder.getCallingUid();
            verifyCallingPackage(callingUid, packageName);
            verifyCallingPackage(callingUid, packageName);


            if (!isAllowedBlobAccess(callingUid, packageName)) {
            if (!isAllowedBlobStoreAccess(callingUid, packageName)) {
                throw new SecurityException("Caller not allowed to create session; "
                throw new SecurityException("Caller not allowed to create session; "
                        + "callingUid=" + callingUid + ", callingPackage=" + packageName);
                        + "callingUid=" + callingUid + ", callingPackage=" + packageName);
            }
            }
@@ -1491,7 +1506,7 @@ public class BlobStoreManagerService extends SystemService {
            final int callingUid = Binder.getCallingUid();
            final int callingUid = Binder.getCallingUid();
            verifyCallingPackage(callingUid, packageName);
            verifyCallingPackage(callingUid, packageName);


            if (!isAllowedBlobAccess(callingUid, packageName)) {
            if (!isAllowedBlobStoreAccess(callingUid, packageName)) {
                throw new SecurityException("Caller not allowed to open blob; "
                throw new SecurityException("Caller not allowed to open blob; "
                        + "callingUid=" + callingUid + ", callingPackage=" + packageName);
                        + "callingUid=" + callingUid + ", callingPackage=" + packageName);
            }
            }
@@ -1522,7 +1537,7 @@ public class BlobStoreManagerService extends SystemService {
            final int callingUid = Binder.getCallingUid();
            final int callingUid = Binder.getCallingUid();
            verifyCallingPackage(callingUid, packageName);
            verifyCallingPackage(callingUid, packageName);


            if (!isAllowedBlobAccess(callingUid, packageName)) {
            if (!isAllowedBlobStoreAccess(callingUid, packageName)) {
                throw new SecurityException("Caller not allowed to open blob; "
                throw new SecurityException("Caller not allowed to open blob; "
                        + "callingUid=" + callingUid + ", callingPackage=" + packageName);
                        + "callingUid=" + callingUid + ", callingPackage=" + packageName);
            }
            }
@@ -1546,7 +1561,7 @@ public class BlobStoreManagerService extends SystemService {
            final int callingUid = Binder.getCallingUid();
            final int callingUid = Binder.getCallingUid();
            verifyCallingPackage(callingUid, packageName);
            verifyCallingPackage(callingUid, packageName);


            if (!isAllowedBlobAccess(callingUid, packageName)) {
            if (!isAllowedBlobStoreAccess(callingUid, packageName)) {
                throw new SecurityException("Caller not allowed to open blob; "
                throw new SecurityException("Caller not allowed to open blob; "
                        + "callingUid=" + callingUid + ", callingPackage=" + packageName);
                        + "callingUid=" + callingUid + ", callingPackage=" + packageName);
            }
            }
@@ -1554,6 +1569,21 @@ public class BlobStoreManagerService extends SystemService {
            releaseLeaseInternal(blobHandle, callingUid, packageName);
            releaseLeaseInternal(blobHandle, callingUid, packageName);
        }
        }


        @Override
        public void releaseAllLeases(@NonNull String packageName) {
            Objects.requireNonNull(packageName, "packageName must not be null");

            final int callingUid = Binder.getCallingUid();
            verifyCallingPackage(callingUid, packageName);

            if (!isAllowedBlobStoreAccess(callingUid, packageName)) {
                throw new SecurityException("Caller not allowed to open blob; "
                        + "callingUid=" + callingUid + ", callingPackage=" + packageName);
            }

            releaseAllLeasesInternal(callingUid, packageName);
        }

        @Override
        @Override
        public long getRemainingLeaseQuotaBytes(@NonNull String packageName) {
        public long getRemainingLeaseQuotaBytes(@NonNull String packageName) {
            final int callingUid = Binder.getCallingUid();
            final int callingUid = Binder.getCallingUid();
@@ -1629,7 +1659,7 @@ public class BlobStoreManagerService extends SystemService {
            final int callingUid = Binder.getCallingUid();
            final int callingUid = Binder.getCallingUid();
            verifyCallingPackage(callingUid, packageName);
            verifyCallingPackage(callingUid, packageName);


            if (!isAllowedBlobAccess(callingUid, packageName)) {
            if (!isAllowedBlobStoreAccess(callingUid, packageName)) {
                throw new SecurityException("Caller not allowed to open blob; "
                throw new SecurityException("Caller not allowed to open blob; "
                        + "callingUid=" + callingUid + ", callingPackage=" + packageName);
                        + "callingUid=" + callingUid + ", callingPackage=" + packageName);
            }
            }
+8 −8
Original line number Original line Diff line number Diff line
@@ -28,8 +28,8 @@ import static com.android.server.tare.EconomicPolicy.TYPE_REWARD;
import static com.android.server.tare.EconomicPolicy.eventToString;
import static com.android.server.tare.EconomicPolicy.eventToString;
import static com.android.server.tare.EconomicPolicy.getEventType;
import static com.android.server.tare.EconomicPolicy.getEventType;
import static com.android.server.tare.TareUtils.appToString;
import static com.android.server.tare.TareUtils.appToString;
import static com.android.server.tare.TareUtils.cakeToString;
import static com.android.server.tare.TareUtils.getCurrentTimeMillis;
import static com.android.server.tare.TareUtils.getCurrentTimeMillis;
import static com.android.server.tare.TareUtils.narcToString;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
@@ -161,7 +161,7 @@ class Agent {


    @GuardedBy("mLock")
    @GuardedBy("mLock")
    private boolean isAffordableLocked(long balance, long price, long ctp) {
    private boolean isAffordableLocked(long balance, long price, long ctp) {
        return balance >= price && mScribe.getRemainingConsumableNarcsLocked() >= ctp;
        return balance >= price && mScribe.getRemainingConsumableCakesLocked() >= ctp;
    }
    }


    @GuardedBy("mLock")
    @GuardedBy("mLock")
@@ -464,13 +464,13 @@ class Agent {
                    + eventToString(transaction.eventId)
                    + eventToString(transaction.eventId)
                    + (transaction.tag == null ? "" : ":" + transaction.tag)
                    + (transaction.tag == null ? "" : ":" + transaction.tag)
                    + " for " + appToString(userId, pkgName)
                    + " for " + appToString(userId, pkgName)
                    + " by " + narcToString(transaction.delta - newDelta));
                    + " by " + cakeToString(transaction.delta - newDelta));
            transaction = new Ledger.Transaction(
            transaction = new Ledger.Transaction(
                    transaction.startTimeMs, transaction.endTimeMs,
                    transaction.startTimeMs, transaction.endTimeMs,
                    transaction.eventId, transaction.tag, newDelta, transaction.ctp);
                    transaction.eventId, transaction.tag, newDelta, transaction.ctp);
        }
        }
        ledger.recordTransaction(transaction);
        ledger.recordTransaction(transaction);
        mScribe.adjustRemainingConsumableNarcsLocked(-transaction.ctp);
        mScribe.adjustRemainingConsumableCakesLocked(-transaction.ctp);
        if (transaction.delta != 0 && notifyOnAffordabilityChange) {
        if (transaction.delta != 0 && notifyOnAffordabilityChange) {
            final ArraySet<ActionAffordabilityNote> actionAffordabilityNotes =
            final ArraySet<ActionAffordabilityNote> actionAffordabilityNotes =
                    mActionAffordabilityNotes.get(userId, pkgName);
                    mActionAffordabilityNotes.get(userId, pkgName);
@@ -724,7 +724,7 @@ class Agent {
    private void reclaimAssetsLocked(final int userId, @NonNull final String pkgName) {
    private void reclaimAssetsLocked(final int userId, @NonNull final String pkgName) {
        final Ledger ledger = mScribe.getLedgerLocked(userId, pkgName);
        final Ledger ledger = mScribe.getLedgerLocked(userId, pkgName);
        if (ledger.getCurrentBalance() != 0) {
        if (ledger.getCurrentBalance() != 0) {
            mScribe.adjustRemainingConsumableNarcsLocked(-ledger.getCurrentBalance());
            mScribe.adjustRemainingConsumableCakesLocked(-ledger.getCurrentBalance());
        }
        }
        mScribe.discardLedgerLocked(userId, pkgName);
        mScribe.discardLedgerLocked(userId, pkgName);
        mCurrentOngoingEvents.delete(userId, pkgName);
        mCurrentOngoingEvents.delete(userId, pkgName);
@@ -872,7 +872,7 @@ class Agent {
            return;
            return;
        }
        }
        mTrendCalculator.reset(getBalanceLocked(userId, pkgName),
        mTrendCalculator.reset(getBalanceLocked(userId, pkgName),
                mScribe.getRemainingConsumableNarcsLocked(),
                mScribe.getRemainingConsumableCakesLocked(),
                mActionAffordabilityNotes.get(userId, pkgName));
                mActionAffordabilityNotes.get(userId, pkgName));
        ongoingEvents.forEach(mTrendCalculator);
        ongoingEvents.forEach(mTrendCalculator);
        final long lowerTimeMs = mTrendCalculator.getTimeToCrossLowerThresholdMs();
        final long lowerTimeMs = mTrendCalculator.getTimeToCrossLowerThresholdMs();
@@ -1260,11 +1260,11 @@ class Agent {
                        pw.print(" runtime=");
                        pw.print(" runtime=");
                        TimeUtils.formatDuration(nowElapsed - ongoingEvent.startTimeElapsed, pw);
                        TimeUtils.formatDuration(nowElapsed - ongoingEvent.startTimeElapsed, pw);
                        pw.print(" delta/sec=");
                        pw.print(" delta/sec=");
                        pw.print(narcToString(ongoingEvent.getDeltaPerSec()));
                        pw.print(cakeToString(ongoingEvent.getDeltaPerSec()));
                        final long ctp = ongoingEvent.getCtpPerSec();
                        final long ctp = ongoingEvent.getCtpPerSec();
                        if (ctp != 0) {
                        if (ctp != 0) {
                            pw.print(" ctp/sec=");
                            pw.print(" ctp/sec=");
                            pw.print(narcToString(ongoingEvent.getCtpPerSec()));
                            pw.print(cakeToString(ongoingEvent.getCtpPerSec()));
                        }
                        }
                        pw.print(" refCount=");
                        pw.print(" refCount=");
                        pw.print(ongoingEvent.refCount);
                        pw.print(ongoingEvent.refCount);
Loading