Merge "Ignore fragment attr from ext authenticator resource" into sc-dev
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 7c368d6..54b1080 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -148,6 +148,7 @@
         <item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault.Medium</item>
         <item name="android:textColorHint">?android:attr/textColorSecondary</item>
         <item name="android:minHeight">@dimen/min_tap_target_size</item>
+        <item name="android:maxLength">500</item>
     </style>
 
     <style name="wifi_section">
diff --git a/src/com/android/settings/search/SearchFeatureProvider.java b/src/com/android/settings/search/SearchFeatureProvider.java
index 4c39b9c..5c54878 100644
--- a/src/com/android/settings/search/SearchFeatureProvider.java
+++ b/src/com/android/settings/search/SearchFeatureProvider.java
@@ -51,7 +51,7 @@
      * @throws IllegalArgumentException when caller is null
      * @throws SecurityException        when caller is not allowed to launch search result page
      */
-    void verifyLaunchSearchResultPageCaller(Context context, @NonNull ComponentName caller)
+    void verifyLaunchSearchResultPageCaller(@NonNull Context context, @NonNull String callerPackage)
             throws SecurityException, IllegalArgumentException;
 
     /**
diff --git a/src/com/android/settings/search/SearchFeatureProviderImpl.java b/src/com/android/settings/search/SearchFeatureProviderImpl.java
index 508d37d..5035ef8 100644
--- a/src/com/android/settings/search/SearchFeatureProviderImpl.java
+++ b/src/com/android/settings/search/SearchFeatureProviderImpl.java
@@ -17,13 +17,14 @@
 
 package com.android.settings.search;
 
-import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
 import android.provider.Settings;
 import android.text.TextUtils;
 
+import androidx.annotation.NonNull;
+
 import com.android.settingslib.search.SearchIndexableResources;
 import com.android.settingslib.search.SearchIndexableResourcesMobile;
 
@@ -32,21 +33,18 @@
  */
 public class SearchFeatureProviderImpl implements SearchFeatureProvider {
 
-    private static final String TAG = "SearchFeatureProvider";
-
     private SearchIndexableResources mSearchIndexableResources;
 
     @Override
-    public void verifyLaunchSearchResultPageCaller(Context context, ComponentName caller) {
-        if (caller == null) {
+    public void verifyLaunchSearchResultPageCaller(@NonNull Context context,
+            @NonNull String callerPackage) {
+        if (TextUtils.isEmpty(callerPackage)) {
             throw new IllegalArgumentException("ExternalSettingsTrampoline intents "
                     + "must be called with startActivityForResult");
         }
-        final String packageName = caller.getPackageName();
-        final boolean isSettingsPackage = TextUtils.equals(packageName, context.getPackageName())
-                || TextUtils.equals(getSettingsIntelligencePkgName(context), packageName);
-        final boolean isAllowlistedPackage =
-                isSignatureAllowlisted(context, caller.getPackageName());
+        final boolean isSettingsPackage = TextUtils.equals(callerPackage, context.getPackageName())
+                || TextUtils.equals(getSettingsIntelligencePkgName(context), callerPackage);
+        final boolean isAllowlistedPackage = isSignatureAllowlisted(context, callerPackage);
         if (isSettingsPackage || isAllowlistedPackage) {
             return;
         }
diff --git a/src/com/android/settings/search/SearchResultTrampoline.java b/src/com/android/settings/search/SearchResultTrampoline.java
index e930473..28030e8 100644
--- a/src/com/android/settings/search/SearchResultTrampoline.java
+++ b/src/com/android/settings/search/SearchResultTrampoline.java
@@ -39,7 +39,7 @@
         // First make sure caller has privilege to launch a search result page.
         FeatureFactory.getFactory(this)
                 .getSearchFeatureProvider()
-                .verifyLaunchSearchResultPageCaller(this, getCallingActivity());
+                .verifyLaunchSearchResultPageCaller(this, getLaunchedFromPackage());
         // Didn't crash, proceed and launch the result as a subsetting.
         final Intent intent = getIntent();
 
diff --git a/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java
index 444a813..ebd935d 100644
--- a/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java
@@ -21,7 +21,6 @@
 
 import android.app.Activity;
 import android.app.settings.SettingsEnums;
-import android.content.ComponentName;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
 import android.content.pm.ResolveInfo;
@@ -126,20 +125,22 @@
 
     @Test(expected = SecurityException.class)
     public void verifyLaunchSearchResultPageCaller_badCaller_shouldCrash() {
-        final ComponentName cn = new ComponentName("pkg", "class");
-        mProvider.verifyLaunchSearchResultPageCaller(mActivity, cn);
+        final String packageName = "pkg";
+
+        mProvider.verifyLaunchSearchResultPageCaller(mActivity, packageName);
     }
 
     @Test
     public void verifyLaunchSearchResultPageCaller_settingsCaller_shouldNotCrash() {
-        final ComponentName cn = new ComponentName(mActivity.getPackageName(), "class");
-        mProvider.verifyLaunchSearchResultPageCaller(mActivity, cn);
+        final String packageName = mActivity.getPackageName();
+
+        mProvider.verifyLaunchSearchResultPageCaller(mActivity, packageName);
     }
 
     @Test
     public void verifyLaunchSearchResultPageCaller_settingsIntelligenceCaller_shouldNotCrash() {
         final String packageName = mProvider.getSettingsIntelligencePkgName(mActivity);
-        final ComponentName cn = new ComponentName(packageName, "class");
-        mProvider.verifyLaunchSearchResultPageCaller(mActivity, cn);
+
+        mProvider.verifyLaunchSearchResultPageCaller(mActivity, packageName);
     }
 }