Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87f76d1c authored by Allen Su's avatar Allen Su Committed by Android (Google) Code Review
Browse files

Merge "Add locale recommendation metrics" into main

parents ec244f2f 30e1bf61
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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);
+3 −0
Original line number Diff line number Diff line
@@ -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);
    }
+5 −0
Original line number Diff line number Diff line
@@ -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;
        }
+5 −0
Original line number Diff line number Diff line
@@ -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);
        }
    }

+2 −0
Original line number Diff line number Diff line
@@ -314,6 +314,8 @@ public class AppLocalePickerActivityTest {
        assertThat(info.getNotificationCount()).isEqualTo(1);
        assertThat(info.getDismissCount()).isEqualTo(0);
        assertThat(info.getLastNotificationTimeMs()).isNotEqualTo(0);
        verify(mFeatureFactory.metricsFeatureProvider).action(
                any(), eq(SettingsEnums.ACTION_NOTIFICATION_FOR_SYSTEM_LOCALE));

        mDataManager.clearLocaleNotificationMap();
    }
Loading