Get Tile#intent through getter
Bug: 77600770 Test: robotests Change-Id: I17d3556f833e6a9610fe34f382534bd90bb0499f
This commit is contained in:
@@ -723,7 +723,8 @@ public class SettingsActivity extends SettingsBaseActivity
|
||||
for (DashboardCategory category : categories) {
|
||||
final int tileCount = category.getTilesCount();
|
||||
for (int i = 0; i < tileCount; i++) {
|
||||
final ComponentName component = category.getTile(i).intent.getComponent();
|
||||
final ComponentName component = category.getTile(i)
|
||||
.getIntent().getComponent();
|
||||
final String name = component.getClassName();
|
||||
final boolean isEnabledForRestricted = ArrayUtils.contains(
|
||||
SettingsGateway.SETTINGS_FOR_RESTRICTED, name);
|
||||
|
@@ -22,6 +22,9 @@ import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
@@ -33,9 +36,6 @@ import com.android.settingslib.drawer.Tile;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
public class AccountDetailDashboardFragment extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "AccountDetailDashboard";
|
||||
@@ -131,8 +131,8 @@ public class AccountDetailDashboardFragment extends DashboardFragment {
|
||||
return false;
|
||||
}
|
||||
final boolean display = mAccountType.equals(metadata.getString(METADATA_IA_ACCOUNT));
|
||||
if (display && tile.intent != null) {
|
||||
tile.intent.putExtra(EXTRA_ACCOUNT_NAME, mAccount.name);
|
||||
if (display) {
|
||||
tile.getIntent().putExtra(EXTRA_ACCOUNT_NAME, mAccount.name);
|
||||
}
|
||||
return display;
|
||||
}
|
||||
|
@@ -98,7 +98,7 @@ public class CategoryManager {
|
||||
DashboardCategory category = mCategories.get(i);
|
||||
for (int j = 0; j < category.getTilesCount(); j++) {
|
||||
Tile tile = category.getTile(j);
|
||||
if (tileBlacklist.contains(tile.intent.getComponent())) {
|
||||
if (tileBlacklist.contains(tile.getIntent().getComponent())) {
|
||||
category.removeTile(j--);
|
||||
}
|
||||
}
|
||||
@@ -205,10 +205,7 @@ public class CategoryManager {
|
||||
final Set<ComponentName> components = new ArraySet<>();
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
final Tile tile = category.getTile(i);
|
||||
if (tile.intent == null) {
|
||||
continue;
|
||||
}
|
||||
final ComponentName tileComponent = tile.intent.getComponent();
|
||||
final ComponentName tileComponent = tile.getIntent().getComponent();
|
||||
if (components.contains(tileComponent)) {
|
||||
category.removeTile(i);
|
||||
} else {
|
||||
|
@@ -333,7 +333,7 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
}
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, "Failed to set background color for " + tile.intent.getPackage());
|
||||
Log.e(TAG, "Failed to set background color for " + tile.getPackageName());
|
||||
}
|
||||
mCache.updateIcon(tileIcon, icon);
|
||||
}
|
||||
|
@@ -117,14 +117,14 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
|
||||
@Override
|
||||
public String getDashboardKeyForTile(Tile tile) {
|
||||
if (tile == null || tile.intent == null) {
|
||||
if (tile == null) {
|
||||
return null;
|
||||
}
|
||||
if (!TextUtils.isEmpty(tile.key)) {
|
||||
return tile.key;
|
||||
}
|
||||
final StringBuilder sb = new StringBuilder(DASHBOARD_TILE_PREF_KEY_PREFIX);
|
||||
final ComponentName component = tile.intent.getComponent();
|
||||
final ComponentName component = tile.getIntent().getComponent();
|
||||
sb.append(component.getClassName());
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -157,8 +157,8 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
}
|
||||
if (!TextUtils.isEmpty(clsName)) {
|
||||
pref.setFragment(clsName);
|
||||
} else if (tile.intent != null) {
|
||||
final Intent intent = new Intent(tile.intent);
|
||||
} else {
|
||||
final Intent intent = new Intent(tile.getIntent());
|
||||
intent.putExtra(VisibilityLoggerMixin.EXTRA_SOURCE_METRICS_CATEGORY,
|
||||
sourceMetricsCategory);
|
||||
if (action != null) {
|
||||
@@ -178,11 +178,8 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
order = -tile.priority;
|
||||
}
|
||||
if (order != null) {
|
||||
boolean shouldSkipBaseOrderOffset = false;
|
||||
if (tile.intent != null) {
|
||||
shouldSkipBaseOrderOffset = TextUtils.equals(
|
||||
skipOffsetPackageName, tile.intent.getComponent().getPackageName());
|
||||
}
|
||||
boolean shouldSkipBaseOrderOffset = TextUtils.equals(
|
||||
skipOffsetPackageName, tile.getIntent().getComponent().getPackageName());
|
||||
if (shouldSkipBaseOrderOffset || baseOrder == Preference.DEFAULT_ORDER) {
|
||||
pref.setOrder(order);
|
||||
} else {
|
||||
@@ -204,11 +201,7 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
mContext.startActivity(intent);
|
||||
return;
|
||||
}
|
||||
|
||||
if (tile.intent == null) {
|
||||
return;
|
||||
}
|
||||
final Intent intent = new Intent(tile.intent)
|
||||
final Intent intent = new Intent(tile.getIntent())
|
||||
.putExtra(VisibilityLoggerMixin.EXTRA_SOURCE_METRICS_CATEGORY,
|
||||
MetricsEvent.DASHBOARD_SUMMARY)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
@@ -244,14 +237,12 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
} else if (tile.getMetaData() != null
|
||||
&& tile.getMetaData().containsKey(META_DATA_PREFERENCE_ICON_URI)) {
|
||||
ThreadUtils.postOnBackgroundThread(() -> {
|
||||
final Intent intent = tile.getIntent();
|
||||
String packageName = null;
|
||||
if (tile.intent != null) {
|
||||
Intent intent = tile.intent;
|
||||
if (!TextUtils.isEmpty(intent.getPackage())) {
|
||||
packageName = intent.getPackage();
|
||||
} else if (intent.getComponent() != null) {
|
||||
packageName = intent.getComponent().getPackageName();
|
||||
}
|
||||
if (!TextUtils.isEmpty(intent.getPackage())) {
|
||||
packageName = intent.getPackage();
|
||||
} else if (intent.getComponent() != null) {
|
||||
packageName = intent.getComponent().getPackageName();
|
||||
}
|
||||
final Map<String, IContentProvider> providerMap = new ArrayMap<>();
|
||||
final String uri = tile.getMetaData().getString(META_DATA_PREFERENCE_ICON_URI);
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.dashboard;
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -155,19 +156,20 @@ public class SummaryLoader {
|
||||
}
|
||||
|
||||
private SummaryProvider getSummaryProvider(Tile tile) {
|
||||
if (!mActivity.getPackageName().equals(tile.intent.getComponent().getPackageName())) {
|
||||
if (!mActivity.getPackageName().equals(tile.getPackageName())) {
|
||||
// Not within Settings, can't load Summary directly.
|
||||
// TODO: Load summary indirectly.
|
||||
return null;
|
||||
}
|
||||
final Bundle metaData = tile.getMetaData();
|
||||
final Intent intent = tile.getIntent();
|
||||
if (metaData == null) {
|
||||
if (DEBUG) Log.d(TAG, "No metadata specified for " + tile.intent.getComponent());
|
||||
Log.d(TAG, "No metadata specified for " + intent.getComponent());
|
||||
return null;
|
||||
}
|
||||
String clsName = metaData.getString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS);
|
||||
final String clsName = metaData.getString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS);
|
||||
if (clsName == null) {
|
||||
if (DEBUG) Log.d(TAG, "No fragment specified for " + tile.intent.getComponent());
|
||||
Log.d(TAG, "No fragment specified for " + intent.getComponent());
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
@@ -193,15 +195,12 @@ public class SummaryLoader {
|
||||
* operations are asynchronous.
|
||||
*/
|
||||
public void registerReceiver(final BroadcastReceiver receiver, final IntentFilter filter) {
|
||||
mActivity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!mListening) {
|
||||
return;
|
||||
}
|
||||
mReceivers.add(receiver);
|
||||
mActivity.registerReceiver(receiver, filter);
|
||||
mActivity.runOnUiThread(() -> {
|
||||
if (!mListening) {
|
||||
return;
|
||||
}
|
||||
mReceivers.add(receiver);
|
||||
mActivity.registerReceiver(receiver, filter);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -242,7 +241,7 @@ public class SummaryLoader {
|
||||
SummaryProvider provider = getSummaryProvider(tile);
|
||||
if (provider != null) {
|
||||
if (DEBUG) Log.d(TAG, "Creating " + tile);
|
||||
mSummaryProviderMap.put(provider, tile.intent.getComponent());
|
||||
mSummaryProviderMap.put(provider, tile.getIntent().getComponent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +253,7 @@ public class SummaryLoader {
|
||||
final int tileCount = tiles.size();
|
||||
for (int j = 0; j < tileCount; j++) {
|
||||
final Tile tile = tiles.get(j);
|
||||
if (component.equals(tile.intent.getComponent())) {
|
||||
if (component.equals(tile.getIntent().getComponent())) {
|
||||
return tile;
|
||||
}
|
||||
}
|
||||
|
@@ -71,8 +71,9 @@ public class ProfileSelectDialog extends DialogFragment implements OnClickListen
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
UserHandle user = mSelectedTile.userHandle.get(which);
|
||||
// Show menu on top level items.
|
||||
mSelectedTile.intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
getActivity().startActivityAsUser(mSelectedTile.intent, user);
|
||||
final Intent intent = mSelectedTile.getIntent();
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
getActivity().startActivityAsUser(intent, user);
|
||||
}
|
||||
|
||||
public static void updateUserHandlesIfNeeded(Context context, Tile tile) {
|
||||
|
@@ -63,6 +63,8 @@ public class AccountDetailDashboardFragmentTest {
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mActivityInfo = new ActivityInfo();
|
||||
mActivityInfo.packageName = "pkg";
|
||||
mActivityInfo.name = "clazz";
|
||||
mActivityInfo.metaData = new Bundle();
|
||||
|
||||
final Bundle args = new Bundle();
|
||||
@@ -121,7 +123,6 @@ public class AccountDetailDashboardFragmentTest {
|
||||
mActivityInfo.metaData.putString(METADATA_ACCOUNT_TYPE, "com.abc");
|
||||
mActivityInfo.metaData.putString("com.android.settings.intent.action",
|
||||
Intent.ACTION_ASSIST);
|
||||
tile.intent = new Intent();
|
||||
tile.userHandle = null;
|
||||
mFragment.displayTile(tile);
|
||||
|
||||
|
@@ -54,6 +54,8 @@ public class CategoryManagerTest {
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mActivityInfo = new ActivityInfo();
|
||||
mActivityInfo.packageName = "pkg";
|
||||
mActivityInfo.name = "class";
|
||||
mActivityInfo.applicationInfo = new ApplicationInfo();
|
||||
mTileByComponentCache = new HashMap<>();
|
||||
mCategoryByKeyMap = new HashMap<>();
|
||||
@@ -130,18 +132,21 @@ public class CategoryManagerTest {
|
||||
// Create some fake tiles that are not sorted.
|
||||
final String testPackage = "com.android.test";
|
||||
final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class1";
|
||||
final Tile tile1 = new Tile(mActivityInfo, category.key);
|
||||
tile1.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class1"));
|
||||
tile1.priority = 100;
|
||||
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class2";
|
||||
final Tile tile2 = new Tile(mActivityInfo, category.key);
|
||||
tile2.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class2"));
|
||||
tile2.priority = 50;
|
||||
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class3";
|
||||
final Tile tile3 = new Tile(mActivityInfo, category.key);
|
||||
tile3.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class3"));
|
||||
tile3.priority = 200;
|
||||
|
||||
category.addTile(tile1);
|
||||
category.addTile(tile2);
|
||||
category.addTile(tile3);
|
||||
@@ -163,18 +168,22 @@ public class CategoryManagerTest {
|
||||
final String testPackage1 = "com.android.test1";
|
||||
final String testPackage2 = "com.android.test2";
|
||||
final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
|
||||
|
||||
mActivityInfo.packageName = testPackage2;
|
||||
mActivityInfo.name = "class1";
|
||||
final Tile tile1 = new Tile(mActivityInfo, category.key);
|
||||
tile1.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage2, "class1"));
|
||||
tile1.priority = 100;
|
||||
|
||||
mActivityInfo.packageName = testPackage1;
|
||||
mActivityInfo.name = "class2";
|
||||
final Tile tile2 = new Tile(mActivityInfo, category.key);
|
||||
tile2.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage1, "class2"));
|
||||
tile2.priority = 100;
|
||||
|
||||
mActivityInfo.packageName = testPackage1;
|
||||
mActivityInfo.name = "class3";
|
||||
final Tile tile3 = new Tile(mActivityInfo, category.key);
|
||||
tile3.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage1, "class3"));
|
||||
tile3.priority = 50;
|
||||
|
||||
category.addTile(tile1);
|
||||
category.addTile(tile2);
|
||||
category.addTile(tile3);
|
||||
@@ -194,18 +203,22 @@ public class CategoryManagerTest {
|
||||
// Create some fake tiles that are not sorted.
|
||||
final String testPackage = mContext.getPackageName();
|
||||
final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
|
||||
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class1";
|
||||
final Tile tile1 = new Tile(mActivityInfo, category.key);
|
||||
tile1.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class1"));
|
||||
tile1.priority = 100;
|
||||
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class2";
|
||||
final Tile tile2 = new Tile(mActivityInfo, category.key);
|
||||
tile2.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class2"));
|
||||
tile2.priority = 100;
|
||||
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class3";
|
||||
final Tile tile3 = new Tile(mActivityInfo, category.key);
|
||||
tile3.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class3"));
|
||||
tile3.priority = 50;
|
||||
|
||||
category.addTile(tile1);
|
||||
category.addTile(tile2);
|
||||
category.addTile(tile3);
|
||||
@@ -226,17 +239,21 @@ public class CategoryManagerTest {
|
||||
final String testPackage = mContext.getPackageName();
|
||||
final String testPackage2 = "com.google.test2";
|
||||
final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class1";
|
||||
final Tile tile1 = new Tile(mActivityInfo, category.key);
|
||||
tile1.intent = new Intent().setComponent(new ComponentName(testPackage, "class1"));
|
||||
tile1.priority = 2;
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class2";
|
||||
final Tile tile2 = new Tile(mActivityInfo, category.key);
|
||||
tile2.intent = new Intent().setComponent(new ComponentName(testPackage, "class2"));
|
||||
tile2.priority = 1;
|
||||
mActivityInfo.packageName = testPackage2;
|
||||
mActivityInfo.name = "class0";
|
||||
final Tile tile3 = new Tile(mActivityInfo, category.key);
|
||||
tile3.intent = new Intent().setComponent(new ComponentName(testPackage2, "class0"));
|
||||
tile3.priority = 0;
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class3";
|
||||
final Tile tile4 = new Tile(mActivityInfo, category.key);
|
||||
tile4.intent = new Intent().setComponent(new ComponentName(testPackage, "class3"));
|
||||
tile4.priority = -1;
|
||||
category.addTile(tile1);
|
||||
category.addTile(tile2);
|
||||
@@ -261,15 +278,21 @@ public class CategoryManagerTest {
|
||||
final String testPackage2 = "com.google.test2";
|
||||
final String testPackage3 = "com.abcde.test3";
|
||||
final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
|
||||
mActivityInfo.packageName = testPackage2;
|
||||
mActivityInfo.name = "class1";
|
||||
final Tile tile1 = new Tile(mActivityInfo, category.key);
|
||||
tile1.intent = new Intent().setComponent(new ComponentName(testPackage2, "class1"));
|
||||
tile1.priority = 1;
|
||||
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class2";
|
||||
final Tile tile2 = new Tile(mActivityInfo, category.key);
|
||||
tile2.intent = new Intent().setComponent(new ComponentName(testPackage, "class2"));
|
||||
tile2.priority = 1;
|
||||
|
||||
mActivityInfo.packageName = testPackage3;
|
||||
mActivityInfo.name = "class3";
|
||||
final Tile tile3 = new Tile(mActivityInfo, category.key);
|
||||
tile3.intent = new Intent().setComponent(new ComponentName(testPackage3, "class3"));
|
||||
tile3.priority = 1;
|
||||
|
||||
category.addTile(tile1);
|
||||
category.addTile(tile2);
|
||||
category.addTile(tile3);
|
||||
@@ -289,18 +312,21 @@ public class CategoryManagerTest {
|
||||
// Create some unique tiles
|
||||
final String testPackage = mContext.getPackageName();
|
||||
final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class1";
|
||||
final Tile tile1 = new Tile(mActivityInfo, category.key);
|
||||
tile1.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class1"));
|
||||
tile1.priority = 100;
|
||||
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class2";
|
||||
final Tile tile2 = new Tile(mActivityInfo, category.key);
|
||||
tile2.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class2"));
|
||||
tile2.priority = 100;
|
||||
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class3";
|
||||
final Tile tile3 = new Tile(mActivityInfo, category.key);
|
||||
tile3.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class3"));
|
||||
tile3.priority = 50;
|
||||
|
||||
category.addTile(tile1);
|
||||
category.addTile(tile2);
|
||||
category.addTile(tile3);
|
||||
@@ -316,17 +342,13 @@ public class CategoryManagerTest {
|
||||
// Create tiles pointing to same intent.
|
||||
final String testPackage = mContext.getPackageName();
|
||||
final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class1";
|
||||
final Tile tile1 = new Tile(mActivityInfo, category.key);
|
||||
tile1.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class1"));
|
||||
tile1.priority = 100;
|
||||
final Tile tile2 = new Tile(mActivityInfo, category.key);
|
||||
tile2.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class1"));
|
||||
tile2.priority = 100;
|
||||
final Tile tile3 = new Tile(mActivityInfo, category.key);
|
||||
tile3.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class1"));
|
||||
tile3.priority = 50;
|
||||
category.addTile(tile1);
|
||||
category.addTile(tile2);
|
||||
|
@@ -92,6 +92,8 @@ public class DashboardAdapterTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mFactory = FakeFeatureFactory.setupForTest();
|
||||
mActivityInfo = new ActivityInfo();
|
||||
mActivityInfo.packageName = "pkg";
|
||||
mActivityInfo.name = "class";
|
||||
mActivityInfo.metaData = new Bundle();
|
||||
when(mFactory.dashboardFeatureProvider.shouldTintIcon()).thenReturn(true);
|
||||
|
||||
|
@@ -34,7 +34,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
@@ -101,6 +100,8 @@ public class DashboardFeatureProviderImplTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mActivityInfo = new ActivityInfo();
|
||||
mActivityInfo.packageName = "pkg";
|
||||
mActivityInfo.name = "class";
|
||||
mActivityInfo.metaData = new Bundle();
|
||||
doReturn(mPackageManager).when(mContext).getPackageManager();
|
||||
when(mPackageManager.resolveActivity(any(Intent.class), anyInt()))
|
||||
@@ -140,8 +141,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.priority = 10;
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
|
||||
preference, tile, "123", Preference.DEFAULT_ORDER);
|
||||
@@ -158,8 +157,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
tile.userHandle = new ArrayList<>();
|
||||
tile.userHandle.add(mock(UserHandle.class));
|
||||
tile.userHandle.add(mock(UserHandle.class));
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
|
||||
when(mActivity.getApplicationContext().getSystemService(Context.USER_SERVICE))
|
||||
.thenReturn(mUserManager);
|
||||
@@ -177,8 +174,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.userHandle = new ArrayList<>();
|
||||
tile.userHandle.add(mock(UserHandle.class));
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
|
||||
when(mActivity.getSystemService(Context.USER_SERVICE))
|
||||
.thenReturn(mUserManager);
|
||||
@@ -198,12 +193,10 @@ public class DashboardFeatureProviderImplTest {
|
||||
@Test
|
||||
public void bindPreference_toInternalSettingActivity_shouldBindToDirectLaunchIntentAndNotLog() {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
mActivityInfo.packageName = RuntimeEnvironment.application.getPackageName();
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.userHandle = new ArrayList<>();
|
||||
tile.userHandle.add(mock(UserHandle.class));
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(
|
||||
new ComponentName(RuntimeEnvironment.application.getPackageName(), "class"));
|
||||
|
||||
when(mActivity.getSystemService(Context.USER_SERVICE))
|
||||
.thenReturn(mUserManager);
|
||||
@@ -234,8 +227,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
public void bindPreference_withNullKeyNullPriority_shouldGenerateKeyAndPriority() {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
|
||||
preference, tile, null /*key */, Preference.DEFAULT_ORDER);
|
||||
|
||||
@@ -247,8 +238,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
public void bindPreference_noSummary_shouldSetSummaryToPlaceholder() {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
|
||||
preference, tile, null /*key */, Preference.DEFAULT_ORDER);
|
||||
|
||||
@@ -261,8 +250,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.summary = "test";
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
|
||||
preference, tile, null /*key */, Preference.DEFAULT_ORDER);
|
||||
|
||||
@@ -274,8 +261,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
public void bindPreference_hasSummaryUri_shouldLoadSummaryFromContentProvider() {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
mActivityInfo.metaData.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI,
|
||||
"content://com.android.settings/tile_summary");
|
||||
|
||||
@@ -290,8 +275,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.key = "key";
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
|
||||
preference, tile, null /* key */, Preference.DEFAULT_ORDER);
|
||||
|
||||
@@ -302,11 +285,9 @@ public class DashboardFeatureProviderImplTest {
|
||||
@Config(shadows = {ShadowTileUtils.class, ShadowThreadUtils.class})
|
||||
public void bindPreference_withIconUri_shouldLoadIconFromContentProvider() {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
mActivityInfo.packageName = RuntimeEnvironment.application.getPackageName();
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.key = "key";
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(
|
||||
new ComponentName(RuntimeEnvironment.application.getPackageName(), "class"));
|
||||
mActivityInfo.metaData.putString(TileUtils.META_DATA_PREFERENCE_ICON_URI,
|
||||
"content://com.android.settings/tile_icon");
|
||||
mImpl.bindIcon(preference, tile);
|
||||
@@ -357,8 +338,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.key = "key";
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction");
|
||||
tile.userHandle = null;
|
||||
mImpl.bindPreferenceToTile(activity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
|
||||
@@ -382,8 +361,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
final Preference preference = new Preference(application.getApplicationContext());
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.key = "key";
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction");
|
||||
tile.userHandle = null;
|
||||
|
||||
@@ -457,8 +434,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
@Test
|
||||
public void openTileIntent_profileSelectionDialog_shouldShow() {
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
final ArrayList<UserHandle> handles = new ArrayList<>();
|
||||
handles.add(new UserHandle(0));
|
||||
handles.add(new UserHandle(10));
|
||||
@@ -474,8 +449,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
public void openTileIntent_profileSelectionDialog_explicitMetadataShouldShow() {
|
||||
mActivityInfo.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_ALL);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
final ArrayList<UserHandle> handles = new ArrayList<>();
|
||||
handles.add(new UserHandle(0));
|
||||
handles.add(new UserHandle(10));
|
||||
@@ -491,8 +464,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
public void openTileIntent_profileSelectionDialog_shouldNotShow() {
|
||||
mActivityInfo.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_PRIMARY);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
final ArrayList<UserHandle> handles = new ArrayList<>();
|
||||
handles.add(new UserHandle(0));
|
||||
handles.add(new UserHandle(10));
|
||||
|
@@ -67,6 +67,8 @@ public class DashboardFragmentTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mActivityInfo = new ActivityInfo();
|
||||
mActivityInfo.packageName = "pkg";
|
||||
mActivityInfo.name = "class";
|
||||
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mDashboardCategory = new DashboardCategory("key");
|
||||
mDashboardCategory.addTile(new Tile(mActivityInfo, mDashboardCategory.key));
|
||||
|
@@ -43,7 +43,10 @@ public class DashboardItemAnimatorTest {
|
||||
public void SetUp() {
|
||||
mDashboardItemAnimator = new DashboardItemAnimator();
|
||||
mViewHolder = new ViewHolder(new TextView(RuntimeEnvironment.application));
|
||||
mViewHolder.itemView.setTag(new Tile(new ActivityInfo(), CategoryKey.CATEGORY_HOMEPAGE));
|
||||
final ActivityInfo activityInfo = new ActivityInfo();
|
||||
activityInfo.packageName = "pkg";
|
||||
activityInfo.name = "class";
|
||||
mViewHolder.itemView.setTag(new Tile(activityInfo, CategoryKey.CATEGORY_HOMEPAGE));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -22,7 +22,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
@@ -52,8 +51,10 @@ public class SummaryLoaderTest {
|
||||
public void SetUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
|
||||
mTile = new Tile(new ActivityInfo(), CategoryKey.CATEGORY_HOMEPAGE);
|
||||
final ActivityInfo activityInfo = new ActivityInfo();
|
||||
activityInfo.packageName = "pkg";
|
||||
activityInfo.name = "class";
|
||||
mTile = new Tile(activityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
mTile.summary = SUMMARY_1;
|
||||
mCallbackInvoked = false;
|
||||
|
||||
@@ -86,9 +87,11 @@ public class SummaryLoaderTest {
|
||||
public void testUpdateSummaryToCache_hasCache_shouldUpdate() {
|
||||
final String testSummary = "test_summary";
|
||||
final DashboardCategory category = new DashboardCategory(CategoryKey.CATEGORY_HOMEPAGE);
|
||||
final Tile tile = new Tile(new ActivityInfo(), category.key);
|
||||
final ActivityInfo activityInfo = new ActivityInfo();
|
||||
activityInfo.packageName = "pkg";
|
||||
activityInfo.name = "cls";
|
||||
final Tile tile = new Tile(activityInfo, category.key);
|
||||
tile.key = "123";
|
||||
tile.intent = new Intent();
|
||||
category.addTile(tile);
|
||||
when(mFeatureFactory.dashboardFeatureProvider.getDashboardKeyForTile(tile))
|
||||
.thenReturn(tile.key);
|
||||
|
@@ -24,7 +24,6 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.UserHandle;
|
||||
@@ -51,6 +50,8 @@ public class ProfileSelectDialogTest {
|
||||
@Mock
|
||||
private UserManager mUserManager;
|
||||
|
||||
private ActivityInfo mActivityInfo;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
@@ -58,12 +59,15 @@ public class ProfileSelectDialogTest {
|
||||
final UserInfo userInfo = new UserInfo(
|
||||
NORMAL_USER.getIdentifier(), "test_user", UserInfo.FLAG_RESTRICTED);
|
||||
when(mUserManager.getUserInfo(NORMAL_USER.getIdentifier())).thenReturn(userInfo);
|
||||
mActivityInfo = new ActivityInfo();
|
||||
mActivityInfo.packageName = "pkg";
|
||||
mActivityInfo.name = "cls";
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateUserHandlesIfNeeded_Normal() {
|
||||
final Tile tile = new Tile(new ActivityInfo(), CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.intent = new Intent();
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.userHandle.add(NORMAL_USER);
|
||||
|
||||
ProfileSelectDialog.updateUserHandlesIfNeeded(mContext, tile);
|
||||
@@ -75,8 +79,7 @@ public class ProfileSelectDialogTest {
|
||||
|
||||
@Test
|
||||
public void updateUserHandlesIfNeeded_Remove() {
|
||||
final Tile tile = new Tile(new ActivityInfo(), CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.intent = new Intent();
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.userHandle.add(REMOVED_USER);
|
||||
tile.userHandle.add(NORMAL_USER);
|
||||
tile.userHandle.add(REMOVED_USER);
|
||||
|
@@ -78,6 +78,8 @@ public class SuggestionFeatureProviderImplTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mFactory = FakeFeatureFactory.setupForTest();
|
||||
mActivityInfo = new ActivityInfo();
|
||||
mActivityInfo.packageName = "pkg";
|
||||
mActivityInfo.name = "class";
|
||||
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||
// Explicit casting to object due to MockitoCast bug
|
||||
when((Object) mContext.getSystemService(FingerprintManager.class))
|
||||
|
Reference in New Issue
Block a user