Bug 852246 - Allow installing over an app with >= version in Android 4.2 via the agent;r=jmaher
authorWilliam Lachance <wlachance@mozilla.com>
Tue, 19 Mar 2013 11:58:53 -0400
changeset 125430 6cae06155037ee729e3c53ad3bd2c43fca4a042b
parent 125429 b7c5623df2283f89b799e24a3933f6e6164c7556
child 125431 c079f741c3d0af80d97b5817ccb0de6eab0f9b6a
push id24454
push userryanvm@gmail.com
push dateTue, 19 Mar 2013 20:40:08 +0000
treeherdermozilla-central@453ccf5b5d29 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs852246
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 852246 - Allow installing over an app with >= version in Android 4.2 via the agent;r=jmaher
build/mobile/sutagent/android/DoCommand.java
--- a/build/mobile/sutagent/android/DoCommand.java
+++ b/build/mobile/sutagent/android/DoCommand.java
@@ -3312,17 +3312,26 @@ private void CancelNotification()
 
     public String InstallApp(String sApp, OutputStream out)
         {
         String sRet = "";
         File    srcFile = new File(sApp);
 
         try
             {
-            pProc = Runtime.getRuntime().exec(this.getSuArgs("pm install -r " + sApp + " Cleanup;exit"));
+            // on android 4.2 and above, we want to pass the "-d" argument to pm so that version
+            // downgrades are allowed... (option unsupported in earlier versions)
+            String sPmCmd;
+
+            if (android.os.Build.VERSION.SDK_INT >= 17) { // JELLY_BEAN_MR1
+                sPmCmd = "pm install -r -d " + sApp + " Cleanup;exit";
+            } else {
+                sPmCmd = "pm install -r " + sApp + " Cleanup;exit";
+            }
+            pProc = Runtime.getRuntime().exec(this.getSuArgs(sPmCmd));
             RedirOutputThread outThrd3 = new RedirOutputThread(pProc, out);
             outThrd3.start();
             try {
                 outThrd3.joinAndStopRedirect(60000);
                 int nRet3 = pProc.exitValue();
                 sRet = "\ninstallation complete [" + nRet3 + "]";
                 }
             catch (IllegalThreadStateException itse) {