1 // Copyright 2015-present 650 Industries. All rights reserved. 2 3 package host.exp.exponent; 4 5 import android.content.Context; 6 import android.content.pm.PackageInfo; 7 import android.content.pm.PackageManager; 8 import android.net.Uri; 9 import android.text.TextUtils; 10 11 import java.util.ArrayList; 12 import java.util.List; 13 14 import host.exp.exponent.analytics.EXL; 15 16 public class Constants { 17 18 private static final String TAG = Constants.class.getSimpleName(); 19 20 public static final String VERSION_NAME = null; 21 public static String INITIAL_URL = null; 22 public static final String SHELL_APP_SCHEME = null; 23 public static final String API_HOST = "https://exp.host"; 24 public static String ABI_VERSIONS; 25 public static String SDK_VERSIONS; 26 public static List<String> SDK_VERSIONS_LIST; 27 public static final String TEMPORARY_ABI_VERSION = null; 28 public static final String EMBEDDED_KERNEL_PATH = "assets://kernel.android.bundle"; 29 public static final List<EmbeddedResponse> EMBEDDED_RESPONSES; 30 public static boolean DISABLE_NUX = false; 31 32 public static void setSdkVersions(List<String> sdkVersions) { 33 ABI_VERSIONS = TextUtils.join(",", sdkVersions); 34 35 // NOTE: Currently public-facing SDK versions and internal ABI versions are the same, but 36 // eventually we may decouple them 37 SDK_VERSIONS = ABI_VERSIONS; 38 SDK_VERSIONS_LIST = sdkVersions; 39 } 40 41 static { 42 List<String> abiVersions = new ArrayList<>(); 43 // THIS COMMENT IS USED BY android-build-aar.sh DO NOT MODIFY 44 abiVersions.add("21.0.0"); 45 abiVersions.add("20.0.0"); 46 abiVersions.add("19.0.0"); 47 abiVersions.add("18.0.0"); 48 abiVersions.add("17.0.0"); 49 abiVersions.add("16.0.0"); 50 abiVersions.add("15.0.0"); 51 abiVersions.add("14.0.0"); 52 53 if (TEMPORARY_ABI_VERSION != null) { 54 abiVersions.add(TEMPORARY_ABI_VERSION); 55 } 56 57 setSdkVersions(abiVersions); 58 59 List<EmbeddedResponse> embeddedResponses = new ArrayList<>(); 60 embeddedResponses.add(new EmbeddedResponse("https://exp.host/@exponent/home/bundle", EMBEDDED_KERNEL_PATH, "application/javascript")); 61 // ADD EMBEDDED RESPONSES HERE 62 // START EMBEDDED RESPONSES 63 // END EMBEDDED RESPONSES 64 EMBEDDED_RESPONSES = embeddedResponses; 65 } 66 67 public static final boolean DEBUG_COLD_START_METHOD_TRACING = false; 68 public static final boolean DEBUG_MANIFEST_METHOD_TRACING = false; 69 public static final boolean DEBUG_METHOD_TRACING = DEBUG_COLD_START_METHOD_TRACING || DEBUG_MANIFEST_METHOD_TRACING; 70 public static final boolean ENABLE_LEAK_CANARY = false; 71 public static final boolean WRITE_BUNDLE_TO_LOG = false; 72 public static final boolean WAIT_FOR_DEBUGGER = false; 73 74 public static boolean isShellApp() { 75 return INITIAL_URL != null; 76 } 77 78 public static class EmbeddedResponse { 79 public final String url; 80 public final String responseFilePath; 81 public final String mediaType; 82 83 public EmbeddedResponse(final String url, final String responseFilePath, final String mediaType) { 84 this.url = url; 85 this.responseFilePath = responseFilePath; 86 this.mediaType = mediaType; 87 } 88 } 89 90 public static String getVersionName(Context context) { 91 if (VERSION_NAME != null) { 92 // This will be set in shell apps 93 return VERSION_NAME; 94 } else { 95 try { 96 PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); 97 return pInfo.versionName; 98 } catch (PackageManager.NameNotFoundException e) { 99 EXL.e(TAG, e.toString()); 100 return ""; 101 } 102 } 103 } 104 105 private static boolean sIsDetached = true; 106 public static void setIsDetached(boolean isDetached) { 107 sIsDetached = isDetached; 108 } 109 110 public static boolean isDetached() { 111 return sIsDetached; 112 } 113 } 114