89 lines
3.0 KiB
Java
89 lines
3.0 KiB
Java
|
package com.kofax.kmc.klo.logistics.service;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.net.wifi.WifiInfo;
|
||
|
import android.net.wifi.WifiManager;
|
||
|
import bolts.Task;
|
||
|
import bolts.TaskCompletionSource;
|
||
|
import com.kofax.kmc.kut.utilities.AppContextProvider;
|
||
|
import com.kofax.mobile.sdk._internal.k;
|
||
|
import java.util.UUID;
|
||
|
import java.util.concurrent.Callable;
|
||
|
import o.gjJ;
|
||
|
|
||
|
/* loaded from: classes3.dex */
|
||
|
public class NetworkService {
|
||
|
private static final String TAG = "NetworkService";
|
||
|
private static String jA;
|
||
|
private static String jB;
|
||
|
private static String jy;
|
||
|
private static String jz;
|
||
|
|
||
|
public static boolean initializeNetworkSettings(Context context) {
|
||
|
try {
|
||
|
WifiInfo connectionInfo = ((WifiManager) context.getApplicationContext().getSystemService("wifi")).getConnectionInfo();
|
||
|
jB = UUID.randomUUID().toString();
|
||
|
String ag = ag();
|
||
|
jy = ag;
|
||
|
jz = ag;
|
||
|
int ipAddress = connectionInfo.getIpAddress();
|
||
|
jA = String.format("%d.%d.%d.%d", Integer.valueOf(ipAddress & 255), Integer.valueOf((ipAddress >> 8) & 255), Integer.valueOf((ipAddress >> 16) & 255), Integer.valueOf(ipAddress >>> 24));
|
||
|
return true;
|
||
|
} catch (Exception e) {
|
||
|
k.e(TAG, "Error getting macAddress", (Throwable) e);
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static String ag() throws RuntimeException {
|
||
|
Task<String> ah = ah();
|
||
|
try {
|
||
|
ah.waitForCompletion();
|
||
|
if (ah.isFaulted()) {
|
||
|
throw new RuntimeException(ah.getError().getMessage());
|
||
|
}
|
||
|
if (gjJ.b((CharSequence) ah.getResult())) {
|
||
|
throw new RuntimeException("Error getting macAddress");
|
||
|
}
|
||
|
return (String) ah.getResult();
|
||
|
} catch (InterruptedException e) {
|
||
|
throw new RuntimeException(e.getMessage());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static Task<String> ah() {
|
||
|
TaskCompletionSource taskCompletionSource = new TaskCompletionSource();
|
||
|
Task.callInBackground(new Callable<Void>(taskCompletionSource) { // from class: com.kofax.kmc.klo.logistics.service.NetworkService.1
|
||
|
final TaskCompletionSource val$tcs;
|
||
|
|
||
|
{
|
||
|
this.val$tcs = taskCompletionSource;
|
||
|
}
|
||
|
|
||
|
@Override // java.util.concurrent.Callable
|
||
|
public final Void call() {
|
||
|
try {
|
||
|
this.val$tcs.setResult(CustomAdvertisingIdClient.getAdvertisingIdInfo(AppContextProvider.getContext()));
|
||
|
return null;
|
||
|
} catch (Exception e) {
|
||
|
this.val$tcs.setError(e);
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
return taskCompletionSource.getTask();
|
||
|
}
|
||
|
|
||
|
public static String getSystemIdentifier() {
|
||
|
return jz;
|
||
|
}
|
||
|
|
||
|
public static String getMacAddress() {
|
||
|
return jy;
|
||
|
}
|
||
|
|
||
|
public static String getIpAddress() {
|
||
|
return jA;
|
||
|
}
|
||
|
}
|