Cannot record screen on Android 4.4.2 - android

I am trying to record my device screen using the shell command as outlined here:
http://developer.android.com/tools/help/adb.html#screenrecord
Using the verbose flag, I am getting a Permission Denial that I think is connected to the fact there is an Owner profile on the device, as it references User 0 and User 1 in the error message.
Does anyone know how I can remove the Owner profile (can't see any options to do so) or how I can set the Owner to user 0?
EDIT - clarification, the error states "broadcast asks to run as user -1 but is calling from user 0"

I got the recording to work.
It seems that for whatever reason, you need to do this via adb shell.
Whilst adb shell is running shell commands on the connected device, running the screenrecord commands directly on the device just doesn't want to work.

Related

adb - Script to add PIN but not secure start-up

I'm trying to write a shellscript to create android emulators programatically (OS version >= 7.1.1), and I want those emulators to have a PIN but not "secure start-up".
Note that "secure start-up" is not the "lock screen" and also not the screen to unlock an encrypted device.
The secure start prevents android from booting without first inserting the PIN; lock screen is what appears after the boot up has finished.
Here's the description that shows up on Android 8.1 when you set the PIN manually on the emulator:
And what shows up when the emulator starts with the secure start-up activated:
I only managed to insert the PIN using the command:
adb -s <emulator_name> shell locksettings set-pin 1111
but this also activates the secure-start and I didn't find a way to deactivate it.
Do you know a command to deactivate only the secure-start and not the PIN? Thanks!

Device owner not being cleared on Android M

I wrote a device owner kiosk app that I'd like to remove the device owner status on so I can uninstall it without having to factory reset the device. The following works on Nougat and Oreo, but not Marshmallow for Samsung tablets.
The specifics of how I'm coding the device owner stuff:
To set the app as device owner, I am running this adb shell command after installing the app:
adb shell dpm set-device-owner com.dps.myapp/.DeviceAdminReceiver
Then when I am trying to remove device owner status and uninstall the app, I am running these shell commands:
adb shell am force-stop com.dps.myapp
adb shell am start -n com.dps.myapp/.DeactivateDeviceOwnerActivity
adb shell pm uninstall com.dps.myapp
DeactivateDeviceOwnerActivity is an Activity in my app that contains the following code to clear the device owner status:
DevicePolicyManager mDevicePolicyManager = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
mDevicePolicyManager.clearDeviceOwnerApp(getApplicationContext().getPackageName());
if (mDevicePolicyManager.isDeviceOwnerApp(getApplicationContext().getPackageName())) {
Toast.makeText(getApplicationContext(),
"Failure! App is still device owner.",Toast.LENGTH_LONG)
.show();
}
else {
Toast.makeText(getApplicationContext(),
"Success!", Toast.LENGTH_LONG).show();
}
What is so weird is that my Activity is displaying the Toast that the clearDeviceOwnerApp call worked, but when I run the uninstall command immediately after, I get the "Failure [DELETE_FAILED_DEVICE_POLICY_MANAGER]" return from it, so obviously the device owner was not cleared for my app.
Does anyone know of any specific differences between Marshmallow and subsequent APIs, regarding device ownership or DevicePolicyManager that would cause this code, that works on Nougat and Oreo, to not work on Marshmallow? When I issue the start command to have DeactivateDeviceOwnerActivity clear the device owner, I'm looking in the system log and I'm not seeing anything that indicates any exceptions occurring. Any help would be appreciated.
I have not faced such an issue on Marshmallow.
This is strange, although I can't give an answer, I will suggest something
1) This might be a bug. So, you can factory reset device and try again.
2) It is very convenient to use the emulator for this type of testing as you can easily just delete and create a new one.
I hope it helps.

Appium : How to launch app from Android For Work work profile

I need to launch an app which is in different work profile (Android For Work). If install the app in personal profile then I am able to launch the app from the personal profile on the same device.
However, When I install the app only in the work profile then I am not able to launch the app through adb command.
As per my understanding, google keeps two different containers for personal and work profile. I think the work profile has different space and adb does not have any access to that app and workspace of work profile.
I need to launch the app through appium
If anyone has the answer to the above problem, please answer. Thanks in Advance !
Do you mean launching application on different user account ? check this link please : https://stackoverflow.com/a/24093533/5093606
You can get try to get list of accounts using
adb shell pm list users
and if you working account is there, try
adb shell am start --user WORKING_ACCOUNT com.example.MainActivity
Yes, there is way to launch the apps by using Appium/Adb commands. Instead of appium use adb commands to launch the apps.
The app which you have used for AndroidForWork enrollment, it should be in android:debuggable mode. Set debuggable mode to true and build the apk.
Once the device is enrolled/Configured Androidfor work then get the list of users.
adb shell pm list users UserInfo{0:Drew:13} running UserInfo{10:Work profile:30} running
Get the workprofile user id. In this case 10 is the id. Use the user id to launch the apps.
adb shell am start --user 10 -n "com.android.vending/com.google.android.finsky.activities.MainActivity"
Note: If the provision app is not enabled in Debug mode then you don't have the access to the work profile user.
Turns out I was able to accomplish this with Appium Desktop by adding another parameter to the inspector:
optionalIntentArguments text --user 12
Where '12' is the work profile id you'd see from typing this:
adb -d shell pm list users
Users:
UserInfo{0:Ken Corey:13} running
UserInfo{12:Workspace:50100030} running

