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

Commit 66e09afd authored by Alexander Dorokhine's avatar Alexander Dorokhine
Browse files

Switch to a non-hidden way to compute data path and switch to subdir.

We need to store other things in the appsearch data dir other than what
Icing stores, such as the storage info cache.

Bug: 177685938
Bug: 181787682
Test: Presubmit
Change-Id: I903c34a2c891d617217d44f5126d0d31c8c6bf39
parent ad37babc
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.Context;
import android.os.Environment;
import android.os.UserHandle;
import android.util.ArrayMap;
import android.util.Log;

import com.android.internal.annotations.GuardedBy;
import com.android.server.appsearch.external.localstorage.AppSearchImpl;
@@ -38,9 +39,10 @@ import java.util.Objects;
 * Manages the lifecycle of instances of {@link AppSearchImpl}.
 *
 * <p>These instances are managed per unique device-user.
 * @hide
 */
public final class ImplInstanceManager {
    private static final String APP_SEARCH_DIR = "appSearch";
    private static final String TAG = "AppSearchImplInstanceMa";

    private static ImplInstanceManager sImplInstanceManager;

@@ -71,8 +73,11 @@ public final class ImplInstanceManager {
     * <p>This folder should only be accessed after unlock.
     */
    public static File getAppSearchDir(@NonNull UserHandle userHandle) {
        return new File(
                Environment.getDataSystemCeDirectory(userHandle.getIdentifier()), APP_SEARCH_DIR);
        // Duplicates the implementation of Environment#getDataSystemCeDirectory
        // TODO(b/191059409): Unhide Environment#getDataSystemCeDirectory and switch to it.
        File systemCeDir = new File(Environment.getDataDirectory(), "system_ce");
        File systemCeUserDir = new File(systemCeDir, String.valueOf(userHandle.getIdentifier()));
        return new File(systemCeUserDir, "appSearch");
    }

    /**
@@ -154,8 +159,10 @@ public final class ImplInstanceManager {
            @Nullable AppSearchLogger logger)
            throws AppSearchException {
        File appSearchDir = getAppSearchDir(userHandle);
        File icingDir = new File(appSearchDir, "icing");
        Log.i(TAG, "Creating new AppSearch instance at: " + icingDir);
        return AppSearchImpl.create(
                appSearchDir,
                icingDir,
                userContext,
                /*logger=*/ null,
                new FrameworkOptimizeStrategy());