setting android wear watch device owner - android

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?

Related

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.

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

Retrieve Device ID from android using perl

I have 3-4 android devices connected to my laptop (with working ADB on windows). Now I want to trigger Youtube app on all these devices simultaneously and run that for a certain duration at a given time. The script will read the devices connected and trigger the app on it's own.
Requirement:
Is there a way I can take out the Unique Device ID and store it somewhere and use it for my rest of the programming?
For example:
C:\Users\Arka.B>adb devices
List of devices attached
94e38259 device
94e38260 device 2
94e38261 device 3
94e38262 device 4
Questions:
How do I take out this unique device id (94e38259, 94e38260, etc in this case) from each of these devices and trigger some other actions like launching an app or installing an APK?
You can store the device ids using following script:
my $output = `adb devices`;
my #devices = split("\n", $output);
my #deviceids;
foreach(#devices){
chomp($_);
push(#deviceids, $1) if($_ =~ /(.+)\s+device$/);
}

Programmatically accessing the KNOX counter

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.

Categories

Resources