[Coding] How to Catch an Exception when trying to get root - Android Software Development

I'm working on an application that requires root, I have gained root access, and everything works, but I need to know how to throw up a toast notification whenever I am denied root. Any ideas?
catch (Exception e) {
Toast.makeText(NotificationLights.this, "Couldn't get SU, are you rooted?", Toast.LENGTH_SHORT);
return;
}
That is what I'm currently using and it accomplishes nothing

Related

SU Request Problems

Whenever i use anything that requires getting SU request i just get a black screen with no allow or deny and after awhile it says Activity SU Request (in application Superuser Permissions) is not responding force close or wait...
Any help to fix this problem and be able to use these apps like wifi tether and root explorer would be great
Thanks Masta Of Evil

[Q] superuser access control

It seems that I have no control (using CM 10.2.1) over restricting superuser access. I thought I had reasonable options selected (prompt and log), but then I realized that I am getting no prompts and no log entries. So I disabled root access completely, but all of the apps that require root access are still working without any problem (even after a reboot).
Can anyone explain what is going on (and how to actually restrict root access)?

[Issue] Hangouts Refusing to sign in

During my time while hangouts was working, I tried to use the Xposed SMS mod that added a "quick reply' menu for replying. While attempting to get it to work, I pressed "Uninstall updates" with hangouts and managed to break the online portion of hangouts, preventing me from signing in with it. Specifically after a short period of "signing in", it would flash a "Couldn't sign in because we couldn't reach Google. Try Again." on the 2.1 APK version. For the material-styled v2.3 version that just released it's just stuck in a infinite loop for "Signing In". While trying to debug the issue I came across this ADB error printed that says "V/GCM﹕ not posting request to register com.google.android.talk because of backoff period." Fiddling with the "clear cache/data" option reposts that log. I already reflashed Gapps, turned on/off exposed, and reset as much data pertaining to the other gapps(gmail, gplay etc. work fine), and tried diffrent version of the app out. No solution currently works. I'm currently on the Alliance Rom, with root & xposed(currently disabled).
another log entry:
"[avd][avd] Permission for com.google.android.talk to access oauth2:https://www.googleapis.com/auth/chat https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/hangouts https://www.googleapis.com/auth/chat.native will be managed locally."
consistenly afterwards I also noticed a "GCM registration failed" notice.
specific order:
1"register - retrying gcm registration:Redacted-21"
2"Implicit intents with startService are not safe: Intent { act=com.google.android.c2dm.intent.REGISTER (has extras) } android.content.ContextWrapper.startService:506 com.google.android.apps.babel.realtimechat.GcmIntentService.xS:295 com.google.android.apps.babel.realtimechat.x.ya:401"
3."I/GCM﹕GCM config loaded"
4."V/GCM﹕not posting request to register com.google.android.talk because of backoff period"
5."I/Babel: [GcmIntentService] gcm error: SERVICE_NOT_AVAILABLE"
6. "E/Babel﹕ Gcm registration failed"
7."D/CMASMessage﹕ [update] mShowingCMASText is false" *repeats multiple times*
Did you fixed it? Im also stuck at signing in in my s4 running Dan's cm11 m9 stock kernel.
Nope.not seems to be related to GCM which handles communications. Flashing a new GAPPS package may fix it if your try that.

Suspicious adb activity

So I have rooted my N910H using cf autoroot. Never used adb or anything else on it, but, suddenly earlier today out of nowhere I got a permission request for "ADB Shell UID" and as soon as I granted the permission I got lots of notifications telling me what adb shell uid was doing because of that permission...
So I kinda scared and decided to deny it. As soon as I denied it, I got all the notifications about how adb shell uid couldn't perform different tasks because of the denial.
I tried to google but I found nothing about it.
Now does anyone know what that was about and if I should grant permission again or should I keep it denied..? If it's not a good thing how am I supposed to get rid of it?
Yeh I am getting exactly the same thing, didn't use CF AutoRoot though
probably spyware payload unpacking itself. once your rooted you have no protections. cant do anything about it.

Disable OTA - Keep SDCard Write Access and Use a Different Launcher *READ BEFORE BOOT

