Merge branch 'eclair' into eclair-release

This commit is contained in:
The Android Open Source Project
2009-10-16 11:12:33 -07:00
17 changed files with 264 additions and 140 deletions

View File

@@ -309,7 +309,7 @@ status_t CameraService::Client::connect(const sp<ICameraClient>& client)
oldClient = mCameraClient;
// did the client actually change?
if (client->asBinder() == mCameraClient->asBinder()) {
if ((mCameraClient != NULL) && (client->asBinder() == mCameraClient->asBinder())) {
LOGD("Connect to the same client");
return NO_ERROR;
}
@@ -878,7 +878,10 @@ void CameraService::Client::handleShutter()
mSurface->unregisterBuffers();
}
mCameraClient->notifyCallback(CAMERA_MSG_SHUTTER, 0, 0);
sp<ICameraClient> c = mCameraClient;
if (c != NULL) {
c->notifyCallback(CAMERA_MSG_SHUTTER, 0, 0);
}
mHardware->disableMsgType(CAMERA_MSG_SHUTTER);
// It takes some time before yuvPicture callback to be called.
@@ -932,31 +935,38 @@ void CameraService::Client::handlePreviewData(const sp<IMemory>& mem)
}
}
// Is the callback enabled or not?
if (!(mPreviewCallbackFlag & FRAME_CALLBACK_FLAG_ENABLE_MASK)) {
// local copy of the callback flags
int flags = mPreviewCallbackFlag;
// is callback enabled?
if (!(flags & FRAME_CALLBACK_FLAG_ENABLE_MASK)) {
// If the enable bit is off, the copy-out and one-shot bits are ignored
LOGV("frame callback is diabled");
return;
}
// Is the received frame copied out or not?
if (mPreviewCallbackFlag & FRAME_CALLBACK_FLAG_COPY_OUT_MASK) {
LOGV("frame is copied out");
copyFrameAndPostCopiedFrame(heap, offset, size);
} else {
LOGV("frame is directly sent out without copying");
mCameraClient->dataCallback(CAMERA_MSG_PREVIEW_FRAME, mem);
}
// hold a strong pointer to the client
sp<ICameraClient> c = mCameraClient;
// Is this is one-shot only?
if (mPreviewCallbackFlag & FRAME_CALLBACK_FLAG_ONE_SHOT_MASK) {
LOGV("One-shot only, thus clear the bits and disable frame callback");
// clear callback flags if no client or one-shot mode
if ((c == NULL) || (mPreviewCallbackFlag & FRAME_CALLBACK_FLAG_ONE_SHOT_MASK)) {
LOGV("Disable preview callback");
mPreviewCallbackFlag &= ~(FRAME_CALLBACK_FLAG_ONE_SHOT_MASK |
FRAME_CALLBACK_FLAG_COPY_OUT_MASK |
FRAME_CALLBACK_FLAG_ENABLE_MASK);
// TODO: Shouldn't we use this API for non-overlay hardware as well?
if (mUseOverlay)
mHardware->disableMsgType(CAMERA_MSG_PREVIEW_FRAME);
}
// Is the received frame copied out or not?
if (flags & FRAME_CALLBACK_FLAG_COPY_OUT_MASK) {
LOGV("frame is copied");
copyFrameAndPostCopiedFrame(c, heap, offset, size);
} else {
LOGV("frame is forwarded");
c->dataCallback(CAMERA_MSG_PREVIEW_FRAME, mem);
}
}
// picture callback - postview image ready
@@ -972,7 +982,10 @@ void CameraService::Client::handlePostview(const sp<IMemory>& mem)
}
#endif
mCameraClient->dataCallback(CAMERA_MSG_POSTVIEW_FRAME, mem);
sp<ICameraClient> c = mCameraClient;
if (c != NULL) {
c->dataCallback(CAMERA_MSG_POSTVIEW_FRAME, mem);
}
mHardware->disableMsgType(CAMERA_MSG_POSTVIEW_FRAME);
}
@@ -997,7 +1010,10 @@ void CameraService::Client::handleRawPicture(const sp<IMemory>& mem)
mSurface->postBuffer(offset);
}
mCameraClient->dataCallback(CAMERA_MSG_RAW_IMAGE, mem);
sp<ICameraClient> c = mCameraClient;
if (c != NULL) {
c->dataCallback(CAMERA_MSG_RAW_IMAGE, mem);
}
mHardware->disableMsgType(CAMERA_MSG_RAW_IMAGE);
}
@@ -1014,7 +1030,10 @@ void CameraService::Client::handleCompressedPicture(const sp<IMemory>& mem)
}
#endif
mCameraClient->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE, mem);
sp<ICameraClient> c = mCameraClient;
if (c != NULL) {
c->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE, mem);
}
mHardware->disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE);
}
@@ -1032,7 +1051,10 @@ void CameraService::Client::notifyCallback(int32_t msgType, int32_t ext1, int32_
client->handleShutter();
break;
default:
client->mCameraClient->notifyCallback(msgType, ext1, ext2);
sp<ICameraClient> c = client->mCameraClient;
if (c != NULL) {
c->notifyCallback(msgType, ext1, ext2);
}
break;
}
@@ -1053,10 +1075,13 @@ void CameraService::Client::dataCallback(int32_t msgType, const sp<IMemory>& dat
return;
}
sp<ICameraClient> c = client->mCameraClient;
if (dataPtr == NULL) {
LOGE("Null data returned in data callback");
client->mCameraClient->notifyCallback(CAMERA_MSG_ERROR, UNKNOWN_ERROR, 0);
client->mCameraClient->dataCallback(msgType, NULL);
if (c != NULL) {
c->notifyCallback(CAMERA_MSG_ERROR, UNKNOWN_ERROR, 0);
c->dataCallback(msgType, NULL);
}
return;
}
@@ -1074,7 +1099,9 @@ void CameraService::Client::dataCallback(int32_t msgType, const sp<IMemory>& dat
client->handleCompressedPicture(dataPtr);
break;
default:
client->mCameraClient->dataCallback(msgType, dataPtr);
if (c != NULL) {
c->dataCallback(msgType, dataPtr);
}
break;
}
@@ -1095,15 +1122,20 @@ void CameraService::Client::dataCallbackTimestamp(nsecs_t timestamp, int32_t msg
if (client == 0) {
return;
}
sp<ICameraClient> c = client->mCameraClient;
if (dataPtr == NULL) {
LOGE("Null data returned in data with timestamp callback");
client->mCameraClient->notifyCallback(CAMERA_MSG_ERROR, UNKNOWN_ERROR, 0);
client->mCameraClient->dataCallbackTimestamp(0, msgType, NULL);
if (c != NULL) {
c->notifyCallback(CAMERA_MSG_ERROR, UNKNOWN_ERROR, 0);
c->dataCallbackTimestamp(0, msgType, NULL);
}
return;
}
client->mCameraClient->dataCallbackTimestamp(timestamp, msgType, dataPtr);
if (c != NULL) {
c->dataCallbackTimestamp(timestamp, msgType, dataPtr);
}
#if DEBUG_CLIENT_REFERENCES
if (client->getStrongCount() == 1) {
@@ -1161,7 +1193,8 @@ status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t a
return mHardware->sendCommand(cmd, arg1, arg2);
}
void CameraService::Client::copyFrameAndPostCopiedFrame(sp<IMemoryHeap> heap, size_t offset, size_t size)
void CameraService::Client::copyFrameAndPostCopiedFrame(const sp<ICameraClient>& client,
const sp<IMemoryHeap>& heap, size_t offset, size_t size)
{
LOGV("copyFrameAndPostCopiedFrame");
// It is necessary to copy out of pmem before sending this to
@@ -1186,7 +1219,7 @@ void CameraService::Client::copyFrameAndPostCopiedFrame(sp<IMemoryHeap> heap, si
LOGE("failed to allocate space for frame callback");
return;
}
mCameraClient->dataCallback(CAMERA_MSG_PREVIEW_FRAME, frame);
client->dataCallback(CAMERA_MSG_PREVIEW_FRAME, frame);
}
status_t CameraService::dump(int fd, const Vector<String16>& args)

View File

@@ -23,10 +23,9 @@
#include <ui/CameraHardwareInterface.h>
#include <ui/Camera.h>
class android::MemoryHeapBase;
namespace android {
class MemoryHeapBase;
class MediaPlayer;
// ----------------------------------------------------------------------------
@@ -151,7 +150,8 @@ private:
void handleRawPicture(const sp<IMemory>&);
void handleCompressedPicture(const sp<IMemory>&);
void copyFrameAndPostCopiedFrame(sp<IMemoryHeap> heap, size_t offset, size_t size);
void copyFrameAndPostCopiedFrame(const sp<ICameraClient>& client,
const sp<IMemoryHeap>& heap, size_t offset, size_t size);
// camera operation mode
enum camera_mode {

View File

@@ -123,7 +123,8 @@ public class AppWidgetHostView extends FrameLayout {
@Override
protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
final ParcelableSparseArray jail = (ParcelableSparseArray) container.get(generateId());
ParcelableSparseArray jail = (ParcelableSparseArray) container.get(generateId());
if (jail == null) jail = new ParcelableSparseArray();
super.dispatchRestoreInstanceState(jail);
}

View File

@@ -34,7 +34,4 @@ interface IPowerManager
// sets the brightness of the backlights (screen, keyboard, button) 0-255
void setBacklightBrightness(int brightness);
// enables or disables automatic brightness mode
void setAutoBrightness(boolean on);
}

View File

@@ -1080,6 +1080,18 @@ public final class Settings {
*/
public static final String SCREEN_BRIGHTNESS_MODE = "screen_brightness_mode";
/**
* SCREEN_BRIGHTNESS_MODE value for manual mode.
* @hide
*/
public static final int SCREEN_BRIGHTNESS_MODE_MANUAL = 0;
/**
* SCREEN_BRIGHTNESS_MODE value for manual mode.
* @hide
*/
public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1;
/**
* Control whether the process CPU usage meter should be shown.
*/

View File

@@ -2926,12 +2926,12 @@ public class WebView extends AbsoluteLayout
animateScroll);
if (mNativeClass == 0) return;
if (mShiftIsPressed) {
if (mShiftIsPressed && !animateZoom) {
if (mTouchSelection) {
nativeDrawSelectionRegion(canvas);
} else {
nativeDrawSelection(canvas, mSelectX, mSelectY,
mExtendSelection);
nativeDrawSelection(canvas, mInvActualScale, getTitleHeight(),
mSelectX, mSelectY, mExtendSelection);
}
} else if (drawCursorRing) {
if (mTouchMode == TOUCH_SHORTPRESS_START_MODE) {
@@ -4065,6 +4065,9 @@ public class WebView extends AbsoluteLayout
return true;
}
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
if (mShiftIsPressed) {
return true; // discard press if copy in progress
}
mTrackballDown = true;
if (mNativeClass == 0) {
return false;
@@ -4093,6 +4096,7 @@ public class WebView extends AbsoluteLayout
} else {
mExtendSelection = true;
}
return true; // discard press if copy in progress
}
if (DebugFlags.WEB_VIEW) {
Log.v(LOGTAG, "onTrackballEvent up ev=" + ev
@@ -5600,8 +5604,8 @@ public class WebView extends AbsoluteLayout
private native void nativeDestroy();
private native void nativeDrawCursorRing(Canvas content);
private native void nativeDrawMatches(Canvas canvas);
private native void nativeDrawSelection(Canvas content
, int x, int y, boolean extendSelection);
private native void nativeDrawSelection(Canvas content, float scale,
int offset, int x, int y, boolean extendSelection);
private native void nativeDrawSelectionRegion(Canvas content);
private native void nativeDumpDisplayTree(String urlOrNull);
private native int nativeFindAll(String findLower, String findUpper);

View File

@@ -67,7 +67,11 @@
the slider can be opened (for example, in a pocket or purse). -->
<bool name="config_bypass_keyguard_if_slider_open">true</bool>
<!-- Flag indicating whether the device supports automatic brightness mode. -->
<!-- Flag indicating whether the device supports automatic brightness mode in hardware. -->
<bool name="config_hardware_automatic_brightness_available">false</bool>
<!-- Flag indicating whether the we should enable the automatic brightness in Settings.
Software implementation will be used if config_hardware_auto_brightness_available is not set -->
<bool name="config_automatic_brightness_available">false</bool>
<!-- XXXXXX END OF RESOURCES USING WRONG NAMING CONVENTION -->

View File

@@ -29,6 +29,8 @@ using namespace android;
using namespace android::renderscript;
pthread_key_t Context::gThreadTLSKey = 0;
uint32_t Context::gThreadTLSKeyCount = 0;
pthread_mutex_t Context::gInitMutex = PTHREAD_MUTEX_INITIALIZER;
void Context::initEGL()
{
@@ -57,6 +59,7 @@ void Context::initEGL()
configAttribsPtr[0] = EGL_NONE;
rsAssert(configAttribsPtr < (configAttribs + (sizeof(configAttribs) / sizeof(EGLint))));
LOGV("initEGL start");
mEGL.mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(mEGL.mDisplay, &mEGL.mMajorVersion, &mEGL.mMinorVersion);
@@ -144,6 +147,12 @@ bool Context::runRootScript()
}
mStateFragmentStore.mLast.clear();
bool ret = runScript(mRootScript.get(), 0);
GLenum err = glGetError();
if (err != GL_NO_ERROR) {
LOGE("Pending GL Error, 0x%x", err);
}
return ret;
}
@@ -293,6 +302,8 @@ void * Context::threadProc(void *vrsc)
Context::Context(Device *dev, Surface *sur, bool useDepth)
{
pthread_mutex_lock(&gInitMutex);
dev->addContext(this);
mDev = dev;
mRunning = false;
@@ -304,16 +315,18 @@ Context::Context(Device *dev, Surface *sur, bool useDepth)
int status;
pthread_attr_t threadAttr;
if (!gThreadTLSKey) {
if (!gThreadTLSKeyCount) {
status = pthread_key_create(&gThreadTLSKey, NULL);
if (status) {
LOGE("Failed to init thread tls key.");
pthread_mutex_unlock(&gInitMutex);
return;
}
} else {
// HACK: workaround gl hang on start
exit(-1);
}
gThreadTLSKeyCount++;
pthread_mutex_unlock(&gInitMutex);
// Global init done at this point.
status = pthread_attr_init(&threadAttr);
if (status) {
@@ -355,10 +368,16 @@ Context::~Context()
int status = pthread_join(mThreadId, &res);
objDestroyOOBRun();
// Global structure cleanup.
pthread_mutex_lock(&gInitMutex);
if (mDev) {
mDev->removeContext(this);
pthread_key_delete(gThreadTLSKey);
--gThreadTLSKeyCount;
if (!gThreadTLSKeyCount) {
pthread_key_delete(gThreadTLSKey);
}
}
pthread_mutex_unlock(&gInitMutex);
objDestroyOOBDestroy();
}
@@ -419,6 +438,7 @@ void Context::setVertex(ProgramVertex *pv)
} else {
mVertex.set(pv);
}
mVertex->forceDirty();
}
void Context::assignName(ObjectBase *obj, const char *name, uint32_t len)

View File

@@ -53,6 +53,9 @@ public:
~Context();
static pthread_key_t gThreadTLSKey;
static uint32_t gThreadTLSKeyCount;
static pthread_mutex_t gInitMutex;
struct ScriptTLSStruct {
Context * mContext;
Script * mScript;

View File

@@ -44,6 +44,10 @@ protected:
ObjectBaseRef<Allocation> mConstants;
mutable bool mDirty;
public:
void forceDirty() {mDirty = true;}
};

View File

@@ -74,7 +74,7 @@ void ProgramRaster::setupGL(const Context *rsc, ProgramRasterState *state)
if (mLineSmooth) {
glEnable(GL_LINE_SMOOTH);
} else {
glEnable(GL_LINE_SMOOTH);
glDisable(GL_LINE_SMOOTH);
}
if (rsc->checkVersion1_1()) {

View File

@@ -45,7 +45,6 @@ public class SettingsHelper {
private boolean mSilent;
private boolean mVibrate;
private boolean mHasAutoBrightness;
public SettingsHelper(Context context) {
mContext = context;
@@ -54,9 +53,6 @@ public class SettingsHelper {
mContentService = ContentResolver.getContentService();
mPowerManager = IPowerManager.Stub.asInterface(
ServiceManager.getService("power"));
mHasAutoBrightness = context.getResources().getBoolean(
com.android.internal.R.bool.config_automatic_brightness_available);
}
/**
@@ -71,18 +67,6 @@ public class SettingsHelper {
public boolean restoreValue(String name, String value) {
if (Settings.System.SCREEN_BRIGHTNESS.equals(name)) {
setBrightness(Integer.parseInt(value));
} else if (Settings.System.SCREEN_BRIGHTNESS_MODE.equals(name)) {
if (mHasAutoBrightness) {
// When setting auto-brightness, must reset the brightness afterwards
try {
int curBrightness = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS);
setAutoBrightness(Integer.parseInt(value) != 0);
setBrightness(curBrightness);
} catch (Settings.SettingNotFoundException e) {
// no brightness setting at all? weird. skip this then.
}
}
} else if (Settings.System.SOUND_EFFECTS_ENABLED.equals(name)) {
setSoundEffects(Integer.parseInt(value) == 1);
} else if (Settings.Secure.LOCATION_PROVIDERS_ALLOWED.equals(name)) {
@@ -92,16 +76,6 @@ public class SettingsHelper {
return true;
}
private void setAutoBrightness(boolean value) {
if (mPowerManager != null) {
try {
mPowerManager.setAutoBrightness(value);
} catch (RemoteException e) {
// unable to reach the power manager; skip
}
}
}
private void setGpsLocation(String value) {
final String GPS = LocationManager.GPS_PROVIDER;
boolean enabled =

View File

@@ -133,7 +133,7 @@ public class HardwareService extends IHardwareService.Stub {
context.registerReceiver(mIntentReceiver, filter);
mAutoBrightnessAvailable = context.getResources().getBoolean(
com.android.internal.R.bool.config_automatic_brightness_available);
com.android.internal.R.bool.config_hardware_automatic_brightness_available);
}
protected void finalize() throws Throwable {

View File

@@ -53,6 +53,7 @@ import android.view.WindowManagerPolicy;
import static android.provider.Settings.System.DIM_SCREEN;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import static android.provider.Settings.System.STAY_ON_WHILE_PLUGGED_IN;
@@ -64,7 +65,7 @@ import java.util.Observable;
import java.util.Observer;
class PowerManagerService extends IPowerManager.Stub
implements LocalPowerManager, Watchdog.Monitor, SensorEventListener {
implements LocalPowerManager, Watchdog.Monitor {
private static final String TAG = "PowerManagerService";
static final String PARTIAL_NAME = "PowerManagerService";
@@ -189,6 +190,9 @@ class PowerManagerService extends IPowerManager.Stub
private BatteryService mBatteryService;
private SensorManager mSensorManager;
private Sensor mProximitySensor;
private Sensor mLightSensor;
private boolean mLightSensorEnabled;
private float mLightSensorValue = -1;
private boolean mDimScreen = true;
private long mNextTimeout;
private volatile int mPokey = 0;
@@ -199,6 +203,8 @@ class PowerManagerService extends IPowerManager.Stub
private long mScreenOnStartTime;
private boolean mPreventScreenOn;
private int mScreenBrightnessOverride = -1;
private boolean mHasHardwareAutoBrightness;
private boolean mAutoBrightessEnabled;
// Used when logging number and duration of touch-down cycles
private long mTotalTouchDownTime;
@@ -207,6 +213,7 @@ class PowerManagerService extends IPowerManager.Stub
// could be either static or controllable at runtime
private static final boolean mSpew = false;
private static final boolean mDebugLightSensor = false;
/*
static PrintStream mLog;
@@ -344,6 +351,9 @@ class PowerManagerService extends IPowerManager.Stub
// DIM_SCREEN
//mDimScreen = getInt(DIM_SCREEN) != 0;
// SCREEN_BRIGHTNESS_MODE
setScreenBrightnessMode(getInt(SCREEN_BRIGHTNESS_MODE));
// recalculate everything
setScreenOffTimeoutsLocked();
}
@@ -415,12 +425,17 @@ class PowerManagerService extends IPowerManager.Stub
mScreenOffIntent = new Intent(Intent.ACTION_SCREEN_OFF);
mScreenOffIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
ContentResolver resolver = mContext.getContentResolver();
mHasHardwareAutoBrightness = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_hardware_automatic_brightness_available);
ContentResolver resolver = mContext.getContentResolver();
Cursor settingsCursor = resolver.query(Settings.System.CONTENT_URI, null,
"(" + Settings.System.NAME + "=?) or ("
+ Settings.System.NAME + "=?) or ("
+ Settings.System.NAME + "=?) or ("
+ Settings.System.NAME + "=?)",
new String[]{STAY_ON_WHILE_PLUGGED_IN, SCREEN_OFF_TIMEOUT, DIM_SCREEN},
new String[]{STAY_ON_WHILE_PLUGGED_IN, SCREEN_OFF_TIMEOUT, DIM_SCREEN,
SCREEN_BRIGHTNESS_MODE},
null);
mSettings = new ContentQueryMap(settingsCursor, Settings.System.NAME, true, mHandler);
SettingsObserver settingsObserver = new SettingsObserver();
@@ -444,10 +459,6 @@ class PowerManagerService extends IPowerManager.Stub
// turn everything on
setPowerState(ALL_BRIGHT);
// set auto brightness mode to user setting
boolean brightnessMode = Settings.System.getInt(resolver, SCREEN_BRIGHTNESS_MODE, 1) != 0;
mHardware.setAutoBrightness_UNCHECKED(brightnessMode);
synchronized (mHandlerThread) {
mInitComplete = true;
mHandlerThread.notifyAll();
@@ -1164,7 +1175,7 @@ class PowerManagerService extends IPowerManager.Stub
// Finally, set the flag that prevents the screen from turning on.
// (Below, in setPowerState(), we'll check mPreventScreenOn and
// we *won't* call Power.setScreenState(true) if it's set.)
// we *won't* call setScreenStateLocked(true) if it's set.)
mPreventScreenOn = true;
} else {
// (Re)enable the screen.
@@ -1182,9 +1193,9 @@ class PowerManagerService extends IPowerManager.Stub
Log.d(TAG,
"preventScreenOn: turning on after a prior preventScreenOn(true)!");
}
int err = Power.setScreenState(true);
int err = setScreenStateLocked(true);
if (err != 0) {
Log.w(TAG, "preventScreenOn: error from Power.setScreenState(): " + err);
Log.w(TAG, "preventScreenOn: error from setScreenStateLocked(): " + err);
}
}
@@ -1239,6 +1250,14 @@ class PowerManagerService extends IPowerManager.Stub
}
};
private int setScreenStateLocked(boolean on) {
int err = Power.setScreenState(on);
if (err == 0) {
enableLightSensor(on && mAutoBrightessEnabled);
}
return err;
}
private void setPowerState(int state)
{
setPowerState(state, false, false);
@@ -1327,7 +1346,7 @@ class PowerManagerService extends IPowerManager.Stub
reallyTurnScreenOn = false;
}
if (reallyTurnScreenOn) {
err = Power.setScreenState(true);
err = setScreenStateLocked(true);
long identity = Binder.clearCallingIdentity();
try {
mBatteryStats.noteScreenBrightness(
@@ -1339,7 +1358,7 @@ class PowerManagerService extends IPowerManager.Stub
Binder.restoreCallingIdentity(identity);
}
} else {
Power.setScreenState(false);
setScreenStateLocked(false);
// But continue as if we really did turn the screen on...
err = 0;
}
@@ -1384,7 +1403,7 @@ class PowerManagerService extends IPowerManager.Stub
EventLog.writeEvent(LOG_POWER_SCREEN_STATE, 0, becauseOfUser ? 1 : 0,
mTotalTouchDownTime, mTouchCycles);
mLastTouchDown = 0;
int err = Power.setScreenState(false);
int err = setScreenStateLocked(false);
if (mScreenOnStartTime != 0) {
mScreenOnTime += SystemClock.elapsedRealtime() - mScreenOnStartTime;
mScreenOnStartTime = 0;
@@ -1802,6 +1821,14 @@ class PowerManagerService extends IPowerManager.Stub
}
}
private void lightSensorChangedLocked(float value) {
if (mDebugLightSensor) {
Log.d(TAG, "lightSensorChangedLocked " + value);
}
mLightSensorValue = value;
// more to do here
}
/**
* The user requested that we go to sleep (probably with the power button).
* This overrides all wake locks that are held.
@@ -1885,6 +1912,18 @@ class PowerManagerService extends IPowerManager.Stub
}
}
private void setScreenBrightnessMode(int mode) {
mAutoBrightessEnabled = (mode == SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
if (mHasHardwareAutoBrightness) {
// When setting auto-brightness, must reset the brightness afterwards
mHardware.setAutoBrightness_UNCHECKED(mAutoBrightessEnabled);
setBacklightBrightness((int)mScreenBrightness.curValue);
} else {
enableLightSensor(screenIsOn() && mAutoBrightessEnabled);
}
}
/** Sets the screen off timeouts:
* mKeylightDelay
* mDimDelay
@@ -2031,6 +2070,14 @@ class PowerManagerService extends IPowerManager.Stub
}
void systemReady() {
mSensorManager = new SensorManager(mHandlerThread.getLooper());
mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
// don't bother with the light sensor if auto brightness is handled in hardware
if (!mHasHardwareAutoBrightness) {
mLightSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
enableLightSensor(mAutoBrightessEnabled);
}
synchronized (mLocks) {
Log.d(TAG, "system ready!");
mDoneBooting = true;
@@ -2058,8 +2105,6 @@ class PowerManagerService extends IPowerManager.Stub
| PowerManager.FULL_WAKE_LOCK
| PowerManager.SCREEN_DIM_WAKE_LOCK;
// call getSensorManager() to make sure mProximitySensor is initialized
getSensorManager();
if (mProximitySensor != null) {
result |= PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK;
}
@@ -2098,31 +2143,19 @@ class PowerManagerService extends IPowerManager.Stub
}
}
public void setAutoBrightness(boolean on) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
mHardware.setAutoBrightness_UNCHECKED(on);
}
private SensorManager getSensorManager() {
if (mSensorManager == null) {
mSensorManager = new SensorManager(mHandlerThread.getLooper());
mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
}
return mSensorManager;
}
private void enableProximityLockLocked() {
if (mSpew) {
Log.d(TAG, "enableProximityLockLocked");
}
mSensorManager.registerListener(this, mProximitySensor, SensorManager.SENSOR_DELAY_NORMAL);
mSensorManager.registerListener(mProximityListener, mProximitySensor,
SensorManager.SENSOR_DELAY_NORMAL);
}
private void disableProximityLockLocked() {
if (mSpew) {
Log.d(TAG, "disableProximityLockLocked");
}
mSensorManager.unregisterListener(this);
mSensorManager.unregisterListener(mProximityListener);
synchronized (mLocks) {
if (mProximitySensorActive) {
mProximitySensorActive = false;
@@ -2131,32 +2164,65 @@ class PowerManagerService extends IPowerManager.Stub
}
}
public void onSensorChanged(SensorEvent event) {
long milliseconds = event.timestamp / 1000000;
synchronized (mLocks) {
float distance = event.values[0];
// compare against getMaximumRange to support sensors that only return 0 or 1
if (distance >= 0.0 && distance < PROXIMITY_THRESHOLD &&
distance < mProximitySensor.getMaximumRange()) {
if (mSpew) {
Log.d(TAG, "onSensorChanged: proximity active, distance: " + distance);
}
goToSleepLocked(milliseconds);
mProximitySensorActive = true;
private void enableLightSensor(boolean enable) {
if (mDebugLightSensor) {
Log.d(TAG, "enableLightSensor " + enable);
}
if (mSensorManager != null && mLightSensorEnabled != enable) {
mLightSensorEnabled = enable;
if (enable) {
mSensorManager.registerListener(mLightListener, mLightSensor,
SensorManager.SENSOR_DELAY_NORMAL);
} else {
// proximity sensor negative events trigger as user activity.
// temporarily set mUserActivityAllowed to true so this will work
// even when the keyguard is on.
if (mSpew) {
Log.d(TAG, "onSensorChanged: proximity inactive, distance: " + distance);
}
mProximitySensorActive = false;
forceUserActivityLocked();
mSensorManager.unregisterListener(mLightListener);
}
}
}
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// ignore
}
SensorEventListener mProximityListener = new SensorEventListener() {
public void onSensorChanged(SensorEvent event) {
long milliseconds = event.timestamp / 1000000;
synchronized (mLocks) {
float distance = event.values[0];
// compare against getMaximumRange to support sensors that only return 0 or 1
if (distance >= 0.0 && distance < PROXIMITY_THRESHOLD &&
distance < mProximitySensor.getMaximumRange()) {
if (mSpew) {
Log.d(TAG, "onSensorChanged: proximity active, distance: " + distance);
}
goToSleepLocked(milliseconds);
mProximitySensorActive = true;
} else {
// proximity sensor negative events trigger as user activity.
// temporarily set mUserActivityAllowed to true so this will work
// even when the keyguard is on.
if (mSpew) {
Log.d(TAG, "onSensorChanged: proximity inactive, distance: " + distance);
}
mProximitySensorActive = false;
forceUserActivityLocked();
}
}
}
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// ignore
}
};
SensorEventListener mLightListener = new SensorEventListener() {
public void onSensorChanged(SensorEvent event) {
synchronized (mLocks) {
int value = (int)event.values[0];
if (mDebugLightSensor) {
Log.d(TAG, "onSensorChanged: light value: " + value);
}
lightSensorChangedLocked(value);
}
}
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// ignore
}
};
}

View File

@@ -140,7 +140,7 @@ public class StatusBarService extends IStatusBar.Stub
boolean down = event.getAction() == KeyEvent.ACTION_DOWN;
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_BACK:
if (down) {
if (!down) {
StatusBarService.this.deactivate();
}
return true;
@@ -973,15 +973,24 @@ public class StatusBarService extends IStatusBar.Stub
}
void animateCollapse() {
if (SPEW) Log.d(TAG, "Animate collapse: expanded=" + mExpanded
+ " expanded visible=" + mExpandedVisible);
if (SPEW) {
Log.d(TAG, "animateCollapse(): mExpanded=" + mExpanded
+ " mExpandedVisible=" + mExpandedVisible
+ " mAnimating=" + mAnimating
+ " mAnimVel=" + mAnimVel);
}
if (!mExpandedVisible) {
return;
}
prepareTracking(mDisplay.getHeight()-1);
performFling(mDisplay.getHeight()-1, -2000.0f, true);
if (mAnimating) {
return;
}
int y = mDisplay.getHeight()-1;
prepareTracking(y);
performFling(y, -2000.0f, true);
}
void performExpand() {
@@ -1096,7 +1105,7 @@ public class StatusBarService extends IStatusBar.Stub
mTracking = true;
mVelocityTracker = VelocityTracker.obtain();
boolean opening = !mExpanded;
if (!mExpanded) {
if (opening) {
mAnimAccel = 2000.0f;
mAnimVel = 200;
mAnimY = mStatusBarView.getHeight();
@@ -1111,16 +1120,13 @@ public class StatusBarService extends IStatusBar.Stub
mAnimating = true;
mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE_REVEAL),
mCurAnimationTime);
makeExpandedVisible();
} else {
// it's open, close it?
if (mAnimating) {
mAnimating = false;
mHandler.removeMessages(MSG_ANIMATE);
}
}
if (opening) {
makeExpandedVisible();
} else {
updateExpandedViewPos(y + mViewDelta);
}
}
@@ -1547,7 +1553,7 @@ public class StatusBarService extends IStatusBar.Stub
void updateExpandedViewPos(int expandedPosition) {
if (SPEW) {
Log.d(TAG, "updateExpandedViewPos before pos=" + expandedPosition
Log.d(TAG, "updateExpandedViewPos before expandedPosition=" + expandedPosition
+ " mTrackingParams.y=" + mTrackingParams.y
+ " mTrackingPosition=" + mTrackingPosition);
}

View File

@@ -595,7 +595,8 @@ public final class GsmMmiCode extends Handler implements MmiCode {
}
int isSettingUnconditionalVoice =
((reason == CommandsInterface.CF_REASON_UNCONDITIONAL) &&
(((reason == CommandsInterface.CF_REASON_UNCONDITIONAL) ||
(reason == CommandsInterface.CF_REASON_ALL)) &&
(((serviceClass & CommandsInterface.SERVICE_CLASS_VOICE) != 0) ||
(serviceClass == CommandsInterface.SERVICE_CLASS_NONE))) ? 1 : 0;

View File

@@ -79,8 +79,7 @@ public class FileFilter {
"profiler", // profiler is not supported
"svg", // svg is not supported
"platform", // platform specific
"http", // requires local http(s) server
"fast/workers",
"http/wml",
};
static final String [] ignoreTestList = {