Merge "Profcollect: Allow manually triggering profile upload"
This commit is contained in:
@@ -20,9 +20,11 @@ import android.app.job.JobInfo;
|
|||||||
import android.app.job.JobParameters;
|
import android.app.job.JobParameters;
|
||||||
import android.app.job.JobScheduler;
|
import android.app.job.JobScheduler;
|
||||||
import android.app.job.JobService;
|
import android.app.job.JobService;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder.DeathRecipient;
|
import android.os.IBinder.DeathRecipient;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
@@ -53,7 +55,8 @@ public final class ProfcollectForwardingService extends SystemService {
|
|||||||
public static final String LOG_TAG = "ProfcollectForwardingService";
|
public static final String LOG_TAG = "ProfcollectForwardingService";
|
||||||
|
|
||||||
private static final boolean DEBUG = Log.isLoggable(LOG_TAG, Log.DEBUG);
|
private static final boolean DEBUG = Log.isLoggable(LOG_TAG, Log.DEBUG);
|
||||||
|
private static final String INTENT_UPLOAD_PROFILES =
|
||||||
|
"com.android.server.profcollect.UPLOAD_PROFILES";
|
||||||
private static final long BG_PROCESS_PERIOD = TimeUnit.HOURS.toMillis(4); // every 4 hours.
|
private static final long BG_PROCESS_PERIOD = TimeUnit.HOURS.toMillis(4); // every 4 hours.
|
||||||
|
|
||||||
private IProfCollectd mIProfcollect;
|
private IProfCollectd mIProfcollect;
|
||||||
@@ -66,6 +69,16 @@ public final class ProfcollectForwardingService extends SystemService {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (intent.getAction() == INTENT_UPLOAD_PROFILES) {
|
||||||
|
Log.d(LOG_TAG, "Received broadcast to pack and upload reports");
|
||||||
|
packAndUploadReport();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public ProfcollectForwardingService(Context context) {
|
public ProfcollectForwardingService(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
|
||||||
@@ -73,6 +86,10 @@ public final class ProfcollectForwardingService extends SystemService {
|
|||||||
throw new AssertionError("only one service instance allowed");
|
throw new AssertionError("only one service instance allowed");
|
||||||
}
|
}
|
||||||
sSelfService = this;
|
sSelfService = this;
|
||||||
|
|
||||||
|
final IntentFilter filter = new IntentFilter();
|
||||||
|
filter.addAction(INTENT_UPLOAD_PROFILES);
|
||||||
|
context.registerReceiver(mBroadcastReceiver, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -296,7 +313,7 @@ public final class ProfcollectForwardingService extends SystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (status == UpdateEngine.UpdateStatusConstants.UPDATED_NEED_REBOOT) {
|
if (status == UpdateEngine.UpdateStatusConstants.UPDATED_NEED_REBOOT) {
|
||||||
packProfileReport();
|
packAndUploadReport();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +324,7 @@ public final class ProfcollectForwardingService extends SystemService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void packProfileReport() {
|
private void packAndUploadReport() {
|
||||||
if (mIProfcollect == null) {
|
if (mIProfcollect == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user