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

Commit b345f093 authored by Arnau Vàzquez's avatar Arnau Vàzquez
Browse files

Merge branch 'issue_1491_Fix_oreo' into 'v1-oreo'

Fix issue when eDrive doesn't detect user account after update

See merge request e/apps/eDrive!32
parents fbe57ef8 e28f16d0
Loading
Loading
Loading
Loading
Loading
+35 −25
Original line number Diff line number Diff line
@@ -7,8 +7,7 @@ http://www.gnu.org/licenses/gpl.html
-->
<!-- @author Vincent Bourgmayer -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="foundation.e.drive"
    android:sharedUserId="android.uid.system" >
    package="foundation.e.drive">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
@@ -18,7 +17,9 @@ http://www.gnu.org/licenses/gpl.html
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
    <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
    <permission android:name="android.permission.FORCE_STOP_PACKAGES"

    <permission
        android:name="android.permission.FORCE_STOP_PACKAGES"
        android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
        android:protectionLevel="signature" />

@@ -29,53 +30,62 @@ http://www.gnu.org/licenses/gpl.html
        android:roundIcon="@mipmap/ic_eelo_round">
        <!-- Providers -->
        <provider
            android:authorities="foundation.e.drive.providers.MediasSyncProvider"
            android:name=".providers.MediasSyncProvider"
            android:label="Pictures and videos"
            android:authorities="foundation.e.drive.providers.MediasSyncProvider"
            android:enabled="true"
            android:exported="true"/>
            android:exported="true"
            android:label="Pictures and videos" />
        <provider
            android:authorities="foundation.e.drive.providers.SettingsSyncProvider"
            android:name=".providers.SettingsSyncProvider"
            android:label="Application settings"
            android:authorities="foundation.e.drive.providers.SettingsSyncProvider"
            android:enabled="true"
            android:exported="true"/>
            android:exported="true"
            android:label="Application settings" />

        <!-- Services -->
        <service android:name=".services.InitializerService"
        <service
            android:name=".services.InitializerService"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="drive.services.InitializerService" />
            </intent-filter>
        </service>
        <service android:name=".services.ResetService"
        <service
            android:name=".services.ResetService"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="drive.services.ResetService" />
            </intent-filter>
        </service>
        <service android:name=".jobs.ScannerJob"
        <service
            android:name=".jobs.ScannerJob"
            android:permission="android.permission.BIND_JOB_SERVICE" />
        <service android:name=".services.ObserverService"
        <service
            android:name=".services.ObserverService"
            android:enabled="true" />
        <service android:name=".services.OperationManagerService" />

        <!-- Receivers -->
        <receiver android:name=".receivers.BootCompleteReceiver"
        <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>
                <action android:name="android.intent.action.BATTERY_LOW" />
                <action android:name="android.intent.action.BATTERY_OKAY" />
            </intent-filter>
        </receiver>
        <receiver android:name=".receivers.PackageEventReceiver" android:enabled="true">
        <receiver
            android:name=".receivers.PackageEventReceiver"
            android:enabled="true">
            <intent-filter>
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
            </intent-filter>
+28 −7
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@

package foundation.e.drive.receivers;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -15,19 +16,20 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;

import foundation.e.drive.R;
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();


        String intentAction = intent.getAction();

        if (intentAction == null) {
            Log.e(TAG, "intent Action is null");
@@ -41,6 +43,25 @@ public class BootCompleteReceiver extends BroadcastReceiver {
                    //scanner job isn't registered then register it
                    JobUtils.scheduleScannerJob(context);
                }
            } else {

                Account mAccount = CommonUtils.getAccount(context.getString(R.string.eelo_account_type), AccountManager.get(context));

                if (mAccount != null) {
                    String accountName = mAccount.name;
                    String accountType = mAccount.type;

                    //If data come from intent, store them into pref because there aren't stored
                    prefs.edit().putString(AccountManager.KEY_ACCOUNT_NAME, accountName)
                            .putBoolean(AppConstants.KEY_OMS_IS_WORKING, false)
                            .putString(AccountManager.KEY_ACCOUNT_TYPE, accountType)
                            .apply();

                    if (!JobUtils.isScannerJobRegistered(context)) {
                        //scanner job isn't registered then register it
                        JobUtils.scheduleScannerJob(context);
                    }
                }
            }
        }
    }
