Commit d307eb70 authored by Jonathan Klee's avatar Jonathan Klee
Browse files

Reset OperationManagerService setting

Reset OperationManagerService setting if service gets killed
and also at boot so that OperationManagerService always run
again if something bad happens.
parent 357ffca8
Pipeline #155291 passed with stage
in 4 minutes and 48 seconds
......@@ -32,10 +32,10 @@ public class EdriveApplication extends Application {
super.onCreate();
Log.i(TAG, "Starting");
resetOperationManagerSetting();
SharedPreferences prefs = getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE);
if (prefs.getString(AccountManager.KEY_ACCOUNT_NAME, null) != null) {
prefs.edit().putBoolean(AppConstants.KEY_OMS_IS_WORKING, false).commit();
scheduleScannerJob();
} else {
Account mAccount = CommonUtils.getAccount(getString(R.string.eelo_account_type), AccountManager.get(this));
......@@ -44,7 +44,6 @@ public class EdriveApplication extends Application {
String accountType = mAccount.type;
prefs.edit().putString(AccountManager.KEY_ACCOUNT_NAME, accountName)
.putBoolean(AppConstants.KEY_OMS_IS_WORKING, false)
.putString(AccountManager.KEY_ACCOUNT_TYPE, accountType)
.apply();
......@@ -59,6 +58,12 @@ public class EdriveApplication extends Application {
}
}
private void resetOperationManagerSetting() {
getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE).edit()
.putBoolean(AppConstants.KEY_OMS_IS_WORKING, false)
.apply();
}
@Override
public void onLowMemory() {
super.onLowMemory();
......
......@@ -290,4 +290,12 @@ public class OperationManagerService extends Service implements OnRemoteOperatio
public IBinder onBind(Intent intent) {
throw new UnsupportedOperationException();
}
@Override
public void onLowMemory() {
Log.w(TAG, "System is low on memory. Service might get killed. Setting KEY_OMS_IS_WORKING to false");
getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE).edit()
.putBoolean(AppConstants.KEY_OMS_IS_WORKING, false)
.apply();
}
}
File mode changed from 100644 to 100755
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment