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
fe849af6
Commit
fe849af6
authored
Oct 28, 2019
by
Vincent Bourgmayer
🎼
Browse files
Issue 95 n
parent
f18487cf
Pipeline
#28748
passed with stage
in 6 minutes and 13 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/src/main/AndroidManifest.xml
View file @
fe849af6
...
@@ -22,8 +22,9 @@ http://www.gnu.org/licenses/gpl.html
...
@@ -22,8 +22,9 @@ http://www.gnu.org/licenses/gpl.html
android:allowBackup=
"true"
android:allowBackup=
"true"
android:icon=
"@mipmap/ic_eelo"
android:icon=
"@mipmap/ic_eelo"
android:label=
"@string/app_name"
android:label=
"@string/app_name"
android:roundIcon=
"@mipmap/ic_eelo_round"
android:roundIcon=
"@mipmap/ic_eelo_round"
>
android:supportsRtl=
"true"
>
<!-- Provider -->
<provider
<provider
android:authorities=
"foundation.e.drive.providers.MediasSyncProvider"
android:authorities=
"foundation.e.drive.providers.MediasSyncProvider"
android:name=
".providers.MediasSyncProvider"
android:name=
".providers.MediasSyncProvider"
...
@@ -36,6 +37,8 @@ http://www.gnu.org/licenses/gpl.html
...
@@ -36,6 +37,8 @@ http://www.gnu.org/licenses/gpl.html
android:label=
"Application settings"
android:label=
"Application settings"
android:enabled=
"true"
android:enabled=
"true"
android:exported=
"true"
/>
android:exported=
"true"
/>
<!-- Services -->
<service
android:name=
".services.InitializerService"
<service
android:name=
".services.InitializerService"
android:enabled=
"true"
android:enabled=
"true"
android:exported=
"true"
>
android:exported=
"true"
>
...
@@ -43,7 +46,6 @@ http://www.gnu.org/licenses/gpl.html
...
@@ -43,7 +46,6 @@ http://www.gnu.org/licenses/gpl.html
<action
android:name=
"drive.services.InitializerService"
/>
<action
android:name=
"drive.services.InitializerService"
/>
</intent-filter>
</intent-filter>
</service>
</service>
<service
android:name=
".services.ResetService"
<service
android:name=
".services.ResetService"
android:enabled=
"true"
android:enabled=
"true"
android:exported=
"true"
>
android:exported=
"true"
>
...
@@ -54,11 +56,16 @@ http://www.gnu.org/licenses/gpl.html
...
@@ -54,11 +56,16 @@ http://www.gnu.org/licenses/gpl.html
<service
android:name=
".jobs.ScannerJob"
<service
android:name=
".jobs.ScannerJob"
android:permission=
"android.permission.BIND_JOB_SERVICE"
/>
android:permission=
"android.permission.BIND_JOB_SERVICE"
/>
<service
android:name=
".services.ObserverService"
<service
android:name=
".services.ObserverService"
android:enabled=
"true"
android:enabled=
"true"
/>
android:exported=
"true"
>
</service>
<service
android:name=
".services.OperationManagerService"
/>
<service
android:name=
".services.OperationManagerService"
/>
<!-- Receivers -->
<receiver
android:name=
".receivers.BootCompleteReceiver"
android:enabled=
"true"
>
<intent-filter>
<action
android:name=
"android.intent.action.BOOT_COMPLETED"
/>
</intent-filter>
</receiver>
<receiver
android:name=
".receivers.BatteryStateReceiver"
android:enabled=
"true"
>
<receiver
android:name=
".receivers.BatteryStateReceiver"
android:enabled=
"true"
>
<intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.BATTERY_LOW"
/>
<action
android:name=
"android.intent.action.BATTERY_LOW"
/>
...
...
app/src/main/java/foundation/e/drive/receivers/BootCompleteReceiver.java
0 → 100644
View file @
fe849af6
package
foundation.e.drive.receivers
;
import
android.accounts.AccountManager
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.util.Log
;
import
foundation.e.drive.services.ObserverService
;
import
foundation.e.drive.utils.AppConstants
;
import
foundation.e.drive.utils.CommonUtils
;
import
foundation.e.drive.utils.JobUtils
;
public
class
BootCompleteReceiver
extends
BroadcastReceiver
{
private
final
static
String
TAG
=
BootCompleteReceiver
.
class
.
getSimpleName
();
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
Log
.
i
(
TAG
,
"onReceive"
);
String
intentAction
=
intent
.
getAction
();
if
(
intentAction
==
null
){
Log
.
e
(
TAG
,
"intent Action is null"
);
}
else
if
(
intent
.
getAction
().
equals
(
Intent
.
ACTION_BOOT_COMPLETED
))
{
SharedPreferences
prefs
=
context
.
getSharedPreferences
(
AppConstants
.
SHARED_PREFERENCE_NAME
,
Context
.
MODE_PRIVATE
);
if
(
prefs
.
getString
(
AccountManager
.
KEY_ACCOUNT_NAME
,
null
)
!=
null
){
//If user account is registered
prefs
.
edit
().
putBoolean
(
AppConstants
.
KEY_OMS_IS_WORKING
,
false
).
commit
();
if
(!
JobUtils
.
isScannerJobRegistered
(
context
))
{
//scanner job isn't registered then register it
JobUtils
.
scheduleScannerJob
(
context
);}
}
}
}
}
app/src/main/java/foundation/e/drive/services/ResetService.java
View file @
fe849af6
...
@@ -16,6 +16,9 @@ import android.content.SharedPreferences;
...
@@ -16,6 +16,9 @@ import android.content.SharedPreferences;
import
android.os.IBinder
;
import
android.os.IBinder
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.util.Log
;
import
android.util.Log
;
import
com.owncloud.android.lib.common.accounts.AccountUtils
;
import
java.io.File
;
import
java.io.File
;
import
foundation.e.drive.database.DbHelper
;
import
foundation.e.drive.database.DbHelper
;
import
foundation.e.drive.utils.AppConstants
;
import
foundation.e.drive.utils.AppConstants
;
...
@@ -64,12 +67,20 @@ public class ResetService extends Service {
...
@@ -64,12 +67,20 @@ public class ResetService extends Service {
result
=
this
.
deleteDatabase
(
DbHelper
.
DATABASE_NAME
);
result
=
this
.
deleteDatabase
(
DbHelper
.
DATABASE_NAME
);
Log
.
d
(
TAG
,
"Remove Database: "
+
result
);
Log
.
d
(
TAG
,
"Remove Database: "
+
result
);
//4. clear prefs
//4. preferences cleaning
prefs
.
edit
().
remove
(
AccountManager
.
KEY_ACCOUNT_NAME
)
.
remove
(
AccountManager
.
KEY_ACCOUNT_TYPE
)
//Remove the prefs file.
.
putBoolean
(
INITIALIZATION_HAS_BEEN_DONE
,
false
)
if
(!
this
.
deleteSharedPreferences
(
AppConstants
.
SHARED_PREFERENCE_NAME
)){
.
remove
(
INITIALFOLDERS_NUMBER
)
.
apply
();
//If removal failed, clear all data inside
prefs
.
edit
().
remove
(
AccountManager
.
KEY_ACCOUNT_NAME
)
.
remove
(
AccountManager
.
KEY_ACCOUNT_TYPE
)
.
putBoolean
(
INITIALIZATION_HAS_BEEN_DONE
,
false
)
.
remove
(
INITIALFOLDERS_NUMBER
)
.
remove
(
AppConstants
.
KEY_OMS_IS_WORKING
)
.
remove
(
AppConstants
.
KEY_LAST_SYNC_TIME
)
.
apply
();
}
//5. Unregister screenOffReceiver
//5. Unregister screenOffReceiver
result
=
CommonUtils
.
unregisterScreenOff
(
getApplicationContext
());
result
=
CommonUtils
.
unregisterScreenOff
(
getApplicationContext
());
...
...
app/src/main/java/foundation/e/drive/utils/JobUtils.java
View file @
fe849af6
...
@@ -54,4 +54,13 @@ public abstract class JobUtils {
...
@@ -54,4 +54,13 @@ public abstract class JobUtils {
public
static
void
stopScheduledJob
(
Context
context
,
int
jobId
){
public
static
void
stopScheduledJob
(
Context
context
,
int
jobId
){
context
.
getSystemService
(
JobScheduler
.
class
).
cancel
(
jobId
);
context
.
getSystemService
(
JobScheduler
.
class
).
cancel
(
jobId
);
}
}
/**
* tell if the scannerJob is already registered or not
* @param context
* @return true if is registered, false either
*/
public
static
boolean
isScannerJobRegistered
(
Context
context
){
return
(
context
.
getSystemService
(
JobScheduler
.
class
).
getPendingJob
(
ScannerJobId
)
!=
null
);
}
}
}
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