android移植(三)-一些问题与解决方法

板子helper2416    芯片是三星的s3c2416  arm平台   本机系统: opensuse

==============================================================================

命令行让Android播放音乐
插tf卡开机之后,运行 gdb shell
am start -n com.android.music/com.android.music.MediaPlaybackActivity -d ./1.mp3
这个命令可以让android播放TF卡中的MP3


========================================
从2.0(android 的版本)开始有的电池的问题


I/SystemServer( 1749): Battery Service                                    
W/dalvikvm( 1749): No implementation found for native Lcom/android/server/BatteryService;.native_update ()V
W/dalvikvm( 1749): threadid=15: thread exiting with uncaught exception (group=0x4001b178)                 
E/AndroidRuntime( 1749): Uncaught handler: thread android.server.ServerThread exiting due to uncaught exception  
E/AndroidRuntime( 1749): *** EXCEPTION IN SYSTEM PROCESS.  System will crash.                                   
E/AndroidRuntime( 1749): java.lang.UnsatisfiedLinkError: native_update                                         
E/AndroidRuntime( 1749):        at com.android.server.BatteryService.native_update(Native Method)             
E/AndroidRuntime( 1749):        at com.android.server.BatteryService.update(BatteryService.java:200)         
E/AndroidRuntime( 1749):        at com.android.server.BatteryService.<init>(BatteryService.java:138)        
E/AndroidRuntime( 1749):        at com.android.server.ServerThread.run(SystemServer.java:140)              
E/AndroidRuntime( 1749): Crash logging skipped, no checkin service                                        
I/Process ( 1749): Sending signal. PID: 1749 SIG: 9                                                      
D/BootAnimation( 1764): SurfaceFlinger died, exiting...                                                 
I/ServiceManager(init: untracked pid 1742 exited                                                       
 1589): service 'batteryinfo' died                                                                    
I/ServiceManager( 1589): service 'usagestats' died                                                   
I/ServiceManager( 1589): service 'entropy' died                                                     
I/ServiceManager( 1589): service 'power' died                                                      
I/ServiceManager( 1589): service 'meminfo' died                                                   
I/ServiceManager( 1589): service 'activity.broadcasts' died                                      
I/ServiceManager( 1589): service 'activity.services' died                                       
I/ServiceManager( 1589): service 'activity.senders' died                                       
I/ServiceManager( 1589): service 'activity.providers' died                                    
I/ServiceManager( 1589): service 'permission' died                                           
I/ServiceManager( 1589): service 'telephony.registry' died                                  
I/ServiceManager( 1589): service 'activity' died                                           
I/ServiceManager( 1589): service 'package' died                                           
I/ServiceManager( 1589): service 'SurfaceFlinger' died                                   
I/ServiceManager( 1589): service 'cpuinfo' died                                         
I/ServiceManager( 1589): service 'account' died                                        
I/ServiceManager( 1589): service 'content' died                                       
I/Zygote  ( 1744): Exit zygote because system server (1749) has terminated           
E/installd( 1597): eof                                                              
E/installd( 1597): failed to read size                                             
I/installd( 1597): closing connection                                             
I/ServiceManager( 1589): service 'media.audio_flinger' died                      
I/ServiceManager( 1589): service 'media.player' died                            
I/ServiceManager( 1589): service 'media.camera' died                           
I/ServiceManager( 1589): service 'media.audio_policy' died                    
D/AndroidRuntime( 1784):                                                     
D/AndroidRuntime( 1784): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<


原因
The problem are not the Java or JNI files, the problem is in the
kernel.
I guess you also have an error like this, right before the crash log
you posted:
E/BatteryService( 1737): Could not open /sys/class/power_supply
You have to add a generic power management driver in your kernel or
otherwise the system class will not be found.
In the JNI file, the first thing before registering the native calls
is a check for the /sys/class/power_supply path. If it doesn't exist,
this function returns without registering any native functions. This
check was added with 2.0 thats why your 1.6 file worked just fine.
(I had the same problem, worked for me) 


init.rc中
在on boot  的action中加入对battery的设置:
setprop hw.nobattery true 
2.1 2.2版本不适用


可以打以下patch


--- services/java/com/android/server/BatteryService.java    2012-05-03 20:19:16.000000000 +0800
+++ services/java/com/android/server/BatteryService.java.new    2012-05-03 20:19:09.000000000 +0800
@@ -84,6 +84,7 @@
     private static final int DUMP_MAX_LENGTH = 24 * 1024;
     private static final String[] DUMPSYS_ARGS = new String[] { "--checkin", "-u" };
     private static final String BATTERY_STATS_SERVICE_NAME = "batteryinfo";
+    private static final String BATTERY_TECHNOLOGY = "dynamo";
     
     private static final String DUMPSYS_DATA_PATH = "/data/system/";
 
