Android CTS 7.0: CtsCarrierApiTestCases item failed in "testHasCarrierPrivileges" - android

I am now trying to run the Android CTS 7.0 on Google Nexus 6 (AOS:7).
There is an fail in the item "CtsCarrierApiTestCases"
The error message is:
android.carrierapi.cts.CarrierApiTest#testHasCarrierPrivileges
fail
junit.framework.AssertionFailedError: This test requires a SIM card with carrier privilege rule on it.
We had checked the following Android web page:
https://source.android.com/devices/tech/config/uicc.html#prepare_uicc
According to the above link, we need to add the CarrierPrivileges to the UICC card and this has to be done through the Telephone System provider.
Unfortunately, till now we do not have the contact to our system provider here in Taiwan.
Any chance that we can do this by our won in the lab?
We are thinking to buy a card reader and a blank SIM card, could this be a direction?
Any advice is welcome and thanks in advance.

I had encountered same issue. Some cts tests are only allowed for system priviledged apps or if app has UICC carrier privileges.
In both options are not availabe, as a workaround, /AOSP/platform/packages/services/Telephony/src/com/android/phone/PhoneInterfaceManager.java can be tweaked as shown below to disable permission checking in source code.
After aplying patch, run "mmm platform/packages/services/Telephony/" followed by "adb remount && adb sync" to update system priviledged app /system/priv-app/TeleService/TeleService.apk.
One time device reboot is required afterwards.
private void enforceModifyPermissionOrCarrierPrivilege(int subId) {
+ log("CTS CarrierPrivilege Allowed Patch");
+ return;
int permission = mApp.checkCallingOrSelfPermission(

Related

Run an instrument test from within app and wait for result

I am developing a QA automation solution that can record/playback QA tests on Android. A key business requirement is to have no dependency on a connected PC while playing back the recorded test. To that end, I'm trying to run an Instrumentation test without a connected PC. (Specifically, an Appium UiAutomator2 test).
My current approach is trying to run the test programmatically from my app. If I were running the test normally from a connected PC, I would use the command adb shell am instrument -w. I tried accessing ADB Shell from my app and running am instrument -w, but this produces an error that I am missing the INTERACT_ACROSS_USERS_FULL permission.
To get around this issue, I am trying to run the test using startInstrumentation. This successfully starts the test. However, the test immediately crashes. Upon further investigation, I traced the crash to an NPE: the test is trying to retrieve InstrumentationRegistry.getInstrumentation.getUiAutomation(0), but this returns null.
How do I run the test programatically and give it access to the required UiAutomation instance?
This is how I start the test:
public void runTest() {
final String pm = getPackageName().replaceFirst(".test$", "");
final InstrumentationInfo info = getInstrumentationInfo(pm);
if (info != null) {
final ComponentName cn = new ComponentName(info.packageName,
info.name);
Bundle arguments = new Bundle();
arguments.putString("class", "io.testim.appiumwrapper.test.AppiumUiAutomator2Server");
//cn = {io.extension.test/android.support.test.runner.AndroidJUnitRunner}
startInstrumentation(cn, null, arguments);
}
}
see signature protection level - clarifying ...unless having the package white-listed by Google's release key, you won't be able to obtain the necessary permission. this is a security/integrity feature, with the purpose to limit what malware is able to do - and what you intend to do there, is typical malware behavior - no matter the actual intention of it; working against the system leads nowhere.
the only way I could imaging would be to run commands directly from a terminal emulator or the test application - against a custom build of AOSP, so that you could add android:protectionLevel="signature" to the Manifest.xml and then require android.permission.INTERACT_ACROSS_USERS_FULL. but with a stock ROM, there definitely is no chance to do so. it is not, that it would be "impossible", but building a custom ROM means quite some effort, in order to get there. at least for Nexus and Pixel devices, the required drivers are available here; for other devices, you'd have to find them at the device's vendor, if they're even available.
the trick is to sign off the ROM with the same key as the app - only then signature level permissions can be obtained - while for a stock ROM, you'd (theoretically) need Google's release key to sign off the package. one can enforce single user, as explained here, while this also is only available to system apps.

Getting into root mode via an App for a device that is not rooted

I'm trying to read the MSR information from an android device with userDebug build , and it requires root permission. I have tried adding :process = Runtime.getRuntime().exec("su"); and when i debugged the program ,the variable process is getting initialized with NULL. And I have made some function call to read the MSR value by specifying its path /dev/msr*,and when i run the program the log window shows Permission denied. So is there any way to get into root permission via an app without having a rooted android device?
So is there any way to get into root permission via an app without having a rooted android device?
By definition, no.
process = Runtime.getRuntime().exec("su");
su command is to run the shell commands in Super user mode.
If the device is rooted, this command causes SuperUser to show a dialog, which lets you either Allow or Block it from root access.
So is there any way to get into root permission via an app without
having a rooted android device?
There is no official way to do this. If your app needs SuperUser access, then you can build one click root method like rooting apps and can ask the user to root first.

How to check if custom android is rooted?

We've bought some custom android tablets, that we're going to use as kiosk tablets. For our kiosk app to work properly the app needs root access.
How can I check if the device is rooted properly?
And how can I root it if it isn't?
Things that point to that the device IS rooted:
When I ADB shell into the tablet the line starts with "#" (I read somewhere that this means that the tablet is rooted).
When I run "su" in the shell nothing happens (no errors).
This file exist /system/xbin/su"
Things that point to that the device IS NOT rooted:
I have installed Root Checker, it says "Sorry! This device does not
have root access"
When I run the following code in our app, which I know for a fact is working on
other rooted devices:
Process process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
os.writeBytes(cmd + "\n");
I get an error: "java.io.IOException: write failed: EPIPE (Broken pipe)".
Had to try a number of different root tools. Turns out KingRoot (https://kingroot.net/) did the job. Afterwards Root Checker says that it is rooted correctly and my app works again.
There is this nice guide which you can follow to check if the phone is rooted or not.
Link to website

How to hide/unhide app without root device 5.0 +

I make application that hide other apps. I succeed to hide and unhide other apps with rooted device. But when i was trying on unrooted device, not succeeded. I also tried with nfs, Device owner but not getting success. Followed these links. tried with manage permission also but not working. Please help me if anyone getting success without rooted device.
Error: root require:
E/hide: java.lang.SecurityException: Permission Denial: attempt to change component state from pid=23999, uid=10263, package uid=10264
followed these links below:
http://www.eoeandroid.com/thread-288229-1-1.html Install / Unistall from shell command in Android
You have to take device owner in order to use the hide/unhide api. You can use this guide to understand about the device owner
Once you have achieved device owner, you can use the following apis: setApplicationHidden.

Set Data roaming on/off

How could I programmatically set data roaming on/off in my android application ?
Apologies in advance for reopening a dead post but I have managed to achieve it by calling this executable:
su -c settings put global data_roaming0 1
Also to get the roaming setting for first SIM card:
su -c settings get global data_roaming0
If your app is signatureOrSystem/Privileged app (app resides in /system/priv-app) and your have valid android.permission.WRITE_SECURE_SETTINGS permission in system/etc/permissions. Then you can do it as below.
Enable :
Settings.Global.putInt(context.getContentResolver(), Settings.Global.DATA_ROAMING, 1)
Disable :
Settings.Global.putInt(context.getContentResolver(), Settings.Global.DATA_ROAMING, 0)
I hope that it's not possible to turn on data roaming programmatically as this would be a serious security issue from my point of view ...
Data roaming (i.e. UMTS data transfer via a foreign network) may result in a huge bill from your network provider - at least in europe.
If data roaming is currently on, then I think you can manipulate the Access Points Names in order to make it appear that a data service isn't available. See this post which also links to apndroid. You could browse their source and see the approach they have taken.
If data roaming has been set to off by the user, then this approach won't work. Though you could prompt users to turn it on as part of your install/setup process, which is the route apndroid take.
apndroid also provide an API for changing these kind of settings, which might be more convenient than reimplementing the same functionality.
On rooted devices when using su to enable data roaming, on multi sim devices the data roaming setting is sim specific.
So you need to get the sim number that is active for data calls
sim_num = settings get global multi_sim_data_call
and use this in the data_roaming + sim_num setting. EG sim_num 3
settings get global data_roaming3
if this is null then not multi sim device and use data_roaming otherwise use
settings put global data_roaming3
I was able to enable data roaming on my dual sim Motorola G8 without the need to root it via ADB. I'm posting here the procedure, because the phone has a bug that prevents data roaming from being enabled normally.
You need a computer and to install ADB installed
Enable developer mode and USB debugging in your phone
Connect the phone to the computer via USB and accept the debugging connection.
Start an "adb shell", be sure that it is correctly connected to your phone.
Issue the command
settings put global data_roaming1 1
to enable data roaming for SIM card 1, or
settings put global data_roaming2 1
to enable it for SIM 2
Note: if you do not have the USB cable, this can be done via wifi, but the pairing process is a bit complicated and version dependent.
If you do not have a computer, it may be possible to run the commands directly on the phone using a "local adb" app (there are a few on the play store), but I have not tested any.

Categories

Resources