summaryrefslogtreecommitdiff
path: root/services/profcollect
diff options
context:
space:
mode:
authorYi Kong <yikong@google.com>2020-10-20 01:53:47 +0800
committerYi Kong <yikong@google.com>2020-10-19 18:33:19 +0000
commit36c8432f9cb9f9597512fedc5b15680982e05df0 (patch)
treeda369aec057b26eb9bd38d6adbb6f41bb13687f3 /services/profcollect
parentb0d3d461f8f05e58d4934738fb714b306d28740f (diff)
profcollectd: OTA Observer
Pack any existing ETM profiles when an OTA is ready to install, which simplifies the workflow for reporting profcollectd profiles. Future work will use the same observer to upload profiles to a collection service. Bug: 79161490 Test: vendor/google/tools/fake-ota streaming on Change-Id: I106af19a3360b87d19ceafaa3ef3b97f1cf34244
Diffstat (limited to 'services/profcollect')
-rw-r--r--services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
index ddd1f7568224..d14ed5a15cf9 100644
--- a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
+++ b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
@@ -29,6 +29,8 @@ import android.os.Looper;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
+import android.os.UpdateEngine;
+import android.os.UpdateEngineCallback;
import android.util.Log;
import com.android.server.IoThread;
@@ -198,6 +200,7 @@ public final class ProfcollectForwardingService extends SystemService {
// Event observers
private void registerObservers() {
registerAppLaunchObserver();
+ registerOTAObserver();
}
private final AppLaunchObserver mAppLaunchObserver = new AppLaunchObserver();
@@ -261,4 +264,33 @@ public final class ProfcollectForwardingService extends SystemService {
// Ignored
}
}
+
+ private void registerOTAObserver() {
+ UpdateEngine updateEngine = new UpdateEngine();
+ updateEngine.bind(new UpdateEngineCallback() {
+ @Override
+ public void onStatusUpdate(int status, float percent) {
+ if (status == UpdateEngine.UpdateStatusConstants.UPDATED_NEED_REBOOT) {
+ packProfileReport();
+ }
+ }
+
+ @Override
+ public void onPayloadApplicationComplete(int errorCode) {
+ // Ignored
+ }
+ });
+ }
+
+ private void packProfileReport() {
+ if (mIProfcollect == null) {
+ return;
+ }
+
+ try {
+ mIProfcollect.CreateProfileReport();
+ } catch (RemoteException e) {
+ Log.e(LOG_TAG, e.getMessage());
+ }
+ }
}