Merge "Refactor ChangeReporter and rate limit stats logging."

am: 9a253e12cc

Change-Id: I33b14641d259efea6bf7038da264a3483e71f955
This commit is contained in:
atrost
2019-09-26 10:39:31 -07:00
committed by android-build-merger
3 changed files with 81 additions and 41 deletions

View File

@@ -18,7 +18,6 @@ package android.app;
import android.compat.Compatibility;
import android.os.Process;
import android.util.Log;
import android.util.StatsLog;
import com.android.internal.compat.ChangeReporter;
@@ -31,8 +30,6 @@ import java.util.Arrays;
* @hide
*/
public final class AppCompatCallbacks extends Compatibility.Callbacks {
private static final String TAG = "Compatibility";
private final long[] mDisabledChanges;
private final ChangeReporter mChangeReporter;
@@ -48,7 +45,8 @@ public final class AppCompatCallbacks extends Compatibility.Callbacks {
private AppCompatCallbacks(long[] disabledChanges) {
mDisabledChanges = Arrays.copyOf(disabledChanges, disabledChanges.length);
Arrays.sort(mDisabledChanges);
mChangeReporter = new ChangeReporter();
mChangeReporter = new ChangeReporter(
StatsLog.APP_COMPATIBILITY_CHANGE_REPORTED__SOURCE__APP_PROCESS);
}
protected void reportChange(long changeId) {
@@ -67,10 +65,7 @@ public final class AppCompatCallbacks extends Compatibility.Callbacks {
private void reportChange(long changeId, int state) {
int uid = Process.myUid();
//TODO(b/138374585): Implement rate limiting for the logs.
Log.d(TAG, ChangeReporter.createLogString(uid, changeId, state));
mChangeReporter.reportChange(uid, changeId,
state, /* source */StatsLog.APP_COMPATIBILITY_CHANGE_REPORTED__SOURCE__APP_PROCESS);
mChangeReporter.reportChange(uid, changeId, state);
}
}