MISC: modify the time when do you get root privilage
authorJaeMin Kim <jm.jemin.kim@samsung.com>
Mon, 17 Oct 2016 09:05:40 +0000 (18:05 +0900)
committerJaeMin Kim <jm.jemin.kim@samsung.com>
Thu, 20 Oct 2016 03:25:10 +0000 (12:25 +0900)
privious root policy
1. To install package
2. To launch app
3. To load platform plugin
4. To open Package Manager
5. To run zypper

now
1. To install package .
2. To open Package Manager

Change-Id: I882d1004cabb7dd270747e2975aa332bd5d4d6d0
Signed-off-by: JaeMin Kim <jm.jemin.kim@samsung.com>
org.tizen.nativeplatform.launcher/bin/org/tizen/nativeplatform/launcher/message/PlatformLaunchMessages.properties [deleted file]
org.tizen.nativeplatform.launcher/src/org/tizen/nativeplatform/launcher/message/PlatformLaunchMessages.java
org.tizen.nativeplatform.launcher/src/org/tizen/nativeplatform/launcher/message/PlatformLaunchMessages.properties
org.tizen.nativeplatform.launcher/src/org/tizen/nativeplatform/launcher/rpm/RpmPackageLauncher.java
org.tizen.nativeplatform.launcher/src/org/tizen/nativeplatform/launcher/ui/shortcut/PlatformProjectCommonLaunchShortcut.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/Activator.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/DeviceChangeListener.java [deleted file]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RPMPackageDialog.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformLaunchUtil.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/UIMessages.properties

diff --git a/org.tizen.nativeplatform.launcher/bin/org/tizen/nativeplatform/launcher/message/PlatformLaunchMessages.properties b/org.tizen.nativeplatform.launcher/bin/org/tizen/nativeplatform/launcher/message/PlatformLaunchMessages.properties
deleted file mode 100644 (file)
index a3fade2..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-CANNOT_FIND_PROJECT_NAME = Project name not found.
-CANNOT_CONNECT_TO_DEVICE = Device connection failed.
-CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP = Binary file not found in the host rootstrap.
-CANNOT_CREATE_PACKAGE = Package creation failed.
-CANNOT_TRANSFER_FILE = File transfer failed.
-CANNOT_INSTALL = Project installation failed.
-CANNOT_LAUNCH = Project launch failed.
-CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER = Project launch with GDBServer failed.
-CANNOT_LAUNCH_APPLICATION_WITH_GDBCLIENT = Project launch with GDBClient failed.
-BUILD_CONFIGURATION_DOES_NOT_MATCH_WITH_CURRENT_DEVICE_TYPE = Build configuration does not match the current device type. Select the correct device or build configuration.
-CANNOT_FIND_HOST_ROOTSTRAP_PATH = Host rootstrap path not found.
-CANNOT_FIND_DEBIAN_CONTROL_FILE = Debian control file not found.
-CANNOT_FIND_PACKAGE_SECTION_IN_CONTROL_FILE = Package section not found in the control file.
-OPERATION_CANCELED = Operation canceled.
-IS_NOT_INITIALIZED_ROOTSTRAP = Rootstrap is not initialized. [%s]
-DEVICE_IS_NOT_ROOT_ON = Device is not root on
-FAILED_CHECK_FILE_CHECKSUM = Failed to check file checksum
-FAILED_CACHE_PACKAGE_CHECKSUM = Failed to cache package checksum
-
-UPDATE_PKG_INFOS = Updating package information...
-LAUNCH_APPLICATION = Launching the application...
-LAUNCH_APPLICATION_WITH_GDBSERVER = Launching the application with GDBServer...
-LAUNCH_APPLICATION_WITH_GDBCLIENT = Launching the application with GDBClient...
-PREPARE_TO_LAUNCH = Preparing to launch...
-START_DEPLOY_PROCESS = Starting the deployment process...
-CREATE_PACKAGE = Creating the package...
-TRANSFER_PACKAGE = Transferring the package...
-INSTALL_PACKAGE = Installing the package...
-INSTALL_PACKAGES_TO_BUILDSYSTEM = Installing packages to buildsystem  
-INSTALL_PACKAGES_TO_DEVICE = Installing packages to device
-CHECK_PKG_STATUS = Checking package status
-CANCELED_LAUNCH = Canceled launching
-QUESTION_PACKAGING = "%s" project does not have package files(*.rpm)\nDo you want packaging now ?\n
-QUESTION_CONTINUE = Do you want to continue ?
-FAILED_INSTALL_PKGS = Failed to install packages.
-FAILED_INSTALL_PKGS_DEVICE = Failed to install packages to device.
-FAILED_INSTALL_PKGS_ROOTSTRAP = Failed to install packages to rootstrap.
-
-FAILED_SET_COREDUMP = Failed to set coredump archive.
-FAILED_COPY_COREDUMP = Failed to copy coredump file: %s
-FAILED_DOWNLOAD_COREDUMP = Failed to download coredump archive.
-FAILED_EXTRACT_COREDUMP = Failed to extract coredump archive.
-CANNOT_FIND_COREDUMP = Coredump file is not found.
-ROOTSTRAP_NOT_INITED = The rootstrap is not initialized.
-CANNOT_FIND_ROOTSTRAP = Rootstrap is not found: %s
-FAILED_KILL_GDBSERVER = Failed to kill gdbserver
-FAILED_REMOVE_FORWARD = Failed to remove port forwarding %s %d
\ No newline at end of file
index 87407d8..a71c9e2 100644 (file)
@@ -4,10 +4,12 @@
  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>  
