Add locale recommendation metrics

Bug: 275306065
Test: atest SettingsRoboTests:com.android.settings.localepicker
Change-Id: I7263c292eee51475274585fe4c0864f82fabf7d2
This commit is contained in:
Allen Su
2023-12-25 02:56:30 +00:00
parent b1ab7f0373
commit 30e1bf61b7
7 changed files with 31 additions and 0 deletions

View File

@@ -176,6 +176,8 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
localeInfo.getFullNameNative()),
getString(R.string.desc_system_locale_addition),
localeTag);
mMetricsFeatureProvider.action(this,
SettingsEnums.ACTION_NOTIFICATION_FOR_SYSTEM_LOCALE);
}
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Unable to find info for package: " + mPackageName);

View File

@@ -245,6 +245,7 @@ public class LocaleListEditor extends RestrictedSettingsFragment implements View
}
mAdapter.setCacheItemList();
} else if (requestCode == DIALOG_ADD_SYSTEM_LOCALE) {
int action = SettingsEnums.ACTION_CANCEL_SYSTEM_LOCALE_FROM_RECOMMENDATION;
if (resultCode == Activity.RESULT_OK) {
localeInfo = (LocaleStore.LocaleInfo) data.getExtras().getSerializable(
LocaleDialogFragment.ARG_TARGET_LOCALE);
@@ -252,7 +253,9 @@ public class LocaleListEditor extends RestrictedSettingsFragment implements View
getContext().getContentResolver(),
Settings.System.LOCALE_PREFERENCES);
mAdapter.addLocale(mayAppendUnicodeTags(localeInfo, preferencesTags));
action = SettingsEnums.ACTION_ADD_SYSTEM_LOCALE_FROM_RECOMMENDATION;
}
mMetricsFeatureProvider.action(getContext(), action);
}
super.onActivityResult(requestCode, resultCode, data);
}

View File

@@ -21,6 +21,7 @@ import static com.android.settings.localepicker.AppLocalePickerActivity.EXTRA_NO
import static com.android.settings.localepicker.LocaleListEditor.EXTRA_SYSTEM_LOCALE_DIALOG_TYPE;
import static com.android.settings.localepicker.LocaleListEditor.LOCALE_SUGGESTION;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@@ -32,6 +33,8 @@ import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AppCompatActivity;
import com.android.settings.overlay.FeatureFactory;
/**
* An Activity that launches the system locale settings page.
*/
@@ -60,6 +63,8 @@ public class NotificationActionActivity extends AppCompatActivity {
actionIntent.putExtra(EXTRA_APP_LOCALE, appLocale);
actionIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
getLauncher().launch(actionIntent);
FeatureFactory.getFeatureFactory().getMetricsFeatureProvider().action(this,
SettingsEnums.ACTION_NOTIFICATION_CLICK_FOR_SYSTEM_LOCALE);
finish();
return;
}

View File

@@ -19,6 +19,7 @@ package com.android.settings.localepicker;
import static com.android.settings.localepicker.AppLocalePickerActivity.EXTRA_APP_LOCALE;
import static com.android.settings.localepicker.AppLocalePickerActivity.EXTRA_NOTIFICATION_ID;
import android.app.settings.SettingsEnums;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -26,6 +27,8 @@ import android.util.Log;
import androidx.annotation.VisibleForTesting;
import com.android.settings.overlay.FeatureFactory;
/**
* A Broadcast receiver that handles the locale notification which is swiped away.
*/
@@ -41,6 +44,8 @@ public class NotificationCancelReceiver extends BroadcastReceiver {
Log.i(TAG, "Locale notification is swiped away.");
if (savedNotificationID == notificationId) {
getNotificationController(context).incrementDismissCount(appLocale);
FeatureFactory.getFeatureFactory().getMetricsFeatureProvider().action(context,
SettingsEnums.ACTION_NOTIFICATION_SWIPE_FOR_SYSTEM_LOCALE);
}
}