Killing pid on start Android

Hi,
i’m trying to installa Android App on Android TV 11. I receive the same message with 2.12 or 3.0.0 version.
In the same device (Mecool KM7) there’s another app, myself developed, that start on boot without problems.

2022-07-07 06:29:34.950 560-619/? I/SystemServerTimingAsync: InitThreadPoolExec:Update app-ops uidState in case package com.signage.mkeyekwwkm changed
2022-07-07 06:29:35.699 560-560/? V/StorageManagerService: Package com.signage.mkeyekwwkm has legacy storage
2022-09-06 14:44:00.976 560-588/? I/ActivityManager: Start proc 2971:com.signage.mkeyekwwkm/u0a75 for broadcast {com.signage.mkeyekwwkm/uk.org.xibo.alarms.ReceiveBootCompletedReceiver}
2022-09-06 14:44:01.090 2971-2971/? W/nativeloader: target_sdk_version is 28 is_shared is 0 java_library_path is /data/app/~~NqaActwK6eihB2xDriQ55Q==/com.signage.mkeyekwwkm-WZPVaDFhCZF2IPq7oAWEkA==/lib/arm permitted_path is /data:/mnt/expand:/data/user/0/com.signage.mkeyekwwkm
2022-09-06 14:44:01.184 2971-2971/? I/ACRA: ACRA is enabled for com.signage.mkeyekwwkm, initializing...
2022-09-06 14:44:13.285 560-881/? I/ActivityManager: Killing 2971:com.signage.mkeyekwwkm/u0a75 (adj 985): empty #18

Will be to add something in MANIFEST in source?

Thank you for help

DF

For more details i’ve found this Expetion in Devel version.

2022-07-07 06:29:36.156 797-797/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.signage.mkeyekwwkm, PID: 797
    java.lang.RuntimeException: Unable to instantiate application uk.org.xibo.player.Xibo: java.lang.IllegalStateException: SharedPreferences in credential encrypted storage are not available until after user is unlocked
        at android.app.LoadedApk.makeApplication(LoadedApk.java:1244)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6683)
        at android.app.ActivityThread.access$1300(ActivityThread.java:237)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: java.lang.IllegalStateException: SharedPreferences in credential encrypted storage are not available until after user is unlocked
        at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:494)
        at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:479)
        at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:188)
        at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:545)
        at org.acra.prefs.SharedPreferencesFactory.create(SharedPreferencesFactory.java:4)
        at org.acra.ACRA.init(ACRA.java:17)
        at org.acra.ACRA.init(ACRA.java:5)
        at org.acra.ACRA.init(ACRA.java:4)
        at org.acra.ACRA.init(ACRA.java:3)
        at uk.org.xibo.player.Xibo.attachBaseContext(Xibo.java:2)
        at android.app.Application.attach(Application.java:351)
        at android.app.Instrumentation.newApplication(Instrumentation.java:1159)
        at android.app.LoadedApk.makeApplication(LoadedApk.java:1236)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6683) 
        at android.app.ActivityThread.access$1300(ActivityThread.java:237) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:223) 
        at android.app.ActivityThread.main(ActivityThread.java:7656) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

This happens when the application starts before the device has been unlocked, which it shouldn’t do.

The only way to run apps before the device has been unlocked is to support “directBootAware”, but this adds a lot of complexity to the solution, and there is nothing Xibo needs to do before the device is unlocked, so it shouldn’t be necessary.

So the answer is - we need to find out why Xibo is being started before the device is unlocked.

Ok, it’s clear.
In the same Device there my devel app thats running well on startup.
Maybe it will be help my Java solution:

MainActivity declared in Manifest as follow:

<activity
            android:name="it.soldout.music4business.MainActivity"
            android:directBootAware="true"
            android:exported="true"
            android:label="Soldout Sounds Experience"
            android:launchMode="singleInstance"
            android:stateNotNeeded="true">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.HOME" />
                <action android:name="android.intent.action.VIEW" />
            </intent-filter>
        </activity>

StartUp Acvitivy declared in manifest as follow:

   <receiver android:name=".StartUpOnBoot">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

StartUpOnBoot class:

package it.soldout.music4business;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class StartUpOnBoot extends  BroadcastReceiver {

    static final String ACTION = "android.intent.action.BOOT_COMPLETED";
    @Override
    public void onReceive(Context context, Intent intent) {
        // BOOT_COMPLETED” start Service
        if (intent.getAction().equals(ACTION)) {
            //Service
            Intent serviceIntent = new Intent(context, it.soldout.music4business.MainActivity.class);
            context.startService(serviceIntent);
        }
    }
}

best regards

Thanks for the code.

Your app works because you have android:directBootAware="true" in your manifest. This is not something we can support as it causes issue with other parts of Xibo.

According to the documentation we shouldn’t need to use android:directBootAware="true" unless we try to access storage before the user has unlocked the device - we don’t do this!

  • we access storage once BOOT_COMPLETED is sent, which should be after the device is unlocked
  • it is strange for a digital signage box to start up locked anyway, most don’t

Make sure you don’t have Xibo set as your Launcher!

Thanks!