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

Commit a69b7eb1 authored by Kenny Root's avatar Kenny Root
Browse files

Change thread priority for disk measurement to bg

Change the thread priority for all disk measurement and statfs calls to
background priority.

Also move the measurement fully into the measurement task since it makes
more sense.

Bug: 6332097
Change-Id: Iafc2151313ad9b14117daf67e933dccd32f68d54
parent 728e4394
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -223,6 +223,8 @@ public class DefaultContainerService extends IntentService {

        @Override
        public long calculateDirectorySize(String path) throws RemoteException {
            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);

            final File directory = new File(path);
            if (directory.exists() && directory.isDirectory()) {
                return MeasurementUtils.measureDirectory(path);
@@ -233,6 +235,8 @@ public class DefaultContainerService extends IntentService {

        @Override
        public long[] getFileSystemStats(String path) {
            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);

            try {
                final StructStatFs stat = Libcore.os.statfs(path);
                final long totalSize = stat.f_blocks * stat.f_bsize;
+13 −17
Original line number Diff line number Diff line
@@ -5600,16 +5600,18 @@ public class PackageManagerService extends IPackageManager.Stub {

        private final IPackageStatsObserver mObserver;

        public MeasureParams(PackageStats stats, boolean success, IPackageStatsObserver observer) {
        public MeasureParams(PackageStats stats, IPackageStatsObserver observer) {
            mObserver = observer;
            mStats = stats;
            mSuccess = success;
        }

        @Override
        void handleStartCopy() throws RemoteException {
            final boolean mounted;
            synchronized (mInstallLock) {
                mSuccess = getPackageSizeInfoLI(mStats.packageName, mStats);
            }

            final boolean mounted;
            if (Environment.isExternalStorageEmulated()) {
                mounted = true;
            } else {
@@ -7781,22 +7783,16 @@ public class PackageManagerService extends IPackageManager.Stub {
            final IPackageStatsObserver observer) {
        mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.GET_PACKAGE_SIZE, null);
        // Queue up an async operation since the package deletion may take a little while.
        mHandler.post(new Runnable() {
            public void run() {
                mHandler.removeCallbacks(this);
                PackageStats stats = new PackageStats(packageName);

                final boolean success;
                synchronized (mInstallLock) {
                    success = getPackageSizeInfoLI(packageName, stats);
                }
        PackageStats stats = new PackageStats(packageName);

        /*
         * Queue up an async operation since the package measurement may take a
         * little while.
         */
        Message msg = mHandler.obtainMessage(INIT_COPY);
                msg.obj = new MeasureParams(stats, success, observer);
        msg.obj = new MeasureParams(stats, observer);
        mHandler.sendMessage(msg);
            } //end run
        });
    }

    private boolean getPackageSizeInfoLI(String packageName, PackageStats pStats) {