1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.internal.os.logging; 18 19 import android.view.WindowManager.LayoutParams; 20 21 import com.android.internal.util.FrameworkStatsLog; 22 23 /** 24 * Used to wrap different logging calls in one, so that client side code base is clean and more 25 * readable. 26 */ 27 public class MetricsLoggerWrapper { 28 logAppOverlayEnter(int uid, String packageName, boolean changed, int type, boolean usingAlertWindow)29 public static void logAppOverlayEnter(int uid, String packageName, boolean changed, int type, boolean usingAlertWindow) { 30 if (changed) { 31 if (type != LayoutParams.TYPE_APPLICATION_OVERLAY) { 32 FrameworkStatsLog.write(FrameworkStatsLog.OVERLAY_STATE_CHANGED, uid, packageName, 33 true, FrameworkStatsLog.OVERLAY_STATE_CHANGED__STATE__ENTERED); 34 } else if (!usingAlertWindow){ 35 FrameworkStatsLog.write(FrameworkStatsLog.OVERLAY_STATE_CHANGED, uid, packageName, 36 false, FrameworkStatsLog.OVERLAY_STATE_CHANGED__STATE__ENTERED); 37 } 38 } 39 } 40 logAppOverlayExit(int uid, String packageName, boolean changed, int type, boolean usingAlertWindow)41 public static void logAppOverlayExit(int uid, String packageName, boolean changed, int type, boolean usingAlertWindow) { 42 if (changed) { 43 if (type != LayoutParams.TYPE_APPLICATION_OVERLAY) { 44 FrameworkStatsLog.write(FrameworkStatsLog.OVERLAY_STATE_CHANGED, uid, packageName, 45 true, FrameworkStatsLog.OVERLAY_STATE_CHANGED__STATE__EXITED); 46 } else if (!usingAlertWindow){ 47 FrameworkStatsLog.write(FrameworkStatsLog.OVERLAY_STATE_CHANGED, uid, packageName, 48 false, FrameworkStatsLog.OVERLAY_STATE_CHANGED__STATE__EXITED); 49 } 50 } 51 } 52 } 53