android 4.1 composer->captureScreen(...) failed - android

I use JNI way, composer -> captureScreen(...) to capture final surfaceflinger composed screen, like this sample in source code.
and build success on android 4.1, but there are error happened at runtime: the captureScreen(...) returns err = 1, and heap = null.
I googled this link is the same fail, still no answer.

OK! I got the answer...
the err = 1 means PERMISSION_DENIED = 1 in native code,
the root cause is after android 4.0 screenshot consider APP's permission , explained here in Chinese,
and here is the detail to work
thanks!
B.R.

Related

AMediaExtractor setDataSource AMEDIA_ERROR_UNSUPPORTED error on Android Q

I am working with AMediaCodec and AMediaExtractor, all works fine on all devices(I hope:), but if I check the same code on Android Q (in my case Pixel 2XL) I got such error AMEDIA_ERROR_UNSUPPORTED.
What I do
bool NativeCodec::createStreamingMediaPlayer(const std::string &filename)
{
AMediaExtractor *ex = AMediaExtractor_new();
media_status_t err =
AMediaExtractor_setDataSource(ex, filename.c_str());; <-- Here media status I got AMEDIA_ERROR_UNSUPPORTED
if (err != AMEDIA_OK)
{
__android_log_print(ANDROID_LOG_ERROR, "ERROR", "ERROR ::: %s", std::to_string(err).c_str());
return false;
}
.....
}
Maybe this is somehow connected with privicy that was introduced in Android Q, but I didn't find any info about it...
How to check this issue?
This to me seems a bug on Android 10. It seems that android:requestLegacyExternalStorage="true" does not change the situation. You may have to request <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE/> on manifest and ask same permission at runtime. The AMediaExtractor_setDataSource function must be called on a thread that is attached to Java. Doing all of that correctly will allow you to make it work on other versions of Android but not on Android 10. I've reported the issue on Android Bug Tracker here: https://issuetracker.google.com/144837266
As per google answer, it seems that all the app using native libraries that require file access through path can be affected and they know the issue https://www.youtube.com/watch?v=UnJ3amzJM94 .
A workaround in my case was to use AMediaExtractor_setDataSourceFd, getting the file descriptor at Java level through contentResolver and its method openFileDescriptor.
This is due to you not specifying a Java thread to be used. Create the thread and then attach it via AttachCurrentThread

Titanium SDK 5.4.0.GA is showing too many logs at console on Android platform

did anyone notice that on Android - Ti SDK 5.4.0.GA is showing many output at console on all modes like Trace, Debug, Info, Warning, Error.
I have not tried it for Wi-Fi off state, but it is showing such lines every second when the device is connected to Wi-Fi and my console filled up with 100 lines in just few seconds:
[INFO] : D/StatusBar.MSimNetworkController( 1166): getNumberOfActiveSim:0
[INFO] : D/StatusBar.MSimNetworkController( 1166): getPhoneSignalIconList: mMaxLevelOfSignalStrengthIndicator = 4 inetCondition = 0
[INFO] : D/StatusBar.MSimNetworkController( 1166): getDataSignalIconId: mMaxLevelOfSignalStrengthIndicator = 4 inetCondition = 0 iconLevel = 4
[INFO] : D/StatusBar.MSimNetworkController( 1166): updateTelephonySignalStrength: iconLevel=4
Can anyone suggest any solution as this is getting quite annoying and I cannot focus on the console output from code due to too many above logs?
Update
Finally I found a solution to this problem:
https://github.com/appcelerator/titanium_mobile/pull/8754
Logs that contain a dot (or any other character besides letters) won't be caught in the don't show part!
The PR will change the RegEx rule to match any character.
Old solution:
Check the output of ti config cli.logLevel and set it to info
Might solve the problem for you.
I'm facing the same issue and I use monitor with this custom filter:
^(?!(WifiStateMachine|WIFI_UT|AppOps|GraphicsStats|RegisteredNfcid2Cache|Wifi|NotifUtils|WIFI|usbnet|Ethernet|FaceDetectTask|RecentsTaskLoadPlan|MorningBundlePlugin|SocialManagerService|PhoneApp|LoadDialerReceiver|Icing|Herrevad|Finsky|StatusBarManagerService|DropBoxEntryAddedChimeraService|ClearcutLoggerApiImpl|AlarmManager|GCoreUlr|GCoreFlp|APSAnalyticsService|QCNEJ|NetworkStats|IpReachabilityMonitor|Nfcid2RoutingManager|ls|WifiManager|libc|dex2oat|ACRA|HtcMirrorLinkAmsListener|LOWI-Scan|DownloadManagerWrapper|wpa_supplicant|QCALOG|WIFI_ICON|HtcWrapCustomizationManager|gdlights|PowerUtils|ExtremePowerSave|WifiService|FrameworkListener|MediaRouterServie|DotMatrix|PowerUI|PMS|XTCC-5.1.0.7|NetworkManagement|HtcPowerSaver|BatteryControlle|NetLinkSocketObs|WifiController|NetlinkSocketObs|BatteryService|UsbnetService|DeviceIdleControler|Keyboard.Facilit|xiaomi|qdlights|SensorService|AutoSetting|HtcWifiRssiMonitor|HtcWifiDataStallTracker|WifiAutoJoinController|HtcWLD_v5.1.0|WifiMonitor|WifiConfigStore|StatusBar.NetworkController|CwMcuSensor|BrcmNfcJni|DATA_ICON|TelephoneCallback|ContactMessageStore|HtcUPManager|ScreenOnOffReceiver|DeviceIdleController|QSPanel|NetworkPolicy|GpsLocationProvider|SensorManager|SmartNS_PSService|PhoneStatusBar|ScrimController|Settings|LocationManagerService|getVisibilityByRssi|NetworkController.WifiSignalController|GAv4|IntegrityChecker|KernelCpuSpeedReader|KernelWakelockReader|BatteryStatsImpl|WeatherUtility|WeatherTimeKeeper|PNP_UPDATERD|DsService|PathParser|StatusBarManagerServiceHtcASN_1.1|SignalClusterView|SIGNAL_ICON|HtcSystemUPManager|ConnectivityService|HtcASN_1.1|SignalClusterView|SIGNAL_ICON|HtcSystemUPManager|ConnectivityService|WSP|Babel|CityCodeHelper|TetherStatsReporting|TelephonyCallback))
Put this in by Log Tag in a new filter. My device is a HTC A9, a very log-noisy device!
If you still see rows you don't want to just put attach the tags with |tagname

