Log source with visibility change
- Add a method in VisibilityLoggerMixin to log visible event using LogMaker, which allows logging additional FIELD_CONTEXT field. - In Utils.startFragment, add current page's metricsCategory as an extra to next page. - In next page's onResume(), extract the previous page's metricsCategory and send it to VisibilityLoggerMixin.visible() - Update all caller with additional paramters Change-Id: I8e1f2597fa465b7d3aa16fa1d21c052a3219694a Fix: 35359289 Test: RunSettingsRoboTests
This commit is contained in:
@@ -252,7 +252,6 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
/**
|
||||
* Returns the default link's IP addresses, if any, taking into account IPv4 and IPv6 style
|
||||
* addresses.
|
||||
* @param context the application context
|
||||
* @return the formatted and newline-separated IP addresses, or null if none.
|
||||
*/
|
||||
public static String getDefaultIpAddresses(ConnectivityManager cm) {
|
||||
@@ -496,12 +495,14 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
* @param titleResId resource id for the String to display for the title of this set
|
||||
* of preferences.
|
||||
* @param title String to display for the title of this set of preferences.
|
||||
* @param metricsCategory The current metricsCategory for logging source when fragment starts
|
||||
*/
|
||||
public static void startWithFragment(Context context, String fragmentName, Bundle args,
|
||||
Fragment resultTo, int resultRequestCode, int titleResId,
|
||||
CharSequence title) {
|
||||
CharSequence title, int metricsCategory) {
|
||||
startWithFragment(context, fragmentName, args, resultTo, resultRequestCode,
|
||||
null /* titleResPackageName */, titleResId, title, false /* not a shortcut */);
|
||||
null /* titleResPackageName */, titleResId, title, false /* not a shortcut */,
|
||||
metricsCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -519,19 +520,21 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
* @param titleResId resource id for the String to display for the title of this set
|
||||
* of preferences.
|
||||
* @param title String to display for the title of this set of preferences.
|
||||
* @param metricsCategory The current metricsCategory for logging source when fragment starts
|
||||
*/
|
||||
public static void startWithFragment(Context context, String fragmentName, Bundle args,
|
||||
Fragment resultTo, int resultRequestCode, String titleResPackageName, int titleResId,
|
||||
CharSequence title) {
|
||||
CharSequence title, int metricsCategory) {
|
||||
startWithFragment(context, fragmentName, args, resultTo, resultRequestCode,
|
||||
titleResPackageName, titleResId, title, false /* not a shortcut */);
|
||||
titleResPackageName, titleResId, title, false /* not a shortcut */,
|
||||
metricsCategory);
|
||||
}
|
||||
|
||||
public static void startWithFragment(Context context, String fragmentName, Bundle args,
|
||||
Fragment resultTo, int resultRequestCode, int titleResId,
|
||||
CharSequence title, boolean isShortcut) {
|
||||
CharSequence title, boolean isShortcut, int metricsCategory) {
|
||||
Intent intent = onBuildStartFragmentIntent(context, fragmentName, args,
|
||||
null /* titleResPackageName */, titleResId, title, isShortcut);
|
||||
null /* titleResPackageName */, titleResId, title, isShortcut, metricsCategory);
|
||||
if (resultTo == null) {
|
||||
context.startActivity(intent);
|
||||
} else {
|
||||
@@ -541,9 +544,9 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
|
||||
public static void startWithFragment(Context context, String fragmentName, Bundle args,
|
||||
Fragment resultTo, int resultRequestCode, String titleResPackageName, int titleResId,
|
||||
CharSequence title, boolean isShortcut) {
|
||||
CharSequence title, boolean isShortcut, int metricsCategory) {
|
||||
Intent intent = onBuildStartFragmentIntent(context, fragmentName, args, titleResPackageName,
|
||||
titleResId, title, isShortcut);
|
||||
titleResId, title, isShortcut, metricsCategory);
|
||||
if (resultTo == null) {
|
||||
context.startActivity(intent);
|
||||
} else {
|
||||
@@ -552,30 +555,15 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
}
|
||||
|
||||
public static void startWithFragmentAsUser(Context context, String fragmentName, Bundle args,
|
||||
int titleResId, CharSequence title, boolean isShortcut,
|
||||
int titleResId, CharSequence title, boolean isShortcut, int metricsCategory,
|
||||
UserHandle userHandle) {
|
||||
// workaround to avoid crash in b/17523189
|
||||
if (userHandle.getIdentifier() == UserHandle.myUserId()) {
|
||||
startWithFragment(context, fragmentName, args, null, 0, titleResId, title, isShortcut);
|
||||
startWithFragment(context, fragmentName, args, null, 0, titleResId, title, isShortcut,
|
||||
metricsCategory);
|
||||
} else {
|
||||
Intent intent = onBuildStartFragmentIntent(context, fragmentName, args,
|
||||
null /* titleResPackageName */, titleResId, title, isShortcut);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
context.startActivityAsUser(intent, userHandle);
|
||||
}
|
||||
}
|
||||
|
||||
public static void startWithFragmentAsUser(Context context, String fragmentName, Bundle args,
|
||||
String titleResPackageName, int titleResId, CharSequence title, boolean isShortcut,
|
||||
UserHandle userHandle) {
|
||||
// workaround to avoid crash in b/17523189
|
||||
if (userHandle.getIdentifier() == UserHandle.myUserId()) {
|
||||
startWithFragment(context, fragmentName, args, null, 0, titleResPackageName, titleResId,
|
||||
title, isShortcut);
|
||||
} else {
|
||||
Intent intent = onBuildStartFragmentIntent(context, fragmentName, args,
|
||||
titleResPackageName, titleResId, title, isShortcut);
|
||||
null /* titleResPackageName */, titleResId, title, isShortcut, metricsCategory);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
context.startActivityAsUser(intent, userHandle);
|
||||
@@ -595,12 +583,13 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
* @param titleResId Optional title resource id to show for this item.
|
||||
* @param title Optional title to show for this item.
|
||||
* @param isShortcut tell if this is a Launcher Shortcut or not
|
||||
* @param sourceMetricsCategory The context (source) from which an action is performed
|
||||
* @return Returns an Intent that can be launched to display the given
|
||||
* fragment.
|
||||
*/
|
||||
public static Intent onBuildStartFragmentIntent(Context context, String fragmentName,
|
||||
Bundle args, String titleResPackageName, int titleResId, CharSequence title,
|
||||
boolean isShortcut) {
|
||||
boolean isShortcut, int sourceMetricsCategory) {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.setClass(context, SubSettings.class);
|
||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, fragmentName);
|
||||
@@ -610,6 +599,7 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, titleResId);
|
||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE, title);
|
||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SHORTCUT, isShortcut);
|
||||
intent.putExtra(SettingsActivity.EXTRA_SOURCE_METRICS_CATEGORY, sourceMetricsCategory);
|
||||
return intent;
|
||||
}
|
||||
|
||||
@@ -1197,15 +1187,6 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isPackageEnabled(Context context, String packageName) {
|
||||
try {
|
||||
return context.getPackageManager().getApplicationInfo(packageName, 0).enabled;
|
||||
} catch (NameNotFoundException e) {
|
||||
// Thrown by PackageManager.getApplicationInfo if the package does not exist
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPackageDirectBootAware(Context context, String packageName) {
|
||||
try {
|
||||
final ApplicationInfo ai = context.getPackageManager().getApplicationInfo(
|
||||
|
||||
Reference in New Issue
Block a user