@@ -132,7 +133,7 @@
         mLowBatteryCloseWarningLevel = mContext.getResources().getInteger(
                 com.android.internal.R.integer.config_lowBatteryCloseWarningLevel);
 
-        mUEventObserver.startObserving("SUBSYSTEM=power_supply");
+        //mUEventObserver.startObserving("SUBSYSTEM=power_supply");
 
         // set initial status
         update();
@@ -197,8 +198,23 @@
     private native void native_update();
 
     private synchronized final void update() {
-        native_update();
+        //native_update();
+        mBatteryLevel = BATTERY_SCALE - CRITICAL_BATTERY_LEVEL;
+        mBatteryLevelCritical = mBatteryLevel <= CRITICAL_BATTERY_LEVEL;
+        mPlugType = BatteryManager.BATTERY_PLUGGED_AC;
+        mDischargeStartTime = 0;
+
+        mBatteryStatus = BatteryManager.BATTERY_STATUS_FULL;
+        mBatteryHealth = BatteryManager.BATTERY_HEALTH_GOOD;
+        mBatteryPresent = true;
+        mBatteryVoltage = 5;
+        mBatteryTemperature = 30;
+        mBatteryTechnology = BATTERY_TECHNOLOGY;
+        sendIntent();
+
+        return;
 
+        /*
         boolean logOutlier = false;
         long dischargeDuration = 0;
 
@@ -274,6 +290,7 @@
             
             final boolean plugged = mPlugType != BATTERY_PLUGGED_NONE;
             final boolean oldPlugged = mLastPlugType != BATTERY_PLUGGED_NONE;
+            */
 
             /* The ACTION_BATTERY_LOW broadcast is sent in these situations:
              * - is just un-plugged (previously was plugged) and battery level is
@@ -281,6 +298,7 @@
              * - is not plugged and battery level falls to WARNING boundary
              *   (becomes <= mLowBatteryWarningLevel).
              */
+            /*
             final boolean sendBatteryLow = !plugged
                 && mBatteryStatus != BatteryManager.BATTERY_STATUS_UNKNOWN
                 && mBatteryLevel <= mLowBatteryWarningLevel
@@ -326,6 +344,7 @@
             mLastBatteryTemperature = mBatteryTemperature;
             mLastBatteryLevelCritical = mBatteryLevelCritical;
         }
+        */
     }
 
     private final void sendIntent() {


=================================================================
一按按键导致程序挂掉


提示
can't open keycharmap file
Error loading keycharmap file xx 之类的然后直接程序挂掉。。
这个是权限的问题
chmod 0644 system/usr/keychars/*




==============================================================
运行音乐程序时出错
W/dalvikvm( 1777): threadid=3: thread exiting with uncaught exception (group=0x4001b178)
E/AndroidRuntime( 1777): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 1777): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.music/com.android.music.Artis>
E/AndroidRuntime( 1777):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
E/AndroidRuntime( 1777):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
E/AndroidRuntime( 1781): Caused by: android.content.res.Resources$NotFoundException: File res/drawable-finger/buttonbarbackground.xml7


原因
Probably you are running on a mdpi device and you are missing files from
drawable-mdpi. You could rescale those from hdpi folders.


buttonbarbackground.xml部分内容 
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_focused="true"
        android:drawable="@drawable/buttonbar_focused" />
    <item
        android:state_pressed="true"
        android:drawable="@drawable/buttonbar_pressed" />
    <item
        android:state_selected="true"
        android:drawable="@drawable/buttonbar_active" />
    <item
        android:state_selected="false"
        android:drawable="@drawable/buttonbar_inactive" />
</selector>


drawable-mdpi 文件夹中缺少buttonbar_xx 图片文件,所以运行时出错

./packages/apps/Music/res/drawable-hdpi-finger/
下挎贝下面几个文件到./packages/apps/Music/res/drawable-mdpi-finger/ 文件夹下
buttonbar_active.9.png
buttonbar_focused.9.png
buttonbar_inactive.9.png
buttonbar_pressed.9.png
rm out/target/common/obj/APPS/Music_intermediates/ -r
重新
make
==============================================
2.1一运行就提示calendar运行出错
E/AndroidRuntime( 1718): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 1718): java.lang.NullPointerException                                
E/AndroidRuntime( 1718):        at com.android.providers.calendar.CalendarSyncAdapter.onAccountsChanged(CalendarSyncAdapter.java:1400)
E/AndroidRuntime( 1718):        at android.content.AbstractSyncableContentProvider$1.onAccountsUpdated(AbstractSyncableContentProvide)
E/AndroidRuntime( 1718):        at android.accounts.AccountManager$10.run(AccountManager.java:826)                              
E/AndroidRuntime( 1718):        at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 1718):        at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 1718):        at android.os.Looper.loop(Looper.java:123)           
E/AndroidRuntime( 1718):        at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime( 1718):        at java.lang.reflect.Method.invokeNative(Native Method)    
E/AndroidRuntime( 1718):        at java.lang.reflect.Method.invoke(Method.java:521)       
E/AndroidRuntime( 1718):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 1718):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)                  
E/AndroidRuntime( 1718):        at dalvik.system.NativeStart.main(Native Method)


==================================================
andorid插入sd卡
产生的mmcblk0 mmcblk0p1 不在/dev下,而是在/dev/block下


手动 mount -t vfat  /dev/block/mmcblk0p1 /sdcard/   android上层并不会认为sd卡已经插入了


vold程序负责检查内核的 sysfs 文件系统,发现有SD卡插入后,自动挂载。 在文件系统目录 /system/etc/  下有一个vold.fstab 文件,该文件是系统与用户硬件平台的交互接口,用户根据自己的平台来配置这个文件,里面内容比较简单,只需要你指定sys下vold程序需要查询的文件夹路径,当SD卡插入设备后,这个路径下会产生相应的文件,vold能检查到
2.2以下不是vold.fstab 而是vold.conf
system/etc/vold.conf
可从development/data/etc/vold.conf挎贝
volume_sdcard {
    media_type     mmc
    mount_point    /sdcard
    media_path     /devices/platform/s3c-hsmmc.1/mmc_host/mmc1
}


system/etc/mountd.conf
可从system/core/rootdir/etc/mountd.conf挎贝
mount {
    ## root block device with partition map or raw FAT file system
    block_device    /dev/block/mmcblk0p1
        
    ## mount point for block device
    mount_point     /sdcard
    
    ## true if this mount point can be shared via USB mass storage
    enable_ums      true
    
    ## path to the UMS driver file for specifying the block device path  
    ## use this for the mass_storage function driver
    driver_store_path   /sys/devices/platform/usb_mass_storage/lun0/file
    ## use this for android_usb composite gadget driver
    ##driver_store_path   /sys/devices/platform/msm_hsusb/gadget/lun0/file
}


and the kernel config:
# CONFIG_SYSFS_DEPRECATED_V2 is not set


General setup  --->
[ ] Create deprecated sysfs files


helper2416 有sd0 与sd1两个卡座,当插上sd1时
# ls /sys//devices/platform/s3c-hsmmc.0/mmc_host/mmc0
uevent
subsystem
device
power


#ls /sys/devices/platform/s3c-hsmmc.1/mmc_host/mmc1
uevent
subsystem
device
power
mmc1:0001


以下是logcat 输出
s3c-hsmmc channel-1(EXT): card inserted.
mmc1: host does not support reading read-only switch. assuming write-enable.
mmc1: new high speed SD card at address 0001                               
I/vold    ( 1594): New MMC card 'x�#Eg' (smmcblk0: mmc1:0001 x�#Eg 1943552KiB 
 mmcblk0: p1                                                                 
erial 0) added @ /devices/platform/s3c-hsmmc.1/mmc_host/mmc1/mmc1:0001      
I/vold    ( 1594): Disk (blkdev 179:0), 3887104 secs (1898 MB) 1 partitions
I/vold    ( 1594): New blkdev 179.0 on media x�#Eg, media path /devices/platform/s3c-hsmmc.1/mmc_host/mmc1/mmc1:0001, Dpp 1
I/vold    ( 1594): Partition (blkdev 179:1), 3886973 secs (1897 MB) type 0x6                                              
I/vold    ( 1594): New blkdev 179.1 on media x�#Eg, media path /devices/platform/s3c-hsmmc.1/mmc_host/mmc1/mmc1:0001, Dpp 0


2.2 开始
system/etc/vold.fstab
dev_mount sdcard /mnt/sdcard auto /devices/platform/s3c-hsmmc.1/mmc_host/mmc1
===================================================================
目前测试1.6  android-2.2.3_r2.1 跑的比较好,错误问题比较少, 但是播放音乐无声音,触摸都不准, 似乎坐标是反的,最上方变成最下方
2.2.3有一个问题,sd卡在启动前插入,不会自动产生设备,也就不能自动mount, 启动后再拔插的话,才会自动mount
android-2.1_r2 启动时calendar 会崩溃,此版bug相对较多
gingerbread-release(2.3.6) 此版编译后运行不出界面,且命令行无法输入


 将init.rc的loglevel改为最低级7,目的是为了查看更多输出信息
===================================================================
网上有一些针对2440的android fs
比如android-fs-20090825.tar.gz
armv4的, 可以在2416上用(armv5te).
当用它做的系统从nfs上启动时,还得做些修改,否则网卡会停掉
init.rc 中
service myInit /bin/busybox sh /system/etc/shine/myInit.rc
   oneshot
改成
#service myInit /bin/busybox sh /system/etc/shine/myInit.rc
#   oneshot


启动后运行logcat查看运行的一些输出

 作者:帅得不敢出门   c++哈哈堂群:31843264  转载请保留此信息

你可能感兴趣的:(android移植(三)-一些问题与解决方法)