+ * JaeMin Kim <jm.jemin.kim@samsung.com>
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
  * Kangho Kim <kh5325.kim@samsung.com>
- * 
+ * Sangho Park <sangho.p@samsung.com>
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -50,6 +52,7 @@ public class PlatformLaunchMessages extends NLS {
     public static String OPERATION_CANCELED;
     public static String IS_NOT_INITIALIZED_ROOTSTRAP;
     public static String DEVICE_IS_NOT_ROOT_ON;
+    public static String DEVICE_IS_NOT_ROOT_OFF;
     public static String FAILED_INSTALL_PKGS;
     public static String FAILED_INSTALL_PKGS_DEVICE;
     public static String FAILED_INSTALL_PKGS_ROOTSTRAP;
index a3fade2..6bdaaa6 100644 (file)
@@ -13,7 +13,8 @@ CANNOT_FIND_DEBIAN_CONTROL_FILE = Debian control file not found.
 CANNOT_FIND_PACKAGE_SECTION_IN_CONTROL_FILE = Package section not found in the control file.
 OPERATION_CANCELED = Operation canceled.
 IS_NOT_INITIALIZED_ROOTSTRAP = Rootstrap is not initialized. [%s]
-DEVICE_IS_NOT_ROOT_ON = Device is not root on
+DEVICE_IS_NOT_ROOT_ON = Failed to get root privilege\n Install command must be run as root\n Please check whether it's being run as root or not
+DEVICE_IS_NOT_ROOT_OFF = Failed to get original privilege back
 FAILED_CHECK_FILE_CHECKSUM = Failed to check file checksum
 FAILED_CACHE_PACKAGE_CHECKSUM = Failed to cache package checksum
 
index 11786e8..6690ed3 100644 (file)
@@ -5,9 +5,10 @@
  *
  * Contact:
  * Jaemin Kim <jm.jaemin.kim@samsung.com>
- * Donghyuk Yang <donghyuk.yang@samsung.com>  
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ * Sangho Park <sangho.p@samsung.com>
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -66,6 +67,7 @@ import org.tizen.nativeplatform.util.IPackageUtil;
 import org.tizen.nativeplatform.util.LRCaching;
 import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 import org.tizen.nativeplatform.util.PlatformUserInteraction;
+import org.tizen.sdblib.IDevice;
 import org.tizen.sdblib.util.DeviceUtil;
 
 public class RpmPackageLauncher implements IPkgLauncher {
@@ -172,7 +174,7 @@ public class RpmPackageLauncher implements IPkgLauncher {
         List<IPackage> selectBsPkgs = getSelectedPackages(buildSystemPkgStatus);
         List<IPackage> selectDvPkgs = getSelectedPackages(devicePkgStatus);
 
-               // FIXME: Disable RDS forcibly
+        // FIXME: Disable RDS forcibly
         //boolean bsAvailableRds = checkAvaiableRds(project, buildSystemPkgStatus);
         boolean bsAvailableRds = false;
         //boolean dvAvailableRds = checkAvaiableRds(project, devicePkgStatus);
@@ -206,38 +208,38 @@ public class RpmPackageLauncher implements IPkgLauncher {
         boolean installResult = false;
 
         // wait for all load thread finished
-        for (Thread t1 : installThread) {            
+        for (Thread t1 : installThread) {
             t1.join();
             if (t1 instanceof DeviceInstallThread) {
-               installResult = ((DeviceInstallThread) t1).isInstallResult() ? true : false;
-               if (!installResult) {
-                       InterruptedException ex = ((DeviceInstallThread) t1).getException();
-                       if (ex != null) {
-                               throw ((DeviceInstallThread) t1).getException();
-                       } else {
-                               throw new InterruptedException(PlatformLaunchMessages.FAILED_INSTALL_PKGS_DEVICE);
-                       }
-               }
+                installResult = ((DeviceInstallThread) t1).isInstallResult() ? true : false;
+                if (!installResult) {
+                    InterruptedException ex = ((DeviceInstallThread) t1).getException();
+                    if (ex != null) {
+                        throw ((DeviceInstallThread) t1).getException();
+                    } else {
+                        throw new InterruptedException(PlatformLaunchMessages.FAILED_INSTALL_PKGS_DEVICE);
+                    }
+                }
             }
             if (t1 instanceof RootstrapInstallThread) {
-               installResult = ((RootstrapInstallThread) t1).isInstallResult() ? true : false;
-               if (!installResult) {
-                       InterruptedException ex = ((RootstrapInstallThread) t1).getException();
-                       if (ex != null) {
-                               throw ((RootstrapInstallThread) t1).getException();
-                       } else {
-                               throw new InterruptedException(PlatformLaunchMessages.FAILED_INSTALL_PKGS_ROOTSTRAP);
-                       }
-               }
-            }           
+                installResult = ((RootstrapInstallThread) t1).isInstallResult() ? true : false;
+                if (!installResult) {
+                    InterruptedException ex = ((RootstrapInstallThread) t1).getException();
+                    if (ex != null) {
+                        throw ((RootstrapInstallThread) t1).getException();
+                    } else {
+                        throw new InterruptedException(PlatformLaunchMessages.FAILED_INSTALL_PKGS_ROOTSTRAP);
+                    }
+                }
+            }
             if (monitor != null) {
                 monitor.worked(1);
-            }            
+            }
         }
-        
+
         // cache packages after a successful work
         // selectDvPkgs is the set of selectBsPkgs; selectBsPkgs include
-        
+
         if (installResult && !LRCaching.getWorkingCaching().isEmpty()) {
             if (selectBsPkgs != null && !selectBsPkgs.isEmpty()) {
                 LRCaching.copyWorkingtoStaging(selectBsPkgs);
@@ -328,40 +330,49 @@ public class RpmPackageLauncher implements IPkgLauncher {
 
     protected boolean installPkgsToDevice(List<IPackage> packages, boolean isEfl,
             IProgressMonitor monitor, boolean useRds) throws InterruptedException {
-        if (!DeviceUtil.isOnline(target.getDevice())) {
-            newInterruptedException(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE);
-        } else if (!PlatformLaunchUtil.checkDeviceRootOn(target.getDevice())) {
-            newInterruptedException(PlatformLaunchMessages.DEVICE_IS_NOT_ROOT_ON);
-        } else {
-            // Refreshing repository is needed?
-        }
-        IPkgCommander commander = target.getCommander(CmdTargetTypes.DEVICE);
-        boolean installResult = false;
-        if (useRds) {
-            installResult = internalProcessRDS(commander, packages, true, monitor);
-            // if RDS is failed, install packages normally
-            if (!installResult) {
+        IDevice device = target.getDevice();
+        boolean rootStatus = device.isRoot();
+        try {
+            if (!DeviceUtil.isOnline(device)) {
+                newInterruptedException(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE);
+            } else if (!PlatformLaunchUtil.checkAndSetDeviceRootOn(device)) {
+                newInterruptedException(PlatformLaunchMessages.DEVICE_IS_NOT_ROOT_ON);
+            } else {
+                // Refreshing repository is needed?
+            }
+            IPkgCommander commander = target.getCommander(CmdTargetTypes.DEVICE);
+            boolean installResult = false;
+            if (useRds) {
+                installResult = internalProcessRDS(commander, packages, true, monitor);
+                // if RDS is failed, install packages normally
+                if (!installResult) {
+                    installResult = internalInstallPkgsToDevice(commander, packages, monitor);
+                }
+            } else {
                 installResult = internalInstallPkgsToDevice(commander, packages, monitor);
             }
-        } else {
-            installResult = internalInstallPkgsToDevice(commander, packages, monitor);
+            deviceLog = commander.getLogs();
+            return installResult;
+        } finally {
+            if(!rootStatus){
+                if (!PlatformLaunchUtil.checkAndSetDeviceRootOff(target.getDevice())) {
+                    newInterruptedException(PlatformLaunchMessages.DEVICE_IS_NOT_ROOT_OFF);
+                }
+            }
         }
-
-        deviceLog = commander.getLogs();
-        return installResult;
     }
-    
+
     protected boolean internalInstallPkgsToDevice(IPkgCommander commander, List<IPackage> packages, IProgressMonitor monitor)
-               throws InterruptedException {
-       List<String> paths = new ArrayList<String>();
-       StringBuffer sbLog = new StringBuffer();
-       
+            throws InterruptedException {
+        List<String> paths = new ArrayList<String>();
+        StringBuffer sbLog = new StringBuffer();
+
         boolean useSDB = DevicePreferencesManager.isTransferToolSDB();
         if (useSDB) {
-               IConfiguration config = PlatformConfigurationManager.getDefaultConfiguration(project);
+            IConfiguration config = PlatformConfigurationManager.getDefaultConfiguration(project);
             IPath configPath = project.getLocation().append(config.getName());
             for (IPackage p : packages) {
-               String tool = p.getTool();
+                String tool = p.getTool();
                 String filePath = p.getPath();
                 String filename = FileUtil.getFileNameFromPath(filePath);
                 String targetPath = configPath.append(filename).toOSString();
@@ -374,7 +385,7 @@ public class RpmPackageLauncher implements IPkgLauncher {
                 if (!status.isOk()) {
                     newInterruptedException(status.getMessage());
                 }
-                
+
                 List<String> value = status.getValues();
                 if (value != null && !value.isEmpty()) {
                     for (String s : value) {
@@ -383,8 +394,8 @@ public class RpmPackageLauncher implements IPkgLauncher {
                 }
             }
         } else {
-               for (IPackage p : packages) {
-                       String tool = p.getTool();
+            for (IPackage p : packages) {
+                String tool = p.getTool();
                 String filePath = p.getPath();
                 paths.add(filePath.trim());
                 ICommandStatus status = commander.installLocalPkg(filePath.trim(), tool,
@@ -396,28 +407,28 @@ public class RpmPackageLauncher implements IPkgLauncher {
                 if (!status.isOk()) {
                     newInterruptedException(status.getMessage());
                 }
-                
+
                 List<String> value = status.getValues();
                 if (value != null && !value.isEmpty()) {
                     for (String s : value) {
                         sbLog.append(s + newline());
                     }
                 }
-                   
+
             }
         }
-        
-        return true;        
+
+        return true;
     }
 
     protected boolean installPkgs(IPkgCommander commander, List<IPackage> packages, boolean isEfl,
             IProgressMonitor monitor) throws InterruptedException {
 
         List<String> paths = new ArrayList<String>();
-        
+
         boolean useSDB = DevicePreferencesManager.isTransferToolSDB();
         if (useSDB && commander.getCommandType().equals(CmdTargetTypes.DEVICE)) {
-               IConfiguration config = PlatformConfigurationManager.getDefaultConfiguration(project);
+            IConfiguration config = PlatformConfigurationManager.getDefaultConfiguration(project);
             IPath configPath = project.getLocation().append(config.getName());
             for (IPackage p : packages) {
                 String filePath = p.getPath();
@@ -426,12 +437,12 @@ public class RpmPackageLauncher implements IPkgLauncher {
                 paths.add(targetPath.trim());
             }
         } else {
-               for (IPackage p : packages) {
+            for (IPackage p : packages) {
                 String filePath = p.getPath();
                 paths.add(filePath.trim());
             }
         }
-        
+
         ICommandStatus status = commander.installLocalPkg(paths.toArray(new String[0]), isEfl,
                 monitor);
 
@@ -458,7 +469,6 @@ public class RpmPackageLauncher implements IPkgLauncher {
                 failedInstallPkgs = failedInstallPkgs + "   - " + name + newline();
             }
         }
-
         if (!failedInstallPkgs.isEmpty()) {
             newInterruptedException(sbLog.toString());
         }
@@ -470,7 +480,7 @@ public class RpmPackageLauncher implements IPkgLauncher {
             boolean worksSmack, IProgressMonitor monitor) {
         boolean result = false;
         UserLogger.start(UserInteraction.CATE_PLATFORM_LAUNCH, PlatformUserInteraction.LAUNCH_RDS);
-        IRpmRapidDeployer rpmRds = LauncherInstances.getLaunchCommandUtil().getRpmRapidDeployer(project, commander, packages);       
+        IRpmRapidDeployer rpmRds = LauncherInstances.getLaunchCommandUtil().getRpmRapidDeployer(project, commander, packages);
         result = rpmRds.processFast();
         UserLogger.end(UserInteraction.CATE_PLATFORM_LAUNCH, PlatformUserInteraction.LAUNCH_RDS);
         return result;
@@ -510,8 +520,8 @@ public class RpmPackageLauncher implements IPkgLauncher {
             try {
                 insPkgs = installPkgsToRootstrap(pkgs, IPkgCommander.TOOL.ZYPPER, monitor, useRds);
             } catch (InterruptedException e) {
-               isInstallResult = false;
-               exception = e;
+                isInstallResult = false;
+                exception = e;
             }
             if (insPkgs) {
                 isInstallResult = true;
@@ -525,8 +535,8 @@ public class RpmPackageLauncher implements IPkgLauncher {
         }
 
         private InterruptedException getException() {
-               return exception;
-        }        
+            return exception;
+        }
     }
 
     private class DeviceInstallThread extends Thread {
@@ -559,23 +569,23 @@ public class RpmPackageLauncher implements IPkgLauncher {
                         List<IPackage> apps = result.get(0);
                         List<IPackage> others = result.get(1);
                         if (!apps.isEmpty()) {
-                               insPkgs = installPkgsToDevice(apps, isEfl, monitor, useRds);
+                            insPkgs = installPkgsToDevice(apps, isEfl, monitor, useRds);
                         }
                         if (!others.isEmpty()) {
-                               insPkgs = installPkgsToDevice(others, !isEfl, monitor, useRds);
+                            insPkgs = installPkgsToDevice(others, !isEfl, monitor, useRds);
                         }
                     } else {
-                       insPkgs = installPkgsToDevice(pkgs, isEfl, monitor, useRds);
+                        insPkgs = installPkgsToDevice(pkgs, isEfl, monitor, useRds);
                     }
                 } else {
-                       insPkgs = installPkgsToDevice(pkgs, isEfl, monitor, useRds);
+                    insPkgs = installPkgsToDevice(pkgs, isEfl, monitor, useRds);
                 }
                 if (insPkgs) {
                     isInstallResult = true;
-                }             
-            } catch (InterruptedException e) {                 
-               isInstallResult = false;
-               exception = e;
+                }
+            } catch (InterruptedException e) {
+                isInstallResult = false;
+                exception = e;
             }
             UserLogger.end(UserInteraction.CATE_PLATFORM_LAUNCH,
                     PlatformUserInteraction.INSTALL_DEVICE);
@@ -603,9 +613,9 @@ public class RpmPackageLauncher implements IPkgLauncher {
         private boolean isInstallResult() {
             return isInstallResult;
         }
-        
+
         private InterruptedException getException() {
-               return exception;
+            return exception;
         }
     }
 }
index ba149ec..e6981cd 100644 (file)
@@ -4,11 +4,11 @@
  * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Contact:
- * Jaemin Kim <jm.jaemin.kim@samsung.com>
- * Donghyuk Yang <donghyuk.yang@samsung.com>  
+ * Jaemin Kim <jm.jemin.kim@samsung.com>
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
  * SangHo Park <sangho.p@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -133,13 +133,6 @@ abstract public class PlatformProjectCommonLaunchShortcut extends CApplicationLa
             return;
         }
 
-        // device root should be on only when normal debugging.
-        if (needCheckDeviceRootOn()) {
-            if (!PlatformLaunchUtil.checkDeviceRootOn(device)) {
-                DialogUtil.openErrorDialog(PlatformLaunchMessages.DEVICE_IS_NOT_ROOT_ON);
-                return;
-            }
-        }
         pkgUtil = PlatformInstances.getPackageUtil();
         if (elements != null && elements.length > 0) {
             int nElements = elements.length;
index 38fda2e..2130fa6 100644 (file)
@@ -45,7 +45,6 @@ import org.tizen.common.core.application.InstallPathConfig;
 import org.tizen.nativecommon.build.CommonConfigurationManager;
 import org.tizen.nativeplatform.preferences.PreferencesManager;
 import org.tizen.nativeplatform.util.PlatformDirUtil;
-import org.tizen.sdblib.SmartDevelopmentBridge;
 import org.tizen.sdblib.util.IOUtil;
 
 /**
@@ -81,7 +80,6 @@ public class Activator extends AbstractUIPlugin {
 
         PlatformDirUtil.clearPlatformTempDir();
         PreferencesManager.setDefaultValues();
-        SmartDevelopmentBridge.addDeviceChangeListener(new DeviceChangeListener(), true);
         PlatformResourceChangeListener listener = new PlatformResourceChangeListener();
         ResourcesPlugin.getWorkspace().addResourceChangeListener(listener,
                 IResourceChangeEvent.PRE_DELETE);
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/DeviceChangeListener.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/DeviceChangeListener.java
deleted file mode 100644 (file)
index 1f54eb1..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaemin Kim <jm.jaemin.kim@samsung.com>
- * Donghyuk Yang <donghyuk.yang@samsung.com>  
- * DongHee Yang <donghee.yang@samsung.com>
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
-import org.tizen.nativeplatform.util.PlatformProjectUtil;
-import org.tizen.sdblib.IDevice;
-import org.tizen.sdblib.IDeviceChangeListener;
-import org.tizen.sdblib.util.DeviceUtil;
-
-public class DeviceChangeListener implements IDeviceChangeListener {
-
-    protected final Logger logger = LoggerFactory.getLogger(DeviceChangeListener.class);
-
-    @Override
-    public void onConnected(IDevice device) {
-        if (!DeviceUtil.isOnline(device)) {
-            return;
-        }
-        PkgCommandTarget target = new PkgCommandTarget(PlatformProjectUtil.getPkgType(), device);
-        try {
-            device.becomeSuperUser(true);
-        } catch (Exception e) {
-            e.printStackTrace();
-            logger.error("Failed to root on device");
-        }
-        target.getDeviceCommander().actionBeforeUsingZypper();
-    }
-
-    @Override
-    public void onDisconnected(IDevice device) {
-        // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void onChanged(IDevice device, int changeMask) {
-        // TODO Auto-generated method stub
-
-    }
-
-}
index 6026a84..62c5ac2 100644 (file)
@@ -4,10 +4,11 @@
  * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Contact:
- * Jaemin Kim <jm.jaemin.kim@samsung.com>
- * Donghyuk Yang <donghyuk.yang@samsung.com>  
+ * Jaemin Kim <jm.jemin.kim@samsung.com>
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ * Sangho Park <sangho.p@samsung.com>
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -54,6 +55,7 @@ import org.osgi.framework.Bundle;
 import org.tizen.nativeplatform.Activator;
 import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
 import org.tizen.nativeplatform.pkg.model.PackageProvider;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 import org.tizen.sdblib.IDevice;
 import org.tizen.sdblib.exception.SdbCommandRejectedException;
 import org.tizen.sdblib.exception.TimeoutException;
@@ -65,6 +67,8 @@ public class RPMPackageDialog extends Dialog {
     private boolean enableRootstrapTab = false;
     private boolean enableDeviceTab = false;
     private int tabIndex = 0;
+    private boolean rootStatus = false;
+
 
     private BuildsystemTab rootstrapTab;
     private DeviceTab deviceTab;
@@ -83,7 +87,8 @@ public class RPMPackageDialog extends Dialog {
         this.target = target;
         if (target.isSetDevice()) {
             this.enableDeviceTab = true;
-            setDeviceRootOn();
+            rootStatus = target.getDevice().isRoot();
+            PlatformLaunchUtil.checkAndSetDeviceRootOn(target.getDevice());
         }
         if (target.isSetRootstrap()) {
             this.enableRootstrapTab = true;
@@ -94,21 +99,6 @@ public class RPMPackageDialog extends Dialog {
         y = bounds.y + (bounds.height - height) / 2;
     }
 
-    private void setDeviceRootOn() {
-        IDevice device = target.getDevice();
-        if (!device.isRoot()) {
-            try {
-                device.becomeSuperUser(true);
-            } catch (TimeoutException e) {
-                e.printStackTrace();
-            } catch (SdbCommandRejectedException e) {
-                e.printStackTrace();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
     private void setImage(Shell parentShell) {
         Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
         try {
@@ -146,6 +136,9 @@ public class RPMPackageDialog extends Dialog {
                     deviceTab.closeTab();
                     monitor.worked(1);
                 }
+                if(!rootStatus){
+                    PlatformLaunchUtil.checkAndSetDeviceRootOff(target.getDevice());
+                }
                 PackageProvider.INSTANCE.clear();
                 monitor.done();
                 return Status.OK_STATUS;
@@ -229,4 +222,4 @@ public class RPMPackageDialog extends Dialog {
         }
         tabFolder.setSelection(tabIndex);
     }
-}
\ No newline at end of file
+}
index 2597815..f07dbc6 100644 (file)
@@ -4,11 +4,11 @@
  * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Contact:
- * Jaemin Kim <jm.jaemin.kim@samsung.com>
- * Donghyuk Yang <donghyuk.yang@samsung.com>  
+ * Jaemin Kim <jm.jemin.kim@samsung.com>
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
  * SangHo Park <sangho.p@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -106,14 +106,28 @@ public class PlatformLaunchUtil {
 
     private static final Logger logger = LoggerFactory.getLogger(PlatformLaunchUtil.class);
 
-    public static boolean checkDeviceRootOn(IDevice device) {
+    public static boolean checkAndSetDeviceRootOn(IDevice device) {
         if (device != null && !device.isRoot()) {
             try {
                 if (!device.becomeSuperUser(true)) {
                     return false;
                 }
             } catch (Exception e) {
-                logger.error(resources.getString("Device.not.rooton"), e);
+                logger.error(resources.getString("Device.not.rootOn"), e);
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public static boolean checkAndSetDeviceRootOff(IDevice device) {
+        if (device != null && device.isRoot()) {
+            try {
+                if (!device.becomeSuperUser(false)) {
+                    return false;
+                }
+            } catch (Exception e) {
+                logger.error(resources.getString("Device.not.rootOff"), e);
                 return false;
             }
         }
index 7b3fc0c..21c87ed 100644 (file)
@@ -1,4 +1,5 @@
 Failed.cache.pkg.checksum = Failed to cache package checksum
-Device.not.rooton = Device is not root on
+Device.not.rootOn = Failed to get root privilege\n Install command must be run as root\n Please check whether it's being run as root or not
+Device.not.rootOff = Failed to get original privilege back
 Question.packaging = The project does not have package files(*.rpm)\nDo you want packaging now ?\n
 Question.continue = Do you want to continue ?