android using GSMPhone to communicate with rild

I'm working on a non phone device that run Android 2.3.3. We have a custom Android version (with some additionnal driver) and my application has "system" privileges since we build our apps with the same key used to build android.
I had unlocked full Android API (including com.android.internal.*) following this post : https://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-1-introduction/.
I deleted the Phone.apk from the device to ensure that no process is using rild.
I can instanciate a GSMPhone from my app, but after, I'm unable to execute any commands like supplyPin or getImei. I always have the same error : 
CommandException: RADIO_NOT_AVAILABLE.
I'm really stuck here, any help would be precious.
CommandException: RADIO_NOT_AVAILABLE indicates that the rild socket is not opened. In other words, the rild service is not attached to the underlying basebane/modem you are using.
Run ps in adb shell to check if rild service is in the list. If it is in the list, run ls -l /dev/tty* and check if the modem device attached with the Android platform exists here or not. If it does not exist, it means that the Kernel is unable to enumerate your modem device and you need to add support in kernel for it. If it exists, run adb logcat -b radio and check the radio logs output which would really be helpful to diagnose the issue further.
adb shell ps | grep rild to check if RILD is in runing.
Since you can access all the api, do some initialization like PhoneApp do in Phone application OnCreate(mostly like setting params to modem, set radio power which will power on/off the modem, etc)

Android regular user login loses group information when su to another user in an ssh session

What I'm doing:
I've built GNU emacs for native use on an phone.
I run emacs in daemon mode on the phone, so I connect to it anytime with emacsclient, to continue working with regular files, run processes, etc.
When logging in from the terminal on the phone, I'm currently user 10157, everything works:
$ id
uid=10157(10157) gid=10157(10157)
groups=10157(10157),1015(1015),1023(1023),1028(1028),3003(3003)
When I connect via ssh to the phone from a PC (I use DigiSSHd on the phone), it logs me in as a regular user 10282, everything works:
$ id
uid=10282 gid=10282 groups=1015(1015),1023(1023),1028(1028),3003(3003)
Emacs runs fine etc. However, this way I can't connect via emacsclient to the emacs process running under user 10157. This is desirable, since I don't want to start two emacs processes, since I want to continue working with files that I have open in emacs under user 10157.
Therefore:
$ su - 10157
Fine, I can run emacs etc. However, I cannot access the web.
$ ping -c1 google.com
You must have internet permissions to use ping. Aborting.
$ id
uid=10157(10157) gid=10157(10157) groups=10157(10157)
Thus I'm no longer in group 3003, necessary for internet access, besides other groups also.
Why does this group info get stripped, and how can I remedy this, so I can continue accessing the web when su as this user under ssh?
When i run the command:
busybox --list
I don't see su in the list.
su --help
shows Superuser.apk in the help text. It means su is provided by Superuser app.
I followed the steps described by you and i could su as another user and still have internet permission as shown below.
I have the following apps installed.
BusyBox v1.18.5-Stericson
Superuser v3.0.7
Terminal Emulator v1.0.45
SSHDroid v1.9.6
Suggestion:
I think the issue is with su on your device. You may try this one.
https://play.google.com/store/apps/details?id=com.noshufou.android.su
If i just use adb shell without running SSHDroid still i can su as another user with internet permission.
Note: The BusyBox id command doesn't show groups information always.
According to the standard man page for su (from a linux box)
When - is used, it must be specified as the last su option. The other forms (-l and --login) do not have this restriction.
Based on that, try
$ su 10157 -
I'm probably missing something here because this seems way too obvious but why not just 'sudo -u 10157' your emacs program?
you'd still have access to the net and your emacs would be working. or did I miss something important?
Permissions are not environment variables that can be inherited via su -.
Moreover, gid are are hard coded and their associations with each APP uid cannot be changed after installation.
10157 should be the uid of the DigiSSHd application, thus you could try to rebuild it after changing the AndroidManifest.xml to require the proper permission.
You can find something useful here and here.
The same should work for BusyBox (see here).
However, you could open some security hole by enabling NETWORK access through such applications.

Categories

Resources