Programmatically accessing the KNOX counter - android

How can you access the KNOX counter programmatically from the android SDK?
I would like my app to check the value to try and ascertain if it is running on a samsung phone that has been rooted.

I just decompiled KNOX Status. It looks like all the app is doing is getting the system property ro.boot.warranty_bit. I'm not sure if this still works and I don't have a Samsung at the moment to test.
In terminal run:
adb shell getprop ro.boot.warranty_bit
If the result is 0, then the warranty should be valid. You can use this class to get the system property in an Android app.

Related

How can I add/change the Settings.Global.PACKAGE_VERIFIER_ENABLE

I am trying to set the Settings.Global.PACKAGE_VERIFIER_ENABLE value in Android by using
Settings.Global.putInt(mContext.getContentResolver(),key,value);
However, what ever value I set , I was not getting the value when do following adb command.
adb shell settings get global package_verifier_enable
Thanks InAdvance
in the official android documentation is described that
Applications can read these but are not allowed to write; like the "Secure" settings, these are for preferences that the user must explicitly modify through the system UI or specialized APIs for those values.
This means that unless your app is running as system you're not allowed to write to those settings.
If you have the right signing certificate for the android operating system that you're using, you can sign your app to run with system privileges. As long as you're just running as a "normal" app there is no way to modify these settings.
You can however (which is bad practice) use su to set this setting via
su -c 'settings set global package_verifier_enable 0'

check android device fingerprint status via adb

I am automating the Android app using appium and i have a scenario which need to be verified on both Fringerprint available and not available devices.
To get the devices details like device OS version, name etc. i am using the adb shell command like
adb shell getprop ro.build.version.release
like this i tried to get the props for fingerprint enabled device and i got the below props which are related to fingerprint
[ro.bootimage.build.fingerprint]: [google/angler/angler:7.1.2/N2G47O/3852959:user/release-keys]
[ro.vendor.build.fingerprint]: [google/angler/angler:7.1.2/N2G47O/3852959:user/release-keys]
[init.svc.fingerprintd]: [running]
And now need to know which is the right property to check
Is Fingerprint option available
Is Fingerprint setting is enabled (i mean atleast one finger added or not)
The first two properties you are listing [ro.bootimage.build.fingerprint] and [ro.vendor.build.fingerprint] are not related to a fingerprint reader device, but to the cryptographic fingerprint of the Android disk image for the boot partition (ro.bootimage) and vendor-specific software partition (ro.vendor).
The property [init.svc.fingerprintd] tells you the current state (running) of the fingerprint daemon (fingerprintd) service (svc). This service is needed to enroll fingerprints and perform other operations (see https://source.android.com/security/authentication/fingerprint-hal).
So you need to look elsewhere for a way to check if the fingerprint option is available and set. The FingerprintManager API has a public method hasEnrolledFingerprints() which can be used to determine if there is at least one fingerprint enrolled. You can call this API this from within an app.
From an adb shell, you might have to call the fingerprintd service directly instead of using the API (Use Android API functions with ADB).
To get the unique device fingerprint, use the following adb command
adb shell getprop ro.build.fingerprint

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

setting android wear watch device owner

We are creating an app for android watch (in my case sony 3) that needs a kiosk mode.
Using
adb shell
dpm set-device-owner com.example/.MyDeviveAdminReceiver
I get
Can't set package com.example as device owner.
using
db shell pm list features
I get
feature:reqGlEsVersion=0x20000
feature:android.hardware.bluetooth
feature:android.hardware.bluetooth_le
feature:android.hardware.faketouch
feature:android.hardware.location
feature:android.hardware.location.gps
feature:android.hardware.microphone
feature:android.hardware.screen.portrait
feature:android.hardware.sensor.accelerometer
feature:android.hardware.sensor.compass
feature:android.hardware.sensor.gyroscope
feature:android.hardware.sensor.light
feature:android.hardware.sensor.stepcounter
feature:android.hardware.sensor.stepdetector
feature:android.hardware.touchscreen
feature:android.hardware.touchscreen.multitouch
feature:android.hardware.type.watch
feature:android.hardware.usb.accessory
feature:android.hardware.wifi
feature:android.software.home_screen
feature:android.software.live_wallpaper
feature:android.software.voice_recognizers
feature:com.sonymobile.watch
Does anyone has an experiance own creating a device owner app for android wear watch ?
Haven't tried this with wearables, but most of the times I got errors setting up DeviceOwner through adb was due to an existing google account on the device, meaning it is already provisioned. Device Owner setup requires the device to not be fully provisioned.
More on this: How do you un-provision a device in order to set the Device Owner?

Run google-chrome with flags on Android

There are command line flags (or "switches") that Chromium (and Chrome) accept in order to enable particular features or modify otherwise default functionality.
Chromium Command Line Switches
Run Chromium with flags
Tried Chrome 41.0.xx and Chromium 43.0.xxx shell with:
# echo "chrome <flags>" > /data/local/tmp/android-webview-command-line
# echo "chrome <flags>" > /data/local/tmp/content-shell-command-line
Any idea how to run chrome with flags on Android or directly add these into default profile.
Want to add --sync-url flag to use my sync server instead of google sync servers. chrome://flags only enable/disable flags but wont let you add new flag.
New method added in Chrome 661 that works for a production build on unrooted devices.
Using adb, write the flags to /data/local/tmp/chrome-command-line.
For example:
~$ adb shell 'echo --unsafely-treat-insecure-origin-as-secure=http://a.test > /data/local/tmp/chrome-command-line'
In chrome://flags, turn on enable-command-line-on-non-rooted-devices.
Force stop Chrome (the relaunch now button will not trigger the reading of the flags file, even though the danger snackbar will disagree).
Verify in chrome://version that this worked.
https://www.chromium.org/developers/how-tos/run-chromium-with-flags#TOC-Android
What you're doing is correct, but seems like you're writing the switches to the wrong file for Chrome (and note that the file that you write the switches to may vary based on the OS version [or maybe phone?] ).
I tried this on two different phones, and had to write to two different files! Hopefully one of them will work for you:
Phone 1: Nexus 6 with Android 6.0.1
Simply do the following in adb shell:
echo "chrome --sync-url" > /data/local/tmp/chrome-command-line'
Phone 2: MotoG with Android 4.4.4
This is a bit trickier. It turned out that Chrome actually reads the switches from /data/local/chrome-command-line (not in the tmp subdirectory!). Now the issue is that on an unrooted phone you won't have permission to write to this file! So I had to root my phone* and use su to write to the file:
adb shell
su
echo "chrome --sync-url" > /data/local/chrome-command-line
*Rooting an Android phone is actually very easy and takes only a few minutes. There are a number of one click apps for rooting your phone (e.g. KingoRoot). For the case of MotoG, I had to do a few more steps to root, following this)
I needed insecure origin flag for testing of service workers on mobile device. However, for some reason these flags did not work on mobile chrome. Behaviour similar to insecure origin flag can be achieved by port forwarding.
You can find further info in my original answer here: https://stackoverflow.com/a/56146180/5048121
This does not apply exclusively on service workers, if you need https behavior on mobile device, you can combine it for example with allow-insecure-localhost flag or use self-signed certificate for localhost on server and get rid of cert errors on mobile chrome.
You need chromium debug build in order to use these switches.

Categories

Resources