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

Commit 59735f4b authored by Ajay Gopi's avatar Ajay Gopi Committed by Android (Google) Code Review
Browse files

Merge "Modernize HotwordTrainingDataLimitEnforcer utc date calculation." into main

parents de107e75 0b7b11ff
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -27,10 +27,9 @@ import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import java.time.LocalDate;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;

/**
 * Enforces daily limits on the egress of {@link HotwordTrainingData} from the hotword detection
@@ -111,9 +110,9 @@ public class HotwordTrainingDataLimitEnforcer {
    }

    private boolean incrementTrainingDataEgressCountLocked() {
        SimpleDateFormat dt = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
        dt.setTimeZone(TimeZone.getTimeZone("UTC"));
        String currentDate = dt.format(new Date());
        LocalDate utcDate = LocalDate.now(ZoneOffset.UTC);
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        String currentDate = utcDate.format(formatter);

        String storedDate = mSharedPreferences.getString(TRAINING_DATA_EGRESS_DATE, "");
        int storedCount = mSharedPreferences.getInt(TRAINING_DATA_EGRESS_COUNT, 0);