Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9086762d authored by Bookatz's avatar Bookatz
Browse files

Use statsd constants instead of literals

Instead of writing StatsLog.write(StatsLog.NAME, 1), we replace the 1
with the appropriate StatsLog constant.

Bug: 72749863
Test: still compiles

Change-Id: I68c8206de49df7e77ee66333dd633e4b70c7b226
parent 75ca5dff
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -757,8 +757,8 @@ message SettingChanged {
    // The tag used with the is_default for resetting sets of settings. This is generally null.
    optional string tag = 5;

    // 1 indicates that this setting with tag should be resettable.
    optional int32 is_default = 6;
    // True if this setting with tag should be resettable.
    optional bool is_default = 6;

    // The user ID associated. Defined in android/os/UserHandle.java
    optional int32 user = 7;
@@ -1105,9 +1105,12 @@ message IsolatedUidChanged {

    optional int32 isolated_uid = 2;

    // 1 denotes we're creating an isolated uid and 0 denotes removal. We expect an isolated uid to
    // be removed before if it's used for another parent uid.
    optional int32 is_create = 3;
    // We expect an isolated uid to be removed before if it's used for another parent uid.
    enum Event {
        REMOVED = 0;
        CREATED = 1;
    }
    optional Event event = 3;
}

/**
+14 −6
Original line number Diff line number Diff line
@@ -116,28 +116,32 @@ public class MainActivity extends Activity {
        findViewById(R.id.plug).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                StatsLog.write(StatsLog.PLUGGED_STATE_CHANGED, 1);
                StatsLog.write(StatsLog.PLUGGED_STATE_CHANGED,
                        StatsLog.PLUGGED_STATE_CHANGED__STATE__BATTERY_PLUGGED_AC);
            }
        });

        findViewById(R.id.unplug).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                StatsLog.write(StatsLog.PLUGGED_STATE_CHANGED, 0);
                StatsLog.write(StatsLog.PLUGGED_STATE_CHANGED,
                        StatsLog.PLUGGED_STATE_CHANGED__STATE__BATTERY_PLUGGED_NONE);
            }
        });

        findViewById(R.id.screen_on).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                StatsLog.write(StatsLog.SCREEN_STATE_CHANGED, 2);
                StatsLog.write(StatsLog.SCREEN_STATE_CHANGED,
                        StatsLog.SCREEN_STATE_CHANGED__STATE__DISPLAY_STATE_ON);
            }
        });

        findViewById(R.id.screen_off).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                StatsLog.write(StatsLog.SCREEN_STATE_CHANGED, 1);
                StatsLog.write(StatsLog.SCREEN_STATE_CHANGED,
                        StatsLog.SCREEN_STATE_CHANGED__STATE__DISPLAY_STATE_OFF);
            }
        });

@@ -255,7 +259,9 @@ public class MainActivity extends Activity {
        }
        int[] uids = new int[] {mUids[id]};
        String[] tags  = new String[] {"acquire"};
        StatsLog.write(StatsLog.WAKELOCK_STATE_CHANGED, uids, tags, 0, name, 1);
        StatsLog.write(StatsLog.WAKELOCK_STATE_CHANGED, uids, tags,
                StatsLog.WAKELOCK_STATE_CHANGED__LEVEL__PARTIAL_WAKE_LOCK, name,
                StatsLog.WAKELOCK_STATE_CHANGED__STATE__ACQUIRE);
        StringBuilder sb = new StringBuilder();
        sb.append("StagsLog.write(10, ").append(mUids[id]).append(", ").append(0)
                .append(", ").append(name).append(", 1);");
@@ -269,7 +275,9 @@ public class MainActivity extends Activity {
        }
        int[] uids = new int[] {mUids[id]};
        String[] tags  = new String[] {"release"};
        StatsLog.write(10, uids, tags, 0, name, 0);
        StatsLog.write(StatsLog.WAKELOCK_STATE_CHANGED, uids, tags,
                StatsLog.WAKELOCK_STATE_CHANGED__LEVEL__PARTIAL_WAKE_LOCK, name,
                StatsLog.WAKELOCK_STATE_CHANGED__STATE__RELEASE);
        StringBuilder sb = new StringBuilder();
        sb.append("StagsLog.write(10, ").append(mUids[id]).append(", ").append(0)
                .append(", ").append(name).append(", 0);");
+1 −1
Original line number Diff line number Diff line
@@ -1903,7 +1903,7 @@ public final class Settings {
                cp.call(cr.getPackageName(), mCallSetCommand, name, arg);
                String newValue = getStringForUser(cr, name, userHandle);
                StatsLog.write(StatsLog.SETTING_CHANGED, name, value, newValue, prevValue, tag,
                        makeDefault ? 1 : 0, userHandle);
                        makeDefault, userHandle);
            } catch (RemoteException e) {
                Log.w(TAG, "Can't set key " + name + " in " + mUri, e);
                return false;
+100 −57

File changed.

Preview size limit exceeded, changes collapsed.

+5 −2
Original line number Diff line number Diff line
@@ -4331,7 +4331,9 @@ public class ActivityManagerService extends IActivityManager.Stub
        final BatteryStatsImpl stats = mBatteryStatsService.getActiveStatistics();
        StatsLog.write(StatsLog.ACTIVITY_FOREGROUND_STATE_CHANGED,
            component.userId, component.realActivity.getPackageName(),
            component.realActivity.getShortClassName(), resumed ? 1 : 0);
            component.realActivity.getShortClassName(), resumed ?
                        StatsLog.ACTIVITY_FOREGROUND_STATE_CHANGED__ACTIVITY__MOVE_TO_FOREGROUND :
                        StatsLog.ACTIVITY_FOREGROUND_STATE_CHANGED__ACTIVITY__MOVE_TO_BACKGROUND);
        if (resumed) {
            if (mUsageStatsService != null) {
                mUsageStatsService.reportEvent(component.realActivity, component.userId,
@@ -12844,7 +12846,8 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        // TODO: Where should the corresponding '1' (start) write go?
        StatsLog.write(StatsLog.DEVICE_ON_STATUS_CHANGED, 0);
        StatsLog.write(StatsLog.DEVICE_ON_STATUS_CHANGED,
                StatsLog.DEVICE_ON_STATUS_CHANGED__STATE__OFF);
        boolean timedout = false;
Loading