jadx icon indicating copy to clipboard operation
jadx copied to clipboard

[core] Weird `if` conditions #2

Open bagipro opened this issue 2 years ago • 1 comments

Hey!

APK: https://drive.google.com/file/d/1XBpFGkIORvQkPu8sYaWFpSZ1ZI87QpxR/view?usp=sharing

File com/samsung/android/knox/location/GeofenceFactory.java:

    public static Geofence createGeofence(int i, Parcel parcel) {
        if (i != 1) {
            if (i != 2) {
                if (i != 3) {
                    return null;
                }
                return new LinearGeofence(parcel);
            }
            return new PolygonalGeofence(parcel);
        }
        return new CircularGeofence(parcel);
    }

This condition can be simplified to

    public static Geofence createGeofence(int i, Parcel parcel) {
        if (i == 1) {
            return new CircularGeofence(parcel);
        } else if (i == 2) {
            return new PolygonalGeofence(parcel);
        } else if (i == 3) {
            return new LinearGeofence(parcel);
        } else {
            return null;
        }
    }

That would be great to keep positive conditions, but not negative

bagipro avatar Sep 28 '22 22:09 bagipro

I don't think this is a bug.

porum avatar Sep 29 '22 09:09 porum