C++ Builder WSDL client for Android

I'm having a confusing problem. I'm trying to make a Web cleint that uses WSDL.
I'm using C++ RAD Studio 10 Seattle, but the same problem occured in RAD Studio XE8(older version).
1.I create a Multi-Device Application, add one Edit component and one Button.
2.I create a WSDL Importer by changing the location of the WSDL file to : "http://www.w3schools.com/webservices/tempconvert.asmx?WSDL" and leave all other setting to default.
3.On ButtonClick event of the button I write two lines of code :
_di_TempConvertSoap Converter = GetTempConvertSoap(true,
"http://www.w3schools.com/webservices/tempconvert.asmx?WSDL");
Edit1->Text = Converter->CelsiusToFahrenheit("32");
So after these three steps I have one unit, which is the main Unit with the Form and with the button event. And one file "tempconvert.cpp" that the WSDL Importer has generated. It quite actually just translates the WSDL code to a C++ one and defines the method to communicate with the server. In my case I have two methods : FahrenheitToCelsius() and CelsiusToFahrenheit(), in the example I use CelsiusToFahrenheit().
I compile it to 32-bit Windows platform, run it and when I click the button, the result "89.6" appears in the text of the Edit component. So this is working as expected.
But when I change the target platform to "Android" and use my mobile phone "Samsung GT-I8262" with Android 4.1.2 and run the project, it just stops and exits. I debugged the problem and it stops at the first command in "tempconvert.cpp" in RegTypes() method.
// ************************************************************************
//
// This routine registers the interfaces and types exposed by the WebService.
// ************************************************************************ //
static void RegTypes()
{
/* TempConvertSoap */
InvRegistry()->RegisterInterface(__delphirtti(TempConvertSoap), L"http://www.w3schools.com/webservices/", L"utf-8");
InvRegistry()->RegisterDefaultSOAPAction(__delphirtti(TempConvertSoap), L"http://www.w3schools.com/webservices/%operationName%");
InvRegistry()->RegisterInvokeOptions(__delphirtti(TempConvertSoap), ioDocument);
/* TempConvertSoap.FahrenheitToCelsius */
InvRegistry()->RegisterMethodInfo(__delphirtti(TempConvertSoap), "FahrenheitToCelsius", "",
"[ReturnName='FahrenheitToCelsiusResult']", IS_OPTN);
/* TempConvertSoap.CelsiusToFahrenheit */
InvRegistry()->RegisterMethodInfo(__delphirtti(TempConvertSoap), "CelsiusToFahrenheit", "",
"[ReturnName='CelsiusToFahrenheitResult']", IS_OPTN);
/* TempConvertHttpPost */
InvRegistry()->RegisterInterface(__delphirtti(TempConvertHttpPost), L"http://www.w3schools.com/webservices/", L"utf-8");
InvRegistry()->RegisterDefaultSOAPAction(__delphirtti(TempConvertHttpPost), L"");
}
#pragma startup RegTypes 32
Does someone have any idea why this might be happening? I tried on two other Samsung phones and it didn't work. The error that shuts the program down is "Segmentation fault(11)", and more precisely it stops at the following line of code in "System.pas" file :
u_strFromUTF8(PUChar(Dest), MaxDestChars, DestLen, MarshaledAString(Source), SourceBytes, ErrorConv);
Here is some info that I've found about the function:
u_strFromUTF8 - function that converts a UTF-8 string to UTF-16.
UCHAR is a Byte(in Delphi), so PUCHAR is a pointer to Byte.
I cannot se what could possibly go wrong with this function which apparently only converts a string.
So my question is why does the project work on Windows 32 bit version, but on Android it throws Segmentation fault(11)?
I hope I could find a solution for this problem. I will keep looking.
Thank you,
Zdravko Donev :)
UPDATE:
I disassembled the line:
InvRegistry()->RegisterInterface(__delphirtti(TempConvertSoap), L"http://www.w3schools.com/webservices/", L"utf-16");
to get :
TInvokableClassRegistry *Class = InvRegistry();
TTypeInfo *Info = __delphirtti(TempConvertSoap);
UnicodeString Namespace = "http://www.w3schools.com/webservices/";
UnicodeString WSDLEncoding = "utf-8";
Class->RegisterInterface(Info, Namespace, WSDLEncoding);
And I saw that the problem occurs when calling InvRegistry() function, but I still haven't found the problem as I cannot reach the source code of the function.
I found a solution.
I deleted the line
#pragma startup RegTypes 32
and called the method RegTypes() on my own when I create the form and it worked.

