Skip to content

Commit

Permalink
Add Developer Options checker . .
Browse files Browse the repository at this point in the history
  • Loading branch information
krlan2789 authored Oct 13, 2024
1 parent bc54c62 commit be48ea8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
20 changes: 16 additions & 4 deletions Runtime/Android/UnityActivityJavaClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ namespace LAN.Android
{
public struct Settings
{
#if UNITY_ANDROID && !UNITY_EDITOR
//#if UNITY_ANDROID && !UNITY_EDITOR
public static readonly string IGNORE_BATTERY_OPTIMIZATION_SETTINGS = "android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS";
public static readonly string APPLICATION_DETAILS_SETTINGS = "android.settings.APPLICATION_DETAILS_SETTINGS";
public static readonly string LOCATION_SOURCE_SETTINGS = "android.settings.LOCATION_SOURCE_SETTINGS";
public static readonly string MANAGE_OVERLAY_PERMISSION = "android.settings.action.MANAGE_OVERLAY_PERMISSION";
#endif
//#endif
}

public static class UnityActivityJavaClass
{
#if UNITY_ANDROID && !UNITY_EDITOR
//#if UNITY_ANDROID && !UNITY_EDITOR
public static readonly AndroidJavaClass URI_CLASS = new("android.net.Uri");
public static readonly AndroidJavaClass VERSION_INFO_CLASS = new("android.os.Build$VERSION");
public static readonly AndroidJavaClass UNITY_PLAYER_CLASS = new("com.unity3d.player.UnityPlayer");
Expand Down Expand Up @@ -75,6 +75,18 @@ public static bool IsDebuggingModeEnabled
// Check if developer options are enabled
bool status = SETTINGS_GLOBAL_CLASS.CallStatic<int>("getInt", CurrentActivity.Call<AndroidJavaObject>("getContentResolver"), "adb_enabled", 0) == 1;

Debug.Log($"USB Debugging is {(status ? "enabled" : "disabled")}!");
return status;
}
}

public static bool IsDevOptionsEnabled
{
get
{
// Check if developer options are enabled
bool status = SETTINGS_GLOBAL_CLASS.CallStatic<int>("getInt", CurrentActivity.Call<AndroidJavaObject>("getContentResolver"), "development_settings_enabled", 0) == 1;

Debug.Log($"Developer options are {(status ? "enabled" : "disabled")}!");
return status;
}
Expand Down Expand Up @@ -154,6 +166,6 @@ public static void OpenGPSSetting()

Debug.LogWarning("GPS service disabled by user");
}
#endif
//#endif
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.lan.live-location",
"version": "1.1.0",
"displayName": "Live Location for Mobile",
"version": "1.2.0",
"displayName": "Live Location",
"description": "A plugin that allow unity (Android) to run a background service location",
"unity": "2020.3",
"documentationUrl": "https://github.com/krlan2789/Unity-Background-Location/blob/main/README.md",
Expand All @@ -18,4 +18,4 @@
"email": "[email protected]",
"url": "https://erlankurnia.github.io"
}
}
}

0 comments on commit be48ea8

Please sign in to comment.