code: static public byte[] unpack(byte[] packed) {
          if (packed == null) {
              return null;
          }
  
          int unpackedLen = (packed.length * 8) / 7;
          byte[] unpacked = new byte[unpackedLen];
          int len = unpacked.length;
          int current = 0;
          int bitpos = 0;
          for (int i = 0; i < len; i++) {
              // remove top bit and assign first half of partial bits
              unpacked[i] = (byte)(((packed[current] & 0xFF) >> bitpos) & 0x7F);
              // remove top bit and assign second half of partial bits (if exist)
              if (bitpos >= 2)
                  unpacked[i] |= (byte)((packed[++current] << (8 - bitpos)) & 0x7F);
              bitpos = (bitpos + 7) % 8;
              if (bitpos == 0)
                  current++;
          }
          // this fixes an ambiguity bug in the specs
          // where the last of 8 packed bytes is 0
          // and it's impossible to distinguish whether it is a
          // trailing '@' character (which is mapped to 0)
          // or extra zero-bit padding for 7 actual data bytes.
          //
          // we opt for the latter, since it's far more likely,
          // at the cost of losing a trailing '@' character
          // in strings whose unpacked size modulo 8 is 0,
          // and whose last character is '@'.
          //
          // an application that wishes to handle this rare case
          // properly must disambiguate this case externally, such
          // as by obtaining the original string length, and
          // appending the trailing '@' if the length
          // shows that there is one character missing.
          if (len % 8 == 0 && len > 0 && unpacked[len-1] == 0) {
              //System.err.println("Hit special case...");
              byte[] fixed = new byte[len-1];
              System.arraycopy(unpacked, 0, fixed, 0, len-1);
              unpacked = fixed;
          }
          return unpacked;
      }
docs: Unpack a byte array according to the GSM bit-packing algorithm.
  Read the full description in the documentation of the
  <code>pack</code> method.
  @see #pack(byte[])
  @param packed The packed byte array.
  @return A new byte array containing the unpacked bytes.