1 /* 2 * Copyright 2015, Google Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * 9 * Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above 12 * copyright notice, this list of conditions and the following disclaimer 13 * in the documentation and/or other materials provided with the 14 * distribution. 15 * Neither the name of Google Inc. nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 package org.jf.dexlib2; 33 34 public class VersionMap { 35 public static final int NO_VERSION = -1; 36 mapArtVersionToApi(int artVersion)37 public static int mapArtVersionToApi(int artVersion) { 38 // NOTE: Art version 87 and api level 26 do not correspond to any 39 // particular android release and represent the current (as of 40 // October 2016) state of aosp/master. 41 if (artVersion >= 87) { 42 return 26; 43 } 44 if (artVersion >= 79) { 45 return 24; 46 } 47 if (artVersion >= 64) { 48 return 23; 49 } 50 if (artVersion >= 45) { 51 return 22; 52 } 53 if (artVersion >= 39) { 54 return 21; 55 } 56 return 19; 57 } 58 mapApiToArtVersion(int api)59 public static int mapApiToArtVersion(int api) { 60 switch (api) { 61 case 19: 62 case 20: 63 return 7; 64 case 21: 65 return 39; 66 case 22: 67 return 45; 68 case 23: 69 return 64; 70 case 24: 71 case 25: 72 return 79; 73 } 74 75 // NOTE: Art version 87 and api level 26 do not correspond to any 76 // particular android release and represent the current (as of 77 // October 2016) state of aosp/master. 78 if (api > 25) { 79 return 87; 80 } 81 return NO_VERSION; 82 } 83 } 84