// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package com.olio.util; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.os.Vibrator; import android.util.ArrayMap; import com.olio.communication.bluetooth.channel_messages.ANCSNotification; import com.olio.communication.notifications.NavigationNotification; import java.util.List; import java.util.Random; import java.util.regex.Matcher; import java.util.regex.Pattern; // Referenced classes of package com.olio.util: // ALog public class NavigationUtils { private static class ConstantParser implements NavigationParser { final int action; final int direction; public void parse(Matcher matcher, NavigationNotification navigationnotification, String s, String s1) { ALog.d("Navigation=PARSE, Message='%s', Match=CONSTANT", new Object[] { s }); navigationnotification.action = action; navigationnotification.direction = direction; navigationnotification.target = s; } ConstantParser(int i) { this(i, 0); } ConstantParser(int i, int j) { action = i; direction = j; } } private static class DirectionParser implements NavigationParser { final int action; final int group; public void parse(Matcher matcher, NavigationNotification navigationnotification, String s, String s1) { ALog.d("Navigation=PARSE, Message='%s', Match=DIRECTION", new Object[] { s }); navigationnotification.action = action; navigationnotification.direction = NavigationUtils.parseDirection(matcher.group(group)); navigationnotification.target = s; } DirectionParser(int i, int j) { action = i; group = j; } } private static interface NavigationParser { public abstract void parse(Matcher matcher, NavigationNotification navigationnotification, String s, String s1); } private static class RoundaboutParser implements NavigationParser { public void parse(Matcher matcher, NavigationNotification navigationnotification, String s, String s1) { int i; i = 0; ALog.d("Navigation=PARSE, Message='%s', Match=ROUNDABOUT", new Object[] { s }); if (!"continue straight".equals(matcher.group(1))) goto _L2; else goto _L1 _L1: i = 1; _L9: navigationnotification.action = 96; navigationnotification.direction = i; navigationnotification.target = s; return; _L2: s1 = matcher.group(3); if (s1 != null) { switch (Integer.parseInt(s1)) { default: i = 2; break; case 1: // '\001' case 2: // '\002' i = 3; break; } continue; /* Loop/switch isn't completed */ } matcher = matcher.group(2); matcher.hashCode(); JVM INSTR lookupswitch 2: default 136 // -906279820: 182 // 97440432: 170; goto _L3 _L4 _L5 _L3: i = -1; _L6: switch (i) { default: i = 2; break; case 0: // '\0' i = 3; break; case 1: // '\001' i = 3; break; } continue; /* Loop/switch isn't completed */ _L5: if (!matcher.equals("first")) goto _L3; else goto _L6 _L4: if (!matcher.equals("second")) goto _L3; else goto _L7 _L7: i = 1; goto _L6 if (true) goto _L9; else goto _L8 _L8: } private RoundaboutParser() { } } private static final boolean DEBUG_MESSAGE = false; private static final long MIN_VIBRATION_REPEAT_TIME = 5000L; private static final boolean SEND_EVERYTHING = false; private static final long VIBRATION_TIME = 500L; private static long lastVibrationTime; private static final ArrayMap sPatterns; public NavigationUtils() { } public static void checkDismissal(ContentResolver contentresolver) { ALog.d("Notification=CONTENT_CHANGED, Event=ERASE, Action=CHECK_IF_ID_MATCH", new Object[0]); Object obj = com.olio.communication.notifications.NotificationContract.Notifications.originalNotificationForId(contentresolver, "com.olio.apps.NavigationItem.ID"); if (obj instanceof NavigationNotification) { obj = (NavigationNotification)obj; ALog.d("Notification=CONTENT_CHANGED, Event=ERASE, Action=LOOK_FOR_ID, Id=%s", new Object[] { ((NavigationNotification) (obj)).sourceId }); if (ANCSNotification.notificationsForANCSId(Integer.valueOf(((NavigationNotification) (obj)).sourceId).intValue(), contentresolver).isEmpty()) { ALog.d("Notification=CONTENT_CHANGED, Event=ERASE, Action=CHECK_IF_ID_MATCH, Result=NOT_MATCH_DELETING", new Object[0]); com.olio.communication.notifications.NotificationContract.Notifications.delete(contentresolver, "com.olio.apps.NavigationItem.ID"); return; } else { ALog.d("Notification=CONTENT_CHANGED, Event=ERASE, Action=CHECK_IF_ID_MATCH, Result=MATCH_NOT_DELETING", new Object[0]); return; } } else { ALog.d("Notification=CONTENT_CHANGED, Event=ERASE, Action=CHECK_IF_ID_MATCH, Result=NAVIGATION_NOTIFICATION_NOT_FOUND", new Object[0]); return; } } private static byte[] convertToByteId(int i) { return (new byte[] { (byte)(i >> 24), (byte)(i >> 16), (byte)(i >> 8), (byte)(i & 0xff) }); } public static ANCSNotification createTestNotification(ANCSNotification ancsnotification, Random random) { int i = random.nextInt(); ancsnotification.setANCSId(convertToByteId(i)); ancsnotification.setIdInteger(Integer.valueOf(i)); ancsnotification.setCategory(com.olio.communication.notifications.NotificationFilters.Category.LOCATION); ancsnotification.setAppName("com.google.Maps"); ancsnotification.setTitle("Navigation Guidance"); ancsnotification.setANCSDate(System.currentTimeMillis()); return ancsnotification; } public static void insertNotification(Context context, NavigationNotification navigationnotification) { com.olio.communication.notifications.NotificationContract.Notifications.queuedBulkInsert(context, navigationnotification); } public static NavigationNotification parse(ANCSNotification ancsnotification) { if (!"com.google.Maps".equals(ancsnotification.getAppName())) { ALog.d("Notification=CREATE_UPDATE, From='%s', Category=LOCATION, Action=REJECTED_NOT_GMAPS", new Object[] { ancsnotification.getAppName() }); return null; } String s = ancsnotification.getMessage().trim(); String s1 = s.toLowerCase(); String s2 = String.valueOf(ancsnotification.getIdInteger()); int j = sPatterns.size(); for (int i = 0; i < j; i++) { Matcher matcher = ((Pattern)sPatterns.keyAt(i)).matcher(s1); if (matcher.matches()) { NavigationNotification navigationnotification = new NavigationNotification(); ((NavigationParser)sPatterns.valueAt(i)).parse(matcher, navigationnotification, s, s1); navigationnotification.sourceId = s2; navigationnotification.timestamp = ancsnotification.getANCSDate(); return navigationnotification; } } ALog.w("Navigation=PARSE, Message='%s', Match=NOT_A_MATCH", new Object[] { s }); return null; } private static int parseDirection(String s) { byte byte0 = -1; s.hashCode(); JVM INSTR lookupswitch 2: default 32 // 3317767: 58 // 108511772: 73; goto _L1 _L2 _L3 _L1: break; /* Loop/switch isn't completed */ _L3: break MISSING_BLOCK_LABEL_73; _L4: switch (byte0) { default: return 1; case 0: // '\0' return 2; case 1: // '\001' return 3; } _L2: if (s.equals("left")) { byte0 = 0; } goto _L4 if (s.equals("right")) { byte0 = 1; } goto _L4 } private static void parseSomething(String s, NavigationNotification navigationnotification, String s1) { navigationnotification.action = 240; navigationnotification.target = s; } public static void sendNavigationIntent(Context context, NavigationNotification navigationnotification) { Intent intent = new Intent("navigation.action"); intent.putExtra("navigation.direction", navigationnotification.direction); intent.putExtra("navigation.distance", navigationnotification.distance); intent.putExtra("navigation.units", navigationnotification.unit); intent.putExtra("navigation.target", navigationnotification.target); context.sendBroadcast(intent); } public static void vibrate(Context context) { long l = System.currentTimeMillis(); if (l - lastVibrationTime > 5000L) { ((Vibrator)context.getSystemService("vibrator")).vibrate(500L); lastVibrationTime = l; } } static { sPatterns = new ArrayMap(); sPatterns.put(Pattern.compile("^turn (left|right) (at|onto) (.+)$"), new DirectionParser(32, 1)); sPatterns.put(Pattern.compile("^keep (left|right) at the fork( to continue towards (.+))?$"), new DirectionParser(128, 1)); sPatterns.put(Pattern.compile("^slight (left|right)( onto (.+))?$"), new DirectionParser(160, 1)); sPatterns.put(Pattern.compile("^sharp (left|right) at (.+)$"), new DirectionParser(176, 1)); sPatterns.put(Pattern.compile("^at the roundabout, (continue straight|take the ((\\d+)(st|nd|rd|th)|(first|second|third)) exit)$"), new RoundaboutParser()); sPatterns.put(Pattern.compile("^make a u\\-turn at (.+)$"), new ConstantParser(144, 2)); sPatterns.put(Pattern.compile("^take the (.+) (left|right)$"), new DirectionParser(48, 2)); sPatterns.put(Pattern.compile("^take the ramp on the (left|right) onto (.+)$"), new DirectionParser(80, 1)); sPatterns.put(Pattern.compile("^take the ramp to (.+)$"), new ConstantParser(80)); sPatterns.put(Pattern.compile("^turn (left|right) to merge onto (.+)$"), new DirectionParser(112, 1)); sPatterns.put(Pattern.compile("^merge onto (.+)$"), new ConstantParser(112)); sPatterns.put(Pattern.compile("^take the (.+) exit towards (.+)$"), new ConstantParser(64)); sPatterns.put(Pattern.compile("^exit onto (.+)$"), new ConstantParser(64)); ConstantParser constantparser = new ConstantParser(16, 1); sPatterns.put(Pattern.compile("^head (towards (.+)|(.+)( on (.+) toward (.+))?)$"), constantparser); sPatterns.put(Pattern.compile("^continue onto (.+)$"), constantparser); sPatterns.put(Pattern.compile("^pass by (.+)$"), constantparser); } }