How to install Android application as system app - sleep

I am trying to learn how to install any application as system app.
Basically i am trying to use goToSleep and WakeUp function calls in android. I understand that to use these call in your application , application must be installed as system application.
Tried building application with permissions in Manifist.xml as given below
android:sharedUserId="android.uid.system"
uses-permission android:name="android.permission.DEVICE_POWER"
goToSleep call was used as discribed below
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
pm.goToSleep(SystemClock.uptimeMillis() + 10);
After successfully building the application the application was loaded into /system/app directory of android filesystem using following commands
adb remount ;
adb push <*.apk> /system/app/
Running the application with above changes resulted in Error
"Neither user 10050 nor current process has android.permission.DEVICE_POWER."
I also read that application must be signed as system app for this to successfully work
i have the copy of android kernel source that i built, Using this how do i sign the current application as system application and successfully test the goToSleep functionality
Thanks,
-SP-

You would need to root the android device and place the APK inside the system/app directory. I believe that's the only way around to convert any custom application to system app.

Related

qt program deployed on mac. config file not writing when standalone app launched, works when run from within qt creator

I have a program that I have developed for mac osx. When the program is run from within Qt creator, a log file and a config.cfg file are created in the myapp.app/Contents/MacOS folder, alongside the executable. This is the correct behaviour, the program needs these files.
When I deploy the app to run standalone (by linking the required libraries using macdeploymentqt tool) the app launches and runs correctly however the log and config.cfg file do not get written to the myapp.app/Contents/MacOS folder and so settings can't be read in.
Is there anyway to get around this? Has anyone encountered this before?
Mitch
osx will likely not allow you writing to your bundle location on installed apps, for security reasons and because it may conflict when multiple users are using your app.
To be cross platform, you could write instead to:
QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
which resolves to
~/Library/Application Support/<APPNAME>
and
C:/Users/<USER>/AppData/Local/<APPNAME>
or equivalent on windows.
You're never supposed to write to the application bundle, whether on Mac or on Windows. Even on Windows, it will not work if your user isn't an administrator. This idea last made sense on Windows 95 - not even on Windows NT. Don't do it.

detect if app is sideloaded in windows runtime

I am working on a windows phone Runtime app
I want to know how can I find if the app is side loaded or it downloaded from Store directly ?
Note : I want to prevent application run when it's sideloaded. I want to prevent crack installation of application
try to Write a file in Installed Directory solved the problem .
Thanks to DJAmol in Xda-Developers.com forum

Mac OS X: Launching an app using NSWorkspace from a daemon doesn't work if the daemon is run as root

I created a Command Line Tool app using Xcode.
In that app, I used NSWorkspace to launch another application bundle (.app) as suggested here.
MacOsX: How to launch an application (.app) from a "Command Line Tool" type of app
All seem to work fine until I tried to start that Command Line Tool app as a daemon using launchctl.
If the daemon is run as the currently logged in user, then the Command Line Tool app launches the external app just fine.
If the daemon is run as root, then the Command Line Tool app cannot launch the external app.
Using NSWorkspace to open an app doesn't seem to work if the daemon is run as root.
Does anyone know the correct way to open another app from a daemon that's running as root?
This is likely a security restriction within MacOS you're running into.
What I would suggest doing is to create a code-signed "helper tool" that resets itself (via setuid -- which I wouldn't do outside of a code-signed app) to the userid of currently logged in user, and then do the NSWorkspace trick to launch the app in that user context.
Creating helper tools is not trivial though. The grand concepts are described in Apple's Authorization Services Programming Guide.
Take a look at Apple's "SMJobBless" sample code, which shows how to install the helper tool that you could set the user rights on and then modify it's helper tool code to launch your app.
This is too complicated a subject to really address in a StackOverflow answer. The short answer is that daemons can't launch applications reliably. For the long answer, please read Apple's Technical Note TN2083: Daemons and Agents.
I finally got it working by using the code mentioned in this link to get the "console user's" uid and gid:
https://superuser.com/questions/180819/how-can-you-find-out-the-currently-logged-in-user-in-the-os-x-gui.
The link shows an example of how to use SCDynamicStoreCreate() and SCDynamicStoreCopyConsoleUser() to get "console user's" uid and gid.
After getting the uid and gid, just set the uid and gid to those of the console user before using NSWorkspace to open an app and that did the trick for me.

Mac app crashes from finder but runs inside Terminal

I tried searching, but did not find a specific post that could answer my question.
For my MacOS app, I have an external framework residing in /Library/Frameworks that I am linking to.
The app runs fine from Xcode. The app runs fine by itself on my dev system.
If I copy the app bundle over to another machine, and also copy over the external framework to /Library/Frameworks area (so it has a similar setup to my dev machine), the app crashes when it tries to perform the task that uses the external framework.
What's weird is that the app does not crash on the other machine if run from the terminal, or through gdb. It only crashes on the feature using the external framework when launched from the Finder. I made sure permissions etc are all open.
The crash is of BAD_ACCESS (SIGSEGV) type and the feature involves using the framework to write out a file.
Any thoughts about what could be causing the crash/how to go about debugging this?
Thanks
The most likely difference you're running into is working directories -- launching an application manually from the terminal will run it in whatever directory you happen to be in at the time, while launching it normally (e.g, by double-clicking it in the Finder) will start it up with a working directory of /. Make sure you aren't using any relative paths by mistake.

Auto Update application windows desktop using win32

I am trying to auto update my current application to new application in windows desktop using win32 api . And my application is running in background. so is there any api Microsoft providing for auto updating application or is there any procedure .please help me so that i can make update my appilication in windows desktop in vs 2005 using win32 .
Thanks
KamalBhr
AFAIK there is not Win32 API nor should there be. You will have actually have to write it. :|.
If you expect frequent updates to the application, e.g., in an environment where you want to push updates without user interaction.
on application start, spawn a copy of the the executable.
either periodically or through user action, check if there are updates available.
kill the process, replace the necessary files. restart the application.
as you spawned a copy of the executable you are free to overwrite it whilst the application is running.
Alternative, download the update packet to a directory. On next application start check if there are updates to be applied.
HTH,

Resources