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

Commit 23e3c3ff authored by Mohit Mali's avatar Mohit Mali
Browse files

- Removed sharedUserId

- Fix issue when eDrive doesn't recognise User account after update
parent f7ba4bd8
Loading
Loading
Loading
Loading
Loading
+31 −23
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" />
@@ -26,53 +25,62 @@ http://www.gnu.org/licenses/gpl.html

        <!-- Provider -->
        <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>
+31 −7
Original line number Diff line number Diff line
package foundation.e.drive.receivers;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -7,32 +8,55 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;

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

        SharedPreferences prefs = context.getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE);

        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);}
                    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);
                }
            }
        }
    }
+85 −54
Original line number Diff line number Diff line
@@ -24,13 +24,17 @@ import android.support.annotation.NonNull;
import android.support.v4.app.NotificationCompat;
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;

@@ -45,6 +49,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) {
@@ -59,9 +64,9 @@ 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,15 +80,17 @@ public abstract class CommonUtils {
        }
        return true;
    }

    /**
     * Send notification to UI.
     * @dev-only
     *
     * @param context app context
     * @param id      notification ID
     * @param msg     Message of the notification
     * @param icon    Icon to use
     * @param pIntent intent to launch when user tap on the notif. Can be null
     * @param ticker  The ticker message, shown first. Can be null
     * @dev-only
     */
    public static void sendNotification(Context context, int id, String msg, int icon, PendingIntent pIntent, String ticker) {
        NotificationCompat.Builder builder =
@@ -103,6 +110,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
@@ -118,9 +126,27 @@ 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
@@ -132,14 +158,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
     */
@@ -172,6 +201,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
     */
@@ -265,9 +295,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">e.foundation.webdav.eelo</string>
</resources>