Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
e
os
eDrive
Commits
3e3f19e6
Commit
3e3f19e6
authored
Jan 27, 2022
by
Jonathan Klee
Browse files
Merge branch 'cherry-pick-force-sync' into 'v1-nougat'
Implement FORCE_SYNC intent See merge request e/apps/eDrive!69
parents
a5d6695b
9e4e4274
Pipeline
#161054
passed with stage
in 4 minutes and 35 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
app/src/main/AndroidManifest.xml
View file @
3e3f19e6
...
...
@@ -79,5 +79,12 @@ http://www.gnu.org/licenses/gpl.html
<action
android:name=
"android.intent.action.MY_PACKAGE_REPLACED"
/>
</intent-filter>
</receiver>
<receiver
android:name=
".receivers.ForceSyncReceiver"
android:enabled=
"true"
>
<intent-filter>
<action
android:name=
"foundation.e.drive.action.FORCE_SYNC"
/>
</intent-filter>
</receiver>
</application>
</manifest>
app/src/main/java/foundation/e/drive/receivers/ForceSyncReceiver.java
0 → 100644
View file @
3e3f19e6
package
foundation.e.drive.receivers
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.util.Log
;
import
foundation.e.drive.BuildConfig
;
import
foundation.e.drive.services.ObserverService
;
public
class
ForceSyncReceiver
extends
BroadcastReceiver
{
public
static
final
String
ACTION_FORCE_SYNC
=
"foundation.e.drive.action.FORCE_SYNC"
;
public
static
final
String
TAG
=
"ForceSyncReceiver"
;
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
if
(
ACTION_FORCE_SYNC
.
equals
(
intent
.
getAction
())
&&
BuildConfig
.
DEBUG
)
{
Log
.
i
(
TAG
,
"Start ObserverService"
);
context
.
startService
(
new
Intent
(
context
,
ObserverService
.
class
));
}
}
}
\ No newline at end of file
app/src/main/java/foundation/e/drive/services/ObserverService.java
View file @
3e3f19e6
...
...
@@ -36,6 +36,7 @@ import java.util.List;
import
java.util.ListIterator
;
import
java.util.Map
;
import
foundation.e.drive.BuildConfig
;
import
foundation.e.drive.database.DbHelper
;
import
foundation.e.drive.fileFilters.CrashlogsFileFilter
;
import
foundation.e.drive.fileFilters.FileFilterFactory
;
...
...
@@ -127,7 +128,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene
long
currentTime
=
System
.
currentTimeMillis
();
//if time diff between current sync and last sync is higher or equal to delay minimum between two sync
if
(
(
currentTime
-
lastSyncTime
)
<
INTERSYNC_MINIMUM_DELAY
){
if
(!
BuildConfig
.
DEBUG
&&
(
currentTime
-
lastSyncTime
)
<
INTERSYNC_MINIMUM_DELAY
){
Log
.
w
(
TAG
,
"Delay between now and last call is too short"
);
return
super
.
onStartCommand
(
intent
,
flags
,
startId
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment