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 public static final String RELEASE_CHANNEL = "default"; 32 public static boolean SHOW_LOADING_VIEW_IN_SHELL_APP = false; 33 34 public static void setSdkVersions(List<String> sdkVersions) { 35 ABI_VERSIONS = TextUtils.join(",", sdkVersions); 36 37 // NOTE: Currently public-facing SDK versions and internal ABI versions are the same, but 38 // eventually we may decouple them 39 SDK_VERSIONS = ABI_VERSIONS; 40 SDK_VERSIONS_LIST = sdkVersions; 41 } 42 43 static { 44 List<String> abiVersions = new ArrayList<>(); 45 // THIS COMMENT IS USED BY android-build-aar.sh DO NOT MODIFY 46 abiVersions.add("23.0.0"); 47 abiVersions.add("22.0.0"); 48 abiVersions.add("21.0.0"); 49 abiVersions.add("20.0.0"); 50 abiVersions.add("19.0.0"); 51 abiVersions.add("18.0.0"); 52 abiVersions.add("17.0.0"); 53 54 if (TEMPORARY_ABI_VERSION != null) { 55 abiVersions.add(TEMPORARY_ABI_VERSION); 56 } 57 58 setSdkVersions(abiVersions); 59 60 List<EmbeddedResponse> embeddedResponses = new ArrayList<>(); 61 embeddedResponses.add(new EmbeddedResponse("https://exp.host/@exponent/home/bundle", EMBEDDED_KERNEL_PATH, "application/javascript")); 62 // ADD EMBEDDED RESPONSES HERE 63 // START EMBEDDED RESPONSES 64 // END EMBEDDED RESPONSES 65 EMBEDDED_RESPONSES = embeddedResponses; 66 } 67 68 public static final boolean DEBUG_COLD_START_METHOD_TRACING = false; 69 public static final boolean DEBUG_MANIFEST_METHOD_TRACING = false; 70 public static final boolean DEBUG_METHOD_TRACING = DEBUG_COLD_START_METHOD_TRACING || DEBUG_MANIFEST_METHOD_TRACING; 71 public static final boolean ENABLE_LEAK_CANARY = false; 72 public static final boolean WRITE_BUNDLE_TO_LOG = false; 73 public static final boolean WAIT_FOR_DEBUGGER = false; 74 75 public static boolean isShellApp() { 76 return INITIAL_URL != null; 77 } 78 79 public static class EmbeddedResponse { 80 public final String url; 81 public final String responseFilePath; 82 public final String mediaType; 83 84 public EmbeddedResponse(final String url, final String responseFilePath, final String mediaType) { 85 this.url = url; 86 this.responseFilePath = responseFilePath; 87 this.mediaType = mediaType; 88 } 89 } 90 91 public static String getVersionName(Context context) { 92 if (VERSION_NAME != null) { 93 // This will be set in shell apps 94 return VERSION_NAME; 95 } else { 96 try { 97 PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); 98 return pInfo.versionName; 99 } catch (PackageManager.NameNotFoundException e) { 100 EXL.e(TAG, e.toString()); 101 return ""; 102 } 103 } 104 } 105 106 private static boolean sIsDetached = true; 107 public static void setIsDetached(boolean isDetached) { 108 sIsDetached = isDetached; 109 } 110 111 public static boolean isDetached() { 112 return sIsDetached; 113 } 114 } 115