Commit 2f20f7d7 authored by Philipp Auersperg's avatar Philipp Auersperg

whitelist

parent ed4c19ba
Pipeline #287 failed with stages
......@@ -8,8 +8,8 @@ android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.androidrpcclient"
// minSdkVersion 19
minSdkVersion 26 //brauchts fuer android 8 fuer startForegroundService
minSdkVersion 19
// minSdkVersion 26 //brauchts fuer android 8 fuer startForegroundService
targetSdkVersion 28
versionCode 1
versionName "1.0"
......
......@@ -76,31 +76,11 @@ class MainActivity : AppCompatActivity() {
fun onStartService(view: View){
val cn = ComponentName("org.bd.pureservice", "org.bd.pureservice.ServiceSchas")
val intent = Intent();
// intent.setAction("org.bd.pureservice.ServiceSchas");
intent.setComponent(cn)
// intent.putExtra("androidPrivate", "/data/user/0/org.bd.pureservice/files/app")
// intent.putExtra("androidArgument", "/data/user/0/org.bd.pureservice/files/app")
// intent.putExtra("serviceEntrypoint","servp3.py")
// intent.putExtra("pythonName","schas")
// intent.putExtra("pythonHome","/data/user/0/org.bd.pureservice/files/app")
// intent.putExtra("pythonPath", "/data/user/0/org.bd.pureservice/files/app:/data/user/0/org.bd.pureservice/files/app/lib")
// intent.putExtra("pythonServiceArgument", "test argument ok")
val pm=getPackageManager()
val res=pm.getPackageInfo("org.bd.pureservice",0)
val prefix = res.applicationInfo.dataDir
intent.putExtra("androidPrivate", prefix+"/files/app")
intent.putExtra("androidArgument", prefix+"/files/app")
intent.putExtra("serviceEntrypoint","servp3.py")
intent.putExtra("pythonName","schas")
intent.putExtra("pythonHome",prefix+"/files/app")
intent.putExtra("pythonPath", "$prefix/files/app:$prefix/files/app/lib")
intent.putExtra("pythonServiceArgument", "test argument ok")
try{
// val res=startService(intent)
val res=startForegroundService(intent)
val res=startPythonService("org.bd.pureservice", "schas", "servp3.py")
this.txtMessage.text=res.toString()
this.txtStatus.text="started service"
} catch (e: Exception) {
txtStatus.text = "Exception"
txtMessage.text = e.toString()
......@@ -118,9 +98,45 @@ class MainActivity : AppCompatActivity() {
// } catch (e:Exception) {
// txtMessage.text=e.message
// }
val pm=getPackageManager()
val res=pm.getPackageInfo("org.bd.pureservice",0)
this.txtMessage.text = res.applicationInfo.dataDir
// val pm=getPackageManager()
// val res=pm.getPackageInfo("org.bd.pureservice",0)
// this.txtMessage.text = res.applicationInfo.dataDir
try{
val res=startPythonService("org.test.testapp_service", "time", "p4atime.py")
this.txtMessage.text=res.toString()
this.txtStatus.text="started service"
} catch (e: Exception) {
txtStatus.text = "Exception"
txtMessage.text = e.toString()
}
}
fun startPythonService(pkgname: String, servicename:String, script:String) : ComponentName{
// val pkgname= "org.bd.pureservice"
val serviceclassname="Service${servicename.capitalize()}"
val cn = ComponentName(pkgname, "$pkgname.$serviceclassname")
val intent = Intent();
intent.setComponent(cn)
val pm=getPackageManager()
val res=pm.getPackageInfo(pkgname,0)
val prefix = res.applicationInfo.dataDir
intent.putExtra("androidPrivate", prefix+"/files/app")
intent.putExtra("androidArgument", prefix+"/files/app")
intent.putExtra("serviceEntrypoint",script)
intent.putExtra("pythonName",servicename)
intent.putExtra("pythonHome","$prefix/files/app")
intent.putExtra("pythonPath", "$prefix/files/app:$prefix/files/app/lib")
intent.putExtra("pythonServiceArgument", "test argument ok")
println("======================================pythonHome:"+ "$prefix/files/app")
println("======================================pythonPath:"+"$prefix/files/app:$prefix/files/app/lib")
return startService(intent) //android < 8
// return startForegroundService(intent) //android 8
}
}
......@@ -15,11 +15,11 @@ Minimal Kivy Service example with a simple echo service
starting app via logcat works now
$ adb shell am start org.bd.p3service/org.kivy.android.PythonActivity
$ adb shell am start org.bd.pureservice/org.kivy.android.PythonActivity
## start service via adb
$ adb shell am startservice org.bd.p3service/org.bd.p3service.ServiceTestp3serv
$ adb shell am startservice org.bd.pureservice/org.bd.pureservice.ServiceSchas
but still searching how to start it from an android app
......
print('Service Test App main.py was successfully called')
print('================================================')
import time
import sys
......
......@@ -28,6 +28,10 @@ def add(self, elements, conn, **kw):
def geterror(self, **kw):
raise Exception("shit happened")
@delegate.api
def version(self, **kw):
return '1.0.0 p'
def runit():
host = '0.0.0.0'
port = 8077
......
print('Service Test App main.py was successfully called')
print('================================================')
import time
import sys
......
......@@ -28,6 +28,10 @@ def add(self, elements, conn, **kw):
def geterror(self, **kw):
raise Exception("shit happened")
@delegate.api
def version(self, **kw):
return '1.0.0 p'
def runit():
host = '0.0.0.0'
port = 8077
......
......@@ -13,11 +13,10 @@ options = {'apk': {'debug': None,
'bootstrap': 'service_only',
'permissions': ['INTERNET', 'VIBRATE'],
'arch': 'armeabi-v7a',
'service': 'schas:servp3.py:sticky',
# 'service': 'schas:servp3.py:sticky',
'service': 'schas:servp3.py',
'blacklist':'',
'whitelist':'whitelist.txt',
# 'include_ext':'*.schas',
# 'service': 'time:p4atime.py',
'package':'org.bd.pureservice',
}}
......
pureservice/servp3.py
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment