Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3af6619a authored by android-build-team Robot's avatar android-build-team Robot
Browse files

release-request-8cd2a23c-f767-488e-8139-390d1636483f-for-git_oc-mr1-release-43...

release-request-8cd2a23c-f767-488e-8139-390d1636483f-for-git_oc-mr1-release-4323561 snap-temp-L80400000100600189

Change-Id: Ib34a464b0738bfd279782393ec5f22be33e81201
parents f95168d6 4ce113d6
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -188,22 +188,27 @@ public final class BluetoothDevicePreference extends GearPreference implements
    }

    void onClicked() {
        Context context = getContext();
        int bondState = mCachedDevice.getBondState();

        final MetricsFeatureProvider metricsFeatureProvider =
                FeatureFactory.getFactory(getContext()).getMetricsFeatureProvider();
                FeatureFactory.getFactory(context).getMetricsFeatureProvider();

        if (mCachedDevice.isConnected()) {
            metricsFeatureProvider.action(getContext(),
            metricsFeatureProvider.action(context,
                    MetricsEvent.ACTION_SETTINGS_BLUETOOTH_DISCONNECT);
            askDisconnect();
        } else if (bondState == BluetoothDevice.BOND_BONDED) {
            metricsFeatureProvider.action(getContext(),
            metricsFeatureProvider.action(context,
                    MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT);
            mCachedDevice.connect(true);
        } else if (bondState == BluetoothDevice.BOND_NONE) {
            metricsFeatureProvider.action(getContext(),
            metricsFeatureProvider.action(context,
                    MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
            if (!mCachedDevice.hasHumanReadableName()) {
                metricsFeatureProvider.action(context,
                        MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR_DEVICES_WITHOUT_NAMES);
            }
            pair();
        }
    }
+11 −0
Original line number Diff line number Diff line
@@ -460,6 +460,17 @@ public class DashboardData {
                    // Only check title and summary for dashboard tile
                    return TextUtils.equals(localTile.title, targetTile.title)
                            && TextUtils.equals(localTile.summary, targetTile.summary);
                case TYPE_SUGGESTION_CONDITION_CONTAINER:
                    // If entity is suggestion and contains remote view, force refresh
                    final List entities = (List) entity;
                    if (!entities.isEmpty()) {
                        Object firstEntity = entities.get(0);
                        if (firstEntity instanceof Tile
                                && ((Tile) firstEntity).remoteViews != null) {
                            return false;
                        }
                    }
                    // Otherwise Fall through to default
                default:
                    return entity == null ? targetItem.entity == null
                            : entity.equals(targetItem.entity);
+3 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ import com.android.settings.dashboard.DashboardAdapter.DashboardItemHolder;
import com.android.settings.dashboard.DashboardAdapter.IconCache;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.drawer.Tile;
import com.android.settingslib.drawer.TileUtils;

import java.util.List;
import java.util.Objects;

@@ -73,6 +75,7 @@ public class SuggestionAdapter extends RecyclerView.Adapter<DashboardItemHolder>
            mSuggestionsShownLogged.add(suggestionId);
        }
        if (suggestion.remoteViews != null) {
            TileUtils.updateTileUsingSummaryUri(mContext, suggestion);
            final ViewGroup itemView = (ViewGroup) holder.itemView;
            itemView.removeAllViews();
            itemView.addView(suggestion.remoteViews.apply(itemView.getContext(), itemView));
+19 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import static com.google.common.truth.Truth.assertThat;

import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -98,11 +99,29 @@ public class BluetoothDevicePreferenceTest {
        when(mCachedBluetoothDevice.isConnected()).thenReturn(false);
        when(mCachedBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_NONE);
        when(mCachedBluetoothDevice.startPairing()).thenReturn(true);
        when(mCachedBluetoothDevice.hasHumanReadableName()).thenReturn(true);

        mPreference.onClicked();

        verify(mMetricsFeatureProvider).action(
                mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
        verify(mMetricsFeatureProvider, never()).action(mContext,
                MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR_DEVICES_WITHOUT_NAMES);
    }

    @Test
    public void onClicked_deviceNotBonded_shouldLogBluetoothPairEventAndPairWithoutNameEvent() {
        when(mCachedBluetoothDevice.isConnected()).thenReturn(false);
        when(mCachedBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_NONE);
        when(mCachedBluetoothDevice.startPairing()).thenReturn(true);
        when(mCachedBluetoothDevice.hasHumanReadableName()).thenReturn(false);

        mPreference.onClicked();

        verify(mMetricsFeatureProvider).action(
                mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
        verify(mMetricsFeatureProvider).action(mContext,
                MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR_DEVICES_WITHOUT_NAMES);
    }

    @Test
+24 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.settings.dashboard;
import android.support.annotation.NonNull;
import android.support.v7.util.DiffUtil;
import android.support.v7.util.ListUpdateCallback;
import android.widget.RemoteViews;

import com.android.settings.TestConfig;
import com.android.settings.dashboard.conditional.AirplaneModeCondition;
@@ -35,6 +36,7 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -224,6 +226,28 @@ public class DashboardDataTest {
        testDiffUtil(mDashboardDataWithOneConditions, mDashboardDataWithNoItems, testResultData);
    }

    @Test
    public void testDiffUtil_typeSuggestedContainer_ResultDataNothingChanged() {
        //Build testResultData
        final List<ListUpdateResult.ResultData> testResultData = new ArrayList<>();
        testResultData.add(new ListUpdateResult.ResultData(
                ListUpdateResult.ResultData.TYPE_OPERATION_CHANGE, 0, 1));
        Tile tile = new Tile();
        tile.remoteViews = mock(RemoteViews.class);

        DashboardData prevData = new DashboardData.Builder()
                .setConditions(null)
                .setCategory(null)
                .setSuggestions(Arrays.asList(tile))
                .build();
        DashboardData currentData = new DashboardData.Builder()
                .setConditions(null)
                .setCategory(null)
                .setSuggestions(Arrays.asList(tile))
                .build();
        testDiffUtil(prevData, currentData, testResultData);
    }

    /**
     * Test when using the
     * {@link com.android.settings.dashboard.DashboardData.ItemsDataDiffCallback}