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

Commit 4f2095f8 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: I0b88a7629082d1eab292452f2fdda185e6170786
parents d596687a 5568049c
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.Handler;
import android.view.accessibility.AccessibilityManager;

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

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

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

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

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

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

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

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

    private void logUiEvent(NotificationAppOpsEvent event) {
        if (mSbn != null) {
            mUiEventLogger.logWithInstanceId(event,
                    mSbn.getUid(), mSbn.getPackageName(), mSbn.getInstanceId());
        }
    }
}
+41 −0
Original line number 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 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 Diff line number Diff line
@@ -41,6 +41,7 @@ import android.view.accessibility.AccessibilityManager;

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

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

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

        AppOpsInfo.OnSettingsClickListener onSettingsClick =
                (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);
                    guts.resetFalsingCheck();
                    startAppOpsSettingsActivity(pkg, uid, ops, row);
        };
        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(),
                onSettingsClick,
                onAppSettingsClick,
                mUiEventLogger,
                mDeviceProvisionedController.isDeviceProvisioned(),
                row.getIsNonblockable(),
                mHighPriorityProvider.isHighPriority(row.getEntry()));
Loading