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

Commit 5470bc18 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Revert some new APIs for restrictions provider

Simplify back to being a broadcast receiver and add an extra to
indicate that a new request is desired vs. returning a pending
response from before.

Change-Id: Iafd16ed98293a2cc09006d2cce097fc3d590bbe2
parent a4ab7808
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -118,9 +118,7 @@ LOCAL_SRC_FILES += \
	core/java/android/content/IIntentReceiver.aidl \
	core/java/android/content/IIntentSender.aidl \
	core/java/android/content/IOnPrimaryClipChangedListener.aidl \
        core/java/android/content/IPermissionResponseCallback.aidl \
	core/java/android/content/IRestrictionsManager.aidl \
        core/java/android/content/IRestrictionsProvider.aidl \
	core/java/android/content/ISyncAdapter.aidl \
	core/java/android/content/ISyncContext.aidl \
	core/java/android/content/ISyncServiceAdapter.aidl \
+10 −15
Original line number Diff line number Diff line
@@ -6571,11 +6571,10 @@ package android.bluetooth.le {
package android.content {
  public abstract class AbstractRestrictionsProvider extends android.app.Service {
  public abstract class AbstractRestrictionsProvider extends android.content.BroadcastReceiver {
    ctor public AbstractRestrictionsProvider();
    method public abstract android.os.Bundle getPermissionResponse(java.lang.String, java.lang.String);
    method public final android.os.IBinder onBind(android.content.Intent);
    method public abstract void requestPermission(java.lang.String, java.lang.String, android.os.Bundle);
    method public void onReceive(android.content.Context, android.content.Intent);
    method public abstract void requestPermission(android.content.Context, java.lang.String, java.lang.String, android.os.Bundle);
  }
  public abstract class AbstractThreadedSyncAdapter {
@@ -7957,24 +7956,25 @@ package android.content {
  public class RestrictionsManager {
    method public android.os.Bundle getApplicationRestrictions();
    method public java.util.List<android.content.RestrictionEntry> getManifestRestrictions(java.lang.String);
    method public void getPermissionResponse(java.lang.String, android.content.RestrictionsManager.PermissionResponseCallback);
    method public boolean hasRestrictionsProvider();
    method public void notifyPermissionResponse(java.lang.String, android.os.Bundle);
    method public void requestPermission(java.lang.String, android.os.Bundle);
    field public static final java.lang.String ACTION_PERMISSION_RESPONSE_RECEIVED = "android.intent.action.PERMISSION_RESPONSE_RECEIVED";
    field public static final java.lang.String EXTRA_PACKAGE_NAME = "package_name";
    field public static final java.lang.String EXTRA_RESPONSE_BUNDLE = "response";
    field public static final java.lang.String ACTION_REQUEST_PERMISSION = "android.content.action.REQUEST_PERMISSION";
    field public static final java.lang.String EXTRA_PACKAGE_NAME = "android.content.extra.PACKAGE_NAME";
    field public static final java.lang.String EXTRA_REQUEST_BUNDLE = "android.content.extra.REQUEST_BUNDLE";
    field public static final java.lang.String EXTRA_REQUEST_TYPE = "android.content.extra.REQUEST_TYPE";
    field public static final java.lang.String EXTRA_RESPONSE_BUNDLE = "android.content.extra.RESPONSE_BUNDLE";
    field public static final java.lang.String REQUEST_KEY_APPROVE_LABEL = "android.request.approve_label";
    field public static final java.lang.String REQUEST_KEY_DATA = "android.request.data";
    field public static final java.lang.String REQUEST_KEY_DENY_LABEL = "android.request.deny_label";
    field public static final java.lang.String REQUEST_KEY_DEVICE_NAME = "android.request.device";
    field public static final java.lang.String REQUEST_KEY_ICON = "android.request.icon";
    field public static final java.lang.String REQUEST_KEY_ID = "android.request.id";
    field public static final java.lang.String REQUEST_KEY_MESSAGE = "android.request.mesg";
    field public static final java.lang.String REQUEST_KEY_REQUESTOR_NAME = "android.request.requestor";
    field public static final java.lang.String REQUEST_KEY_NEW_REQUEST = "android.request.new_request";
    field public static final java.lang.String REQUEST_KEY_TITLE = "android.request.title";
    field public static final java.lang.String REQUEST_TYPE_APPROVAL = "android.request.type.approval";
    field public static final java.lang.String REQUEST_TYPE_LOCAL_APPROVAL = "android.request.type.local_approval";
    field public static final java.lang.String REQUEST_TYPE_QUESTION = "android.request.type.question";
    field public static final java.lang.String RESPONSE_KEY_ERROR_CODE = "android.response.errorcode";
    field public static final java.lang.String RESPONSE_KEY_ERROR_MESSAGE = "android.response.errormsg";
    field public static final java.lang.String RESPONSE_KEY_RESPONSE_TIMESTAMP = "android.response.timestamp";
@@ -7989,11 +7989,6 @@ package android.content {
    field public static final int RESULT_UNKNOWN_REQUEST = 4; // 0x4
  }
  public static abstract class RestrictionsManager.PermissionResponseCallback {
    ctor public RestrictionsManager.PermissionResponseCallback();
    method public abstract void onResponse(android.os.Bundle);
  }
  public class SearchRecentSuggestionsProvider extends android.content.ContentProvider {
    ctor public SearchRecentSuggestionsProvider();
    method public int delete(android.net.Uri, java.lang.String, java.lang.String[]);
+29 −42
Original line number Diff line number Diff line
@@ -16,78 +16,65 @@

package android.content;

import android.app.Service;
import android.app.admin.DevicePolicyManager;
import android.os.Bundle;
import android.os.IBinder;

/**
 * Abstract implementation of a Restrictions Provider Service. To implement a Restrictions Provider,
 * extend from this class and implement the abstract methods. Export this service in the
 * manifest. A profile owner device admin can then register this component as a Restrictions
 * Provider using {@link DevicePolicyManager#setRestrictionsProvider(ComponentName, ComponentName)}.
 * Abstract implementation of a Restrictions Provider BroadcastReceiver. To implement a
 * Restrictions Provider, extend from this class and implement the abstract methods.
 * Export this receiver in the manifest. A profile owner device admin can then register this
 * component as a Restrictions Provider using
 * {@link DevicePolicyManager#setRestrictionsProvider(ComponentName, ComponentName)}.
 * <p>
 * The function of a Restrictions Provider is to transport permission requests from apps on this
 * device to an administrator (most likely on a remote device or computer) and deliver back
 * responses. The response should be sent back to the app via
 * {@link RestrictionsManager#notifyPermissionResponse(String, Bundle)}.
 * <p>
 * Apps can also query previously received responses using
 * {@link #getPermissionResponse(String, String)}. The period for which previously received
 * responses are available is left to the implementation of the Restrictions Provider.
 *
 * @see RestrictionsManager
 */
public abstract class AbstractRestrictionsProvider extends Service {
public abstract class AbstractRestrictionsProvider extends BroadcastReceiver {

    private static final String TAG = "AbstractRestrictionsProvider";

    @Override
    public final IBinder onBind(Intent intent) {
        return new RestrictionsProviderWrapper().asBinder();
    }

    /**
     * Checks to see if there is a response for a prior request and returns the response bundle if
     * it exists. If there is no response yet or if the request is not known, the returned bundle
     * should contain the response code in {@link RestrictionsManager#RESPONSE_KEY_RESULT}.
     *
     * @param packageName the application that is requesting a permission response.
     * @param requestId the id of the request for which the response is needed.
     * @return a bundle containing at a minimum the result of the request. It could contain other
     * optional information such as error codes and cookies.
     *
     * @see RestrictionsManager#RESPONSE_KEY_RESULT
     */
    public abstract Bundle getPermissionResponse(String packageName, String requestId);

    /**
     * An asynchronous permission request made by an application for an operation that requires
     * authorization by a local or remote administrator other than the user. The Restrictions
     * Provider must transfer the request to the administrator and deliver back a response, when
     * Provider should transfer the request to the administrator and deliver back a response, when
     * available. The calling application is aware that the response could take an indefinite
     * amount of time.
     * <p>
     * If the request bundle contains the key {@link RestrictionsManager#REQUEST_KEY_NEW_REQUEST},
     * then a new request must be sent. Otherwise the provider can look up any previous response
     * to the same requestId and return the cached response.
     *
     * @param packageName the application requesting permission.
     * @param requestType the type of request, which determines the content and presentation of
     * the request data.
     * @param request the request data bundle containing at a minimum a request id.
     *
     * @see RestrictionsManager#REQUEST_TYPE_QUESTION
     * @see RestrictionsManager#REQUEST_TYPE_APPROVAL
     * @see RestrictionsManager#REQUEST_TYPE_LOCAL_APPROVAL
     * @see RestrictionsManager#REQUEST_KEY_ID
     */
    public abstract void requestPermission(String packageName, String requestType, Bundle request);

    private class RestrictionsProviderWrapper extends IRestrictionsProvider.Stub {
    public abstract void requestPermission(Context context,
            String packageName, String requestType, Bundle request);

    /**
     * Intercept standard Restrictions Provider broadcasts.  Implementations
     * should not override this method; it is better to implement the
     * convenience callbacks for each action.
     */
    @Override
        public Bundle getPermissionResponse(String packageName, String requestId) {
            return AbstractRestrictionsProvider.this
                    .getPermissionResponse(packageName, requestId);
        }
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();

        @Override
        public void requestPermission(String packageName, String templateId, Bundle request) {
            AbstractRestrictionsProvider.this.requestPermission(packageName, templateId, request);
        if (RestrictionsManager.ACTION_REQUEST_PERMISSION.equals(action)) {
            String packageName = intent.getStringExtra(RestrictionsManager.EXTRA_PACKAGE_NAME);
            String requestType = intent.getStringExtra(RestrictionsManager.EXTRA_REQUEST_TYPE);
            Bundle request = intent.getBundleExtra(RestrictionsManager.EXTRA_REQUEST_BUNDLE);
            requestPermission(context, packageName, requestType, request);
        }
    }
}
+0 −30
Original line number Diff line number Diff line
/*
** Copyright 2014, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

package android.content;

import android.os.Bundle;

/**
 * Callback for permission response queries.
 *
 * @hide
 */
 interface IPermissionResponseCallback {

    void onResponse(in Bundle response);

}
+0 −3
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.content;

import android.os.Bundle;
import android.content.IPermissionResponseCallback;

/**
 * Interface used by the RestrictionsManager
@@ -28,6 +27,4 @@ interface IRestrictionsManager {
    boolean hasRestrictionsProvider();
    void requestPermission(in String packageName, in String requestTemplate, in Bundle requestData);
    void notifyPermissionResponse(in String packageName, in Bundle response);
    void getPermissionResponse(in String packageName, in String requestId,
            in IPermissionResponseCallback callback);
}
Loading