Exemplo n.º 1
0
 def normal_install(self):
     print 'performing standard install'
     dluri = Uri.fromFile(File(self.downloadfile))
     intent = Intent(Intent.ACTION_VIEW)
     intent.setDataAndType(dluri, 'application/vnd.android.package-archive')
     intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
     mContext().startActivity(intent)
Exemplo n.º 2
0
	def normal_install(self):
		print 'performing standard install'
		dluri = Uri.fromFile(File(self.downloadfile))
		intent = Intent(Intent.ACTION_VIEW)
		intent.setDataAndType(dluri, 'application/vnd.android.package-archive')
		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
		mContext().startActivity(intent)
Exemplo n.º 3
0
	def restart_app(self):
		print 'restarting app'
		app = mContext()
		context = app.getBaseContext()
		intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName())
		intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
		app.startActivity(intent)
		print 'app activity launched'
Exemplo n.º 4
0
 def restart_app(self):
     print 'restarting app'
     app = mContext()
     context = app.getBaseContext()
     intent = context.getPackageManager().getLaunchIntentForPackage(
         context.getPackageName())
     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
     app.startActivity(intent)
     print 'app activity launched'
Exemplo n.º 5
0
    def root_install(self):
        print 'performing root install'

        scriptfilesd = os.path.join(
            Environment.getExternalStorageDirectory().getPath(),
            'py4aupdate.sh')
        scriptfile = os.path.join('/cache', 'py4aupdate.sh')

        with open(scriptfilesd, 'w') as f:
            f.write(
                '(pm install -r %s | tee /proc/self/fd/2 | grep -q Success) 2>&1 || exit 1\n'
                % self.downloadfile)
            f.write('rm -f %s\n' % self.downloadfile)
            f.write('rm -f %s\n' % scriptfile)
            if self.restart:
                appname = mContext().getPackageName()
                f.write('am start -n %s/%s\n' %
                        (appname, self.restart_activity))

        print self.run_root('cp %s %s' % (scriptfilesd, scriptfile))
        print self.run_root('chmod 0777 %s' % scriptfile)

        os.unlink(scriptfilesd)

        try:
            output = self.run_root('sh %s' % scriptfile)

            # service should be killed on update, if we're still running it's an error
            print 'install failed:'
            print output
            raise UpdateFailedException(output)
        except UpdateFailedException:
            raise
        except Exception, e:
            print 'install failed:'
            if hasattr(e, 'output') and e.output:
                print e.output
                raise UpdateFailedException(e.output)
            else:
                traceback.print_exc()
                print '(no command output)'
                raise UpdateFailedException(e)
Exemplo n.º 6
0
	def root_install(self):
		print 'performing root install'

		scriptfilesd = os.path.join(Environment.getExternalStorageDirectory().getPath(), 'py4aupdate.sh')
		scriptfile = os.path.join('/cache', 'py4aupdate.sh')
		
		with open(scriptfilesd, 'w') as f:
			f.write('(pm install -r %s | tee /proc/self/fd/2 | grep -q Success) 2>&1 || exit 1\n' % self.downloadfile)
			f.write('rm -f %s\n' % self.downloadfile)
			f.write('rm -f %s\n' % scriptfile)
			if self.restart:
				appname = mContext().getPackageName()
				f.write('am start -n %s/%s\n' % (appname, self.restart_activity))
		
		print self.run_root('cp %s %s' % (scriptfilesd, scriptfile))
		print self.run_root('chmod 0777 %s' % scriptfile)
		
		os.unlink(scriptfilesd)
		
		try:
			output = self.run_root('sh %s' % scriptfile)
			
			# service should be killed on update, if we're still running it's an error
			print 'install failed:'
			print output
			raise UpdateFailedException(output)
		except UpdateFailedException:
			raise
		except Exception, e:
			print 'install failed:'
			if hasattr(e, 'output') and e.output:
				print e.output
				raise UpdateFailedException(e.output)
			else:
				traceback.print_exc()
				print '(no command output)'
				raise UpdateFailedException(e)