From 61544ef9f3c99d5679ce4c26a5b1ae36dc075ae9 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Fri, 8 May 2020 12:37:15 -0400 Subject: [PATCH] Backed out 3 changesets (bug 1633568) DONTBUILD Backed out changeset fc35d7e69e44 (bug 1633568) Backed out changeset fe76f80393ad (bug 1633568) Backed out changeset 31b72a62024a (bug 1633568) --- .../java/org/mozilla/gecko/BrowserApp.java | 5 +- .../adjust/AdjustBrowserAppDelegate.java | 8 +- .../mozilla/gecko/adjust/AdjustHelper.java | 14 +- .../gecko/adjust/AdjustHelperInterface.java | 2 +- .../adjust/AttributionHelperListener.java | 11 +- .../gecko/adjust/StubAdjustHelper.java | 2 +- .../telemetry/TelemetryCorePingDelegate.java | 7 +- .../TelemetryInstallationPingDelegate.java | 80 -------- .../TelemetryInstallationPingBuilder.java | 181 ------------------ .../TelemetryInstallationPingStore.java | 117 ----------- .../stores/TelemetryJSONFilePingStore.java | 16 +- .../telemetry/docs/data/installation-ping.rst | 57 ------ 12 files changed, 23 insertions(+), 477 deletions(-) delete mode 100644 mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryInstallationPingDelegate.java delete mode 100644 mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetryInstallationPingBuilder.java delete mode 100644 mobile/android/base/java/org/mozilla/gecko/telemetry/stores/TelemetryInstallationPingStore.java delete mode 100644 toolkit/components/telemetry/docs/data/installation-ping.rst diff --git a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java index 04bde0da3c5ba..9fda26104c239 100644 --- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java +++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java @@ -141,7 +141,6 @@ import org.mozilla.gecko.tabs.TabHistoryFragment; import org.mozilla.gecko.tabs.TabHistoryPage; import org.mozilla.gecko.tabs.TabsPanel; import org.mozilla.gecko.telemetry.TelemetryCorePingDelegate; -import org.mozilla.gecko.telemetry.TelemetryInstallationPingDelegate; import org.mozilla.gecko.telemetry.TelemetryUploadService; import org.mozilla.gecko.telemetry.measurements.SearchCountMeasurements; import org.mozilla.gecko.telemetry.TelemetryActivationPingDelegate; @@ -325,7 +324,6 @@ public class BrowserApp extends GeckoApp private final TelemetryCorePingDelegate mTelemetryCorePingDelegate = new TelemetryCorePingDelegate(); private final TelemetryActivationPingDelegate mTelemetryActivationPingDelegate = new TelemetryActivationPingDelegate(); - private final TelemetryInstallationPingDelegate mTelemetryInstallationPingDelegate = new TelemetryInstallationPingDelegate(); private final List delegates = Collections.unmodifiableList(Arrays.asList( new ScreenshotDelegate(), @@ -333,9 +331,8 @@ public class BrowserApp extends GeckoApp new ReaderViewBookmarkPromotion(), mTelemetryCorePingDelegate, mTelemetryActivationPingDelegate, - mTelemetryInstallationPingDelegate, new OfflineTabStatusDelegate(), - new AdjustBrowserAppDelegate(mTelemetryCorePingDelegate, mTelemetryInstallationPingDelegate) + new AdjustBrowserAppDelegate(mTelemetryCorePingDelegate) )); @NonNull diff --git a/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustBrowserAppDelegate.java b/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustBrowserAppDelegate.java index f160e971def3b..aee0bba63a8a2 100644 --- a/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustBrowserAppDelegate.java +++ b/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustBrowserAppDelegate.java @@ -13,18 +13,18 @@ import org.mozilla.gecko.util.IntentUtils; public class AdjustBrowserAppDelegate extends BrowserAppDelegate { private final AdjustHelperInterface adjustHelper; - private final AttributionHelperListener[] attributionHelperListeners; + private final AttributionHelperListener attributionHelperListener; - public AdjustBrowserAppDelegate(AttributionHelperListener... attributionHelperListeners) { + public AdjustBrowserAppDelegate(AttributionHelperListener attributionHelperListener) { this.adjustHelper = AdjustConstants.getAdjustHelper(); - this.attributionHelperListeners = attributionHelperListeners; + this.attributionHelperListener = attributionHelperListener; } @Override public void onCreate(BrowserApp browserApp, Bundle savedInstanceState) { adjustHelper.onCreate(browserApp, AdjustConstants.MOZ_INSTALL_TRACKING_ADJUST_SDK_APP_TOKEN, - attributionHelperListeners); + attributionHelperListener); final boolean isInAutomation = IntentUtils.getIsInAutomationFromEnvironment( new SafeIntent(browserApp.getIntent())); diff --git a/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelper.java b/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelper.java index 410a172e77504..19399e735bb5d 100644 --- a/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelper.java +++ b/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelper.java @@ -21,9 +21,9 @@ import org.mozilla.gecko.AppConstants; public class AdjustHelper implements AdjustHelperInterface, OnAttributionChangedListener { private static final String LOGTAG = AdjustHelper.class.getSimpleName(); - private AttributionHelperListener[] attributionListeners; + private AttributionHelperListener attributionListener; - public void onCreate(final Context context, final String maybeAppToken, final AttributionHelperListener... listeners) { + public void onCreate(final Context context, final String maybeAppToken, final AttributionHelperListener listener) { final String environment; final LogLevel logLevel; if (AppConstants.MOZILLA_OFFICIAL) { @@ -37,7 +37,7 @@ public class AdjustHelper implements AdjustHelperInterface, OnAttributionChanged // We've got install tracking turned on -- we better have a token! throw new IllegalArgumentException("maybeAppToken must not be null"); } - attributionListeners = listeners; + attributionListener = listener; AdjustConfig config = new AdjustConfig(context, maybeAppToken, environment); config.setLogLevel(logLevel); config.setOnAttributionChangedListener(this); @@ -62,16 +62,14 @@ public class AdjustHelper implements AdjustHelperInterface, OnAttributionChanged @Override public void onAttributionChanged(AdjustAttribution attribution) { - if (attributionListeners == null) { + if (attributionListener == null) { throw new IllegalStateException("Expected non-null attribution listener."); } if (attribution == null) { - Log.e(LOGTAG, "Adjust attribution is null. Skipping informing listeners about this."); + Log.e(LOGTAG, "Adjust attribution is null; skipping campaign id retrieval."); return; } - for (AttributionHelperListener listener: attributionListeners) { - listener.onAttributionChanged(attribution); - } + attributionListener.onCampaignIdChanged(attribution.campaign); } } diff --git a/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelperInterface.java b/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelperInterface.java index 0e4b9ff6455c5..aeb7b4334e9fc 100644 --- a/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelperInterface.java +++ b/mobile/android/base/java/org/mozilla/gecko/adjust/AdjustHelperInterface.java @@ -13,7 +13,7 @@ public interface AdjustHelperInterface { * Register the Application with the Adjust SDK. * @param appToken the (secret!) Adjust SDK per-application token to register with; may be null. */ - void onCreate(final Context context, final String appToken, final AttributionHelperListener... listener); + void onCreate(final Context context, final String appToken, final AttributionHelperListener listener); void onPause(); void onResume(); diff --git a/mobile/android/base/java/org/mozilla/gecko/adjust/AttributionHelperListener.java b/mobile/android/base/java/org/mozilla/gecko/adjust/AttributionHelperListener.java index ada55838707ac..6dadd2261d7a5 100644 --- a/mobile/android/base/java/org/mozilla/gecko/adjust/AttributionHelperListener.java +++ b/mobile/android/base/java/org/mozilla/gecko/adjust/AttributionHelperListener.java @@ -5,20 +5,13 @@ package org.mozilla.gecko.adjust; -import android.support.annotation.NonNull; - -import com.adjust.sdk.AdjustAttribution; - /** * Because of how our build module dependencies are structured, we aren't able to use * the {@link com.adjust.sdk.OnAttributionChangedListener} directly outside of {@link AdjustHelper}. * If the Adjust SDK is enabled, this listener should be notified when {@link com.adjust.sdk.OnAttributionChangedListener} * is fired (i.e. this listener would be daisy-chained to the Adjust one). The listener also - * inherits thread-safety from GeckoSharedPrefs which is used to store the attribution. + * inherits thread-safety from GeckoSharedPrefs which is used to store the campaign ID. */ public interface AttributionHelperListener { - /** - * @param attribution - new Adjust attribution configuration. - */ - void onAttributionChanged(@NonNull final AdjustAttribution attribution); + void onCampaignIdChanged(String campaignId); } diff --git a/mobile/android/base/java/org/mozilla/gecko/adjust/StubAdjustHelper.java b/mobile/android/base/java/org/mozilla/gecko/adjust/StubAdjustHelper.java index 386bd97c05e28..ddfed84bd73b0 100644 --- a/mobile/android/base/java/org/mozilla/gecko/adjust/StubAdjustHelper.java +++ b/mobile/android/base/java/org/mozilla/gecko/adjust/StubAdjustHelper.java @@ -9,7 +9,7 @@ import android.content.Context; import android.content.Intent; public class StubAdjustHelper implements AdjustHelperInterface { - public void onCreate(final Context context, final String appToken, final AttributionHelperListener... listeners) { + public void onCreate(final Context context, final String appToken, final AttributionHelperListener listener) { // Do nothing. } diff --git a/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java b/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java index 5b54657d319c3..fa00a37a7c163 100644 --- a/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java +++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java @@ -9,14 +9,11 @@ package org.mozilla.gecko.telemetry; import android.accessibilityservice.AccessibilityServiceInfo; import android.content.Context; import android.content.SharedPreferences; -import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; import android.util.Log; import android.view.accessibility.AccessibilityManager; -import com.adjust.sdk.AdjustAttribution; - import org.json.JSONArray; import org.json.JSONException; import org.mozilla.gecko.BrowserApp; @@ -276,7 +273,7 @@ public class TelemetryCorePingDelegate extends BrowserAppDelegateWithReference } @Override - public void onAttributionChanged(@NonNull final AdjustAttribution attribution) { - CampaignIdMeasurements.updateCampaignIdPref(getBrowserApp(), attribution.campaign); + public void onCampaignIdChanged(String campaignId) { + CampaignIdMeasurements.updateCampaignIdPref(getBrowserApp(), campaignId); } } diff --git a/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryInstallationPingDelegate.java b/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryInstallationPingDelegate.java deleted file mode 100644 index 50b8c068ca333..0000000000000 --- a/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryInstallationPingDelegate.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at http://mozilla.org/MPL/2.0/. - */ - -package org.mozilla.gecko.telemetry; - -import android.support.annotation.NonNull; -import android.util.Log; - -import com.adjust.sdk.AdjustAttribution; - -import org.mozilla.gecko.BrowserApp; -import org.mozilla.gecko.GeckoAppShell; -import org.mozilla.gecko.adjust.AttributionHelperListener; -import org.mozilla.gecko.delegates.BrowserAppDelegate; -import org.mozilla.gecko.telemetry.pingbuilders.TelemetryInstallationPingBuilder; -import org.mozilla.gecko.telemetry.pingbuilders.TelemetryInstallationPingBuilder.PingReason; -import org.mozilla.gecko.telemetry.schedulers.TelemetryUploadAllPingsImmediatelyScheduler; -import org.mozilla.gecko.telemetry.stores.TelemetryInstallationPingStore; -import org.mozilla.gecko.util.ThreadUtils; - -import java.io.IOException; - -public class TelemetryInstallationPingDelegate - extends BrowserAppDelegate - implements AttributionHelperListener { - - private static final String LOGTAG = "InstallPingDelegate"; - - @Override - public void onStart(BrowserApp browserApp) { - if (!TelemetryUploadService.isUploadEnabledByAppConfig(browserApp)) { - return; - } - - if (!TelemetryInstallationPingStore.hasLightPingBeenUploaded()) { - ThreadUtils.postToBackgroundThread(() -> { - TelemetryInstallationPingStore store = new TelemetryInstallationPingStore(); - TelemetryOutgoingPing ping = new TelemetryInstallationPingBuilder() - .setReason(PingReason.APP_STARTED) - .build(); - - try { - store.storePing(ping.getPayload(), PingReason.APP_STARTED.value, ping.getURLPath()); - store.queuePingsForUpload(new TelemetryUploadAllPingsImmediatelyScheduler()); - } catch (IOException e) { - // #storePing() might throw. Nothing to do. Will try again later. - Log.w(LOGTAG, "Could not store ping. Will try again later"); - } - }); - } - } - - @Override - public void onAttributionChanged(@NonNull final AdjustAttribution attribution) { - if (!TelemetryUploadService.isUploadEnabledByAppConfig(GeckoAppShell.getApplicationContext())) { - return; - } - - if (!TelemetryInstallationPingStore.hasFullPingBeenUploaded()) { - ThreadUtils.postToBackgroundThread(() -> { - TelemetryInstallationPingStore store = new TelemetryInstallationPingStore(); - TelemetryOutgoingPing ping = new TelemetryInstallationPingBuilder() - .setReason(PingReason.ADJUST_AVAILABLE) - .setAdjustProperties(attribution) - .build(); - - try { - store.storePing(ping.getPayload(), PingReason.ADJUST_AVAILABLE.value, ping.getURLPath()); - store.queuePingsForUpload(new TelemetryUploadAllPingsImmediatelyScheduler()); - } catch (IOException e) { - // #storePing() might throw. Nothing to do. Will try again later. - Log.w(LOGTAG, "Could not store ping. Will try again later"); - } - }); - } - } -} diff --git a/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetryInstallationPingBuilder.java b/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetryInstallationPingBuilder.java deleted file mode 100644 index 8638b23858497..0000000000000 --- a/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetryInstallationPingBuilder.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at http://mozilla.org/MPL/2.0/. - */ - -package org.mozilla.gecko.telemetry.pingbuilders; - -import android.content.Context; -import android.content.SharedPreferences; -import android.os.Build; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.util.Log; - -import com.adjust.sdk.AdjustAttribution; - -import org.mozilla.gecko.AppConstants; -import org.mozilla.gecko.GeckoAppShell; -import org.mozilla.gecko.GeckoSharedPrefs; -import org.mozilla.gecko.GeckoThread; -import org.mozilla.gecko.Locales; -import org.mozilla.gecko.util.DateUtil; -import org.mozilla.gecko.util.HardwareUtils; - -import java.lang.reflect.Method; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.Locale; - -public class TelemetryInstallationPingBuilder extends TelemetryPingBuilder { - private static final String LOGTAG = "InstallPingBuilder"; - - public enum PingReason { - APP_STARTED("app-started"), - ADJUST_AVAILABLE("adjust-available"); - - PingReason(String reason) { - this.value = reason; - } - - public final String value; - } - - private static final String PING_TYPE = "installation"; - - private static final String PREF_KEY_SEQ_NUMBER = "installationPingSeqNumber"; - - private static final String REASON = "reason"; - private static final String PING_QUEUED_TIMES = "seq"; - private static final String CLIENT_ID = "client_id"; - private static final String DEVICE_ID = "device_id"; - private static final String LOCALE = "locale"; - private static final String OS_NAME = "os"; - private static final String OS_VERSION = "osversion"; - private static final String DEVICE_MANUFACTURER = "manufacturer"; - private static final String DEVICE_MODEL = "model"; - private static final String DEVICE_ABI = "arch"; - private static final String PROFILE_DATE = "profile_date"; - private static final String PING_CREATION_TIME = "created"; - private static final String TIMEZONE_OFFSET = "tz"; - private static final String APP_NAME = "app_name"; - private static final String RELEASE_CHANNEL = "channel"; - private static final String ADJUST_CAMPAIGN = "campaign"; - private static final String ADJUST_ADGROUP = "adgroup"; - private static final String ADJUST_CREATIVE = "creative"; - private static final String ADJUST_NETWORK = "network"; - - public TelemetryInstallationPingBuilder() { - super(UNIFIED_TELEMETRY_VERSION, false); - setPayloadConstants(); - } - - @Override - public String getDocType() { - return PING_TYPE; - } - - @Override - public String[] getMandatoryFields() { - return new String[]{ - REASON, - PING_QUEUED_TIMES, - CLIENT_ID, - DEVICE_ID, - LOCALE, - OS_NAME, - OS_VERSION, - DEVICE_MANUFACTURER, - DEVICE_MODEL, - DEVICE_ABI, - PROFILE_DATE, - PING_CREATION_TIME, - TIMEZONE_OFFSET, - APP_NAME, - RELEASE_CHANNEL, - }; - } - - public @NonNull TelemetryInstallationPingBuilder setReason(@NonNull PingReason reason) { - payload.put(REASON, reason.value); - - return this; - } - - public @NonNull TelemetryInstallationPingBuilder setAdjustProperties(@NonNull final AdjustAttribution attribution) { - payload.put(ADJUST_CAMPAIGN, attribution.campaign); - payload.put(ADJUST_ADGROUP, attribution.adgroup); - payload.put(ADJUST_CREATIVE, attribution.creative); - payload.put(ADJUST_NETWORK, attribution.network); - - return this; - } - - private void setPayloadConstants() { - payload.put(PING_QUEUED_TIMES, incrementAndGetQueueTimes()); - payload.put(CLIENT_ID, getGeckoClientID()); - payload.put(DEVICE_ID, getAdvertisingId()); - payload.put(LOCALE, Locales.getLanguageTag(Locale.getDefault())); - payload.put(OS_NAME, TelemetryPingBuilder.OS_NAME); - payload.put(OS_VERSION, Integer.toString(Build.VERSION.SDK_INT)); - payload.put(DEVICE_MANUFACTURER, Build.MANUFACTURER); - payload.put(DEVICE_MODEL, Build.MODEL); - payload.put(DEVICE_ABI, HardwareUtils.getRealAbi()); - payload.put(PROFILE_DATE, getGeckoProfileCreationDate()); - payload.put(PING_CREATION_TIME, new SimpleDateFormat("yyyy-MM-dd", Locale.US).format(new Date())); - payload.put(TIMEZONE_OFFSET, DateUtil.getTimezoneOffsetInMinutesForGivenDate(Calendar.getInstance())); - payload.put(APP_NAME, AppConstants.MOZ_APP_BASENAME); - payload.put(RELEASE_CHANNEL, AppConstants.MOZ_UPDATE_CHANNEL); - } - - private @Nullable String getGeckoClientID() { - // zero-ed Gecko profile that respects the expected format "8-4-4-4-12" chars - String clientID = "00000000-0000-0000-0000-000000000000"; - try { - clientID = GeckoThread.getActiveProfile().getClientId(); - } catch (Exception e) { - Log.w(LOGTAG, "Could not get Gecko Client ID", e); - } - - return clientID; - } - - private @Nullable String getAdvertisingId() { - String advertisingId = null; - try { - final Class clazz = Class.forName("org.mozilla.gecko.advertising.AdvertisingUtil"); - final Method getAdvertisingId = clazz.getMethod("getAdvertisingId", Context.class); - advertisingId = (String) getAdvertisingId.invoke(clazz, GeckoAppShell.getApplicationContext()); - } catch (Exception e) { - Log.w(LOGTAG, "Could not get advertising ID", e); - } - - return advertisingId; - } - - private int incrementAndGetQueueTimes() { - final SharedPreferences sharedPrefs = GeckoSharedPrefs.forProfile(GeckoAppShell.getApplicationContext()); - - // 1-based, always incremented - final int incrementedSeqNumber = sharedPrefs.getInt(PREF_KEY_SEQ_NUMBER, 0) + 1; - sharedPrefs.edit().putInt(PREF_KEY_SEQ_NUMBER, incrementedSeqNumber).apply(); - - return incrementedSeqNumber; - } - - private int getGeckoProfileCreationDate() { - // The method returns days since epoch. An int is enough. - int date = 0; - try { - date = TelemetryActivationPingBuilder.getProfileCreationDate( - GeckoAppShell.getApplicationContext(), - GeckoThread.getActiveProfile()).intValue(); - } catch (NullPointerException e) { - Log.w(LOGTAG, "Could not get Gecko profile creation date", e); - } - - return date; - } -} diff --git a/mobile/android/base/java/org/mozilla/gecko/telemetry/stores/TelemetryInstallationPingStore.java b/mobile/android/base/java/org/mozilla/gecko/telemetry/stores/TelemetryInstallationPingStore.java deleted file mode 100644 index 9a2a2f1962208..0000000000000 --- a/mobile/android/base/java/org/mozilla/gecko/telemetry/stores/TelemetryInstallationPingStore.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at http://mozilla.org/MPL/2.0/. - */ - -package org.mozilla.gecko.telemetry.stores; - -import android.content.SharedPreferences; -import android.os.Parcel; -import android.os.Parcelable; -import android.support.annotation.NonNull; - -import org.mozilla.gecko.GeckoAppShell; -import org.mozilla.gecko.GeckoSharedPrefs; -import org.mozilla.gecko.GeckoThread; -import org.mozilla.gecko.telemetry.schedulers.TelemetryUploadAllPingsImmediatelyScheduler; -import org.mozilla.gecko.telemetry.pingbuilders.TelemetryInstallationPingBuilder.PingReason; -import org.mozilla.gecko.util.FileUtils; - -import java.io.File; -import java.io.FilenameFilter; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -public class TelemetryInstallationPingStore extends TelemetryJSONFilePingStore { - private static final String PREF_KEY_WAS_LIGHT_PING_SENT = "wasLightInstallationPingSent"; - private static final String PREF_KEY_WAS_FULL_PING_SENT = "wasFullInstallationPingSent"; - private static final String INSTALLATION_PING_STORE_DIR = "installation_ping"; - private static final String DEFAULT_PROFILE = "default"; - - public TelemetryInstallationPingStore() { - super(getInstallationPingStoreDir(), getCurrentProfileName()); - } - - @Override - public void onUploadAttemptComplete(@NonNull final Set successfulRemoveIDs) { - // Delete the just uploaded files - super.onUploadAttemptComplete(successfulRemoveIDs); - - // Remember the uploads. We only wanted one of each. - if (successfulRemoveIDs.contains(PingReason.APP_STARTED.value)) { - setLightPingUploaded(); - } - if (successfulRemoveIDs.contains(PingReason.ADJUST_AVAILABLE.value)) { - setFullPingUploaded(); - } - } - - @Override - protected FilenameFilter getFilenameFilter() { - return new FileUtils.FilenameWhitelistFilter( - new HashSet<>(Arrays.asList(PingReason.APP_STARTED.value, PingReason.ADJUST_AVAILABLE.value)) - ); - } - - public void queuePingsForUpload(@NonNull final TelemetryUploadAllPingsImmediatelyScheduler scheduler) { - scheduler.scheduleUpload(GeckoAppShell.getApplicationContext(), this); - } - - public static boolean hasLightPingBeenUploaded() { - return getSharedPrefs().getBoolean(PREF_KEY_WAS_LIGHT_PING_SENT, false); - } - - public static boolean hasFullPingBeenUploaded() { - return getSharedPrefs().getBoolean(PREF_KEY_WAS_FULL_PING_SENT, false); - } - - private static void setLightPingUploaded() { - getSharedPrefs().edit().putBoolean(PREF_KEY_WAS_LIGHT_PING_SENT, true).apply(); - } - - private static void setFullPingUploaded() { - getSharedPrefs().edit().putBoolean(PREF_KEY_WAS_FULL_PING_SENT, true).apply(); - } - - private static @NonNull SharedPreferences getSharedPrefs() { - return GeckoSharedPrefs.forProfile(GeckoAppShell.getApplicationContext()); - } - - private static @NonNull File getInstallationPingStoreDir() { - return GeckoAppShell.getApplicationContext().getFileStreamPath(INSTALLATION_PING_STORE_DIR); - } - - private static @NonNull String getCurrentProfileName() { - return GeckoThread.getActiveProfile() != null ? - GeckoThread.getActiveProfile().getName() : - DEFAULT_PROFILE; - } - - - // Class needs to be Parcelable as it will be passed through Intents - public static final Parcelable.Creator CREATOR = - new Parcelable.Creator() { - - @Override - public TelemetryInstallationPingStore createFromParcel(final Parcel source) { - return new TelemetryInstallationPingStore(); - } - - @Override - public TelemetryInstallationPingStore[] newArray(final int size) { - return new TelemetryInstallationPingStore[size]; - } - }; - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(final Parcel dest, final int flags) { - super.writeToParcel(dest, flags); - } -} diff --git a/mobile/android/base/java/org/mozilla/gecko/telemetry/stores/TelemetryJSONFilePingStore.java b/mobile/android/base/java/org/mozilla/gecko/telemetry/stores/TelemetryJSONFilePingStore.java index 6efacc79fcd33..65e1b1bdb4dd2 100644 --- a/mobile/android/base/java/org/mozilla/gecko/telemetry/stores/TelemetryJSONFilePingStore.java +++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/stores/TelemetryJSONFilePingStore.java @@ -75,7 +75,7 @@ public class TelemetryJSONFilePingStore extends TelemetryPingStore { @VisibleForTesting static final String KEY_URL_PATH = "u"; private final File storeDir; - private final FilenameFilter filenameFilter; + private final FilenameFilter uuidFilenameFilter; private final FileLastModifiedComparator fileLastModifiedComparator = new FileLastModifiedComparator(); @WorkerThread // Writes to disk @@ -89,7 +89,7 @@ public class TelemetryJSONFilePingStore extends TelemetryPingStore { this.storeDir = storeDir; this.storeDir.mkdirs(); - filenameFilter = getFilenameFilter(); + uuidFilenameFilter = new FilenameRegexFilter(UUIDUtil.UUID_PATTERN); if (!this.storeDir.canRead() || !this.storeDir.canWrite() || !this.storeDir.canExecute()) { throw new IllegalStateException("Cannot read, write, or execute store dir: " + @@ -125,7 +125,7 @@ public class TelemetryJSONFilePingStore extends TelemetryPingStore { @Override public void maybePrunePings() { - final File[] files = storeDir.listFiles(filenameFilter); + final File[] files = storeDir.listFiles(uuidFilenameFilter); if (files == null) { return; } @@ -157,7 +157,7 @@ public class TelemetryJSONFilePingStore extends TelemetryPingStore { @Override public ArrayList getAllPings() { - final File[] fileArray = storeDir.listFiles(filenameFilter); + final File[] fileArray = storeDir.listFiles(uuidFilenameFilter); if (fileArray == null) { // Intentionally don't log all info for the store directory to prevent leaking the path. Log.w(LOGTAG, "listFiles unexpectedly returned null - unable to retrieve pings. Debug: exists? " + @@ -195,7 +195,7 @@ public class TelemetryJSONFilePingStore extends TelemetryPingStore { @Override public int getCount() { - final File[] fileArray = storeDir.listFiles(filenameFilter); + final File[] fileArray = storeDir.listFiles(uuidFilenameFilter); if (fileArray == null) { Log.w(LOGTAG, "listFiles unexpectedly returned null - unable to retrieve pings. Assuming 0. " + "Debug: exists? " + storeDir.exists() + "; directory? " + storeDir.isDirectory()); @@ -207,7 +207,7 @@ public class TelemetryJSONFilePingStore extends TelemetryPingStore { @Override public Set getStoredIDs() { final Set ids = new HashSet<>(); - final File[] fileArray = storeDir.listFiles(filenameFilter); + final File[] fileArray = storeDir.listFiles(uuidFilenameFilter); if (fileArray == null) { return ids; } @@ -315,10 +315,6 @@ public class TelemetryJSONFilePingStore extends TelemetryPingStore { } } - protected FilenameFilter getFilenameFilter() { - return new FilenameRegexFilter(UUIDUtil.UUID_PATTERN); - } - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { @Override public TelemetryJSONFilePingStore createFromParcel(final Parcel source) { diff --git a/toolkit/components/telemetry/docs/data/installation-ping.rst b/toolkit/components/telemetry/docs/data/installation-ping.rst deleted file mode 100644 index 4b1a64f2e6b1d..0000000000000 --- a/toolkit/components/telemetry/docs/data/installation-ping.rst +++ /dev/null @@ -1,57 +0,0 @@ - -"installation" ping -=================== - -This mobile-specific ping is intended to keep track of installs and Adjust attribution. - -There should only be two installation pings sent, for different reasons: - -* One sent immediately after the app start. -* One sent immediately after the Adjust attribution data becomes available. - -If the app is later deleted and installed again, the Installation Pings must be send again. - -Submission will be per the Edge server specification (legacy) and also use the unified telemetry version - 4:: - - /submit/telemetry/docId/docType/appName/appVersion/appUpdateChannel/appBuildID/?v=4 - -* ``docId`` is a UUID for deduping -* ``docType`` is “installation” -* ``appName`` is “Fennec” -* ``appVersion`` is the version of the application (e.g. "68.0.0") -* ``appUpdateChannel`` is “release”, “beta”, etc. -* ``appBuildID`` is the build number - -Structure: - -.. code-block:: js - - { - "reason": , // Ping reason. Either "app-started", either "adjust-available". - "seq": , // running ping counter, 1-based. e.g. 2. - "client_id": , // Gecko client id, e.g. "de0efb06-6b57-4ee0-b13b-e8aabfccdcb9". - "device_id": , // hashed Google Ad ID, e.g. "$2a$10$ZfglUfcbmTyaBbAQ7SL9OO". - // null if Google Play Service from which to get the advertisingId is not available. - "locale": , // application locale, e.g. "en-US". - "os": , // device platform, e.g. "Android". - "osversion": , // device platform version, e.g. "25". - "manufacturer": , // device manufacturer - Build.MANUFACTURER, e.g. "Google". - "model": , // device model - Build.MODEL, e.g. "Pixel 3". - "arch": , // device ABI, e.g. "arm". - "profile_date": , // Profile creation date in days since UNIX epoch. - // 0 if the value could not be read. - "created": , // date the ping was created in local time, "yyyy-MM-dd" - "tz": , // timezone offset (in minutes) of the - // device when the ping was created - "app_name": , // "Fennec" - "channel": , // Release channel, e.g. "beta" - "campaign": , // Adjust campaign. Can be null. - "adgroup": , // Adjust adgroup. Can be null. - "creative": , // Adjust creative. Can be null. - "network": , // Adjust network. Can be null. - } - - -Version history ---------------- -* v1: initial version - shipped in Fennec 68 - (`bug 1633568 `_). -- GitLab