error with pymtp to work on python 3

I want to access a android device from python to download some photos.
libmtp works from the CLI.
Than pymtp. It's been around for a while but it's designed for python 2 and i'm using python 3. Meanwhile fixed several minor issues but i'm stuck at an error from function get_filelisting
specially this section:
ret = []
next = files
while next:
ret.append(next.contents)
if (next(next.contents) is None):
break
next = next(next.contents)
The error is related to the "next".
That section looks strange to me, i've been coding in python for a while but i'm new to ctypes. Tried a lot of variants, they all failed. The "next" could be confusing with python buildin function so i renamed it to nextpointer and came to this code:
ret = []
nextpointer = files
while nextpointer:
ret.append(nextpointer.contents)
nextpointer = nextpointer.contents.next
It seems to work but did it work by accident ? does it have any design flaws ? Could anyone with experience on python ctypes confirm this a solution ? Any suggestion welcome.
From python2.7 documentation
next(iterator[, default])
Retrieve the next item from the iterator by calling its next() method. If default is given, it is returned if the iterator is
exhausted, otherwise StopIteration is raised.
from python3 documentation
next(iterator[, default])
Retrieve the next item from the iterator by calling its __next__() method. If default is given, it is returned if the iterator is
exhausted, otherwise StopIteration is raised.
Notice that next() method was removed from python3 but the function still exists.
This is all I can say about the next function and .next()/__next__() methods.
I downloaded the pymtp module and get_filelisting() is slightly different from what you posted in your ported code, here it is:
ret = []
next = files
while next:
ret.append(next.contents)
if (next.contents.next == None):
break
next = next.contents.next
If none of this helped you (which probably didn't :D), the version of pymtp library that I am using is 0.0.6 download using pip.

Appium: "An element could not be located on the page using the given search parameters" error

I am new to Appium and have been trying to automate the Conversion Calculator app for Android. Am getting the error "org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters", when trying to find a EditText element. Using Appium ver 1.0.0 and Android 4.3
The following is my code:
List<WebElement> textViews = driver.findElements(By.className("android.widget.TextView"));
for (i=0; i<textViews.size(); i++) {
if(textViews.get(i).getText().toLowerCase().contains("memory")) {
textViews.get(i).click();
}
}
Thread.sleep(5000);
WebElement editText = driver.findElement(By.className("android.widget.EditText"));
editText.sendKeys("123");
Even findElement by ID is not working. Please let me know what I am doing wrong here or if I need to provide more details.
I would use
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); instead of Thread.sleep(5000).
Try to use a newer version of Appium, I's been improved a lot. You can download the latest version of Appium and Appium clients here:http://appium.io/downloads.html
But be careful because in the newer version the findElement throws an Exception if there are more then one result of the search.
I would write this in a comment but I've not enough reputation :/
Possible Cause:
Multiple EditText in the current screen.
Please try with the following:
Solution1:
List<WebElement> editText = driver.findElements(By.className("android.widget.EditText"));
editText.get(0).sendKeys("123");
0 - Index of EditText
Solution2:
Use any other locating strategy like Xpath.
Maybe you could try waiting until the element is visible or enabled using a WebDriverWait object?
Avoid using sleep as much as possible, try using the WAIT command.
Sleep without waiting for the time that has been determined, even if the element is already on the screen.
In the case of the wait command, as soon as the element appears, the action will already be performed, this along the code will reduce the execution time considerably.
The issue for me was the app path I was using. If you are using a config file make sure to declare the application separately from the device.
If not, make sure the "app" capability has the right path. Here is the code in my config file for example:
devices_by_ids = {
"platformName": "Android",
"appium:DEVICE ADB ID": {
"android_version": "13",
"device_name": "google_Pixel_5a",
"DEVICE ADB ID": "DEVICE ADB ID",
"port":"4723",
"autoGrantPermissions": "true",
},
"appium:app": "YOUR APP PATH",
"appium:appWaitActivity": "*"
}
In Appium v2 use
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));

Categories

Resources