Added UI mode type to debug info

pull/206/head
M66B 3 years ago
parent 65b495e9f0
commit 1be2e31a0d

@ -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,37 @@ public class Helper {
return (Build.VERSION.SDK_INT > Build.VERSION_CODES.R && false); return (Build.VERSION.SDK_INT > Build.VERSION_CODES.R && false);
} }
static String getUiModeType(Context context) {
try {
UiModeManager uimm =
(UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
int uiModeType = uimm.getCurrentModeType();
switch (uiModeType) {
case Configuration.UI_MODE_TYPE_UNDEFINED:
return "undefined";
case Configuration.UI_MODE_TYPE_NORMAL:
return "normal";
case Configuration.UI_MODE_TYPE_DESK:
return "desk";
case Configuration.UI_MODE_TYPE_CAR:
return "car";
case Configuration.UI_MODE_TYPE_TELEVISION:
return "television";
case Configuration.UI_MODE_TYPE_APPLIANCE:
return "applicance";
case Configuration.UI_MODE_TYPE_WATCH:
return "watch";
case Configuration.UI_MODE_TYPE_VR_HEADSET:
return "vr headset";
default:
return Integer.toString(uiModeType);
}
} catch (Throwable ex) {
Log.w(ex);
return null;
}
}
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));
} }

@ -1761,6 +1761,8 @@ public class Log {
.append(" night=").append(Helper.isNight(context)) .append(" night=").append(Helper.isNight(context))
.append("\r\n"); .append("\r\n");
sb.append(String.format("UI type: %s\r\n", Helper.getUiModeType(context)));
sb.append("ExactAlarms") sb.append("ExactAlarms")
.append(" can=") .append(" can=")
.append(AlarmManagerCompatEx.canScheduleExactAlarms(context)) .append(AlarmManagerCompatEx.canScheduleExactAlarms(context))

Loading…
Cancel
Save