Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 400c9c10 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Add app start source info from notification

This provides the time from action up time in SystemUI
to the time system received the activity intent.

Bug: 166614700
Test: Enable statsd log: "adb shell cmd stats print-logs"
      Click notification to launch activity and check logcat.
      adb logcat | grep statsd | grep "(48)"
      The line should contain 0x100000->2[I].
Change-Id: Icd43f38ebc8201156844adcc0cba922212185ea6
parent 2bfca138
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
    private float mAppearAnimationTranslation;
    private int mNormalColor;
    private boolean mIsBelowSpeedBump;
    private long mLastActionUpTime;

    private float mNormalBackgroundVisibilityAmount;
    private float mDimmedBackgroundFadeInAmount = -1;
@@ -225,6 +226,22 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        return super.onInterceptTouchEvent(ev);
    }

    /** Sets the last action up time this view was touched. */
    void setLastActionUpTime(long eventTime) {
        mLastActionUpTime = eventTime;
    }

    /**
     * Returns the last action up time. The last time will also be cleared because the source of
     * action is not only from touch event. That prevents the caller from utilizing the time with
     * unrelated event. The time can be 0 if the event is unavailable.
     */
    public long getAndResetLastActionUpTime() {
        long lastActionUpTime = mLastActionUpTime;
        mLastActionUpTime = 0;
        return lastActionUpTime;
    }

    protected boolean disallowSingleClick(MotionEvent ev) {
        return false;
    }
+4 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.statusbar.notification.row;

import android.os.SystemClock;
import android.view.MotionEvent;
import android.view.View;
import android.view.accessibility.AccessibilityManager;
@@ -92,6 +93,9 @@ public class ActivatableNotificationViewController {
                mBlockNextTouch = false;
                return true;
            }
            if (ev.getAction() == MotionEvent.ACTION_UP) {
                mView.setLastActionUpTime(SystemClock.uptimeMillis());
            }
            if (mNeedsDimming && !mAccessibilityManager.isTouchExplorationEnabled()
                    && mView.isInteractive()) {
                if (mNeedsDimming && !mView.isDimmed()) {
+14 −1
Original line number Diff line number Diff line
@@ -4284,6 +4284,19 @@ public class StatusBar extends SystemUI implements DemoMode,
    }

    public static Bundle getActivityOptions(@Nullable RemoteAnimationAdapter animationAdapter) {
        return getDefaultActivityOptions(animationAdapter).toBundle();
    }

    public static Bundle getActivityOptions(@Nullable RemoteAnimationAdapter animationAdapter,
            boolean isKeyguardShowing, long eventTime) {
        ActivityOptions options = getDefaultActivityOptions(animationAdapter);
        options.setSourceInfo(isKeyguardShowing ? ActivityOptions.SourceInfo.TYPE_LOCKSCREEN
                : ActivityOptions.SourceInfo.TYPE_NOTIFICATION, eventTime);
        return options.toBundle();
    }

    public static ActivityOptions getDefaultActivityOptions(
            @Nullable RemoteAnimationAdapter animationAdapter) {
        ActivityOptions options;
        if (animationAdapter != null) {
            options = ActivityOptions.makeRemoteAnimation(animationAdapter);
@@ -4293,7 +4306,7 @@ public class StatusBar extends SystemUI implements DemoMode,
        // Anything launched from the notification shade should always go into the secondary
        // split-screen windowing mode.
        options.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY);
        return options.toBundle();
        return options;
    }

    void visibilityChanged(boolean visible) {
+6 −3
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.app.TaskStackBuilder;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
@@ -40,7 +41,6 @@ import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
import android.util.EventLog;
import android.view.RemoteAnimationAdapter;
import android.view.View;

import com.android.internal.logging.MetricsLogger;
import com.android.internal.statusbar.NotificationVisibility;
@@ -402,7 +402,7 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit
            PendingIntent intent,
            Intent fillInIntent,
            NotificationEntry entry,
            View row,
            ExpandableNotificationRow row,
            boolean wasOccluded,
            boolean isActivityIntent) {
        RemoteAnimationAdapter adapter = mActivityLaunchAnimator.getLaunchAnimation(row,
@@ -414,8 +414,11 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit
                        .registerRemoteAnimationForNextActivityStart(
                                intent.getCreatorPackage(), adapter);
            }
            long eventTime = row.getAndResetLastActionUpTime();
            Bundle options = eventTime > 0 ? getActivityOptions(adapter,
                    mKeyguardStateController.isShowing(), eventTime) : getActivityOptions(adapter);
            int launchResult = intent.sendAndReturnResult(mContext, 0, fillInIntent, null,
                    null, null, getActivityOptions(adapter));
                    null, null, options);
            mMainThreadHandler.post(() -> {
                mActivityLaunchAnimator.setLaunchResult(launchResult, isActivityIntent);
            });