Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Commit

Permalink
bug 620584 - add ANDROID_PACKAGE_NAME rather than hard code org.mozil…
Browse files Browse the repository at this point in the history
…la.@MOZ_APP_NAME@ r=ted,blassy a=stuart

--HG--
branch : GECKO20b8_20101214_RELBRANCH
extra : transplant_source : %CD%DD%FC9%9D%F3X%EE%40%E6Z%FB0%7ED%83%AE%5C%AD%A6
  • Loading branch information
michaelwu committed Dec 21, 2010
1 parent f305443 commit 1de8b50
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 32 deletions.
2 changes: 2 additions & 0 deletions config/autoconf.mk.in
Expand Up @@ -705,6 +705,8 @@ ANDROID_SDK = @ANDROID_SDK@
ANDROID_TOOLS = @ANDROID_TOOLS@
ANDROID_VERSION = @ANDROID_VERSION@

ANDROID_PACKAGE_NAME = @ANDROID_PACKAGE_NAME@

JS_SHARED_LIBRARY = @JS_SHARED_LIBRARY@

# We only want to do the pymake sanity on Windows, other os's can cope
Expand Down
4 changes: 4 additions & 0 deletions configure.in
Expand Up @@ -330,6 +330,9 @@ if test "$target" = "arm-android-eabi" ; then
ANDROID_SDK="${android_sdk}"
ANDROID_TOOLS="${android_tools}"
ANDROID_VERSION="${android_version}"
if test -z "$ANDROID_PACKAGE_NAME" ; then
ANDROID_PACKAGE_NAME='org.mozilla.$(MOZ_APP_NAME)'
fi

AC_DEFINE(ANDROID)
AC_DEFINE_UNQUOTED(ANDROID_VERSION, $android_version)
Expand All @@ -344,6 +347,7 @@ AC_SUBST(ANDROID_TOOLCHAIN)
AC_SUBST(ANDROID_PLATFORM)
AC_SUBST(ANDROID_SDK)
AC_SUBST(ANDROID_TOOLS)
AC_SUBST(ANDROID_PACKAGE_NAME)

dnl ========================================================
dnl Checks for compilers.
Expand Down
2 changes: 1 addition & 1 deletion embedding/android/AlertNotification.java
Expand Up @@ -82,7 +82,7 @@ public void updateProgress(String aAlertText, long aProgress, long aProgressMax)
// Custom view
int layout = aAlertText.length() > 0 ? R.layout.notification_progress_text : R.layout.notification_progress;

RemoteViews view = new RemoteViews("org.mozilla." + GeckoApp.mAppContext.getAppName(), layout);
RemoteViews view = new RemoteViews(GeckoApp.mAppContext.getPackageName(), layout);
view.setImageViewResource(R.id.notificationImage, mIcon);
view.setTextViewText(R.id.notificationTitle, mTitle);
contentView = view;
Expand Down
4 changes: 2 additions & 2 deletions embedding/android/AndroidManifest.xml.in
@@ -1,7 +1,7 @@
#filter substitution
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.mozilla.@MOZ_APP_NAME@"
package="@ANDROID_PACKAGE_NAME@"
android:installLocation="auto"
android:versionCode="1"
android:versionName="@MOZ_APP_VERSION@"
Expand Down Expand Up @@ -76,7 +76,7 @@
<activity android:name="Restarter"
android:theme="@android:style/Theme.Light.NoTitleBar">
<intent-filter>
<action android:name="org.mozilla.gecko.restart@MOZ_APP_NAME@"
<action android:name="org.mozilla.gecko.restart"
android:process="@MOZ_APP_NAME@Restarter"/>
</intent-filter>
</activity>
Expand Down
6 changes: 3 additions & 3 deletions embedding/android/App.java.in
Expand Up @@ -36,13 +36,13 @@
* ***** END LICENSE BLOCK ***** */

#filter substitution
package org.mozilla.@MOZ_APP_NAME@;
package @ANDROID_PACKAGE_NAME@;

import org.mozilla.gecko.GeckoApp;

