正在查看: Glean v1.1.34 应用的 FSLSensor.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Glean v1.1.34 应用的 FSLSensor.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package co.tryterra.terra.fsl;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.nfc.NfcAdapter;
import android.nfc.Tag;
import android.os.Bundle;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.util.Log;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import co.tryterra.terra.ConstantsKt;
import co.tryterra.terra.R;
import co.tryterra.terra.TerraManager;
import co.tryterra.terra.fsl.models.FSLSensorDetails;
import java.util.function.Consumer;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
public class FSLSensor extends AppCompatActivity implements NfcAdapter.ReaderCallback {
private static final String TAG = "FSLSensor";
public static Consumer<FSLSensorDetails> dataConsumer;
private String devId;
private NfcAdapter nfcAdapter;
private SharedPreferences preferencesEn;
protected void onCreate(Bundle bundle) {
Log.d(TAG, "Creating FSLSensor Activity");
super.onCreate(bundle);
setContentView(R.layout.nfc_reader);
SharedPreferences sharedPreferences = getSharedPreferences(TerraManager.TERRA_PREFS, 0);
this.preferencesEn = sharedPreferences;
this.devId = sharedPreferences.getString(ConstantsKt.DEVID, null);
this.nfcAdapter = NfcAdapter.getDefaultAdapter(this);
if (!this.preferencesEn.getBoolean(ConstantsKt.TERRA_ENABLE_FSL_SDK, false) || this.nfcAdapter == null) {
Log.e(TAG, "FSL has not yet been enabled. Did you call initConnection with FSL yet?");
Consumer<FSLSensorDetails> consumer = dataConsumer;
if (consumer != null) {
consumer.accept(null);
}
dataConsumer = null;
finish();
}
findViewById(R.id.dismiss_fsl).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
FSLSensor.this.m488lambda$onCreate$0$cotryterraterrafslFSLSensor(view);
}
});
doReading(getIntent(), new Tag[0]);
Log.d(TAG, "FSLSensor Activity created");
}
void m488lambda$onCreate$0$cotryterraterrafslFSLSensor(View view) {
Consumer<FSLSensorDetails> consumer = dataConsumer;
if (consumer != null) {
consumer.accept(null);
}
dataConsumer = null;
finish();
}
protected void onResume() {
this.nfcAdapter.enableReaderMode(this, this, 143, new Bundle());
super.onResume();
}
protected void onPause() {
this.nfcAdapter.disableReaderMode(this);
super.onPause();
}
@Override
public void onTagDiscovered(Tag tag) {
doReading(null, tag);
}
void doReading(Intent intent, Tag... tagArr) {
Log.d(TAG, "Doing reading");
if ((intent == null && tagArr.length == 0) || this.devId == null || TerraManager.INSTANCE.getSensorScanning().get()) {
Log.e(TAG, "Doing reading err 1");
finish();
return;
}
SensorAsyncTask sensorAsyncTask = new SensorAsyncTask(this.devId, this);
if (intent != null && "android.nfc.action.TECH_DISCOVERED".equals(intent.getAction())) {
Log.e(TAG, "Doing reading err 2");
final Tag tag = (Tag) intent.getParcelableExtra("android.nfc.extra.TAG");
sensorAsyncTask.readData(tag, new Function1() {
public final Object invoke(Object obj) {
return FSLSensor.this.m486lambda$doReading$1$cotryterraterrafslFSLSensor(tag, (FSLSensorDetails) obj);
}
});
} else if (tagArr.length != 0) {
Log.e(TAG, "Doing reading err 3");
final Tag tag2 = tagArr[0];
sensorAsyncTask.readData(tag2, new Function1() {
public final Object invoke(Object obj) {
return FSLSensor.this.m487lambda$doReading$2$cotryterraterrafslFSLSensor(tag2, (FSLSensorDetails) obj);
}
});
}
}
Unit m486lambda$doReading$1$cotryterraterrafslFSLSensor(Tag tag, FSLSensorDetails fSLSensorDetails) {
completeReading(fSLSensorDetails, tag, true);
return Unit.INSTANCE;
}
Unit m487lambda$doReading$2$cotryterraterrafslFSLSensor(Tag tag, FSLSensorDetails fSLSensorDetails) {
completeReading(fSLSensorDetails, tag, false);
return Unit.INSTANCE;
}
private void completeReading(FSLSensorDetails fSLSensorDetails, Tag tag, boolean z) {
((Vibrator) getSystemService("vibrator")).vibrate(VibrationEffect.createOneShot(1000L, 60));
Consumer<FSLSensorDetails> consumer = dataConsumer;
if (consumer != null) {
consumer.accept(fSLSensorDetails);
}
this.nfcAdapter.ignore(tag, 1500, null, null);
setDataConsumer(null);
String string = this.preferencesEn.getString(ConstantsKt.TERRA_FSL_SCAN_FROM_BACKGROUND, null);
if (string != null && z) {
try {
startActivity(new Intent((Context) this, Class.forName(string)));
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
TerraManager.INSTANCE.getSensorScanning().set(false);
finish();
}
public static void setDataConsumer(Consumer<FSLSensorDetails> consumer) {
dataConsumer = consumer;
}
}