import android.widget.ImageView;
import android.widget.ListView;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.Settings.TetherSettingsActivity;
+import com.android.settings.overlay.FeatureFactory;
import java.util.ArrayList;
import java.util.List;
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
- ListItem item = itemForPosition(position);
+ final ListItem item = itemForPosition(position);
+ logCreateShortcut(item.resolveInfo);
setResult(RESULT_OK, createResultIntent(intentForPosition(position),
item.resolveInfo, item.label));
finish();
return intent;
}
+ private void logCreateShortcut(ResolveInfo info) {
+ if (info == null || info.activityInfo == null) {
+ return;
+ }
+ FeatureFactory.getFactory(this).getMetricsFeatureProvider().action(
+ this, MetricsProto.MetricsEvent.ACTION_SETTINGS_CREATE_SHORTCUT,
+ info.activityInfo.name);
+ }
+
private Bitmap createIcon(int resource) {
Context context = new ContextThemeWrapper(this, android.R.style.Theme_Material);
View view = LayoutInflater.from(context).inflate(R.layout.shortcut_badge, null);
continue;
}
updates.add(new ShortcutInfo.Builder(mContext, info.getId())
- .setShortLabel(ri.loadLabel(pm)).build());
+ .setShortLabel(ri.loadLabel(pm)).build());
}
if (!updates.isEmpty()) {
sm.updateShortcuts(updates);
import com.android.settingslib.drawer.SettingsDrawerActivity;
import com.android.settingslib.drawer.Tile;
-import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import android.text.TextUtils;
import android.util.Log;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.SettingsActivity;
+import com.android.settings.core.instrumentation.MetricsFeatureProvider;
+import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.drawer.CategoryManager;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.ProfileSelectDialog;
protected final Context mContext;
-
+ private final MetricsFeatureProvider mMetricsFeatureProvider;
private final CategoryManager mCategoryManager;
public DashboardFeatureProviderImpl(Context context) {
mContext = context.getApplicationContext();
mCategoryManager = CategoryManager.get(context, getExtraIntentAction());
+ mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
@VisibleForTesting
DashboardFeatureProviderImpl(Context context, CategoryManager categoryManager) {
mContext = context.getApplicationContext();
mCategoryManager = categoryManager;
+ mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
@Override
private void launchIntentOrSelectProfile(Activity activity, Tile tile, Intent intent) {
ProfileSelectDialog.updateUserHandlesIfNeeded(mContext, tile);
if (tile.userHandle == null) {
+ logStartActivity(intent);
activity.startActivityForResult(intent, 0);
} else if (tile.userHandle.size() == 1) {
+ logStartActivity(intent);
activity.startActivityForResultAsUser(intent, 0, tile.userHandle.get(0));
} else {
ProfileSelectDialog.show(activity.getFragmentManager(), tile);
}
}
+
+ private void logStartActivity(Intent intent) {
+ if (intent == null) {
+ return;
+ }
+ final ComponentName cn = intent.getComponent();
+ if (cn == null) {
+ return;
+ }
+ mMetricsFeatureProvider.action(mContext,
+ MetricsProto.MetricsEvent.ACTION_SETTINGS_TILE_CLICK,
+ cn.flattenToString());
+ }
}
import android.os.UserManager;
import android.support.v7.preference.Preference;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.drawer.CategoryManager;
import com.android.settingslib.drawer.DashboardCategory;
private UserManager mUserManager;
@Mock
private CategoryManager mCategoryManager;
+ private FakeFeatureFactory mFeatureFactory;
private DashboardFeatureProviderImpl mImpl;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ FakeFeatureFactory.setupForTest(mActivity);
+ mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mActivity);
mImpl = new DashboardFeatureProviderImpl(mActivity);
}
mImpl.bindPreferenceToTile(mActivity, preference, tile, "123", Preference.DEFAULT_ORDER);
preference.getOnPreferenceClickListener().onPreferenceClick(null);
-
+ verify(mFeatureFactory.metricsFeatureProvider).action(
+ any(Context.class),
+ eq(MetricsProto.MetricsEvent.ACTION_SETTINGS_TILE_CLICK),
+ eq(tile.intent.getComponent().flattenToString()));
verify(mActivity)
.startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
}