Added user id getter
This commit is contained in:
parent
55a737ea67
commit
a11753e647
5 changed files with 26 additions and 15 deletions
|
@ -5,7 +5,6 @@ import android.database.Cursor;
|
|||
import android.database.DatabaseUtils;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.provider.Settings;
|
||||
|
||||
import net.osmand.AndroidNetworkUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
|
@ -161,11 +160,7 @@ public class AnalyticsHelper extends SQLiteOpenHelper {
|
|||
additionalData.put(PARAM_LANG, ctx.getLanguage() + "");
|
||||
additionalData.put(PARAM_FIRST_INSTALL_DAYS, String.valueOf(ctx.getAppInitializer().getFirstInstalledDays()));
|
||||
additionalData.put(PARAM_NUMBER_OF_STARTS, String.valueOf(ctx.getAppInitializer().getNumberOfStarts()));
|
||||
try {
|
||||
additionalData.put(PARAM_USER_ID, Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
additionalData.put(PARAM_USER_ID, ctx.getUserAndroidId());
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
for (Map.Entry<String, String> entry : additionalData.entrySet()) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
|
@ -15,6 +16,7 @@ import android.os.AsyncTask;
|
|||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.support.multidex.MultiDex;
|
||||
import android.support.multidex.MultiDexApplication;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
@ -77,6 +79,7 @@ import java.io.PrintStream;
|
|||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import btools.routingapp.BRouterServiceConnection;
|
||||
import btools.routingapp.IBRouterService;
|
||||
|
@ -919,6 +922,24 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressLint("HardwareIds")
|
||||
public String getUserAndroidId() {
|
||||
String userAndroidId = osmandSettings.USER_ANDROID_ID.get();
|
||||
if (!Algorithms.isEmpty(userAndroidId)) {
|
||||
return userAndroidId;
|
||||
}
|
||||
try {
|
||||
userAndroidId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
if (userAndroidId == null || userAndroidId.length() < 16 || userAndroidId.equals("0000000000000000")) {
|
||||
userAndroidId = UUID.randomUUID().toString();
|
||||
}
|
||||
osmandSettings.USER_ANDROID_ID.set(userAndroidId);
|
||||
return userAndroidId;
|
||||
}
|
||||
|
||||
public void logEvent(String event) {
|
||||
try {
|
||||
if (osmandSettings.SEND_ANONYMOUS_APP_USAGE_DATA.get()) {
|
||||
|
|
|
@ -1172,6 +1172,7 @@ public class OsmandSettings {
|
|||
public final CommonPreference<Boolean> ENABLE_PROXY = new BooleanPreference("enable_proxy", false).makeGlobal();
|
||||
public final CommonPreference<String> PROXY_HOST = new StringPreference("proxy_host", "127.0.0.1").makeGlobal();
|
||||
public final CommonPreference<Integer> PROXY_PORT = new IntPreference("proxy_port", 8118).makeGlobal();
|
||||
public final CommonPreference<String> USER_ANDROID_ID = new StringPreference("user_android_id", "").makeGlobal();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public static final String SAVE_CURRENT_TRACK = "save_current_track"; //$NON-NLS-1$
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.content.res.Resources;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
@ -28,10 +27,10 @@ import android.widget.TextView;
|
|||
|
||||
import net.osmand.AndroidNetworkUtils;
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivity.BannerAndDownloadFreeVersion;
|
||||
|
@ -283,7 +282,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
|||
protected String doInBackground(Void... params) {
|
||||
try {
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
parameters.put("aid", Settings.Secure.getString(activity.getContentResolver(), Settings.Secure.ANDROID_ID));
|
||||
parameters.put("aid", getMyApplication().getUserAndroidId());
|
||||
parameters.put("email", email);
|
||||
|
||||
return AndroidNetworkUtils.sendRequest(getMyApplication(),
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
|
|||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.provider.Settings;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
@ -677,11 +676,7 @@ public class InAppPurchaseHelper {
|
|||
parameters.put("lang", ctx.getLanguage() + "");
|
||||
parameters.put("nd", ctx.getAppInitializer().getFirstInstalledDays() + "");
|
||||
parameters.put("ns", ctx.getAppInitializer().getNumberOfStarts() + "");
|
||||
try {
|
||||
parameters.put("aid", Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
parameters.put("aid", ctx.getUserAndroidId());
|
||||
}
|
||||
|
||||
// Callback for when a purchase is finished
|
||||
|
|
Loading…
Reference in a new issue