Replace getCallingActivity() with getLaunchedFromPackage()
getLaunchedFromPackage() reports who launched this Activity or built
PendingIntent used to launch it, whereas getCallingActivity() reports
who will get result of Activity.
Bug: 316891059
Test: robotest, manual
Change-Id: If97018c2741caef622f0596bbfeaa42ef1788b78
Merged-In: If97018c2741caef622f0596bbfeaa42ef1788b78
(cherry picked from commit ddc11bc03a)
This commit is contained in:
@@ -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 @@ import com.android.settingslib.search.SearchIndexableResourcesMobile;
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user