Since root has been obtained and an alternative launcher can be installed, as has been mentioned there is really no need to stay on 5.0.0 anymore. I would recommend updating to 5.0.1. However, this procedure can still be applied to 5.0.1 and hopefully it'll prevent any future updates. (As of writing it 5.0.1 is the latest).
The steps are basically as follows:
Enable ADB by going to Settings> Device Options. Keep tapping on the Serial Number field until the Developer options field appears.
Under Developer options Enable ADB
Hook the Fire up to your computer and do the following commands:
adb shell pm hide com.amazon.otaverifier
adb shell pm hide com.amazon.device.software.ota
adb shell pm hide com.amazon.settings.systemupdates
I don't know which of three is the magic one, But you can not longer go to device options > system update. It also never appears to pull down the update in the background.
Rivethread23 - good work and many thanks for this
I know that you have the original Fire 7 with no system update but I wanted to see if any of your commands will work on 5.01. My device is on 5.01 has been in aeroplane mode since purchase, I have been using OTG Ethernet for connectivity and I have not signed into Amazon. Google Play is installed - basically a standalone device on 5.01 with no association with Amazon.
After running the commands and the ADB shell gave a [True State] after each command. Rebooted the device:
System Updates now gives the following error message: [The requested action is not permitted. Check Parental controls settings and try again]. As my device is not associated with Amazon parental controls have not been configured - so I browsed to a few proxy sites and such to confirm no filtering on web browsing etc
I've tried various launchers from Play store and every time the default Fire Launcher kicks back in again.
SD Card issue is still there.
When you tried the System Update button did you get the same error message as me? If so, I wonder if the Adb Shell command to disable OTA works on 5.01 as well?
Update 1: [adb shell pm hide com.amazon.firelauncher] disables the default Amazon launcher. I picked another launcher at random from Google Play. Halo installed and it worked with the default launcher hidden, however using the minimise middle button on the device forces the Parental Control Popup to appear.
So it is possible to hide the default launcher on 5.01 using ADB but it is causing issues. We need a better work around.
Unfortunately this only blocks the update from occurring. I ran into another issue on the 5.0.0 tablet in that I can't get Google play store working. It just says cannot connect. So I don't know if one of the above things broke it. It was getting late so I went to bed. I'll keep plugging at it and see what I can do.
I might finally take both of mine out of the box today, can more people confirm this is working? @Rivethread23, did you get the play store sorted out?
Couldn't wait, dove in. On an out-of-box Fire, running 5.0.0, these do in-fact keep the OTA updates from firing. I have been online, installing apps and customizing the tablet for over an hour with many reboots, no prompts or attempts of an update.
With this, and ads disabled, and the play store turned on we have a usable tablet!
F-Droid works as well, just sideload their APK to get access to lots of software:
https://f-droid.org/repo/org.fdroid.fdroid_96150.apk
Still stuck on Play Store in 5.0.0 *not working* for now.....same problem as OP
I can confirm that the Google Play Services, Login Services, and Framework are (at least partly) working, even though the Play Store is not. I sideloaded Gmail, and it automatically had my info, and downloaded my email.
Wait, I'm confused. In 1 post you say play store is on and working, then you're saying it's not...
Aside from the play store, it sounds like everything else is working fine! Is that correct. I'm asking because I'm thinking about buying a 2nd one of these, only if I can have it working 100% the way I have it now with my tablet, just with the ability to use a different launcher.
With the original 5.0.0 firmware, if you prevented the OTA update to 5.0.1:
+Can change launcher
+Can write to SD from apps
-Can't get Play Store to work (so far, but can manually side-load GApps (Gmail, Hangouts, etc))
In the other thread, people that have gone to 5.0.1:
-Locked to amazon Launcher when using HOME button
-Manual SD writing is disabled
+Google Play Store can be installed and 90% of the GApps work
--------
The key to take away is that if you get another one, and you do the fix in this thread to prevent OTA updates, you can simply wait til everyone gets things fixed and figured out. You can safely use it and not worry about getting pushed to a firmware that might be even more locked down.
On the other hand, if you're not worried about OTA updates breaking stuff, and want a working store, go to 5.0.1 and follow SD_Shadow's instructions in his thread on that subject.
Hopefully root comes soon and we can fix all these problems properly, but until then it's kinda hit and miss depending on what version you got.
Hope that helps.
Thanks Tufkal was going to post something along those lines but you beat me to it.
Essentially you can prevent updates from further locking down the tablet. Who knows what future updates bring? I'll wait and update as thing warrant.
I have two one on 5.0.0 and another on 5.0.1. While I like being able to use the launcher of my choosing on 5.0.0, the working google store and updated amazon store and apps have me using the 5.0.1 one. I am keeping the other on 5.0.0 until development starts then I'll try my hand at making a ROM.
Your device that is on 5.0.0 Firmware have you signed into Amazon and associated your device? Or is it standalone like mine?
Was on Amazon for a day. Factory reset it and am using it sans Amazon. Mostly using the 5.0.1 one myself.
Yep same here. 5.01 with no amazon sign in.
I've been playing around with the launcher again. Tried changing the hardcoded buttons and also with ADB Shell am force-stop pm disable on com.amazon.firelauncher to stop dependent services, ie hard buttons. All to no avail.
root definitely needed for this
I figured out a way to access some hidden functions within the OS last night. Seeing where this leads after work today Apparently I can cast the screen and access the home function disabled in 5.0.1. Problem is the home function doesn't override the hard coding.
Most interesting is something called Prod and Devo Switch that give "Access Denied" when I try to activate it. Hmmmm........
Here's what I have discovered. It's easier done on 5.0.0 but can be done on 5.0.1. You'll need another launcher like Nova installed. Installed "Anycut" from the google store. It'll let you put a shortcut on the desktop for any "activity". There are alot of items there not normally accessible. You can cast to a Chromcast for example (it works). The reason you need another launcher is the Amazon launcher doesn't support shortcuts I guess as they don't appear. They appear on Nova's desktop when created.
Most interesting is a shortcut called "Prod and Devo Switch" which if you look at the info refers to the "Amazon Device Settings" app.. ( com.amazon.device.settings?). It's separate from the user settings. If you try to access it it will say "Access Denied" on 5.0.1. Or "Permission denied" on 5.0.0. Makes me wonder if what needs to happen the app needs some additional permissions to be run. I was looking through the list of permissions via ADB and there are a number of permission groups that are android.xxxxx. However there are only a few permission groups that are amazon.xxxxx one of which is amazon.permission-group.settings. Listing the settings in the group shows a large list. Maybe using ADB pm grant com.amazon.device.settings the correct permissions could unlock this? Thoughts?
Here's what I got from a logcat when I click on the shortcut in novalauncher:
I/ActivityManager( 454): START u0 {act=android.intent.action.VIEW flg=0x1000000
0 cmp=com.amazon.device.settings/.DevoProdConfigActivity bnds=[300,168][400,310]
} from uid 10017 on display 0
W/ActivityManager( 454): Permission Denial: starting Intent { act=android.inten
t.action.VIEW flg=0x10000000 cmp=com.amazon.device.settings/.DevoProdConfigActiv
ity bnds=[300,168][400,310] } from ProcessRecord{9460965 1138:com.teslacoilsw.la
uncher/u0a17} (pid=1138, uid=10017) requires com.amazon.dcp.permission.DISPLAY_D
EBUG_UI
E/Launcher( 1138): Launcher does not have the permission to launch Intent { act=
android.intent.action.VIEW flg=0x10000000 cmp=com.amazon.device.settings/.DevoPr
odConfigActivity bnds=[300,168][400,310] }. Make sure to create a MAIN intent-fi
lter for the corresponding activity or use the exported attribute for this activ
ity. tag=ShortcutInfo(title=Prod and Devo Switch intent=#Intent;launchFlags=0x10
000000;component=com.amazon.device.settings/.DevoProdConfigActivity;sourceBounds
=300%20168%20400%20310;end id=15 type=Shortcut container=-100 screen=1 rank=-1 c
ellX=3.0 cellY=1.0 spanX=1.0 spanY=1.0 dropPos=null user=UserHandle{0} modelGene
ration=-1) intent=Intent { act=android.intent.action.VIEW flg=0x10000000 cmp=com
.amazon.device.settings/.DevoProdConfigActivity bnds=[300,168][400,310] }
E/Launcher( 1138): java.lang.SecurityException: Permission Denial: starting Inte
nt { act=android.intent.action.VIEW flg=0x10000000 cmp=com.amazon.device.setting
s/.DevoProdConfigActivity bnds=[300,168][400,310] } from ProcessRecord{9460965 1
138:com.teslacoilsw.launcher/u0a17} (pid=1138, uid=10017) requires com.amazon.dc
p.permission.DISPLAY_DEBUG_UI
Tried granting that specific permission to Nova launcher or the Fire launcher but both do the same thing:
com.amazon.firelauncher com.amazon.dcp.permission.DISPLAY_DEBUG_UI <
Operation not allowed: java.lang.SecurityException: Package com.amazon.firelaunc
her has not requested permission com.amazon.dcp.permission.DISPLAY_DEBUG_UI
Maybe someone with more knowledge than I create a program with that permission that calls the intent in question?
Again good work on this
I picked up another new device yesterday morning. OTA updates disabled, Fire OS 5.0, no association to Amazon and connectivity via WiFi. Just like you I got Gmail, YouTube and other Google associated apps to work with the exception of the Play store. It finally let me sign in but comes up every time with the [Connection Retry] error.
I followed your instructions and installed AnyCut - and I have been playing around as I thought it might be possible by using shortcuts to load my Google account onto the device.
Shortcut [Add an account] - and the "Couldn't sign in - google server error" came back so not working for now.
Shortcut [Testing] - allows us to pull up more info on the Fire 7 with the 4 below options
Tablet Information - not working
Battery Information - working
Usage Statistics - working
WiFi Information - working
Shortcut [IP Settings] - gives us advanced WiFi options
A lot of the options try to load or there is a visible presence of starting to load and you can clearly see the device stopping them from loading. Basically we are trying to load Android Apps that are locked down by Fire OS which sits on top of Android.
Other apps with Permission Denied
[Log Manager]
[Crash Manager]
[Metrics Debug UI]
Looks like Amazon do not want us to have access to their inbuilt log files on their device
As I do not have access to Google store I have been using F-Droid for my apps. I have installed APK Extractor and it lists all the current APK's on the Fire 7. What is interesting about this is that there are APK's that where not findable using [AnyCut] but show up in APK Extractor.
Will update more in a bit
Here's an interesting note..... I'm on 5.0.0 and trying to get the Play Store working (I believe that 5.0.0 w/ Play Store is a better avenue to attack than trying to fix the launcher in 5.0.1)
For testing reasons I'm on an older version of the Play Store where the search icon is visible.
On the play store screen where it says no connection with the retry button, I hit the search icon and start typing "clas" It autofilled in clash of clans. Then i did "hang" and I see hangouts dialer. The play store app is communicating it would seem.....
tufkal said:
Here's an interesting note..... I'm on 5.0.0 and trying to get the Play Store working (I believe that 5.0.0 w/ Play Store is a better avenue to attack than trying to fix the launcher in 5.0.1)
For testing reasons I'm on an older version of the Play Store where the search icon is visible.
On the play store screen where it says no connection with the retry button, I hit the search icon and start typing "clas" It autofilled in clash of clans. Then i did "hang" and I see hangouts dialer. The play store app is communicating it would seem.....
Click to expand...
Click to collapse
What is the version of your Play APK please? As I have the latest version with no search - but still on 5.0.0
k3ll0gs said:
What is the version of your Play APK please? As I have the latest version with no search - but still on 5.0.0
Click to expand...
Click to collapse
I'm trying all kinds, the one i was using for that test I got here:
https://onedrive.live.com/redir?res...4&authkey=!AIVXLFXAOWDeM0Q&ithint=folder,.apk
I'm with you I tried some work arounds on the 5.0.1 tablet but if we can get the play store working on 5.0.0 it seems to offer more opportunities.
Yep same here - it makes more sense to get Play store to work.
I think I might know what the issue is causing and I believe it is down to the Google Service Framework (GSF) on 5.0 not installing correctly and causing the sync issue when trying to connect. I installed [Device ID] app on 5.0 and there is no serial listed for GSF at all - on my 5.1 tablet GSF would load up on the screen and you could view settings but on 5.0 it does not.
When trying to open the Google Play some I found the following error in Logcat [.onClick: b/5160617: Reinitialize account] this relates to the GSF serial not being present. Logs also show permissions and api errors as well. The only
Looking into a GSF workaround if possible. It might be on the wrong track but I am going to see what else I can find out.
I thought I had found a back door into Google signin. Using an App calling [Applications Info] which I used to pull up the GoogleServiceFframework apk. From there I started to play around with the launch options for the applicable services.
Selecting launch on [Legal Services] takes you to Google Sign In - keyboard was not working for this so I had to adb shell input text of my gmail & password. Unfortunately the same old Google error was appearing even after I cleared the cache and re-installed Gapps.
The last screengrab shows that the System Updates on installed Google Service Framework is corrupt and not working properly. I have also launched other Gapps dependent activities from the services in [App Info] and again they either fail to load of abundance of errors. So installation issues for all of the Gapps in one way or another on Fire 5.0
Obviously there is a difference between the 5.0 Rom + 5.01 Rom that is stopping Gapps from working. Due to the amount of errors in Logcat and in Application Info and dependent services not working. My gut is saying that when we have root on 5.0 we have a better chance of getting Gapps working as we will have the ability to play around with not only System files but System commands too.
If anyone has any ideas or what else we could try please chip in.
rivethead23 said:
Hook the Fire up to your computer and do the following commands:
adb shell pm hide com.amazon.otaverifier
adb shell pm hide com.amazon.device.software.ota
adb shell pm hide com.amazon.settings.systemupdates
Click to expand...
Click to collapse
running those commands will prevent any future update?
Right now I have 5.0.1 and I'm happy with it, I would like to avoid any bad surprises.
redst said:
running those commands will prevent any future update?
Right now I have 5.0.1 and I'm happy with it, I would like to avoid any bad surprises.
Click to expand...
Click to collapse
yes updates would be blocked until you run the unhide commands.
Sent from my KFFOWI using Tapatalk

Categories

Resources