diff options
author | Jerome Gaillard <jgaillard@google.com> | 2020-12-02 16:35:46 +0000 |
---|---|---|
committer | Jerome Gaillard <jgaillard@google.com> | 2020-12-04 12:18:51 +0000 |
commit | 4ddfc794db54deacea89d7ba8c68fd70386eec9d (patch) | |
tree | 263deb631fa198715285b19702b1aa4baa7fda84 /layoutlib | |
parent | 8ba97709110bd65b098791ea80c82d65073bcbd1 (diff) | |
download | idea-4ddfc794db54deacea89d7ba8c68fd70386eec9d.tar.gz |
Rename layoutlib plugins to re-enable native for all
Change Layoutlib Native to Layoutlib and Layoutlib Standard to
Layoutlib Legacy. That will re-enable layoutlib native for all
users, as both plugins have a new id.
Bug: 174144030
Test: N/A
Change-Id: I52705ee7c42938a0fabce78dc2e26ea6962646c6
Diffstat (limited to 'layoutlib')
-rw-r--r-- | layoutlib/src/META-INF/plugin.xml | 11 | ||||
-rw-r--r-- | layoutlib/src/com/android/layoutlib/NativeCrashHandling.java | 43 |
2 files changed, 52 insertions, 2 deletions
diff --git a/layoutlib/src/META-INF/plugin.xml b/layoutlib/src/META-INF/plugin.xml index e46a93b2f03..5b0b1b975f7 100644 --- a/layoutlib/src/META-INF/plugin.xml +++ b/layoutlib/src/META-INF/plugin.xml @@ -14,11 +14,18 @@ ~ limitations under the License. --> <idea-plugin> - <id>com.android.layoutlib.standard</id> - <name>Layoutlib Standard</name> + <id>com.android.layoutlib</id> + <name>Layoutlib</name> <version>1.0</version> <vendor>Google</vendor> <description>Provides a library for rendering Android resources</description> + <application-components> + <component> + <implementation-class>com.android.layoutlib.NativeCrashHandling</implementation-class> + <headless-implementation-class/> + </component> + </application-components> + </idea-plugin>
\ No newline at end of file diff --git a/layoutlib/src/com/android/layoutlib/NativeCrashHandling.java b/layoutlib/src/com/android/layoutlib/NativeCrashHandling.java new file mode 100644 index 00000000000..fd948248849 --- /dev/null +++ b/layoutlib/src/com/android/layoutlib/NativeCrashHandling.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2019 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 com.android.layoutlib; + +import com.android.layoutlib.bridge.Bridge; +import com.intellij.internal.statistic.analytics.StudioCrashDetails; +import com.intellij.internal.statistic.analytics.StudioCrashDetection; +import com.intellij.openapi.components.BaseComponent; +import java.util.List; +import org.jetbrains.annotations.NotNull; + +public class NativeCrashHandling implements BaseComponent { + + @Override + public void initComponent() { + // If the previous run of Studio ended on a JVM crash caused by Layoutlib, pass the information to the Layoutlib Bridge + List<StudioCrashDetails> crashes = StudioCrashDetection.reapCrashDescriptions(); + for (StudioCrashDetails crash : crashes) { + if (isCrashCausedByLayoutlib(crash)) { + Bridge.setNativeCrash(true); + return; + } + } + } + + private static boolean isCrashCausedByLayoutlib(@NotNull StudioCrashDetails crash) { + return crash.isJvmCrash() && + (crash.getErrorThread().contains("Layoutlib Render Thread") || crash.getErrorFrame().contains("libandroid_runtime")); + } +} |