Use AlarmManager calls to set date/time, instead of SystemClock.setTime
This way secondary users' settings app can request the system server to set the time. Alarm driver cannot be opened as a secondary user. Bug: 7459635 Change-Id: I1ae1630dc448021d35280a297c5d9960f8e8fc2e
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package com.android.settings;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.TimePickerDialog;
|
||||
@@ -184,18 +185,18 @@ public class DateTimeSettings extends SettingsPreferenceFragment
|
||||
|
||||
@Override
|
||||
public void onDateSet(DatePicker view, int year, int month, int day) {
|
||||
setDate(year, month, day);
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
setDate(activity, year, month, day);
|
||||
updateTimeAndDateDisplay(activity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||
setTime(hourOfDay, minute);
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
setTime(activity, hourOfDay, minute);
|
||||
updateTimeAndDateDisplay(activity);
|
||||
}
|
||||
|
||||
@@ -337,7 +338,7 @@ public class DateTimeSettings extends SettingsPreferenceFragment
|
||||
}
|
||||
}
|
||||
|
||||
/* package */ static void setDate(int year, int month, int day) {
|
||||
/* package */ static void setDate(Context context, int year, int month, int day) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
|
||||
c.set(Calendar.YEAR, year);
|
||||
@@ -346,11 +347,11 @@ public class DateTimeSettings extends SettingsPreferenceFragment
|
||||
long when = c.getTimeInMillis();
|
||||
|
||||
if (when / 1000 < Integer.MAX_VALUE) {
|
||||
SystemClock.setCurrentTimeMillis(when);
|
||||
((AlarmManager) context.getSystemService(Context.ALARM_SERVICE)).setTime(when);
|
||||
}
|
||||
}
|
||||
|
||||
/* package */ static void setTime(int hourOfDay, int minute) {
|
||||
/* package */ static void setTime(Context context, int hourOfDay, int minute) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
|
||||
c.set(Calendar.HOUR_OF_DAY, hourOfDay);
|
||||
@@ -360,7 +361,7 @@ public class DateTimeSettings extends SettingsPreferenceFragment
|
||||
long when = c.getTimeInMillis();
|
||||
|
||||
if (when / 1000 < Integer.MAX_VALUE) {
|
||||
SystemClock.setCurrentTimeMillis(when);
|
||||
((AlarmManager) context.getSystemService(Context.ALARM_SERVICE)).setTime(when);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user