Merge "set the metrics handle correctly on error" into main am: 15ff781844 am: 71bd147610

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/2947106

Change-Id: Icb9fd0392c8bd0b93ac52166f81f7db7109d178c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>