mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1232773 - Check if user is opt out from Adjust before accessing. r=mfinkle
It made sense to me to have this code inside the AdjustHelper so I moved the existing opt out code inside the AdjustHelper as well.
This commit is contained in:
parent
8b980a0619
commit
f877291fd8
@ -695,10 +695,7 @@ public class BrowserApp extends GeckoApp
|
||||
mAccountsHelper = new AccountsHelper(appContext, getProfile());
|
||||
|
||||
if (AppConstants.MOZ_INSTALL_TRACKING) {
|
||||
final SharedPreferences prefs = GeckoSharedPrefs.forApp(this);
|
||||
if (prefs.getBoolean(GeckoPreferences.PREFS_HEALTHREPORT_UPLOAD_ENABLED, true)) {
|
||||
AdjustConstants.getAdjustHelper().onCreate(this, AdjustConstants.MOZ_INSTALL_TRACKING_ADJUST_SDK_APP_TOKEN);
|
||||
}
|
||||
AdjustConstants.getAdjustHelper().onCreate(this, AdjustConstants.MOZ_INSTALL_TRACKING_ADJUST_SDK_APP_TOKEN);
|
||||
}
|
||||
|
||||
if (AppConstants.MOZ_ANDROID_BEAM) {
|
||||
@ -889,7 +886,7 @@ public class BrowserApp extends GeckoApp
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
AdjustConstants.getAdjustHelper().onResume();
|
||||
AdjustConstants.getAdjustHelper().onResume(this);
|
||||
|
||||
final String args = ContextUtils.getStringExtra(getIntent(), "args");
|
||||
// If an external intent tries to start Fennec in guest mode, and it's not already
|
||||
@ -911,7 +908,7 @@ public class BrowserApp extends GeckoApp
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
AdjustConstants.getAdjustHelper().onPause();
|
||||
AdjustConstants.getAdjustHelper().onPause(this);
|
||||
// Register for Prompt:ShowTop so we can foreground this activity even if it's hidden.
|
||||
EventDispatcher.getInstance().registerGeckoThreadListener((GeckoEventListener) this,
|
||||
"Prompt:ShowTop");
|
||||
|
@ -5,8 +5,12 @@
|
||||
|
||||
package org.mozilla.gecko.adjust;
|
||||
|
||||
import org.mozilla.gecko.GeckoSharedPrefs;
|
||||
import org.mozilla.gecko.preferences.GeckoPreferences;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import com.adjust.sdk.Adjust;
|
||||
import com.adjust.sdk.AdjustConfig;
|
||||
@ -15,6 +19,10 @@ import com.adjust.sdk.LogLevel;
|
||||
|
||||
public class AdjustHelper implements AdjustHelperInterface {
|
||||
public void onCreate(final Context context, final String maybeAppToken) {
|
||||
if (isUserOptOut(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String environment;
|
||||
final String appToken;
|
||||
final LogLevel logLevel;
|
||||
@ -33,14 +41,31 @@ public class AdjustHelper implements AdjustHelperInterface {
|
||||
}
|
||||
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
if (isUserOptOut(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
new AdjustReferrerReceiver().onReceive(context, intent);
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
public void onResume(final Context context) {
|
||||
if (isUserOptOut(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Adjust.onResume();
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
public void onPause(final Context context) {
|
||||
if (isUserOptOut(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Adjust.onPause();
|
||||
}
|
||||
|
||||
private boolean isUserOptOut(final Context context) {
|
||||
final SharedPreferences prefs = GeckoSharedPrefs.forApp(context);
|
||||
return !prefs.getBoolean(GeckoPreferences.PREFS_HEALTHREPORT_UPLOAD_ENABLED, true);
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,6 @@ public interface AdjustHelperInterface {
|
||||
*/
|
||||
void onCreate(final Context context, final String appToken);
|
||||
void onReceive(final Context context, final Intent intent);
|
||||
void onResume();
|
||||
void onPause();
|
||||
void onResume(final Context context);
|
||||
void onPause(final Context context);
|
||||
}
|
||||
|
@ -17,11 +17,11 @@ public class StubAdjustHelper implements AdjustHelperInterface {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
public void onResume(final Context context) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
public void onPause(final Context context) {
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user