正在查看: Fix Locker v1.5 应用的 ForeGroundGetLocationActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Fix Locker v1.5 应用的 ForeGroundGetLocationActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.user.a4keygen.activity;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.gson.JsonObject;
import com.user.a4keygen.DeviceAdminReceiver;
import com.user.a4keygen.R;
import com.user.a4keygen.model.CommonResponseModel;
import com.user.a4keygen.network.ApiClient;
import com.user.a4keygen.network.ApiInterface;
import com.user.a4keygen.webutil.WebClientService;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class ForeGroundGetLocationActivity extends AppCompatActivity implements LocationListener {
private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10;
private static final long MIN_TIME_BW_UPDATES = 60000;
private DevicePolicyManager dpm;
Location location;
protected LocationManager locationManager;
private ComponentName mAdminComponentName;
private Context mContext;
String userid;
boolean isGPSEnabled = false;
boolean isNetworkEnabled = false;
int locationCount = 0;
boolean canGetLocation = false;
double latitude = 0.0d;
double longitude = 0.0d;
private int lastShownNotificationId = 321;
@Override
public void onLocationChanged(Location location) {
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_fore_ground_get_location);
this.locationCount = 0;
this.mContext = this;
this.userid = getIntent().getStringExtra("USERID");
Toast.makeText(this.mContext, "Your Id is :" + this.userid, 0).show();
setLocationEnable();
getLocation();
}
private void setLocationEnable() {
this.dpm = (DevicePolicyManager) getSystemService("device_policy");
this.mAdminComponentName = DeviceAdminReceiver.getComponentName(this);
if (!WebClientService.isActiveAdmin(this) || Build.VERSION.SDK_INT < 30) {
return;
}
this.dpm.setLocationEnabled(this.mAdminComponentName, true);
}
public Location getLocation() {
this.locationCount++;
try {
LocationManager locationManager = (LocationManager) this.mContext.getSystemService(FirebaseAnalytics.Param.LOCATION);
this.locationManager = locationManager;
this.isGPSEnabled = locationManager.isProviderEnabled("gps");
boolean isProviderEnabled = this.locationManager.isProviderEnabled("network");
this.isNetworkEnabled = isProviderEnabled;
boolean z = this.isGPSEnabled;
if (z || isProviderEnabled) {
this.canGetLocation = true;
if (z && Build.VERSION.SDK_INT >= 23 && ((ContextCompat.checkSelfPermission(this.mContext, "android.permission.ACCESS_FINE_LOCATION") == 0 || ContextCompat.checkSelfPermission(this.mContext, "android.permission.ACCESS_COARSE_LOCATION") == 0) && this.location == null)) {
this.locationManager.requestLocationUpdates("gps", MIN_TIME_BW_UPDATES, 10.0f, this);
LocationManager locationManager2 = this.locationManager;
if (locationManager2 != null) {
Location lastKnownLocation = locationManager2.getLastKnownLocation("gps");
this.location = lastKnownLocation;
if (lastKnownLocation != null) {
this.latitude = lastKnownLocation.getLatitude();
this.longitude = this.location.getLongitude();
}
}
}
if (this.isNetworkEnabled) {
if (Build.VERSION.SDK_INT >= 23) {
if (ContextCompat.checkSelfPermission(this.mContext, "android.permission.ACCESS_FINE_LOCATION") == 0 || ContextCompat.checkSelfPermission(this.mContext, "android.permission.ACCESS_COARSE_LOCATION") == 0) {
this.locationManager.requestLocationUpdates("network", MIN_TIME_BW_UPDATES, 10.0f, this);
LocationManager locationManager3 = this.locationManager;
if (locationManager3 != null) {
Location lastKnownLocation2 = locationManager3.getLastKnownLocation("network");
this.location = lastKnownLocation2;
if (lastKnownLocation2 != null) {
this.latitude = lastKnownLocation2.getLatitude();
this.longitude = this.location.getLongitude();
}
}
}
} else {
this.locationManager.requestLocationUpdates("network", MIN_TIME_BW_UPDATES, 10.0f, this);
LocationManager locationManager4 = this.locationManager;
if (locationManager4 != null) {
Location lastKnownLocation3 = locationManager4.getLastKnownLocation("network");
this.location = lastKnownLocation3;
if (lastKnownLocation3 != null) {
this.latitude = lastKnownLocation3.getLatitude();
this.longitude = this.location.getLongitude();
System.out.println("latitude = " + this.latitude);
System.out.println("longitude = " + this.longitude);
}
}
}
}
}
if (this.latitude != 0.0d && this.longitude != 0.0d) {
this.locationCount = 0;
if (!WebClientService.isNull(this.userid)) {
sendLTandLNGtoApi(this.mContext);
} else {
Toast.makeText(this.mContext, "User id not get :" + this.longitude + "," + this.latitude + "id is :" + this.userid, 1).show();
}
} else {
if (this.locationCount < 4) {
getLocation();
}
Toast.makeText(this.mContext, "lat and long are not found :" + this.longitude + "," + this.latitude, 1).show();
}
} catch (Exception e) {
e.printStackTrace();
}
return this.location;
}
private void sendLTandLNGtoApi(final Context context) {
Toast.makeText(context, "Calling Api For :" + this.longitude + "," + this.latitude, 0).show();
try {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("userId", this.userid);
jsonObject.addProperty("longitude", String.valueOf(this.longitude));
jsonObject.addProperty("latitude", String.valueOf(this.latitude));
((ApiInterface) ApiClient.getInstance(this).getClient().create(ApiInterface.class)).saveLTandLNG(jsonObject).enqueue(new Callback<CommonResponseModel>() {
public void onResponse(Call<CommonResponseModel> call, Response<CommonResponseModel> response) {
if (response.isSuccessful()) {
if ("S".equals(((CommonResponseModel) response.body()).getStatus())) {
Toast.makeText(context, "Location Fetched SuccessFully", 1).show();
} else {
Toast.makeText(context, "else Fail status S Not found", 1).show();
}
}
}
public void onFailure(Call<CommonResponseModel> call, Throwable th) {
Toast.makeText(context, "on failure", 1).show();
}
});
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(context, "Fail " + e.getMessage(), 1).show();
}
}
}