Merge commit 'goog/cupcake'

This commit is contained in:
The Android Open Source Project
2009-03-27 18:48:32 -07:00
6 changed files with 77 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 729 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -30,11 +30,24 @@
#include <utils/MemoryHeapBase.h>
#include <utils/MemoryBase.h>
#include <media/PVMediaRecorder.h>
#include <utils/String16.h>
#include "MediaRecorderClient.h"
namespace android {
const char* cameraPermission = "android.permission.CAMERA";
static bool checkPermission(const char* permissionString) {
#ifndef HAVE_ANDROID_OS
return true;
#endif
if (getpid() == IPCThreadState::self()->getCallingPid()) return true;
bool ok = checkCallingPermission(String16(permissionString));
if (!ok) LOGE("Request requires %s", permissionString);
return ok;
}
status_t MediaRecorderClient::setCamera(const sp<ICamera>& camera)
{
LOGV("setCamera");
@@ -60,6 +73,9 @@ status_t MediaRecorderClient::setPreviewSurface(const sp<ISurface>& surface)
status_t MediaRecorderClient::setVideoSource(int vs)
{
LOGV("setVideoSource(%d)", vs);
if (!checkPermission(cameraPermission)) {
return PERMISSION_DENIED;
}
Mutex::Autolock lock(mLock);
if (mRecorder == NULL) {
LOGE("recorder is not initialized");

View File

@@ -89,6 +89,11 @@ public class WifiService extends IWifiManager.Stub {
private int mPluggedType;
private final LockList mLocks = new LockList();
// some wifi lock statistics
private int mFullLocksAcquired;
private int mFullLocksReleased;
private int mScanLocksAcquired;
private int mScanLocksReleased;
private final IBatteryStats mBatteryStats;
@@ -1731,6 +1736,11 @@ public class WifiService extends IWifiManager.Stub {
}
}
pw.println();
pw.println("Locks acquired: " + mFullLocksAcquired + " full, " +
mScanLocksAcquired + " scan");
pw.println("Locks released: " + mFullLocksReleased + " full, " +
mScanLocksReleased + " scan");
pw.println();
pw.println("Locks held:");
mLocks.dump(pw);
}
@@ -1852,8 +1862,14 @@ public class WifiService extends IWifiManager.Stub {
long ident = Binder.clearCallingIdentity();
try {
switch(wifiLock.mLockMode) {
case (WifiManager.WIFI_MODE_FULL): mBatteryStats.noteFullWifiLockAcquired(uid);
case (WifiManager.WIFI_MODE_SCAN_ONLY): mBatteryStats.noteScanWifiLockAcquired(uid);
case WifiManager.WIFI_MODE_FULL:
++mFullLocksAcquired;
mBatteryStats.noteFullWifiLockAcquired(uid);
break;
case WifiManager.WIFI_MODE_SCAN_ONLY:
++mScanLocksAcquired;
mBatteryStats.noteScanWifiLockAcquired(uid);
break;
}
} catch (RemoteException e) {
} finally {
@@ -1882,8 +1898,14 @@ public class WifiService extends IWifiManager.Stub {
long ident = Binder.clearCallingIdentity();
try {
switch(wifiLock.mLockMode) {
case (WifiManager.WIFI_MODE_FULL): mBatteryStats.noteFullWifiLockReleased(uid);
case (WifiManager.WIFI_MODE_SCAN_ONLY): mBatteryStats.noteScanWifiLockReleased(uid);
case WifiManager.WIFI_MODE_FULL:
++mFullLocksReleased;
mBatteryStats.noteFullWifiLockReleased(uid);
break;
case WifiManager.WIFI_MODE_SCAN_ONLY:
++mScanLocksReleased;
mBatteryStats.noteScanWifiLockReleased(uid);
break;
}
} catch (RemoteException e) {
} finally {

View File

@@ -245,6 +245,13 @@ public class WifiStateTracker extends NetworkStateTracker {
private static final int RUN_STATE_RUNNING = 2;
private static final int RUN_STATE_STOPPING = 3;
private static final int RUN_STATE_STOPPED = 4;
private static final String mRunStateNames[] = {
"Starting",
"Running",
"Stopping",
"Stopped"
};
private int mRunState;
private final IBatteryStats mBatteryStats;
@@ -836,7 +843,14 @@ public class WifiStateTracker extends NetworkStateTracker {
newDetailedState = DetailedState.FAILED;
}
handleDisconnectedState(newDetailedState);
if (mRunState == RUN_STATE_RUNNING && !mIsScanOnly) {
/**
* If we were associated with a network (networkId != -1),
* assume we reached this state because of a failed attempt
* to acquire an IP address, and attempt another connection
* and IP address acquisition in RECONNECT_DELAY_MSECS
* milliseconds.
*/
if (mRunState == RUN_STATE_RUNNING && !mIsScanOnly && networkId != -1) {
sendEmptyMessageDelayed(EVENT_DEFERRED_RECONNECT, RECONNECT_DELAY_MSECS);
} else if (mRunState == RUN_STATE_STOPPING) {
synchronized (this) {
@@ -1376,13 +1390,24 @@ public class WifiStateTracker extends NetworkStateTracker {
}
}
/**
* We want to stop the driver, but if we're connected to a network,
* we first want to disconnect, so that the supplicant is always in
* a known state (DISCONNECTED) when the driver is stopped.
* @return {@code true} if the operation succeeds, which means that the
* disconnect or stop command was initiated.
*/
public synchronized boolean disconnectAndStop() {
if (mRunState != RUN_STATE_STOPPING && mRunState != RUN_STATE_STOPPED) {
// Take down any open network notifications
setNotificationVisible(false, 0, false, 0);
mRunState = RUN_STATE_STOPPING;
return WifiNative.disconnectCommand();
if (mWifiInfo.getSupplicantState() == SupplicantState.DORMANT) {
return WifiNative.stopDriverCommand();
} else {
return WifiNative.disconnectCommand();
}
} else {
/*
* The "driver-stop" wake lock normally is released from the
@@ -1574,9 +1599,14 @@ public class WifiStateTracker extends NetworkStateTracker {
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("interface ").append(mInterfaceName).
append(" runState=").append(mRunState).append(LS);
sb.append(mWifiInfo).append(LS);
sb.append("interface ").append(mInterfaceName);
sb.append(" runState=");
if (mRunState >= 1 && mRunState <= mRunStateNames.length) {
sb.append(mRunStateNames[mRunState-1]);
} else {
sb.append(mRunState);
}
sb.append(LS).append(mWifiInfo).append(LS);
sb.append(mDhcpInfo).append(LS);
sb.append("haveIpAddress=").append(mHaveIPAddress).
append(", obtainingIpAddress=").append(mObtainingIPAddress).