Error on schedule notifications (java.lang.SecurityException)


#1

On some devices (samsung, for example Tab S2 and S6, android 7.0) we have game crash with the next traceback.

Case, when schedule defold local notifications. Min SDK 19, Target SDK 26

java.lang.SecurityException: 
  at android.os.Parcel.readException (Parcel.java:1693)
  at android.os.Parcel.readException (Parcel.java:1646)
  at android.app.IAlarmManager$Stub$Proxy.set (IAlarmManager.java:228)
  at android.app.AlarmManager.setImpl (AlarmManager.java:735)
  at android.app.AlarmManager.set (AlarmManager.java:391)
  at com.defold.push.Push.scheduleNotification (Push.java:205)

We already have the “android.permission.READ_PHONE_STATE” permission. Need some more permissions for this?


#2

Hmm, @sven any idea?


#3

Hi!

What Defold version are you using? Do you have a custom AndroidManifest.xml, if so can you share it? Is it only local notifications that doesn’t work?


#4

Version of Defold is last one (136). We have the custom manifest and we using only local notifications
Manifest:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="{{android.package}}"
        android:versionCode="{{android.version_code}}"
        android:versionName="{{project.version}}"
        android:installLocation="auto">

    <uses-feature android:required="true" android:glEsVersion="0x00020000" />
    <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="26" />
    <application
        {{#has-icons?}}
        android:icon="@drawable/icon"
        {{/has-icons?}}
        android:label="{{project.title}}" android:hasCode="true" android:debuggable="false">


        <!-- For Local Notifications -->
        <receiver android:name="com.defold.push.LocalNotificationReceiver" >
        </receiver>


        <meta-data android:name="android.max_aspect" android:value="2.1" />


        <!-- For GCM (push) -->
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />


        <!-- For Facebook -->
        <meta-data android:name="com.facebook.sdk.ApplicationName"
            android:value="{{project.title}}" />


        <activity android:name="com.dynamo.android.DefoldActivity"
                android:label="{{project.title}}"
                android:configChanges="orientation|screenSize|keyboardHidden"
                android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                android:screenOrientation="sensorLandscape"
                android:launchMode="singleTask">
            <meta-data android:name="android.app.lib_name"
                    android:value="{{exe-name}}" />
            {{#android.push_field_title}}
            <meta-data
                android:name="com.defold.push.field_title"
                android:value="{{android.push_field_title}}" />
            {{/android.push_field_title}}
            {{#android.push_field_text}}
            <meta-data
                android:name="com.defold.push.field_text"
                android:value="{{android.push_field_text}}" />
            {{/android.push_field_text}}
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.dynamo.android.DispatcherActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
        <activity android:name="com.facebook.FacebookActivity"
          android:theme="@android:style/Theme.Translucent.NoTitleBar"
          android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
          android:label="{{project.title}}" />
        <activity android:name="com.defold.iap.IapGooglePlayActivity"
          android:theme="@android:style/Theme.Translucent.NoTitleBar"
          android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
          android:label="IAP">
        </activity>


        <!-- For Local Notifications -->
        <activity android:name="com.defold.push.LocalPushDispatchActivity"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            android:launchMode="singleTask"
            android:configChanges="keyboardHidden|orientation|screenSize">
            <intent-filter>
                <action android:name="com.defold.push.FORWARD" />
                <category android:name="com.defold.push" />
            </intent-filter>
        </activity>


        <!-- For GCM (push) -->
        <activity android:name="com.defold.push.PushDispatchActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar">
            <intent-filter>
                <action android:name="com.defold.push.FORWARD" />
                <category android:name="com.defold.push" />
            </intent-filter>
        </activity>
        <receiver
            android:name="com.defold.push.GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.defold.push.FORWARD" />
                <category android:name="com.defold.push" />
            </intent-filter>
        </receiver>


        <!-- For IAC Invocations -->
        <activity android:name="com.defold.iac.IACActivity"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            android:launchMode="singleTask"
            android:configChanges="keyboardHidden|orientation|screenSize">
            <intent-filter>
               <action android:name="android.intent.action.VIEW" />
               <category android:name="android.intent.category.DEFAULT" />
               <category android:name="android.intent.category.BROWSABLE" />
               <data android:scheme="{{android.package}}" />
            </intent-filter>
        </activity>

        <service android:name="com.defold.adtruth.InstallReceiver"/>
        <receiver
            android:name="com.defold.adtruth.InstallReceiver"
            android:exported="true">
          <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
          </intent-filter>
        </receiver>


        <!-- For Amazon IAP -->
        <receiver android:name="com.amazon.device.iap.ResponseReceiver" >
            <intent-filter>
                <action android:name="com.amazon.inapp.purchasing.NOTIFY" android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY" />
            </intent-filter>
        </receiver>
    </application>
    

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.android.vending.BILLING" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <permission android:name="{{android.package}}.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="{{android.package}}.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE" />

    <!--for Samsung-->
    <uses-permission android:name="com.sec.android.provider.badge.permission.READ"/>
    <uses-permission android:name="com.sec.android.provider.badge.permission.WRITE"/>
    <!--for htc-->
    <uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS"/>
    <uses-permission android:name="com.htc.launcher.permission.UPDATE_SHORTCUT"/>
    <!--for sony-->
    <uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE"/>
    <!--for apex-->
    <uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT"/>
    <!--for solid-->
    <uses-permission android:name="com.majeur.launcher.permission.UPDATE_BADGE"/>
</manifest>
<!-- END_INCLUDE(manifest) -->


#5

I’m suspecting it could have something to do with android:minSdkVersion="19", could you try lowering it to 9 (same as in the builtin manifest)?


#6

Game crash still exist even with minSDK = 9 :frowning:


#7

Would it be possible to recreate the issue with a minimal repro case and send it to me? For example, using your manifest and a single collection with a script that schedules a notification?


#8

The reason, what we does not have device, what have crashes with notifications
I will try do something and post later


#9

Is it the manifest you posted earlier that you currently use, I can try to setup a minimal repro here as well. I’ll try to find one of the devices you listed as well.


#10

There is any news with this push error?
Still last post I not tested in production, so dont know fixed it or not

So we have no pushes on Android now (iOS ok) :slight_smile:


#11

No news. Let’s recap what we know. Do we have a repro case? Can you share a small example?


#12

For now I only knew, that game crashing for some of users with Samsung (with turn on push notifications)
Sorry, cant reproduce it now. I will try enable pushes on new version again and let you know, if error still exist or not :slight_smile:


#13

@sven, let’s add local push to our QRT test runs or automated device tests and see if we can catch this on the device farm.


#14

I tried to schedule a local push on Samsung Galaxy S6 [SM-G920F] (7.0) and it worked here. Standard manifest and basically an empty project.


#15

@britzl :+1: Sounds like a plan. It seems strange, still feels like it has something to do with the manifest. I would expect us to hear from internal Defold games about this issue otherwise.