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

Commit 90be90c5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Statsd logging: notification controls." into rvc-dev am: 5568049c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11947592

Change-Id: I242bcc385c41f71c2a8c455a0c31f11a3f66f968
parents 68a2d6f6 5568049c
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.Handler;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityManager;


import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.UiEventLogger;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Background;
@@ -116,7 +117,8 @@ public interface NotificationsModule {
            ChannelEditorDialogController channelEditorDialogController,
            ChannelEditorDialogController channelEditorDialogController,
            CurrentUserContextTracker contextTracker,
            CurrentUserContextTracker contextTracker,
            Provider<PriorityOnboardingDialogController.Builder> builderProvider,
            Provider<PriorityOnboardingDialogController.Builder> builderProvider,
            BubbleController bubbleController) {
            BubbleController bubbleController,
            UiEventLogger uiEventLogger) {
        return new NotificationGutsManager(
        return new NotificationGutsManager(
                context,
                context,
                visualStabilityManager,
                visualStabilityManager,
@@ -131,7 +133,8 @@ public interface NotificationsModule {
                channelEditorDialogController,
                channelEditorDialogController,
                contextTracker,
                contextTracker,
                builderProvider,
                builderProvider,
                bubbleController);
                bubbleController,
                uiEventLogger);
    }
    }


    /** Provides an instance of {@link VisualStabilityManager} */
    /** Provides an instance of {@link VisualStabilityManager} */
+13 −0
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.TextView;


import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.UiEventLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.systemui.R;
import com.android.systemui.R;


