diff options
author | Jim Miller <jaggies@google.com> | 2011-10-17 17:37:28 -0700 |
---|---|---|
committer | Jim Miller <jaggies@google.com> | 2011-10-17 17:43:02 -0700 |
commit | a7f3a34313074a96b1cc2eb4bea0304d8375af75 (patch) | |
tree | 2db61f2d3d4ab097ff251835702ad9b45ed94683 /core/java/com/android/internal/widget/DigitalClock.java | |
parent | f129988a1aa8a210dc125b0f427d848a2aeb8bb2 (diff) | |
download | frameworks_base-a7f3a34313074a96b1cc2eb4bea0304d8375af75.zip frameworks_base-a7f3a34313074a96b1cc2eb4bea0304d8375af75.tar.gz frameworks_base-a7f3a34313074a96b1cc2eb4bea0304d8375af75.tar.bz2 |
Fix 5473038: workaround for fd leak in lockscreen
This works around a file descriptor leak in Skia. It also improves
view creation time by avoiding re-loading the font every time a
DigitalClock is created.
Change-Id: I5c46445da36b1e6ba06c8ca340e436835d281180
Diffstat (limited to 'core/java/com/android/internal/widget/DigitalClock.java')
-rw-r--r-- | core/java/com/android/internal/widget/DigitalClock.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/core/java/com/android/internal/widget/DigitalClock.java b/core/java/com/android/internal/widget/DigitalClock.java index ac0dc35..18a4794 100644 --- a/core/java/com/android/internal/widget/DigitalClock.java +++ b/core/java/com/android/internal/widget/DigitalClock.java @@ -22,8 +22,6 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.res.AssetManager; -import android.content.res.Resources; import android.database.ContentObserver; import android.graphics.Typeface; import android.os.Handler; @@ -61,6 +59,14 @@ public class DigitalClock extends RelativeLayout { private final Handler mHandler = new Handler(); private BroadcastReceiver mIntentReceiver; + private static final Typeface sBackgroundFont; + private static final Typeface sForegroundFont; + + static { + sBackgroundFont = Typeface.createFromFile(SYSTEM_FONT_TIME_BACKGROUND); + sForegroundFont = Typeface.createFromFile(SYSTEM_FONT_TIME_FOREGROUND); + } + private static class TimeChangedReceiver extends BroadcastReceiver { private WeakReference<DigitalClock> mClock; private Context mContext; @@ -159,13 +165,11 @@ public class DigitalClock extends RelativeLayout { protected void onFinishInflate() { super.onFinishInflate(); - AssetManager assets = mContext.getAssets(); - /* The time display consists of two tones. That's why we have two overlapping text views. */ mTimeDisplayBackground = (TextView) findViewById(R.id.timeDisplayBackground); - mTimeDisplayBackground.setTypeface(Typeface.createFromFile(SYSTEM_FONT_TIME_BACKGROUND)); + mTimeDisplayBackground.setTypeface(sBackgroundFont); mTimeDisplayForeground = (TextView) findViewById(R.id.timeDisplayForeground); - mTimeDisplayForeground.setTypeface(Typeface.createFromFile(SYSTEM_FONT_TIME_FOREGROUND)); + mTimeDisplayForeground.setTypeface(sForegroundFont); mAmPm = new AmPm(this, null); mCalendar = Calendar.getInstance(); |