Houston
Houston

Reputation: 437

Operation inside thread freezes UI on Android

I am using a 3rd party SDK in my Android app. An initialization method on the SDK must be called and the method takes the application context as an argument like so: sdk.initialize(getApplicationContext()). Now this works fine on a normal device however it freezes the UI on a rooted device. The SDK vendor says this is by design because they want to prevent the software from running on rooted devices. In response, I now run the method inside a thread. I've tried traditional threading and AsyncTasks but the UI still freezes. How is this possible? Can the SDK use the application context to block the UI?

Upvotes: 0

Views: 113

Answers (1)

FunkSoulBrother
FunkSoulBrother

Reputation: 2167

Simple - the SDK uses runOnUIThread to check if the device is rooted (let's say - it tries to list the files in a directory that require root privileges) and this is what makes your rooted device become unresponsive. on a rooted device - this may take time (maybe they do it more than once on purpose, to make it impossible to run on a rooted device).

on a normal device - a security exception is probably thrown when this code runs (because the app does NOT have root permissions) and that's how the SDK knows that device is not rooted.

Upvotes: 1

Related Questions