mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Fixing MainThreadInitializedObject
> Making SafeCloseable implementation mandatory, to prevent leaks during test and preview > Removing getNoCreate method and defining executeIfCreated to avoid null pointer exceptions > Fixing sandbox value leaking into main, by Checking sandbox against App context > Converting sanbox to an interface instead a class Bug: 335280439 Test: Presubmit Flag: None Change-Id: I951dcde871898e745ff6490a1c4f8fd1512888f5
This commit is contained in:
@@ -35,6 +35,7 @@ import androidx.room.Room;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.launcher3.model.AppShareabilityDatabase.ShareabilityDao;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.launcher3.util.SafeCloseable;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.util.ArrayList;
|
||||
@@ -47,7 +48,7 @@ import java.util.function.Consumer;
|
||||
* Each app's status is retrieved from the Play Store's API. Statuses are cached in order
|
||||
* to limit extraneous calls to that API (which can be time-consuming).
|
||||
*/
|
||||
public class AppShareabilityManager {
|
||||
public class AppShareabilityManager implements SafeCloseable {
|
||||
@Retention(SOURCE)
|
||||
@IntDef({
|
||||
ShareabilityStatus.UNKNOWN,
|
||||
@@ -194,6 +195,11 @@ public class AppShareabilityManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
mDatabase.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a testable instance of this class
|
||||
* This instance allows database queries on the main thread
|
||||
|
||||
Reference in New Issue
Block a user