Commit 0422d67d authored by Joshua Peraza's avatar Joshua Peraza Committed by Commit Bot

Add base::android::GetPathToBaseApk()

Bug: crashpad:30
Change-Id: I433eba2e734244dd80d9becae84789fd406de25d
Reviewed-on: https://chromium-review.googlesource.com/1202703Reviewed-by: default avataragrieve <agrieve@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593045}
parent 2c2930e7
......@@ -261,4 +261,13 @@ public abstract class PathUtils {
public static String getExternalStorageDirectory() {
return Environment.getExternalStorageDirectory().getAbsolutePath();
}
/**
* @ return the path to the base apk.
*/
@SuppressWarnings("unused")
@CalledByNative
public static String getPathToBaseApk() {
return ContextUtils.getApplicationContext().getApplicationInfo().sourceDir;
}
}
......@@ -78,5 +78,14 @@ bool GetExternalStorageDirectory(FilePath* result) {
return true;
}
bool GetPathToBaseApk(FilePath* result) {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jstring> path =
Java_PathUtils_getPathToBaseApk(env);
FilePath apk_path(ConvertJavaStringToUTF8(path));
*result = apk_path;
return true;
}
} // namespace android
} // namespace base
......@@ -49,6 +49,10 @@ BASE_EXPORT bool GetNativeLibraryDirectory(FilePath* result);
// is placed in the FilePath pointed to by 'result'.
BASE_EXPORT bool GetExternalStorageDirectory(FilePath* result);
// Retrieves the absolute path the base APK. The result is placed in the
// FilePath pointed to by 'result'.
BASE_EXPORT bool GetPathToBaseApk(FilePath* result);
} // namespace android
} // namespace base
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment