Closed Bug 1208605 Opened 9 years ago Closed 9 years ago

Don't use static ANDROID_PACKAGE_NAME in toolkit/crashreporter

Categories

(Toolkit :: Crash Reporting, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed

People

(Reporter: nalexander, Unassigned)

Details

Attachments

(1 file)

Right now, we use a static ANDROID_PACKAGE_NAME reference at https://dxr.mozilla.org/mozilla-central/source/toolkit/crashreporter/nsExceptionHandler.cpp#1113.  This is a totally reasonable approach for the apps we build in automation.

Unfortunately, |mach artifact| based builds -- which are similar to the mooted "Go Faster" style builds -- use binaries built in automation (with package name 'org.mozilla.fennec') in locally produced binaries with package names like 'org.mozilla.fennec_$USER'.  We could re-use these binaries more easily if we extracted the appropriate package dynamically, at run-time.

This ticket tracks using the JNI to extract the package dynamically.
snorp: jchen: it's straightforward to use the JNI to extract the package name: something like:

static jstring getpkg(JNIEnv* env, jobject thiz, jobject activity) {
	jclass android_content_Context =env->GetObjectClass(activity);
	jmethodID midGetPackageName = env->GetMethodID(android_content_Context,"getPackageName", "()Ljava/lang/String;");
	jstring packageName= (jstring)env->CallObjectMethod(activity, midGetPackageName);
	return packageName;
}

(from https://gist.github.com/douzifly/11086408) should work.  Is there a reason not to do this?  Is it forbidden to use JNI in this location?
Flags: needinfo?(snorp)
Flags: needinfo?(nchen)
(In reply to Nick Alexander :nalexander from comment #1)
> snorp: jchen: it's straightforward to use the JNI to extract the package
> name: something like:

Hurgh, perhaps not so straight-forward: one needs an Android context somewhere, and it's not obvious where.  Presumably we can't get a GeckoAppShell or whatever at this point?
Would it be reasonable to fish the package name from an environment variable (set early in the process life, by the Java side) and perhaps fall back to the ANDROID_PACKAGE_NAME?
Bug 1208605 - Try MOZ_ANDROID_PACKAGE_NAME env var before static ANDROID_PACKAGE_NAME. r?snorp
Attachment #8666236 - Flags: review?(snorp)
Comment on attachment 8666236 [details]
MozReview Request: Bug 1208605 - Try MOZ_ANDROID_PACKAGE_NAME env var before static ANDROID_PACKAGE_NAME. r?snorp

https://reviewboard.mozilla.org/r/20473/#review18461

looks good
Attachment #8666236 - Flags: review?(snorp) → review+
Flags: needinfo?(nchen)
Jim did this get committed?
Flags: needinfo?(nchen)
I think you meant Nick?
Flags: needinfo?(nchen) → needinfo?(nalexander)
Try is green (the failures are a known, recently spiked, intermittent).  This is blocked on me verifying that the crash reporter still works, although it's hard to imagine it doesn't and we'd find out if it didn't quite quickly.
Flags: needinfo?(nalexander)
https://hg.mozilla.org/integration/fx-team/rev/8a3e98127ebc28fcc01d27bdedb4c959a456c47d
Bug 1208605 - Try MOZ_ANDROID_PACKAGE_NAME env var before static ANDROID_PACKAGE_NAME. r=snorp
https://hg.mozilla.org/mozilla-central/rev/8a3e98127ebc
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: