Jackeagle | 0cc335a | 2018-10-19 00:06:49 -0400 | [diff] [blame] | 1 | From 291679ee3ce0959101b2b905208e0275d3d463a9 Mon Sep 17 00:00:00 2001 |
| 2 | From: Jackeagle <jackeagle102@gmail.com> |
| 3 | Date: Sat, 20 Oct 2018 12:13:12 -0400 |
| 4 | Subject: [PATCH 26/26] Revert "Revert "CameraServiceProxy: Add client API |
| 5 | level to log metrics"" |
| 6 | |
| 7 | This reverts commit 7c97b7bb8b1b7f87974fcd13c1ae267288ca3e79. |
| 8 | --- |
| 9 | proto/src/metrics_constants.proto | 5 +++++ |
| 10 | .../com/android/server/camera/CameraServiceProxy.java | 16 ++++++++++------ |
| 11 | 2 files changed, 15 insertions(+), 6 deletions(-) |
| 12 | |
| 13 | diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto |
| 14 | index 62f9377..e568b12 100644 |
| 15 | --- a/proto/src/metrics_constants.proto |
| 16 | +++ b/proto/src/metrics_constants.proto |
| 17 | @@ -5447,6 +5447,11 @@ message MetricsEvent { |
| 18 | // OS: P |
| 19 | PACKAGE_OPTIMIZATION_COMPILATION_REASON = 1321; |
| 20 | |
| 21 | + // FIELD: The camera API level used. |
| 22 | + // CATEGORY: CAMERA |
| 23 | + // OS: P |
| 24 | + FIELD_CAMERA_API_LEVEL = 1322; |
| 25 | + |
| 26 | // OPEN: Settings > Battery > Battery tip > Battery tip Dialog |
| 27 | // CATEGORY: SETTINGS |
| 28 | // OS: P |
| 29 | diff --git a/services/core/java/com/android/server/camera/CameraServiceProxy.java b/services/core/java/com/android/server/camera/CameraServiceProxy.java |
| 30 | index 45d2375..0ee55ed 100644 |
| 31 | --- a/services/core/java/com/android/server/camera/CameraServiceProxy.java |
| 32 | +++ b/services/core/java/com/android/server/camera/CameraServiceProxy.java |
| 33 | @@ -103,13 +103,15 @@ public class CameraServiceProxy extends SystemService |
| 34 | private static class CameraUsageEvent { |
| 35 | public final int mCameraFacing; |
| 36 | public final String mClientName; |
| 37 | + public final int mAPILevel; |
| 38 | |
| 39 | private boolean mCompleted; |
| 40 | private long mDurationOrStartTimeMs; // Either start time, or duration once completed |
| 41 | |
| 42 | - public CameraUsageEvent(int facing, String clientName) { |
| 43 | + public CameraUsageEvent(int facing, String clientName, int apiLevel) { |
| 44 | mCameraFacing = facing; |
| 45 | mClientName = clientName; |
| 46 | + mAPILevel = apiLevel; |
| 47 | mDurationOrStartTimeMs = SystemClock.elapsedRealtime(); |
| 48 | mCompleted = false; |
| 49 | } |
| 50 | @@ -173,7 +175,7 @@ public class CameraServiceProxy extends SystemService |
| 51 | |
| 52 | @Override |
| 53 | public void notifyCameraState(String cameraId, int newCameraState, int facing, |
| 54 | - String clientName) { |
| 55 | + String clientName, int apiLevel) { |
| 56 | if (Binder.getCallingUid() != Process.CAMERASERVER_UID) { |
| 57 | Slog.e(TAG, "Calling UID: " + Binder.getCallingUid() + " doesn't match expected " + |
| 58 | " camera service UID!"); |
| 59 | @@ -182,9 +184,9 @@ public class CameraServiceProxy extends SystemService |
| 60 | String state = cameraStateToString(newCameraState); |
| 61 | String facingStr = cameraFacingToString(facing); |
| 62 | if (DEBUG) Slog.v(TAG, "Camera " + cameraId + " facing " + facingStr + " state now " + |
| 63 | - state + " for client " + clientName); |
| 64 | + state + " for client " + clientName + " API Level " + apiLevel); |
| 65 | |
| 66 | - updateActivityCount(cameraId, newCameraState, facing, clientName); |
| 67 | + updateActivityCount(cameraId, newCameraState, facing, clientName, apiLevel); |
| 68 | } |
| 69 | }; |
| 70 | |
| 71 | @@ -303,6 +305,7 @@ public class CameraServiceProxy extends SystemService |
| 72 | .setType(MetricsEvent.TYPE_ACTION) |
| 73 | .setSubtype(subtype) |
| 74 | .setLatency(e.getDuration()) |
| 75 | + .addTaggedData(MetricsEvent.FIELD_CAMERA_API_LEVEL, e.mAPILevel) |
| 76 | .setPackageName(e.mClientName); |
| 77 | mLogger.write(l); |
| 78 | } |
| 79 | @@ -383,7 +386,8 @@ public class CameraServiceProxy extends SystemService |
| 80 | return true; |
| 81 | } |
| 82 | |
| 83 | - private void updateActivityCount(String cameraId, int newCameraState, int facing, String clientName) { |
| 84 | + private void updateActivityCount(String cameraId, int newCameraState, int facing, |
| 85 | + String clientName, int apiLevel) { |
| 86 | synchronized(mLock) { |
| 87 | // Update active camera list and notify NFC if necessary |
| 88 | boolean wasEmpty = mActiveCameraUsage.isEmpty(); |
| 89 | @@ -391,7 +395,7 @@ public class CameraServiceProxy extends SystemService |
| 90 | case ICameraServiceProxy.CAMERA_STATE_OPEN: |
| 91 | break; |
| 92 | case ICameraServiceProxy.CAMERA_STATE_ACTIVE: |
| 93 | - CameraUsageEvent newEvent = new CameraUsageEvent(facing, clientName); |
| 94 | + CameraUsageEvent newEvent = new CameraUsageEvent(facing, clientName, apiLevel); |
| 95 | CameraUsageEvent oldEvent = mActiveCameraUsage.put(cameraId, newEvent); |
| 96 | if (oldEvent != null) { |
| 97 | Slog.w(TAG, "Camera " + cameraId + " was already marked as active"); |
| 98 | -- |
| 99 | 2.7.4 |
| 100 | |