code: private void resolveBaseDirection(byte[] levels) {
          if (Bidi.IsDefaultLevel(levels[0])) {
              byte level = Bidi.getBaseDirection(text);
              levels[0] = level != Bidi.NEUTRAL ? level
                  : levels[0] == Bidi.LEVEL_DEFAULT_RTL ? Bidi.RTL : Bidi.LTR;
          } else {
              levels[0] &= 1;
          }
          if (Bidi.IsDefaultLevel(levels[1])) {
              levels[1] = levels[0];
          } else {
              levels[1] &= 1;
          }
      }
docs: When the direction option is
  <code>{@link Bidi#LEVEL_DEFAULT_LTR}</code> or
  <code>{@link Bidi#LEVEL_DEFAULT_RTL}</code>, resolves the base
  direction according to that of the first strong directional character in
  the text.
  
  @param levels Byte array, where levels[0] is an input level levels[1] is
  an output level. Resolved levels override these.