mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
remove unneccessary checks for Android M
This commit is contained in:
@@ -44,7 +44,6 @@ import lineageos.providers.WeatherContract;
|
|||||||
/**
|
/**
|
||||||
* Provides access to the weather services in the device.
|
* Provides access to the weather services in the device.
|
||||||
*/
|
*/
|
||||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
|
||||||
public class LineageWeatherManager {
|
public class LineageWeatherManager {
|
||||||
|
|
||||||
private static ILineageWeatherManager sWeatherManagerService;
|
private static ILineageWeatherManager sWeatherManagerService;
|
||||||
|
|||||||
@@ -572,7 +572,6 @@ public class GBApplication extends Application {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.M)
|
|
||||||
public static boolean isPriorityNumber(int priorityType, String number) {
|
public static boolean isPriorityNumber(int priorityType, String number) {
|
||||||
NotificationManager.Policy notificationPolicy = notificationManager.getNotificationPolicy();
|
NotificationManager.Policy notificationPolicy = notificationManager.getNotificationPolicy();
|
||||||
if (priorityType == Policy.PRIORITY_CATEGORY_MESSAGES) {
|
if (priorityType == Policy.PRIORITY_CATEGORY_MESSAGES) {
|
||||||
|
|||||||
+1
-1
@@ -189,7 +189,7 @@ public class DevicesFragment extends Fragment {
|
|||||||
|
|
||||||
refreshPairedDevices();
|
refreshPairedDevices();
|
||||||
|
|
||||||
if (GB.isBluetoothEnabled() && deviceList.isEmpty() && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
if (GB.isBluetoothEnabled() && deviceList.isEmpty()) {
|
||||||
startActivity(new Intent(getActivity(), DiscoveryActivityV2.class));
|
startActivity(new Intent(getActivity(), DiscoveryActivityV2.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+38
-40
@@ -1202,51 +1202,49 @@ public class GoogleMapsNotificationHandler {
|
|||||||
LOG.info("Navigation: " + instruction + "," + distance + "," + navLines[0] + "," + navLines[1] + "," + navLines[2]);
|
LOG.info("Navigation: " + instruction + "," + distance + "," + navLines[0] + "," + navLines[1] + "," + navLines[2]);
|
||||||
int matchedIcon = -1;
|
int matchedIcon = -1;
|
||||||
// getLargeIcon only works in API 23+ - don't try and get icons on older devices
|
// getLargeIcon only works in API 23+ - don't try and get icons on older devices
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
Icon icon = notification.getLargeIcon();
|
||||||
Icon icon = notification.getLargeIcon();
|
if (icon != null) {
|
||||||
if (icon != null) {
|
// We convert the icon to a bitmap, then to x 32x32 1bpp which we'll check against known images
|
||||||
// We convert the icon to a bitmap, then to x 32x32 1bpp which we'll check against known images
|
Drawable drawable = icon.loadDrawable(context);
|
||||||
Drawable drawable = icon.loadDrawable(context);
|
Bitmap bitmap = Bitmap.createBitmap(32, 32, Bitmap.Config.ARGB_8888); // Single color bitmap will be created of 1x1 pixel
|
||||||
Bitmap bitmap = Bitmap.createBitmap(32, 32, Bitmap.Config.ARGB_8888); // Single color bitmap will be created of 1x1 pixel
|
Canvas canvas = new Canvas(bitmap);
|
||||||
Canvas canvas = new Canvas(bitmap);
|
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
drawable.draw(canvas);
|
||||||
drawable.draw(canvas);
|
int[] pixelsRGBA = new int[32 * 32];
|
||||||
int[] pixelsRGBA = new int[32 * 32];
|
bitmap.getPixels(pixelsRGBA, 0, 32, 0, 0, 32, 32);
|
||||||
bitmap.getPixels(pixelsRGBA, 0, 32, 0, 0, 32, 32);
|
int[] pixelPack = new int[32]; // pixels packed down 1bpp
|
||||||
int[] pixelPack = new int[32]; // pixels packed down 1bpp
|
char[] pixelStringChars = new char[33 * 32];
|
||||||
char[] pixelStringChars = new char[33 * 32];
|
|
||||||
|
|
||||||
for (int y = 0; y < 32; y++) {
|
for (int y = 0; y < 32; y++) {
|
||||||
int pack = 0;
|
int pack = 0;
|
||||||
for (int x = 0; x < 32; x++) {
|
for (int x = 0; x < 32; x++) {
|
||||||
int pixel = ((pixelsRGBA[(y * 32) + x] & 0x80000000) != 0) ? 1 : 0;
|
int pixel = ((pixelsRGBA[(y * 32) + x] & 0x80000000) != 0) ? 1 : 0;
|
||||||
pack = (pack << 1) | pixel; // check top bit (=alpha)
|
pack = (pack << 1) | pixel; // check top bit (=alpha)
|
||||||
pixelStringChars[x + y * 33] = (pixel != 0) ? '1' : '0';
|
pixelStringChars[x + y * 33] = (pixel != 0) ? '1' : '0';
|
||||||
}
|
|
||||||
pixelStringChars[32 + y * 33] = '\n';
|
|
||||||
pixelPack[y] = pack;
|
|
||||||
}
|
}
|
||||||
// This is now a printable string showing the image, which we can log if we don't recognise it
|
pixelStringChars[32 + y * 33] = '\n';
|
||||||
String pixelString = new String(pixelStringChars);
|
pixelPack[y] = pack;
|
||||||
|
}
|
||||||
|
// This is now a printable string showing the image, which we can log if we don't recognise it
|
||||||
|
String pixelString = new String(pixelStringChars);
|
||||||
|
|
||||||
int bestDiff = 100;
|
int bestDiff = 100;
|
||||||
for (int i = 0; i < knownImages.size(); i++) {
|
for (int i = 0; i < knownImages.size(); i++) {
|
||||||
IconType knownImage = knownImages.get(i);
|
IconType knownImage = knownImages.get(i);
|
||||||
int diff = 0;
|
int diff = 0;
|
||||||
// Work out how many bits differ over the whole image
|
// Work out how many bits differ over the whole image
|
||||||
for (int j = 0; j < 32; j++)
|
for (int j = 0; j < 32; j++)
|
||||||
diff += Integer.bitCount(knownImage.icon[j] ^ pixelPack[j]);
|
diff += Integer.bitCount(knownImage.icon[j] ^ pixelPack[j]);
|
||||||
// if it's close enough, match
|
// if it's close enough, match
|
||||||
if (diff < 32 && diff < bestDiff) {
|
if (diff < 32 && diff < bestDiff) {
|
||||||
matchedIcon = knownImage.iconType;
|
matchedIcon = knownImage.iconType;
|
||||||
bestDiff = diff;
|
bestDiff = diff;
|
||||||
}
|
|
||||||
}
|
|
||||||
if (matchedIcon < 0) {
|
|
||||||
LOG.info("Icon NEW:\n" + pixelString);
|
|
||||||
knownImages.add(new IconType(255, pixelPack));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (matchedIcon < 0) {
|
||||||
|
LOG.info("Icon NEW:\n" + pixelString);
|
||||||
|
knownImages.add(new IconType(255, pixelPack));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
NavigationInfoSpec navInfo = new NavigationInfoSpec();
|
NavigationInfoSpec navInfo = new NavigationInfoSpec();
|
||||||
if (matchedIcon>=0)
|
if (matchedIcon>=0)
|
||||||
|
|||||||
+1
-5
@@ -86,11 +86,7 @@ public class ZeppOsCannedMessagesService extends AbstractZeppOsService {
|
|||||||
LOG.info("Canned Message reply SMS check");
|
LOG.info("Canned Message reply SMS check");
|
||||||
final boolean canSendSms;
|
final boolean canSendSms;
|
||||||
// TODO place this behind a setting as well?
|
// TODO place this behind a setting as well?
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
canSendSms = getContext().checkSelfPermission(Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_GRANTED;
|
||||||
canSendSms = getContext().checkSelfPermission(Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_GRANTED;
|
|
||||||
} else {
|
|
||||||
canSendSms = true;
|
|
||||||
}
|
|
||||||
sendCannedSmsReplyAllow(canSendSms);
|
sendCannedSmsReplyAllow(canSendSms);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
|||||||
+1
-5
@@ -434,11 +434,7 @@ public class XiaomiNotificationService extends AbstractXiaomiService implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSendSms() {
|
public boolean canSendSms() {
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
return getSupport().getContext().checkSelfPermission(Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_GRANTED;
|
||||||
return getSupport().getContext().checkSelfPermission(Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_GRANTED;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleNotificationIconQuery(final XiaomiProto.NotificationIconPackage notificationIconPackage) {
|
private void handleNotificationIconQuery(final XiaomiProto.NotificationIconPackage notificationIconPackage) {
|
||||||
|
|||||||
Reference in New Issue
Block a user