about late resume, when PowerManagerService write on to /sys/power/state to call late resume

by Dianne Hackborn » Wed, 21 Apr 2010 06:47:43 GMT


Sponsored Links
 



Sorry, that isn't true.  If the process running the VM has permission to
access the file, then the Java code can access it.  Android doesn't use the
VM to enforce this (or most) kinds of security.

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--



Other Threads

1. MediaPlayer and LocalSocket problem

I want to set LocalSocket FileDescriptor as a data source for the
MediaPlayer. Here is my code:

public class sipActivity extends Activity {
    public static final String S_ADDR = "test.server";

    public class Server implements Runnable {
        public LocalSocket receiver = null;

        public void run() {
                try {
                        LocalServerSocket server = new LocalServerSocket 
(S_ADDR);
                        while (receiver == null) {
                                receiver = server.accept();
                        }
                } catch (Exception e) {
                        Log.e("me", "ooops", e);
                }
        }
    }

    public class MediaWriter implements Runnable {
        public LocalSocket sender = null;

        public void run() {
                try {
                        sender = new LocalSocket();
                        sender.connect(new LocalSocketAddress(S_ADDR));
                        FileInputStream media = new 
FileInputStream("/system/media/
audio/alarms/Alarm_Classic.ogg");
                        int readed;
                        byte [] b = new byte [1024];
                        do {
                                readed = media.read(b);
                                if (readed > 0) {
                                        sender.getOutputStream().write(b, 0, 
readed);
                                }
                        } while (readed > -1);
                } catch (Exception e) {
                        Log.e("me", "ooops", e);
                }
        }
    }

    /** Called when the activity is first created. */
    @Override

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        try {
                Server mServer = new Server ();
                new Thread (mServer).start();
                MediaWriter mMedia = new MediaWriter ();
                new Thread (mMedia).start();
                while (mServer.receiver == null) {
                        Thread.sleep(10);
                }
                MediaPlayer mMediaPlayer = new MediaPlayer();
                mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
 
mMediaPlayer.setDataSource(mServer.receiver.getFileDescriptor());
                mMediaPlayer.prepare();
                mMediaPlayer.start();
        } catch(Exception e) {
                Log.e("me", "ooops", e);
        }
    }
}

But I got an exception on the line:
mMediaPlayer.setDataSource(mServer.receiver.getFileDescriptor());

The error is following:
java.io.IOException: setDataSourceFD failed: status=0x80000000
  at android.Media.MediaPlayer.setDataSource(Native Method)
  at android.Media.MediaPlayer.setDataSource(MediaPlayer.java:251)
  ...

--~--~---------~--~----~------------~-------~--~----~

2. Map overlay not drawing in beta 0.9. Why?

Hi all,

