apbaxel / UKM

Universal Kernel Manager

Home Page:http://forum.xda-developers.com/android/software/zip-synapse-script-universal-kernel-t2736986

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Don't use multiple notifiers which do the same thing

AndreiLux opened this issue · comments

Noticed this while somebody was asking me about global voltage sliders: https://github.com/apbaxel/UKM/blob/UKM-Enhanced/data/UKM/config.json.generate.cpuvolt#L16

You're doing:

notify:['
    while read CPUFREQ VOLT; do
        CPUFREQ=\`$BB echo $CPUFREQ | $BB sed "s/://"\`
        LABEL=$((CPUFREQ / 1000))
        $BB echo '{
            on:APPLY,
            do:[ REFRESH, APPLY ],
            to:"cpuvolt '$CPUFREQ'"
        },'
    done < /sys/devices/system/cpu/cpufreq/vdd_table/vdd_levels
    $BB echo ']

You're creating a notifier for each frequency.

Please don't do that, it will slow down your app since each notifier is a single runnable in the app.

Use this instead:

notify:{
    on:APPLY,
    do:[ REFRESH, APPLY ],
    to:[ 
    `
    while read CPUFREQ VOLT; do
        CPUFREQ=\`echo $CPUFREQ | sed "s/://"\`
        echo '"cpuvolt $CPUFREQ",'
    done < /sys/devices/system/cpu/cpufreq/vdd_table/vdd_levels
    `
    ]
}

Single notifier with multiple targets. It'll cause less overhead in the app.

Cool didn't know you could do that, thanks for the help.

Hey @AndreiLux I tried a couple of ways but still get the error Object[] cannot be cast to java.lang.string. Is it supposed to be like this?

notify:{
on:APPLY,
do:[ REFRESH, APPLY ],
to:[
"cpuvolt 384000",
"cpuvolt 482000",
"cpuvolt 584000",
etc...
]
}

Yes. Can you post the log of the error?

Sure, do you need a logcat or just a screenshot of the error?

LogCat, any time there's a "xxxx failure" error in the interface the app dumps a full stacktrace description of it in the log.

Here you go:

W/System.err(28139): com.af.synapse.utils.ElementFailureException: java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.String
W/System.err(28139): at com.af.synapse.elements.SSeekBar.onMainStart(SSeekBar.java:672)
W/System.err(28139): at com.af.synapse.MainActivity$TabSectionFragment.onElementsMainStart(MainActivity.java:527)
W/System.err(28139): at com.af.synapse.MainActivity.continueCreate(MainActivity.java:185)
W/System.err(28139): at com.af.synapse.MainActivity.access$500(MainActivity.java:63)
W/System.err(28139): at com.af.synapse.MainActivity$SectionsPagerAdapter$1.run(MainActivity.java:360)
W/System.err(28139): at com.af.synapse.lib.ActionValueNotifierHandler.subExtract(ActionValueNotifierHandler.java:128)
W/System.err(28139): at com.af.synapse.lib.ActionValueNotifierHandler.addNotifiers(ActionValueNotifierHandler.java:140)
W/System.err(28139): Caused by: java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.String
W/System.err(28139): at com.af.synapse.elements.SSeekBar.onMainStart(SSeekBar.java:670)

Are you really sure your config is generated as you posted? With notify:{ .. } and not notify:[ .. ] ?

I don't see any error right now, I'll check back later tomorrow for more extensive debugging as it's late here.

For now try to do a notify:[ { ... } ] of the single notifier and see if that works.

Yep, look below I copied directly from the config.json generated:

{ SSeekBar:{
default:0,
action:"cpuvolt global",
unit:" uV",
min:-300000,
max:300000,
step:25000,
notify:{
on:APPLY,
do:[ REFRESH, APPLY ],
to:[
"cpuvolt 384000",
"cpuvolt 432000",
"cpuvolt 486000",
"cpuvolt 540000",
"cpuvolt 594000",
"cpuvolt 648000",
"cpuvolt 702000",
"cpuvolt 756000",
"cpuvolt 810000",
"cpuvolt 864000",
"cpuvolt 918000",
"cpuvolt 972000",
"cpuvolt 1026000",
"cpuvolt 1080000",
"cpuvolt 1134000",
"cpuvolt 1188000",
"cpuvolt 1242000",
"cpuvolt 1296000",
"cpuvolt 1350000",
"cpuvolt 1404000",
"cpuvolt 1458000",
"cpuvolt 1512000",
"cpuvolt 1620000",
"cpuvolt 1728000",
"cpuvolt 1836000",
"cpuvolt 1890000",
"cpuvolt 1944000",
]
}
}},

Try the notify:[{..}] syntax, seems to be an encapsulation bug more than anything.

Same, now it's:

notify:[
{
on:APPLY,
do:[ REFRESH, APPLY ],
to:[
"cpuvolt 384000",
"cpuvolt 482000",
"cpuvolt 584000",
etc...
]
}
]

If you want we can continue tomorrow, we don't have to rush this.

I pushed a new version (0.37) fixing the issue. The above syntax will work now.

Great thank you for the help as always.