From 499e098f0c529f761666150db12d1907aa0ae668 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn <> Date: Fri, 27 Mar 2009 09:53:15 -0700 Subject: [PATCH 1/3] AI 143101: Fix issue # 1741546 (Put back private resources used by maps.) BUG=1741546 Automated import of CL 143101 --- core/res/res/drawable/blank_tile.png | Bin 0 -> 557 bytes core/res/res/drawable/loading_tile.png | Bin 0 -> 729 bytes core/res/res/drawable/no_tile_128.png | Bin 0 -> 1392 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 core/res/res/drawable/blank_tile.png create mode 100644 core/res/res/drawable/loading_tile.png create mode 100644 core/res/res/drawable/no_tile_128.png diff --git a/core/res/res/drawable/blank_tile.png b/core/res/res/drawable/blank_tile.png new file mode 100644 index 0000000000000000000000000000000000000000..63b9296b1276b8b21ab93c7471112fb5770b08eb GIT binary patch literal 557 zcmeAS@N?(olHy`uVBq!ia0vp^4InJQ1SDn7Xx#@=oCO|{#X#BvjNMLV+c7XO-uHBI z45_&F_NF0MbAX7eBkxOA>F@h(qz{Vj(K%q{T9oEx`SvMi{oI)|Bjw)x-gWNt&)VDH z{#tzb_5VdYcZ(!LCY!^p-{JqRe)*OEMGwTA#W-PG75jzh)#42%%nD~2JU;U+@c#~z zdM4{I|6MG@B_6P(b%WjA-3&{>rpzj5sNGf0=wS?&e9!Q!(OT^vIyZoR#;k+<1Fg!SNIUx)vD6=fH3$UHp2tFY1dX1|%UzxakZ z&*%KEi!DA^DU+OYd)wOA5_#Ky|NUN6&%id}bEQ^IedCv}U+2G$W)MhYeDS*dw-`f9 zB*U*?5BIS$B#JfctJ{&!=rDtI!Fu_3Se5K&{qWzlX!qUs`*j&OKC|IeM}$%T*dLU& z=W{b0+Cz>*;1>L6+;R8eZKei;d=k6?*A4UOvwDWS@*mq66wXK!4g?I{@SyxD-*8)Y f-|z~WZ>-a~inGp4xVICS8W}uY{an^LB{Ts5?rJ5E zv@pE&E^7b)J|aB$Ypm!0TXtsH>)20(v9{@Acx*b>!#`H&^Hd4|7P}*Y1EaH)2!AMY zBFf?WM*ww~8IXPV@b;@= z0cvx2EBNg*;EKnAlsqp>D%2!2%lFx^K1&BnGA|M%s9CDl{(2{G$cK*G+cspMp# zaM|w|CsWp@k4a0*ru;HHH-{h^i0i@*>EQ`+2kg_*Ajs03(QxW)PRv&hPuDs{Yf}81 z;dxl?*gacv%+cnaN1qbevvaeJjg9RU$+tW|K-w<6el`h`H}{M1G*6 zj)35u(5j8yy11~h<`dBicgWVJMIJ^|uY6<(rM(2A-A&EuO$+rF-9Y3#yI+b zq;Uk%Y7-Ln#caL-5sPcHcw#mx?jev({#E8bziugd!n$=PwzFzaVNXxbTNbo^25R2# z>ABz8#l?AUjzZdo(Z%FbXHIAqI^xr~*hag|N4*nsa}yKOy-$jTk#UuM3Icjj&jI Date: Fri, 27 Mar 2009 12:21:17 -0700 Subject: [PATCH 2/3] AI 143124: Fix bug #1731826, in which auto-connect to remembered networks does not take place. This has the same underlying cause as bug #1739874, so this fixes that bug as well. The problem was that if the supplicant was in the DORMANT state at the time a scan-only Wi-Fi lock was released, the command to stop the Wi-Fi driver would never be issued. This had two main results: first, the driver would stay awake when the screen was blank and it was supposed to be sleeping, leading to excessive battery drain, and second, when the screen was turned back on, there would be no DRIVER-STARTED event generated (because the driver was already running). The DRIVER-STARTED event is the trigger for the framework to issue a RECONNECT command to the supplicant to cause it leave the DORMANT state and look for available remembered networks. To assist in tracking down this problem, and any such problems in the future, I added four counters to keep track of how many times full and scan-only Wi-Fi locks are acquired and released. The counter values are output in the dump() method of WifiService. While doing this, I noticed that because of missing "break" statements, the battery stats that keep track of how much time Wi-Fi locks are held were including the time for full locks in the time reported for scan-only locks. BUG=1731826,1739874 Automated import of CL 143124 --- .../java/com/android/server/WifiService.java | 30 ++++++++++++-- .../android/net/wifi/WifiStateTracker.java | 40 ++++++++++++++++--- 2 files changed, 61 insertions(+), 9 deletions(-) diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java index 6323e2f1501f3..8e1d053a675bb 100644 --- a/services/java/com/android/server/WifiService.java +++ b/services/java/com/android/server/WifiService.java @@ -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 { diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java index f7a9677a5600c..6ea35f58be028 100644 --- a/wifi/java/android/net/wifi/WifiStateTracker.java +++ b/wifi/java/android/net/wifi/WifiStateTracker.java @@ -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). From ba9844ee1242243306aaf78cca2a15cb2dd2f083 Mon Sep 17 00:00:00 2001 From: Dave Sparks <> Date: Fri, 27 Mar 2009 12:57:40 -0700 Subject: [PATCH 3/3] AI 143127: Media recorder service requires android.permission.CAMERA to record video BUG=1742392 Automated import of CL 143127 --- .../MediaRecorderClient.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/media/libmediaplayerservice/MediaRecorderClient.cpp b/media/libmediaplayerservice/MediaRecorderClient.cpp index 5d1887d898884..e0d29474dc2f8 100644 --- a/media/libmediaplayerservice/MediaRecorderClient.cpp +++ b/media/libmediaplayerservice/MediaRecorderClient.cpp @@ -30,11 +30,24 @@ #include #include #include +#include #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& camera) { LOGV("setCamera"); @@ -60,6 +73,9 @@ status_t MediaRecorderClient::setPreviewSurface(const sp& 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");