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

Commit a3fd541b authored by c_jyuan's avatar c_jyuan Committed by Linux Build Service Account
Browse files

Send broadcast to MediaScannerReceiver to refresh gallery

After restore file, the pics can only be seen in FileManager,
so send broadcast to MediaScannerReceiver to refresh the datebase,
then the pics can be seen in the gallery.

Change-Id: I43cd8edc0c96c1d845314c7760b367f85485a6e5
parent 05f47f44
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -13,6 +13,9 @@ import android.util.Slog;

import java.io.File;
import java.io.IOException;
import android.os.SystemProperties;
import android.content.Intent;
import android.net.Uri;

public class SharedStorageAgent extends FullBackupAgent {
    static final String TAG = "SharedStorageAgent";
@@ -93,5 +96,13 @@ public class SharedStorageAgent extends FullBackupAgent {
        }

        FullBackup.restoreFile(data, size, type, -1, mtime, outFile);
        if (isStrictOpEnable()) {
            getApplicationContext().sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
                    Uri.fromFile(outFile)));
        }
    }

    private boolean isStrictOpEnable() {
        return SystemProperties.getBoolean("persist.sys.strict_op_enable", false);
    }
}