开机过程中两个Activity优先级冲突

冲突的LOG如下:
/ActivityManager(  196): Sending system update to: ComponentInfo{com.android.providers.contacts/com.android.providers.contacts.ContactsUpgradeReceiver}
I/ActivityManager(  196): Sending system update to: ComponentInfo{com.android.providers.calendar/com.android.providers.calendar.CalendarUpgradeReceiver}
I/ActivityManager(  196): Sending system update to: ComponentInfo{com.google.android.gsf/com.google.android.gsf.loginservice.MigrateToAccountManagerBroadcastReceiver}
I/ActivityManager(  196): Start proc android.process.acore for broadcast com.android.providers.contacts/.ContactsUpgradeReceiver: pid=267 uid=10018 gids={3003, 1015}
I/SystemServer(  196): Enabled StrictMode for system server main thread.
I/SensorsHal(  196): [File] : hardware/rk29/libsensors/rk29_mid_sdk/MmaSensor.cpp; [Line] : 82; [Func] : enable() ; ! Info : newState = 0x1, what = 0x0, mEnabled = 0x0.
E/SensorsHal(  196): Couldn't open /dev/mma8452_daemon (No such file or directory)
I/SensorsHal(  196): [File] : hardware/rk29/libsensors/rk29_mid_sdk/MmaSensor.cpp; [Line] : 89; [Func] : enable() ; ! Info : to call 'MMA_IOCTL_START'.
E/SensorsHal(  196): [File] : hardware/rk29/libsensors/rk29_mid_sdk/MmaSensor.cpp; [Line] : 91; [Func] : enable() ; !!! Error : fail to perform MMA_IOCTL_START, err = -1, error is 'Bad file number'
E/SensorService(  196): Error activating sensor 0 (Operation not permitted)
I/ActivityManager(  196): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000000 cmp=android/com.android.internal.app.ResolverActivity } from pid 0
W/dalvikvm(  196): threadid=9: thread exiting with uncaught exception (group=0x40015560)
E/AndroidRuntime(  196): *** FATAL EXCEPTION IN SYSTEM PROCESS: android.server.ServerThread
E/AndroidRuntime(  196): java.lang.RuntimeException: Unable to start activity ComponentInfo{android/com.android.internal.app.ResolverActivity}: java.lang.NullPointerException
E/AndroidRuntime(  196):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
E/AndroidRuntime(  196):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
E/AndroidRuntime(  196):        at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime(  196):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime(  196):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(  196):        at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime(  196):        at com.android.server.ServerThread.run(SystemServer.java:569)
E/AndroidRuntime(  196): Caused by: java.lang.NullPointerException
E/AndroidRuntime(  196):        at android.content.res.Configuration.setTo(Configuration.java:227)
E/AndroidRuntime(  196):        at android.content.res.Configuration.<init>(Configuration.java:223)
E/AndroidRuntime(  196):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1591)
E/AndroidRuntime(  196):        ... 6 more
I/dalvikvm(  196): +++ DexOpt: numDeps = 8
W/dalvikvm(  196): DexOpt: Spurious dep data? 615 vs 706
I/dalvikvm(  196): +++ DexOpt: numDeps = 8
W/dalvikvm(  196): DexOpt: Spurious dep data? 615 vs 706
I/ActivityManager(  196): Launching preboot mode app: ProcessRecord{406e85d8 267:android.process.acore/10018}
I/Process (  196): Sending signal. PID: 196 SIG: 9
I/ServiceManager(   52): service 'usb' died
I/ServiceManager(   52): service 'audio' died
I/ServiceManager(   52): service 'uimode' died
I/ServiceManager(   52): service 'SurfaceFlinger' died
I/ServiceManager(   52): service 'sensorservice' died
I/ServiceManager(   52): service 'entropy' died
I/ServiceManager(   52): service 'power' died
I/ServiceManager(   52): service 'batteryinfo' died
I/ServiceManager(   52): service 'telephony.registry' died
I/ServiceManager(   52): service 'usagestats' died
I/ServiceManager(   52): service 'account' died
I/ServiceManager(   52): service 'permission' died
其实是一个setup wizard, 一个provision, 当然也有可能存在两个setup wizard的情况.

出错原因是当有两个 (或多个) Setupwizard 时, 会在开机早期调用system的内部 Activity (ResolverActivity), 而这时ActivityThread 的某个成员变量 mConfiguration还没有被初始化, 所以报空指针错误.

在2.2中, mConfiguration的第一次赋值是在执行 statusBar.systemReady() 时, 而2.3中相对应的函数体为空 (StatusBarManagerService.systemReady()).

修改Configuration的构造函数, 做空指针判断, 可以解决这个问题:

public Configuration(Configuration o) {
		if (o == null) {
			setToDefaults();
		} else {
			setTo(o);
		}
    }


你可能感兴趣的:(thread,exception,service,File,System,wizard)