Loading services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java +57 −3 Original line number Original line Diff line number Diff line Loading @@ -41,7 +41,12 @@ import static com.android.server.autofill.Helper.sVerbose; import android.annotation.IntDef; import android.annotation.IntDef; import android.annotation.Nullable; import android.annotation.Nullable; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.provider.Settings; import android.service.autofill.Dataset; import android.service.autofill.Dataset; import android.text.TextUtils; import android.util.Slog; import android.util.Slog; import android.view.autofill.AutofillId; import android.view.autofill.AutofillId; import android.view.autofill.AutofillManager; import android.view.autofill.AutofillManager; Loading Loading @@ -72,6 +77,7 @@ public final class PresentationStatsEventLogger { }) }) @Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE) public @interface NotShownReason {} public @interface NotShownReason {} public static final int NOT_SHOWN_REASON_ANY_SHOWN = AUTOFILL_PRESENTATION_EVENT_REPORTED__PRESENTATION_EVENT_RESULT__ANY_SHOWN; public static final int NOT_SHOWN_REASON_ANY_SHOWN = AUTOFILL_PRESENTATION_EVENT_REPORTED__PRESENTATION_EVENT_RESULT__ANY_SHOWN; public static final int NOT_SHOWN_REASON_VIEW_FOCUS_CHANGED = AUTOFILL_PRESENTATION_EVENT_REPORTED__PRESENTATION_EVENT_RESULT__NONE_SHOWN_VIEW_FOCUS_CHANGED; public static final int NOT_SHOWN_REASON_VIEW_FOCUS_CHANGED = AUTOFILL_PRESENTATION_EVENT_REPORTED__PRESENTATION_EVENT_RESULT__NONE_SHOWN_VIEW_FOCUS_CHANGED; public static final int NOT_SHOWN_REASON_VIEW_CHANGED = AUTOFILL_PRESENTATION_EVENT_REPORTED__PRESENTATION_EVENT_RESULT__NONE_SHOWN_VIEW_CHANGED; public static final int NOT_SHOWN_REASON_VIEW_CHANGED = AUTOFILL_PRESENTATION_EVENT_REPORTED__PRESENTATION_EVENT_RESULT__NONE_SHOWN_VIEW_CHANGED; Loading Loading @@ -172,6 +178,45 @@ public final class PresentationStatsEventLogger { }); }); } } public void maybeSetInlinePresentationAndSuggestionHostUid(Context context, int userId) { mEventInternal.ifPresent(event -> { event.mDisplayPresentationType = UI_TYPE_INLINE; String imeString = Settings.Secure.getStringForUser(context.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD, userId); if (TextUtils.isEmpty(imeString)) { Slog.w(TAG, "No default IME found"); return; } ComponentName imeComponent = ComponentName.unflattenFromString(imeString); if (imeComponent == null) { Slog.w(TAG, "No default IME found"); return; } int imeUid; String packageName = imeComponent.getPackageName(); try { imeUid = context.getPackageManager().getApplicationInfoAsUser(packageName, PackageManager.ApplicationInfoFlags.of(0), userId).uid; } catch (PackageManager.NameNotFoundException e) { Slog.w(TAG, "Couldn't find packageName: " + packageName); return; } event.mInlineSuggestionHostUid = imeUid; }); } public void maybeSetAutofillServiceUid(int uid) { mEventInternal.ifPresent(event -> { event.mAutofillServiceUid = uid; }); } public void maybeSetIsNewRequest(boolean isRequestTriggered) { mEventInternal.ifPresent(event -> { event.mIsRequestTriggered = isRequestTriggered; }); } public void logAndEndEvent() { public void logAndEndEvent() { if (!mEventInternal.isPresent()) { if (!mEventInternal.isPresent()) { Slog.w(TAG, "Shouldn't be logging AutofillPresentationEventReported again for same " Slog.w(TAG, "Shouldn't be logging AutofillPresentationEventReported again for same " Loading @@ -190,7 +235,10 @@ public final class PresentationStatsEventLogger { + " mCountNotShownImePresentationNotDrawn=" + " mCountNotShownImePresentationNotDrawn=" + event.mCountNotShownImePresentationNotDrawn + event.mCountNotShownImePresentationNotDrawn + " mCountNotShownImeUserNotSeen=" + event.mCountNotShownImeUserNotSeen + " mCountNotShownImeUserNotSeen=" + event.mCountNotShownImeUserNotSeen + " mDisplayPresentationType=" + event.mDisplayPresentationType); + " mDisplayPresentationType=" + event.mDisplayPresentationType + " mAutofillServiceUid=" + event.mAutofillServiceUid + " mInlineSuggestionHostUid=" + event.mInlineSuggestionHostUid + " mIsRequestTriggered=" + event.mIsRequestTriggered); } } // TODO(b/234185326): Distinguish empty responses from other no presentation reasons. // TODO(b/234185326): Distinguish empty responses from other no presentation reasons. Loading @@ -208,7 +256,10 @@ public final class PresentationStatsEventLogger { event.mCountFilteredUserTyping, event.mCountFilteredUserTyping, event.mCountNotShownImePresentationNotDrawn, event.mCountNotShownImePresentationNotDrawn, event.mCountNotShownImeUserNotSeen, event.mCountNotShownImeUserNotSeen, event.mDisplayPresentationType); event.mDisplayPresentationType, event.mAutofillServiceUid, event.mInlineSuggestionHostUid, event.mIsRequestTriggered); mEventInternal = Optional.empty(); mEventInternal = Optional.empty(); } } Loading @@ -222,6 +273,9 @@ public final class PresentationStatsEventLogger { int mCountNotShownImePresentationNotDrawn; int mCountNotShownImePresentationNotDrawn; int mCountNotShownImeUserNotSeen; int mCountNotShownImeUserNotSeen; int mDisplayPresentationType = AUTOFILL_PRESENTATION_EVENT_REPORTED__DISPLAY_PRESENTATION_TYPE__UNKNOWN_AUTOFILL_DISPLAY_PRESENTATION_TYPE; int mDisplayPresentationType = AUTOFILL_PRESENTATION_EVENT_REPORTED__DISPLAY_PRESENTATION_TYPE__UNKNOWN_AUTOFILL_DISPLAY_PRESENTATION_TYPE; int mAutofillServiceUid = -1; int mInlineSuggestionHostUid = -1; boolean mIsRequestTriggered; PresentationStatsEventInternal() {} PresentationStatsEventInternal() {} } } Loading services/autofill/java/com/android/server/autofill/Session.java +11 −1 Original line number Original line Diff line number Diff line Loading @@ -68,6 +68,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.IntentFilter; import android.content.IntentSender; import android.content.IntentSender; import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo; import android.content.pm.ServiceInfo; import android.graphics.Bitmap; import android.graphics.Bitmap; import android.graphics.Rect; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable; Loading @@ -79,6 +80,7 @@ import android.os.Handler; import android.os.IBinder; import android.os.IBinder; import android.os.IBinder.DeathRecipient; import android.os.IBinder.DeathRecipient; import android.os.Parcelable; import android.os.Parcelable; import android.os.Process; import android.os.RemoteCallback; import android.os.RemoteCallback; import android.os.RemoteException; import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemClock; Loading Loading @@ -3040,6 +3042,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState mSessionFlags.mFillDialogDisabled = true; mSessionFlags.mFillDialogDisabled = true; } } mPresentationStatsEventLogger.startNewEvent(); mPresentationStatsEventLogger.startNewEvent(); mPresentationStatsEventLogger.maybeSetAutofillServiceUid(getAutofillServiceUid()); requestNewFillResponseLocked(viewState, ViewState.STATE_STARTED_SESSION, flags); requestNewFillResponseLocked(viewState, ViewState.STATE_STARTED_SESSION, flags); break; break; case ACTION_VALUE_CHANGED: case ACTION_VALUE_CHANGED: Loading Loading @@ -3129,6 +3132,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } } mPresentationStatsEventLogger.startNewEvent(); mPresentationStatsEventLogger.startNewEvent(); mPresentationStatsEventLogger.maybeSetAutofillServiceUid(getAutofillServiceUid()); if (requestNewFillResponseOnViewEnteredIfNecessaryLocked(id, viewState, flags)) { if (requestNewFillResponseOnViewEnteredIfNecessaryLocked(id, viewState, flags)) { return; return; } } Loading Loading @@ -3373,7 +3377,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // shown, inflated, and filtered. // shown, inflated, and filtered. mPresentationStatsEventLogger.maybeSetCountShown( mPresentationStatsEventLogger.maybeSetCountShown( response.getDatasets(), mCurrentViewId); response.getDatasets(), mCurrentViewId); mPresentationStatsEventLogger.maybeSetDisplayPresentationType(UI_TYPE_INLINE); mPresentationStatsEventLogger.maybeSetInlinePresentationAndSuggestionHostUid( mContext, userId); return; return; } } } } Loading Loading @@ -4750,4 +4755,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return "UNKNOWN_SESSION_STATE_" + sessionState; return "UNKNOWN_SESSION_STATE_" + sessionState; } } } } private int getAutofillServiceUid() { ServiceInfo serviceInfo = mService.getServiceInfo(); return serviceInfo == null ? Process.INVALID_UID : serviceInfo.applicationInfo.uid; } } } Loading
services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java +57 −3 Original line number Original line Diff line number Diff line Loading @@ -41,7 +41,12 @@ import static com.android.server.autofill.Helper.sVerbose; import android.annotation.IntDef; import android.annotation.IntDef; import android.annotation.Nullable; import android.annotation.Nullable; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.provider.Settings; import android.service.autofill.Dataset; import android.service.autofill.Dataset; import android.text.TextUtils; import android.util.Slog; import android.util.Slog; import android.view.autofill.AutofillId; import android.view.autofill.AutofillId; import android.view.autofill.AutofillManager; import android.view.autofill.AutofillManager; Loading Loading @@ -72,6 +77,7 @@ public final class PresentationStatsEventLogger { }) }) @Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE) public @interface NotShownReason {} public @interface NotShownReason {} public static final int NOT_SHOWN_REASON_ANY_SHOWN = AUTOFILL_PRESENTATION_EVENT_REPORTED__PRESENTATION_EVENT_RESULT__ANY_SHOWN; public static final int NOT_SHOWN_REASON_ANY_SHOWN = AUTOFILL_PRESENTATION_EVENT_REPORTED__PRESENTATION_EVENT_RESULT__ANY_SHOWN; public static final int NOT_SHOWN_REASON_VIEW_FOCUS_CHANGED = AUTOFILL_PRESENTATION_EVENT_REPORTED__PRESENTATION_EVENT_RESULT__NONE_SHOWN_VIEW_FOCUS_CHANGED; public static final int NOT_SHOWN_REASON_VIEW_FOCUS_CHANGED = AUTOFILL_PRESENTATION_EVENT_REPORTED__PRESENTATION_EVENT_RESULT__NONE_SHOWN_VIEW_FOCUS_CHANGED; public static final int NOT_SHOWN_REASON_VIEW_CHANGED = AUTOFILL_PRESENTATION_EVENT_REPORTED__PRESENTATION_EVENT_RESULT__NONE_SHOWN_VIEW_CHANGED; public static final int NOT_SHOWN_REASON_VIEW_CHANGED = AUTOFILL_PRESENTATION_EVENT_REPORTED__PRESENTATION_EVENT_RESULT__NONE_SHOWN_VIEW_CHANGED; Loading Loading @@ -172,6 +178,45 @@ public final class PresentationStatsEventLogger { }); }); } } public void maybeSetInlinePresentationAndSuggestionHostUid(Context context, int userId) { mEventInternal.ifPresent(event -> { event.mDisplayPresentationType = UI_TYPE_INLINE; String imeString = Settings.Secure.getStringForUser(context.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD, userId); if (TextUtils.isEmpty(imeString)) { Slog.w(TAG, "No default IME found"); return; } ComponentName imeComponent = ComponentName.unflattenFromString(imeString); if (imeComponent == null) { Slog.w(TAG, "No default IME found"); return; } int imeUid; String packageName = imeComponent.getPackageName(); try { imeUid = context.getPackageManager().getApplicationInfoAsUser(packageName, PackageManager.ApplicationInfoFlags.of(0), userId).uid; } catch (PackageManager.NameNotFoundException e) { Slog.w(TAG, "Couldn't find packageName: " + packageName); return; } event.mInlineSuggestionHostUid = imeUid; }); } public void maybeSetAutofillServiceUid(int uid) { mEventInternal.ifPresent(event -> { event.mAutofillServiceUid = uid; }); } public void maybeSetIsNewRequest(boolean isRequestTriggered) { mEventInternal.ifPresent(event -> { event.mIsRequestTriggered = isRequestTriggered; }); } public void logAndEndEvent() { public void logAndEndEvent() { if (!mEventInternal.isPresent()) { if (!mEventInternal.isPresent()) { Slog.w(TAG, "Shouldn't be logging AutofillPresentationEventReported again for same " Slog.w(TAG, "Shouldn't be logging AutofillPresentationEventReported again for same " Loading @@ -190,7 +235,10 @@ public final class PresentationStatsEventLogger { + " mCountNotShownImePresentationNotDrawn=" + " mCountNotShownImePresentationNotDrawn=" + event.mCountNotShownImePresentationNotDrawn + event.mCountNotShownImePresentationNotDrawn + " mCountNotShownImeUserNotSeen=" + event.mCountNotShownImeUserNotSeen + " mCountNotShownImeUserNotSeen=" + event.mCountNotShownImeUserNotSeen + " mDisplayPresentationType=" + event.mDisplayPresentationType); + " mDisplayPresentationType=" + event.mDisplayPresentationType + " mAutofillServiceUid=" + event.mAutofillServiceUid + " mInlineSuggestionHostUid=" + event.mInlineSuggestionHostUid + " mIsRequestTriggered=" + event.mIsRequestTriggered); } } // TODO(b/234185326): Distinguish empty responses from other no presentation reasons. // TODO(b/234185326): Distinguish empty responses from other no presentation reasons. Loading @@ -208,7 +256,10 @@ public final class PresentationStatsEventLogger { event.mCountFilteredUserTyping, event.mCountFilteredUserTyping, event.mCountNotShownImePresentationNotDrawn, event.mCountNotShownImePresentationNotDrawn, event.mCountNotShownImeUserNotSeen, event.mCountNotShownImeUserNotSeen, event.mDisplayPresentationType); event.mDisplayPresentationType, event.mAutofillServiceUid, event.mInlineSuggestionHostUid, event.mIsRequestTriggered); mEventInternal = Optional.empty(); mEventInternal = Optional.empty(); } } Loading @@ -222,6 +273,9 @@ public final class PresentationStatsEventLogger { int mCountNotShownImePresentationNotDrawn; int mCountNotShownImePresentationNotDrawn; int mCountNotShownImeUserNotSeen; int mCountNotShownImeUserNotSeen; int mDisplayPresentationType = AUTOFILL_PRESENTATION_EVENT_REPORTED__DISPLAY_PRESENTATION_TYPE__UNKNOWN_AUTOFILL_DISPLAY_PRESENTATION_TYPE; int mDisplayPresentationType = AUTOFILL_PRESENTATION_EVENT_REPORTED__DISPLAY_PRESENTATION_TYPE__UNKNOWN_AUTOFILL_DISPLAY_PRESENTATION_TYPE; int mAutofillServiceUid = -1; int mInlineSuggestionHostUid = -1; boolean mIsRequestTriggered; PresentationStatsEventInternal() {} PresentationStatsEventInternal() {} } } Loading
services/autofill/java/com/android/server/autofill/Session.java +11 −1 Original line number Original line Diff line number Diff line Loading @@ -68,6 +68,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.IntentFilter; import android.content.IntentSender; import android.content.IntentSender; import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo; import android.content.pm.ServiceInfo; import android.graphics.Bitmap; import android.graphics.Bitmap; import android.graphics.Rect; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable; Loading @@ -79,6 +80,7 @@ import android.os.Handler; import android.os.IBinder; import android.os.IBinder; import android.os.IBinder.DeathRecipient; import android.os.IBinder.DeathRecipient; import android.os.Parcelable; import android.os.Parcelable; import android.os.Process; import android.os.RemoteCallback; import android.os.RemoteCallback; import android.os.RemoteException; import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemClock; Loading Loading @@ -3040,6 +3042,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState mSessionFlags.mFillDialogDisabled = true; mSessionFlags.mFillDialogDisabled = true; } } mPresentationStatsEventLogger.startNewEvent(); mPresentationStatsEventLogger.startNewEvent(); mPresentationStatsEventLogger.maybeSetAutofillServiceUid(getAutofillServiceUid()); requestNewFillResponseLocked(viewState, ViewState.STATE_STARTED_SESSION, flags); requestNewFillResponseLocked(viewState, ViewState.STATE_STARTED_SESSION, flags); break; break; case ACTION_VALUE_CHANGED: case ACTION_VALUE_CHANGED: Loading Loading @@ -3129,6 +3132,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } } mPresentationStatsEventLogger.startNewEvent(); mPresentationStatsEventLogger.startNewEvent(); mPresentationStatsEventLogger.maybeSetAutofillServiceUid(getAutofillServiceUid()); if (requestNewFillResponseOnViewEnteredIfNecessaryLocked(id, viewState, flags)) { if (requestNewFillResponseOnViewEnteredIfNecessaryLocked(id, viewState, flags)) { return; return; } } Loading Loading @@ -3373,7 +3377,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // shown, inflated, and filtered. // shown, inflated, and filtered. mPresentationStatsEventLogger.maybeSetCountShown( mPresentationStatsEventLogger.maybeSetCountShown( response.getDatasets(), mCurrentViewId); response.getDatasets(), mCurrentViewId); mPresentationStatsEventLogger.maybeSetDisplayPresentationType(UI_TYPE_INLINE); mPresentationStatsEventLogger.maybeSetInlinePresentationAndSuggestionHostUid( mContext, userId); return; return; } } } } Loading Loading @@ -4750,4 +4755,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return "UNKNOWN_SESSION_STATE_" + sessionState; return "UNKNOWN_SESSION_STATE_" + sessionState; } } } } private int getAutofillServiceUid() { ServiceInfo serviceInfo = mService.getServiceInfo(); return serviceInfo == null ? Process.INVALID_UID : serviceInfo.applicationInfo.uid; } } }