@@ -50,6 +51,7 @@ public class AppOpsInfo extends LinearLayout implements NotificationGuts.GutsCon
    private MetricsLogger mMetricsLogger;
    private MetricsLogger mMetricsLogger;
    private OnSettingsClickListener mOnSettingsClickListener;
    private OnSettingsClickListener mOnSettingsClickListener;
    private NotificationGuts mGutsContainer;
    private NotificationGuts mGutsContainer;
    private UiEventLogger mUiEventLogger;


    private OnClickListener mOnOk = v -> {
    private OnClickListener mOnOk = v -> {
        mGutsContainer.closeControls(v, false);
        mGutsContainer.closeControls(v, false);
@@ -66,6 +68,7 @@ public class AppOpsInfo extends LinearLayout implements NotificationGuts.GutsCon
    public void bindGuts(final PackageManager pm,
    public void bindGuts(final PackageManager pm,
            final OnSettingsClickListener onSettingsClick,
            final OnSettingsClickListener onSettingsClick,
            final StatusBarNotification sbn,
            final StatusBarNotification sbn,
            final UiEventLogger uiEventLogger,
            ArraySet<Integer> activeOps) {
            ArraySet<Integer> activeOps) {
        mPkg = sbn.getPackageName();
        mPkg = sbn.getPackageName();
        mSbn = sbn;
        mSbn = sbn;
@@ -73,11 +76,13 @@ public class AppOpsInfo extends LinearLayout implements NotificationGuts.GutsCon
        mAppName = mPkg;
        mAppName = mPkg;
        mOnSettingsClickListener = onSettingsClick;
        mOnSettingsClickListener = onSettingsClick;
        mAppOps = activeOps;
        mAppOps = activeOps;
        mUiEventLogger = uiEventLogger;


        bindHeader();
        bindHeader();
        bindPrompt();
        bindPrompt();
        bindButtons();
        bindButtons();


        logUiEvent(NotificationAppOpsEvent.NOTIFICATION_APP_OPS_OPEN);
        mMetricsLogger = new MetricsLogger();
        mMetricsLogger = new MetricsLogger();
        mMetricsLogger.visibility(MetricsEvent.APP_OPS_GUTS, true);
        mMetricsLogger.visibility(MetricsEvent.APP_OPS_GUTS, true);
    }
    }
@@ -188,6 +193,7 @@ public class AppOpsInfo extends LinearLayout implements NotificationGuts.GutsCon


    @Override
    @Override
    public boolean handleCloseControls(boolean save, boolean force) {
    public boolean handleCloseControls(boolean save, boolean force) {
        logUiEvent(NotificationAppOpsEvent.NOTIFICATION_APP_OPS_CLOSE);
        if (mMetricsLogger != null) {
        if (mMetricsLogger != null) {
            mMetricsLogger.visibility(MetricsEvent.APP_OPS_GUTS, false);
            mMetricsLogger.visibility(MetricsEvent.APP_OPS_GUTS, false);
        }
        }
@@ -198,4 +204,11 @@ public class AppOpsInfo extends LinearLayout implements NotificationGuts.GutsCon
    public int getActualHeight() {
    public int getActualHeight() {
        return getHeight();
        return getHeight();
    }
    }

    private void logUiEvent(NotificationAppOpsEvent event) {
        if (mSbn != null) {
            mUiEventLogger.logWithInstanceId(event,
                    mSbn.getUid(), mSbn.getPackageName(), mSbn.getInstanceId());
        }
    }
}
}
+41 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2020 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 com.android.systemui.statusbar.notification.row;

import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;

enum NotificationAppOpsEvent implements UiEventLogger.UiEventEnum {
    @UiEvent(doc = "User opened app ops controls on a notification (for active "
            + "privacy-sensitive permissions usage)")
    NOTIFICATION_APP_OPS_OPEN(597),

    @UiEvent(doc = "User closed app ops controls")
    NOTIFICATION_APP_OPS_CLOSE(598),

    @UiEvent(doc = "User clicked through to settings in app ops controls")
    NOTIFICATION_APP_OPS_SETTINGS_CLICK(599);

    private final int mId;
    NotificationAppOpsEvent(int id) {
        mId = id;
    }
    @Override public int getId() {
        return mId;
    }
}
+40 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2020 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 com.android.systemui.statusbar.notification.row;

import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;

enum NotificationControlsEvent implements UiEventLogger.UiEventEnum {
    @UiEvent(doc = "The user opened the notification inline controls.")
    NOTIFICATION_CONTROLS_OPEN(594),

    @UiEvent(doc = "In notification inline controls, the user saved a notification channel "
            + "importance change.")
    NOTIFICATION_CONTROLS_SAVE_IMPORTANCE(595),

    @UiEvent(doc = "The user closed the notification inline controls.")
    NOTIFICATION_CONTROLS_CLOSE(596);

    private final int mId;
    NotificationControlsEvent(int id) {
        mId = id;
    }
    @Override public int getId() {
        return mId;
    }
}
+14 −5
Original line number Original line Diff line number Diff line
@@ -41,6 +41,7 @@ import android.view.accessibility.AccessibilityManager;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.UiEventLogger;
import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settingslib.notification.ConversationIconFactory;
import com.android.settingslib.notification.ConversationIconFactory;
import com.android.systemui.Dependency;
import com.android.systemui.Dependency;
@@ -121,6 +122,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
    private final ShortcutManager mShortcutManager;
    private final ShortcutManager mShortcutManager;
    private final CurrentUserContextTracker mContextTracker;
    private final CurrentUserContextTracker mContextTracker;
    private final Provider<PriorityOnboardingDialogController.Builder> mBuilderProvider;
    private final Provider<PriorityOnboardingDialogController.Builder> mBuilderProvider;
    private final UiEventLogger mUiEventLogger;


    /**
    /**
     * Injected constructor. See {@link NotificationsModule}.
     * Injected constructor. See {@link NotificationsModule}.
@@ -135,7 +137,8 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
            ChannelEditorDialogController channelEditorDialogController,
            ChannelEditorDialogController channelEditorDialogController,
            CurrentUserContextTracker contextTracker,
            CurrentUserContextTracker contextTracker,
            Provider<PriorityOnboardingDialogController.Builder> builderProvider,
            Provider<PriorityOnboardingDialogController.Builder> builderProvider,
            BubbleController bubbleController) {
            BubbleController bubbleController,
            UiEventLogger uiEventLogger) {
        mContext = context;
        mContext = context;
        mVisualStabilityManager = visualStabilityManager;
        mVisualStabilityManager = visualStabilityManager;
        mStatusBarLazy = statusBarLazy;
        mStatusBarLazy = statusBarLazy;
@@ -150,6 +153,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
        mBuilderProvider = builderProvider;
        mBuilderProvider = builderProvider;
        mChannelEditorDialogController = channelEditorDialogController;
        mChannelEditorDialogController = channelEditorDialogController;
        mBubbleController = bubbleController;
        mBubbleController = bubbleController;
        mUiEventLogger = uiEventLogger;
    }
    }


    public void setUpWithPresenter(NotificationPresenter presenter,
    public void setUpWithPresenter(NotificationPresenter presenter,
@@ -315,12 +319,16 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx


        AppOpsInfo.OnSettingsClickListener onSettingsClick =
        AppOpsInfo.OnSettingsClickListener onSettingsClick =
                (View v, String pkg, int uid, ArraySet<Integer> ops) -> {
                (View v, String pkg, int uid, ArraySet<Integer> ops) -> {
                    mUiEventLogger.logWithInstanceId(
                            NotificationAppOpsEvent.NOTIFICATION_APP_OPS_SETTINGS_CLICK,
                            sbn.getUid(), sbn.getPackageName(), sbn.getInstanceId());
                    mMetricsLogger.action(MetricsProto.MetricsEvent.ACTION_OPS_GUTS_SETTINGS);
                    mMetricsLogger.action(MetricsProto.MetricsEvent.ACTION_OPS_GUTS_SETTINGS);
                    guts.resetFalsingCheck();
                    guts.resetFalsingCheck();
                    startAppOpsSettingsActivity(pkg, uid, ops, row);
                    startAppOpsSettingsActivity(pkg, uid, ops, row);
        };
        };
        if (!row.getEntry().mActiveAppOps.isEmpty()) {
        if (!row.getEntry().mActiveAppOps.isEmpty()) {
            appOpsInfoView.bindGuts(pmUser, onSettingsClick, sbn, row.getEntry().mActiveAppOps);
            appOpsInfoView.bindGuts(pmUser, onSettingsClick, sbn, mUiEventLogger,
                    row.getEntry().mActiveAppOps);
        }
        }
    }
    }


@@ -370,6 +378,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
                row.getEntry(),
                row.getEntry(),
                onSettingsClick,
                onSettingsClick,
                onAppSettingsClick,
                onAppSettingsClick,
                mUiEventLogger,
                mDeviceProvisionedController.isDeviceProvisioned(),
                mDeviceProvisionedController.isDeviceProvisioned(),
                row.getIsNonblockable(),
                row.getIsNonblockable(),
                mHighPriorityProvider.isHighPriority(row.getEntry()));
                mHighPriorityProvider.isHighPriority(row.getEntry()));
Loading