Merge "Dont include code size for apps on sdcard. Use constants defined in PackageHelper for user preferences to install auto, internal, external. Set default install location to external. Update settings db version number"
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c
index c8d1397..654ee68 100644
--- a/cmds/installd/commands.c
+++ b/cmds/installd/commands.c
@@ -404,6 +404,15 @@
}
}
+ /* count the source apk as code -- but only if it's not
+ * installed on the sdcard
+ */
+ if (strncmp(apkpath, SDCARD_DIR_PREFIX, 7) != 0) {
+ if (stat(apkpath, &s) == 0) {
+ codesize += stat_size(&s);
+ }
+ }
+
/* count the cached dexfile as code */
if (!create_cache_path(path, apkpath)) {
diff --git a/core/java/com/android/internal/content/PackageHelper.java b/core/java/com/android/internal/content/PackageHelper.java
index de6a175..80efca4 100644
--- a/core/java/com/android/internal/content/PackageHelper.java
+++ b/core/java/com/android/internal/content/PackageHelper.java
@@ -40,6 +40,10 @@
public static final int RECOMMEND_FAILED_ALREADY_EXISTS = -4;
private static final boolean localLOGV = true;
private static final String TAG = "PackageHelper";
+ // App installation location settings values
+ public static final int APP_INSTALL_AUTO = 0;
+ public static final int APP_INSTALL_INTERNAL = 1;
+ public static final int APP_INSTALL_EXTERNAL = 2;
public static IMountService getMountService() {
IBinder service = ServiceManager.getService("mount");
diff --git a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
index 4635f48..7714911 100644
--- a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
+++ b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
@@ -349,11 +349,11 @@
int installPreference = Settings.System.getInt(getApplicationContext()
.getContentResolver(),
Settings.System.DEFAULT_INSTALL_LOCATION,
- PackageInfo.INSTALL_LOCATION_AUTO);
- if (installPreference == 1) {
+ PackageHelper.APP_INSTALL_AUTO);
+ if (installPreference == PackageHelper.APP_INSTALL_INTERNAL) {
installOnlyInternal = true;
auto = false;
- } else if (installPreference == 2) {
+ } else if (installPreference == PackageHelper.APP_INSTALL_EXTERNAL) {
installOnlyOnSd = true;
auto = false;
}
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index 64bb0ef..34302c4 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -56,7 +56,10 @@
<bool name="def_mount_ums_autostart">false</bool>
<bool name="def_mount_ums_prompt">true</bool>
<bool name="def_mount_ums_notify_enabled">true</bool>
+ <!-- Enable User preference for setting install location -->
<bool name="set_install_location">true</bool>
+ <!-- Default install location if user preference for setting install location is turned on. -->
+ <integer name="def_install_location">2</integer>
<!-- user interface sound effects -->
<integer name="def_power_sounds_enabled">1</integer>
@@ -72,5 +75,4 @@
<!-- Default for Settings.System.VIBRATE_IN_SILENT -->
<bool name="def_vibrate_in_silent">true</bool>
-
</resources>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index edf3923..ba66dc5 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -61,7 +61,7 @@
// database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
// is properly propagated through your change. Not doing so will result in a loss of user
// settings.
- private static final int DATABASE_VERSION = 53;
+ private static final int DATABASE_VERSION = 54;
private Context mContext;
@@ -650,6 +650,25 @@
upgradeVersion = 53;
}
+
+ if (upgradeVersion == 53) {
+ /*
+ * New settings for set install location UI.
+ */
+ db.beginTransaction();
+ try {
+ SQLiteStatement stmt = db.compileStatement("INSERT INTO system(name,value)"
+ + " VALUES(?,?);");
+ loadIntegerSetting(stmt, Settings.System.DEFAULT_INSTALL_LOCATION,
+ R.integer.def_install_location);
+ stmt.close();
+ db.setTransactionSuccessful();
+ } finally {
+ db.endTransaction();
+ }
+
+ upgradeVersion = 54;
+ }
// *** Remember to update DATABASE_VERSION above!
@@ -943,9 +962,10 @@
loadBooleanSetting(stmt, Settings.System.NOTIFICATION_LIGHT_PULSE,
R.bool.def_notification_pulse);
- loadBooleanSetting(stmt, Settings.System.SET_INSTALL_LOCATION, R.bool.set_install_location);
- loadSetting(stmt, Settings.System.DEFAULT_INSTALL_LOCATION,
- PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
+ loadBooleanSetting(stmt, Settings.System.SET_INSTALL_LOCATION,
+ R.bool.set_install_location);
+ loadIntegerSetting(stmt, Settings.System.DEFAULT_INSTALL_LOCATION,
+ R.integer.def_install_location);
loadUISoundEffectsSettings(stmt);
diff --git a/tests/AndroidTests/src/com/android/unit_tests/PackageManagerTests.java b/tests/AndroidTests/src/com/android/unit_tests/PackageManagerTests.java
index d4435d3..8c8b00c 100755
--- a/tests/AndroidTests/src/com/android/unit_tests/PackageManagerTests.java
+++ b/tests/AndroidTests/src/com/android/unit_tests/PackageManagerTests.java
@@ -16,6 +16,8 @@
package com.android.unit_tests;
+import com.android.internal.content.PackageHelper;
+
import android.os.storage.IMountService.Stub;
import android.net.Uri;
@@ -73,9 +75,9 @@
public final long MAX_WAIT_TIME=120*1000;
public final long WAIT_TIME_INCR=20*1000;
private static final String SECURE_CONTAINERS_PREFIX = "/mnt/asec";
- private static final int APP_INSTALL_AUTO = 0;
- private static final int APP_INSTALL_DEVICE = 1;
- private static final int APP_INSTALL_SDCARD = 2;
+ private static final int APP_INSTALL_AUTO = PackageHelper.APP_INSTALL_AUTO;
+ private static final int APP_INSTALL_DEVICE = PackageHelper.APP_INSTALL_INTERNAL;
+ private static final int APP_INSTALL_SDCARD = PackageHelper.APP_INSTALL_EXTERNAL;
void failStr(String errMsg) {
Log.w(TAG, "errMsg="+errMsg);