Added auto car mode

pull/206/head
M66B 3 years ago
parent 12479b7603
commit b96e9d8a89

@ -4,6 +4,10 @@
### [Adratiklit](https://en.wikipedia.org/wiki/Adratiklit) ### [Adratiklit](https://en.wikipedia.org/wiki/Adratiklit)
### Next version
* Improved Android Auto support
### 1.1746 ### 1.1746
* Enabled Android auto support (see the FAQ for details) * Enabled Android auto support (see the FAQ for details)

@ -4520,6 +4520,9 @@ class Core {
String sound = prefs.getString("sound", null); String sound = prefs.getString("sound", null);
boolean alert_once = prefs.getBoolean("alert_once", true); boolean alert_once = prefs.getBoolean("alert_once", true);
if (Helper.inCar(context))
notify_messaging = true;
// Get contact info // Get contact info
Map<Long, Address[]> messageFrom = new HashMap<>(); Map<Long, Address[]> messageFrom = new HashMap<>();
Map<Long, ContactInfo[]> messageInfo = new HashMap<>(); Map<Long, ContactInfo[]> messageInfo = new HashMap<>();

@ -26,6 +26,7 @@ import android.Manifest;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.KeyguardManager; import android.app.KeyguardManager;
import android.app.UiModeManager;
import android.app.usage.UsageStatsManager; import android.app.usage.UsageStatsManager;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.ComponentName; import android.content.ComponentName;
@ -1041,6 +1042,17 @@ public class Helper {
return (Build.VERSION.SDK_INT > Build.VERSION_CODES.R && false); return (Build.VERSION.SDK_INT > Build.VERSION_CODES.R && false);
} }
static boolean inCar(Context context) {
try {
UiModeManager uimm =
(UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
return (uimm.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR);
} catch (Throwable ex) {
Log.w(ex);
return false;
}
}
static void reportNoViewer(Context context, Uri uri) { static void reportNoViewer(Context context, Uri uri) {
reportNoViewer(context, new Intent().setData(uri)); reportNoViewer(context, new Intent().setData(uri));
} }

@ -25,6 +25,7 @@ import android.app.Dialog;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationChannel; import android.app.NotificationChannel;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.UiModeManager;
import android.app.usage.UsageStatsManager; import android.app.usage.UsageStatsManager;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
@ -1761,6 +1762,17 @@ public class Log {
.append(" night=").append(Helper.isNight(context)) .append(" night=").append(Helper.isNight(context))
.append("\r\n"); .append("\r\n");
int mode;
try {
UiModeManager uimm =
(UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
mode = uimm.getCurrentModeType();
} catch (Throwable ex) {
mode = -1;
Log.w(ex);
}
sb.append(String.format("In car=%b mode=%d\r\n", Helper.inCar(context), mode));
sb.append("ExactAlarms") sb.append("ExactAlarms")
.append(" can=") .append(" can=")
.append(AlarmManagerCompatEx.canScheduleExactAlarms(context)) .append(AlarmManagerCompatEx.canScheduleExactAlarms(context))

Loading…
Cancel
Save