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

Commit e6306c48 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Throw at getPackageSizeInfoAsUser() callers.

But only when targeting O; if they're old apps then log and pass
a soft failure message to their callback.

Test: builds, boots
Bug: 35749102
Change-Id: I6c6b5a37c23669e7b1ed3c30207bca610821eb1f
parent 4f459b85
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -2129,10 +2130,15 @@ public class ApplicationPackageManager extends PackageManager {
    @Override
    public void getPackageSizeInfoAsUser(String packageName, int userHandle,
            IPackageStatsObserver observer) {
        if (mContext.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.O) {
            throw new UnsupportedOperationException(
                    "Shame on you for calling a hidden API. Shame!");
        } else if (observer != null) {
            Log.d(TAG, "Shame on you for calling a hidden API. Shame!");
            try {
            mPM.getPackageSizeInfo(packageName, userHandle, observer);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
                observer.onGetStatsCompleted(null, false);
            } catch (RemoteException ignored) {
            }
        }
    }

+2 −5
Original line number Diff line number Diff line
@@ -18625,11 +18625,8 @@ public class PackageManagerService extends IPackageManager.Stub {
    @Override
    public void getPackageSizeInfo(final String packageName, int userHandle,
            final IPackageStatsObserver observer) {
        Slog.w(TAG, "Shame on you for calling a hidden API. Shame!");
        try {
            observer.onGetStatsCompleted(null, false);
        } catch (Throwable ignored) {
        }
        throw new UnsupportedOperationException(
                "Shame on you for calling a hidden API. Shame!");
    }
    private boolean getPackageSizeInfoLI(String packageName, int userId, PackageStats stats) {