summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorGreg Hackmann <ghackmann@google.com>2014-02-22 00:46:52 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-02-22 00:46:52 +0000
commit4418372b21e91f6d4b9e11931dd87a90a023d79e (patch)
treee6a049cd2573e5e6160c1cb0febc9411fbc246bc /core/java
parent3b49a8a629fb66431bf320d0a759299c5383cb06 (diff)
parent5f652b9fdfbcc279353955f7ef86b72d2ef9f5fb (diff)
downloadframeworks_base-4418372b21e91f6d4b9e11931dd87a90a023d79e.zip
frameworks_base-4418372b21e91f6d4b9e11931dd87a90a023d79e.tar.gz
frameworks_base-4418372b21e91f6d4b9e11931dd87a90a023d79e.tar.bz2
am 5f652b9f: am 0cab896a: resolved conflicts for merge of 9e413bf4 to klp-modular-dev-plus-aosp
* commit '5f652b9fdfbcc279353955f7ef86b72d2ef9f5fb': open("/dev/rtc0") failure in AlarmManagerService.setTime() should be non-fatal Move time setting code from SystemClock to AlarmManagerService
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/IAlarmManager.aidl2
-rw-r--r--core/java/android/os/SystemClock.java23
2 files changed, 23 insertions, 2 deletions
diff --git a/core/java/android/app/IAlarmManager.aidl b/core/java/android/app/IAlarmManager.aidl
index 8476609..ef9f26e 100644
--- a/core/java/android/app/IAlarmManager.aidl
+++ b/core/java/android/app/IAlarmManager.aidl
@@ -28,7 +28,7 @@ interface IAlarmManager {
/** windowLength == 0 means exact; windowLength < 0 means the let the OS decide */
void set(int type, long triggerAtTime, long windowLength,
long interval, in PendingIntent operation, in WorkSource workSource);
- void setTime(long millis);
+ boolean setTime(long millis);
void setTimeZone(String zone);
void remove(in PendingIntent operation);
}
diff --git a/core/java/android/os/SystemClock.java b/core/java/android/os/SystemClock.java
index 729c64b..672df6d 100644
--- a/core/java/android/os/SystemClock.java
+++ b/core/java/android/os/SystemClock.java
@@ -16,6 +16,9 @@
package android.os;
+import android.app.IAlarmManager;
+import android.content.Context;
+import android.util.Slog;
/**
* Core timekeeping facilities.
@@ -89,6 +92,8 @@ package android.os;
* </ul>
*/
public final class SystemClock {
+ private static final String TAG = "SystemClock";
+
/**
* This class is uninstantiable.
*/
@@ -134,7 +139,23 @@ public final class SystemClock {
*
* @return if the clock was successfully set to the specified time.
*/
- native public static boolean setCurrentTimeMillis(long millis);
+ public static boolean setCurrentTimeMillis(long millis) {
+ IBinder b = ServiceManager.getService(Context.ALARM_SERVICE);
+ IAlarmManager mgr = IAlarmManager.Stub.asInterface(b);
+ if (mgr == null) {
+ return false;
+ }
+
+ try {
+ return mgr.setTime(millis);
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Unable to set RTC", e);
+ } catch (SecurityException e) {
+ Slog.e(TAG, "Unable to set RTC", e);
+ }
+
+ return false;
+ }
/**
* Returns milliseconds since boot, not counting time spent in deep sleep.