One swallow does not make a summer

pull/178/head
M66B 5 years ago
parent d878f76170
commit 4004f07e08

File diff suppressed because it is too large Load Diff

@ -182,7 +182,8 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
(BuildConfig.DEBUG ?
" " + account.poll_interval +
"/" + account.keep_alive_ok +
"/" + account.keep_alive_failed : "")));
"/" + account.keep_alive_failed +
"/" + account.keep_alive_succeeded : "")));
tvQuota.setText(context.getString(R.string.title_storage_quota,
(account.quota_usage == null ? "-" : Helper.humanReadableByteCount(account.quota_usage, true)),
(account.quota_limit == null ? "-" : Helper.humanReadableByteCount(account.quota_limit, true))));

@ -60,7 +60,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 150,
version = 151,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -1429,6 +1429,13 @@ public abstract class DB extends RoomDatabase {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `language` TEXT");
}
})
.addMigrations(new Migration(150, 151) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `account` ADD COLUMN `keep_alive_succeeded` INTEGER NOT NULL DEFAULT 0");
}
});
}

@ -149,8 +149,10 @@ public interface DaoAccount {
@Query("UPDATE account SET keep_alive_ok = :ok WHERE id = :id")
int setAccountKeepAliveOk(long id, boolean ok);
@Query("UPDATE account SET keep_alive_failed = :value WHERE id = :id")
int setAccountKeepAliveFailed(long id, int value);
@Query("UPDATE account" +
" SET keep_alive_failed = :failed, keep_alive_succeeded = :succeeded" +
" WHERE id = :id")
int setAccountKeepAliveValues(long id, int failed, int succeeded);
@Query("UPDATE account SET poll_exempted = :value WHERE id = :id")
int setAccountPollExempted(long id, boolean value);

@ -119,6 +119,8 @@ public class EntityAccount extends EntityOrder implements Serializable {
@NonNull
public Integer keep_alive_failed = 0;
@NonNull
public Integer keep_alive_succeeded = 0;
@NonNull
public Boolean partial_fetch = true;
@NonNull
public Boolean ignore_size = false;

@ -1112,6 +1112,7 @@ public class FragmentAccount extends FragmentBase {
if (account.poll_interval != poll_interval) {
account.keep_alive_ok = false;
account.keep_alive_failed = 0;
account.keep_alive_succeeded = 0;
}
account.poll_interval = poll_interval;

@ -1358,28 +1358,40 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
} catch (Throwable ex) {
if (optimize) {
account.keep_alive_failed++;
account.keep_alive_succeeded = 0;
if (account.keep_alive_failed >= 3) {
account.keep_alive_failed = 0;
account.poll_interval--;
db.account().setAccountKeepAliveInterval(account.id, account.poll_interval);
}
db.account().setAccountKeepAliveFailed(account.id, account.keep_alive_failed);
EntityLog.log(ServiceSynchronize.this, account.name +
" keep alive failed=" + account.keep_alive_failed +
" keep alive interval=" + account.poll_interval +
" max idle=" + idleTime + "/" + optimize);
db.account().setAccountKeepAliveValues(account.id,
account.keep_alive_failed, account.keep_alive_succeeded);
EntityLog.log(ServiceSynchronize.this, account.name + " keep alive" +
" failed=" + account.keep_alive_failed +
" succeeded=" + account.keep_alive_succeeded +
" interval=" + account.poll_interval +
" idle=" + idleTime);
}
throw ex;
}
if (optimize) {
account.keep_alive_ok = true;
account.keep_alive_failed = 0;
db.account().setAccountKeepAliveOk(account.id, true);
db.account().setAccountKeepAliveFailed(account.id, account.keep_alive_failed);
if (!BuildConfig.PLAY_STORE_RELEASE)
Log.e(account.host + " keep alive=" + account.poll_interval);
EntityLog.log(ServiceSynchronize.this, account.name + " keep alive ok");
account.keep_alive_succeeded++;
db.account().setAccountKeepAliveValues(account.id,
account.keep_alive_failed, account.keep_alive_succeeded);
if (account.keep_alive_succeeded >= 3) {
account.keep_alive_ok = true;
db.account().setAccountKeepAliveOk(account.id, true);
if (!BuildConfig.PLAY_STORE_RELEASE)
Log.e(account.host + " keep alive=" + account.poll_interval);
EntityLog.log(ServiceSynchronize.this, account.name + " keep alive ok");
} else
EntityLog.log(ServiceSynchronize.this, account.name + " keep alive" +
" failed=" + account.keep_alive_failed +
" succeeded=" + account.keep_alive_succeeded +
" interval=" + account.poll_interval +
" idle=" + idleTime);
}
// Successfully connected: reset back off time

Loading…
Cancel
Save