Fixing LauncherAppCompoent not available for isolated context

In those cases, creating a new LauncherAppCompoent and storing it in
the application context

Bug: 372180905
Test: atest LauncherComponentProviderTest
Flag: EXEMPT bugfix
Change-Id: Ibf517a23801138b1fa18e8e4a7adbdedb994365b
This commit is contained in:
Sunny Goyal
2024-11-14 10:38:31 -08:00
parent 1297e9eb98
commit 5861ee437a
3 changed files with 133 additions and 4 deletions
@@ -18,8 +18,8 @@ package com.android.launcher3.util;
import android.content.Context;
import com.android.launcher3.LauncherApplication;
import com.android.launcher3.dagger.LauncherAppComponent;
import com.android.launcher3.dagger.LauncherComponentProvider;
import java.util.function.Function;
@@ -37,8 +37,6 @@ public class DaggerSingletonObject<T> {
}
public T get(Context context) {
LauncherAppComponent component =
((LauncherApplication) context.getApplicationContext()).getAppComponent();
return mFunction.apply(component);
return mFunction.apply(LauncherComponentProvider.get(context));
}
}