Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,28 @@ public HttpClient(Context context) {
if (hasConnectivityManager()) {
if (context.checkSelfPermission(permission.ACCESS_NETWORK_STATE)
== PackageManager.PERMISSION_GRANTED) {
m_connectivityManager =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (m_connectivityManager != null) {
boolean is_metered = m_connectivityManager.isActiveNetworkMetered();
m_callback = new ConnectivityCallback(this, is_metered);
onCostChange(is_metered); // set initial value in C++ side
m_connectivityManager.registerDefaultNetworkCallback(m_callback);
}
try {
m_connectivityManager =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (m_connectivityManager != null) {
boolean is_metered = m_connectivityManager.isActiveNetworkMetered();
m_callback = new ConnectivityCallback(this, is_metered);
onCostChange(is_metered); // set initial value in C++ side
m_connectivityManager.registerDefaultNetworkCallback(m_callback);
}
}
catch (SecurityException e) {
// Fetching CONNECTIVITY_SERVICE can throw a SecurityException, especially in Android Work Profile cases
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to log to mat*.log file from Android? Or LogCat at least?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LogCat is definitely doable. From what I see in the Android layer, it doesn't log anything itself, but rather, once the call makes it into the C++ maesdk components, those log to both logcat (if enabled) and mat*.log. The C++ debug logging is also controlled by a configuration setting, I fear straight logcatting from the android layer might spam logcat as the client cannot control its output.

And as the main logger depends on HttpClient, it seems cyclical to call into the debug logging on the C++ side from here....so not sure what to do/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe @larvacea can chime in?

// "package does not belong to xxxx"
}
catch (RuntimeException e) {
// can throw runtimeException:
// https://developer.android.com/reference/android/net/ConnectivityManager#registerDefaultNetworkCallback(android.net.ConnectivityManager.NetworkCallback)
}
catch (Exception e) {
// If we don't have access to ConnectivityInfo, we can't truly populate callback/isMetered, or react to network changes
// However, we can still continue with initialization
}
}
}
m_power_receiver = new PowerInfoReceiver(this);
Expand Down