diff options
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/os/storage/StorageManager.java | 23 | ||||
| -rw-r--r-- | core/java/android/preference/TwoStatePreference.java | 12 | ||||
| -rw-r--r-- | core/java/android/service/dreams/Dream.java | 8 |
3 files changed, 30 insertions, 13 deletions
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java index cb6c1dc..8a20a6e 100644 --- a/core/java/android/os/storage/StorageManager.java +++ b/core/java/android/os/storage/StorageManager.java @@ -56,7 +56,7 @@ public class StorageManager /* * Our internal MountService binder reference */ - private IMountService mMountService; + final private IMountService mMountService; /* * The looper target for callbacks @@ -304,8 +304,6 @@ public class StorageManager return; } mTgtLooper = tgtLooper; - mBinderListener = new MountServiceBinderListener(); - mMountService.registerListener(mBinderListener); } @@ -322,6 +320,15 @@ public class StorageManager } synchronized (mListeners) { + if (mBinderListener == null ) { + try { + mBinderListener = new MountServiceBinderListener(); + mMountService.registerListener(mBinderListener); + } catch (RemoteException rex) { + Log.e(TAG, "Register mBinderListener failed"); + return; + } + } mListeners.add(new ListenerDelegate(listener)); } } @@ -347,7 +354,15 @@ public class StorageManager break; } } - } + if (mListeners.size() == 0 && mBinderListener != null) { + try { + mMountService.unregisterListener(mBinderListener); + } catch (RemoteException rex) { + Log.e(TAG, "Unregister mBinderListener failed"); + return; + } + } + } } /** diff --git a/core/java/android/preference/TwoStatePreference.java b/core/java/android/preference/TwoStatePreference.java index d186b20..c649879 100644 --- a/core/java/android/preference/TwoStatePreference.java +++ b/core/java/android/preference/TwoStatePreference.java @@ -37,6 +37,7 @@ public abstract class TwoStatePreference extends Preference { private CharSequence mSummaryOn; private CharSequence mSummaryOff; boolean mChecked; + private boolean mCheckedSet; private boolean mSendClickAccessibilityEvent; private boolean mDisableDependentsState; @@ -74,11 +75,16 @@ public abstract class TwoStatePreference extends Preference { * @param checked The checked state. */ public void setChecked(boolean checked) { - if (mChecked != checked) { + // Always persist/notify the first time; don't assume the field's default of false. + final boolean changed = mChecked != checked; + if (changed || !mCheckedSet) { mChecked = checked; + mCheckedSet = true; persistBoolean(checked); - notifyDependencyChange(shouldDisableDependents()); - notifyChanged(); + if (changed) { + notifyDependencyChange(shouldDisableDependents()); + notifyChanged(); + } } } diff --git a/core/java/android/service/dreams/Dream.java b/core/java/android/service/dreams/Dream.java index 1aa7856..5a3fad6 100644 --- a/core/java/android/service/dreams/Dream.java +++ b/core/java/android/service/dreams/Dream.java @@ -172,11 +172,6 @@ public class Dream extends Service implements Window.Callback { @Override public void onAttachedToWindow() { - mWindow.addFlags( - WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON - | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED - ); - lightsOut(); } @Override @@ -306,7 +301,8 @@ public class Dream extends Service implements Window.Callback { // turn the lights down low final View v = mWindow.getDecorView(); if (v != null) { - v.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); + v.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE + | View.SYSTEM_UI_FLAG_FULLSCREEN); } } |
