Add SettingsContextualCardProvider
- provide contextual cards for SettingsIntelligence - add contextualcards libs Fixes: 116837093 Test: make RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.homepage.contextualcards" Change-Id: I873e77fa43e9a8f6056be1f583b1910002efbd2e
This commit is contained in:
10
Android.mk
10
Android.mk
@@ -41,6 +41,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
|
|||||||
androidx.lifecycle_lifecycle-extensions \
|
androidx.lifecycle_lifecycle-extensions \
|
||||||
guava \
|
guava \
|
||||||
jsr305 \
|
jsr305 \
|
||||||
|
contextualcards \
|
||||||
settings-logtags \
|
settings-logtags \
|
||||||
|
|
||||||
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
|
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
|
||||||
@@ -57,7 +58,14 @@ include frameworks/base/packages/SettingsLib/search/common.mk
|
|||||||
|
|
||||||
include $(BUILD_PACKAGE)
|
include $(BUILD_PACKAGE)
|
||||||
|
|
||||||
|
# ==== prebuilt library ========================
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
|
||||||
|
contextualcards:libs/contextualcards.aar
|
||||||
|
include $(BUILD_MULTI_PREBUILT)
|
||||||
|
|
||||||
# Use the following include to make our test apk.
|
# Use the following include to make our test apk.
|
||||||
ifeq (,$(ONE_SHOT_MAKEFILE))
|
ifeq (,$(ONE_SHOT_MAKEFILE))
|
||||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
include $(call all-makefiles-under,$(LOCAL_PATH))
|
||||||
endif
|
endif
|
@@ -3192,6 +3192,15 @@
|
|||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:permission="android.permission.WRITE_SETTINGS_HOMEPAGE_DATA" />
|
android:permission="android.permission.WRITE_SETTINGS_HOMEPAGE_DATA" />
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:name=".homepage.contextualcards.SettingsContextualCardProvider"
|
||||||
|
android:authorities="com.android.settings.homepage.contextualcards"
|
||||||
|
android:permission="android.permission.WRITE_SETTINGS_HOMEPAGE_DATA"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.content.action.SETTINGS_HOMEPAGE_DATA"/>
|
||||||
|
</intent-filter>
|
||||||
|
</provider>
|
||||||
<!-- This is the longest AndroidManifest.xml ever. -->
|
<!-- This is the longest AndroidManifest.xml ever. -->
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
BIN
libs/contextualcards.aar
Executable file
BIN
libs/contextualcards.aar
Executable file
Binary file not shown.
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.homepage.contextualcards;
|
||||||
|
|
||||||
|
import static android.provider.SettingsSlicesContract.KEY_WIFI;
|
||||||
|
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.android.settings.homepage.deviceinfo.DataUsageSlice;
|
||||||
|
import com.android.settings.wifi.WifiSlice;
|
||||||
|
|
||||||
|
import com.google.android.settings.intelligence.libs.contextualcards.ContextualCard;
|
||||||
|
import com.google.android.settings.intelligence.libs.contextualcards.ContextualCardProvider;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/** Provides dynamic card for SettingsIntelligence. */
|
||||||
|
public class SettingsContextualCardProvider extends ContextualCardProvider {
|
||||||
|
|
||||||
|
public static final String CARD_AUTHORITY = "com.android.settings.homepage.contextualcards";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public List<ContextualCard> getContextualCards() {
|
||||||
|
final List<ContextualCard> cards = new ArrayList<>();
|
||||||
|
final ContextualCard wifiCard =
|
||||||
|
new ContextualCard.Builder()
|
||||||
|
.setSliceUri(WifiSlice.WIFI_URI.toString())
|
||||||
|
.setName(KEY_WIFI)
|
||||||
|
.build();
|
||||||
|
final ContextualCard dataUsageCard =
|
||||||
|
new ContextualCard.Builder()
|
||||||
|
.setSliceUri(DataUsageSlice.DATA_USAGE_CARD_URI.toString())
|
||||||
|
.setName(DataUsageSlice.PATH_DATA_USAGE_CARD)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
cards.add(wifiCard);
|
||||||
|
cards.add(dataUsageCard);
|
||||||
|
return cards;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.homepage.contextualcards;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import android.content.ContentResolver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
|
|
||||||
|
import com.google.android.settings.intelligence.libs.contextualcards.ContextualCard;
|
||||||
|
import com.google.android.settings.intelligence.libs.contextualcards.ContextualCardProvider;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
public class SettingsContextualCardProviderTest {
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private ContentResolver mResolver;
|
||||||
|
private Uri mUri;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
mContext = RuntimeEnvironment.application;
|
||||||
|
mResolver = mContext.getContentResolver();
|
||||||
|
mUri = new Uri.Builder()
|
||||||
|
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||||
|
.authority(SettingsContextualCardProvider.CARD_AUTHORITY)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void contentProviderCall_returnCorrectSize() {
|
||||||
|
final Bundle returnValue =
|
||||||
|
mResolver.call(mUri, ContextualCardProvider.METHOD_GET_CARD_LIST, "", null);
|
||||||
|
final ArrayList<ContextualCard> cards =
|
||||||
|
returnValue.getParcelableArrayList(ContextualCardProvider.BUNDLE_CARD_LIST);
|
||||||
|
assertThat(cards.size()).isEqualTo(2);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user