Skip to content

Commit

Permalink
Show Kernel Version in Device Info
Browse files Browse the repository at this point in the history
  • Loading branch information
reveny committed Jan 11, 2025
1 parent e6bc39a commit e1b7e46
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@
import org.json.JSONArray;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.MessageDigest;
Expand Down Expand Up @@ -139,7 +141,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,

SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext());
boolean isSnowDisabled = sharedPreferences.getBoolean("disable_snow", false);
boolean enableExperimental = sharedPreferences.getBoolean("enable_experimental", false);
boolean enableExperimental = sharedPreferences.getBoolean("enable_experimental", true);

if (isSnowDisabled) {
binding.snowView.setVisibility(View.GONE);
Expand All @@ -166,6 +168,9 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
String androidVersion = Build.VERSION.RELEASE;
binding.AndroidVersion.setText(String.format("Android Version : %s", androidVersion));

String kernelVersion = getKernelVersion();
binding.KernelVersion.setText(String.format("Kernel Version : %s", kernelVersion));

PackageManager packageManager = requireContext().getPackageManager();
try {
PackageInfo packageInfo = packageManager.getPackageInfo(requireContext().getPackageName(), 0);
Expand Down Expand Up @@ -262,6 +267,27 @@ private String getDevice() {
return manufacturer;
}

public String getKernelVersion() {
StringBuilder kernelVersion = new StringBuilder();
try {
// Execute the uname command to get the kernel version
Process process = Runtime.getRuntime().exec("uname -r");
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
kernelVersion.append(line);
}
reader.close();
process.waitFor();
} catch (Exception e) {
e.printStackTrace();
}

// Split the kernel version string by hyphen and return the first part
String[] parts = kernelVersion.toString().split("-");
return parts[0];
}

public void setSignature(boolean valid) {
if (binding == null) {
Log.w("HomeFragment", "Binding is null. Skipping displayDetections operation.");
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?textAppearanceBodyMedium" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/KernelVersion"
style="@style/Label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?textAppearanceBodyMedium" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
app:title="Enable Experimental Detections"
app:summaryOff="This will enable experimental detections (restart required)"
app:summaryOn="Experimental detections are enabled"
app:defaultValue="false" />
app:defaultValue="true" />
</PreferenceCategory>
</PreferenceScreen>

0 comments on commit e1b7e46

Please sign in to comment.