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

Commit 7e99bc02 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Modify restrictions bundle per api council recommendations

Use a Bundle for persisting and passing to the application, but use a
list to return data back from an application that's exposing restrictions.

Changed the xml reading/writing code to store the value type in the Bundle
so that it can be reproduced when reading. Earlier we were assuming only
String and String[].

Bug: 8633967

Change-Id: I523d5553728edcf28a1e9d432f490b4956f34215
parent 95a869f9
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -5618,7 +5618,6 @@ package android.content {
    method public abstract java.lang.String[] fileList();
    method public abstract java.lang.String[] fileList();
    method public abstract android.content.Context getApplicationContext();
    method public abstract android.content.Context getApplicationContext();
    method public abstract android.content.pm.ApplicationInfo getApplicationInfo();
    method public abstract android.content.pm.ApplicationInfo getApplicationInfo();
    method public java.util.List<android.content.RestrictionEntry> getApplicationRestrictions();
    method public abstract android.content.res.AssetManager getAssets();
    method public abstract android.content.res.AssetManager getAssets();
    method public abstract java.io.File getCacheDir();
    method public abstract java.io.File getCacheDir();
    method public abstract java.lang.ClassLoader getClassLoader();
    method public abstract java.lang.ClassLoader getClassLoader();
@@ -6205,8 +6204,9 @@ package android.content {
    field public static final java.lang.String EXTRA_REFERRER = "android.intent.extra.REFERRER";
    field public static final java.lang.String EXTRA_REFERRER = "android.intent.extra.REFERRER";
    field public static final java.lang.String EXTRA_REMOTE_INTENT_TOKEN = "android.intent.extra.remote_intent_token";
    field public static final java.lang.String EXTRA_REMOTE_INTENT_TOKEN = "android.intent.extra.remote_intent_token";
    field public static final java.lang.String EXTRA_REPLACING = "android.intent.extra.REPLACING";
    field public static final java.lang.String EXTRA_REPLACING = "android.intent.extra.REPLACING";
    field public static final java.lang.String EXTRA_RESTRICTIONS = "android.intent.extra.restrictions";
    field public static final java.lang.String EXTRA_RESTRICTIONS_BUNDLE = "android.intent.extra.restrictions_bundle";
    field public static final java.lang.String EXTRA_RESTRICTIONS_INTENT = "android.intent.extra.restrictions_intent";
    field public static final java.lang.String EXTRA_RESTRICTIONS_INTENT = "android.intent.extra.restrictions_intent";
    field public static final java.lang.String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
    field public static final java.lang.String EXTRA_RETURN_RESULT = "android.intent.extra.RETURN_RESULT";
    field public static final java.lang.String EXTRA_RETURN_RESULT = "android.intent.extra.RETURN_RESULT";
    field public static final java.lang.String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
    field public static final java.lang.String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
    field public static final java.lang.String EXTRA_SHORTCUT_ICON_RESOURCE = "android.intent.extra.shortcut.ICON_RESOURCE";
    field public static final java.lang.String EXTRA_SHORTCUT_ICON_RESOURCE = "android.intent.extra.shortcut.ICON_RESOURCE";
@@ -17556,7 +17556,7 @@ package android.os {
  }
  }
  public class UserManager {
  public class UserManager {
    method public static synchronized android.os.UserManager get(android.content.Context);
    method public android.os.Bundle getApplicationRestrictions(java.lang.String);
    method public long getSerialNumberForUser(android.os.UserHandle);
    method public long getSerialNumberForUser(android.os.UserHandle);
    method public int getUserCount();
    method public int getUserCount();
    method public android.os.UserHandle getUserForSerialNumber(long);
    method public android.os.UserHandle getUserForSerialNumber(long);
+0 −5
Original line number Original line Diff line number Diff line
@@ -134,11 +134,6 @@ public class Application extends ContextWrapper implements ComponentCallbacks2 {
        }
        }
    }
    }


    public List<RestrictionEntry> getApplicationRestrictions() {
        return ((UserManager) getSystemService(USER_SERVICE))
                .getApplicationRestrictions(getPackageName(), android.os.Process.myUserHandle());
    }

    public void registerComponentCallbacks(ComponentCallbacks callback) {
    public void registerComponentCallbacks(ComponentCallbacks callback) {
        synchronized (mComponentCallbacks) {
        synchronized (mComponentCallbacks) {
            mComponentCallbacks.add(callback);
            mComponentCallbacks.add(callback);
+0 −9
Original line number Original line Diff line number Diff line
@@ -292,15 +292,6 @@ public abstract class Context {
     */
     */
    public abstract Context getApplicationContext();
    public abstract Context getApplicationContext();


    /**
     * Returns the list of restrictions for the application, or null if there are no
     * restrictions.
     * @return
     */
    public List<RestrictionEntry> getApplicationRestrictions() {
        return getApplicationContext().getApplicationRestrictions();
    }

    /**
    /**
     * Add a new {@link ComponentCallbacks} to the base application of the
     * Add a new {@link ComponentCallbacks} to the base application of the
     * Context, which will be called at the same times as the ComponentCallbacks
     * Context, which will be called at the same times as the ComponentCallbacks
+20 −5
Original line number Original line Diff line number Diff line
@@ -2417,11 +2417,16 @@ public class Intent implements Parcelable, Cloneable {


    /**
    /**
     * Broadcast to a specific application to query any supported restrictions to impose
     * Broadcast to a specific application to query any supported restrictions to impose
     * on restricted users. The response should contain an extra {@link #EXTRA_RESTRICTIONS},
     * on restricted users. The broadcast intent contains an extra
     * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
     * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
     * String[] depending on the restriction type.<p/>
     * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
     * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
     * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
     * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
     * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
     * The activity specified by that intent will be launched for a result which must contain
     * The activity specified by that intent will be launched for a result which must contain
     * the extra {@link #EXTRA_RESTRICTIONS}. The returned restrictions will be persisted.
     * the extra {@link #EXTRA_RESTRICTIONS_LIST}. The keys and values of the returned restrictions
     * will be persisted.
     * @see RestrictionEntry
     * @see RestrictionEntry
     */
     */
    public static final String ACTION_GET_RESTRICTION_ENTRIES =
    public static final String ACTION_GET_RESTRICTION_ENTRIES =
@@ -3160,7 +3165,8 @@ public class Intent implements Parcelable, Cloneable {
        "android.intent.extra.ALLOW_MULTIPLE";
        "android.intent.extra.ALLOW_MULTIPLE";


    /**
    /**
     * The userHandle carried with broadcast intents related to addition, removal and switching of users
     * The userHandle carried with broadcast intents related to addition, removal and switching of
     * users
     * - {@link #ACTION_USER_ADDED}, {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
     * - {@link #ACTION_USER_ADDED}, {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
     * @hide
     * @hide
     */
     */
@@ -3169,9 +3175,18 @@ public class Intent implements Parcelable, Cloneable {


    /**
    /**
     * Extra used in the response from a BroadcastReceiver that handles
     * Extra used in the response from a BroadcastReceiver that handles
     * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
     * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
     * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
     */
    public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";

    /**
     * Extra sent in the intent to the BroadcastReceiver that handles
     * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
     * the restrictions as key/value pairs.
     */
     */
    public static final String EXTRA_RESTRICTIONS = "android.intent.extra.restrictions";
    public static final String EXTRA_RESTRICTIONS_BUNDLE =
            "android.intent.extra.restrictions_bundle";


    /**
    /**
     * Extra used in the response from a BroadcastReceiver that handles
     * Extra used in the response from a BroadcastReceiver that handles
+3 −2
Original line number Original line Diff line number Diff line
@@ -42,7 +42,8 @@ interface IUserManager {
    int getUserHandle(int userSerialNumber);
    int getUserHandle(int userSerialNumber);
    Bundle getUserRestrictions(int userHandle);
    Bundle getUserRestrictions(int userHandle);
    void setUserRestrictions(in Bundle restrictions, int userHandle);
    void setUserRestrictions(in Bundle restrictions, int userHandle);
    void setApplicationRestrictions(in String packageName, in List<RestrictionEntry> entries,
    void setApplicationRestrictions(in String packageName, in Bundle restrictions,
            int userHandle);
            int userHandle);
    List<RestrictionEntry> getApplicationRestrictions(in String packageName, int userHandle);
    Bundle getApplicationRestrictions(in String packageName);
    Bundle getApplicationRestrictionsForUser(in String packageName, int userHandle);
}
}
Loading