Remove clock binder call
Change-Id: I773663174d0aa7a02989f3389ff0ed67135a16ac
Fixes: 77832075
Test: wait for clock to update, switch user, repeat
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
index baeaaad..9aa8044 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
@@ -16,9 +16,6 @@
package com.android.systemui.statusbar.policy;
-import libcore.icu.LocaleData;
-
-import android.app.ActivityManager;
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -46,6 +43,7 @@
import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
import com.android.systemui.SysUiServiceProvider;
+import com.android.systemui.settings.CurrentUserTracker;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
@@ -53,6 +51,8 @@
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;
+import libcore.icu.LocaleData;
+
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
@@ -66,6 +66,9 @@
public static final String CLOCK_SECONDS = "clock_seconds";
+ private final CurrentUserTracker mCurrentUserTracker;
+ private int mCurrentUserId;
+
private boolean mClockVisibleByPolicy = true;
private boolean mClockVisibleByUser = true;
@@ -117,6 +120,12 @@
} finally {
a.recycle();
}
+ mCurrentUserTracker = new CurrentUserTracker(context) {
+ @Override
+ public void onUserSwitched(int newUserId) {
+ mCurrentUserId = newUserId;
+ }
+ };
}
@Override
@@ -141,6 +150,8 @@
if (mShowDark) {
Dependency.get(DarkIconDispatcher.class).addDarkReceiver(this);
}
+ mCurrentUserTracker.startTracking();
+ mCurrentUserId = mCurrentUserTracker.getCurrentUserId();
}
// NOTE: It's safe to do these after registering the receiver since the receiver always runs
@@ -166,6 +177,7 @@
if (mShowDark) {
Dependency.get(DarkIconDispatcher.class).removeDarkReceiver(this);
}
+ mCurrentUserTracker.stopTracking();
}
}
@@ -302,7 +314,7 @@
private final CharSequence getSmallTime() {
Context context = getContext();
- boolean is24 = DateFormat.is24HourFormat(context, ActivityManager.getCurrentUser());
+ boolean is24 = DateFormat.is24HourFormat(context, mCurrentUserId);
LocaleData d = LocaleData.get(context.getResources().getConfiguration().locale);
final char MAGIC1 = '\uEF00';
@@ -392,8 +404,7 @@
} else if (hhmm != null && hhmm.length() == 4) {
int hh = Integer.parseInt(hhmm.substring(0, 2));
int mm = Integer.parseInt(hhmm.substring(2));
- boolean is24 = DateFormat.is24HourFormat(
- getContext(), ActivityManager.getCurrentUser());
+ boolean is24 = DateFormat.is24HourFormat(getContext(), mCurrentUserId);
if (is24) {
mCalendar.set(Calendar.HOUR_OF_DAY, hh);
} else {