Merge "Guarded access to mCallback and check for null before using it."

This commit is contained in:
Felipe Leme
2017-02-09 18:17:50 +00:00
committed by Android (Google) Code Review
3 changed files with 13 additions and 7 deletions

View File

@@ -172,7 +172,7 @@ public abstract class AutoFillService extends Service {
* <p>You should generally do initialization here rather than in {@link #onCreate}.
*/
public void onConnected() {
//TODO(b/33197203): is not called anymore, fix it!
}
/**
@@ -221,6 +221,6 @@ public abstract class AutoFillService extends Service {
* <p> At this point this service may no longer be an active {@link AutoFillService}.
*/
public void onDisconnected() {
//TODO(b/33197203): is not called anymore, fix it!
}
}

View File

@@ -886,8 +886,10 @@ final class AutoFillManagerServiceImpl {
}
private AutoFillUI getUiForShowing() {
mUi.setCallback(this, mActivityToken);
return mUi;
synchronized (mLock) {
mUi.setCallbackLocked(this, mActivityToken);
return mUi;
}
}
private ViewNode findViewNodeByIdLocked(AutoFillId id) {
@@ -926,7 +928,7 @@ final class AutoFillManagerServiceImpl {
private void destroyLocked() {
mRemoteFillService.destroy();
mUi.hideAll();
mUi.setCallback(null, null);
mUi.setCallbackLocked(null, null);
}
private void removeSelf() {

View File

@@ -100,7 +100,7 @@ final class AutoFillUI {
mWm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
}
void setCallback(AutoFillUiCallback callback, IBinder activityToken) {
void setCallbackLocked(AutoFillUiCallback callback, IBinder activityToken) {
hideAll();
mCallback = callback;
mActivityToken = activityToken;
@@ -180,7 +180,11 @@ final class AutoFillUI {
synchronized (mLock) {
callback = mCallback;
}
callback.fill(dataset);
if (callback != null) {
callback.fill(dataset);
} else {
Slog.w(TAG, "null callback on showFillUi() for " + viewState.mId);
}
hideFillUi();
});