I'm running 0.9 in Eclipse 3.3/ADT.
I have a very stripped down one-class app (converted from m5) which
ought to be
presenting a map (that works ok) and then drawing an overlay (it
doesn't).
In onCreate(), a simple overlay (TOverlay) is created and added to
_mapView.getOverlays().
Lastly, mapUpdateHandler.sendEmptyMessage() is called, which should
invalidate the mapView,
and hence cause the overlay to be drawn.

I've copied the code below, and then copied the manifest.
The code has a few System.out.println's to determine flow of control.
All these appear in the LogCat output except the one in the overlay:
"TOverlay.draw".
At the very end I've copied the LogCat output.  One can see the
printlns:

09-09 15:18:06.332: INFO/System.out(695): o2:1
09-09 15:18:06.352: INFO/System.out(695): mUH:msg=101
09-09 15:18:06.352: INFO/System.out(695): mUH:101
09-09 15:18:06.352: INFO/System.out(695): o3: 1

But not the desired "TOverlay.draw"

Any suggestions will be greatly appreciated.
Thanks in advance,
Ken

-------------- Java ----------
package com.herenow.android.quester;

import java.util.List;

public class Quester extends MapActivity
{
        private static final double INIT_CENTER_LAT = 42.3908245;
        private static final double INIT_CENTER_LONG = -71.130993;
        private MapView _mapView;

    @Override
    public void onCreate(Bundle icicle)
    {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        _mapView = new MapView(this, "dummyapikey");
        GeoPoint p = new GeoPoint((int) (INIT_CENTER_LAT * 1000000),
(int) (INIT_CENTER_LONG * 1000000));
        MapController mc = _mapView.getController();

        TOverlay tOver = new TOverlay(_mapView);
        List<Overlay> overlays = _mapView.getOverlays();
        overlays.add(tOver);

        mc.animateTo(p);
        mc.setZoom(15);
        setContentView(_mapView);

        mapUpdateHandler.sendEmptyMessage(101);
List<Overlay> o2 = _mapView.getOverlays();
System.out.println("o2:"+o2.size());
    }
    private Handler mapUpdateHandler
        = new Handler(){
                @Override
                public void handleMessage(Message msg) {
                        System.out.println("mUH:msg="+msg.what);
                    switch (msg.what) {
                          case 101:
                   //         _mapView.invalidate();
                            _mapView.postInvalidate();
                            System.out.println("mUH:101");
                                       break;
                             }
List <Overlay> o3 = _mapView.getOverlays();
System.out.println("o3: "+o3.size());
                     super.handleMessage(msg);
                }
            };

    public class TOverlay extends Overlay
    {
        private Paint plotPaint = new Paint();
        private MapView mapView;

        public TOverlay(MapView mapView){
                this.mapView = mapView;
                plotPaint.setColor(Color.BLUE);
        }

        public synchronized void draw(Canvas canvas, boolean b)
        {
            super.draw(canvas, mapView, b);
System.out.println("TOverlay.draw");

            int lat = (int)(INIT_CENTER_LAT*1E6);
                int lng = (int)(INIT_CENTER_LONG*1E6);
            GeoPoint geopoint = new GeoPoint(lat, lng);

            Point screenCoords = new Point();
            mapView.getProjection().toPixels(geopoint, screenCoords);
            canvas.drawCircle(screenCoords.x, screenCoords.y, 12,
plotPaint);
        }
    }

    public boolean isRouteDisplayed(){
        return false;
    }
}
--------------- Manifest -------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=" http://www.***.com/ ;
    package="com.herenow.android.quester">
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:icon="@drawable/icon">
        <activity android:name=".Quester" android:label="@string/
app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <uses-library android:name="com.google.android.maps" />
    </application>
</manifest>
-------------- LogCat Output-----------
09-09 15:38:59.813: DEBUG/dalvikvm(695): Calling exit(1)
09-09 15:38:59.843: INFO/ActivityManager(51): Process
com.herenow.android.quester (pid 695) has died.
09-09 15:38:59.853: DEBUG/Zygote(23): Process 695 exited cleanly (1)
09-09 15:38:59.863: INFO/WindowManager(51): WIN DEATH: Window{4347d300
com.herenow.android.quester/com.herenow.android.quester.Quester}
09-09 15:39:00.182: DEBUG/AndroidRuntime(709): >>>>>>>>>>>>>>
AndroidRuntime START <<<<<<<<<<<<<<
09-09 15:39:00.192: DEBUG/AndroidRuntime(709): CheckJNI is ON
09-09 15:39:00.353: DEBUG/AndroidRuntime(709): --- registering native
functions ---
09-09 15:39:00.363: INFO/jdwp(709): received file descriptor 19 from
ADB
09-09 15:39:01.052: DEBUG/PackageParser(51): Scanning package: /data/
app/vmdl38048.tmp
09-09 15:39:01.132: WARN/PackageManager(51): Attempt to re-install
com.herenow.android.quester without first uninstalling.
09-09 15:39:01.162: DEBUG/AndroidRuntime(709): Shutting down VM
09-09 15:39:01.162: DEBUG/dalvikvm(709): DestroyJavaVM waiting for non-
daemon threads to exit
09-09 15:39:01.162: INFO/dalvikvm(709): DestroyJavaVM shutting VM down
09-09 15:39:01.162: DEBUG/dalvikvm(709): HeapWorker thread shutting
down
09-09 15:39:01.172: DEBUG/dalvikvm(709): HeapWorker thread has shut
down
09-09 15:39:01.172: DEBUG/jdwp(709): JDWP shutting down net...
09-09 15:39:01.172: DEBUG/jdwp(709): +++ peer disconnected
09-09 15:39:01.172: INFO/dalvikvm(709): De{*filter*} has detached; object
registry had 1 entries
09-09 15:39:01.182: DEBUG/dalvikvm(709): VM cleaning up
09-09 15:39:01.192: DEBUG/dalvikvm(709): LinearAlloc 0x0 used 527204
of 4194304 (12%)
09-09 15:39:01.363: DEBUG/dalvikvm(51): GC freed 7240 objects / 405616
bytes in 207ms
09-09 15:39:01.483: DEBUG/AndroidRuntime(717): >>>>>>>>>>>>>>
AndroidRuntime START <<<<<<<<<<<<<<
09-09 15:39:01.483: DEBUG/AndroidRuntime(717): CheckJNI is ON
09-09 15:39:01.633: DEBUG/AndroidRuntime(717): --- registering native
functions ---
09-09 15:39:01.633: INFO/jdwp(717): received file descriptor 19 from
ADB
09-09 15:39:02.343: DEBUG/PackageParser(51): Scanning package: /data/
app/vmdl38049.tmp
09-09 15:39:02.413: DEBUG/PackageManager(51): Removing package
com.herenow.android.quester
09-09 15:39:02.413: DEBUG/PackageManager(51):   Activities:
com.herenow.android.quester.Quester
09-09 15:39:02.423: DEBUG/PackageManager(51): Scanning package
com.herenow.android.quester
09-09 15:39:02.433: ERROR/PackageManager(51): Package
com.herenow.android.quester has mismatched uid: 10008 on disk, 10015
in settings
09-09 15:39:02.433: INFO/PackageManager(51): /data/app/vmdl38049.tmp
changed; unpacking
09-09 15:39:02.443: INFO/dalvikvm(27): Opening files: input='/data/app/
vmdl38049.tmp' cache='/data/dalvik-cache/
[EMAIL PROTECTED]@[EMAIL PROTECTED]'
09-09 15:39:02.443: DEBUG/dalvikvm(27): DexInv: --- BEGIN
'vmdl38049.tmp' (bootstrap=0) ---
09-09 15:39:02.453: DEBUG/dalvikvm(27): DexInv: waiting for verify
+opt, pid=723
09-09 15:39:02.543: DEBUG/dalvikvm(723): Unable to resolve superclass
of Lcom/herenow/android/quester/Quester$TOverlay; (15)
09-09 15:39:02.553: DEBUG/dalvikvm(723): Link of class 'Lcom/herenow/
android/quester/Quester$TOverlay;' failed
09-09 15:39:02.553: DEBUG/dalvikvm(723): DexOpt: failed loading 'Lcom/
herenow/android/quester/Quester$TOverlay;'
09-09 15:39:02.553: DEBUG/dalvikvm(723): Unable to resolve superclass
of Lcom/herenow/android/quester/Quester; (12)
09-09 15:39:02.553: DEBUG/dalvikvm(723): Link of class 'Lcom/herenow/
android/quester/Quester;' failed
09-09 15:39:02.553: DEBUG/dalvikvm(723): DexOpt: failed loading 'Lcom/
herenow/android/quester/Quester;'
09-09 15:39:02.563: DEBUG/dalvikvm(723): VFY: unable to find class
referenced in signature (Lcom/herenow/android/quester/Quester;)
09-09 15:39:02.573: DEBUG/dalvikvm(723): VFY: unable to resolve static
method 25: Lcom/herenow/android/quester/Quester;.access$0 (Lcom/
herenow/android/quester/Quester;)Lcom/google/android/maps/MapView;
09-09 15:39:02.573: DEBUG/dalvikvm(723): VFY:  rejecting opcode 0x71
at 0x001d
09-09 15:39:02.583: DEBUG/dalvikvm(723): VFY:  rejected Lcom/herenow/
android/quester/Quester$1;.handleMessage (Landroid/os/Message;)V
09-09 15:39:02.583: DEBUG/dalvikvm(723): Verifier rejected class Lcom/
herenow/android/quester/Quester$1;
09-09 15:39:02.583: DEBUG/dalvikvm(723): DexOpt: not optimizing
unavailable class 'Lcom/herenow/android/quester/Quester$TOverlay;'
09-09 15:39:02.583: DEBUG/dalvikvm(723): DexOpt: not optimizing
unavailable class 'Lcom/herenow/android/quester/Quester;'
09-09 15:39:02.583: DEBUG/dalvikvm(723): DexOpt: load 24ms, verify
25ms, opt 1ms
09-09 15:39:02.593: DEBUG/dalvikvm(27): DexInv: --- END
'vmdl38049.tmp' (success) ---
09-09 15:39:02.593: DEBUG/PackageManager(51):   Activities:
com.herenow.android.quester.Quester
09-09 15:39:02.653: DEBUG/PackageManager(51): New package installed
in /data/app/com.herenow.android.quester.apk
09-09 15:39:02.743: DEBUG/AndroidRuntime(717): Shutting down VM
09-09 15:39:02.743: DEBUG/dalvikvm(717): DestroyJavaVM waiting for non-
daemon threads to exit
09-09 15:39:02.753: DEBUG/ActivityManager(51): Uninstalling process
com.herenow.android.quester
09-09 15:39:02.763: INFO/dalvikvm(717): DestroyJavaVM shutting VM down
09-09 15:39:02.763: DEBUG/dalvikvm(717): HeapWorker thread shutting
down
09-09 15:39:02.763: DEBUG/dalvikvm(717): HeapWorker thread has shut
down
09-09 15:39:02.763: DEBUG/jdwp(717): JDWP shutting down net...
09-09 15:39:02.763: DEBUG/jdwp(717): Got wake-up signal, bailing out
of select
09-09 15:39:02.763: INFO/dalvikvm(717): De{*filter*} has detached; object
registry had 1 entries
09-09 15:39:02.763: DEBUG/dalvikvm(717): VM cleaning up
09-09 15:39:02.763: DEBUG/dalvikvm(717): LinearAlloc 0x0 used 527204
of 4194304 (12%)
09-09 15:39:03.022: DEBUG/dalvikvm(51): GC freed 3617 objects / 197288
bytes in 223ms
09-09 15:39:03.202: DEBUG/AndroidRuntime(728): >>>>>>>>>>>>>>
AndroidRuntime START <<<<<<<<<<<<<<
09-09 15:39:03.202: DEBUG/AndroidRuntime(728): CheckJNI is ON
09-09 15:39:03.403: DEBUG/dalvikvm(91): GC freed 624 objects / 30648
bytes in 138ms
09-09 15:39:03.453: DEBUG/AndroidRuntime(728): --- registering native
functions ---
09-09 15:39:03.463: INFO/jdwp(728): received file descriptor 19 from
ADB
09-09 15:39:04.182: DEBUG/ActivityManager(51): Uninstalling process
com.herenow.android.quester
09-09 15:39:04.182: INFO/ActivityManager(51): Starting activity:
Intent { flags=0x10000000 comp={com.herenow.android.quester/
com.herenow.android.quester.Quester} }
09-09 15:39:04.222: INFO/ActivityManager(51): Start proc
com.herenow.android.quester for activity
com.herenow.android.quester/.Quester: pid=736 uid=10015 gids={3003}
09-09 15:39:04.252: DEBUG/AndroidRuntime(728): Shutting down VM
09-09 15:39:04.252: DEBUG/dalvikvm(728): DestroyJavaVM waiting for non-
daemon threads to exit
09-09 15:39:04.262: INFO/dalvikvm(728): DestroyJavaVM shutting VM down
09-09 15:39:04.262: DEBUG/dalvikvm(728): HeapWorker thread shutting
down
09-09 15:39:04.262: DEBUG/dalvikvm(728): HeapWorker thread has shut
down
09-09 15:39:04.262: DEBUG/jdwp(728): JDWP shutting down net...
09-09 15:39:04.262: DEBUG/jdwp(728): Got wake-up signal, bailing out
of select
09-09 15:39:04.262: INFO/dalvikvm(728): De{*filter*} has detached; object
registry had 1 entries
09-09 15:39:04.262: DEBUG/dalvikvm(728): VM cleaning up
09-09 15:39:04.293: DEBUG/dalvikvm(728): LinearAlloc 0x0 used 538516
of 4194304 (12%)
09-09 15:39:04.342: INFO/jdwp(736): received file descriptor 10 from
ADB
09-09 15:39:04.463: WARN/ActivityThread(736): Application
com.herenow.android.quester is waiting for the de{*filter*} on port
8100...
09-09 15:39:04.483: INFO/System.out(736): Sending WAIT chunk
09-09 15:39:04.503: INFO/dalvikvm(736): De{*filter*} is active
09-09 15:39:04.683: INFO/System.out(736): De{*filter*} has connected
09-09 15:39:04.693: INFO/System.out(736): waiting for de{*filter*} to
settle...
09-09 15:39:04.893: INFO/System.out(736): waiting for de{*filter*} to
settle...
09-09 15:39:05.102: INFO/System.out(736): waiting for de{*filter*} to
settle...
09-09 15:39:05.303: INFO/System.out(736): waiting for de{*filter*} to
settle...
09-09 15:39:05.505: INFO/System.out(736): waiting for de{*filter*} to
settle...
09-09 15:39:05.708: INFO/System.out(736): waiting for de{*filter*} to
settle...
09-09 15:39:05.913: INFO/System.out(736): waiting for de{*filter*} to
settle...
09-09 15:39:06.113: INFO/System.out(736): waiting for de{*filter*} to
settle...
09-09 15:39:06.316: INFO/System.out(736): de{*filter*} has settled (1346)
09-09 15:39:06.713: WARN/Maps_Persistence(736): Couldn't find file:  /
data/data/com.herenow.android.quester/files/DATA_Preferences
09-09 15:39:06.743: WARN/Maps_Persistence(736): Couldn't write
block:  /data/data/com.herenow.android.quester/files/DATA_Preferences
09-09 15:39:07.003: WARN/Maps_Persistence(736): Couldn't find file:  /
data/data/com.herenow.android.quester/files/DATA_Tiles
09-09 15:39:07.082: WARN/Maps(736): Couldn't restore map info, data ==
null
09-09 15:39:07.333: INFO/System.out(736): o2:1
09-09 15:39:07.423: INFO/System.out(736): mUH:msg=101
09-09 15:39:07.433: INFO/System.out(736): mUH:101
09-09 15:39:07.433: INFO/System.out(736): o3: 1
09-09 15:39:07.544: INFO/MapActivity(736): Handling network change
notification:CONNECTED
09-09 15:39:07.553: ERROR/MapActivity(736): Couldn't get connection
factory client
09-09 15:39:07.873: INFO/ActivityManager(51): Displayed activity
com.herenow.android.quester/.Quester: 3685 ms
09-09 15:39:10.033: ERROR/Database(51): Error inserting count=1
tag=HTTP_STATUS:AndroidHttpConnectionFactory/70597:200 sum=1.484 using
INSERT INTO stats(count, tag, sum) VALUES(?, ?, ?);
09-09 15:39:10.152: WARN/Maps_Persistence(736): Couldn't write
block:  /data/data/com.herenow.android.quester/files/DATA_Preferences
09-09 15:39:10.242: DEBUG/dalvikvm(736): GC freed 5309 objects /
307896 bytes in 58ms
09-09 15:39:11.202: ERROR/Database(51): Error inserting count=1
tag=HTTP_STATUS:AndroidHttpConnectionFactory/70597:200 sum=0.506 using
INSERT INTO stats(count, tag, sum) VALUES(?, ?, ?);
09-09 15:39:11.433: DEBUG/dalvikvm(736): GC freed 1333 objects / 95632
bytes in 80ms
09-09 15:39:11.553: ERROR/Database(51): Error inserting count=1
tag=HTTP_STATUS:AndroidHttpConnectionFactory/70597:200 sum=0.586 using
INSERT INTO stats(count, tag, sum) VALUES(?, ?, ?);
09-09 15:39:13.953: DEBUG/dalvikvm(117): GC freed 3 objects / 72 bytes
in 65ms
09-09 15:39:13.953: DEBUG/dalvikvm(91): GC freed 516 objects / 24744
bytes in 57ms


--~--~---------~--~----~------------~-------~--~----~

3. Image Button

4. GoogleApps.apk

5. My Submission: PhoneIDE - Develop Android All in Phone

6. Offering widgets in the Application Market

7. orientation change bug with translucent activities