diff options
Diffstat (limited to 'core/java/android/app/UiAutomation.java')
-rw-r--r-- | core/java/android/app/UiAutomation.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/core/java/android/app/UiAutomation.java b/core/java/android/app/UiAutomation.java index a8494fb..efed2e0 100644 --- a/core/java/android/app/UiAutomation.java +++ b/core/java/android/app/UiAutomation.java @@ -30,6 +30,7 @@ import android.os.Looper; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.SystemClock; +import android.os.UserHandle; import android.util.Log; import android.view.Display; import android.view.InputEvent; @@ -846,6 +847,62 @@ public final class UiAutomation { } /** + * Grants a runtime permission to a package for a user. + * @param packageName The package to which to grant. + * @param permission The permission to grant. + * @return Whether granting succeeded. + * + * @hide + */ + public boolean grantRuntimePermission(String packageName, String permission, + UserHandle userHandle) { + synchronized (mLock) { + throwIfNotConnectedLocked(); + } + try { + if (DEBUG) { + Log.i(LOG_TAG, "Granting runtime permission"); + } + // Calling out without a lock held. + mUiAutomationConnection.grantRuntimePermission(packageName, + permission, userHandle.getIdentifier()); + // TODO: The package manager API should return boolean. + return true; + } catch (RemoteException re) { + Log.e(LOG_TAG, "Error granting runtime permission", re); + } + return false; + } + + /** + * Revokes a runtime permission from a package for a user. + * @param packageName The package from which to revoke. + * @param permission The permission to revoke. + * @return Whether revoking succeeded. + * + * @hide + */ + public boolean revokeRuntimePermission(String packageName, String permission, + UserHandle userHandle) { + synchronized (mLock) { + throwIfNotConnectedLocked(); + } + try { + if (DEBUG) { + Log.i(LOG_TAG, "Revoking runtime permission"); + } + // Calling out without a lock held. + mUiAutomationConnection.revokeRuntimePermission(packageName, + permission, userHandle.getIdentifier()); + // TODO: The package manager API should return boolean. + return true; + } catch (RemoteException re) { + Log.e(LOG_TAG, "Error revoking runtime permission", re); + } + return false; + } + + /** * Executes a shell command. This method returs a file descriptor that points * to the standard output stream. The command execution is similar to running * "adb shell <command>" from a host connected to the device. |