diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /mobile/android/thirdparty/com/adjust/sdk/plugin | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'mobile/android/thirdparty/com/adjust/sdk/plugin')
3 files changed, 104 insertions, 0 deletions
diff --git a/mobile/android/thirdparty/com/adjust/sdk/plugin/AndroidIdUtil.java b/mobile/android/thirdparty/com/adjust/sdk/plugin/AndroidIdUtil.java new file mode 100644 index 000000000..96a072287 --- /dev/null +++ b/mobile/android/thirdparty/com/adjust/sdk/plugin/AndroidIdUtil.java @@ -0,0 +1,10 @@ +package com.adjust.sdk.plugin; + +import android.content.Context; +import android.provider.Settings.Secure; + +public class AndroidIdUtil { + public static String getAndroidId(final Context context) { + return Secure.getString(context.getContentResolver(), Secure.ANDROID_ID); + } +} diff --git a/mobile/android/thirdparty/com/adjust/sdk/plugin/MacAddressUtil.java b/mobile/android/thirdparty/com/adjust/sdk/plugin/MacAddressUtil.java new file mode 100644 index 000000000..c8bdbadd7 --- /dev/null +++ b/mobile/android/thirdparty/com/adjust/sdk/plugin/MacAddressUtil.java @@ -0,0 +1,82 @@ +package com.adjust.sdk.plugin; + +import android.content.Context; +import android.net.wifi.WifiManager; +import android.text.TextUtils; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.Locale; + +public class MacAddressUtil { + public static String getMacAddress(Context context) { + final String rawAddress = getRawMacAddress(context); + if (rawAddress == null) { + return null; + } + final String upperAddress = rawAddress.toUpperCase(Locale.US); + return removeSpaceString(upperAddress); + } + + private static String getRawMacAddress(Context context) { + // android devices should have a wlan address + final String wlanAddress = loadAddress("wlan0"); + if (wlanAddress != null) { + return wlanAddress; + } + + // emulators should have an ethernet address + final String ethAddress = loadAddress("eth0"); + if (ethAddress != null) { + return ethAddress; + } + + // query the wifi manager (requires the ACCESS_WIFI_STATE permission) + try { + final WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); + final String wifiAddress = wifiManager.getConnectionInfo().getMacAddress(); + if (wifiAddress != null) { + return wifiAddress; + } + } catch (Exception e) { + /* no-op */ + } + + return null; + } + + private static String loadAddress(final String interfaceName) { + try { + final String filePath = "/sys/class/net/" + interfaceName + "/address"; + final StringBuilder fileData = new StringBuilder(1000); + final BufferedReader reader = new BufferedReader(new FileReader(filePath), 1024); + final char[] buf = new char[1024]; + int numRead; + + String readData; + while ((numRead = reader.read(buf)) != -1) { + readData = String.valueOf(buf, 0, numRead); + fileData.append(readData); + } + + reader.close(); + return fileData.toString(); + } catch (IOException e) { + return null; + } + } + + private static String removeSpaceString(final String inputString) { + if (inputString == null) { + return null; + } + + String outputString = inputString.replaceAll("\\s", ""); + if (TextUtils.isEmpty(outputString)) { + return null; + } + + return outputString; + } +} diff --git a/mobile/android/thirdparty/com/adjust/sdk/plugin/Plugin.java b/mobile/android/thirdparty/com/adjust/sdk/plugin/Plugin.java new file mode 100644 index 000000000..ab704e6d3 --- /dev/null +++ b/mobile/android/thirdparty/com/adjust/sdk/plugin/Plugin.java @@ -0,0 +1,12 @@ +package com.adjust.sdk.plugin; + +import android.content.Context; + +import java.util.Map; + +/** + * Created by pfms on 18/09/14. + */ +public interface Plugin { + Map.Entry<String, String> getParameter(Context context); +} |