Merge changes Ife0b17c2,If37e5c6c am: d4baac7702 am: b0e98333fe
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1455631 Change-Id: I275abdf6d24be889b6ef49a6112801129a4c081c
This commit is contained in:
@@ -26,17 +26,6 @@ interface IStatsCompanionService {
|
|||||||
*/
|
*/
|
||||||
oneway void statsdReady();
|
oneway void statsdReady();
|
||||||
|
|
||||||
/**
|
|
||||||
* Register an alarm for anomaly detection to fire at the given timestamp (ms since epoch).
|
|
||||||
* If anomaly alarm had already been registered, it will be replaced with the new timestamp.
|
|
||||||
* Uses AlarmManager.set API, so if the timestamp is in the past, alarm fires immediately, and
|
|
||||||
* alarm is inexact.
|
|
||||||
*/
|
|
||||||
oneway void setAnomalyAlarm(long timestampMs);
|
|
||||||
|
|
||||||
/** Cancel any anomaly detection alarm. */
|
|
||||||
oneway void cancelAnomalyAlarm();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a repeating alarm for pulling to fire at the given timestamp and every
|
* Register a repeating alarm for pulling to fire at the given timestamp and every
|
||||||
* intervalMs thereafter (in ms since epoch).
|
* intervalMs thereafter (in ms since epoch).
|
||||||
|
|||||||
@@ -41,13 +41,6 @@ interface IStatsd {
|
|||||||
*/
|
*/
|
||||||
void statsCompanionReady();
|
void statsCompanionReady();
|
||||||
|
|
||||||
/**
|
|
||||||
* Tells statsd that an anomaly may have occurred, so statsd can check whether this is so and
|
|
||||||
* act accordingly.
|
|
||||||
* Two-way binder call so that caller's method (and corresponding wakelocks) will linger.
|
|
||||||
*/
|
|
||||||
void informAnomalyAlarmFired();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells statsd that it is time to poll some stats. Statsd will be responsible for determing
|
* Tells statsd that it is time to poll some stats. Statsd will be responsible for determing
|
||||||
* what stats to poll and initiating the polling.
|
* what stats to poll and initiating the polling.
|
||||||
|
|||||||
@@ -100,7 +100,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
|
|||||||
private static IStatsd sStatsd;
|
private static IStatsd sStatsd;
|
||||||
private static final Object sStatsdLock = new Object();
|
private static final Object sStatsdLock = new Object();
|
||||||
|
|
||||||
private final OnAlarmListener mAnomalyAlarmListener;
|
|
||||||
private final OnAlarmListener mPullingAlarmListener;
|
private final OnAlarmListener mPullingAlarmListener;
|
||||||
private final OnAlarmListener mPeriodicAlarmListener;
|
private final OnAlarmListener mPeriodicAlarmListener;
|
||||||
|
|
||||||
@@ -124,7 +123,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
|
|||||||
handlerThread.start();
|
handlerThread.start();
|
||||||
mHandler = new CompanionHandler(handlerThread.getLooper());
|
mHandler = new CompanionHandler(handlerThread.getLooper());
|
||||||
|
|
||||||
mAnomalyAlarmListener = new AnomalyAlarmListener(context);
|
|
||||||
mPullingAlarmListener = new PullingAlarmListener(context);
|
mPullingAlarmListener = new PullingAlarmListener(context);
|
||||||
mPeriodicAlarmListener = new PeriodicAlarmListener(context);
|
mPeriodicAlarmListener = new PeriodicAlarmListener(context);
|
||||||
}
|
}
|
||||||
@@ -336,41 +334,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class AnomalyAlarmListener implements OnAlarmListener {
|
|
||||||
private final Context mContext;
|
|
||||||
|
|
||||||
AnomalyAlarmListener(Context context) {
|
|
||||||
mContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAlarm() {
|
|
||||||
if (DEBUG) {
|
|
||||||
Log.i(TAG, "StatsCompanionService believes an anomaly has occurred at time "
|
|
||||||
+ System.currentTimeMillis() + "ms.");
|
|
||||||
}
|
|
||||||
IStatsd statsd = getStatsdNonblocking();
|
|
||||||
if (statsd == null) {
|
|
||||||
Log.w(TAG, "Could not access statsd to inform it of anomaly alarm firing");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wakelock needs to be retained while calling statsd.
|
|
||||||
Thread thread = new WakelockThread(mContext,
|
|
||||||
AnomalyAlarmListener.class.getCanonicalName(), new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
statsd.informAnomalyAlarmFired();
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
Log.w(TAG, "Failed to inform statsd of anomaly alarm firing", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
thread.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final static class PullingAlarmListener implements OnAlarmListener {
|
public final static class PullingAlarmListener implements OnAlarmListener {
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
|
|
||||||
@@ -468,34 +431,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // Binder call
|
|
||||||
public void setAnomalyAlarm(long timestampMs) {
|
|
||||||
StatsCompanion.enforceStatsdCallingUid();
|
|
||||||
if (DEBUG) Log.d(TAG, "Setting anomaly alarm for " + timestampMs);
|
|
||||||
final long callingToken = Binder.clearCallingIdentity();
|
|
||||||
try {
|
|
||||||
// using ELAPSED_REALTIME, not ELAPSED_REALTIME_WAKEUP, so if device is asleep, will
|
|
||||||
// only fire when it awakens.
|
|
||||||
// AlarmManager will automatically cancel any previous mAnomalyAlarmListener alarm.
|
|
||||||
mAlarmManager.setExact(AlarmManager.ELAPSED_REALTIME, timestampMs, TAG + ".anomaly",
|
|
||||||
mAnomalyAlarmListener, mHandler);
|
|
||||||
} finally {
|
|
||||||
Binder.restoreCallingIdentity(callingToken);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override // Binder call
|
|
||||||
public void cancelAnomalyAlarm() {
|
|
||||||
StatsCompanion.enforceStatsdCallingUid();
|
|
||||||
if (DEBUG) Log.d(TAG, "Cancelling anomaly alarm");
|
|
||||||
final long callingToken = Binder.clearCallingIdentity();
|
|
||||||
try {
|
|
||||||
mAlarmManager.cancel(mAnomalyAlarmListener);
|
|
||||||
} finally {
|
|
||||||
Binder.restoreCallingIdentity(callingToken);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
public void setAlarmForSubscriberTriggering(long timestampMs) {
|
public void setAlarmForSubscriberTriggering(long timestampMs) {
|
||||||
StatsCompanion.enforceStatsdCallingUid();
|
StatsCompanion.enforceStatsdCallingUid();
|
||||||
@@ -666,7 +601,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
|
|||||||
// instead of in binder death because statsd can come back and set different alarms, or not
|
// instead of in binder death because statsd can come back and set different alarms, or not
|
||||||
// want to set an alarm when it had been set. This guarantees that when we get a new statsd,
|
// want to set an alarm when it had been set. This guarantees that when we get a new statsd,
|
||||||
// we cancel any alarms before it is able to set them.
|
// we cancel any alarms before it is able to set them.
|
||||||
cancelAnomalyAlarm();
|
|
||||||
cancelPullingAlarm();
|
cancelPullingAlarm();
|
||||||
cancelAlarmForSubscriberTriggering();
|
cancelAlarmForSubscriberTriggering();
|
||||||
|
|
||||||
|
|||||||
@@ -971,12 +971,6 @@ Status StatsService::informOnePackageRemoved(const string& app, int32_t uid) {
|
|||||||
return Status::ok();
|
return Status::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
Status StatsService::informAnomalyAlarmFired() {
|
|
||||||
ENFORCE_UID(AID_SYSTEM);
|
|
||||||
// Anomaly alarms are handled internally now. This code should be fully deleted.
|
|
||||||
return Status::ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
Status StatsService::informAlarmForSubscriberTriggeringFired() {
|
Status StatsService::informAlarmForSubscriberTriggeringFired() {
|
||||||
ENFORCE_UID(AID_SYSTEM);
|
ENFORCE_UID(AID_SYSTEM);
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ public:
|
|||||||
virtual Status systemRunning();
|
virtual Status systemRunning();
|
||||||
virtual Status statsCompanionReady();
|
virtual Status statsCompanionReady();
|
||||||
virtual Status bootCompleted();
|
virtual Status bootCompleted();
|
||||||
virtual Status informAnomalyAlarmFired();
|
|
||||||
virtual Status informPollAlarmFired();
|
virtual Status informPollAlarmFired();
|
||||||
virtual Status informAlarmForSubscriberTriggeringFired();
|
virtual Status informAlarmForSubscriberTriggeringFired();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user