Re: [android-developers] Can't make restartPackage() / killBackgroundProcesses() to work
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 8/9/10 04:03 , Dianne Hackborn wrote: Well if you need it, write your own code to do it. They are your apps, right? You can have a way for them to interact to have one ask the other to kill itself -- send a broadcast to it, have a service to bind to to send a command to it, or heck even just have an instrumentation test case that does a self-murder and run that between every real test case. It's what I'm doing in other cases, but this wouldn't be a black-box testing. (Note from looking at your manifest -- applications have never been able to get the INJECT_EVENT permission, so there is no reason to request it.) Yes, it's a residual for other tries. Thanks. - -- Fabrizio Giudici - Java Architect, Project Manager Tidalwave s.a.s. - We make Java work. Everywhere. java.net/blog/fabriziogiudici - www.tidalwave.it/people fabrizio.giud...@tidalwave.it -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.14 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxf3uIACgkQeDweFqgUGxfR9gCfThS8ssQCOpmiH2O+DZv4jtpb fg8An1grVKrBcaBFyUdnhVgjAOyRJMsB =C1du -END PGP SIGNATURE- -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Can't make restartPackage() / killBackgroundProcesses() to work
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 8/7/10 19:59 , Dianne Hackborn wrote: Sorry you can't do this. Apps now can only kill processes of other apps that are in the background. Too bad. This makes functional testing more complex and longer than it should... :-( But why doesn't it work in older emulator versions than 2.2? - -- Fabrizio Giudici - Java Architect, Project Manager Tidalwave s.a.s. - We make Java work. Everywhere. java.net/blog/fabriziogiudici - www.tidalwave.it/people fabrizio.giud...@tidalwave.it -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.14 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxend8ACgkQeDweFqgUGxdY8wCfdS/DjA7VIg6NRP3HdjAonvIJ 6CsAn0udiHGHk+MEUF9Szr4zGhsE+a5M =DiZF -END PGP SIGNATURE- -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Can't make restartPackage() / killBackgroundProcesses() to work
Well if you need it, write your own code to do it. They are your apps, right? You can have a way for them to interact to have one ask the other to kill itself -- send a broadcast to it, have a service to bind to to send a command to it, or heck even just have an instrumentation test case that does a self-murder and run that between every real test case. As far as why this doesn't work prior to 2.2... I thought from your message that you had it working there. If not, I don't know what to say -- the API was available, and a number of apps use it. I would suggest looking in the log when you install your app to see if there are any messages about you not being granted the permission, etc. (Note from looking at your manifest -- applications have never been able to get the INJECT_EVENT permission, so there is no reason to request it.) On Sun, Aug 8, 2010 at 5:06 AM, Fabrizio Giudici fabrizio.giud...@tidalwave.it wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 8/7/10 19:59 , Dianne Hackborn wrote: Sorry you can't do this. Apps now can only kill processes of other apps that are in the background. Too bad. This makes functional testing more complex and longer than it should... :-( But why doesn't it work in older emulator versions than 2.2? - -- Fabrizio Giudici - Java Architect, Project Manager Tidalwave s.a.s. - We make Java work. Everywhere. java.net/blog/fabriziogiudici - www.tidalwave.it/people fabrizio.giud...@tidalwave.it -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.14 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxend8ACgkQeDweFqgUGxdY8wCfdS/DjA7VIg6NRP3HdjAonvIJ 6CsAn0udiHGHk+MEUF9Szr4zGhsE+a5M =DiZF -END PGP SIGNATURE- -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Can't make restartPackage() / killBackgroundProcesses() to work
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello. I'm trying to have restartPackage() work - please note that I'm aware of all the discussions related to APIs for restarting another application; I'm not trying to do this in production, but during functional tests in order to be sure to have the application under test to start clean every time (without it, I'm currently forced to run one functional test at a time with adb, which is an annoyance). I know that restartPackage() has been deprecated in 2.2 and now is equivalent to killBackgroundProcesses(), which is perfectly fine for me. This is the code I'm trying (from setUp() of an ActivityInstrumentationTestCase2): private void resetApplication() { logger.info( RESTARTING APP); final Context context = getInstrumentation().getContext(); // also tried with getTargetContext(), even though I suppose getContext() is correct final ActivityManager manager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE); manager.restartPackage(it.tidalwave.bluebill.mobile.android); } but I constantly get: W/ActivityManager( 1280): Permission Denial: restartPackage() from pid=6014, uid=10071 requires android.permission.RESTART_PACKAGES I/TestRunner( 6014): failed: testRun(it.tidalwave.bluebill.mobile.android.test.functional.InsertOneObservationFromScratch) I/TestRunner( 6014): - begin exception - I/TestRunner( 6014): I/TestRunner( 6014): java.lang.SecurityException: Permission Denial: restartPackage() from pid=6014, uid=10071 requires android.permission.RESTART_PACKAGES I/TestRunner( 6014): at android.os.Parcel.readException(Parcel.java:1218) I/TestRunner( 6014): at android.os.Parcel.readException(Parcel.java:1206) I/TestRunner( 6014): at android.app.ActivityManagerProxy.restartPackage(ActivityManagerNative.java:2383) I/TestRunner( 6014): at android.app.ActivityManager.restartPackage(ActivityManager.java:910) I/TestRunner( 6014): at it.tidalwave.bluebill.mobile.android.ScenarioTestSupport.resetApplication(ScenarioTestSupport.java:183) I/TestRunner( 6014): at it.tidalwave.bluebill.mobile.android.ScenarioTestSupport.setUp(ScenarioTestSupport.java:87) I/TestRunner( 6014): at it.tidalwave.bluebill.mobile.android.test.functional.ObservationScenarioTestSupport.setUp(ObservationScenarioTestSupport.java:48) I/TestRunner( 6014): at junit.framework.TestCase.runBare(TestCase.java:125) I/TestRunner( 6014): at junit.framework.TestResult$1.protect(TestResult.java:106) I/TestRunner( 6014): at junit.framework.TestResult.runProtected(TestResult.java:124) I/TestRunner( 6014): at junit.framework.TestResult.run(TestResult.java:109) I/TestRunner( 6014): at junit.framework.TestCase.run(TestCase.java:118) I/TestRunner( 6014): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) I/TestRunner( 6014): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) I/TestRunner( 6014): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430) I/TestRunner( 6014): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447) I/TestRunner( 6014): - end exception - Of course I put the required permission in the AndroidManifest.xml: ?xml version=1.0 encoding=UTF-8? manifest package=it.tidalwave.bluebill.mobile.android.tests android:versionCode=1545 xmlns:android=http://schemas.android.com/apk/res/android; android:versionName=0.14.0-SNAPSHOT uses-sdk android:minSdkVersion=3/ uses-permission android:name=android.permission.INJECT_EVENT/ uses-permission android:name=android.permission.RESTART_PACKAGES/ application android:label=blueBill Mobile Functional Tests uses-library android:name=android.test.runner/ /application instrumentation android:name=android.test.InstrumentationTestRunner android:targetPackage=it.tidalwave.bluebill.mobile.android android:label=Tests for blueBill Mobile for Android./ /manifest The app with tests is signed with the same signature of the app under test (the debug key). It happens both with the emulator (1.5 and 2.2) and a Motorola Droid (2.1). Of course the 2.2 with the variant that the required permission is android.permission.KILL_BACKGROUND_PROCESSES. Why am I still getting the error? Thanks. - -- Fabrizio Giudici - Java Architect, Project Manager Tidalwave s.a.s. - We make Java work. Everywhere. java.net/blog/fabriziogiudici - www.tidalwave.it/people fabrizio.giud...@tidalwave.it -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.14 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxdDr4ACgkQeDweFqgUGxcRFgCgkkyp8VcxyqPCfUkqs7U6HQ5R s5YAn3V2dETNVU7Lga6vHhf7JQB1WQEm =kRZ5 -END PGP SIGNATURE- -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To
Re: [android-developers] Can't make restartPackage() / killBackgroundProcesses() to work
Sorry you can't do this. Apps now can only kill processes of other apps that are in the background. On Sat, Aug 7, 2010 at 12:43 AM, Fabrizio Giudici fabrizio.giud...@tidalwave.it wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello. I'm trying to have restartPackage() work - please note that I'm aware of all the discussions related to APIs for restarting another application; I'm not trying to do this in production, but during functional tests in order to be sure to have the application under test to start clean every time (without it, I'm currently forced to run one functional test at a time with adb, which is an annoyance). I know that restartPackage() has been deprecated in 2.2 and now is equivalent to killBackgroundProcesses(), which is perfectly fine for me. This is the code I'm trying (from setUp() of an ActivityInstrumentationTestCase2): private void resetApplication() { logger.info( RESTARTING APP); final Context context = getInstrumentation().getContext(); // also tried with getTargetContext(), even though I suppose getContext() is correct final ActivityManager manager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE); manager.restartPackage(it.tidalwave.bluebill.mobile.android); } but I constantly get: W/ActivityManager( 1280): Permission Denial: restartPackage() from pid=6014, uid=10071 requires android.permission.RESTART_PACKAGES I/TestRunner( 6014): failed: testRun(it.tidalwave.bluebill.mobile.android.test.functional.InsertOneObservationFromScratch) I/TestRunner( 6014): - begin exception - I/TestRunner( 6014): I/TestRunner( 6014): java.lang.SecurityException: Permission Denial: restartPackage() from pid=6014, uid=10071 requires android.permission.RESTART_PACKAGES I/TestRunner( 6014): at android.os.Parcel.readException(Parcel.java:1218) I/TestRunner( 6014): at android.os.Parcel.readException(Parcel.java:1206) I/TestRunner( 6014): at android.app.ActivityManagerProxy.restartPackage(ActivityManagerNative.java:2383) I/TestRunner( 6014): at android.app.ActivityManager.restartPackage(ActivityManager.java:910) I/TestRunner( 6014): at it.tidalwave.bluebill.mobile.android.ScenarioTestSupport.resetApplication(ScenarioTestSupport.java:183) I/TestRunner( 6014): at it.tidalwave.bluebill.mobile.android.ScenarioTestSupport.setUp(ScenarioTestSupport.java:87) I/TestRunner( 6014): at it.tidalwave.bluebill.mobile.android.test.functional.ObservationScenarioTestSupport.setUp(ObservationScenarioTestSupport.java:48) I/TestRunner( 6014): at junit.framework.TestCase.runBare(TestCase.java:125) I/TestRunner( 6014): at junit.framework.TestResult$1.protect(TestResult.java:106) I/TestRunner( 6014): at junit.framework.TestResult.runProtected(TestResult.java:124) I/TestRunner( 6014): at junit.framework.TestResult.run(TestResult.java:109) I/TestRunner( 6014): at junit.framework.TestCase.run(TestCase.java:118) I/TestRunner( 6014): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) I/TestRunner( 6014): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) I/TestRunner( 6014): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430) I/TestRunner( 6014): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447) I/TestRunner( 6014): - end exception - Of course I put the required permission in the AndroidManifest.xml: ?xml version=1.0 encoding=UTF-8? manifest package=it.tidalwave.bluebill.mobile.android.tests android:versionCode=1545 xmlns:android=http://schemas.android.com/apk/res/android; android:versionName=0.14.0-SNAPSHOT uses-sdk android:minSdkVersion=3/ uses-permission android:name=android.permission.INJECT_EVENT/ uses-permission android:name=android.permission.RESTART_PACKAGES/ application android:label=blueBill Mobile Functional Tests uses-library android:name=android.test.runner/ /application instrumentation android:name=android.test.InstrumentationTestRunner android:targetPackage=it.tidalwave.bluebill.mobile.android android:label=Tests for blueBill Mobile for Android./ /manifest The app with tests is signed with the same signature of the app under test (the debug key). It happens both with the emulator (1.5 and 2.2) and a Motorola Droid (2.1). Of course the 2.2 with the variant that the required permission is android.permission.KILL_BACKGROUND_PROCESSES. Why am I still getting the error? Thanks. - -- Fabrizio Giudici - Java Architect, Project Manager Tidalwave s.a.s. - We make Java work. Everywhere. java.net/blog/fabriziogiudici - www.tidalwave.it/people fabrizio.giud...@tidalwave.it -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.14 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/