summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/provider/Settings.java12
-rw-r--r--core/java/android/widget/AbsListView.java20
-rw-r--r--services/java/com/android/server/LightsService.java16
-rw-r--r--services/java/com/android/server/NotificationManagerService.java6
-rw-r--r--services/java/com/android/server/status/StatusBarService.java21
-rw-r--r--services/java/com/android/server/status/widget/FlashlightButton.java103
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java8
7 files changed, 66 insertions, 120 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 758b65b..0bc241e 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -2272,6 +2272,12 @@ public final class Settings {
public static final String EXPANDED_VIEW_WIDGET = "expanded_view_widget";
/**
+ * Whether to hide the notification screen after clicking on a widget button
+ * @hide
+ */
+ public static final String EXPANDED_HIDE_ONCHANGE = "expanded_hide_onchange";
+
+ /**
* Notification Indicator Color
* @hide
*/
@@ -2390,6 +2396,12 @@ public final class Settings {
public static final String LOCKSCREEN_GESTURES_COLOR = "lockscreen_gestures_color";
/**
+ * Torch state (flashlight)
+ * @hide
+ */
+ public static final String TORCH_STATE = "torch_state";
+
+ /**
* Settings to backup. This is here so that it's in the same place as the settings
* keys and easy to update.
* @hide
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 39d2387..f52e00b 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -1967,7 +1967,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
// Check if we have moved far enough that it looks more like a
// scroll than a tap
final int distance = Math.abs(deltaY);
- final boolean overscroll = mScrollY != 0;
+ final boolean overscroll = mScrollY != 0 && (getOverscrollMode() != OVERSCROLL_NEVER);
if (overscroll || distance > mTouchSlop) {
createScrollingCache();
mTouchMode = overscroll ? TOUCH_MODE_OVERSCROLL : TOUCH_MODE_SCROLL;
@@ -2147,15 +2147,17 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
int motionPosition = findMotionRow(y);
if (motionPosition >= 0) {
final View motionView = getChildAt(motionPosition - mFirstPosition);
- // Apply overscroll
- final int motionViewRealTop = motionView.getTop();
-
- int overscroll = -incrementalDeltaY -
+ if (getOverscrollMode() != OVERSCROLL_NEVER) {
+ // Apply overscroll
+ final int motionViewRealTop = motionView.getTop();
+
+ int overscroll = -incrementalDeltaY -
(motionViewRealTop - mMotionViewOriginalTop);
- overscrollBy(0, overscroll, 0, mScrollY, 0, 0,
- 0, getOverscrollMax(), true);
- mTouchMode = TOUCH_MODE_OVERSCROLL;
- invalidate();
+ overscrollBy(0, overscroll, 0, mScrollY, 0, 0,
+ 0, getOverscrollMax(), true);
+ mTouchMode = TOUCH_MODE_OVERSCROLL;
+ invalidate();
+ }
mMotionViewOriginalTop = motionView.getTop();
}
mMotionY = y;
diff --git a/services/java/com/android/server/LightsService.java b/services/java/com/android/server/LightsService.java
index 7c0a80e..c70aab9 100644
--- a/services/java/com/android/server/LightsService.java
+++ b/services/java/com/android/server/LightsService.java
@@ -109,19 +109,19 @@ public class LightsService {
public void pulse(int color, int onMS) {
synchronized (this) {
- if (mColor == 0 && !mFlashing) {
+ if (mColor == 0 && !mFlashing) {
setLightLocked(color, LIGHT_FLASH_HARDWARE, onMS, 1000, BRIGHTNESS_MODE_USER);
mH.sendMessageDelayed(Message.obtain(mH, 1, this), onMS);
}
}
}
- public void notificationPulse(int color, int onMs, int offMs) {
- synchronized (this) {
- setLightLocked(color, LIGHT_FLASH_TIMED, onMs, 1000, BRIGHTNESS_MODE_USER);
- mH.sendMessageDelayed(Message.obtain(mH, 1, this), onMs);
- }
- }
+ public void notificationPulse(int color, int onMs, int offMs) {
+ synchronized (this) {
+ setLightLocked(color, LIGHT_FLASH_TIMED, onMs, offMs, BRIGHTNESS_MODE_USER);
+ mH.sendMessageDelayed(Message.obtain(mH, 1, this), onMs);
+ }
+ }
public void turnOff() {
synchronized (this) {
@@ -216,7 +216,7 @@ public class LightsService {
@Override
public void handleMessage(Message msg) {
Light light = (Light)msg.obj;
- light.stopFlashing();
+ light.turnOff();
}
};
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index 8207146..7534070 100644
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -42,6 +42,7 @@ import android.media.AudioManager;
import android.net.Uri;
import android.os.BatteryManager;
import android.os.Binder;
+import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
@@ -1396,6 +1397,7 @@ class NotificationManagerService extends INotificationManager.Stub {
}
private void updateRGBLightsLocked() {
+ boolean SHOLES_DEVICE = Build.DEVICE.contains("sholes");
int mPulseScreen = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.TRACKBALL_SCREEN_ON, 0);
int mSuccession = Settings.System.getInt(mContext.getContentResolver(),
@@ -1413,6 +1415,10 @@ class NotificationManagerService extends INotificationManager.Stub {
mPulseAllColor = 0;
}
+ if (SHOLES_DEVICE) {
+ mBlendColor = 0;
+ }
+
// Battery low always shows, other states only show if charging.
if (mBatteryLow) {
if (mBatteryCharging) {
diff --git a/services/java/com/android/server/status/StatusBarService.java b/services/java/com/android/server/status/StatusBarService.java
index 88de4c9..18154a5 100644
--- a/services/java/com/android/server/status/StatusBarService.java
+++ b/services/java/com/android/server/status/StatusBarService.java
@@ -286,6 +286,7 @@ public class StatusBarService extends IStatusBar.Stub
int mDisabled = 0;
private HashMap<String,PowerButton> mUsedPowerButtons = new HashMap<String,PowerButton>();
+ private boolean mHideOnPowerButtonChange = false;
/**
* Construct the service, add the status bar view to the window manager
@@ -1927,6 +1928,9 @@ public class StatusBarService extends IStatusBar.Stub
PowerButton btn = mUsedPowerButtons.get(type);
btn.toggleState(mContext);
updateWidget();
+ if(mHideOnPowerButtonChange) {
+ deactivate();
+ }
}
};
@@ -1951,6 +1955,9 @@ public class StatusBarService extends IStatusBar.Stub
setupWidget(buttonType, posi + 1);
}
updateWidget();
+
+ mHideOnPowerButtonChange = (Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.EXPANDED_HIDE_ONCHANGE, 0) == 1);
}
private void setupWidget(String buttonType, int position) {
@@ -2305,6 +2312,10 @@ public class StatusBarService extends IStatusBar.Stub
false, this);
resolver.registerContentObserver(
+ Settings.System.getUriFor(Settings.System.EXPANDED_HIDE_ONCHANGE),
+ false, this);
+
+ resolver.registerContentObserver(
Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS_MODE),
false, this);
@@ -2319,6 +2330,10 @@ public class StatusBarService extends IStatusBar.Stub
resolver.registerContentObserver(
Settings.System.getUriFor(Settings.System.WIDGET_BUTTONS),
false, this);
+
+ resolver.registerContentObserver(
+ Settings.System.getUriFor(Settings.System.TORCH_STATE),
+ false, this);
}
@Override
@@ -2354,7 +2369,11 @@ public class StatusBarService extends IStatusBar.Stub
}
} else if (uri.equals(Settings.System.getUriFor(Settings.System.WIDGET_BUTTONS))) {
setupPowerWidget();
- } else if (uri.equals(Settings.System.getUriFor(Settings.System.EXPANDED_VIEW_WIDGET))) {
+ } else if (uri.equals(Settings.System.getUriFor(
+ Settings.System.EXPANDED_HIDE_ONCHANGE))) {
+ setupPowerWidget();
+ } else if (uri.equals(Settings.System.getUriFor(
+ Settings.System.EXPANDED_VIEW_WIDGET))) {
boolean powerWidget = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.EXPANDED_VIEW_WIDGET, 1) == 1;
if(!powerWidget) {
diff --git a/services/java/com/android/server/status/widget/FlashlightButton.java b/services/java/com/android/server/status/widget/FlashlightButton.java
index eb25cf0..25b5c08 100644
--- a/services/java/com/android/server/status/widget/FlashlightButton.java
+++ b/services/java/com/android/server/status/widget/FlashlightButton.java
@@ -5,46 +5,14 @@ import com.android.server.status.widget.PowerButton;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.Intent;
import android.provider.Settings;
-import android.util.Log;
-import android.os.Build;
-
-import java.util.concurrent.Executors;
-import java.util.concurrent.ExecutorService;
-import java.lang.Thread;
-import java.lang.Runnable;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
public class FlashlightButton extends PowerButton {
Context mContext;
-
static FlashlightButton ownButton;
private static final String TAG = "FlashlightButton";
- private static int currentMode;
-
- private static FileWriter mWriter;
-
- private static ExecutorService threadExecutor;
- private static boolean runTimer = false;
-
- private static final int MODE_DEFAULT = 0;
- private static final int MODE_HIGH = 1;
- private static boolean useDeathRay = !Build.DEVICE.equals("supersonic");;
-
- private static final String FLASHLIGHT_FILE;
- private static final String FLASHLIGHT_FILE_SPOTLIGHT = "/sys/class/leds/spotlight/brightness";
- static {
- File ff = new File(FLASHLIGHT_FILE_SPOTLIGHT);
- if (ff.exists()) {
- FLASHLIGHT_FILE = FLASHLIGHT_FILE_SPOTLIGHT;
- } else {
- FLASHLIGHT_FILE = "/sys/class/leds/flashlight/brightness";
- }
- }
public void updateState(Context context) {
mContext = context;
@@ -69,80 +37,23 @@ public class FlashlightButton extends PowerButton {
}
public void toggleState(Context context) {
- currentMode = Settings.System.getInt(context.getContentResolver(), Settings.System.EXPANDED_FLASH_MODE,
- MODE_DEFAULT);
- boolean enabled = getFlashlightEnabled();
- runTimer = !enabled;
- setFlashlightEnabled(!enabled);
+ boolean bright = Settings.System.getInt(context.getContentResolver(),
+ Settings.System.EXPANDED_FLASH_MODE, 0) == 1;
+ Intent i = new Intent("net.cactii.flash2.TOGGLE_FLASHLIGHT");
+ i.putExtra("bright", bright);
+ mContext.sendBroadcast(new Intent("net.cactii.flash2.TOGGLE_FLASHLIGHT"));
}
public static FlashlightButton getInstance() {
if (ownButton==null) ownButton = new FlashlightButton();
-
return ownButton;
}
public boolean getFlashlightEnabled() {
- try {
- FileInputStream fis = new FileInputStream(FLASHLIGHT_FILE);
- int result = fis.read();
- fis.close();
- return (result != '0');
- } catch (Exception e) {
- return false;
- }
- }
-
- public void setFlashlightEnabled(boolean on) {
- try {
- if (mWriter == null) {
- mWriter = new FileWriter(FLASHLIGHT_FILE);
- }
- int value = 0;
- if (on) {
- switch (currentMode) {
- case MODE_HIGH:
- value = useDeathRay ? 3 : 128;
- break;
- default:
- value = 1;
- break;
- }
- }
- mWriter.write(String.valueOf(value));
- mWriter.flush();
- if (!on) {
- mWriter.close();
- mWriter = null;
- }
- } catch (Exception e) {
- Log.e(TAG, "setFlashlightEnabled failed", e);
- }
- startTimer(on);
- }
-
- private void startTimer(boolean on) {
- if (!on) return;
- if (threadExecutor == null) threadExecutor = Executors.newSingleThreadExecutor();
-
- flashTimer timerRun = new flashTimer();
- threadExecutor.execute(timerRun);
+ return Settings.System.getInt(mContext.getContentResolver(), Settings.System.TORCH_STATE, 0) == 1;
}
- public class flashTimer implements Runnable {
- public flashTimer() {
- }
- public void run() {
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- }
- setFlashlightEnabled(runTimer);
- }
- }
-
-
@Override
void initButton(int position) {
}
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
index 36de23b..68a6b45 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
@@ -1293,11 +1293,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
String spn;
- if (!mvnoRoaming) {
- spn = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA, "empty");
- } else {
- spn = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA, "");
- }
+ spn = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA, "empty");
String onsl = s.getOperatorAlphaLong();
String onss = s.getOperatorAlphaShort();
@@ -1316,7 +1312,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
} catch (Exception e){
}
- return gsmRoaming && !(equalsMcc && (equalsOnsl || equalsOnss));
+ return gsmRoaming && !(equalsMcc && (equalsOnsl || equalsOnss || mvnoRoaming));
}
private static int twoDigitsAt(String s, int offset) {