Log connected devices entrypoint for analytics
Test: locally tested Bug: N/A Flag: EXEMPT loggings only Change-Id: I5158a026fecdd19245f7427431563dd754dff2eb
This commit is contained in:
@@ -17,6 +17,7 @@ package com.android.settings.connecteddevice;
|
|||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -34,18 +35,25 @@ import com.android.settings.search.BaseSearchIndexProvider;
|
|||||||
import com.android.settings.slices.SlicePreferenceController;
|
import com.android.settings.slices.SlicePreferenceController;
|
||||||
import com.android.settingslib.bluetooth.BluetoothUtils;
|
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||||
import com.android.settingslib.bluetooth.HearingAidStatsLogUtils;
|
import com.android.settingslib.bluetooth.HearingAidStatsLogUtils;
|
||||||
|
|
||||||
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
|
|
||||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||||
public class ConnectedDeviceDashboardFragment extends DashboardFragment {
|
public class ConnectedDeviceDashboardFragment extends DashboardFragment {
|
||||||
|
|
||||||
private static final String TAG = "ConnectedDeviceFrag";
|
private static final String TAG = "ConnectedDeviceFrag";
|
||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
private static final String SETTINGS_SEARCH_ACTION =
|
||||||
private static final String SLICE_ACTION = "com.android.settings.SEARCH_RESULT_TRAMPOLINE";
|
"com.android.settings.SEARCH_RESULT_TRAMPOLINE";
|
||||||
|
|
||||||
@VisibleForTesting static final String KEY_CONNECTED_DEVICES = "connected_device_list";
|
@VisibleForTesting static final String KEY_CONNECTED_DEVICES = "connected_device_list";
|
||||||
@VisibleForTesting static final String KEY_AVAILABLE_DEVICES = "available_device_list";
|
@VisibleForTesting static final String KEY_AVAILABLE_DEVICES = "available_device_list";
|
||||||
|
|
||||||
|
private static final String ENTRYPOINT_SYSUI = "bt_settings_entrypoint_sysui";
|
||||||
|
private static final String ENTRYPOINT_SETTINGS = "bt_settings_entrypoint_settings_click";
|
||||||
|
private static final String ENTRYPOINT_SETTINGS_SEARCH =
|
||||||
|
"bt_settings_entrypoint_settings_search";
|
||||||
|
private static final String ENTRYPOINT_OTHER = "bt_settings_entrypoint_other";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return SettingsEnums.SETTINGS_CONNECTED_DEVICE_CATEGORY;
|
return SettingsEnums.SETTINGS_CONNECTED_DEVICE_CATEGORY;
|
||||||
@@ -71,15 +79,16 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
|
|||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
String callingAppPackageName =
|
String callingAppPackageName =
|
||||||
((SettingsActivity) getActivity()).getInitialCallingPackage();
|
((SettingsActivity) getActivity()).getInitialCallingPackage();
|
||||||
String action = getIntent() != null ? getIntent().getAction() : "";
|
Intent intent = getIntent();
|
||||||
if (DEBUG) {
|
String action = intent != null ? intent.getAction() : "";
|
||||||
|
|
||||||
Log.d(
|
Log.d(
|
||||||
TAG,
|
TAG,
|
||||||
"onAttach() calling package name is : "
|
"onAttach() calling package name is : "
|
||||||
+ callingAppPackageName
|
+ callingAppPackageName
|
||||||
+ ", action : "
|
+ ", action : "
|
||||||
+ action);
|
+ action);
|
||||||
}
|
|
||||||
if (BluetoothUtils.isAudioSharingUIAvailable(context)) {
|
if (BluetoothUtils.isAudioSharingUIAvailable(context)) {
|
||||||
use(AudioSharingDevicePreferenceController.class).init(this);
|
use(AudioSharingDevicePreferenceController.class).init(this);
|
||||||
}
|
}
|
||||||
@@ -100,16 +109,51 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
|
|||||||
provider.sendActivityIfAvailable(category);
|
provider.sendActivityIfAvailable(category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logPageEntrypoint(context, callingAppPackageName, intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
boolean isAlwaysDiscoverable(String callingAppPackageName, String action) {
|
boolean isAlwaysDiscoverable(String callingAppPackageName, String action) {
|
||||||
return TextUtils.equals(SLICE_ACTION, action)
|
return TextUtils.equals(SETTINGS_SEARCH_ACTION, action)
|
||||||
? false
|
? false
|
||||||
: TextUtils.equals(Utils.SETTINGS_PACKAGE_NAME, callingAppPackageName)
|
: TextUtils.equals(Utils.SETTINGS_PACKAGE_NAME, callingAppPackageName)
|
||||||
|| TextUtils.equals(Utils.SYSTEMUI_PACKAGE_NAME, callingAppPackageName);
|
|| TextUtils.equals(Utils.SYSTEMUI_PACKAGE_NAME, callingAppPackageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void logPageEntrypoint(Context context, String callingAppPackageName, Intent intent) {
|
||||||
|
String action = intent != null ? intent.getAction() : "";
|
||||||
|
if (TextUtils.equals(Utils.SYSTEMUI_PACKAGE_NAME, callingAppPackageName)) {
|
||||||
|
mMetricsFeatureProvider.action(
|
||||||
|
context, SettingsEnums.SETTINGS_CONNECTED_DEVICES_ENTRYPOINT, ENTRYPOINT_SYSUI);
|
||||||
|
} else if (TextUtils.equals(Utils.SETTINGS_PACKAGE_NAME, callingAppPackageName)
|
||||||
|
&& TextUtils.equals(Intent.ACTION_MAIN, action)) {
|
||||||
|
String sourceCategory =
|
||||||
|
intent != null
|
||||||
|
? Integer.toString(
|
||||||
|
getIntent()
|
||||||
|
.getIntExtra(
|
||||||
|
MetricsFeatureProvider
|
||||||
|
.EXTRA_SOURCE_METRICS_CATEGORY,
|
||||||
|
SettingsEnums.PAGE_UNKNOWN))
|
||||||
|
: "";
|
||||||
|
mMetricsFeatureProvider.action(
|
||||||
|
context,
|
||||||
|
SettingsEnums.SETTINGS_CONNECTED_DEVICES_ENTRYPOINT,
|
||||||
|
ENTRYPOINT_SETTINGS + "_" + sourceCategory);
|
||||||
|
} else if (TextUtils.equals(Utils.SETTINGS_PACKAGE_NAME, callingAppPackageName)
|
||||||
|
&& TextUtils.equals(SETTINGS_SEARCH_ACTION, action)) {
|
||||||
|
mMetricsFeatureProvider.action(
|
||||||
|
context,
|
||||||
|
SettingsEnums.SETTINGS_CONNECTED_DEVICES_ENTRYPOINT,
|
||||||
|
ENTRYPOINT_SETTINGS_SEARCH);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mMetricsFeatureProvider.action(
|
||||||
|
context, SettingsEnums.SETTINGS_CONNECTED_DEVICES_ENTRYPOINT, ENTRYPOINT_OTHER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** For Search. */
|
/** For Search. */
|
||||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
new BaseSearchIndexProvider(R.xml.connected_devices);
|
new BaseSearchIndexProvider(R.xml.connected_devices);
|
||||||
|
Reference in New Issue
Block a user