Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +57 −29 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.content.res.Configuration; import android.database.ContentObserver; import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.drawable.Drawable; Loading Loading @@ -123,6 +124,8 @@ public class PhoneStatusBar extends StatusBar { private static final boolean CLOSE_PANEL_WHEN_EMPTIED = true; private boolean mShowClock; private boolean mBrightnessControl; private boolean mAutoBrightness; // fling gesture tuning parameters, scaled to display density private float mSelfExpandVelocityPx; // classic value: 2000px/s Loading Loading @@ -241,6 +244,35 @@ public class PhoneStatusBar extends StatusBar { DisplayMetrics mDisplayMetrics = new DisplayMetrics(); class SettingsObserver extends ContentObserver { SettingsObserver(Handler handler) { super(handler); } void observe() { ContentResolver resolver = mContext.getContentResolver(); resolver.registerContentObserver(Settings.System.getUriFor( Settings.System.STATUS_BAR_BRIGHTNESS_TOGGLE), false, this); resolver.registerContentObserver(Settings.System.getUriFor( Settings.System.SCREEN_BRIGHTNESS_MODE), false, this); update(); } @Override public void onChange(boolean selfChange) { update(); } public void update() { ContentResolver resolver = mContext.getContentResolver(); mBrightnessControl = Settings.System.getInt(resolver, Settings.System.STATUS_BAR_BRIGHTNESS_TOGGLE, 0) != 0; mAutoBrightness = Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS_MODE, 0) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC; } } private class ExpandedDialog extends Dialog { ExpandedDialog(Context context) { super(context, com.android.internal.R.style.Theme_Translucent_NoTitleBar); Loading Loading @@ -274,6 +306,9 @@ public class PhoneStatusBar extends StatusBar { //addIntruderView(); SettingsObserver observer = new SettingsObserver(mHandler); observer.observe(); // Lastly, call to the icon policy to install/update all the icons. mIconPolicy = new PhoneStatusBarPolicy(mContext); } Loading Loading @@ -1531,18 +1566,12 @@ public class PhoneStatusBar extends StatusBar { final int minY = statusBarSize + mCloseView.getHeight(); if (action == MotionEvent.ACTION_MOVE) { if (mAnimatingReveal && y < minY) { boolean brightnessControl = Settings.System.getInt(mStatusBarView.getContext().getContentResolver(), Settings.System.STATUS_BAR_BRIGHTNESS_TOGGLE, 0) == 1; if (brightnessControl){ if (mBrightnessControl && !mAutoBrightness) { mVelocityTracker.computeCurrentVelocity(1000); float yVel = mVelocityTracker.getYVelocity(); yVel = Math.abs(yVel); if (yVel < 50.0f) { if (mLinger > 20) { Context context = mStatusBarView.getContext(); boolean autoBrightness = Settings.System.getInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, 0) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC; if (!autoBrightness) { float x = (float) event.getRawX(); int newBrightness = (int) Math.round(((x / mScreenWidth) * android.os.Power.BRIGHTNESS_ON)); newBrightness = Math.min(newBrightness, android.os.Power.BRIGHTNESS_ON); Loading @@ -1551,13 +1580,12 @@ public class PhoneStatusBar extends StatusBar { IPowerManager power = IPowerManager.Stub.asInterface(ServiceManager.getService("power")); if (power != null) { power.setBacklightBrightness(newBrightness); Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, Settings.System.putInt(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, newBrightness); } } catch (RemoteException e) { Slog.w(TAG, "Setting Brightness failed: " + e); } } } else { mLinger++; } Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +57 −29 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.content.res.Configuration; import android.database.ContentObserver; import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.drawable.Drawable; Loading Loading @@ -123,6 +124,8 @@ public class PhoneStatusBar extends StatusBar { private static final boolean CLOSE_PANEL_WHEN_EMPTIED = true; private boolean mShowClock; private boolean mBrightnessControl; private boolean mAutoBrightness; // fling gesture tuning parameters, scaled to display density private float mSelfExpandVelocityPx; // classic value: 2000px/s Loading Loading @@ -241,6 +244,35 @@ public class PhoneStatusBar extends StatusBar { DisplayMetrics mDisplayMetrics = new DisplayMetrics(); class SettingsObserver extends ContentObserver { SettingsObserver(Handler handler) { super(handler); } void observe() { ContentResolver resolver = mContext.getContentResolver(); resolver.registerContentObserver(Settings.System.getUriFor( Settings.System.STATUS_BAR_BRIGHTNESS_TOGGLE), false, this); resolver.registerContentObserver(Settings.System.getUriFor( Settings.System.SCREEN_BRIGHTNESS_MODE), false, this); update(); } @Override public void onChange(boolean selfChange) { update(); } public void update() { ContentResolver resolver = mContext.getContentResolver(); mBrightnessControl = Settings.System.getInt(resolver, Settings.System.STATUS_BAR_BRIGHTNESS_TOGGLE, 0) != 0; mAutoBrightness = Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS_MODE, 0) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC; } } private class ExpandedDialog extends Dialog { ExpandedDialog(Context context) { super(context, com.android.internal.R.style.Theme_Translucent_NoTitleBar); Loading Loading @@ -274,6 +306,9 @@ public class PhoneStatusBar extends StatusBar { //addIntruderView(); SettingsObserver observer = new SettingsObserver(mHandler); observer.observe(); // Lastly, call to the icon policy to install/update all the icons. mIconPolicy = new PhoneStatusBarPolicy(mContext); } Loading Loading @@ -1531,18 +1566,12 @@ public class PhoneStatusBar extends StatusBar { final int minY = statusBarSize + mCloseView.getHeight(); if (action == MotionEvent.ACTION_MOVE) { if (mAnimatingReveal && y < minY) { boolean brightnessControl = Settings.System.getInt(mStatusBarView.getContext().getContentResolver(), Settings.System.STATUS_BAR_BRIGHTNESS_TOGGLE, 0) == 1; if (brightnessControl){ if (mBrightnessControl && !mAutoBrightness) { mVelocityTracker.computeCurrentVelocity(1000); float yVel = mVelocityTracker.getYVelocity(); yVel = Math.abs(yVel); if (yVel < 50.0f) { if (mLinger > 20) { Context context = mStatusBarView.getContext(); boolean autoBrightness = Settings.System.getInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, 0) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC; if (!autoBrightness) { float x = (float) event.getRawX(); int newBrightness = (int) Math.round(((x / mScreenWidth) * android.os.Power.BRIGHTNESS_ON)); newBrightness = Math.min(newBrightness, android.os.Power.BRIGHTNESS_ON); Loading @@ -1551,13 +1580,12 @@ public class PhoneStatusBar extends StatusBar { IPowerManager power = IPowerManager.Stub.asInterface(ServiceManager.getService("power")); if (power != null) { power.setBacklightBrightness(newBrightness); Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, Settings.System.putInt(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, newBrightness); } } catch (RemoteException e) { Slog.w(TAG, "Setting Brightness failed: " + e); } } } else { mLinger++; } Loading