log into Facebook app using am start commands/ADB shell - android

I would like to log into the Facebook app from an android shell using am start commands.
am start -n com.facebook.katana/.LoginActivity
That command brings up the facebook login screen. But how do I fill out the email and password fields and submit it as a one line command from android shell?
I've tried the following....
am start -n com.facebook.katana/.LoginActivity -e email my#email.com -e password mypassword
To no avail, I probably don't understand the usage of extras correctly though.
Additionally, If i'm already logged in these commands work perfectly
am start -a android.intent.action.VIEW -d fb://notifications
am start -a android.intent.action.VIEW -d fb://messages
am start -a android.intent.action.VIEW -d fb://events
But I would like to allow multiple people to access their Facebook accounts using my process.

I don't think you can log in by passing username/pw extras to the Fb LoginActivity.
Take a look at the source code for the LoginActivity, it does not handle extra parameters passed to it for authentication.
https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/LoginActivity.java
The Fb docs do not document the behavior you are asking about either.
https://developers.facebook.com/docs/reference/android/3.0/LoginActivity/

Related

ADB command to show Remove account screen

I want to add and remove google account from device. Programmatically I heard was difficult. I used following command to show screen to add an account, which is working. However, i am not able to find command which removes / manages accounts. Please suggest correct app/intent to launch from adb (or other alternate possibilities to remove account)
I have tried ACCOUNT_TYPES, EXTRA_ACCOUNT_TYPES etc. abd says - Activity not started, unable to resolve Intent
This command launches add account settings screen
adb shell am start -a android.settings.ADD_ACCOUNT_SETTINGS

Is it possible to start an activity via ADB without animation

I know it's possible to have no animation when starting an activity via code (here, for example), but is it possible to do so via adb too, even for activities that were supposed to have an animation ?
Also, is it possible to have no animation when going back from this opened activity?
Looking at the ADB Shell Activity Manager specification for arguments here: https://developer.android.com/studio/command-line/shell.html#IntentSpec
we can see that there is a -f option for Intent flags.
Th Intent flag FLAG_ACTIVITY_NO_ANIMATION has constant value: 65536
See: https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_NO_ANIMATION
Putting that together you could write something like:
am start -a com.example.ACTION_NAME -n com.package.name/com.package.name.ActivityName -f 65536
you can use the below command to start an activity via adb,
am start -n yourpackagename/.activityname

Is it possible to start app without starting test server?

I need to start app before running tests in order to initialize some folders in /data/data/appName/files/ and then I want to use adb command to push some files there.
If I use start_test_server_in_background, it will start tests also...
#I can't do this, bcs it will run my tests before I have data in there
start_test_server_in_background
shutdown_test_server
#I tried something like this, I am not sure how it should be written
http("/ready")
http("/kill")
#Pushing files to created folders afterwards
system("#{default_device.adb_command} push /someFolder/someFiles /data/data/appName/files")
I was able to start app like this:
pn = package_name(ENV['APP_PATH'])
cmd = "#{default_device.adb_command} shell monkey -p \"#{pn}\" -c android.intent.category.LAUNCHER 1"
result = `#{cmd}`
But in the end it was not the problem I got, so my question was misleading

How to "warm start" a deep link visit through adb

I am writing a service that opens deep links to Android apps through adb like so:
adb shell am start -W -a android.intent.action.VIEW -d http://www.example.com/deeplinktest com.example.mjohnst.deeplinktest
The above command works correctly:
Starting: Intent { act=android.intent.action.VIEW dat=http://www.example.com/... pkg=com.example.mjohnst.deeplinktest }
Status: ok
Activity: com.example.mjohnst.deeplinktest/.MainActivity
ThisTime: 606
TotalTime: 606
WaitTime: 731
Complete
What I want to do, is have the app already open/warm to any view, and still be able to visit the deep link.
If I have the app open on the emulator and try this, I get this warning:
Warning: Activity not started, its current task has been brought to the front
and the deep link is not visited (the current, non-linked view of the app is brought to the foreground).
Is there any way for me to visit a deep link on an already open app through adb or another interface?
EDIT: I know that there's a -s flag to kill the app before visiting, but this is not what I want. I would like the warm start to provide a performance gain
I discovered that if you start the app via a non-deeplink activity, deep linking "warm" will work.
Used this adb command to start the app:
shell am start -a android.intent.action.VIEW -n {packageName}/{activityName}

How to get extras of currently running activity through ADB

I have a question about using ADB.
I know that this command:
adb shell dumpsys activity
can show me all the activities that are currently running on the device.
But I notice that sometimes, the intents appear like this:
Intent { ...some_intent/activity_name.... (has extras) }
I know that extras mean that the activity has been started with some sort of parameters passed to it (I may be wrong here, please correct me if I am).
So my question is, how can I get the extras of the intent/activity through ADB ?
The reason I need this is because I'm trying to launch an apk (that is installed on the phone) through ADB command, something like:
adb shell "su -c 'am start -n com.package.name/.ActivityName'"
That works and bring up the application. The application has a start screen (say we call it HomeActivity) and you have to click a button and make some selections (say SelectionActivity) and it will go to another screen (say ActionActivity). I want to be able to launch the apk and make it go straight to ActionActivity.
The application will crash if I try to launch the ActionActivity with am start command, I'm assuming this is because it requires parameters from the SelectionActivity screen.
This is why I'm trying to see what are the "extras" or parameters that the ActionActivity screen actually gets, so that I can do something like:
adb shell "su -c 'am start -n com.package.name/.ActionActivity -e param1 val1 -e param2 val2'"
Hope my question is clear.
Please correct me if I'm making a mistake somewhere.
Thanks in advance!
If I am understanding correctly, your target is to start the 'action' activity with correct intent but you don't know what kind of parameter information should be included, right?
The dumpsys command won't dump everything you want, so to simply achieve your target, you have 2 options (you should find one device which you can burn your own firmware into it):
Modify the dump method in AMS to print out more information
Modify the ActivityThread class source code to print out the detailed intent information

Categories

Resources