Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8feb0aee 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 35d98cdf
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -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();
+7 −0
Original line number Diff line number Diff line
@@ -315,4 +315,11 @@ public class OperationManagerService extends Service implements OnRemoteOperatio
        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();
    }
}

gradlew

100644 → 100755
+0 −0

File mode changed from 100644 to 100755.