Skip to content

Commit 75b5535

Browse files
Merge pull request #33 from comapi/device_id_change
SDK version 1.5.1 Use only uuid for device id generation.
2 parents 30d5971 + 3747953 commit 75b5535

File tree

4 files changed

+5
-68
lines changed

4 files changed

+5
-68
lines changed

COMAPI/foundation/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ dependencies {
6767

6868
ext {
6969
PUBLISH_GROUP_ID = 'com.comapi'
70-
PUBLISH_VERSION = '1.5.0'
70+
PUBLISH_VERSION = '1.5.1'
7171
PUBLISH_ARTIFACT_ID = 'foundation'
7272
}
7373

COMAPI/foundation/src/main/java/com/comapi/BaseComapi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class BaseComapi {
3838
/**
3939
* Version of the ComapiImpl SDK MAJOR.MINOR.PATCH.BUILD
4040
*/
41-
private final static String SDK_VERSION = "1.5.0";
41+
private final static String SDK_VERSION = "1.5.1";
4242

4343
private static final Set<String> apiSpaces = Collections.synchronizedSet(new HashSet<String>());
4444

COMAPI/foundation/src/main/java/com/comapi/internal/helpers/DeviceHelper.java

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,14 @@
2020

2121
package com.comapi.internal.helpers;
2222

23-
import android.Manifest;
2423
import android.annotation.SuppressLint;
2524
import android.annotation.TargetApi;
2625
import android.content.Context;
2726
import android.content.pm.PackageManager;
28-
import android.net.wifi.WifiInfo;
29-
import android.net.wifi.WifiManager;
3027
import android.os.Build;
31-
import android.provider.Settings;
3228
import androidx.annotation.NonNull;
33-
import android.text.TextUtils;
34-
35-
import com.google.android.gms.tasks.Tasks;
36-
import com.google.firebase.installations.FirebaseInstallations;
3729

3830
import java.util.UUID;
39-
import java.util.concurrent.ExecutionException;
4031

4132
/**
4233
* Helper to obtain basic device information.
@@ -72,60 +63,6 @@ public static int getAppVersion(@NonNull Context context) {
7263
*/
7364
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
7465
public static String generateDeviceId(@NonNull Context context) {
75-
76-
String deviceId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
77-
78-
if (TextUtils.isEmpty(deviceId)) {
79-
deviceId = getMacAddress(context);
80-
}
81-
82-
if (TextUtils.isEmpty(deviceId)) {
83-
try {
84-
deviceId = Tasks.await(FirebaseInstallations.getInstance().getId());
85-
} catch (IllegalStateException e) {
86-
//Continue.
87-
} catch (InterruptedException e) {
88-
e.printStackTrace();
89-
} catch (ExecutionException e) {
90-
e.printStackTrace();
91-
}
92-
}
93-
94-
if (TextUtils.isEmpty(deviceId)) {
95-
deviceId = UUID.randomUUID().toString();
96-
}
97-
98-
return deviceId;
99-
}
100-
101-
/**
102-
* Gets device mac address.
103-
*
104-
* @param context App context.
105-
* @return Device mac address.
106-
*/
107-
private static String getMacAddress(@NonNull Context context) {
108-
109-
if (isWifiStatePermissionGranted(context)) {
110-
WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
111-
if (wifiManager != null) {
112-
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
113-
if (wifiInfo != null) {
114-
return wifiInfo.getMacAddress();
115-
}
116-
}
117-
}
118-
119-
return null;
120-
}
121-
122-
/**
123-
* Checks if the {@link Manifest.permission#ACCESS_WIFI_STATE} permission has been granted.
124-
*
125-
* @return True if wifi access permission has been granted.
126-
*/
127-
private static boolean isWifiStatePermissionGranted(@NonNull Context context) {
128-
int res = context.checkCallingOrSelfPermission(Manifest.permission.ACCESS_WIFI_STATE);
129-
return (res == PackageManager.PERMISSION_GRANTED);
66+
return UUID.randomUUID().toString();
13067
}
13168
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ Via Maven
1010
<dependency>
1111
<groupId>com.comapi</groupId>
1212
<artifactId>foundation</artifactId>
13-
<version>1.5.0</version>
13+
<version>1.5.1</version>
1414
</dependency>
1515
```
1616

1717
or Gradle
1818

1919
```
20-
compile 'com.comapi:foundation:1.5.0'
20+
compile 'com.comapi:foundation:1.5.1'
2121
```
2222

2323
For more information about the integration please visit [the website](http://docs.cpaas.dotdigital.com/reference#one-sdk-android-overview).

0 commit comments

Comments
 (0)