Merge "Grant clipboard access to the Augmented Autofill service." into qt-dev
am: 50a56879e5
Change-Id: I04776328cb605e27ff5a69c30e00681bbdce7e19
This commit is contained in:
@@ -45,4 +45,12 @@ public abstract class AutofillManagerInternal {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public abstract AutofillOptions getAutofillOptions(@NonNull String packageName,
|
public abstract AutofillOptions getAutofillOptions(@NonNull String packageName,
|
||||||
long versionCode, @UserIdInt int userId);
|
long versionCode, @UserIdInt int userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the given {@code uid} owns the
|
||||||
|
* {@link android.service.autofill.augmented.AugmentedAutofillService} implementation associated
|
||||||
|
* with the given {@code userId}.
|
||||||
|
*/
|
||||||
|
public abstract boolean isAugmentedAutofillServiceForUser(@NonNull int callingUid,
|
||||||
|
@UserIdInt int userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -806,6 +806,17 @@ public final class AutofillManagerService
|
|||||||
mAugmentedAutofillState.injectAugmentedAutofillInfo(options, userId, packageName);
|
mAugmentedAutofillState.injectAugmentedAutofillInfo(options, userId, packageName);
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAugmentedAutofillServiceForUser(int callingUid, int userId) {
|
||||||
|
synchronized (mLock) {
|
||||||
|
final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
|
||||||
|
if (service != null) {
|
||||||
|
return service.isAugmentedAutofillServiceForUserLocked(callingUid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1165,6 +1165,11 @@ final class AutofillManagerServiceImpl
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isAugmentedAutofillServiceForUserLocked(int callingUid) {
|
||||||
|
return mRemoteAugmentedAutofillServiceInfo != null
|
||||||
|
&& mRemoteAugmentedAutofillServiceInfo.applicationInfo.uid == callingUid;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets which packages and activities can trigger augmented autofill.
|
* Sets which packages and activities can trigger augmented autofill.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import android.provider.Settings;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
import android.view.autofill.AutofillManagerInternal;
|
||||||
|
|
||||||
import com.android.server.LocalServices;
|
import com.android.server.LocalServices;
|
||||||
import com.android.server.SystemService;
|
import com.android.server.SystemService;
|
||||||
@@ -159,6 +160,7 @@ public class ClipboardService extends SystemService {
|
|||||||
private final PackageManager mPm;
|
private final PackageManager mPm;
|
||||||
private final AppOpsManager mAppOps;
|
private final AppOpsManager mAppOps;
|
||||||
private final ContentCaptureManagerInternal mContentCaptureInternal;
|
private final ContentCaptureManagerInternal mContentCaptureInternal;
|
||||||
|
private final AutofillManagerInternal mAutofillInternal;
|
||||||
private final IBinder mPermissionOwner;
|
private final IBinder mPermissionOwner;
|
||||||
private HostClipboardMonitor mHostClipboardMonitor = null;
|
private HostClipboardMonitor mHostClipboardMonitor = null;
|
||||||
private Thread mHostMonitorThread = null;
|
private Thread mHostMonitorThread = null;
|
||||||
@@ -179,6 +181,7 @@ public class ClipboardService extends SystemService {
|
|||||||
mUm = (IUserManager) ServiceManager.getService(Context.USER_SERVICE);
|
mUm = (IUserManager) ServiceManager.getService(Context.USER_SERVICE);
|
||||||
mAppOps = (AppOpsManager) getContext().getSystemService(Context.APP_OPS_SERVICE);
|
mAppOps = (AppOpsManager) getContext().getSystemService(Context.APP_OPS_SERVICE);
|
||||||
mContentCaptureInternal = LocalServices.getService(ContentCaptureManagerInternal.class);
|
mContentCaptureInternal = LocalServices.getService(ContentCaptureManagerInternal.class);
|
||||||
|
mAutofillInternal = LocalServices.getService(AutofillManagerInternal.class);
|
||||||
final IBinder permOwner = mUgmInternal.newUriPermissionOwner("clipboard");
|
final IBinder permOwner = mUgmInternal.newUriPermissionOwner("clipboard");
|
||||||
mPermissionOwner = permOwner;
|
mPermissionOwner = permOwner;
|
||||||
if (IS_EMULATOR) {
|
if (IS_EMULATOR) {
|
||||||
@@ -653,13 +656,18 @@ public class ClipboardService extends SystemService {
|
|||||||
// Clipboard can only be read by applications with focus..
|
// Clipboard can only be read by applications with focus..
|
||||||
boolean allowed = mWm.isUidFocused(callingUid);
|
boolean allowed = mWm.isUidFocused(callingUid);
|
||||||
if (!allowed && mContentCaptureInternal != null) {
|
if (!allowed && mContentCaptureInternal != null) {
|
||||||
// ...or the Intelligence Service
|
// ...or the Content Capture Service
|
||||||
allowed = mContentCaptureInternal.isContentCaptureServiceForUser(callingUid,
|
allowed = mContentCaptureInternal.isContentCaptureServiceForUser(callingUid,
|
||||||
userId);
|
userId);
|
||||||
}
|
}
|
||||||
|
if (!allowed && mAutofillInternal != null) {
|
||||||
|
// ...or the Augmented Autofill Service
|
||||||
|
allowed = mAutofillInternal.isAugmentedAutofillServiceForUser(callingUid,
|
||||||
|
userId);
|
||||||
|
}
|
||||||
if (!allowed) {
|
if (!allowed) {
|
||||||
Slog.e(TAG, "Denying clipboard access to " + callingPackage
|
Slog.e(TAG, "Denying clipboard access to " + callingPackage
|
||||||
+ ", application is not in focus neither is the IntelligeService for "
|
+ ", application is not in focus neither is a system service for "
|
||||||
+ "user " + userId);
|
+ "user " + userId);
|
||||||
}
|
}
|
||||||
return allowed;
|
return allowed;
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageItemInfo;
|
import android.content.pm.PackageItemInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManagerInternal;
|
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources.Theme;
|
import android.content.res.Resources.Theme;
|
||||||
import android.database.sqlite.SQLiteCompatibilityWalFlags;
|
import android.database.sqlite.SQLiteCompatibilityWalFlags;
|
||||||
@@ -1248,11 +1247,6 @@ public final class SystemServer {
|
|||||||
mSystemServiceManager.startService(CONTENT_SUGGESTIONS_SERVICE_CLASS);
|
mSystemServiceManager.startService(CONTENT_SUGGESTIONS_SERVICE_CLASS);
|
||||||
traceEnd();
|
traceEnd();
|
||||||
|
|
||||||
// NOTE: ClipboardService indirectly depends on IntelligenceService
|
|
||||||
traceBeginAndSlog("StartClipboardService");
|
|
||||||
mSystemServiceManager.startService(ClipboardService.class);
|
|
||||||
traceEnd();
|
|
||||||
|
|
||||||
traceBeginAndSlog("InitNetworkStackClient");
|
traceBeginAndSlog("InitNetworkStackClient");
|
||||||
try {
|
try {
|
||||||
NetworkStackClient.getInstance().init();
|
NetworkStackClient.getInstance().init();
|
||||||
@@ -1887,6 +1881,11 @@ public final class SystemServer {
|
|||||||
traceEnd();
|
traceEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: ClipboardService depends on ContentCapture and Autofill
|
||||||
|
traceBeginAndSlog("StartClipboardService");
|
||||||
|
mSystemServiceManager.startService(ClipboardService.class);
|
||||||
|
traceEnd();
|
||||||
|
|
||||||
traceBeginAndSlog("AppServiceManager");
|
traceBeginAndSlog("AppServiceManager");
|
||||||
mSystemServiceManager.startService(AppBindingService.Lifecycle.class);
|
mSystemServiceManager.startService(AppBindingService.Lifecycle.class);
|
||||||
traceEnd();
|
traceEnd();
|
||||||
|
|||||||
Reference in New Issue
Block a user