Insertion Mount on state_Pending.

by axel haslam » Fri, 16 Jul 2010 06:26:54 GMT


Sponsored Links
 e have a problem with froyo in which the MMC does not get
automatically mounted upon insertion.

This is what i could understand from the code:
in DirectVolume.cpp on the function handleDiskAdded, if the number of
partitions is not 0, the volume state gets set to "State_Pending" ,
and the VolumeDiskInserted broadcast is sent.This triggers the onEvent
method on MountService, which starts a new thread that sends the
command "volume mount"

the "volume mount" command, gets handled in Volume.cpp function
mountVol() which checks if the state is "State_Idle" if not, returns
BUSY, which in turn gets translated to code 405 "OpFailedStorageBusy"
which is what we see on MountService. This happens because we have
just set the state to "State_Pending".

If we force "State_Idle" on handleDiskAdded, instead of going into
state_Pending, it fixes our problem.

A possible fix for this is setting a flag in the onEvent method on
MountService when the disk is inserted, and starting the thread that
sends the mount command when we receive the state-change to idle, and
the
flag is set.

In short, we should try to mount when the state has changed to idle,
and
not on insertion.

Here is the patch for this:

index 6ceeb95..0adaf19
--- a/services/java/com/android/server/MountService.java
+++ b/services/java/com/android/server/MountService.java
@@ -136,6 +136,8 @@ class MountService extends IMountService.Stub
private static final int RETRY_UNMOUNT_DELAY = 30; // in ms
private static final int MAX_UNMOUNT_RETRIES = 4;

+ /*used to send the mount command after state is idle.*/
+ boolean insertionMountPending = false;
class UnmountCallBack {
String path;
int retries;
@@ -495,6 +497,26 @@ class MountService extends IMountService.Stub
* Format: "NNN Volume <label> <path> state changed
* from <old_#> (<old_str>) to <new_#> (<new_str>)"
*/
+ if ((Integer.parseInt(cooked[10]) == VolumeState.Idle) &&
+ insertionMountPending == true) {
+ /* If the state moves to idle after a insertion
+ * try to mount the device "Insertion mount"
+ */
+ final String path = cooked[3];
+ insertionMountPending = false;
+ new Thread() {
+ public void run() {
+ try {
+ int rc;
+ if ((rc = doMountVolume(path)) !=
StorageResultCode.OperationSucceeded) {
+ Slog.w(TAG, String.format("Insertion
mount failed (%d)", rc));
+ }
+ } catch (Exception ex) {
+ Slog.w(TAG, "Failed to mount media on
insertion", ex);
+ }
+ }
+ }.start();
+ }
notifyVolumeStateChange(
cooked[2], cooked[3],
Integer.parseInt(cooked[7]),
Integer.parseInt(cooked[10]));
@@ -526,18 +548,11 @@ class MountService extends IMountService.Stub
}

if (code == VoldResponseCode.VolumeDiskInserted) {
- new Thread() {
- public void run



Insertion Mount on state_Pending.

by 閭卞缓娉 » Fri, 13 Aug 2010 02:15:40 GMT


 i axelhaslam :

We have a problem with mount too .That is MMC can't mount auto while it
no partitions.
when SDcard Inserted ,the state changed and stoped with state "Pending"

Have you had this problem?

2010/7/16 axel haslam <axelhas...@gmail.com>




--
------

Jianbo Qiu (

Mobile: 13681184653

MSN:q173981...@126.com <msn%3aq173981...@126.com>

------

--


Sponsored Links


Insertion Mount on state_Pending.

by axel haslam » Fri, 13 Aug 2010 02:15:41 GMT


  have pushed this patch that helped with our problem.
https://review.source.android.com/#change,16460, let me know
if it helps..

Im not sure what you mean with "no partitions".. you have not
partitioned the sdcard?




<https://review.source.android.com/#change,16460>

2010/8/12 <qjb.1...@gmail.com>


--



Insertion Mount on state_Pending.

by 閭卞缓娉 » Mon, 16 Aug 2010 11:48:57 GMT


 i axel:

your patch works well.
"no partitions" means ths sdcard has none partitions,deleted all
partitions.it can r/w with pc operating system

had this problem happen on your device?can't mount sdcard with "no
partitions"



2010210:51xel haslam <axelhas...@gmail.com>


--
------

Jianbo Qiu (

Mobile: 13681184653

MSN:q173981...@126.com <msn%3aq173981...@126.com>

------

--



Other Threads

1. Android Developer Day - Dallas - Saturday April 10

Free event for Android developers organized with help from Motorola,
Cohabitat and Athlete360.

http://androiddevday.eventbrite.com/

Event Details:
Developers! This is your opportunity to get first-hand experience
developing for the Google Android platform! This all-day developer
camp will give you the tools you'll need to get started in mobile
development. If you have a working knowledge of Java, Objective C, or
C#, or you've developed for WinMo, iPhone, Blackberry, or Palm this
day is for you.

In our morning sessions we'll give a tour of easy-to-build application
starter kits. Then we'll show you how to build your applications on
top of them and take them to the Android Market before the day is
over! Finally we'll give prizes and awards to the most ambitious apps.
Bring your own developer team or form teams at the event!

Agenda
9am - 10am Sign-In and Network
10am - 10:30 Introduction and Welcome
10:30 - 12:30 Starter Kit Tours
12:30 - 1:30 Form Teams & Lunch
1:30 - 4:30 Code Jam
4:30 - 5:00 Go To Market! & Door Prizes

Starter Kits Areas of Interest:
Voice Recognition
Feed Reader
Web Wrapper
Widgets
Twitter
Camera
Home Screen Replacements

Sponsors:
Motorola, Cohabitat, Athlete360

-- 

2. The program stopped unexpectedly when invoking the goToSleep method in PowerManager object

Hello everyone,

I am trying to figure out why my app will stop unexpectedly when
invoking the goToSleep method in PowerManager object. I code my app in
this way:

public class ScreenOff extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        PowerManager pm = (PowerManager)
getSystemService(Context.POWER_SERVICE);
        pm.goToSleep(SystemClock.uptimeMillis());
   }
}

Friends, do you have any idea on this?
Thank you very much

-- 

3. How to use scroller in an application?

4. Expenses of MediaPlayer.getCurrentPosition() vs own ticker

5. Animation from AppWidget to Activity

6. Activities across tasks passing data, possible?

7. Problem using sqlite DB -- unable to open database file