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

Commit c85efa92 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka Committed by Android Git Automerger
Browse files

am 72c2feb5: Use TimeUnit instead of DateUtils for readability

* commit '72c2feb5':
  Use TimeUnit instead of DateUtils for readability
parents c29acb5b 72c2feb5
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.text.format.DateUtils;
import android.util.Log;
import android.widget.Toast;

@@ -30,6 +29,7 @@ import com.android.inputmethod.latin.R;

import java.util.Locale;
import java.util.Random;
import java.util.concurrent.TimeUnit;

/**
 * Service that handles background tasks for the dictionary provider.
@@ -77,19 +77,19 @@ public final class DictionaryService extends Service {
     * How often, in milliseconds, we want to update the metadata. This is a
     * floor value; actually, it may happen several hours later, or even more.
     */
    private static final long UPDATE_FREQUENCY = 4 * DateUtils.DAY_IN_MILLIS;
    private static final long UPDATE_FREQUENCY = TimeUnit.DAYS.toMillis(4);

    /**
     * We are waked around midnight, local time. We want to wake between midnight and 6 am,
     * roughly. So use a random time between 0 and this delay.
     */
    private static final int MAX_ALARM_DELAY = 6 * ((int)AlarmManager.INTERVAL_HOUR);
    private static final int MAX_ALARM_DELAY = (int)TimeUnit.HOURS.toMillis(6);

    /**
     * How long we consider a "very long time". If no update took place in this time,
     * the content provider will trigger an update in the background.
     */
    private static final long VERY_LONG_TIME = 14 * DateUtils.DAY_IN_MILLIS;
    private static final long VERY_LONG_TIME = TimeUnit.DAYS.toMillis(14);

    /**
     * The last seen start Id. This must be stored because we must only call stopSelfResult() with
+3 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.text.format.DateUtils;
import android.util.Log;

import com.android.inputmethod.latin.AssetFileAddress;
@@ -35,6 +34,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Locale;
import java.util.concurrent.TimeUnit;

/**
 * This class encapsulates the logic for the Latin-IME side of dictionary information management.
@@ -74,8 +74,8 @@ public class DictionaryInfoUtils {
            values.put(LOCALE_COLUMN, mLocale.toString());
            values.put(DESCRIPTION_COLUMN, mDescription);
            values.put(LOCAL_FILENAME_COLUMN, mFileAddress.mFilename);
            values.put(DATE_COLUMN,
                    new File(mFileAddress.mFilename).lastModified() / DateUtils.SECOND_IN_MILLIS);
            values.put(DATE_COLUMN, TimeUnit.MILLISECONDS.toSeconds(
                    new File(mFileAddress.mFilename).lastModified()));
            values.put(FILESIZE_COLUMN, mFileAddress.mLength);
            values.put(VERSION_COLUMN, mVersion);
            return values;
+4 −3
Original line number Diff line number Diff line
@@ -16,9 +16,10 @@

package com.android.inputmethod.latin.utils;

import android.text.format.DateUtils;
import android.util.Log;

import java.util.concurrent.TimeUnit;

public final class UserHistoryForgettingCurveUtils {
    private static final String TAG = UserHistoryForgettingCurveUtils.class.getSimpleName();
    private static final boolean DEBUG = false;
@@ -27,8 +28,8 @@ public final class UserHistoryForgettingCurveUtils {
    private static final int FC_LEVEL_MAX = 3;
    /* package */ static final int ELAPSED_TIME_MAX = 15;
    private static final int ELAPSED_TIME_INTERVAL_HOURS = 6;
    private static final long ELAPSED_TIME_INTERVAL_MILLIS = ELAPSED_TIME_INTERVAL_HOURS
            * DateUtils.HOUR_IN_MILLIS;
    private static final long ELAPSED_TIME_INTERVAL_MILLIS =
            TimeUnit.HOURS.toMillis(ELAPSED_TIME_INTERVAL_HOURS);
    private static final int HALF_LIFE_HOURS = 48;
    private static final int MAX_PUSH_ELAPSED = (FC_LEVEL_MAX + 1) * (ELAPSED_TIME_MAX + 1);

+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ public class ResearchLog {
    private static final String TAG = ResearchLog.class.getSimpleName();
    private static final boolean DEBUG = false
            && ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS_DEBUG;
    private static final long FLUSH_DELAY_IN_MS = 1000 * 5;
    private static final long FLUSH_DELAY_IN_MS = TimeUnit.SECONDS.toMillis(5);

    /* package */ final ScheduledExecutorService mExecutor;
    /* package */ final File mFile;
+9 −9
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import android.os.IBinder;
import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -75,6 +74,7 @@ import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;

// TODO: Add a unit test for every "logging" method (i.e. that is called from the IME and calls
@@ -137,10 +137,10 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
    private static final int MAX_INPUTVIEW_LENGTH_TO_CAPTURE = 8192; // must be >=1
    private static final String PREF_RESEARCH_SAVED_CHANNEL = "pref_research_saved_channel";

    private static final long RESEARCHLOG_CLOSE_TIMEOUT_IN_MS = 5 * 1000;
    private static final long RESEARCHLOG_ABORT_TIMEOUT_IN_MS = 5 * 1000;
    private static final long DURATION_BETWEEN_DIR_CLEANUP_IN_MS = DateUtils.DAY_IN_MILLIS;
    private static final long MAX_LOGFILE_AGE_IN_MS = 4 * DateUtils.DAY_IN_MILLIS;
    private static final long RESEARCHLOG_CLOSE_TIMEOUT_IN_MS = TimeUnit.SECONDS.toMillis(5);
    private static final long RESEARCHLOG_ABORT_TIMEOUT_IN_MS = TimeUnit.SECONDS.toMillis(5);
    private static final long DURATION_BETWEEN_DIR_CLEANUP_IN_MS = TimeUnit.DAYS.toMillis(1);
    private static final long MAX_LOGFILE_AGE_IN_MS = TimeUnit.DAYS.toMillis(4);

    private static final ResearchLogger sInstance = new ResearchLogger();
    private static String sAccountType = null;
@@ -195,7 +195,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
    // not performed on text that the user types into the feedback dialog.
    private boolean mInFeedbackDialog = false;
    private Handler mUserRecordingTimeoutHandler;
    private static final long USER_RECORDING_TIMEOUT_MS = 30L * DateUtils.SECOND_IN_MILLIS;
    private static final long USER_RECORDING_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(30);

    // Stores a temporary LogUnit while generating a phantom space.  Needed because phantom spaces
    // are issued out-of-order, immediately before the characters generated by other operations that
@@ -542,8 +542,8 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
            toast.show();
            boolean isLogDeleted = abort();
            final long currentTime = System.currentTimeMillis();
            final long resumeTime = currentTime + 1000 * 60 *
                    SUSPEND_DURATION_IN_MINUTES;
            final long resumeTime = currentTime
                    + TimeUnit.MINUTES.toMillis(SUSPEND_DURATION_IN_MINUTES);
            suspendLoggingUntil(resumeTime);
            toast.cancel();
            Toast.makeText(latinIME, R.string.research_notify_logging_suspended,
@@ -635,7 +635,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
                            mMotionEventReader.readMotionEventData(mUserRecordingFile);
                    mReplayer.replay(replayData, null);
                }
            }, 1000);
            }, TimeUnit.SECONDS.toMillis(1));
        }

        if (FEEDBACK_DIALOG_SHOULD_PRESERVE_TEXT_FIELD) {
Loading