Issue with SystemClock.setCurrentTimeMillis

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Issue with SystemClock.setCurrentTimeMillis

Postby widget_will » Fri Jul 02, 2010 3:06 pm

Hey all,
I've been trying to write a simple NTP client for an Android device. I've got the networked portion down and am getting a good value from my SNTP server, but I'm having issues when trying to set the system time to this value. I've been trying to use the SystemClock.setCurrentTimeMillis() function, but am receiving a permissions error when my code hits this point. Specifically, my debugger is giving me the message "Unable to open alarm driver: Permission denied." I've poked around a bit on the android dev user groups and mailing lists, and see this issue referenced occasionally, but have yet to come across a solution. I'm running 2.2 (API level 8 ) and have given my application the SET_TIME, WRITE_SETTINGS, and WRITE_SECURE_SETTINGS permissions.

Any ideas what the issue might be?
widget_will
Freshman
Freshman
 
Posts: 2
Joined: Fri Jul 02, 2010 2:58 pm

Top

Re: Issue with SystemClock.setCurrentTimeMillis

Postby widget_will » Fri Jul 02, 2010 3:20 pm

update:
I just read through a bit more of my LogCat and found that when I try to run my app, I'm getting a warning stating "Not granting permission android.permission.SET_TIME to package ... (protectionLevel=3 flags=0x8444)"

I looked around the SDK documentation for info on protectionLevels, but I could only find information on how to set the protection level for a custom permission. Is it possible to have an application run as root? It seems like the only way to make use of the SET_TIME permission is for an app to be cleared up to the signatureOrSystem protection level, which doesn't seem like something you'd be able to do for a normal application.

Any help would be appreciated, and thanks in advance!
widget_will
Freshman
Freshman
 
Posts: 2
Joined: Fri Jul 02, 2010 2:58 pm

Re: Issue with SystemClock.setCurrentTimeMillis

Postby anarche » Sat Jul 03, 2010 3:02 am

You can only run as root on a rooted phone. Security would not work if any app could run as root.

I had this same issue with Power permissions. AFAIK you cannot get this permission without running on a rooted phone.
anarche
Master Developer
Master Developer
 
Posts: 369
Joined: Sun Apr 11, 2010 5:21 am

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 4 guests