Merge branch 'eclair' into eclair-release

This commit is contained in:
android-build SharedAccount
2009-10-07 21:00:34 -07:00
25 changed files with 210 additions and 221 deletions

View File

@@ -25550,6 +25550,17 @@
visibility="public"
>
</method>
<method name="getDefaultAdapter"
return="android.bluetooth.BluetoothAdapter"
abstract="false"
native="false"
synchronized="true"
static="true"
final="false"
deprecated="not deprecated"
visibility="public"
>
</method>
<method name="getName"
return="java.lang.String"
abstract="false"
@@ -31505,17 +31516,6 @@
visibility="public"
>
</field>
<field name="BLUETOOTH_SERVICE"
type="java.lang.String"
transient="false"
volatile="false"
value="&quot;bluetooth&quot;"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="CLIPBOARD_SERVICE"
type="java.lang.String"
transient="false"

View File

@@ -22,8 +22,6 @@ import com.google.android.collect.Maps;
import org.xmlpull.v1.XmlPullParserException;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.IBluetooth;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -182,8 +180,6 @@ class ApplicationContext extends Context {
private StatusBarManager mStatusBarManager = null;
private TelephonyManager mTelephonyManager = null;
private ClipboardManager mClipboardManager = null;
private boolean mIsBluetoothAdapterCached = false;
private BluetoothAdapter mBluetoothAdapter;
private boolean mRestricted;
private AccountManager mAccountManager; // protected by mSync
@@ -883,8 +879,6 @@ class ApplicationContext extends Context {
return getSearchManager();
} else if (SENSOR_SERVICE.equals(name)) {
return getSensorManager();
} else if (BLUETOOTH_SERVICE.equals(name)) {
return getBluetoothAdapter();
} else if (VIBRATOR_SERVICE.equals(name)) {
return getVibrator();
} else if (STATUS_BAR_SERVICE.equals(name)) {
@@ -1034,18 +1028,6 @@ class ApplicationContext extends Context {
return mSearchManager;
}
private synchronized BluetoothAdapter getBluetoothAdapter() {
if (!mIsBluetoothAdapterCached) {
mIsBluetoothAdapterCached = true;
IBinder b = ServiceManager.getService(BLUETOOTH_SERVICE);
if (b != null) {
IBluetooth service = IBluetooth.Stub.asInterface(b);
mBluetoothAdapter = new BluetoothAdapter(service);
}
}
return mBluetoothAdapter;
}
private SensorManager getSensorManager() {
synchronized (mSync) {
if (mSensorManager == null) {

View File

@@ -20,9 +20,11 @@ import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.ParcelUuid;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;
import java.io.IOException;
@@ -36,10 +38,8 @@ import java.util.UUID;
/**
* Represents the local Bluetooth adapter.
*
* <p>Use {@link android.content.Context#getSystemService} with {@link
* android.content.Context#BLUETOOTH_SERVICE} to get the default local
* Bluetooth adapter. On most Android devices there is only one local
* Bluetotoh adapter.
* <p>Use {@link #getDefaultAdapter} to get the default local Bluetooth
* adapter.
*
* <p>Use the {@link BluetoothDevice} class for operations on remote Bluetooth
* devices.
@@ -257,12 +257,40 @@ public final class BluetoothAdapter {
*/
public static final String EXTRA_LOCAL_NAME = "android.bluetooth.adapter.extra.LOCAL_NAME";
/** @hide */
public static final String BLUETOOTH_SERVICE = "bluetooth";
private static final int ADDRESS_LENGTH = 17;
/**
* Lazyily initialized singleton. Guaranteed final after first object
* constructed.
*/
private static BluetoothAdapter sAdapter;
private final IBluetooth mService;
/**
* Do not use this constructor. Use Context.getSystemService() instead.
* Get a handle to the default local Bluetooth adapter.
* <p>Currently Android only supports one Bluetooth adapter, but the API
* could be extended to support more. This will always return the default
* adapter.
* @return the default local adapter, or null if Bluetooth is not supported
* on this hardware platform
*/
public static synchronized BluetoothAdapter getDefaultAdapter() {
if (sAdapter == null) {
IBinder b = ServiceManager.getService(BluetoothAdapter.BLUETOOTH_SERVICE);
if (b != null) {
IBluetooth service = IBluetooth.Stub.asInterface(b);
sAdapter = new BluetoothAdapter(service);
}
}
return sAdapter;
}
/**
* Use {@link #getDefaultAdapter} to get the BluetoothAdapter instance.
* @hide
*/
public BluetoothAdapter(IBluetooth service) {

View File

@@ -18,7 +18,6 @@ package android.bluetooth;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.content.Context;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
@@ -328,7 +327,7 @@ public final class BluetoothDevice implements Parcelable {
/*package*/ static IBluetooth getService() {
synchronized (BluetoothDevice.class) {
if (sService == null) {
IBinder b = ServiceManager.getService(Context.BLUETOOTH_SERVICE);
IBinder b = ServiceManager.getService(BluetoothAdapter.BLUETOOTH_SERVICE);
if (b == null) {
throw new RuntimeException("Bluetooth service not available");
}

View File

@@ -1217,14 +1217,6 @@ public abstract class Context {
* @see android.hardware.SensorManager
*/
public static final String SENSOR_SERVICE = "sensor";
/**
* Use with {@link #getSystemService} to retrieve a {@link
* android.bluetooth.BluetoothAdapter} for using Bluetooth.
*
* @see #getSystemService
* @see android.bluetooth.BluetoothAdapter
*/
public static final String BLUETOOTH_SERVICE = "bluetooth";
/**
* Use with {@link #getSystemService} to retrieve a
* com.android.server.WallpaperService for accessing wallpapers.

View File

@@ -137,7 +137,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
throw new RuntimeException("Could not init BluetoothA2dpService");
}
mAdapter = (BluetoothAdapter) context.getSystemService(Context.BLUETOOTH_SERVICE);
mAdapter = BluetoothAdapter.getDefaultAdapter();
mIntentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
mIntentFilter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);

View File

@@ -154,7 +154,7 @@ public class BluetoothService extends IBluetooth.Stub {
}
public synchronized void initAfterRegistration() {
mAdapter = (BluetoothAdapter) mContext.getSystemService(Context.BLUETOOTH_SERVICE);
mAdapter = BluetoothAdapter.getDefaultAdapter();
mEventLoop = new BluetoothEventLoop(mContext, mAdapter, this);
}

View File

@@ -32,6 +32,7 @@ import android.os.RemoteException;
import android.os.Power;
import android.os.ServiceManager;
import android.os.SystemClock;
import com.android.internal.telephony.ITelephony;
import android.util.Log;
import android.view.WindowManager;
@@ -91,7 +92,10 @@ public final class ShutdownThread extends Thread {
.setNegativeButton(com.android.internal.R.string.no, null)
.create();
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
if (!context.getResources().getBoolean(
com.android.internal.R.bool.config_sf_slowBlur)) {
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
}
dialog.show();
} else {
beginShutdownSequence(context);
@@ -111,7 +115,10 @@ public final class ShutdownThread extends Thread {
pd.setIndeterminate(true);
pd.setCancelable(false);
pd.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
pd.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
if (!context.getResources().getBoolean(
com.android.internal.R.bool.config_sf_slowBlur)) {
pd.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
}
pd.show();
@@ -181,7 +188,7 @@ public final class ShutdownThread extends Thread {
ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
final IBluetooth bluetooth =
IBluetooth.Stub.asInterface(ServiceManager.checkService(
Context.BLUETOOTH_SERVICE));
BluetoothAdapter.BLUETOOTH_SERVICE));
try {
bluetoothOff = bluetooth == null ||

View File

@@ -4,31 +4,39 @@
<!-- various string resources for Contacts -->
<string-array name="common_nicknames">
<item>Abigail, Abbie, Gail, Gayle</item>
<item>Abe, Abraham</item>
<item>Aggie, Agatha, Agnes</item>
<item>Albert, Al, Bert, Bertie</item>
<item>Alexander, Al, Alex, Lex, Sasha</item>
<item>Alexandra, Al, Alex, Allie, Ally, Lex, Lexie, Sandra, Sandy, Sasha</item>
<item>Alexander, Al, Alec, Alex, Lex, Sasha</item>
<item>Alexandra, Al, Allie, Ally, Lex, Lexie, Sandra, Sandy, Sasha</item>
<item>Alf, Alfred, Alfredo, Alfie</item>
<item>Alice, Allie, Ally</item>
<item>Alison, Allie, Ally</item>
<item>Allison, Allie, Ally</item>
<item>Amanda, Mandi, Mandy</item>
<item>Andrea, Andie</item>
<item>Andrew, Andy, Drew</item>
<item>Anne, Annie, Annette</item>
<item>Anthony, Tony, Toni, Tone</item>
<item>Arthur, Art, Arty</item>
<item>Barbara, Babs, Barb, Barbie</item>
<item>Benjamin, Ben, Benji, Benny</item>
<item>Bernard, Bern, Bernie</item>
<item>Bernard, Bern, Bernie, Barnie</item>
<item>Bertram, Bert, Bertie</item>
<item>Bradly, Brad</item>
<item>Calvin, Cal</item>
<item>Catherine, Cat, Cate, Cath, Catie, Cathy, Kat, Kate, Katie, Kathy</item>
<item>Carrie, Caroline, Carolyn</item>
<item>Charles, Chuck, Chaz, Charlie, Buck</item>
<item>Christine, Chris, Chrissy, Chrissie</item>
<item>Christine, Chrissy, Chrissie</item>
<item>Christopher, Chris</item>
<item>Clinton, Clint</item>
<item>Cynthia, Cindy, Cynth</item>
<item>Daniel, Dan, Danny</item>
<item>David, Dave</item>
<item>Deborah, Deb, Debbie</item>
<item>Dennis, Den, Denny, Dean</item>
<item>Dennis, Den, Denny</item>
<item>Dolores, Dolly</item>
<item>Donald, Don, Donny</item>
<item>Donnatella, Donna</item>
@@ -41,22 +49,21 @@
<item>Elizabeth, Beth, Bess, Bessie, Betsy, Betty, Bette, Eliza, Lisa, Liza, Liz</item>
<item>Emily, Em, Ems, Emmy</item>
<item>Emma, Em, Ems, Emmy</item>
<item>Erica, Rikki, Rikkie, Ricky</item>
<item>Eugene, Gene</item>
<item>Fannie, Fanny</item>
<item>Florence, Flo</item>
<item>Frances, Fran, Francie</item>
<item>Francis, Fran, Frank</item>
<item>Francis, Fran, Frank, Frankie</item>
<item>Frederick, Fred, Freddy</item>
<item>Gabriel, Gabe</item>
<item>Geoffrey, Jeff</item>
<item>Gerald, Gerry</item>
<item>Gerard, Gerry</item>
<item>Gregory, Greg</item>
<item>Harold, Hal, Hank, Harry</item>
<item>Gregory, Greg, Gregg</item>
<item>Harold, Hal, Harry</item>
<item>Henry, Hal, Hank, Harry</item>
<item>Herbert, Bert, Bertie</item>
<item>Irving, Irv</item>
<item>Isabella, Isa, Izzy</item>
<item>Isabella, Isa, Izzy, Bella</item>
<item>Jacob, Jake</item>
<item>Jacqueline, Jackie</item>
<item>James, Jim, Jimmy, Jamie, Jock</item>
@@ -68,8 +75,9 @@
<item>Jennifer, Jen, Jenny</item>
<item>Jerome, Jerry</item>
<item>Jessica, Jessie</item>
<item>John, Jack, Jacky, Johnny, Jon</item>
<item>Jonathan, Jon, John</item>
<item>John, Johnny, Jon</item>
<item>Jack, Jacky</item>
<item>Jonathan, Jon</item>
<item>Joseph, Joe, Joey</item>
<item>Joshua, Josh</item>
<item>Kaitlyn, Cat, Cate, Catie, Cath, Cathy, Kat, Kate, Katie, Kathy</item>
@@ -78,17 +86,20 @@
<item>Katrina, Cat, Cate, Catie, Cath, Cathy, Kat, Kate, Katie, Kathy</item>
<item>Kenneth, Ken</item>
<item>Kevin, Kev</item>
<item>Kim, Kimberly</item>
<item>Laura, Lauri, Laurie</item>
<item>Lauren, Lauri, Laurie</item>
<item>Laurence, Larry, Lauri, Laurie</item>
<item>Lawrence, Larry, Lauri, Laurie</item>
<item>Lawrence, Larry</item>
<item>Leonard, Leo, Len, Lenny</item>
<item>Leopold, Leo, Len, Lenny</item>
<item>Madeline, Maddie, Maddy</item>
<item>Margaret, Marge, Marg, Maggie, Mags, Meg, Peggy</item>
<item>Margaret, Marge, Marg, Maggie, Mags, Meg, Peggy, Greta, Gretchen</item>
<item>Martin, Martie, Marty</item>
<item>Matthew, Matt, Mattie</item>
<item>Maureen, Mo</item>
<item>Maurice, Mo</item>
<item>Maxwell, Max</item>
<item>Maximilian, Maxim, Max</item>
<item>Megan, Meg</item>
<item>Michael, Mickey, Mick, Mike, Mikey</item>
<item>Morris, Mo</item>
@@ -96,16 +107,17 @@
<item>Nathan, Nat, Nate</item>
<item>Nathaniel, Nat, Nate</item>
<item>Nicholas, Nick</item>
<item>Nicole, Nicky, Nickie, Nikky</item>
<item>Pamela, Pam</item>
<item>Patricia, Pat, Patsy, Patty, Trish, Tricia</item>
<item>Patrick, Paddy, Pat, Patty, Patter, Rick, Ricky</item>
<item>Patrick, Pat, Patter</item>
<item>Penelope, Penny</item>
<item>Peter, Pete</item>
<item>Raymond, Ray</item>
<item>Philip, Phil</item>
<item>Rebecca, Becca</item>
<item>Rebecca, Becca, Becky</item>
<item>Richard, Rick, Rich, Dick</item>
<item>Robert, Bob, Rob, Robbie, Bobby, Rab</item>
<item>Roberta, Bobbie</item>
<item>Rodney. Rod</item>
<item>Ronald, Ron, Ronnie</item>
<item>Rosemary, Rosie, Rose</item>
@@ -120,7 +132,8 @@
<item>Stuart, Stu</item>
<item>Susan, Sue, Susie, Suzie</item>
<item>Suzanne, Sue, Susie, Suzie</item>
<item>Teresa, Terrie, Terry</item>
<item>Tamara, Tammy</item>
<item>Theresa, Teresa</item>
<item>Theodora, Teddie, Thea, Theo</item>
<item>Theodore, Ted, Teddy, Theo</item>
<item>Thomas, Tom, Thom, Tommy</item>

View File

@@ -26,6 +26,11 @@
strictly needed. -->
<bool name="config_sf_limitedAlpha">false</bool>
<!-- Flag indicating whether the surface flinger is inefficient
at performing a blur. Used by parts of the UI to turn off
the blur effect where it isn't worth the performance hit. -->
<bool name="config_sf_slowBlur">false</bool>
<!-- The duration (in milliseconds) of a short animation. -->
<integer name="config_shortAnimTime">150</integer>

View File

@@ -290,6 +290,11 @@ public class SimpleMesh extends BaseObj {
}
public void addTriangle(int idx1, int idx2, int idx3) {
if((idx1 >= mVtxCount) || (idx1 < 0) ||
(idx2 >= mVtxCount) || (idx2 < 0) ||
(idx3 >= mVtxCount) || (idx3 < 0)) {
throw new IllegalStateException("Index provided greater than vertex count.");
}
if ((mIndexCount + 3) >= mIndexData.length) {
short t[] = new short[mIndexData.length * 2];
System.arraycopy(mIndexData, 0, t, 0, mIndexData.length);

View File

@@ -289,6 +289,7 @@ public:
void setStatus(status_t status);
status_t reallocate();
status_t assertReallocate(int buffer);
int32_t getQueuedCount() const;
Region getDirtyRegion(int buffer) const;

View File

@@ -1,48 +0,0 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_SURFACE_FLINGER_SYNCHRO_H
#define ANDROID_SURFACE_FLINGER_SYNCHRO_H
#include <stdint.h>
#include <sys/types.h>
#include <utils/Errors.h>
#include <ui/ISurfaceComposer.h>
namespace android {
class SurfaceFlinger;
class SurfaceFlingerSynchro
{
public:
// client constructor
SurfaceFlingerSynchro(const sp<ISurfaceComposer>& flinger);
~SurfaceFlingerSynchro();
// signal surfaceflinger for some work
status_t signal();
private:
friend class SurfaceFlinger;
sp<ISurfaceComposer> mSurfaceComposer;
};
}; // namespace android
#endif // ANDROID_SURFACE_FLINGER_SYNCHRO_H

View File

@@ -153,7 +153,7 @@ private:
SharedClient* mControl;
sp<IMemoryHeap> mControlMemory;
sp<ISurfaceFlingerClient> mClient;
SurfaceFlingerSynchro* mSignalServer;
sp<ISurfaceComposer> mSignalServer;
};
}; // namespace android

View File

@@ -99,6 +99,7 @@ public:
uint32_t getMessageToClient(void *data, size_t *receiveLen, size_t bufferLen, bool wait);
bool sendMessageToClient(void *data, uint32_t cmdID, size_t len, bool waitForSpace);
bool runScript(Script *s, uint32_t launchID);
void initToClient();
void deinitToClient();
@@ -212,7 +213,6 @@ private:
void initEGL();
bool runScript(Script *s, uint32_t launchID);
bool runRootScript();
static void * threadProc(void *);

View File

@@ -1008,6 +1008,13 @@ static uint32_t SC_toClient(void *data, int cmdID, int len, int waitForSpace)
return rsc->sendMessageToClient(data, cmdID, len, waitForSpace != 0);
}
static void SC_scriptCall(int scriptID)
{
GET_TLS();
rsc->runScript((Script *)scriptID, 0);
}
//////////////////////////////////////////////////////////////////////////////
// Class implementation
//////////////////////////////////////////////////////////////////////////////
@@ -1289,6 +1296,9 @@ ScriptCState::SymbolTable_t ScriptCState::gSyms[] = {
{ "debugHexI32", (void *)&SC_debugHexI32,
"void", "(void *, int)" },
{ "scriptCall", (void *)&SC_scriptCall,
"void", "(int)" },
{ NULL, NULL, NULL, NULL }
};

View File

@@ -454,14 +454,16 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
// recompute visible region
recomputeVisibleRegions = true;
// we now have the correct size, unfreeze the screen
mFreezeLock.clear();
}
// we now have the correct size, unfreeze the screen
mFreezeLock.clear();
}
// FIXME: signal an event if we have more buffers waiting
// mFlinger->signalEvent();
if (lcblk->getQueuedCount()) {
// signal an event if we have more buffers waiting
mFlinger->signalEvent();
}
if (!mPostedDirtyRegion.isEmpty()) {
reloadTexture( mPostedDirtyRegion );

View File

@@ -27,8 +27,7 @@ LOCAL_SRC_FILES:= \
Region.cpp \
SharedBufferStack.cpp \
Surface.cpp \
SurfaceComposerClient.cpp \
SurfaceFlingerSynchro.cpp
SurfaceComposerClient.cpp
LOCAL_SHARED_LIBRARIES := \
libcutils \

View File

@@ -394,6 +394,12 @@ status_t SharedBufferServer::reallocate()
return NO_ERROR;
}
int32_t SharedBufferServer::getQueuedCount() const
{
SharedBufferStack& stack( *mSharedStack );
return stack.queued;
}
status_t SharedBufferServer::assertReallocate(int buffer)
{
ReallocateCondition condition(this, buffer);

View File

@@ -746,6 +746,8 @@ status_t Surface::getBufferLocked(int index, int usage)
currentBuffer->setIndex(index);
mNeedFullUpdate = true;
}
} else {
err = err<0 ? err : NO_MEMORY;
}
}
return err;

View File

@@ -42,7 +42,6 @@
#include <private/ui/LayerState.h>
#include <private/ui/SharedBufferStack.h>
#include <private/ui/SurfaceFlingerSynchro.h>
#define VERBOSE(...) ((void)0)
//#define VERBOSE LOGD
@@ -155,7 +154,6 @@ void SurfaceComposerClient::_init(
{
VERBOSE("Creating client %p, conn %p", this, conn.get());
mSignalServer = 0;
mPrebuiltLayerState = 0;
mTransactionOpen = 0;
mStatus = NO_ERROR;
@@ -168,7 +166,7 @@ void SurfaceComposerClient::_init(
}
mControlMemory = mClient->getControlBlock();
mSignalServer = new SurfaceFlingerSynchro(sm);
mSignalServer = sm;
mControl = static_cast<SharedClient *>(mControlMemory->getBase());
}
@@ -225,7 +223,6 @@ void SurfaceComposerClient::dispose()
Mutex::Autolock _lg(gLock);
Mutex::Autolock _lm(mLock);
delete mSignalServer;
mSignalServer = 0;
if (mClient != 0) {

View File

@@ -1,42 +0,0 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdint.h>
#include <private/ui/SurfaceFlingerSynchro.h>
namespace android {
// ---------------------------------------------------------------------------
SurfaceFlingerSynchro::SurfaceFlingerSynchro(const sp<ISurfaceComposer>& flinger)
: mSurfaceComposer(flinger)
{
}
SurfaceFlingerSynchro::~SurfaceFlingerSynchro()
{
}
status_t SurfaceFlingerSynchro::signal()
{
mSurfaceComposer->signal();
return NO_ERROR;
}
// ---------------------------------------------------------------------------
}; // namespace android

View File

@@ -43,8 +43,8 @@ import android.provider.Settings;
/**
* This class implements a service to monitor the amount of disk storage space
* on the device. If the free storage on device is less than a tunable threshold value
* (default is 10%. this value is a gservices parameter) a low memory notification is
* displayed to alert the user. If the user clicks on the low memory notification the
* (default is 10%. this value is a gservices parameter) a low memory notification is
* displayed to alert the user. If the user clicks on the low memory notification the
* Application Manager application gets launched to let the user free storage space.
* Event log events:
* A low memory event with the free storage on device in bytes is logged to the event log
@@ -68,32 +68,35 @@ class DeviceStorageMonitorService extends Binder {
private static final int EVENT_LOG_FREE_STORAGE_LEFT = 2746;
private static final long DEFAULT_DISK_FREE_CHANGE_REPORTING_THRESHOLD = 2 * 1024 * 1024; // 2MB
private static final long DEFAULT_CHECK_INTERVAL = MONITOR_INTERVAL*60*1000;
private long mFreeMem;
private long mFreeMem; // on /data
private long mLastReportedFreeMem;
private long mLastReportedFreeMemTime;
private boolean mLowMemFlag=false;
private Context mContext;
private ContentResolver mContentResolver;
long mBlkSize;
long mTotalMemory;
StatFs mFileStats;
private static final String DATA_PATH="/data";
long mThreadStartTime = -1;
boolean mClearSucceeded = false;
boolean mClearingCache;
private long mTotalMemory; // on /data
private StatFs mDataFileStats;
private StatFs mSystemFileStats;
private StatFs mCacheFileStats;
private static final String DATA_PATH = "/data";
private static final String SYSTEM_PATH = "/system";
private static final String CACHE_PATH = "/cache";
private long mThreadStartTime = -1;
private boolean mClearSucceeded = false;
private boolean mClearingCache;
private Intent mStorageLowIntent;
private Intent mStorageOkIntent;
private CachePackageDataObserver mClearCacheObserver;
private static final int _TRUE = 1;
private static final int _FALSE = 0;
/**
* This string is used for ServiceManager access to this class.
*/
static final String SERVICE = "devicestoragemonitor";
/**
* Handler that checks the amount of disk space on the device and sends a
* Handler that checks the amount of disk space on the device and sends a
* notification if the device runs low on disk space
*/
Handler mHandler = new Handler() {
@@ -107,7 +110,7 @@ class DeviceStorageMonitorService extends Binder {
checkMemory(msg.arg1 == _TRUE);
}
};
class CachePackageDataObserver extends IPackageDataObserver.Stub {
public void onRemoveCompleted(String packageName, boolean succeeded) {
mClearSucceeded = succeeded;
@@ -115,12 +118,17 @@ class DeviceStorageMonitorService extends Binder {
if(localLOGV) Log.i(TAG, " Clear succeeded:"+mClearSucceeded
+", mClearingCache:"+mClearingCache+" Forcing memory check");
postCheckMemoryMsg(false, 0);
}
}
}
private final void restatDataDir() {
mFileStats.restat(DATA_PATH);
mFreeMem = mFileStats.getAvailableBlocks()*mBlkSize;
try {
mDataFileStats.restat(DATA_PATH);
mFreeMem = (long) mDataFileStats.getAvailableBlocks() *
mDataFileStats.getBlockSize();
} catch (IllegalArgumentException e) {
// use the old value of mFreeMem
}
// Allow freemem to be overridden by debug.freemem for testing
String debugFreeMem = SystemProperties.get("debug.freemem");
if (!"".equals(debugFreeMem)) {
@@ -132,10 +140,27 @@ class DeviceStorageMonitorService extends Binder {
DEFAULT_FREE_STORAGE_LOG_INTERVAL_IN_MINUTES)*60*1000;
//log the amount of free memory in event log
long currTime = SystemClock.elapsedRealtime();
if((mLastReportedFreeMemTime == 0) ||
(currTime-mLastReportedFreeMemTime) >= freeMemLogInterval) {
if((mLastReportedFreeMemTime == 0) ||
(currTime-mLastReportedFreeMemTime) >= freeMemLogInterval) {
mLastReportedFreeMemTime = currTime;
EventLog.writeEvent(EVENT_LOG_FREE_STORAGE_LEFT, mFreeMem);
long mFreeSystem = -1, mFreeCache = -1;
try {
mSystemFileStats.restat(SYSTEM_PATH);
mFreeSystem = (long) mSystemFileStats.getAvailableBlocks() *
mSystemFileStats.getBlockSize();
} catch (IllegalArgumentException e) {
// ignore; report -1
}
try {
mCacheFileStats.restat(CACHE_PATH);
mFreeCache = (long) mCacheFileStats.getAvailableBlocks() *
mCacheFileStats.getBlockSize();
} catch (IllegalArgumentException e) {
// ignore; report -1
}
mCacheFileStats.restat(CACHE_PATH);
EventLog.writeEvent(EVENT_LOG_FREE_STORAGE_LEFT,
mFreeMem, mFreeSystem, mFreeCache);
}
// Read the reporting threshold from Gservices
long threshold = Gservices.getLong(mContentResolver,
@@ -148,7 +173,7 @@ class DeviceStorageMonitorService extends Binder {
EventLog.writeEvent(EVENT_LOG_STORAGE_BELOW_THRESHOLD, mFreeMem);
}
}
private final void clearCache() {
if (mClearCacheObserver == null) {
// Lazy instantiation
@@ -165,10 +190,10 @@ class DeviceStorageMonitorService extends Binder {
mClearSucceeded = false;
}
}
private final void checkMemory(boolean checkCache) {
//if the thread that was started to clear cache is still running do nothing till its
//finished clearing cache. Ideally this flag could be modified by clearCache
//if the thread that was started to clear cache is still running do nothing till its
//finished clearing cache. Ideally this flag could be modified by clearCache
// and should be accessed via a lock but even if it does this test will fail now and
//hopefully the next time this flag will be set to the correct value.
if(mClearingCache) {
@@ -177,11 +202,11 @@ class DeviceStorageMonitorService extends Binder {
long diffTime = System.currentTimeMillis() - mThreadStartTime;
if(diffTime > (10*60*1000)) {
Log.w(TAG, "Thread that clears cache file seems to run for ever");
}
}
} else {
restatDataDir();
if (localLOGV) Log.v(TAG, "freeMemory="+mFreeMem);
//post intent to NotificationManager to display icon if necessary
long memThreshold = getMemThreshold();
if (mFreeMem < memThreshold) {
@@ -214,7 +239,7 @@ class DeviceStorageMonitorService extends Binder {
//keep posting messages to itself periodically
postCheckMemoryMsg(true, DEFAULT_CHECK_INTERVAL);
}
private void postCheckMemoryMsg(boolean clearCache, long delay) {
// Remove queued messages
mHandler.removeMessages(DEVICE_MEMORY_WHAT);
@@ -222,16 +247,16 @@ class DeviceStorageMonitorService extends Binder {
clearCache ?_TRUE : _FALSE, 0),
delay);
}
/*
* just query settings to retrieve the memory threshold.
* just query settings to retrieve the memory threshold.
* Preferred this over using a ContentObserver since Settings.Gservices caches the value
* any way
*/
private long getMemThreshold() {
int value = Settings.Gservices.getInt(
mContentResolver,
Settings.Gservices.SYS_STORAGE_THRESHOLD_PERCENTAGE,
mContentResolver,
Settings.Gservices.SYS_STORAGE_THRESHOLD_PERCENTAGE,
DEFAULT_THRESHOLD_PERCENTAGE);
if(localLOGV) Log.v(TAG, "Threshold Percentage="+value);
//evaluate threshold value
@@ -247,16 +272,17 @@ class DeviceStorageMonitorService extends Binder {
mContext = context;
mContentResolver = mContext.getContentResolver();
//create StatFs object
mFileStats = new StatFs(DATA_PATH);
//initialize block size
mBlkSize = mFileStats.getBlockSize();
mDataFileStats = new StatFs(DATA_PATH);
mSystemFileStats = new StatFs(SYSTEM_PATH);
mCacheFileStats = new StatFs(CACHE_PATH);
//initialize total storage on device
mTotalMemory = ((long)mFileStats.getBlockCount()*mBlkSize)/100L;
mTotalMemory = ((long)mDataFileStats.getBlockCount() *
mDataFileStats.getBlockSize())/100L;
mStorageLowIntent = new Intent(Intent.ACTION_DEVICE_STORAGE_LOW);
mStorageOkIntent = new Intent(Intent.ACTION_DEVICE_STORAGE_OK);
checkMemory(true);
}
/**
* This method sends a notification to NotificationManager to display
@@ -271,7 +297,7 @@ class DeviceStorageMonitorService extends Binder {
Intent lowMemIntent = new Intent(Intent.ACTION_MANAGE_PACKAGE_STORAGE);
lowMemIntent.putExtra("memory", mFreeMem);
lowMemIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
NotificationManager mNotificationMgr =
NotificationManager mNotificationMgr =
(NotificationManager)mContext.getSystemService(
Context.NOTIFICATION_SERVICE);
CharSequence title = mContext.getText(
@@ -302,7 +328,7 @@ class DeviceStorageMonitorService extends Binder {
mContext.removeStickyBroadcast(mStorageLowIntent);
mContext.sendBroadcast(mStorageOkIntent);
}
public void updateMemory() {
int callingUid = getCallingUid();
if(callingUid != Process.SYSTEM_UID) {

View File

@@ -23,6 +23,7 @@ import com.android.internal.os.SamplingProfilerIntegration;
import dalvik.system.VMRuntime;
import android.app.ActivityManagerNative;
import android.bluetooth.BluetoothAdapter;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.ContentService;
@@ -172,14 +173,14 @@ class ServerThread extends Thread {
// support Bluetooth - see bug 988521
if (SystemProperties.get("ro.kernel.qemu").equals("1")) {
Log.i(TAG, "Registering null Bluetooth Service (emulator)");
ServiceManager.addService(Context.BLUETOOTH_SERVICE, null);
ServiceManager.addService(BluetoothAdapter.BLUETOOTH_SERVICE, null);
} else if (factoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL) {
Log.i(TAG, "Registering null Bluetooth Service (factory test)");
ServiceManager.addService(Context.BLUETOOTH_SERVICE, null);
ServiceManager.addService(BluetoothAdapter.BLUETOOTH_SERVICE, null);
} else {
Log.i(TAG, "Bluetooth Service");
bluetooth = new BluetoothService(context);
ServiceManager.addService(Context.BLUETOOTH_SERVICE, bluetooth);
ServiceManager.addService(BluetoothAdapter.BLUETOOTH_SERVICE, bluetooth);
bluetooth.initAfterRegistration();
bluetoothA2dp = new BluetoothA2dpService(context, bluetooth);
ServiceManager.addService(BluetoothA2dpService.BLUETOOTH_A2DP_SERVICE,

View File

@@ -448,8 +448,7 @@ public class StatusBarPolicy {
mBluetoothData = IconData.makeIcon("bluetooth",
null, com.android.internal.R.drawable.stat_sys_data_bluetooth, 0, 0);
mBluetoothIcon = service.addIcon(mBluetoothData, null);
BluetoothAdapter adapter =
(BluetoothAdapter) mContext.getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter != null) {
mBluetoothEnabled = adapter.isEnabled();
} else {
@@ -625,15 +624,20 @@ public class StatusBarPolicy {
pixelFormat = bg.getOpacity();
}
int flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
| WindowManager.LayoutParams.FLAG_DIM_BEHIND;
if (!mContext.getResources().getBoolean(
com.android.internal.R.bool.config_sf_slowBlur)) {
flags |= WindowManager.LayoutParams.FLAG_BLUR_BEHIND;
}
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_TOAST,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
| WindowManager.LayoutParams.FLAG_BLUR_BEHIND
| WindowManager.LayoutParams.FLAG_DIM_BEHIND,
pixelFormat);
flags, pixelFormat);
// Get the dim amount from the theme
TypedArray a = mContext.obtainStyledAttributes(