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

Commit 7105dd8b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Shame developers that are calling hidden APIs."

parents e6b44f27 6f4b2a30
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -2139,11 +2139,12 @@ public class ApplicationPackageManager extends PackageManager {
    @Override
    public void getPackageSizeInfoAsUser(String packageName, int userHandle,
            IPackageStatsObserver observer) {
        final String msg = "Shame on you for calling the hidden API "
                + "getPackageSizeInfoAsUser(). Shame!";
        if (mContext.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.O) {
            throw new UnsupportedOperationException(
                    "Shame on you for calling a hidden API. Shame!");
            throw new UnsupportedOperationException(msg);
        } else if (observer != null) {
            Log.d(TAG, "Shame on you for calling a hidden API. Shame!");
            Log.d(TAG, msg);
            try {
                observer.onGetStatsCompleted(null, false);
            } catch (RemoteException ignored) {
+11 −2
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import android.content.res.XmlResourceParser;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
@@ -58,6 +59,8 @@ import android.util.Log;

import com.android.internal.util.ArrayUtils;

import dalvik.system.VMRuntime;

import java.io.File;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -4252,9 +4255,15 @@ public abstract class PackageManager {
    @Deprecated
    public List<ResolveInfo> queryBroadcastReceivers(Intent intent,
            @ResolveInfoFlags int flags, @UserIdInt int userId) {
        Log.w(TAG, "STAHP USING HIDDEN APIS KTHX");
        final String msg = "Shame on you for calling the hidden API "
                + "queryBroadcastReceivers(). Shame!";
        if (VMRuntime.getRuntime().getTargetSdkVersion() >= Build.VERSION_CODES.O) {
            throw new UnsupportedOperationException(msg);
        } else {
            Log.d(TAG, msg);
            return queryBroadcastReceiversAsUser(intent, flags, userId);
        }
    }

    /**
     * Determine the best service to handle for a given Intent.
+1 −1
Original line number Diff line number Diff line
@@ -18646,7 +18646,7 @@ public class PackageManagerService extends IPackageManager.Stub {
    public void getPackageSizeInfo(final String packageName, int userHandle,
            final IPackageStatsObserver observer) {
        throw new UnsupportedOperationException(
                "Shame on you for calling a hidden API. Shame!");
                "Shame on you for calling the hidden API getPackageSizeInfo(). Shame!");
    }
    private boolean getPackageSizeInfoLI(String packageName, int userId, PackageStats stats) {