Debug: added start serializer

pull/215/head
M66B 4 months ago
parent f374c3e2cd
commit 0e18c2f9ba

@ -185,6 +185,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private ImageButton ibSqliteCache;
private SwitchCompat swLegacyQueries;
private SwitchCompat swOauthTabs;
private TextView tvStartDelay;
private SeekBar sbStartDelay;
private TextView tvChunkSize;
private SeekBar sbChunkSize;
private TextView tvThreadRange;
@ -289,7 +291,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"sqlite_integrity_check", "wal", "sqlite_checkpoints", "sqlite_analyze", "sqlite_auto_vacuum", "sqlite_sync_extra", "sqlite_cache",
"legacy_queries",
"oauth_tabs",
"chunk_size", "thread_range",
"start_delay", "chunk_size", "thread_range",
"autoscroll_editor", "undo_manager",
"browser_zoom", "fake_dark",
"ignore_formatted_size",
@ -441,6 +443,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
ibSqliteCache = view.findViewById(R.id.ibSqliteCache);
swLegacyQueries = view.findViewById(R.id.swLegacyQueries);
swOauthTabs = view.findViewById(R.id.swOauthTabs);
tvStartDelay = view.findViewById(R.id.tvStartDelay);
sbStartDelay = view.findViewById(R.id.sbStartDelay);
tvChunkSize = view.findViewById(R.id.tvChunkSize);
sbChunkSize = view.findViewById(R.id.sbChunkSize);
tvThreadRange = view.findViewById(R.id.tvThreadRange);
@ -1291,6 +1295,24 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
sbStartDelay.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
int start_delay = progress * 10;
prefs.edit().putInt("start_delay", start_delay).apply();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// Do nothing
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// Do nothing
}
});
sbChunkSize.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
@ -2413,6 +2435,10 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swOauthTabs.setChecked(prefs.getBoolean("oauth_tabs", true));
int start_delay = prefs.getInt("start_delay", 0);
tvStartDelay.setText(getString(R.string.title_advanced_start_delay, start_delay));
sbStartDelay.setProgress(start_delay / 10);
int chunk_size = prefs.getInt("chunk_size", Core.DEFAULT_CHUNK_SIZE);
tvChunkSize.setText(getString(R.string.title_advanced_chunk_size, chunk_size));
sbChunkSize.setProgress(chunk_size);

@ -86,6 +86,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Semaphore;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@ -293,6 +294,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
private int lastQuitId = -1;
private List<Long> initialized = new ArrayList<>();
private List<TupleAccountNetworkState> accountStates = new ArrayList<>();
private final Map<String, Semaphore> startSerializer = new HashMap<>();
private PowerManager pm = Helper.getSystemService(ServiceSynchronize.this, PowerManager.class);
private PowerManager.WakeLock wl = pm.newWakeLock(
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":service");
@ -556,6 +558,22 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
@Override
public void delegate() {
try {
int start_delay = prefs.getInt("start_delay", 0);
if (start_delay > 0) {
Semaphore sem;
synchronized (startSerializer) {
if (!startSerializer.containsKey(accountNetworkState.accountState.host))
startSerializer.put(accountNetworkState.accountState.host, new Semaphore(1));
sem = startSerializer.get(accountNetworkState.accountState.host);
}
sem.acquire();
getMainHandler().postDelayed(new Runnable() {
@Override
public void run() {
sem.release();
}
}, start_delay * 1000L);
}
monitorAccount(accountNetworkState.accountState, astate, sync, force);
} catch (Throwable ex) {
Log.e(accountNetworkState.accountState.name, ex);

@ -1197,6 +1197,29 @@
app:layout_constraintTop_toBottomOf="@id/swLegacyQueries"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvStartDelay"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_start_delay"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swOauthTabs" />
<SeekBar
android:id="@+id/sbStartDelay"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:max="30"
android:min="0"
android:progress="0"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvStartDelay" />
<TextView
android:id="@+id/tvChunkSize"
android:layout_width="0dp"
@ -1207,7 +1230,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swOauthTabs" />
app:layout_constraintTop_toBottomOf="@id/sbStartDelay" />
<SeekBar
android:id="@+id/sbChunkSize"

@ -946,6 +946,7 @@
<string name="title_advanced_sqlite_cache" translatable="false">sqlite cache: %1$s %% - %2$s</string>
<string name="title_advanced_legacy_queries" translatable="false">Legacy queries</string>
<string name="title_advanced_oauth_tabs" translatable="false">OAuth tabs</string>
<string name="title_advanced_start_delay" translatable="false">Start delay: %1$d s</string>
<string name="title_advanced_chunk_size" translatable="false">Chunk size: %1$d</string>
<string name="title_advanced_thread_range" translatable="false">Thread range: %1$d days</string>
<string name="title_advanced_auto_scroll" translatable="false">Auto scroll editor</string>

Loading…
Cancel
Save