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

Commit d10391e9 authored by Arthur Wang's avatar Arthur Wang
Browse files

resolve merge conflicts of 8debbac6 to master

Change-Id: Icc5cf705caa767de5962ea1cb684f0768c6bbec8
parents ff12b660 8debbac6
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ public final class Flags {

    private static Flags sInstance;

    private Map<String,Boolean> mMap;
    private Map<String, Object> mMap;

    public static Flags getInstance(Context context) {
        if (sInstance == null) {
@@ -42,6 +42,10 @@ public final class Flags {
    }

    public boolean getBoolean(String flagName) {
        return mMap.containsKey(flagName) ? mMap.get(flagName) : false;
        return mMap.containsKey(flagName) ? (boolean) mMap.get(flagName) : false;
    }

    public int getInteger(String flagName) {
        return mMap.containsKey(flagName) ? ((Integer) mMap.get(flagName)).intValue() : 0;
    }
}
+8 −19
Original line number Diff line number Diff line
@@ -78,23 +78,6 @@ public class DynamicShortcuts {
    private static final int LONG_LABEL_MAX_LENGTH = 30;
    private static final int MAX_SHORTCUTS = 3;

    /**
     * How long  to wait after a change to the contacts content uri before updating the shortcuts
     * This increases the likelihood that multiple updates will be coalesced in the case that
     * the updates are happening rapidly
     *
     * TODO: this should probably be externally configurable to make it easier to manually test the
     * behavior
     */
    private static final int CONTENT_CHANGE_MIN_UPDATE_DELAY_MILLIS = 10000; // 10 seconds
    /**
     * The maximum time to wait before updating the shortcuts that may have changed.
     *
     * TODO: this should probably be externally configurable to make it easier to manually test the
     * behavior
     */
    private static final int CONTENT_CHANGE_MAX_UPDATE_DELAY_MILLIS = 24*60*60*1000; // 1 day

    // The spec specifies that it should be 44dp @ xxxhdpi
    // Note that ShortcutManager.getIconMaxWidth and ShortcutManager.getMaxHeight return different
    // (larger) values.
@@ -110,6 +93,8 @@ public class DynamicShortcuts {
    private final ShortcutManager mShortcutManager;
    private int mShortLabelMaxLength = SHORT_LABEL_MAX_LENGTH;
    private int mLongLabelMaxLength = LONG_LABEL_MAX_LENGTH;
    private final int mContentChangeMinUpdateDelay;
    private final int mContentChangeMaxUpdateDelay;

    public DynamicShortcuts(Context context) {
        this(context, context.getContentResolver(), (ShortcutManager)
@@ -121,6 +106,10 @@ public class DynamicShortcuts {
        mContext = context;
        mContentResolver = contentResolver;
        mShortcutManager = shortcutManager;
        mContentChangeMinUpdateDelay = Flags.getInstance(mContext)
                .getInteger(Experiments.DYNAMIC_MIN_CONTENT_CHANGE_UPDATE_DELAY_MILLIS);
        mContentChangeMaxUpdateDelay = Flags.getInstance(mContext)
                .getInteger(Experiments.DYNAMIC_MAX_CONTENT_CHANGE_UPDATE_DELAY_MILLIS);
    }

    @VisibleForTesting
@@ -365,8 +354,8 @@ public class DynamicShortcuts {
                // that complexity.
                .addTriggerContentUri(new JobInfo.TriggerContentUri(ContactsContract.AUTHORITY_URI,
                        JobInfo.TriggerContentUri.FLAG_NOTIFY_FOR_DESCENDANTS))
                .setTriggerContentUpdateDelay(CONTENT_CHANGE_MIN_UPDATE_DELAY_MILLIS)
                .setTriggerContentMaxDelay(CONTENT_CHANGE_MAX_UPDATE_DELAY_MILLIS).build();
                .setTriggerContentUpdateDelay(mContentChangeMinUpdateDelay)
                .setTriggerContentMaxDelay(mContentChangeMaxUpdateDelay).build();
        final JobScheduler scheduler = (JobScheduler)
                mContext.getSystemService(Context.JOB_SCHEDULER_SERVICE);
        scheduler.schedule(job);
+12 −0
Original line number Diff line number Diff line
@@ -40,6 +40,18 @@ public final class Experiments {
     */
    public static final String CONTACT_SHEET = "QuickContact__contact_sheet";

    /**
     * Flags for minimum content update time
     */
    public static final String DYNAMIC_MIN_CONTENT_CHANGE_UPDATE_DELAY_MILLIS =
            "Shortcuts__dynamic_min_content_change_update_delay_millis";

    /**
     * Flags for maximum content update time
     */
    public static final String DYNAMIC_MAX_CONTENT_CHANGE_UPDATE_DELAY_MILLIS =
            "Shortcuts__dynamic_max_content_change_update_delay_millis";

    private Experiments() {
    }
}