From 237f37b7f48eedab7ebf9d966197dfbb1b01b128 Mon Sep 17 00:00:00 2001 From: Tony Mak Date: Fri, 22 Mar 2019 13:35:40 +0000 Subject: [PATCH] Conversation Actions: support multiple models. This allows us to use the universal model when there is no model available for the supported language. Test: adb shell dumpsys textclassification. Observe that both en and univerisal actions model are listed properly. Test: Switch to traditional chinese, observe that url action is working. BUG: 128312720 Change-Id: I38258c8859e8ce505535ccf1f650ccf9daf64f46 --- .../view/textclassifier/TextClassifierImpl.java | 3 ++- .../LegacyIntentClassificationFactoryTest.java | 8 ++++++-- .../TemplateClassificationIntentFactoryTest.java | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/core/java/android/view/textclassifier/TextClassifierImpl.java b/core/java/android/view/textclassifier/TextClassifierImpl.java index cb44f79465efd..0f2e702ecd0d9 100644 --- a/core/java/android/view/textclassifier/TextClassifierImpl.java +++ b/core/java/android/view/textclassifier/TextClassifierImpl.java @@ -86,7 +86,8 @@ public final class TextClassifierImpl implements TextClassifier { new File("/data/misc/textclassifier/lang_id.model"); // Actions - private static final String ACTIONS_FACTORY_MODEL_FILENAME_REGEX = "actions_suggestions.model"; + private static final String ACTIONS_FACTORY_MODEL_FILENAME_REGEX = + "actions_suggestions\\.(.*)\\.model"; private static final File UPDATED_ACTIONS_MODEL = new File("/data/misc/textclassifier/actions_suggestions.model"); diff --git a/core/tests/coretests/src/android/view/textclassifier/intent/LegacyIntentClassificationFactoryTest.java b/core/tests/coretests/src/android/view/textclassifier/intent/LegacyIntentClassificationFactoryTest.java index 72d1ab1c9d0c7..e1ccd7523ebaa 100644 --- a/core/tests/coretests/src/android/view/textclassifier/intent/LegacyIntentClassificationFactoryTest.java +++ b/core/tests/coretests/src/android/view/textclassifier/intent/LegacyIntentClassificationFactoryTest.java @@ -64,7 +64,9 @@ public class LegacyIntentClassificationFactoryTest { null, null, null, - null); + null, + 0, + 0); List intents = mLegacyIntentClassificationFactory.create( InstrumentationRegistry.getContext(), @@ -98,7 +100,9 @@ public class LegacyIntentClassificationFactoryTest { null, null, null, - null); + null, + 0, + 0); List intents = mLegacyIntentClassificationFactory.create( InstrumentationRegistry.getContext(), diff --git a/core/tests/coretests/src/android/view/textclassifier/intent/TemplateClassificationIntentFactoryTest.java b/core/tests/coretests/src/android/view/textclassifier/intent/TemplateClassificationIntentFactoryTest.java index ccf8607b84d9e..2e97e638ba573 100644 --- a/core/tests/coretests/src/android/view/textclassifier/intent/TemplateClassificationIntentFactoryTest.java +++ b/core/tests/coretests/src/android/view/textclassifier/intent/TemplateClassificationIntentFactoryTest.java @@ -82,7 +82,9 @@ public class TemplateClassificationIntentFactoryTest { null, null, null, - createRemoteActionTemplates()); + createRemoteActionTemplates(), + 0, + 0); List intents = mTemplateClassificationIntentFactory.create( @@ -121,7 +123,9 @@ public class TemplateClassificationIntentFactoryTest { null, null, null, - createRemoteActionTemplates()); + createRemoteActionTemplates(), + 0, + 0); List intents = mTemplateClassificationIntentFactory.create( @@ -156,7 +160,9 @@ public class TemplateClassificationIntentFactoryTest { null, null, null, - null); + null, + 0, + 0); mTemplateClassificationIntentFactory.create( InstrumentationRegistry.getContext(), @@ -189,7 +195,9 @@ public class TemplateClassificationIntentFactoryTest { null, null, null, - new RemoteActionTemplate[0]); + new RemoteActionTemplate[0], + 0, + 0); mTemplateClassificationIntentFactory.create( InstrumentationRegistry.getContext(),