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

Commit d3c1ddb8 authored by Svet Ganov's avatar Svet Ganov Committed by Android (Google) Code Review
Browse files

Merge "Add OP_READ_PHONE_STATE app op - framework"

parents f2004061 16a16899
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -93,15 +93,20 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
    }
    static boolean sSystemReady = false;

    static public void broadcastStickyIntent(Intent intent, String permission, int userId) {
        broadcastStickyIntent(intent, permission, AppOpsManager.OP_NONE, userId);
    }

    /**
     * Convenience for sending a sticky broadcast.  For internal use only.
     * If you don't care about permission, use null.
     */
    static public void broadcastStickyIntent(Intent intent, String permission, int userId) {
    static public void broadcastStickyIntent(Intent intent, String permission, int appOp,
            int userId) {
        try {
            getDefault().broadcastIntent(
                null, intent, null, null, Activity.RESULT_OK, null, null,
                null /*permission*/, AppOpsManager.OP_NONE, false, true, userId);
                null /*permission*/, appOp, false, true, userId);
        } catch (RemoteException ex) {
        }
    }
+13 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.app;

import android.Manifest;
import android.annotation.SystemApi;
import android.app.usage.UsageStatsManager;
import android.content.Context;
@@ -212,8 +213,10 @@ public class AppOpsManager {
    public static final int OP_ASSIST_STRUCTURE = 49;
    /** @hide Received a screenshot from assist. */
    public static final int OP_ASSIST_SCREENSHOT = 50;
    /** @hide Read the phone state. */
    public static final int OP_READ_PHONE_STATE = 51;
    /** @hide */
    public static final int _NUM_OP = 51;
    public static final int _NUM_OP = 52;

    /** Access to coarse location information. */
    public static final String OPSTR_COARSE_LOCATION =
@@ -294,6 +297,7 @@ public class AppOpsManager {
            OP_WRITE_WALLPAPER,
            OP_ASSIST_STRUCTURE,
            OP_ASSIST_SCREENSHOT,
            OP_READ_PHONE_STATE
    };

    /**
@@ -352,6 +356,7 @@ public class AppOpsManager {
            null,
            null,
            null,
            null
    };

    /**
@@ -409,7 +414,8 @@ public class AppOpsManager {
            "ACTIVATE_VPN",
            "WRITE_WALLPAPER",
            "ASSIST_STRUCTURE",
            "ASSIST_SCREENSHOT"
            "ASSIST_SCREENSHOT",
            "OP_READ_PHONE_STATE"
    };

    /**
@@ -468,6 +474,7 @@ public class AppOpsManager {
            null, // no permission for supporting wallpaper
            null, // no permission for receiving assist structure
            null, // no permission for receiving assist screenshot
            Manifest.permission.READ_PHONE_STATE
    };

    /**
@@ -527,6 +534,7 @@ public class AppOpsManager {
            UserManager.DISALLOW_WALLPAPER, // WRITE_WALLPAPER
            null, // ASSIST_STRUCTURE
            null, // ASSIST_SCREENSHOT
            null  // READ_PHONE_STATE
    };

    /**
@@ -585,6 +593,7 @@ public class AppOpsManager {
            false, //WALLPAPER
            false, //ASSIST_STRUCTURE
            false, //ASSIST_SCREENSHOT
            false, //READ_PHONE_STATE
    };

    /**
@@ -642,6 +651,7 @@ public class AppOpsManager {
            AppOpsManager.MODE_ALLOWED,
            AppOpsManager.MODE_ALLOWED,
            AppOpsManager.MODE_ALLOWED,
            AppOpsManager.MODE_ALLOWED
    };

    /**
@@ -703,6 +713,7 @@ public class AppOpsManager {
            false,
            false,
            false,
            false
    };

    private static HashMap<String, Integer> sOpStrToOp = new HashMap<String, Integer>();
+9 −3
Original line number Diff line number Diff line
@@ -860,12 +860,18 @@ class ContextImpl extends Context {
    @Override
    public void sendBroadcastAsUser(Intent intent, UserHandle user,
            String receiverPermission) {
        sendBroadcastAsUser(intent, user, receiverPermission, AppOpsManager.OP_NONE);
    }

    @Override
    public void sendBroadcastAsUser(Intent intent, UserHandle user,
            String receiverPermission, int appOp) {
        String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
        try {
            intent.prepareToLeaveProcess();
            ActivityManagerNative.getDefault().broadcastIntent(
                    mMainThread.getApplicationThread(), intent, resolvedType, null,
                Activity.RESULT_OK, null, null, receiverPermission, AppOpsManager.OP_NONE, false, false,
                    Activity.RESULT_OK, null, null, receiverPermission, appOp, false, false,
                    user.getIdentifier());
        } catch (RemoteException e) {
        }
+3 −3
Original line number Diff line number Diff line
@@ -332,10 +332,10 @@ final class SystemServiceRegistry {
            }});

        registerService(Context.NETWORK_POLICY_SERVICE, NetworkPolicyManager.class,
                new StaticServiceFetcher<NetworkPolicyManager>() {
                new CachedServiceFetcher<NetworkPolicyManager>() {
            @Override
            public NetworkPolicyManager createService() {
                return new NetworkPolicyManager(INetworkPolicyManager.Stub.asInterface(
            public NetworkPolicyManager createService(ContextImpl ctx) {
                return new NetworkPolicyManager(ctx, INetworkPolicyManager.Stub.asInterface(
                        ServiceManager.getService(Context.NETWORK_POLICY_SERVICE)));
            }});

+22 −0
Original line number Diff line number Diff line
@@ -1608,6 +1608,28 @@ public abstract class Context {
    public abstract void sendBroadcastAsUser(Intent intent, UserHandle user,
            @Nullable String receiverPermission);


    /**
     * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the
     * user the broadcast will be sent to.  This is not available to applications
     * that are not pre-installed on the system image.  Using it requires holding
     * the INTERACT_ACROSS_USERS permission.
     *
     * @param intent The Intent to broadcast; all receivers matching this
     *               Intent will receive the broadcast.
     * @param user UserHandle to send the intent to.
     * @param receiverPermission (optional) String naming a permission that
     *               a receiver must hold in order to receive your broadcast.
     *               If null, no permission is required.
     * @param appOp The app op associated with the broadcast.
     *
     * @see #sendBroadcast(Intent, String)
     *
     * @hide
     */
    public abstract void sendBroadcastAsUser(Intent intent, UserHandle user,
            @Nullable String receiverPermission, int appOp);

    /**
     * Version of
     * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)}
Loading