Merge "Move API for disabling an autofill service to the manager" into oc-dev am: 7a6df3b777

am: de369349a0

Change-Id: I2d48598f8e685591a88882aa1ba81a4e65268e3b
This commit is contained in:
Svet Ganov
2017-04-11 06:26:32 +00:00
committed by android-build-merger
13 changed files with 91 additions and 111 deletions

View File

@@ -94,9 +94,9 @@ public abstract class AutofillService extends Service {
private final IAutoFillService mInterface = new IAutoFillService.Stub() {
@Override
public void onInit(IAutoFillServiceConnection connection) {
if (connection != null) {
mHandlerCaller.obtainMessageO(MSG_CONNECT, connection).sendToTarget();
public void onConnectedStateChanged(boolean connected) {
if (connected) {
mHandlerCaller.obtainMessage(MSG_CONNECT).sendToTarget();
} else {
mHandlerCaller.obtainMessage(MSG_DISCONNECT).sendToTarget();
}
@@ -127,7 +127,6 @@ public abstract class AutofillService extends Service {
private final HandlerCaller.Callback mHandlerCallback = (msg) -> {
switch (msg.what) {
case MSG_CONNECT: {
mConnection = (IAutoFillServiceConnection) msg.obj;
onConnected();
break;
} case MSG_ON_FILL_REQUEST: {
@@ -152,7 +151,6 @@ public abstract class AutofillService extends Service {
break;
} case MSG_DISCONNECT: {
onDisconnected();
mConnection = null;
break;
} default: {
Log.w(TAG, "MyCallbacks received invalid message type: " + msg);
@@ -162,8 +160,6 @@ public abstract class AutofillService extends Service {
private HandlerCaller mHandlerCaller;
private IAutoFillServiceConnection mConnection;
/**
* {@inheritDoc}
*
@@ -246,21 +242,9 @@ public abstract class AutofillService extends Service {
public void onDisconnected() {
}
/**
* 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>
*/
/** @hide */
public final void disableSelf() {
if (mConnection != null) {
try {
mConnection.disableSelf();
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
}
// TODO(b/33197203): Remove when GCore has migrated off this API
getSystemService(AutofillManager.class).disableOwnedAutofillServices();
}
}

View File

@@ -18,7 +18,6 @@ package android.service.autofill;
import android.app.assist.AssistStructure;
import android.os.Bundle;
import android.service.autofill.IAutoFillServiceConnection;
import android.service.autofill.IFillCallback;
import android.service.autofill.ISaveCallback;
import com.android.internal.os.IResultReceiver;
@@ -29,7 +28,7 @@ import com.android.internal.os.IResultReceiver;
* @hide
*/
oneway interface IAutoFillService {
void onInit(in IAutoFillServiceConnection connection);
void onConnectedStateChanged(boolean connected);
void onFillRequest(in AssistStructure structure, in Bundle extras,
in IFillCallback callback, int flags);
void onSaveRequest(in AssistStructure structure, in Bundle extras,

View File

@@ -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();
}

View File

@@ -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() {
if (mContext instanceof AutofillClient) {
return (AutofillClient) mContext;

View File

@@ -35,10 +35,11 @@ interface IAutoFillManager {
boolean hasCallback, int flags, String packageName);
boolean restoreSession(int sessionId, in IBinder activityToken, in IBinder appCallback);
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);
void finishSession(int sessionId, int userId);
void cancelSession(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);
}