Created LauncherWidgetHolder as a wrapper for LauncherAppWidgetHost

The wrapper class is created for further changes that will run the wrapped host in the background.

Test: N/A
Bug: 235358918
Change-Id: I9bd6fc2749c5d4a4d3391fb75d0c3ff1e13d17bf
This commit is contained in:
Sihua Ma
2022-10-03 16:01:48 -07:00
parent 381ba3319d
commit 0593a0d3ec
11 changed files with 244 additions and 58 deletions

View File

@@ -59,7 +59,7 @@ public class WidgetHostViewLoader implements DragController.DragListener {
// Cleanup widget id
if (mWidgetLoadingId != -1) {
mLauncher.getAppWidgetHost().deleteAppWidgetId(mWidgetLoadingId);
mLauncher.getAppWidgetHolder().deleteAppWidgetId(mWidgetLoadingId);
mWidgetLoadingId = -1;
}
@@ -69,7 +69,7 @@ public class WidgetHostViewLoader implements DragController.DragListener {
Log.d(TAG, "...removing widget from drag layer");
}
mLauncher.getDragLayer().removeView(mInfo.boundWidget);
mLauncher.getAppWidgetHost().deleteAppWidgetId(mInfo.boundWidget.getAppWidgetId());
mLauncher.getAppWidgetHolder().deleteAppWidgetId(mInfo.boundWidget.getAppWidgetId());
mInfo.boundWidget = null;
}
}
@@ -94,7 +94,7 @@ public class WidgetHostViewLoader implements DragController.DragListener {
mBindWidgetRunnable = new Runnable() {
@Override
public void run() {
mWidgetLoadingId = mLauncher.getAppWidgetHost().allocateAppWidgetId();
mWidgetLoadingId = mLauncher.getAppWidgetHolder().allocateAppWidgetId();
if (LOGD) {
Log.d(TAG, "Binding widget, id: " + mWidgetLoadingId);
}
@@ -116,7 +116,7 @@ public class WidgetHostViewLoader implements DragController.DragListener {
if (mWidgetLoadingId == -1) {
return;
}
AppWidgetHostView hostView = mLauncher.getAppWidgetHost().createView(
AppWidgetHostView hostView = mLauncher.getAppWidgetHolder().createView(
(Context) mLauncher, mWidgetLoadingId, pInfo);
mInfo.boundWidget = hostView;