dalvik.system.VMRuntime Java Examples
The following examples show how to use
dalvik.system.VMRuntime.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ZygoteInit.java From android_9.0.0_r45 with Apache License 2.0 | 7 votes |
/** * Note that preparing the profiles for system server does not require special * selinux permissions. From the installer perspective the system server is a regular package * which can capture profile information. */ private static void prepareSystemServerProfile(String systemServerClasspath) throws RemoteException { if (systemServerClasspath.isEmpty()) { return; } String[] codePaths = systemServerClasspath.split(":"); final IInstalld installd = IInstalld.Stub .asInterface(ServiceManager.getService("installd")); String systemServerPackageName = "android"; String systemServerProfileName = "primary.prof"; installd.prepareAppProfile( systemServerPackageName, UserHandle.USER_SYSTEM, UserHandle.getAppId(Process.SYSTEM_UID), systemServerProfileName, codePaths[0], /*dexMetadata*/ null); File profileDir = Environment.getDataProfilesDePackageDirectory( UserHandle.USER_SYSTEM, systemServerPackageName); String profilePath = new File(profileDir, systemServerProfileName).getAbsolutePath(); VMRuntime.registerAppInfo(profilePath, codePaths); }
Example #2
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private static ApplicationInfo maybeAdjustApplicationInfo(ApplicationInfo info) { // If we're dealing with a multi-arch application that has both // 32 and 64 bit shared libraries, we might need to choose the secondary // depending on what the current runtime's instruction set is. if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) { final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet(); // Get the instruction set that the libraries of secondary Abi is supported. // In presence of a native bridge this might be different than the one secondary Abi used. String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi); final String secondaryDexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + secondaryIsa); secondaryIsa = secondaryDexCodeIsa.isEmpty() ? secondaryIsa : secondaryDexCodeIsa; // If the runtimeIsa is the same as the primary isa, then we do nothing. // Everything will be set up correctly because info.nativeLibraryDir will // correspond to the right ISA. if (runtimeIsa.equals(secondaryIsa)) { ApplicationInfo modified = new ApplicationInfo(info); modified.nativeLibraryDir = info.secondaryNativeLibraryDir; return modified; } } return info; }
Example #3
Source File: StatusInstallerFragment.java From EdXposedManager with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String[] abiList; if (VMRuntime.getRuntime().is64Bit()) { abiList = SUPPORTED_64_BIT_ABIS; } else { abiList = SUPPORTED_32_BIT_ABIS; } CPU_ABI = abiList[0]; if (abiList.length > 1) { CPU_ABI2 = abiList[1]; } else { CPU_ABI2 = ""; } sActivity = getActivity(); }
Example #4
Source File: ApplicationPackageManager.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private static ApplicationInfo maybeAdjustApplicationInfo(ApplicationInfo info) { // If we're dealing with a multi-arch application that has both // 32 and 64 bit shared libraries, we might need to choose the secondary // depending on what the current runtime's instruction set is. if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) { final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet(); // Get the instruction set that the libraries of secondary Abi is supported. // In presence of a native bridge this might be different than the one secondary Abi used. String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi); final String secondaryDexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + secondaryIsa); secondaryIsa = secondaryDexCodeIsa.isEmpty() ? secondaryIsa : secondaryDexCodeIsa; // If the runtimeIsa is the same as the primary isa, then we do nothing. // Everything will be set up correctly because info.nativeLibraryDir will // correspond to the right ISA. if (runtimeIsa.equals(secondaryIsa)) { ApplicationInfo modified = new ApplicationInfo(info); modified.nativeLibraryDir = info.secondaryNativeLibraryDir; return modified; } } return info; }
Example #5
Source File: LoadedApk.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private static ApplicationInfo adjustNativeLibraryPaths(ApplicationInfo info) { // If we're dealing with a multi-arch application that has both // 32 and 64 bit shared libraries, we might need to choose the secondary // depending on what the current runtime's instruction set is. if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) { final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet(); // Get the instruction set that the libraries of secondary Abi is supported. // In presence of a native bridge this might be different than the one secondary Abi used. String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi); final String secondaryDexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + secondaryIsa); secondaryIsa = secondaryDexCodeIsa.isEmpty() ? secondaryIsa : secondaryDexCodeIsa; // If the runtimeIsa is the same as the primary isa, then we do nothing. // Everything will be set up correctly because info.nativeLibraryDir will // correspond to the right ISA. if (runtimeIsa.equals(secondaryIsa)) { final ApplicationInfo modified = new ApplicationInfo(info); modified.nativeLibraryDir = modified.secondaryNativeLibraryDir; modified.primaryCpuAbi = modified.secondaryCpuAbi; return modified; } } return info; }
Example #6
Source File: DexLoadReporter.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void notifyPackageManager(List<BaseDexClassLoader> classLoadersChain, List<String> classPaths) { // Get the class loader names for the binder call. List<String> classLoadersNames = new ArrayList<>(classPaths.size()); for (BaseDexClassLoader bdc : classLoadersChain) { classLoadersNames.add(bdc.getClass().getName()); } String packageName = ActivityThread.currentPackageName(); try { ActivityThread.getPackageManager().notifyDexLoad( packageName, classLoadersNames, classPaths, VMRuntime.getRuntime().vmInstructionSet()); } catch (RemoteException re) { Slog.e(TAG, "Failed to notify PM about dex load for package " + packageName, re); } }
Example #7
Source File: Parcel.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void updateNativeSize(long newNativeSize) { if (mOwnsNativeParcelObject) { if (newNativeSize > Integer.MAX_VALUE) { newNativeSize = Integer.MAX_VALUE; } if (newNativeSize != mNativeSize) { int delta = (int) (newNativeSize - mNativeSize); if (delta > 0) { VMRuntime.getRuntime().registerNativeAllocation(delta); } else { VMRuntime.getRuntime().registerNativeFree(-delta); } mNativeSize = newNativeSize; } } }
Example #8
Source File: StrictMode.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Detect everything that's potentially suspect. * * <p>As of the Gingerbread release this includes network and disk operations but will * likely expand in future releases. */ public Builder detectAll() { detectDiskReads(); detectDiskWrites(); detectNetwork(); final int targetSdk = VMRuntime.getRuntime().getTargetSdkVersion(); if (targetSdk >= Build.VERSION_CODES.HONEYCOMB) { detectCustomSlowCalls(); } if (targetSdk >= Build.VERSION_CODES.M) { detectResourceMismatches(); } if (targetSdk >= Build.VERSION_CODES.O) { detectUnbufferedIo(); } return this; }
Example #9
Source File: WebViewLibraryLoader.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Load WebView's native library into the current process. * * <p class="note"><b>Note:</b> Assumes that we have waited for relro creation. * * @param clazzLoader class loader used to find the linker namespace to load the library into. * @param libraryFileName the filename of the library to load. */ public static int loadNativeLibrary(ClassLoader clazzLoader, String libraryFileName) { if (!sAddressSpaceReserved) { Log.e(LOGTAG, "can't load with relro file; address space not reserved"); return WebViewFactory.LIBLOAD_ADDRESS_SPACE_NOT_RESERVED; } String relroPath = VMRuntime.getRuntime().is64Bit() ? CHROMIUM_WEBVIEW_NATIVE_RELRO_64 : CHROMIUM_WEBVIEW_NATIVE_RELRO_32; int result = nativeLoadWithRelroFile(libraryFileName, relroPath, clazzLoader); if (result != WebViewFactory.LIBLOAD_SUCCESS) { Log.w(LOGTAG, "failed to load with relro file, proceeding without"); } else if (DEBUG) { Log.v(LOGTAG, "loaded with relro file"); } return result; }
Example #10
Source File: RuntimeInit.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
protected static Runnable applicationInit(int targetSdkVersion, String[] argv, ClassLoader classLoader) { // If the application calls System.exit(), terminate the process // immediately without running any shutdown hooks. It is not possible to // shutdown an Android application gracefully. Among other things, the // Android runtime shutdown hooks close the Binder driver, which can cause // leftover running threads to crash before the process actually exits. nativeSetExitWithoutCleanup(true); // We want to be fairly aggressive about heap utilization, to avoid // holding on to a lot of memory that isn't needed. // //设置虚拟机的内存利用率参数值为 0.75 VMRuntime.getRuntime().setTargetHeapUtilization(0.75f); VMRuntime.getRuntime().setTargetSdkVersion(targetSdkVersion); final Arguments args = new Arguments(argv); // 解析参数 // The end of of the RuntimeInit event (see #zygoteInit). Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); // Remaining arguments are passed to the start class's static main // 寻找 startClass 的 main() 方法。这里的 startClass 是 com.android.server.SystemServer return findStaticMain(args.startClass, args.startArgs, classLoader); }
Example #11
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private static ApplicationInfo maybeAdjustApplicationInfo(ApplicationInfo info) { // If we're dealing with a multi-arch application that has both // 32 and 64 bit shared libraries, we might need to choose the secondary // depending on what the current runtime's instruction set is. if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) { final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet(); // Get the instruction set that the libraries of secondary Abi is supported. // In presence of a native bridge this might be different than the one secondary Abi used. String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi); final String secondaryDexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + secondaryIsa); secondaryIsa = secondaryDexCodeIsa.isEmpty() ? secondaryIsa : secondaryDexCodeIsa; // If the runtimeIsa is the same as the primary isa, then we do nothing. // Everything will be set up correctly because info.nativeLibraryDir will // correspond to the right ISA. if (runtimeIsa.equals(secondaryIsa)) { ApplicationInfo modified = new ApplicationInfo(info); modified.nativeLibraryDir = info.secondaryNativeLibraryDir; return modified; } } return info; }
Example #12
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private static ApplicationInfo maybeAdjustApplicationInfo(ApplicationInfo info) { // If we're dealing with a multi-arch application that has both // 32 and 64 bit shared libraries, we might need to choose the secondary // depending on what the current runtime's instruction set is. if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) { final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet(); // Get the instruction set that the libraries of secondary Abi is supported. // In presence of a native bridge this might be different than the one secondary Abi used. String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi); final String secondaryDexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + secondaryIsa); secondaryIsa = secondaryDexCodeIsa.isEmpty() ? secondaryIsa : secondaryDexCodeIsa; // If the runtimeIsa is the same as the primary isa, then we do nothing. // Everything will be set up correctly because info.nativeLibraryDir will // correspond to the right ISA. if (runtimeIsa.equals(secondaryIsa)) { ApplicationInfo modified = new ApplicationInfo(info); modified.nativeLibraryDir = info.secondaryNativeLibraryDir; return modified; } } return info; }
Example #13
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private static ApplicationInfo maybeAdjustApplicationInfo(ApplicationInfo info) { // If we're dealing with a multi-arch application that has both // 32 and 64 bit shared libraries, we might need to choose the secondary // depending on what the current runtime's instruction set is. if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) { final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet(); // Get the instruction set that the libraries of secondary Abi is supported. // In presence of a native bridge this might be different than the one secondary Abi used. String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi); final String secondaryDexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + secondaryIsa); secondaryIsa = secondaryDexCodeIsa.isEmpty() ? secondaryIsa : secondaryDexCodeIsa; // If the runtimeIsa is the same as the primary isa, then we do nothing. // Everything will be set up correctly because info.nativeLibraryDir will // correspond to the right ISA. if (runtimeIsa.equals(secondaryIsa)) { ApplicationInfo modified = new ApplicationInfo(info); modified.nativeLibraryDir = info.secondaryNativeLibraryDir; return modified; } } return info; }
Example #14
Source File: LoadedApk.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private static ApplicationInfo adjustNativeLibraryPaths(ApplicationInfo info) { // If we're dealing with a multi-arch application that has both // 32 and 64 bit shared libraries, we might need to choose the secondary // depending on what the current runtime's instruction set is. if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) { final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet(); // Get the instruction set that the libraries of secondary Abi is supported. // In presence of a native bridge this might be different than the one secondary Abi used. String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi); final String secondaryDexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + secondaryIsa); secondaryIsa = secondaryDexCodeIsa.isEmpty() ? secondaryIsa : secondaryDexCodeIsa; // If the runtimeIsa is the same as the primary isa, then we do nothing. // Everything will be set up correctly because info.nativeLibraryDir will // correspond to the right ISA. if (runtimeIsa.equals(secondaryIsa)) { final ApplicationInfo modified = new ApplicationInfo(info); modified.nativeLibraryDir = modified.secondaryNativeLibraryDir; modified.primaryCpuAbi = modified.secondaryCpuAbi; return modified; } } return info; }
Example #15
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private static ApplicationInfo maybeAdjustApplicationInfo(ApplicationInfo info) { // If we're dealing with a multi-arch application that has both // 32 and 64 bit shared libraries, we might need to choose the secondary // depending on what the current runtime's instruction set is. if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) { final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet(); // Get the instruction set that the libraries of secondary Abi is supported. // In presence of a native bridge this might be different than the one secondary Abi used. String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi); final String secondaryDexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + secondaryIsa); secondaryIsa = secondaryDexCodeIsa.isEmpty() ? secondaryIsa : secondaryDexCodeIsa; // If the runtimeIsa is the same as the primary isa, then we do nothing. // Everything will be set up correctly because info.nativeLibraryDir will // correspond to the right ISA. if (runtimeIsa.equals(secondaryIsa)) { ApplicationInfo modified = new ApplicationInfo(info); modified.nativeLibraryDir = info.secondaryNativeLibraryDir; return modified; } } return info; }
Example #16
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private static void maybeAdjustApplicationInfo(ApplicationInfo info) { // If we're dealing with a multi-arch application that has both // 32 and 64 bit shared libraries, we might need to choose the secondary // depending on what the current runtime's instruction set is. if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) { final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet(); // Get the instruction set that the libraries of secondary Abi is supported. // In presence of a native bridge this might be different than the one secondary Abi used. String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi); final String secondaryDexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + secondaryIsa); secondaryIsa = secondaryDexCodeIsa.isEmpty() ? secondaryIsa : secondaryDexCodeIsa; // If the runtimeIsa is the same as the primary isa, then we do nothing. // Everything will be set up correctly because info.nativeLibraryDir will // correspond to the right ISA. if (runtimeIsa.equals(secondaryIsa)) { info.nativeLibraryDir = info.secondaryNativeLibraryDir; } } }
Example #17
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private static ApplicationInfo maybeAdjustApplicationInfo(ApplicationInfo info) { // If we're dealing with a multi-arch application that has both // 32 and 64 bit shared libraries, we might need to choose the secondary // depending on what the current runtime's instruction set is. if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) { final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet(); // Get the instruction set that the libraries of secondary Abi is supported. // In presence of a native bridge this might be different than the one secondary Abi used. String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi); final String secondaryDexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + secondaryIsa); secondaryIsa = secondaryDexCodeIsa.isEmpty() ? secondaryIsa : secondaryDexCodeIsa; // If the runtimeIsa is the same as the primary isa, then we do nothing. // Everything will be set up correctly because info.nativeLibraryDir will // correspond to the right ISA. if (runtimeIsa.equals(secondaryIsa)) { ApplicationInfo modified = new ApplicationInfo(info); modified.nativeLibraryDir = info.secondaryNativeLibraryDir; return modified; } } return info; }
Example #18
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private static ApplicationInfo maybeAdjustApplicationInfo(ApplicationInfo info) { // If we're dealing with a multi-arch application that has both // 32 and 64 bit shared libraries, we might need to choose the secondary // depending on what the current runtime's instruction set is. if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) { final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet(); // Get the instruction set that the libraries of secondary Abi is supported. // In presence of a native bridge this might be different than the one secondary Abi used. String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi); final String secondaryDexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + secondaryIsa); secondaryIsa = secondaryDexCodeIsa.isEmpty() ? secondaryIsa : secondaryDexCodeIsa; // If the runtimeIsa is the same as the primary isa, then we do nothing. // Everything will be set up correctly because info.nativeLibraryDir will // correspond to the right ISA. if (runtimeIsa.equals(secondaryIsa)) { ApplicationInfo modified = new ApplicationInfo(info); modified.nativeLibraryDir = info.secondaryNativeLibraryDir; return modified; } } return info; }
Example #19
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private static void maybeAdjustApplicationInfo(ApplicationInfo info) { // If we're dealing with a multi-arch application that has both // 32 and 64 bit shared libraries, we might need to choose the secondary // depending on what the current runtime's instruction set is. if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) { final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet(); final String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi); // If the runtimeIsa is the same as the primary isa, then we do nothing. // Everything will be set up correctly because info.nativeLibraryDir will // correspond to the right ISA. if (runtimeIsa.equals(secondaryIsa)) { info.nativeLibraryDir = info.secondaryNativeLibraryDir; } } }
Example #20
Source File: Package.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * Returns the string representation of this Package. * Its value is the string "package " and the package name. * If the package title is defined it is appended. * If the package version is defined it is appended. * @return the string representation of the package. */ public String toString() { // Android-changed start // Several apps try to parse the output of toString(). This is a really // bad idea - especially when there's a Package.getName() function as well as a // Class.getName() function that can be used instead. // Starting from the API level 25 the proper output is generated. final int targetSdkVersion = VMRuntime.getRuntime().getTargetSdkVersion(); if (targetSdkVersion > 0 && targetSdkVersion <= 24) { return "package " + pkgName; } // Android-changed end String spec = specTitle; String ver = specVersion; if (spec != null && spec.length() > 0) spec = ", " + spec; else spec = ""; if (ver != null && ver.length() > 0) ver = ", version " + ver; else ver = ""; return "package " + pkgName + spec + ver; }
Example #21
Source File: LoadedApk.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
private void setupJitProfileSupport() { if (!SystemProperties.getBoolean("dalvik.vm.usejitprofiles", false)) { return; } // Only set up profile support if the loaded apk has the same uid as the // current process. // Currently, we do not support profiling across different apps. // (e.g. application's uid might be different when the code is // loaded by another app via createApplicationContext) if (mApplicationInfo.uid != Process.myUid()) { return; } final List<String> codePaths = new ArrayList<>(); if ((mApplicationInfo.flags & ApplicationInfo.FLAG_HAS_CODE) != 0) { codePaths.add(mApplicationInfo.sourceDir); } if (mApplicationInfo.splitSourceDirs != null) { Collections.addAll(codePaths, mApplicationInfo.splitSourceDirs); } if (codePaths.isEmpty()) { // If there are no code paths there's no need to setup a profile file and register with // the runtime, return; } final File profileFile = getPrimaryProfileFile(mPackageName); VMRuntime.registerAppInfo(profileFile.getPath(), codePaths.toArray(new String[codePaths.size()])); // Register the app data directory with the reporter. It will // help deciding whether or not a dex file is the primary apk or a // secondary dex. DexLoadReporter.getInstance().registerAppDataDir(mPackageName, mDataDir); }
Example #22
Source File: RemoteDebugConsole.java From Boardwalk with Apache License 2.0 | 5 votes |
public void runOnce() throws Exception { if (serverSock != null) serverSock.close(); serverSock = new ServerSocket(15554); while (true) { Socket sock = serverSock.accept(); InputStream is = sock.getInputStream(); OutputStream os = sock.getOutputStream(); Scanner scan = new Scanner(is); PrintStream out = new PrintStream(os); String theLine; while ((theLine = scan.nextLine()) != null) { String[] parts = theLine.split(" "); if (parts.length < 1) continue; String c = parts[0]; if (c.equals("heapmaxfree")) { DalvikTweaks.setHeapMaxFree(parseM(parts[1])); } else if (c.equals("heapminfree")) { DalvikTweaks.setHeapMinFree(parseM(parts[1])); } else if (c.equals("utilset")) { VMRuntime.getRuntime().setTargetHeapUtilization(Float.parseFloat(parts[1])); } else if (c.equals("utilget")) { out.println(VMRuntime.getRuntime().getTargetHeapUtilization()); } else if (c.equals("gc")) { System.gc(); } else if (c.equals("alloc")) { byte[] theByte = new byte[(int) parseM(parts[1])]; } else { out.println("?"); } } sock.close(); } }
Example #23
Source File: TypedArray.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void resize(int len) { mLength = len; final int dataLen = len * STYLE_NUM_ENTRIES; final int indicesLen = len + 1; final VMRuntime runtime = VMRuntime.getRuntime(); if (mDataAddress == 0 || mData.length < dataLen) { mData = (int[]) runtime.newNonMovableArray(int.class, dataLen); mDataAddress = runtime.addressOf(mData); mIndices = (int[]) runtime.newNonMovableArray(int.class, indicesLen); mIndicesAddress = runtime.addressOf(mIndices); } }
Example #24
Source File: LoadedApk.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void setupJitProfileSupport() { if (!SystemProperties.getBoolean("dalvik.vm.usejitprofiles", false)) { return; } // Only set up profile support if the loaded apk has the same uid as the // current process. // Currently, we do not support profiling across different apps. // (e.g. application's uid might be different when the code is // loaded by another app via createApplicationContext) if (mApplicationInfo.uid != Process.myUid()) { return; } final List<String> codePaths = new ArrayList<>(); if ((mApplicationInfo.flags & ApplicationInfo.FLAG_HAS_CODE) != 0) { codePaths.add(mApplicationInfo.sourceDir); } if (mApplicationInfo.splitSourceDirs != null) { Collections.addAll(codePaths, mApplicationInfo.splitSourceDirs); } if (codePaths.isEmpty()) { // If there are no code paths there's no need to setup a profile file and register with // the runtime, return; } for (int i = codePaths.size() - 1; i >= 0; i--) { String splitName = i == 0 ? null : mApplicationInfo.splitNames[i - 1]; String profileFile = ArtManager.getCurrentProfilePath( mPackageName, UserHandle.myUserId(), splitName); VMRuntime.registerAppInfo(profileFile, new String[] {codePaths.get(i)}); } // Register the app data directory with the reporter. It will // help deciding whether or not a dex file is the primary apk or a // secondary dex. DexLoadReporter.getInstance().registerAppDataDir(mPackageName, mDataDir); }
Example #25
Source File: DexLoadReporter.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void registerSecondaryDexForProfiling(String dexPath, String[] dataDirs) { if (!isSecondaryDexFile(dexPath, dataDirs)) { // The dex path is not a secondary dex file. Nothing to do. return; } // Secondary dex profiles are stored in the oat directory, next to dex file // and have the same name with 'cur.prof' appended. // NOTE: Keep this in sync with installd expectations. File dexPathFile = new File(dexPath); File secondaryProfileDir = new File(dexPathFile.getParent(), "oat"); File secondaryProfile = new File(secondaryProfileDir, dexPathFile.getName() + ".cur.prof"); // Create the profile if not already there. // Returns true if the file was created, false if the file already exists. // or throws exceptions in case of errors. if (!secondaryProfileDir.exists()) { if (!secondaryProfileDir.mkdir()) { Slog.e(TAG, "Could not create the profile directory: " + secondaryProfile); // Do not continue with registration if we could not create the oat dir. return; } } try { boolean created = secondaryProfile.createNewFile(); if (DEBUG && created) { Slog.i(TAG, "Created profile for secondary dex: " + secondaryProfile); } } catch (IOException ex) { Slog.e(TAG, "Failed to create profile for secondary dex " + dexPath + ":" + ex.getMessage()); // Do not continue with registration if we could not create the profile files. return; } // If we got here, the dex paths is a secondary dex and we were able to create the profile. // Register the path to the runtime. VMRuntime.registerAppInfo(secondaryProfile.getPath(), new String[] { dexPath }); }
Example #26
Source File: GraphicsEnvironment.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private static String chooseAbi(ApplicationInfo ai) { String isa = VMRuntime.getCurrentInstructionSet(); if (ai.primaryCpuAbi != null && isa.equals(VMRuntime.getInstructionSet(ai.primaryCpuAbi))) { return ai.primaryCpuAbi; } if (ai.secondaryCpuAbi != null && isa.equals(VMRuntime.getInstructionSet(ai.secondaryCpuAbi))) { return ai.secondaryCpuAbi; } return null; }
Example #27
Source File: StrictMode.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Detect everything that's potentially suspect. * * <p>In the Honeycomb release this includes leaks of SQLite cursors, Activities, and * other closable objects but will likely expand in future releases. */ public Builder detectAll() { detectLeakedSqlLiteObjects(); final int targetSdk = VMRuntime.getRuntime().getTargetSdkVersion(); if (targetSdk >= Build.VERSION_CODES.HONEYCOMB) { detectActivityLeaks(); detectLeakedClosableObjects(); } if (targetSdk >= Build.VERSION_CODES.JELLY_BEAN) { detectLeakedRegistrationObjects(); } if (targetSdk >= Build.VERSION_CODES.JELLY_BEAN_MR2) { detectFileUriExposure(); } if (targetSdk >= Build.VERSION_CODES.M) { // TODO: always add DETECT_VM_CLEARTEXT_NETWORK once we have // facility for apps to mark sockets that should be ignored if (SystemProperties.getBoolean(CLEARTEXT_PROPERTY, false)) { detectCleartextNetwork(); } } if (targetSdk >= Build.VERSION_CODES.O) { detectContentUriWithoutPermission(); detectUntaggedSockets(); } // TODO: Decide whether to detect non SDK API usage beyond a certain API level. return this; }
Example #28
Source File: WebViewLibraryLoader.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * @return the directory of the native WebView library with bitness {@param is64bit}. * @hide */ @VisibleForTesting public static String getWebViewNativeLibraryDirectory(ApplicationInfo ai, boolean is64bit) { // Primary arch has the same bitness as the library we are looking for. if (is64bit == VMRuntime.is64BitAbi(ai.primaryCpuAbi)) return ai.nativeLibraryDir; // Secondary arch has the same bitness as the library we are looking for. if (!TextUtils.isEmpty(ai.secondaryCpuAbi)) { return ai.secondaryNativeLibraryDir; } return ""; }
Example #29
Source File: InstructionSets.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public static String[] getAppDexInstructionSets(ApplicationInfo info) { if (info.primaryCpuAbi != null) { if (info.secondaryCpuAbi != null) { return new String[] { VMRuntime.getInstructionSet(info.primaryCpuAbi), VMRuntime.getInstructionSet(info.secondaryCpuAbi) }; } else { return new String[] { VMRuntime.getInstructionSet(info.primaryCpuAbi) }; } } return new String[] { getPreferredInstructionSet() }; }
Example #30
Source File: InstructionSets.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public static String[] getAppDexInstructionSets(PackageSetting ps) { if (ps.primaryCpuAbiString != null) { if (ps.secondaryCpuAbiString != null) { return new String[] { VMRuntime.getInstructionSet(ps.primaryCpuAbiString), VMRuntime.getInstructionSet(ps.secondaryCpuAbiString) }; } else { return new String[] { VMRuntime.getInstructionSet(ps.primaryCpuAbiString) }; } } return new String[] { getPreferredInstructionSet() }; }