Make bluetooth not discoverable via large screen deep link flow
Deep links on large screen devices starts a homepage activity on the left pane, and then starts the target activity on the right pane. This flow overrides the calling package, and the target activity can't know who initially calls it. Thus, we store the initial calling package in the intent, so the Connected devices page is able to make bluetooth not discoverable when it's called from unintended apps on large screen devices. Bug: 234440688 Test: robotest, manual Change-Id: I4ddcd4e083c002ece9d10aabdb4af4a41de55ce7 Merged-In: I4ddcd4e083c002ece9d10aabdb4af4a41de55ce7
This commit is contained in:
@@ -70,6 +70,7 @@ import com.android.settings.homepage.DeepLinkHomepageActivityInternal;
|
||||
import com.android.settings.homepage.SettingsHomepageActivity;
|
||||
import com.android.settings.homepage.TopLevelSettings;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.password.PasswordUtils;
|
||||
import com.android.settings.wfd.WifiDisplaySettings;
|
||||
import com.android.settings.widget.SettingsMainSwitchBar;
|
||||
import com.android.settingslib.core.instrumentation.Instrumentable;
|
||||
@@ -154,6 +155,7 @@ public class SettingsActivity extends SettingsBaseActivity
|
||||
public static final String EXTRA_IS_FROM_SLICE = "is_from_slice";
|
||||
|
||||
public static final String EXTRA_USER_HANDLE = "user_handle";
|
||||
public static final String EXTRA_INITIAL_CALLING_PACKAGE = "initial_calling_package";
|
||||
|
||||
/**
|
||||
* Personal or Work profile tab of {@link ProfileSelectFragment}
|
||||
@@ -415,6 +417,8 @@ public class SettingsActivity extends SettingsBaseActivity
|
||||
}
|
||||
|
||||
private boolean tryStartTwoPaneDeepLink(Intent intent) {
|
||||
intent.putExtra(EXTRA_INITIAL_CALLING_PACKAGE, PasswordUtils.getCallingAppPackageName(
|
||||
getActivityToken()));
|
||||
final Intent trampolineIntent;
|
||||
if (intent.getBooleanExtra(EXTRA_IS_FROM_SLICE, false)) {
|
||||
// Get menu key for slice deep link case.
|
||||
@@ -502,6 +506,17 @@ public class SettingsActivity extends SettingsBaseActivity
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the initial calling package name that launches the activity. */
|
||||
public String getInitialCallingPackage() {
|
||||
String callingPackage = PasswordUtils.getCallingAppPackageName(getActivityToken());
|
||||
if (!TextUtils.equals(callingPackage, getPackageName())) {
|
||||
return callingPackage;
|
||||
}
|
||||
|
||||
String initialCallingPackage = getIntent().getStringExtra(EXTRA_INITIAL_CALLING_PACKAGE);
|
||||
return TextUtils.isEmpty(initialCallingPackage) ? callingPackage : initialCallingPackage;
|
||||
}
|
||||
|
||||
/** Returns the initial fragment name that the activity will launch. */
|
||||
@VisibleForTesting
|
||||
public String getInitialFragmentName(Intent intent) {
|
||||
|
Reference in New Issue
Block a user