Loading core/api/test-current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -355,11 +355,13 @@ package android.app { public final class UiAutomation { method public void destroy(); method @NonNull public android.os.ParcelFileDescriptor[] executeShellCommandRwe(@NonNull String); method @NonNull public java.util.Set<java.lang.String> getAdoptedShellPermissions(); method @Deprecated public boolean grantRuntimePermission(String, String, android.os.UserHandle); method public boolean injectInputEvent(@NonNull android.view.InputEvent, boolean, boolean); method @Deprecated public boolean revokeRuntimePermission(String, String, android.os.UserHandle); method public void syncInputTransactions(); method public void syncInputTransactions(boolean); field @NonNull public static final java.util.Set<java.lang.String> ALL_PERMISSIONS; } public class UiModeManager { Loading core/java/android/app/IActivityManager.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -571,6 +571,12 @@ interface IActivityManager { */ void stopDelegateShellPermissionIdentity(); /** * Method for the shell UID to get currently adopted permissions for an active instrumentation. * An active instrumentation is one running and started from the shell. */ List<String> getDelegatedShellPermissions(); /** Returns a file descriptor that'll be closed when the system server process dies. */ ParcelFileDescriptor getLifeMonitor(); Loading core/java/android/app/IUiAutomationConnection.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.view.WindowContentFrameStats; import android.view.WindowAnimationFrameStats; import android.os.ParcelFileDescriptor; import java.util.List; /** * This interface contains privileged operations a shell program can perform * on behalf of an instrumentation that it runs. These operations require Loading Loading @@ -54,4 +56,5 @@ interface IUiAutomationConnection { oneway void shutdown(); void executeShellCommandWithStderr(String command, in ParcelFileDescriptor sink, in ParcelFileDescriptor source, in ParcelFileDescriptor stderrSink); List<String> getAdoptedShellPermissions(); } core/java/android/app/UiAutomation.java +32 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import android.os.Process; import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; import android.util.ArraySet; import android.util.Log; import android.util.SparseArray; import android.view.Display; Loading @@ -66,7 +67,9 @@ import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; import java.util.concurrent.TimeoutException; /** Loading Loading @@ -160,6 +163,16 @@ public final class UiAutomation { */ public static final int FLAG_DONT_USE_ACCESSIBILITY = 0x00000002; /** * Returned by {@link #getAdoptedShellPermissions} to indicate that all permissions have been * adopted using {@link #adoptShellPermissionIdentity}. * * @hide */ @TestApi @NonNull public static final Set<String> ALL_PERMISSIONS = Set.of("_ALL_PERMISSIONS_"); private final Object mLock = new Object(); private final ArrayList<AccessibilityEvent> mEventQueue = new ArrayList<AccessibilityEvent>(); Loading Loading @@ -498,6 +511,25 @@ public final class UiAutomation { } } /** * Returns a list of adopted shell permissions using {@link #adoptShellPermissionIdentity}, * returns and empty set if no permissions are adopted and {@link #ALL_PERMISSIONS} if all * permissions are adopted. * * @hide */ @TestApi @NonNull public Set<String> getAdoptedShellPermissions() { try { final List<String> permissions = mUiAutomationConnection.getAdoptedShellPermissions(); return permissions == null ? ALL_PERMISSIONS : new ArraySet<>(permissions); } catch (RemoteException re) { Log.e(LOG_TAG, "Error getting adopted shell permissions", re); return Collections.emptySet(); } } /** * Performs a global action. Such an action can be performed at any moment * regardless of the current application or user location in that application. Loading core/java/android/app/UiAutomationConnection.java +17 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.List; /** * This is a remote object that is passed from the shell to an instrumentation Loading Loading @@ -340,6 +341,22 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub { } } @Override @Nullable public List<String> getAdoptedShellPermissions() throws RemoteException { synchronized (mLock) { throwIfCalledByNotTrustedUidLocked(); throwIfShutdownLocked(); throwIfNotConnectedLocked(); } final long identity = Binder.clearCallingIdentity(); try { return mActivityManager.getDelegatedShellPermissions(); } finally { Binder.restoreCallingIdentity(identity); } } public class Repeater implements Runnable { // Continuously read readFrom and write back to writeTo until EOF is encountered private final InputStream readFrom; Loading Loading
core/api/test-current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -355,11 +355,13 @@ package android.app { public final class UiAutomation { method public void destroy(); method @NonNull public android.os.ParcelFileDescriptor[] executeShellCommandRwe(@NonNull String); method @NonNull public java.util.Set<java.lang.String> getAdoptedShellPermissions(); method @Deprecated public boolean grantRuntimePermission(String, String, android.os.UserHandle); method public boolean injectInputEvent(@NonNull android.view.InputEvent, boolean, boolean); method @Deprecated public boolean revokeRuntimePermission(String, String, android.os.UserHandle); method public void syncInputTransactions(); method public void syncInputTransactions(boolean); field @NonNull public static final java.util.Set<java.lang.String> ALL_PERMISSIONS; } public class UiModeManager { Loading
core/java/android/app/IActivityManager.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -571,6 +571,12 @@ interface IActivityManager { */ void stopDelegateShellPermissionIdentity(); /** * Method for the shell UID to get currently adopted permissions for an active instrumentation. * An active instrumentation is one running and started from the shell. */ List<String> getDelegatedShellPermissions(); /** Returns a file descriptor that'll be closed when the system server process dies. */ ParcelFileDescriptor getLifeMonitor(); Loading
core/java/android/app/IUiAutomationConnection.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.view.WindowContentFrameStats; import android.view.WindowAnimationFrameStats; import android.os.ParcelFileDescriptor; import java.util.List; /** * This interface contains privileged operations a shell program can perform * on behalf of an instrumentation that it runs. These operations require Loading Loading @@ -54,4 +56,5 @@ interface IUiAutomationConnection { oneway void shutdown(); void executeShellCommandWithStderr(String command, in ParcelFileDescriptor sink, in ParcelFileDescriptor source, in ParcelFileDescriptor stderrSink); List<String> getAdoptedShellPermissions(); }
core/java/android/app/UiAutomation.java +32 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import android.os.Process; import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; import android.util.ArraySet; import android.util.Log; import android.util.SparseArray; import android.view.Display; Loading @@ -66,7 +67,9 @@ import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; import java.util.concurrent.TimeoutException; /** Loading Loading @@ -160,6 +163,16 @@ public final class UiAutomation { */ public static final int FLAG_DONT_USE_ACCESSIBILITY = 0x00000002; /** * Returned by {@link #getAdoptedShellPermissions} to indicate that all permissions have been * adopted using {@link #adoptShellPermissionIdentity}. * * @hide */ @TestApi @NonNull public static final Set<String> ALL_PERMISSIONS = Set.of("_ALL_PERMISSIONS_"); private final Object mLock = new Object(); private final ArrayList<AccessibilityEvent> mEventQueue = new ArrayList<AccessibilityEvent>(); Loading Loading @@ -498,6 +511,25 @@ public final class UiAutomation { } } /** * Returns a list of adopted shell permissions using {@link #adoptShellPermissionIdentity}, * returns and empty set if no permissions are adopted and {@link #ALL_PERMISSIONS} if all * permissions are adopted. * * @hide */ @TestApi @NonNull public Set<String> getAdoptedShellPermissions() { try { final List<String> permissions = mUiAutomationConnection.getAdoptedShellPermissions(); return permissions == null ? ALL_PERMISSIONS : new ArraySet<>(permissions); } catch (RemoteException re) { Log.e(LOG_TAG, "Error getting adopted shell permissions", re); return Collections.emptySet(); } } /** * Performs a global action. Such an action can be performed at any moment * regardless of the current application or user location in that application. Loading
core/java/android/app/UiAutomationConnection.java +17 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.List; /** * This is a remote object that is passed from the shell to an instrumentation Loading Loading @@ -340,6 +341,22 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub { } } @Override @Nullable public List<String> getAdoptedShellPermissions() throws RemoteException { synchronized (mLock) { throwIfCalledByNotTrustedUidLocked(); throwIfShutdownLocked(); throwIfNotConnectedLocked(); } final long identity = Binder.clearCallingIdentity(); try { return mActivityManager.getDelegatedShellPermissions(); } finally { Binder.restoreCallingIdentity(identity); } } public class Repeater implements Runnable { // Continuously read readFrom and write back to writeTo until EOF is encountered private final InputStream readFrom; Loading