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

Commit 4b86583a authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

6691 s add lint

parent fef365cf
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -4,8 +4,9 @@ variables:
  SENTRY_DSN: "${SENTRY_DSN}"

stages:
  - test
  - build
  - test


before_script:
  - export GRADLE_USER_HOME=$(pwd)/.gradle
@@ -33,6 +34,12 @@ test:
      junit: app/build/test-results/*/TEST-*.xml


lint:
  stage: build
  script:
    - ./gradlew lintRelease


build:
  stage: build
  script:
+17 −9
Original line number Diff line number Diff line
@@ -5,9 +5,11 @@

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
    <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"
        tools:ignore="ProtectedPermissions" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/> <!-- for Android 30+ -->
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
        tools:ignore="ScopedStorage" /> <!-- for Android 30+ -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <!-- needed for PersistedJob -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
@@ -23,7 +25,8 @@
    <permission
        android:name="android.permission.FORCE_STOP_PACKAGES"
        android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
        android:protectionLevel="signature" />
        android:protectionLevel="signature"
        tools:ignore="ReservedSystemPermission" />

    <application
        android:name=".EdriveApplication"
@@ -43,7 +46,7 @@
        <receiver
            android:name=".widgets.EDriveWidget"
            android:exported="true"
            android:label="@string/app_widget_description">
            android:label="@string/my_cloud_account">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
@@ -61,25 +64,29 @@
            android:authorities="foundation.e.drive.providers.MediasSyncProvider"
            android:enabled="true"
            android:exported="true"
            android:label="@string/account_setting_media_sync" />
            android:label="@string/account_setting_media_sync"
            tools:ignore="ExportedContentProvider" />
        <provider
            android:name=".providers.SettingsSyncProvider"
            android:authorities="foundation.e.drive.providers.SettingsSyncProvider"
            android:enabled="true"
            android:exported="true"
            android:label="@string/account_setting_app_sync" />
            android:label="@string/account_setting_app_sync"
            tools:ignore="ExportedContentProvider" />
        <provider
            android:name=".providers.MeteredConnectionAllowedProvider"
            android:authorities="foundation.e.drive.providers.MeteredConnectionAllowedProvider"
            android:enabled="true"
            android:exported="true"
            android:label="@string/account_setting_metered_network" />
            android:label="@string/account_setting_metered_network"
            tools:ignore="ExportedContentProvider" />

        <!-- Services -->
        <service
            android:name=".services.InitializerService"
            android:enabled="true"
            android:exported="true">
            android:exported="true"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="drive.services.InitializerService" />
            </intent-filter>
@@ -99,7 +106,8 @@
        <receiver
            android:name=".receivers.DebugCmdReceiver"
            android:enabled="true"
            android:exported="true">
            android:exported="true"
            tools:ignore="ExportedReceiver">
            <intent-filter>
                <action android:name="foundation.e.drive.action.FORCE_SYNC" />
                <action android:name="foundation.e.drive.action.DUMP_DATABASE"/>
+12 −10
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@ import android.content.Context;
import android.content.Intent;
import android.os.FileObserver;

import androidx.annotation.NonNull;

import com.owncloud.android.lib.resources.files.FileUtils;

import java.io.File;
@@ -37,12 +39,12 @@ public class FileEventListener {
    private final Context appContext;
    private final SynchronizationServiceConnection serviceConnection = new SynchronizationServiceConnection();

    public FileEventListener(Context applicationContext) {
    public FileEventListener(@NonNull Context applicationContext) {
        Timber.tag(FileEventListener.class.getSimpleName());
        this.appContext = applicationContext;
    }

    public void onEvent(int event, File file) {
    public void onEvent(int event, @NonNull File file) {
        if (file.isHidden()) return;

        if (file.isDirectory()) {
@@ -57,7 +59,7 @@ public class FileEventListener {
     * @param event the event mask. CLOSE_WRITE, DELETE & MOVE_SELF are handled
     * @param file the file concerned by the event
     */
    private void handleFileEvent(int event, File file) {
    private void handleFileEvent(int event, @NonNull File file) {
        switch(event) {
            case FileObserver.CLOSE_WRITE: //todo it is called two times per file except if screenshot by example or take a picture
                handleFileCloseWrite(file);
@@ -78,7 +80,7 @@ public class FileEventListener {
     * @param event FileEvent mask. CREATE, CLOSE_WRITE, DELETE, MOVE_SELF
     * @param dir directory concerned by file event
     */
    private void handleDirectoryEvent(int event, File dir) {
    private void handleDirectoryEvent(int event, @NonNull File dir) {
        switch(event) {
            case FileObserver.CREATE:
                handleDirectoryCreate(dir);
@@ -101,7 +103,7 @@ public class FileEventListener {
     * Send syncRequest to SynchronizationService
     * @param request
     */
    private void sendSyncRequestToSynchronizationService(SyncRequest request) {
    private void sendSyncRequestToSynchronizationService(@NonNull SyncRequest request) {
        Timber.d("Sending a SyncRequest for %s", request.getSyncedFileState().getName());
        if (serviceConnection.isBound()) {
            serviceConnection.getSynchronizationService().queueSyncRequest(request);
@@ -116,7 +118,7 @@ public class FileEventListener {
     * if it's parent directory is already in the database
     * @param directory
     */
    private void handleDirectoryCreate(File directory) {
    private void handleDirectoryCreate(@NonNull File directory) {
        Timber.d("handleDirectoryCreate( %s )",directory.getAbsolutePath());
        final String parentPath = CommonUtils.getLocalPath(directory.getParentFile());
        final SyncedFolder parentFolder = DbHelper.getSyncedFolderByLocalPath(parentPath, appContext);
@@ -131,7 +133,7 @@ public class FileEventListener {
     * todo: check in which condition a directory can generate a close_write
     * @param directory
     */
    private void handleDirectoryCloseWrite(File directory) {
    private void handleDirectoryCloseWrite(@NonNull File directory) {
        final String fileLocalPath = CommonUtils.getLocalPath(directory);
        Timber.d("handleDirectoryCloseWrite( %s )",fileLocalPath );
        final SyncedFolder folder = DbHelper.getSyncedFolderByLocalPath(fileLocalPath, appContext);
@@ -147,7 +149,7 @@ public class FileEventListener {
     * Handle a file deletion event for a directory
     * @param directory
     */
    private void handleDirectoryDelete(File directory) {
    private void handleDirectoryDelete(@NonNull File directory) {
        final String fileLocalPath = CommonUtils.getLocalPath(directory);
        Timber.d("handleDirectoryDelete( %s )", fileLocalPath);
        SyncedFolder folder = DbHelper.getSyncedFolderByLocalPath(fileLocalPath, appContext);
@@ -174,7 +176,7 @@ public class FileEventListener {
     * handle a file close_write event for a file which is not a directory
     * @param file
     */
    private void handleFileCloseWrite(File file) {
    private void handleFileCloseWrite(@NonNull File file) {
        final String fileLocalPath = CommonUtils.getLocalPath(file);
        Timber.d("handleFileCloseWrite( %s )", fileLocalPath);
        SyncRequest request = null;
@@ -217,7 +219,7 @@ public class FileEventListener {
     * Handle a file deletion event for a file which is not a directory
     * @param file
     */
    private void handleFileDelete(File file) {
    private void handleFileDelete(@NonNull File file) {
        final String fileLocalPath = CommonUtils.getLocalPath(file);
        Timber.d("handleFileDelete( %s )",fileLocalPath);
        final SyncedFileState fileState = DbHelper.loadSyncedFile( appContext, fileLocalPath, true);
+13 −8
Original line number Diff line number Diff line
@@ -11,6 +11,9 @@ package foundation.e.drive.FileObservers;
import android.content.Context;
import android.os.FileObserver;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.io.File;
import java.io.FileFilter;
import java.util.HashMap;
@@ -26,7 +29,8 @@ import foundation.e.drive.models.SyncedFolder;
 */
public class RecursiveFileObserver extends FileObserver {
    private final HashMap<String, FileObserver> observers = new HashMap<>();
    private static final  FileFilter WATCHABLE_DIRECTORIES_FILTER = new FileFilter() {
    // protected to avoid SyntheticAccessor
    protected static final  FileFilter WATCHABLE_DIRECTORIES_FILTER = new FileFilter() {
        @Override
        public boolean accept(File file) {
            return file.isDirectory() && !file.getName().startsWith(".");
@@ -39,11 +43,11 @@ public class RecursiveFileObserver extends FileObserver {
    private int mask;
    private FileEventListener listener;

    public RecursiveFileObserver(Context applicationContext, String path, FileEventListener listener) {
    public RecursiveFileObserver(@NonNull Context applicationContext, @NonNull String path, @Nullable FileEventListener listener) {
        this(applicationContext, path, ALL_EVENTS, listener);
    }

    public RecursiveFileObserver(Context applicationContext, String path, int mask, FileEventListener listener) {
    public RecursiveFileObserver(@NonNull Context applicationContext, @NonNull String path, int mask, @Nullable FileEventListener listener) {
        super(path, mask);
        this.path = path;
        this.mask = mask | FileObserver.CREATE | FileObserver.DELETE_SELF;
@@ -53,7 +57,7 @@ public class RecursiveFileObserver extends FileObserver {


    @Override
    public void onEvent(int event, String path) {
    public void onEvent(int event, @Nullable String path) {
        File file;
        if (path == null) {
            file = new File(this.path);
@@ -64,7 +68,8 @@ public class RecursiveFileObserver extends FileObserver {
        notify(event, file);
    }

    private void notify(int event, File file) {
    // protected to avoid SyntheticAccessor
    protected void notify(int event, @NonNull File file) {
        if (listener != null) {
            listener.onEvent(event & FileObserver.ALL_EVENTS, file);
        }
@@ -102,7 +107,7 @@ public class RecursiveFileObserver extends FileObserver {
     * Start watching a single file
     * @param path
     */
    private void startWatching(String path) {
    protected void startWatching(@NonNull String path) {
        synchronized (observers) {
            FileObserver observer = observers.remove(path);
            if (observer != null) {
@@ -127,7 +132,7 @@ public class RecursiveFileObserver extends FileObserver {
     * Stop watching a single file
     * @param path
     */
    private void stopWatching(String path) {
    protected void stopWatching(@NonNull String path) {
        synchronized (observers) {
            FileObserver observer = observers.remove(path);
            if (observer != null) {
@@ -149,7 +154,7 @@ public class RecursiveFileObserver extends FileObserver {
        }

        @Override
        public void onEvent(int event, String path) {
        public void onEvent(int event, @Nullable String path) {
            File file;
            if (path == null) {
                file = new File(filePath);
+5 −4
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

@@ -48,7 +49,7 @@ public class AccountsActivity extends AppCompatActivity {
    private ActivityAccountsBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Timber.tag(AccountsActivity.class.getSimpleName());
        binding = ActivityAccountsBinding.inflate(getLayoutInflater());
@@ -98,7 +99,7 @@ public class AccountsActivity extends AppCompatActivity {
                totalShownQuota = CommonUtils.humanReadableByteCountBin(totalQuotaLong);
            }
        } catch (NumberFormatException ignored) {
            Timber.i("Bad totalQuotaLong " + totalQuota);
            Timber.i("Bad totalQuotaLong %s", totalQuota);
        }

        try {
@@ -107,7 +108,7 @@ public class AccountsActivity extends AppCompatActivity {
                usedShownQuota = CommonUtils.humanReadableByteCountBin(usedQuotaLong);
            }
        } catch (NumberFormatException ignore) {
            Timber.i("Bad usedQuotaLong " + usedQuota);
            Timber.i("Bad usedQuotaLong %s", usedQuota);
        }

        binding.plan.setText(getString(R.string.free_plan, totalShownQuota));
@@ -158,7 +159,7 @@ public class AccountsActivity extends AppCompatActivity {
        Glide.with(this)
                .load(client.getBaseUri() + NON_OFFICIAL_AVATAR_PATH
                        + client.getCredentials().getUsername() + "/" + 300)
                .error(R.mipmap.ic_eelo_foreground)
                .error(R.drawable.ic_murena_eel)
                .into(binding.avatar);
        binding.avatar.setVisibility(View.VISIBLE);
    }
Loading