[G1 Android Development] Firerat:
lol, I know I said I was just going to ignore you, but I just had to point out that it is you that does not have a good grasp of English.

on the sharing side, I have given the below diff to a few key people

you can't even grasp basics, so I doubt you

know what it is

will be able to use it

diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c
index 8d571dc..d644f94 100644
--- a/cmds/installd/commands.c
+++ b/cmds/installd/commands.c
@@ -181,15 +181,18 @@ static int is_valid_apk_path(const char *path)
{
int len = strlen(APK_DIR_PREFIX);
int nosubdircheck = 0;
- if (strncmp(path, APK_DIR_PREFIX, len)) {
- len = strlen(PROTECTED_DIR_PREFIX);
- if (strncmp(path, PROTECTED_DIR_PREFIX, len)) {
- len = strlen(SDCARD_DIR_PREFIX);
- if (strncmp(path, SDCARD_DIR_PREFIX, len)) {
- LOGE("invalid apk path '%s' (bad prefix)\n", path);
- return 0;
- } else {
- nosubdircheck = 1;
+ if (strncmp(path, APK_EXT_DIR_PREFIX, len)) {
+ len = strlen(APK_DIR_PREFIX);
+ if (strncmp(path, APK_DIR_PREFIX, len)) {
+ len = strlen(PROTECTED_DIR_PREFIX);
+ if (strncmp(path, PROTECTED_DIR_PREFIX, len)) {
+ len = strlen(SDCARD_DIR_PREFIX);
+ if (strncmp(path, SDCARD_DIR_PREFIX, len)) {
+ LOGE("invalid apk path '%s' (bad prefix)\n", path);
+ return 0;
+ } else {
+ nosubdircheck = 1;
+ }
}
}
}
@@ -425,6 +428,10 @@ int create_cache_path(char path[PKG_PATH_MAX], const char *src)
cache_path = DALVIK_SYSTEM_CACHE_PREFIX;
}
}
+
+ if (!strncmp(src, "/sd-ext", 7)) {
+ cache_path = DALVIK_SDEXT_CACHE_PREFIX;
+ }

dstlen = srclen + strlen(cache_path) +
strlen(DALVIK_CACHE_POSTFIX) + 1;
diff --git a/cmds/installd/installd.h b/cmds/installd/installd.h
index fc63b9f..5f94f0b 100644
--- a/cmds/installd/installd.h
+++ b/cmds/installd/installd.h
@@ -57,14 +57,17 @@
#define CACHE_DIR_POSTFIX "/cache"

#define APK_DIR_PREFIX "/data/app/"
+#define APK_EXT_DIR_PREFIX "/sd-ext/app/"

/* other handy constants */

#define PROTECTED_DIR_PREFIX "/data/app-private/"
+#define PROTECTED_EXT_DIR_PREFIX "/sd-ext/app-private/"
#define SDCARD_DIR_PREFIX getenv("ASEC_MOUNTPOINT")

#define DALVIK_CACHE_PREFIX "/data/dalvik-cache/"
#define DALVIK_SYSTEM_CACHE_PREFIX "/cache/dalvik-cache/"
+#define DALVIK_SDEXT_CACHE_PREFIX "/sd-ext/dalvik-cache/"
#define DALVIK_CACHE_POSTFIX "/classes.dex"

#define UPDATE_COMMANDS_DIR_PREFIX "/system/etc/updatecmds/"
diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java
index 812391c..813fb65 100644
--- a/core/java/android/os/Environment.java
+++ b/core/java/android/os/Environment.java
@@ -40,6 +40,9 @@ public class Environment {
private static final File DATA_DIRECTORY
= getDirectory("ANDROID_DATA", "/data");

+ private static final File SD_EXT_DIRECTORY
+ = getDirectory("SD_EXT_DIRECTORY", "/sd-ext");
+
private static final File EXTERNAL_STORAGE_DIRECTORY
= getDirectory("EXTERNAL_STORAGE", "/sdcard");

@@ -62,6 +65,15 @@ public class Environment {
}

/**
+ * Gets the SD EXT directory.
+ * @hide
+ */
+
+ public static File getSdExtDirectory() {
+ return SD_EXT_DIRECTORY;
+ }
+
+ /**
* Gets the Android external storage directory. This directory may not
* currently be accessible if it has been mounted by the user on their
* computer, has been removed from the device, or some other problem has
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android
index 774c337..0d09f2f 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -213,9 +213,15 @@ class PackageManagerService extends IPackageManager.Stub {
// This is the object monitoring mAppInstallDir.
final FileObserver mAppInstallObserver;

+ // This is the object monitoring mSdExtInstallDir.
+ final FileObserver mSdExtInstallObserver;
+
// This is the object monitoring mDrmAppPrivateInstallDir.
final FileObserver mDrmAppInstallObserver;

+ // This is the object monitoring mDrmSdExtPrivateInstallDir.
+ final FileObserver mDrmSdExtInstallObserver;
+
// Used for priviledge escalation. MUST NOT BE CALLED WITH mPackages
// LOCK HELD. Can be called with mInstallLock held.
final Installer mInstaller;
@@ -223,11 +229,17 @@ class PackageManagerService extends IPackageManager.Stub {
final File mFrameworkDir;
final File mSystemAppDir;
final File mAppInstallDir;
+ final File mSdExtInstallDir;
final File mDalvikCacheDir;
+ final File mSdExtDalvikCacheDir;
+
+ // Whether or not we are installing on the EXT partition.
+ boolean mExtInstall;

// Directory containing the private parts (e.g. code and non-resource assets) of forward-locked
// apps.
final File mDrmAppPrivateInstallDir;
+ final File mDrmSdExtPrivateInstallDir;

// ----------------------------------------------------------------

@@ -767,8 +779,11 @@ class PackageManagerService extends IPackageManager.Stub {
mHandler = new PackageHandler(mHandlerThread.getLooper());

File dataDir = Environment.getDataDirectory();
+ File sdExtDir = Environment.getSdExtDirectory();
mAppDataDir = new File(dataDir, "data");
+ mSdExtInstallDir = new File(sdExtDir, "app");
mDrmAppPrivateInstallDir = new File(dataDir, "app-private");
+ mDrmSdExtPrivateInstallDir = new File(sdExtDir, "app-private");

if (mInstaller == null) {
// Make sure these dirs exist, when we are running in
@@ -778,6 +793,8 @@ class PackageManagerService extends IPackageManager.Stub {
miscDir.mkdirs();
mAppDataDir.mkdirs();
mDrmAppPrivateInstallDir.mkdirs();
+ mSdExtInstallDir.mkdirs();
+ mDrmSdExtPrivateInstallDir.mkdirs();
}

readPermissions();
@@ -800,6 +817,7 @@ class PackageManagerService extends IPackageManager.Stub {

mFrameworkDir = new File(Environment.getRootDirectory(), "framework");
mDalvikCacheDir = new File(dataDir, "dalvik-cache");
+ mSdExtDalvikCacheDir = new File(sdExtDir, "dalvik-cache");

if (mInstaller != null) {
boolean didDexOpt = false;
@@ -901,6 +919,19 @@ class PackageManagerService extends IPackageManager.Stub {
}
}
}
+ if (isA2SDActive()) {
+ files = mSdExtDalvikCacheDir.list();
+ if (files != null) {
+ for (int i=0; i<files.length; i++) {
+ String fn = files[i];
+ if (fn.startsWith("sd-ext@app@")
+ || fn.startsWith("sd-ext@app-private@")) {
+ Log.i(TAG, "Pruning dalvik file: " + fn);
+ (new File(mSdExtDalvikCacheDir, fn)).delete();
+ }
+ }
+ }
+ }
}
}

@@ -965,11 +996,21 @@ class PackageManagerService extends IPackageManager.Stub {
scanDirLI(mAppInstallDir, 0, scanMode);
mAppInstallObserver.startWatching();

+ mSdExtInstallObserver = new AppDirObserver(
+ mSdExtInstallDir.getPath(), OBSERVER_EVENTS, false);
+ mSdExtInstallObserver.startWatching();
+ scanDirLI(mSdExtInstallDir, 0, scanMode);
+
mDrmAppInstallObserver = new AppDirObserver(
mDrmAppPrivateInstallDir.getPath(), OBSERVER_EVENTS, false);
scanDirLI(mDrmAppPrivateInstallDir, PackageParser.PARSE_FORWARD_LOCK, scanMode);
mDrmAppInstallObserver.startWatching();

+ mDrmSdExtInstallObserver = new AppDirObserver(
+ mDrmSdExtPrivateInstallDir.getPath(), OBSERVER_EVENTS, false);
+ scanDirLI(mDrmSdExtPrivateInstallDir, PackageParser.PARSE_FORWARD_LOCK, scanMode);
+ mDrmSdExtInstallObserver.startWatching();
+
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_SCAN_END,
SystemClock.uptimeMillis());
Slog.i(TAG, "Time to scan packages: "
@@ -4713,6 +4754,11 @@ class PackageManagerService extends IPackageManager.Stub {
installPackage(packageURI, observer, flags, null);
}

+ private boolean isA2SDActive() {
+ return SystemProperties.getBoolean("cm.a2sd.active", false) ||
+ SystemProperties.getBoolean("cm.a2sd.force", false) ;
+ }
+
/* Called when a downloaded package installation has been confirmed by the user */
public void installPackage(
final Uri packageURI, final IPackageInstallObserver observer, final int flags,