Bug 852246 - Allow installing over an app with >= version in Android 4.2 via the agent;r=jmaher
☠☠ backed out by 7c8f36acc3a3 ☠ ☠
authorWilliam Lachance <wlachance@mozilla.com>
Tue, 19 Mar 2013 11:01:36 -0400
changeset 131848 9e6e38d4ae0bb948df7c8d837e10bbaab15f6d2a
parent 131847 121c90c4ebe429a3941983c589ea11581040fb64
child 131849 e862dc419d9b80d162d3aac09903b9078f227c35
push idunknown
push userunknown
push dateunknown
reviewersjmaher
bugs852246
milestone22.0a1
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,25 @@ 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 >= android.os.Build.VERSION_CODES.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) {