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