+73 −44
Original line number Diff line number Diff line
@@ -22,13 +22,17 @@ import android.net.Uri;
import android.support.annotation.NonNull;
import android.util.Log;
import android.webkit.MimeTypeMap;

import com.owncloud.android.lib.common.OwnCloudBasicCredentials;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientFactory;
import com.owncloud.android.lib.common.accounts.AccountUtils;
import com.owncloud.android.lib.resources.files.FileUtils;

import java.io.File;

import foundation.e.drive.receivers.ScreenOffReceiver;

import static foundation.e.drive.utils.AppConstants.MEDIASYNC_PROVIDER_AUTHORITY;
import static foundation.e.drive.utils.AppConstants.SETTINGSYNC_PROVIDER_AUTHORITY;

@@ -43,6 +47,7 @@ public abstract class CommonUtils {
    /**
     * Set ServiceUncaughtExceptionHandler to be the MainThread Exception Handler
     * Or update the service which use it
     *
     * @param service current service
     */
    public static void setServiceUnCaughtExceptionHandler(Service service) {
@@ -58,6 +63,7 @@ public abstract class CommonUtils {

    /**
     * Unregister from screeOffReceiver component
     *
     * @param context app context
     * @return true if unregistration was successful or false if it encounter an exception
     */
@@ -75,6 +81,7 @@ public abstract class CommonUtils {

    /**
     * This method retrieve Account corresponding to account's name and type
     *
     * @param accountName Account Name, shouldn't be null
     * @param accountType account type
     * @param am          Account Manager
@@ -90,9 +97,26 @@ public abstract class CommonUtils {
        return null;
    }

    /**
     * This method retrieve Account corresponding to account's type
     *
     * @param accountType account type
     * @param am          Account Manager
     * @return Account or null if not found
     */
    public static Account getAccount(String accountType, @NonNull AccountManager am) {
        Account[] accounts = am.getAccounts();
        for (int i = -1, size = accounts.length; ++i < size; ) {
            if (accounts[i].type.equals(accountType)) {
                return accounts[i];
            }
        }
        return null;
    }

    /**
     * Say if synchronisation is allowed
     *
     * @param account                Account used for synchronisation
     * @param syncedFileStateIsMedia true if the concerned syncedFileState is a media's type element, false if it is a settings's type element
     * @return
@@ -104,14 +128,17 @@ public abstract class CommonUtils {

    /**
     * Say if Media Sync is enabled in account
     *
     * @param account Concerned account
     * @return true if media sync enabled
     */
    public static boolean isMediaSyncEnabled(Account account) {
        return ContentResolver.getSyncAutomatically(account, MEDIASYNC_PROVIDER_AUTHORITY);
    }

    /**
     * Say if Settings Sync is enabled in account
     *
     * @param account Concerned account
     * @return true if enabled
     */
@@ -144,6 +171,7 @@ public abstract class CommonUtils {

    /**
     * Return name of a file from its access path
     *
     * @param path File name will be extracted from this path.  Do not provide directory path
     * @return String, the last part after separator of path or null if invalid path has been provided
     */
@@ -237,9 +265,10 @@ public abstract class CommonUtils {

    /**
     * Used for debug
     * @dev-only
     *
     * @param f File to debug
     * @return String showing value of file's properties
     * @dev-only
     */
    public static String debugFile(File f) {
        return "File name: " + f.getName()
+1 −0
Original line number Diff line number Diff line
<resources>
    <string name="app_name">/e/ Drive</string>
    <string name="eelo_account_type" translatable="false">e.foundation.webdav.eelo</string>
</resources>