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

Commit 9bced7d7 authored by Muhammad Qureshi's avatar Muhammad Qureshi
Browse files

Add sysui module for logging SystemUI atoms.

As part of statsd becoming a Mainline module in R, autogenerated
StatsLog.write() calls are going away and replaced by *StatsLog.java
that is autogenerated for each module.
This CL adds autogenerated SysUiStatsLog to SystemUI and replaces usages
of StatsLog with SysUiStatsLog.
Since the write calls in SysUiStatsLog are public, StatsLogCompat is no
longer needed.

Bug: 145952197
Test: m
Test: fastboot flashall
Test: adb shell cmd stats print-logs && adb logcat "*:S statsd:*"
Change-Id: I192ff29d21cedbe715bb02ffa05921b4912af371
parent df747d15
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ message Atom {
        ExcessiveCpuUsageReported excessive_cpu_usage_reported = 16;
        CachedKillReported cached_kill_reported = 17;
        ProcessMemoryStatReported process_memory_stat_reported = 18;
        LauncherUIChanged launcher_event = 19;
        LauncherUIChanged launcher_event = 19 [(module) = "sysui"];
        BatterySaverModeStateChanged battery_saver_mode_state_changed = 20;
        DeviceIdleModeStateChanged device_idle_mode_state_changed = 21;
        DeviceIdlingModeStateChanged device_idling_mode_state_changed = 22;
@@ -138,9 +138,9 @@ message Atom {
        OverlayStateChanged overlay_state_changed = 59;
        ForegroundServiceStateChanged foreground_service_state_changed = 60;
        CallStateChanged call_state_changed = 61;
        KeyguardStateChanged keyguard_state_changed = 62;
        KeyguardBouncerStateChanged keyguard_bouncer_state_changed = 63;
        KeyguardBouncerPasswordEntered keyguard_bouncer_password_entered = 64;
        KeyguardStateChanged keyguard_state_changed = 62 [(module) = "sysui"];
        KeyguardBouncerStateChanged keyguard_bouncer_state_changed = 63 [(module) = "sysui"];
        KeyguardBouncerPasswordEntered keyguard_bouncer_password_entered = 64 [(module) = "sysui"];
        AppDied app_died = 65;
        ResourceConfigurationChanged resource_configuration_changed = 66;
        BluetoothEnabledStateChanged bluetooth_enabled_state_changed = 67;
@@ -231,7 +231,7 @@ message Atom {
        UsbContaminantReported usb_contaminant_reported = 146;
        WatchdogRollbackOccurred watchdog_rollback_occurred = 147;
        BiometricSystemHealthIssueDetected biometric_system_health_issue_detected = 148;
        BubbleUIChanged bubble_ui_changed = 149;
        BubbleUIChanged bubble_ui_changed = 149 [(module) = "sysui"];
        ScheduledJobConstraintChanged scheduled_job_constraint_changed = 150;
        BluetoothActiveDeviceChanged bluetooth_active_device_changed = 151;
        BluetoothA2dpPlaybackStateChanged bluetooth_a2dp_playback_state_changed = 152;
@@ -262,7 +262,7 @@ message Atom {
        AssistGestureProgressReported assist_gesture_progress_reported = 176;
        TouchGestureClassified touch_gesture_classified = 177;
        HiddenApiUsed hidden_api_used = 178 [(allow_from_any_uid) = true];
        StyleUIChanged style_ui_changed = 179 [(module) = "style"];
        StyleUIChanged style_ui_changed = 179 [(module) = "sysui"];
        PrivacyIndicatorsInteracted privacy_indicators_interacted =
            180 [(module) = "permissioncontroller"];
        AppInstallOnExternalStorageReported app_install_on_external_storage_reported = 181;
@@ -317,7 +317,7 @@ message Atom {
        ConversationActionsEvent conversation_actions_event = 221  [(module) = "textclassifier"];
        LanguageDetectionEvent language_detection_event = 222  [(module) = "textclassifier"];
        ExclusionRectStateChanged exclusion_rect_state_changed = 223;
        BackGesture back_gesture_reported_reported = 224;
        BackGesture back_gesture_reported_reported = 224 [(module) = "sysui"];
        UpdateEngineUpdateAttemptReported update_engine_update_attempt_reported = 225;
        UpdateEngineSuccessfulUpdateReported update_engine_successful_update_reported = 226;
        CameraActionEvent camera_action_event = 227;
+17 −2
Original line number Diff line number Diff line
@@ -12,8 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.

android_library {
genrule {
    name: "statslog-SystemUI-java-gen",
    tools: ["stats-log-api-gen"],
    cmd: "$(location stats-log-api-gen) --java $(out) --module sysui --javaPackage com.android.systemui.shared.system --javaClass SysUiStatsLog",
    out: ["com/android/systemui/shared/system/SysUiStatsLog.java"],
}

java_library {
    name: "SystemUI-statsd",

    srcs: [
        ":statslog-SystemUI-java-gen",
    ],
}

android_library {
    name: "SystemUISharedLib",
    srcs: [
        "src/**/*.java",
@@ -21,7 +35,8 @@ android_library {
    ],

    static_libs: [
        "PluginCoreLib"
        "PluginCoreLib",
        "SystemUI-statsd",
    ],

    // Enforce that the library is built against java 7 so that there are
+0 −51
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.shared.system;

import android.util.StatsLog;

/**
 * Wrapper class to make StatsLog hidden API accessible.
 */
public class StatsLogCompat {

    /**
     * StatsLog.write(StatsLog.LAUNCHER_EVENT, int action, int src_state, int dst_state,
     *                byte[] extension, boolean is_swipe_up_enabled);
     */
    public static void write(int action, int srcState, int dstState, byte [] extension,
            boolean swipeUpEnabled) {
        StatsLog.write(19, action, srcState, dstState, extension,
                swipeUpEnabled);
    }

    /**
     *  StatsLog.write(StatsLog.STYLE_EVENT, action, colorPackageHash,
     *           fontPackageHash, shapePackageHash, clockPackageHash,
     *           launcherGrid, wallpaperCategoryHash, wallpaperIdHash,
     *           colorPreference, locationPreference);
     */
    public static void write(int action, int colorPackageHash,
            int fontPackageHash, int shapePackageHash, int clockPackageHash,
            int launcherGrid, int wallpaperCategoryHash, int wallpaperIdHash,
            int colorPreference, int locationPreference) {
        StatsLog.write(179, action, colorPackageHash,
                fontPackageHash, shapePackageHash, clockPackageHash,
                launcherGrid, wallpaperCategoryHash, wallpaperIdHash,
                colorPreference, locationPreference);
    }
}
+5 −5
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.os.UserHandle;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Slog;
import android.util.StatsLog;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -50,6 +49,7 @@ import com.android.settingslib.utils.ThreadUtils;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.shared.system.SysUiStatsLog;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.InjectionInflationController;

@@ -615,8 +615,8 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe

        public void reportUnlockAttempt(int userId, boolean success, int timeoutMs) {
            if (success) {
                StatsLog.write(StatsLog.KEYGUARD_BOUNCER_PASSWORD_ENTERED,
                    StatsLog.KEYGUARD_BOUNCER_PASSWORD_ENTERED__RESULT__SUCCESS);
                SysUiStatsLog.write(SysUiStatsLog.KEYGUARD_BOUNCER_PASSWORD_ENTERED,
                        SysUiStatsLog.KEYGUARD_BOUNCER_PASSWORD_ENTERED__RESULT__SUCCESS);
                mLockPatternUtils.reportSuccessfulPasswordAttempt(userId);
                // Force a garbage collection in an attempt to erase any lockscreen password left in
                // memory. Do it asynchronously with a 5-sec delay to avoid making the keyguard
@@ -628,8 +628,8 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
                    Runtime.getRuntime().gc();
                });
            } else {
                StatsLog.write(StatsLog.KEYGUARD_BOUNCER_PASSWORD_ENTERED,
                    StatsLog.KEYGUARD_BOUNCER_PASSWORD_ENTERED__RESULT__FAILURE);
                SysUiStatsLog.write(SysUiStatsLog.KEYGUARD_BOUNCER_PASSWORD_ENTERED,
                        SysUiStatsLog.KEYGUARD_BOUNCER_PASSWORD_ENTERED__RESULT__FAILURE);
                KeyguardSecurityContainer.this.reportFailedUnlockAttempt(userId, timeoutMs);
            }
            mMetricsLogger.write(new LogMaker(MetricsEvent.BOUNCER)
+3 −3
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ import android.os.RemoteException;
import android.service.notification.StatusBarNotification;
import android.util.AttributeSet;
import android.util.Log;
import android.util.StatsLog;
import android.view.View;
import android.view.WindowInsets;
import android.view.WindowManager;
@@ -52,6 +51,7 @@ import com.android.internal.policy.ScreenDecorationsUtils;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.recents.TriangleShape;
import com.android.systemui.shared.system.SysUiStatsLog;
import com.android.systemui.statusbar.AlphaOptimizedButton;

/**
@@ -467,7 +467,7 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
            mStackView.collapseStack(() -> {
                mContext.startActivityAsUser(intent, mBubble.getEntry().getSbn().getUser());
                logBubbleClickEvent(mBubble,
                        StatsLog.BUBBLE_UICHANGED__ACTION__HEADER_GO_TO_SETTINGS);
                        SysUiStatsLog.BUBBLE_UICHANGED__ACTION__HEADER_GO_TO_SETTINGS);
            });
        }
    }
@@ -564,7 +564,7 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
     */
    private void logBubbleClickEvent(Bubble bubble, int action) {
        StatusBarNotification notification = bubble.getEntry().getSbn();
        StatsLog.write(StatsLog.BUBBLE_UI_CHANGED,
        SysUiStatsLog.write(SysUiStatsLog.BUBBLE_UI_CHANGED,
                notification.getPackageName(),
                notification.getNotification().getChannelId(),
                notification.getId(),
Loading