Override RemoteViews#getApplicationInfo
The delegate avoids calling into ActivityThread and obtains
ApplicationInfo by directly asking the BridgeContext.
Test: Tested from Studio
Bug: 193003647
Change-Id: Ie5be384994b2183a2e27483968cc9a61d28cbbca
(cherry picked from commit 5c947a2a793bd998610225ae8392d7cb700e2c97)
diff --git a/bridge/src/android/widget/RemoteViews_Delegate.java b/bridge/src/android/widget/RemoteViews_Delegate.java
new file mode 100644
index 0000000..35809d5
--- /dev/null
+++ b/bridge/src/android/widget/RemoteViews_Delegate.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.widget;
+
+import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
+
+import android.content.pm.ApplicationInfo;
+
+import static com.android.layoutlib.bridge.impl.RenderAction.getCurrentContext;
+
+public class RemoteViews_Delegate {
+ @LayoutlibDelegate
+ public static ApplicationInfo getApplicationInfo(String packageName, int userId) {
+ return getCurrentContext().getApplicationInfo();
+ }
+}
diff --git a/create/src/com/android/tools/layoutlib/create/CreateInfo.java b/create/src/com/android/tools/layoutlib/create/CreateInfo.java
index eff7b67..a13f1f8 100644
--- a/create/src/com/android/tools/layoutlib/create/CreateInfo.java
+++ b/create/src/com/android/tools/layoutlib/create/CreateInfo.java
@@ -268,6 +268,7 @@
"android.view.ViewRootImpl#isInTouchMode",
"android.view.WindowManagerGlobal#getWindowManagerService",
"android.view.inputmethod.InputMethodManager#isInEditMode",
+ "android.widget.RemoteViews#getApplicationInfo",
"com.android.internal.util.XmlUtils#convertValueToInt",
"com.android.internal.view.menu.MenuBuilder#createNewMenuItem",
"dalvik.system.VMRuntime#getNotifyNativeInterval",