Merge "Move API for disabling an autofill service to the manager" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7a6df3b777
@@ -273,7 +273,6 @@ LOCAL_SRC_FILES += \
|
|||||||
core/java/android/security/IKeystoreService.aidl \
|
core/java/android/security/IKeystoreService.aidl \
|
||||||
core/java/android/security/keymaster/IKeyAttestationApplicationIdProvider.aidl \
|
core/java/android/security/keymaster/IKeyAttestationApplicationIdProvider.aidl \
|
||||||
core/java/android/service/autofill/IAutoFillService.aidl \
|
core/java/android/service/autofill/IAutoFillService.aidl \
|
||||||
core/java/android/service/autofill/IAutoFillServiceConnection.aidl \
|
|
||||||
core/java/android/service/autofill/IFillCallback.aidl \
|
core/java/android/service/autofill/IFillCallback.aidl \
|
||||||
core/java/android/service/autofill/ISaveCallback.aidl \
|
core/java/android/service/autofill/ISaveCallback.aidl \
|
||||||
core/java/android/service/carrier/ICarrierService.aidl \
|
core/java/android/service/carrier/ICarrierService.aidl \
|
||||||
|
|||||||
@@ -36986,7 +36986,6 @@ package android.service.autofill {
|
|||||||
|
|
||||||
public abstract class AutofillService extends android.app.Service {
|
public abstract class AutofillService extends android.app.Service {
|
||||||
ctor public AutofillService();
|
ctor public AutofillService();
|
||||||
method public final void disableSelf();
|
|
||||||
method public final android.os.IBinder onBind(android.content.Intent);
|
method public final android.os.IBinder onBind(android.content.Intent);
|
||||||
method public void onConnected();
|
method public void onConnected();
|
||||||
method public void onDisconnected();
|
method public void onDisconnected();
|
||||||
@@ -47732,6 +47731,7 @@ package android.view.autofill {
|
|||||||
public final class AutofillManager {
|
public final class AutofillManager {
|
||||||
method public void cancel();
|
method public void cancel();
|
||||||
method public void commit();
|
method public void commit();
|
||||||
|
method public void disableOwnedAutofillServices();
|
||||||
method public boolean isEnabled();
|
method public boolean isEnabled();
|
||||||
method public void notifyValueChanged(android.view.View);
|
method public void notifyValueChanged(android.view.View);
|
||||||
method public void notifyValueChanged(android.view.View, int, android.view.autofill.AutofillValue);
|
method public void notifyValueChanged(android.view.View, int, android.view.autofill.AutofillValue);
|
||||||
|
|||||||
@@ -40082,7 +40082,6 @@ package android.service.autofill {
|
|||||||
|
|
||||||
public abstract class AutofillService extends android.app.Service {
|
public abstract class AutofillService extends android.app.Service {
|
||||||
ctor public AutofillService();
|
ctor public AutofillService();
|
||||||
method public final void disableSelf();
|
|
||||||
method public final android.os.IBinder onBind(android.content.Intent);
|
method public final android.os.IBinder onBind(android.content.Intent);
|
||||||
method public void onConnected();
|
method public void onConnected();
|
||||||
method public void onDisconnected();
|
method public void onDisconnected();
|
||||||
@@ -51284,6 +51283,7 @@ package android.view.autofill {
|
|||||||
public final class AutofillManager {
|
public final class AutofillManager {
|
||||||
method public void cancel();
|
method public void cancel();
|
||||||
method public void commit();
|
method public void commit();
|
||||||
|
method public void disableOwnedAutofillServices();
|
||||||
method public boolean isEnabled();
|
method public boolean isEnabled();
|
||||||
method public void notifyValueChanged(android.view.View);
|
method public void notifyValueChanged(android.view.View);
|
||||||
method public void notifyValueChanged(android.view.View, int, android.view.autofill.AutofillValue);
|
method public void notifyValueChanged(android.view.View, int, android.view.autofill.AutofillValue);
|
||||||
|
|||||||
@@ -37144,7 +37144,6 @@ package android.service.autofill {
|
|||||||
|
|
||||||
public abstract class AutofillService extends android.app.Service {
|
public abstract class AutofillService extends android.app.Service {
|
||||||
ctor public AutofillService();
|
ctor public AutofillService();
|
||||||
method public final void disableSelf();
|
|
||||||
method public final android.os.IBinder onBind(android.content.Intent);
|
method public final android.os.IBinder onBind(android.content.Intent);
|
||||||
method public void onConnected();
|
method public void onConnected();
|
||||||
method public void onDisconnected();
|
method public void onDisconnected();
|
||||||
@@ -48114,6 +48113,7 @@ package android.view.autofill {
|
|||||||
public final class AutofillManager {
|
public final class AutofillManager {
|
||||||
method public void cancel();
|
method public void cancel();
|
||||||
method public void commit();
|
method public void commit();
|
||||||
|
method public void disableOwnedAutofillServices();
|
||||||
method public boolean isEnabled();
|
method public boolean isEnabled();
|
||||||
method public void notifyValueChanged(android.view.View);
|
method public void notifyValueChanged(android.view.View);
|
||||||
method public void notifyValueChanged(android.view.View, int, android.view.autofill.AutofillValue);
|
method public void notifyValueChanged(android.view.View, int, android.view.autofill.AutofillValue);
|
||||||
|
|||||||
@@ -94,9 +94,9 @@ public abstract class AutofillService extends Service {
|
|||||||
|
|
||||||
private final IAutoFillService mInterface = new IAutoFillService.Stub() {
|
private final IAutoFillService mInterface = new IAutoFillService.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onInit(IAutoFillServiceConnection connection) {
|
public void onConnectedStateChanged(boolean connected) {
|
||||||
if (connection != null) {
|
if (connected) {
|
||||||
mHandlerCaller.obtainMessageO(MSG_CONNECT, connection).sendToTarget();
|
mHandlerCaller.obtainMessage(MSG_CONNECT).sendToTarget();
|
||||||
} else {
|
} else {
|
||||||
mHandlerCaller.obtainMessage(MSG_DISCONNECT).sendToTarget();
|
mHandlerCaller.obtainMessage(MSG_DISCONNECT).sendToTarget();
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,6 @@ public abstract class AutofillService extends Service {
|
|||||||
private final HandlerCaller.Callback mHandlerCallback = (msg) -> {
|
private final HandlerCaller.Callback mHandlerCallback = (msg) -> {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MSG_CONNECT: {
|
case MSG_CONNECT: {
|
||||||
mConnection = (IAutoFillServiceConnection) msg.obj;
|
|
||||||
onConnected();
|
onConnected();
|
||||||
break;
|
break;
|
||||||
} case MSG_ON_FILL_REQUEST: {
|
} case MSG_ON_FILL_REQUEST: {
|
||||||
@@ -152,7 +151,6 @@ public abstract class AutofillService extends Service {
|
|||||||
break;
|
break;
|
||||||
} case MSG_DISCONNECT: {
|
} case MSG_DISCONNECT: {
|
||||||
onDisconnected();
|
onDisconnected();
|
||||||
mConnection = null;
|
|
||||||
break;
|
break;
|
||||||
} default: {
|
} default: {
|
||||||
Log.w(TAG, "MyCallbacks received invalid message type: " + msg);
|
Log.w(TAG, "MyCallbacks received invalid message type: " + msg);
|
||||||
@@ -162,8 +160,6 @@ public abstract class AutofillService extends Service {
|
|||||||
|
|
||||||
private HandlerCaller mHandlerCaller;
|
private HandlerCaller mHandlerCaller;
|
||||||
|
|
||||||
private IAutoFillServiceConnection mConnection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
@@ -246,21 +242,9 @@ public abstract class AutofillService extends Service {
|
|||||||
public void onDisconnected() {
|
public void onDisconnected() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** @hide */
|
||||||
* Disables the service. After calling this method, the service will
|
|
||||||
* be disabled and settings will show that it is turned off.
|
|
||||||
*
|
|
||||||
* <p>You should call this method only after a call to {@link #onConnected()}
|
|
||||||
* and before the corresponding call to {@link #onDisconnected()}. In other words
|
|
||||||
* you can disable your service only while the system is connected to it.</p>
|
|
||||||
*/
|
|
||||||
public final void disableSelf() {
|
public final void disableSelf() {
|
||||||
if (mConnection != null) {
|
// TODO(b/33197203): Remove when GCore has migrated off this API
|
||||||
try {
|
getSystemService(AutofillManager.class).disableOwnedAutofillServices();
|
||||||
mConnection.disableSelf();
|
|
||||||
} catch (RemoteException re) {
|
|
||||||
throw re.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package android.service.autofill;
|
|||||||
|
|
||||||
import android.app.assist.AssistStructure;
|
import android.app.assist.AssistStructure;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.service.autofill.IAutoFillServiceConnection;
|
|
||||||
import android.service.autofill.IFillCallback;
|
import android.service.autofill.IFillCallback;
|
||||||
import android.service.autofill.ISaveCallback;
|
import android.service.autofill.ISaveCallback;
|
||||||
import com.android.internal.os.IResultReceiver;
|
import com.android.internal.os.IResultReceiver;
|
||||||
@@ -29,7 +28,7 @@ import com.android.internal.os.IResultReceiver;
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
oneway interface IAutoFillService {
|
oneway interface IAutoFillService {
|
||||||
void onInit(in IAutoFillServiceConnection connection);
|
void onConnectedStateChanged(boolean connected);
|
||||||
void onFillRequest(in AssistStructure structure, in Bundle extras,
|
void onFillRequest(in AssistStructure structure, in Bundle extras,
|
||||||
in IFillCallback callback, int flags);
|
in IFillCallback callback, int flags);
|
||||||
void onSaveRequest(in AssistStructure structure, in Bundle extras,
|
void onSaveRequest(in AssistStructure structure, in Bundle extras,
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2017 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.service.autofill;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface from an auto fill service to the system.
|
|
||||||
*
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
interface IAutoFillServiceConnection {
|
|
||||||
void disableSelf();
|
|
||||||
}
|
|
||||||
@@ -537,6 +537,18 @@ public final class AutofillManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the app calling this API has enabled autofill services they
|
||||||
|
* will be disabled.
|
||||||
|
*/
|
||||||
|
public void disableOwnedAutofillServices() {
|
||||||
|
try {
|
||||||
|
mService.disableOwnedAutofillServices(mContext.getUserId());
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw e.rethrowFromSystemServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private AutofillClient getClientLocked() {
|
private AutofillClient getClientLocked() {
|
||||||
if (mContext instanceof AutofillClient) {
|
if (mContext instanceof AutofillClient) {
|
||||||
return (AutofillClient) mContext;
|
return (AutofillClient) mContext;
|
||||||
|
|||||||
@@ -35,10 +35,11 @@ interface IAutoFillManager {
|
|||||||
boolean hasCallback, int flags, String packageName);
|
boolean hasCallback, int flags, String packageName);
|
||||||
boolean restoreSession(int sessionId, in IBinder activityToken, in IBinder appCallback);
|
boolean restoreSession(int sessionId, in IBinder activityToken, in IBinder appCallback);
|
||||||
void setWindow(int sessionId, in IBinder windowToken);
|
void setWindow(int sessionId, in IBinder windowToken);
|
||||||
oneway void updateSession(int sessionId, in AutofillId id, in Rect bounds,
|
void updateSession(int sessionId, in AutofillId id, in Rect bounds,
|
||||||
in AutofillValue value, int flags, int userId);
|
in AutofillValue value, int flags, int userId);
|
||||||
void finishSession(int sessionId, int userId);
|
void finishSession(int sessionId, int userId);
|
||||||
void cancelSession(int sessionId, int userId);
|
void cancelSession(int sessionId, int userId);
|
||||||
void setAuthenticationResult(in Bundle data, int sessionId, int userId);
|
void setAuthenticationResult(in Bundle data, int sessionId, int userId);
|
||||||
oneway void setHasCallback(int sessionId, int userId, boolean hasIt);
|
void setHasCallback(int sessionId, int userId, boolean hasIt);
|
||||||
|
void disableOwnedAutofillServices(int userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import static com.android.server.autofill.Helper.VERBOSE;
|
|||||||
import static com.android.server.autofill.Helper.bundleToString;
|
import static com.android.server.autofill.Helper.bundleToString;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityManagerInternal;
|
import android.app.ActivityManagerInternal;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
@@ -35,6 +37,7 @@ import android.content.pm.UserInfo;
|
|||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Binder;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@@ -194,15 +197,29 @@ public final class AutofillManagerService extends SystemService {
|
|||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
AutofillManagerServiceImpl getServiceForUserLocked(int userId) {
|
AutofillManagerServiceImpl getServiceForUserLocked(int userId) {
|
||||||
AutofillManagerServiceImpl service = mServicesCache.get(userId);
|
final int resolvedUserId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
|
||||||
|
Binder.getCallingUid(), userId, false, false, null, null);
|
||||||
|
AutofillManagerServiceImpl service = mServicesCache.get(resolvedUserId);
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
service = new AutofillManagerServiceImpl(mContext, mLock,
|
service = new AutofillManagerServiceImpl(mContext, mLock, mRequestsHistory,
|
||||||
mRequestsHistory, userId, mUi, mDisabledUsers.get(userId));
|
resolvedUserId, mUi, mDisabledUsers.get(resolvedUserId));
|
||||||
mServicesCache.put(userId, service);
|
mServicesCache.put(userId, service);
|
||||||
}
|
}
|
||||||
return service;
|
return service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Peeks the service instance for a user.
|
||||||
|
*
|
||||||
|
* @return service instance or null if not already present
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
AutofillManagerServiceImpl peekServiceForUserLocked(int userId) {
|
||||||
|
final int resolvedUserId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
|
||||||
|
Binder.getCallingUid(), userId, false, false, null, null);
|
||||||
|
return mServicesCache.get(resolvedUserId);
|
||||||
|
}
|
||||||
|
|
||||||
// Called by Shell command.
|
// Called by Shell command.
|
||||||
void requestSaveForUser(int userId) {
|
void requestSaveForUser(int userId) {
|
||||||
Slog.i(TAG, "requestSaveForUser(): " + userId);
|
Slog.i(TAG, "requestSaveForUser(): " + userId);
|
||||||
@@ -210,7 +227,7 @@ public final class AutofillManagerService extends SystemService {
|
|||||||
final IBinder activityToken = getTopActivityForUser();
|
final IBinder activityToken = getTopActivityForUser();
|
||||||
if (activityToken != null) {
|
if (activityToken != null) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
final AutofillManagerServiceImpl service = mServicesCache.get(userId);
|
final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
Log.w(TAG, "handleSaveForUser(): no cached service for userId " + userId);
|
Log.w(TAG, "handleSaveForUser(): no cached service for userId " + userId);
|
||||||
return;
|
return;
|
||||||
@@ -228,7 +245,10 @@ public final class AutofillManagerService extends SystemService {
|
|||||||
|
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (userId != UserHandle.USER_ALL) {
|
if (userId != UserHandle.USER_ALL) {
|
||||||
mServicesCache.get(userId).destroySessionsLocked();
|
AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
|
||||||
|
if (service != null) {
|
||||||
|
service.destroySessionsLocked();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final int size = mServicesCache.size();
|
final int size = mServicesCache.size();
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
@@ -253,7 +273,10 @@ public final class AutofillManagerService extends SystemService {
|
|||||||
|
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (userId != UserHandle.USER_ALL) {
|
if (userId != UserHandle.USER_ALL) {
|
||||||
mServicesCache.get(userId).listSessionsLocked(sessions);
|
AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
|
||||||
|
if (service != null) {
|
||||||
|
service.listSessionsLocked(sessions);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final int size = mServicesCache.size();
|
final int size = mServicesCache.size();
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
@@ -287,7 +310,7 @@ public final class AutofillManagerService extends SystemService {
|
|||||||
* Removes a cached service for a given user.
|
* Removes a cached service for a given user.
|
||||||
*/
|
*/
|
||||||
private void removeCachedServiceLocked(int userId) {
|
private void removeCachedServiceLocked(int userId) {
|
||||||
final AutofillManagerServiceImpl service = mServicesCache.get(userId);
|
final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
mServicesCache.delete(userId);
|
mServicesCache.delete(userId);
|
||||||
service.destroyLocked();
|
service.destroyLocked();
|
||||||
@@ -305,7 +328,7 @@ public final class AutofillManagerService extends SystemService {
|
|||||||
* Updates a cached service for a given user.
|
* Updates a cached service for a given user.
|
||||||
*/
|
*/
|
||||||
private void updateCachedServiceLocked(int userId, boolean disabled) {
|
private void updateCachedServiceLocked(int userId, boolean disabled) {
|
||||||
AutofillManagerServiceImpl service = mServicesCache.get(userId);
|
AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
service.updateLocked(disabled);
|
service.updateLocked(disabled);
|
||||||
}
|
}
|
||||||
@@ -409,8 +432,7 @@ public final class AutofillManagerService extends SystemService {
|
|||||||
public void updateSession(int sessionId, AutofillId id, Rect bounds,
|
public void updateSession(int sessionId, AutofillId id, Rect bounds,
|
||||||
AutofillValue value, int flags, int userId) {
|
AutofillValue value, int flags, int userId) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
final AutofillManagerServiceImpl service = mServicesCache.get(
|
final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
|
||||||
UserHandle.getCallingUserId());
|
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
service.updateSessionLocked(sessionId, getCallingUid(), id, bounds, value,
|
service.updateSessionLocked(sessionId, getCallingUid(), id, bounds, value,
|
||||||
flags);
|
flags);
|
||||||
@@ -421,8 +443,7 @@ public final class AutofillManagerService extends SystemService {
|
|||||||
@Override
|
@Override
|
||||||
public void finishSession(int sessionId, int userId) {
|
public void finishSession(int sessionId, int userId) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
final AutofillManagerServiceImpl service = mServicesCache.get(
|
final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
|
||||||
UserHandle.getCallingUserId());
|
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
service.finishSessionLocked(sessionId, getCallingUid());
|
service.finishSessionLocked(sessionId, getCallingUid());
|
||||||
}
|
}
|
||||||
@@ -432,14 +453,23 @@ public final class AutofillManagerService extends SystemService {
|
|||||||
@Override
|
@Override
|
||||||
public void cancelSession(int sessionId, int userId) {
|
public void cancelSession(int sessionId, int userId) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
final AutofillManagerServiceImpl service = mServicesCache.get(
|
final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
|
||||||
UserHandle.getCallingUserId());
|
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
service.cancelSessionLocked(sessionId, getCallingUid());
|
service.cancelSessionLocked(sessionId, getCallingUid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disableOwnedAutofillServices(int userId) {
|
||||||
|
synchronized (mLock) {
|
||||||
|
final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
|
||||||
|
if (service != null) {
|
||||||
|
service.disableOwnedAutofillServicesLocked(Binder.getCallingUid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||||
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
|
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import android.os.IBinder;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.RemoteCallbackList;
|
import android.os.RemoteCallbackList;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.autofill.AutofillService;
|
import android.service.autofill.AutofillService;
|
||||||
@@ -348,6 +349,25 @@ final class AutofillManagerServiceImpl {
|
|||||||
session.removeSelfLocked();
|
session.removeSelfLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void disableOwnedAutofillServicesLocked(int uid) {
|
||||||
|
if (mInfo == null || mInfo.getServiceInfo().applicationInfo.uid
|
||||||
|
!= UserHandle.getAppId(uid)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final long identity = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
final String autoFillService = getComponentNameFromSettings();
|
||||||
|
if (mInfo.getServiceInfo().getComponentName().equals(
|
||||||
|
ComponentName.unflattenFromString(autoFillService))) {
|
||||||
|
Settings.Secure.putStringForUser(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.AUTOFILL_SERVICE, null, mUserId);
|
||||||
|
destroySessionsLocked();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(identity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Session createSessionByTokenLocked(@NonNull IBinder activityToken, int uid,
|
private Session createSessionByTokenLocked(@NonNull IBinder activityToken, int uid,
|
||||||
@Nullable IBinder windowToken, @NonNull IBinder appCallbackToken, boolean hasCallback,
|
@Nullable IBinder windowToken, @NonNull IBinder appCallbackToken, boolean hasCallback,
|
||||||
int flags, @NonNull String packageName) {
|
int flags, @NonNull String packageName) {
|
||||||
@@ -474,20 +494,6 @@ final class AutofillManagerServiceImpl {
|
|||||||
mSessions.clear();
|
mSessions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void disableSelf() {
|
|
||||||
final long identity = Binder.clearCallingIdentity();
|
|
||||||
try {
|
|
||||||
final String autoFillService = getComponentNameFromSettings();
|
|
||||||
if (mInfo.getServiceInfo().getComponentName().equals(
|
|
||||||
ComponentName.unflattenFromString(autoFillService))) {
|
|
||||||
Settings.Secure.putStringForUser(mContext.getContentResolver(),
|
|
||||||
Settings.Secure.AUTOFILL_SERVICE, null, mUserId);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
Binder.restoreCallingIdentity(identity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CharSequence getServiceLabel() {
|
CharSequence getServiceLabel() {
|
||||||
return mInfo.getServiceInfo().loadLabel(mContext.getPackageManager());
|
return mInfo.getServiceInfo().loadLabel(mContext.getPackageManager());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import android.os.UserHandle;
|
|||||||
import android.service.autofill.AutofillService;
|
import android.service.autofill.AutofillService;
|
||||||
import android.service.autofill.FillResponse;
|
import android.service.autofill.FillResponse;
|
||||||
import android.service.autofill.IAutoFillService;
|
import android.service.autofill.IAutoFillService;
|
||||||
import android.service.autofill.IAutoFillServiceConnection;
|
|
||||||
import android.service.autofill.IFillCallback;
|
import android.service.autofill.IFillCallback;
|
||||||
import android.service.autofill.ISaveCallback;
|
import android.service.autofill.ISaveCallback;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
@@ -96,7 +95,6 @@ final class RemoteFillService implements DeathRecipient {
|
|||||||
void onSaveRequestFailure(@Nullable CharSequence message,
|
void onSaveRequestFailure(@Nullable CharSequence message,
|
||||||
@NonNull String servicePackageName);
|
@NonNull String servicePackageName);
|
||||||
void onServiceDied(RemoteFillService service);
|
void onServiceDied(RemoteFillService service);
|
||||||
void onDisableSelf();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RemoteFillService(Context context, ComponentName componentName,
|
public RemoteFillService(Context context, ComponentName componentName,
|
||||||
@@ -203,10 +201,6 @@ final class RemoteFillService implements DeathRecipient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleDisableSelf() {
|
|
||||||
mCallbacks.onDisableSelf();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isBound() {
|
private boolean isBound() {
|
||||||
return mAutoFillService != null;
|
return mAutoFillService != null;
|
||||||
}
|
}
|
||||||
@@ -246,7 +240,7 @@ final class RemoteFillService implements DeathRecipient {
|
|||||||
mBinding = false;
|
mBinding = false;
|
||||||
if (isBound()) {
|
if (isBound()) {
|
||||||
try {
|
try {
|
||||||
mAutoFillService.onInit(null);
|
mAutoFillService.onConnectedStateChanged(false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Slog.w(LOG_TAG, "Exception calling onDisconnected(): " + e);
|
Slog.w(LOG_TAG, "Exception calling onDisconnected(): " + e);
|
||||||
}
|
}
|
||||||
@@ -322,12 +316,7 @@ final class RemoteFillService implements DeathRecipient {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
mAutoFillService.onInit(new IAutoFillServiceConnection.Stub() {
|
mAutoFillService.onConnectedStateChanged(true);
|
||||||
@Override
|
|
||||||
public void disableSelf() {
|
|
||||||
mHandler.obtainMessage(MyHandler.MSG_ON_DISABLE_SELF).sendToTarget();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.w(LOG_TAG, "Exception calling onConnected(): " + e);
|
Slog.w(LOG_TAG, "Exception calling onConnected(): " + e);
|
||||||
}
|
}
|
||||||
@@ -353,7 +342,6 @@ final class RemoteFillService implements DeathRecipient {
|
|||||||
public static final int MSG_BINDER_DIED = 2;
|
public static final int MSG_BINDER_DIED = 2;
|
||||||
public static final int MSG_UNBIND = 3;
|
public static final int MSG_UNBIND = 3;
|
||||||
public static final int MSG_ON_PENDING_REQUEST = 4;
|
public static final int MSG_ON_PENDING_REQUEST = 4;
|
||||||
public static final int MSG_ON_DISABLE_SELF = 5;
|
|
||||||
|
|
||||||
public MyHandler(Context context) {
|
public MyHandler(Context context) {
|
||||||
// Cannot use lambda - doesn't compile
|
// Cannot use lambda - doesn't compile
|
||||||
@@ -381,10 +369,6 @@ final class RemoteFillService implements DeathRecipient {
|
|||||||
case MSG_ON_PENDING_REQUEST: {
|
case MSG_ON_PENDING_REQUEST: {
|
||||||
handlePendingRequest((PendingRequest) message.obj);
|
handlePendingRequest((PendingRequest) message.obj);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case MSG_ON_DISABLE_SELF: {
|
|
||||||
handleDisableSelf();
|
|
||||||
} break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|||||||
@@ -309,15 +309,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
mHandlerCaller.getHandler().post(() -> startAuthentication(intent, fillInIntent));
|
mHandlerCaller.getHandler().post(() -> startAuthentication(intent, fillInIntent));
|
||||||
}
|
}
|
||||||
|
|
||||||
// FillServiceCallbacks
|
|
||||||
@Override
|
|
||||||
public void onDisableSelf() {
|
|
||||||
mService.disableSelf();
|
|
||||||
synchronized (mLock) {
|
|
||||||
removeSelfLocked();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// FillServiceCallbacks
|
// FillServiceCallbacks
|
||||||
@Override
|
@Override
|
||||||
public void onServiceDied(RemoteFillService service) {
|
public void onServiceDied(RemoteFillService service) {
|
||||||
|
|||||||
Reference in New Issue
Block a user