From ef0c1885cb9aa62dc2d2eee2849d103b32271133 Mon Sep 17 00:00:00 2001 From: Svet Ganov Date: Fri, 10 Feb 2017 03:45:28 -0800 Subject: [PATCH] Move auto-fill shell command off IPC Auto-fill has a shell command that is useful for development which is currently exposed as a remote method allowing any app to call it reflectively. Since only case this method is called is when handling a shell command there is no need to expose it to IPC over binder. Test: manual Change-Id: Iac20b4a39c7065e254f8aa277d1f2fd1c38b24a8 --- .../service/autofill/IAutoFillManagerService.aidl | 3 --- .../server/autofill/AutoFillManagerService.java | 15 +++++++-------- .../AutoFillManagerServiceShellCommand.java | 5 ++--- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/core/java/android/service/autofill/IAutoFillManagerService.aidl b/core/java/android/service/autofill/IAutoFillManagerService.aidl index b39c0c8e07d4e..6cdb516860efe 100644 --- a/core/java/android/service/autofill/IAutoFillManagerService.aidl +++ b/core/java/android/service/autofill/IAutoFillManagerService.aidl @@ -34,7 +34,4 @@ oneway interface IAutoFillManagerService { void updateSession(in IBinder activityToken, in AutoFillId id, in Rect bounds, in AutoFillValue value, int flags); void finishSession(in IBinder activityToken); - - // Methods called by ShellCommand - void requestSaveForUser(int userId); } diff --git a/services/autofill/java/com/android/server/autofill/AutoFillManagerService.java b/services/autofill/java/com/android/server/autofill/AutoFillManagerService.java index 93473503479b5..631fb530f2d62 100644 --- a/services/autofill/java/com/android/server/autofill/AutoFillManagerService.java +++ b/services/autofill/java/com/android/server/autofill/AutoFillManagerService.java @@ -203,6 +203,12 @@ public final class AutoFillManagerService extends SystemService { return service; } + void requestSaveForUser(int userId) { + mContext.enforceCallingPermission(MANAGE_AUTO_FILL, TAG); + mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageI( + MSG_REQUEST_SAVE_FOR_USER, userId)); + } + /** * Removes a cached service for a given user. */ @@ -317,13 +323,6 @@ public final class AutoFillManagerService extends SystemService { UserHandle.getCallingUserId(), 0, activityToken)); } - @Override - public void requestSaveForUser(int userId) { - mContext.enforceCallingPermission(MANAGE_AUTO_FILL, TAG); - mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageI(MSG_REQUEST_SAVE_FOR_USER, - userId)); - } - @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (mContext.checkCallingPermission( @@ -355,7 +354,7 @@ public final class AutoFillManagerService extends SystemService { @Override public void onShellCommand(FileDescriptor in, FileDescriptor out, FileDescriptor err, String[] args, ShellCallback callback, ResultReceiver resultReceiver) { - (new AutoFillManagerServiceShellCommand(this)).exec( + (new AutoFillManagerServiceShellCommand(AutoFillManagerService.this)).exec( this, in, out, err, args, callback, resultReceiver); } } diff --git a/services/autofill/java/com/android/server/autofill/AutoFillManagerServiceShellCommand.java b/services/autofill/java/com/android/server/autofill/AutoFillManagerServiceShellCommand.java index 201a8890aad04..3318b2bf3843a 100644 --- a/services/autofill/java/com/android/server/autofill/AutoFillManagerServiceShellCommand.java +++ b/services/autofill/java/com/android/server/autofill/AutoFillManagerServiceShellCommand.java @@ -20,15 +20,14 @@ import android.app.ActivityManager; import android.os.RemoteException; import android.os.ShellCommand; import android.os.UserHandle; -import android.service.autofill.IAutoFillManagerService; import java.io.PrintWriter; public final class AutoFillManagerServiceShellCommand extends ShellCommand { - private final IAutoFillManagerService.Stub mService; + private final AutoFillManagerService mService; - public AutoFillManagerServiceShellCommand(IAutoFillManagerService.Stub service) { + public AutoFillManagerServiceShellCommand(AutoFillManagerService service) { mService = service; }