Snap for 7941279 from e4b9992d8a to tm-release
Change-Id: Ibf64d24034862819605334b5980baff18cf34a0d
This commit is contained in:
1
res/raw/lottie_power_menu.json
Normal file
1
res/raw/lottie_power_menu.json
Normal file
File diff suppressed because one or more lines are too long
@@ -17,6 +17,14 @@
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/power_menu_setting_name">
|
||||
|
||||
<!-- Animation uses embedded PNGs and lottie requires asset folder to be set despite
|
||||
embedding. -->
|
||||
<com.android.settingslib.widget.IllustrationPreference
|
||||
android:key="gesture_power_menu_video"
|
||||
settings:searchable="false"
|
||||
settings:lottie_imageAssetsFolder="power_menu"
|
||||
settings:lottie_rawRes="@raw/lottie_power_menu"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="gesture_power_menu_long_press_for_assist"
|
||||
android:title="@string/power_menu_long_press_for_assist"
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.window.embedding.ActivityFilter;
|
||||
import androidx.window.embedding.ActivityRule;
|
||||
import androidx.window.embedding.SplitController;
|
||||
import androidx.window.embedding.SplitPairFilter;
|
||||
import androidx.window.embedding.SplitPairRule;
|
||||
@@ -33,6 +34,8 @@ import androidx.window.embedding.SplitRule;
|
||||
|
||||
import com.android.settings.Settings;
|
||||
import com.android.settings.SubSettings;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintEnrollIntroduction;
|
||||
import com.android.settings.homepage.DeepLinkHomepageActivity;
|
||||
import com.android.settings.homepage.SettingsHomepageActivity;
|
||||
import com.android.settings.homepage.SliceDeepLinkHomepageActivity;
|
||||
@@ -65,6 +68,8 @@ public class ActivityEmbeddingRulesController {
|
||||
|
||||
// Set a placeholder for home page.
|
||||
registerHomepagePlaceholderRule();
|
||||
|
||||
registerAlwaysExpandRule();
|
||||
}
|
||||
|
||||
/** Register a SplitPairRule for 2-pane. */
|
||||
@@ -94,20 +99,26 @@ public class ActivityEmbeddingRulesController {
|
||||
|
||||
/**
|
||||
* Register a new SplitPairRule for Settings home. Because homepage is able to be opened by
|
||||
* {@link Settings} or {@link SettingsHomepageActivity}, we register split rule twice for
|
||||
* two cases.
|
||||
* {@link Settings} or {@link SettingsHomepageActivity} or
|
||||
* {@link SliceDeepLinkHomepageActivity}, we register split rule for above cases.
|
||||
*/
|
||||
public static void registerTwoPanePairRuleForSettingsHome(Context context,
|
||||
ComponentName secondaryComponent,
|
||||
String secondaryIntentAction,
|
||||
boolean finishPrimaryWithSecondary,
|
||||
boolean finishSecondaryWithPrimary,
|
||||
boolean clearTop) {
|
||||
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
registerTwoPanePairRule(
|
||||
context,
|
||||
getComponentName(context, Settings.class),
|
||||
secondaryComponent,
|
||||
secondaryIntentAction,
|
||||
true /* finishPrimaryWithSecondary */,
|
||||
true /* finishSecondaryWithPrimary */,
|
||||
finishPrimaryWithSecondary,
|
||||
finishSecondaryWithPrimary,
|
||||
clearTop);
|
||||
|
||||
registerTwoPanePairRule(
|
||||
@@ -115,8 +126,8 @@ public class ActivityEmbeddingRulesController {
|
||||
new ComponentName(context, DeepLinkHomepageActivity.class),
|
||||
secondaryComponent,
|
||||
secondaryIntentAction,
|
||||
true /* finishPrimaryWithSecondary */,
|
||||
true /* finishSecondaryWithPrimary */,
|
||||
finishPrimaryWithSecondary,
|
||||
finishSecondaryWithPrimary,
|
||||
clearTop);
|
||||
|
||||
registerTwoPanePairRule(
|
||||
@@ -124,8 +135,8 @@ public class ActivityEmbeddingRulesController {
|
||||
getComponentName(context, SettingsHomepageActivity.class),
|
||||
secondaryComponent,
|
||||
secondaryIntentAction,
|
||||
true /* finishPrimaryWithSecondary */,
|
||||
true /* finishSecondaryWithPrimary */,
|
||||
finishPrimaryWithSecondary,
|
||||
finishSecondaryWithPrimary,
|
||||
clearTop);
|
||||
|
||||
registerTwoPanePairRule(
|
||||
@@ -133,6 +144,26 @@ public class ActivityEmbeddingRulesController {
|
||||
getComponentName(context, SliceDeepLinkHomepageActivity.class),
|
||||
secondaryComponent,
|
||||
secondaryIntentAction,
|
||||
finishPrimaryWithSecondary,
|
||||
finishSecondaryWithPrimary,
|
||||
clearTop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new SplitPairRule for Settings home.
|
||||
*/
|
||||
public static void registerTwoPanePairRuleForSettingsHome(Context context,
|
||||
ComponentName secondaryComponent,
|
||||
String secondaryIntentAction,
|
||||
boolean clearTop) {
|
||||
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
registerTwoPanePairRuleForSettingsHome(
|
||||
context,
|
||||
secondaryComponent,
|
||||
secondaryIntentAction,
|
||||
true /* finishPrimaryWithSecondary */,
|
||||
true /* finishSecondaryWithPrimary */,
|
||||
clearTop);
|
||||
@@ -173,6 +204,13 @@ public class ActivityEmbeddingRulesController {
|
||||
mSplitController.registerRule(placeholderRule);
|
||||
}
|
||||
|
||||
private void registerAlwaysExpandRule() {
|
||||
final Set<ActivityFilter> activityFilters = new HashSet<>();
|
||||
addActivityFilter(activityFilters, FingerprintEnrollIntroduction.class);
|
||||
addActivityFilter(activityFilters, FingerprintEnrollEnrolling.class);
|
||||
mSplitController.registerRule(new ActivityRule(activityFilters, true /* alwaysExpand */));
|
||||
}
|
||||
|
||||
private void addActivityFilter(Set<ActivityFilter> activityFilters,
|
||||
Class<? extends Activity> activityClass) {
|
||||
activityFilters.add(new ActivityFilter(getComponentName(activityClass),
|
||||
|
||||
@@ -51,23 +51,37 @@ public class ConnectedDeviceGroupController extends BasePreferenceController
|
||||
private BluetoothDeviceUpdater mBluetoothDeviceUpdater;
|
||||
private ConnectedUsbDeviceUpdater mConnectedUsbDeviceUpdater;
|
||||
private DockUpdater mConnectedDockUpdater;
|
||||
private final PackageManager mPackageManager;
|
||||
|
||||
public ConnectedDeviceGroupController(Context context) {
|
||||
super(context, KEY);
|
||||
mPackageManager = context.getPackageManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
mBluetoothDeviceUpdater.registerCallback();
|
||||
mConnectedUsbDeviceUpdater.registerCallback();
|
||||
if (mBluetoothDeviceUpdater != null) {
|
||||
mBluetoothDeviceUpdater.registerCallback();
|
||||
mBluetoothDeviceUpdater.refreshPreference();
|
||||
}
|
||||
|
||||
if (mConnectedUsbDeviceUpdater != null) {
|
||||
mConnectedUsbDeviceUpdater.registerCallback();
|
||||
}
|
||||
|
||||
mConnectedDockUpdater.registerCallback();
|
||||
mBluetoothDeviceUpdater.refreshPreference();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
mConnectedUsbDeviceUpdater.unregisterCallback();
|
||||
mBluetoothDeviceUpdater.unregisterCallback();
|
||||
if (mBluetoothDeviceUpdater != null) {
|
||||
mBluetoothDeviceUpdater.unregisterCallback();
|
||||
}
|
||||
|
||||
if (mConnectedUsbDeviceUpdater != null) {
|
||||
mConnectedUsbDeviceUpdater.unregisterCallback();
|
||||
}
|
||||
|
||||
mConnectedDockUpdater.unregisterCallback();
|
||||
}
|
||||
|
||||
@@ -80,9 +94,15 @@ public class ConnectedDeviceGroupController extends BasePreferenceController
|
||||
|
||||
if (isAvailable()) {
|
||||
final Context context = screen.getContext();
|
||||
mBluetoothDeviceUpdater.setPrefContext(context);
|
||||
mBluetoothDeviceUpdater.forceUpdate();
|
||||
mConnectedUsbDeviceUpdater.initUsbPreference(context);
|
||||
if (mBluetoothDeviceUpdater != null) {
|
||||
mBluetoothDeviceUpdater.setPrefContext(context);
|
||||
mBluetoothDeviceUpdater.forceUpdate();
|
||||
}
|
||||
|
||||
if (mConnectedUsbDeviceUpdater != null) {
|
||||
mConnectedUsbDeviceUpdater.initUsbPreference(context);
|
||||
}
|
||||
|
||||
mConnectedDockUpdater.setPreferenceContext(context);
|
||||
mConnectedDockUpdater.forceUpdate();
|
||||
}
|
||||
@@ -90,10 +110,8 @@ public class ConnectedDeviceGroupController extends BasePreferenceController
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
final PackageManager packageManager = mContext.getPackageManager();
|
||||
return (packageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
|
||||
|| packageManager.hasSystemFeature(PackageManager.FEATURE_USB_ACCESSORY)
|
||||
|| packageManager.hasSystemFeature(PackageManager.FEATURE_USB_HOST)
|
||||
return (hasBluetoothFeature()
|
||||
|| hasUsbFeature()
|
||||
|| mConnectedDockUpdater != null)
|
||||
? AVAILABLE_UNSEARCHABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
@@ -121,7 +139,7 @@ public class ConnectedDeviceGroupController extends BasePreferenceController
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void init(BluetoothDeviceUpdater bluetoothDeviceUpdater,
|
||||
void init(BluetoothDeviceUpdater bluetoothDeviceUpdater,
|
||||
ConnectedUsbDeviceUpdater connectedUsbDeviceUpdater,
|
||||
DockUpdater connectedDockUpdater) {
|
||||
|
||||
@@ -136,8 +154,21 @@ public class ConnectedDeviceGroupController extends BasePreferenceController
|
||||
FeatureFactory.getFactory(context).getDockUpdaterFeatureProvider();
|
||||
final DockUpdater connectedDockUpdater =
|
||||
dockUpdaterFeatureProvider.getConnectedDockUpdater(context, this);
|
||||
init(new ConnectedBluetoothDeviceUpdater(context, fragment, this),
|
||||
new ConnectedUsbDeviceUpdater(context, fragment, this),
|
||||
init(hasBluetoothFeature()
|
||||
? new ConnectedBluetoothDeviceUpdater(context, fragment, this)
|
||||
: null,
|
||||
hasUsbFeature()
|
||||
? new ConnectedUsbDeviceUpdater(context, fragment, this)
|
||||
: null,
|
||||
connectedDockUpdater);
|
||||
}
|
||||
|
||||
private boolean hasBluetoothFeature() {
|
||||
return mPackageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
|
||||
}
|
||||
|
||||
private boolean hasUsbFeature() {
|
||||
return mPackageManager.hasSystemFeature(PackageManager.FEATURE_USB_ACCESSORY)
|
||||
|| mPackageManager.hasSystemFeature(PackageManager.FEATURE_USB_HOST);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -33,11 +34,14 @@ import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.search.SearchIndexableResources;
|
||||
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* FeatureProvider for Settings Search
|
||||
*/
|
||||
@@ -60,6 +64,9 @@ public interface SearchFeatureProvider {
|
||||
*/
|
||||
SearchIndexableResources getSearchIndexableResources();
|
||||
|
||||
/**
|
||||
* @return a package name of settings intelligence.
|
||||
*/
|
||||
default String getSettingsIntelligencePkgName(Context context) {
|
||||
return context.getString(R.string.config_settingsintelligence_package_name);
|
||||
}
|
||||
@@ -90,16 +97,30 @@ public interface SearchFeatureProvider {
|
||||
navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||
navView.setBackground(null);
|
||||
|
||||
final Context context = activity.getApplicationContext();
|
||||
final Intent intent = buildSearchIntent(context, pageId)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
final List<ResolveInfo> resolveInfos =
|
||||
activity.getPackageManager().queryIntentActivities(intent,
|
||||
PackageManager.MATCH_DEFAULT_ONLY);
|
||||
if (resolveInfos.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ComponentName searchComponentName = resolveInfos.get(0)
|
||||
.getComponentInfo().getComponentName();
|
||||
// Set a component name since activity embedding requires a component name for
|
||||
// registering a rule.
|
||||
intent.setComponent(searchComponentName);
|
||||
ActivityEmbeddingRulesController.registerTwoPanePairRuleForSettingsHome(
|
||||
context,
|
||||
searchComponentName,
|
||||
intent.getAction(),
|
||||
false /* finishPrimaryWithSecondary */,
|
||||
true /* finishSecondaryWithPrimary */,
|
||||
false /* clearTop */);
|
||||
|
||||
toolbar.setOnClickListener(tb -> {
|
||||
final Context context = activity.getApplicationContext();
|
||||
final Intent intent = buildSearchIntent(context, pageId)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
if (activity.getPackageManager().queryIntentActivities(intent,
|
||||
PackageManager.MATCH_DEFAULT_ONLY).isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
FeatureFactory.getFactory(context).getSlicesFeatureProvider()
|
||||
.indexSliceDataAsync(context);
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public class WifiTetherSecurityPreferenceController extends WifiTetherBasePrefer
|
||||
if (!mIsWpa3Supported && mSecurityMap.keySet()
|
||||
.removeIf(key -> key > SoftApConfiguration.SECURITY_TYPE_WPA2_PSK)) {
|
||||
preference.setEntries(mSecurityMap.values().stream().toArray(CharSequence[]::new));
|
||||
preference.setEntryValues(mSecurityMap.keySet().stream().map(Integer::toBinaryString)
|
||||
preference.setEntryValues(mSecurityMap.keySet().stream().map(i -> Integer.toString(i))
|
||||
.toArray(CharSequence[]::new));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -38,6 +39,7 @@ import com.android.settings.bluetooth.ConnectedBluetoothDeviceUpdater;
|
||||
import com.android.settings.connecteddevice.dock.DockUpdater;
|
||||
import com.android.settings.connecteddevice.usb.ConnectedUsbDeviceUpdater;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -52,7 +54,7 @@ import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplicationPackageManager;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = ShadowApplicationPackageManager.class)
|
||||
@Config(shadows = {ShadowApplicationPackageManager.class, ShadowBluetoothAdapter.class})
|
||||
public class ConnectedDeviceGroupControllerTest {
|
||||
|
||||
private static final String PREFERENCE_KEY_1 = "pref_key_1";
|
||||
@@ -203,4 +205,18 @@ public class ConnectedDeviceGroupControllerTest {
|
||||
AVAILABLE_UNSEARCHABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void init_noBluetoothAndUsbFeature_doesNotCrash() {
|
||||
DashboardFragment fragment = mock(DashboardFragment.class);
|
||||
when(fragment.getContext()).thenReturn(mContext);
|
||||
when(mPreferenceScreen.findPreference(anyString())).thenReturn(mPreferenceGroup);
|
||||
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, false);
|
||||
mPackageManager.setSystemFeature(PackageManager.FEATURE_USB_ACCESSORY, false);
|
||||
mPackageManager.setSystemFeature(PackageManager.FEATURE_USB_HOST, false);
|
||||
|
||||
mConnectedDeviceGroupController.init(fragment);
|
||||
mConnectedDeviceGroupController.displayPreference(mPreferenceScreen);
|
||||
mConnectedDeviceGroupController.onStart();
|
||||
mConnectedDeviceGroupController.onStop();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user