public class App extends GeckoApp {
public String getAppName() {
return "@MOZ_APP_NAME@";
public String getPackageName() {
return "@ANDROID_PACKAGE_NAME@";
}
public String getContentProcessName() {
return "@MOZ_CHILD_PROCESS_NAME@";
Expand Down
10 changes: 5 additions & 5 deletions embedding/android/CrashReporter.java.in
Expand Up @@ -36,7 +36,7 @@
* ***** END LICENSE BLOCK ***** */

#filter substitution
package org.mozilla.@MOZ_APP_NAME@;
package @ANDROID_PACKAGE_NAME@;


import android.app.*;
Expand Down Expand Up @@ -108,7 +108,7 @@ public class CrashReporter extends Activity
String passedMinidumpPath = getIntent().getStringExtra("minidumpPath");
File passedMinidumpFile = new File(passedMinidumpPath);
File pendingDir =
new File("/data/data/org.mozilla.@MOZ_APP_NAME@/mozilla/Crash Reports/pending");
new File("/data/data/@ANDROID_PACKAGE_NAME@/mozilla/Crash Reports/pending");
pendingDir.mkdirs();
mPendingMinidumpFile = new File(pendingDir, passedMinidumpFile.getName());
moveFile(passedMinidumpFile, mPendingMinidumpFile);
Expand Down Expand Up @@ -275,7 +275,7 @@ public class CrashReporter extends Activity

if (conn.getResponseCode() == conn.HTTP_OK) {
File submittedDir = new File(
"/data/data/org.mozilla.@MOZ_APP_NAME@/mozilla/Crash Reports/submitted");
"/data/data/@ANDROID_PACKAGE_NAME@/mozilla/Crash Reports/submitted");
submittedDir.mkdirs();
minidumpFile.delete();
extrasFile.delete();
Expand All @@ -298,8 +298,8 @@ public class CrashReporter extends Activity
try {
String action = "android.intent.action.MAIN";
Intent intent = new Intent(action);
intent.setClassName("org.mozilla.@MOZ_APP_NAME@",
"org.mozilla.@MOZ_APP_NAME@.App");
intent.setClassName("@ANDROID_PACKAGE_NAME@",
"@ANDROID_PACKAGE_NAME@.App");
Log.i("GeckoCrashReporter", intent.toString());
startActivity(intent);
} catch (Exception e) {
Expand Down
18 changes: 9 additions & 9 deletions embedding/android/GeckoApp.java
Expand Up @@ -409,7 +409,7 @@ public boolean onKeyLongPress(int keyCode, KeyEvent event) {
return false;
}

abstract public String getAppName();
abstract public String getPackageName();
abstract public String getContentProcessName();

protected void unpackComponents()
Expand All @@ -418,7 +418,7 @@ protected void unpackComponents()
ZipFile zip;
InputStream listStream;

File componentsDir = new File("/data/data/org.mozilla." + getAppName() +
File componentsDir = new File("/data/data/" + getPackageName() +
"/components");
componentsDir.mkdir();
zip = new ZipFile(getApplication().getPackageResourcePath());
Expand Down Expand Up @@ -451,7 +451,7 @@ private void unpackFile(ZipFile zip, byte[] buf, ZipEntry fileEntry,
throw new FileNotFoundException("Can't find " + name + " in " +
zip.getName());

File outFile = new File("/data/data/org.mozilla." + getAppName() +
File outFile = new File("/data/data/" + getPackageName() +
"/" + name);
if (outFile.exists() &&
outFile.lastModified() == fileEntry.getTime() &&
Expand Down Expand Up @@ -493,10 +493,10 @@ public void addEnvToIntent(Intent intent) {

public void doRestart() {
try {
String action = "org.mozilla.gecko.restart" + getAppName();
String action = "org.mozilla.gecko.restart";
Intent intent = new Intent(action);
intent.setClassName("org.mozilla." + getAppName(),
"org.mozilla." + getAppName() + ".Restarter");
intent.setClassName(getPackageName(),
getPackageName() + ".Restarter");
addEnvToIntent(intent);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
Expand Down Expand Up @@ -530,7 +530,7 @@ private void checkAndLaunchUpdate() {
Log.i("GeckoAppJava", "Update is available!");

// Launch APK
File updateFileToRun = new File(updateDir + getAppName() + "-update.apk");
File updateFileToRun = new File(updateDir + getPackageName() + "-update.apk");
try {
if (updateFile.renameTo(updateFileToRun)) {
String amCmd = "/system/bin/am start -a android.intent.action.VIEW " +
Expand Down Expand Up @@ -612,8 +612,8 @@ protected void onActivityResult(int requestCode, int resultCode,
File.createTempFile("tmp_" +
(int)Math.floor(1000 * Math.random()),
fileExt,
new File("/data/data/org.mozilla." +
getAppName()));
new File("/data/data/" +
getPackageName()));

FileOutputStream fos = new FileOutputStream(file);
InputStream is = cr.openInputStream(uri);
Expand Down
10 changes: 5 additions & 5 deletions embedding/android/GeckoAppShell.java
Expand Up @@ -109,8 +109,8 @@ public static void loadGeckoLibs(String apkName) {
Log.i("GeckoApp", "env"+ c +": "+ env);
}

File f = new File("/data/data/org.mozilla." +
GeckoApp.mAppContext.getAppName() +"/tmp");
File f = new File("/data/data/" +
GeckoApp.mAppContext.getPackageName() + "/tmp");
if (!f.exists())
f.mkdirs();

Expand Down Expand Up @@ -366,7 +366,7 @@ static void installWebApplication(String aURI, String aTitle, String aIconData)
// the intent to be launched by the shortcut
Intent shortcutIntent = new Intent("org.mozilla.fennec.WEBAPP");
shortcutIntent.setClassName(GeckoApp.mAppContext,
"org.mozilla." + GeckoApp.mAppContext.getAppName() + ".App");
GeckoApp.mAppContext.getPackageName() + ".App");
shortcutIntent.putExtra("args", "--webapp=" + aURI);

Intent intent = new Intent();
Expand Down Expand Up @@ -521,7 +521,7 @@ public static void showAlertNotification(String aImageUrl, String aAlertTitle, S
// The intent to launch when the user clicks the expanded notification
Intent notificationIntent = new Intent(GeckoApp.ACTION_ALERT_CLICK);
notificationIntent.setClassName(GeckoApp.mAppContext,
"org.mozilla." + GeckoApp.mAppContext.getAppName() + ".NotificationHandler");
GeckoApp.mAppContext.getPackageName() + ".NotificationHandler");

// Put the strings into the intent as an URI "alert:<name>#<cookie>"
Uri dataUri = Uri.fromParts("alert", aAlertName, aAlertCookie);
Expand All @@ -533,7 +533,7 @@ public static void showAlertNotification(String aImageUrl, String aAlertTitle, S
// The intent to execute when the status entry is deleted by the user with the "Clear All Notifications" button
Intent clearNotificationIntent = new Intent(GeckoApp.ACTION_ALERT_CLEAR);
clearNotificationIntent.setClassName(GeckoApp.mAppContext,
"org.mozilla." + GeckoApp.mAppContext.getAppName() + ".NotificationHandler");
GeckoApp.mAppContext.getPackageName() + ".NotificationHandler");
clearNotificationIntent.setData(dataUri);

PendingIntent pendingClearIntent = PendingIntent.getActivity(GeckoApp.mAppContext, 0, clearNotificationIntent, 0);
Expand Down
1 change: 1 addition & 0 deletions embedding/android/Makefile.in
Expand Up @@ -66,6 +66,7 @@ MIN_CPU_VERSION=5
endif

DEFINES += \
-DANDROID_PACKAGE_NAME=$(ANDROID_PACKAGE_NAME) \
-DMOZ_APP_DISPLAYNAME=$(MOZ_APP_DISPLAYNAME) \
-DMOZ_APP_NAME=$(MOZ_APP_NAME) \
-DMOZ_APP_VERSION=$(MOZ_APP_VERSION) \
Expand Down
2 changes: 1 addition & 1 deletion embedding/android/NotificationHandler.java.in
Expand Up @@ -36,7 +36,7 @@
* ***** END LICENSE BLOCK ***** */

#filter substitution
package org.mozilla.@MOZ_APP_NAME@;
package @ANDROID_PACKAGE_NAME@;

import android.app.Activity;
import android.app.NotificationManager;
Expand Down
4 changes: 2 additions & 2 deletions other-licenses/android/APKOpen.cpp
Expand Up @@ -439,7 +439,7 @@ static void * mozload(const char * path, void *zip,

if (extractLibs) {
char fullpath[256];
snprintf(fullpath, 256, "/data/data/org.mozilla.fennec/%s", path + 4);
snprintf(fullpath, 256, "/data/data/" ANDROID_PACKAGE_NAME "/%s", path + 4);
__android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "resolved %s to %s", path, fullpath);
extractFile(fullpath, entry, data);
handle = __wrap_dlopen(fullpath, RTLD_LAZY);
Expand Down Expand Up @@ -560,7 +560,7 @@ extern "C" void simple_linker_init(void);
static void
loadLibs(const char *apkName)
{
chdir("/data/data/org.mozilla.fennec");
chdir("/data/data/" ANDROID_PACKAGE_NAME);

simple_linker_init();

Expand Down
1 change: 1 addition & 0 deletions other-licenses/android/Makefile.in
Expand Up @@ -53,6 +53,7 @@ DEFINES += \
-DMOZ_LINKER \
-DLINKER_TEXT_BASE=0xB0001000 \
-DLINKER_AREA_SIZE=0x01000000 \
-DANDROID_PACKAGE_NAME='"$(ANDROID_PACKAGE_NAME)"' \
$(NULL)

CPPSRCS = \
Expand Down
1 change: 1 addition & 0 deletions toolkit/xre/Makefile.in
Expand Up @@ -135,6 +135,7 @@ endif

ifeq ($(OS_TARGET),Android)
CPPSRCS += nsAndroidStartup.cpp
DEFINES += -DANDROID_PACKAGE_NAME='"$(ANDROID_PACKAGE_NAME)"'
endif

SHARED_LIBRARY_LIBS += ../profile/src/$(LIB_PREFIX)profile_s.$(LIB_SUFFIX)
Expand Down
6 changes: 3 additions & 3 deletions toolkit/xre/nsAndroidStartup.cpp
Expand Up @@ -94,7 +94,7 @@ GeckoStart(void *data)

nsresult rv;
nsCOMPtr<nsILocalFile> appini;
rv = NS_NewLocalFile(NS_LITERAL_STRING("/data/data/org.mozilla." MOZ_APP_NAME "/application.ini"),
rv = NS_NewLocalFile(NS_LITERAL_STRING("/data/data/" ANDROID_PACKAGE_NAME "/application.ini"),
PR_FALSE,
getter_AddRefs(appini));
if (NS_FAILED(rv)) {
Expand All @@ -105,12 +105,12 @@ GeckoStart(void *data)
nsXREAppData *appData;
rv = XRE_CreateAppData(appini, &appData);
if (NS_FAILED(rv)) {
LOG("Failed to load application.ini from /data/data/org.mozilla." MOZ_APP_NAME "/application.ini\n");
LOG("Failed to load application.ini from /data/data/" ANDROID_PACKAGE_NAME "/application.ini\n");
return 0;
}

nsCOMPtr<nsILocalFile> xreDir;
rv = NS_NewLocalFile(NS_LITERAL_STRING("/data/data/org.mozilla." MOZ_APP_NAME),
rv = NS_NewLocalFile(NS_LITERAL_STRING("/data/data/" ANDROID_PACKAGE_NAME),
PR_FALSE,
getter_AddRefs(xreDir));
if (NS_FAILED(rv)) {
Expand Down
2 changes: 1 addition & 1 deletion toolkit/xre/nsXREDirProvider.cpp
Expand Up @@ -1104,7 +1104,7 @@ nsXREDirProvider::GetUserDataDirectoryHome(nsILocalFile** aFile, PRBool aLocal)
#elif defined(ANDROID)
// used for setting the patch to our profile
// XXX: investigate putting the profile somewhere else
const char* homeDir = "/data/data/org.mozilla." MOZ_APP_NAME;
const char* homeDir = "/data/data/" ANDROID_PACKAGE_NAME;

rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), PR_TRUE,
getter_AddRefs(localDir));
Expand Down

0 comments on commit 1de8b50

Please sign in to comment.