Skip to content

Commit

Permalink
Merge pull request #4 from omnt/cherry_pick_from_gitlab
Browse files Browse the repository at this point in the history
Cherry pick from gitlab
  • Loading branch information
PeterHasse authored Apr 18, 2024
2 parents 19796e9 + b28c2ed commit e090713
Show file tree
Hide file tree
Showing 37 changed files with 1,000 additions and 839 deletions.
14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
plugins {
id 'com.android.application'
id 'androidx.navigation.safeargs'
id("org.spdx.sbom") version "0.4.0"
id("org.spdx.sbom") version "0.7.0"
}

android {
Expand Down Expand Up @@ -90,22 +90,22 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.guava:guava:32.1.3-jre'
implementation 'androidx.concurrent:concurrent-futures:1.1.0'
implementation 'androidx.activity:activity:1.8.1'
implementation 'androidx.activity:activity:1.8.2'
implementation 'androidx.fragment:fragment:1.6.2'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.10.0'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment:2.7.5'
implementation 'androidx.navigation:navigation-ui:2.7.5'
implementation 'androidx.navigation:navigation-fragment:2.7.7'
implementation 'androidx.navigation:navigation-ui:2.7.7'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.recyclerview:recyclerview-selection:1.1.0'
implementation 'com.influxdb:influxdb-client-java:6.12.0'
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'com.influxdb:influxdb-client-java:7.0.0'
implementation 'com.google.android.gms:play-services-location:21.2.0'
implementation 'com.github.anastr:speedviewlib:1.6.1'
implementation "androidx.viewpager2:viewpager2:1.0.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
context = requireContext();
super.onViewCreated(view, savedInstanceState);

Button btn_apply = requireView().findViewById(R.id.button_apply_carrier_settings);
if (gv.isCarrier_permissions()) {
btn_apply.setOnClickListener(this::apply_settings);
} else {
btn_apply.setEnabled(false);
}

Button btn_read = requireView().findViewById(R.id.button_read_carrier_settings);
btn_read.setOnClickListener(this::read_settings);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class CellInformation {
private int asuLevel;
private String mcc;
private int arfcn;
private int lac;
private int timingAdvance;

public CellInformation() {
}
Expand Down Expand Up @@ -277,4 +279,21 @@ public int getRssnr() {
public void setRssnr(int rssnr) {
this.rssnr = rssnr;
}

public void setLac(int lac) {
this.lac = lac;
}

public int getLac() {
return lac;
}

public void setTimingAdvance(int timingAdvance) {
this.timingAdvance = timingAdvance;
}

public int getTimingAdvance() {
return this.timingAdvance;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.preference.PreferenceManager;
Expand Down Expand Up @@ -284,6 +283,11 @@ public List<Point> getNetworkInterfaceInformationPoints() {


// ### Cell Information ###

/**
* Callback to receive current cell infomation
* @param list is the list of currently visible cells.
*/
@SuppressLint("ObsoleteSdkInt")
@Override
public void onCellInfoChanged(@NonNull List<CellInfo> list) {
Expand Down Expand Up @@ -321,6 +325,7 @@ public void onCellInfoChanged(@NonNull List<CellInfo> list) {
cim.setSsrsrq(ssNR.getSsRsrq());
cim.setSssinr(ssNR.getSsSinr());
cim.setAsuLevel(ssNR.getAsuLevel());
cim.setTimingAdvance(ssNR.getTimingAdvanceMicros());
}
if (ci instanceof CellInfoLte) {
CellInfoLte ciLTE = (CellInfoLte) ci;
Expand All @@ -341,10 +346,11 @@ public void onCellInfoChanged(@NonNull List<CellInfo> list) {
cim.setLevel(ssLTE.getLevel());
cim.setCqi(ssLTE.getCqi());
cim.setRsrp(ssLTE.getRsrp());
cim.setRsrp(ssLTE.getRsrq());
cim.setRsrq(ssLTE.getRsrq());
cim.setRssi(ssLTE.getRssi());
cim.setRssnr(ssLTE.getRssnr());
cim.setAsuLevel(ssLTE.getAsuLevel());
cim.setTimingAdvance(ssLTE.getTimingAdvance());
}
if (ci instanceof CellInfoCdma) {
cim.setCellType("CDMA");
Expand All @@ -357,14 +363,15 @@ public void onCellInfoChanged(@NonNull List<CellInfo> list) {
cim.setCi(ciGSMId.getCid());
cim.setMcc(ciGSMId.getMccString());
cim.setARFCN(ciGSMId.getArfcn());
cim.setLac(ciGSM.getCellIdentity().getLac());
CellSignalStrengthGsm ssGSM = ciGSM.getCellSignalStrength();
cim.setLevel(ssGSM.getLevel());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
cim.setRssi(ssGSM.getRssi());
}
cim.setDbm(ssGSM.getDbm());
cim.setAsuLevel(ssGSM.getAsuLevel());
cim.setLevel(ssGSM.getLevel());
cim.setTimingAdvance(ssGSM.getTimingAdvance());
}
ciml.add(cim);
}
Expand All @@ -376,6 +383,10 @@ public List<CellInformation> getCellInformation() {
return ci;
}

/**
* Fill an Influx point with the current CellInfomation data
* @return List of InfluxPoints
*/
@SuppressLint("ObsoleteSdkInt")
public List<Point> getCellInformationPoint() {
List<Point> points = new ArrayList<>();
Expand Down Expand Up @@ -411,7 +422,7 @@ public List<Point> getCellInformationPoint() {
point.addField(GlobalVars.SSRSRP, ci_.getSsrsrp());
point.addField(GlobalVars.SSRSRQ, ci_.getSsrsrq());
point.addField(GlobalVars.SSSINR, ci_.getSssinr());
point.addField(GlobalVars.AsuLevel, ci_.getAsuLevel());
point.addField("TimingAdvance", ci_.getTimingAdvance());
}
if (Objects.equals(ci_.getCellType(), "LTE")) {
point.addField("CellType", "LTE");
Expand All @@ -421,11 +432,20 @@ public List<Point> getCellInformationPoint() {
point.addField("Bandwidth", ci_.getBandwidth());
point.addField("CI", ci_.getCi());
point.addTag("CI", String.valueOf(ci_.getCi()));
point.addField("EARFCN", ci_.getARFCN());
point.addField("ARFCN", ci_.getARFCN());
point.addField("MNC", ci_.getMnc());
point.addField("MCC", ci_.getMcc());
point.addField("PCI", ci_.getPci());
point.addField("TAC", ci_.getTac());
point.addField("TAC", ci_.getTac());
point.addField("Level", ci_.getLevel());
point.addField("AsuLevel", ci_.getAsuLevel());
point.addField("Level", ci_.getLevel());
point.addField(GlobalVars.CQI, ci_.getCqi());
point.addField("RSRP", ci_.getRsrp());
point.addField("RSRQ", ci_.getRsrq());
point.addField("RSSI", ci_.getRssi());
point.addField("TimingAdvance", ci_.getTimingAdvance());
}
if (Objects.equals(ci_.getCellType(), "CDMA")) {
point.addField("CellType", "CDMA");
Expand All @@ -437,13 +457,23 @@ public List<Point> getCellInformationPoint() {
point.addField("ARFCN", ci_.getARFCN());
point.addField("MNC", ci_.getMnc());
point.addField("MCC", ci_.getMcc());
point.addField("Level", ci_.getLevel());
point.addField("AsuLevel", ci_.getAsuLevel());
point.addField("Dbm", ci_.getDbm());
point.addField("RSSI", ci_.getRssi());
point.addField("LAC", ci_.getLac());
point.addField("TimingAdvance", ci_.getTimingAdvance());
}
points.add(point);
}
return points;
}

// return a list of CellInfo. This list also contains not available cells

/**
* return a list of CellInfo. This list also contains not available cells
* @return CellInfo list
*/
public List<CellInfo> getAllCellInfo() {
List<CellInfo> cellInfo;
if (ActivityCompat.checkSelfPermission(ct, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
Expand All @@ -455,7 +485,10 @@ public List<CellInfo> getAllCellInfo() {
return cellInfo;
}

// filter CellInfo objects for the registered cells
/**
* Filter CellInfo objects for the registered cells
* @return List of registered cells
*/
public List<CellInformation> getRegisteredCells() {
List<CellInformation> rcil = new ArrayList<>();
for (CellInformation ci_ : ci) {
Expand Down Expand Up @@ -791,13 +824,13 @@ public String getIMSI() {
*/
@SuppressLint("ObsoleteSdkInt")
public List<SubscriptionInfo> getSubscriptions() {
List<SubscriptionInfo> subsciptions;
List<SubscriptionInfo> subscriptions;
if (android.os.Build.VERSION.SDK_INT >= 30) {
subsciptions = sm.getCompleteActiveSubscriptionInfoList();
subscriptions = sm.getCompleteActiveSubscriptionInfoList();
} else {
subsciptions = sm.getActiveSubscriptionInfoList();
subscriptions = sm.getActiveSubscriptionInfoList();
}
return subsciptions;
return subscriptions;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,19 @@ private CardView get_cell_card_view(){
tl.addView(rowBuilder(GlobalVars.Dbm, String.valueOf(ci.getDbm())));
tl.addView(rowBuilder(GlobalVars.AsuLevel, String.valueOf(ci.getAsuLevel())));
tl.addView(rowBuilder("Cell Connection Status", String.valueOf(ci.getCellConnectionStatus())));
tl.addView(rowBuilder("Timing Advance", String.valueOf(ci.getTimingAdvance())));

// Stuff not available in GSM
// Stuff only available in GSM
if (Objects.equals(ci.getCellType(), "GSM")) {
tl.addView(rowBuilder("LAC", String.valueOf(ci.getLac())));
}

// Stuff not available in GSM
if (!Objects.equals(ci.getCellType(), "GSM")) {
tl.addView(rowBuilder("PCI", String.valueOf(ci.getPci())));
tl.addView(rowBuilder("TAC", String.valueOf(ci.getTac())));

}

// Stuff only available in LTE
if (Objects.equals(ci.getCellType(), "LTE")) {
tl.addView(rowBuilder(GlobalVars.CQI, String.valueOf(ci.getCqi())));
Expand All @@ -472,6 +478,7 @@ private CardView get_cell_card_view(){
if (Objects.equals(ci.getCellType(), "NR")) {
tl.addView(rowBuilder(GlobalVars.CSIRSRP, String.valueOf(ci.getCsirsrp())));
tl.addView(rowBuilder(GlobalVars.CSIRSRQ, String.valueOf(ci.getCsirsrq())));
tl.addView(rowBuilder(GlobalVars.CSISINR, String.valueOf(ci.getCsisinr())));
tl.addView(rowBuilder(GlobalVars.SSRSRP, String.valueOf(ci.getSsrsrp())));
tl.addView(rowBuilder(GlobalVars.SSRSRQ, String.valueOf(ci.getSsrsrq())));
tl.addView(rowBuilder(GlobalVars.SSSINR, String.valueOf(ci.getSssinr())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.influxdb.client.WriteApi;
import com.influxdb.client.WriteOptions;
import com.influxdb.client.domain.OnboardingRequest;
import com.influxdb.client.domain.WritePrecision;
import com.influxdb.client.write.Point;

import java.io.IOException;
Expand Down Expand Up @@ -52,6 +53,7 @@ public InfluxdbConnection(String URL, String token, String org, String bucket,
}

public void open_write_api() {
if(writeApi != null) return;
try {
influxDBClient = InfluxDBClientFactory.create(url, this.token, org, bucket);
writeApi = influxDBClient.makeWriteApi(WriteOptions.builder()
Expand Down Expand Up @@ -115,6 +117,37 @@ public boolean writePoint(Point point) throws IOException {
}
}

public boolean writeRecords(List<String> points) throws IOException {
// only add the point if the database is reachable
//InetAddress.getByName(url.split(":")[0]).isReachable(1);
//if (influxDBClient != null && influxDBClient.ping()) {

new Thread(new Runnable() {
@Override
public void run() {
try {
if (influxDBClient != null && InetAddress.getByName(url.split(":")[1].replace("//","")).isReachable(1000)) {
try {
writeApi.writeRecords(WritePrecision.MS, points);
} catch (com.influxdb.exceptions.InfluxException e) {
Log.d(TAG, "writePoint: Error while writing points to influx DB");
e.printStackTrace();
//return false;
}
//return true;
} else {
Log.d(TAG, "writePoints: InfluxDB not reachable: " + url.split(":")[1].replace("//",""));
//return false;
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}).start();
return true;
}

public boolean writePoints(List<Point> points) throws IOException {
// only add the point if the database is reachable
//InetAddress.getByName(url.split(":")[0]).isReachable(1);
Expand Down Expand Up @@ -188,6 +221,10 @@ public void run() {
return true;
}

public WriteApi getWriteApi() {
return writeApi;
}

public boolean ping() {
return influxDBClient.ping();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Looper;
import android.util.Log;
import android.widget.Toast;

Expand All @@ -33,7 +34,11 @@ public static InfluxdbConnection getRicInstance(Context context) {
String token = sp.getString("influx_token", "");
if (url.isEmpty() || org.isEmpty() || bucket.isEmpty() || token.isEmpty()) {
Log.e(TAG, "Influx parameters incomplete, can't setup logging");
Toast.makeText(context, "Influx Parameter not correctly set!", Toast.LENGTH_LONG).show();
// if we are an UI thread we make a toast, if not logging have to be enough
if (Looper.getMainLooper().isCurrentThread()) {
Toast.makeText(context, "Influx Parameter not correctly set!", Toast.LENGTH_LONG).show();// On UI thread.
}

return null;
}

Expand Down
Loading

0 comments on commit e090713

Please sign in to comment.