How to read Samsung Android MessagingContentProvider (SecurityException) - android

I need to directly read
content://com.samsung.android.messaging.service.provider.MessageContentProvider/messages
(Why? Trying to find some way to get to RCS messages, which do not trigger SMS_RECEIVED)
As expected there is a SecurityException
Caused by: java.lang.SecurityException:
Permission Denial: opening provider com.samsung.android.messaging.service.provider.MessageContentProvider
from ProcessRecord{c72fe1ad0 14345:com.gearandroid.phoneleashfree/u0a474} (pid=14345, uid=10474)
requires com.samsung.android.messaging.permission.READ_MESSAGE or
com.samsung.android.messaging.permission.WRITE_MESSAGE
at android.os.Parcel.createException(Parcel.java:1966)
I added com.samsung.android.messaging.permission.READ_MESSAGE and om.samsung.android.messaging.permission.WRITE_MESSAGE to AndroidManifest.xml:
<uses-permission android:name="com.samsung.android.messaging.permission.READ_MESSAGE"/>
<uses-permission android:name="com.samsung.android.messaging.permission.WRITE_MESSAGE"/>
But no luck. Thanks for help, suggestions

Related

Android: Problem with the camera opening in webview

After a few days struggling with opening camera within webview I decided to ask the question here.
So,
I have a webview in my app which open a web page where is a camera. To forestall the questions, I do not have access to the website code.
I work on the android sdk 30 and Pixel 3 api 30. I tried it to open also on old android SDKs (23 - 24) or on the newest android 12. Tried to add android:requestLegacyExternalStorage with target sdk version 29.
When i try to open the given website in the chrome on my emulator it works correctly.
I think it can be problem with camera permissions but i have no idea how to check it. Calling requestPermissions for the camera also didn't help me.
And I just keep getting this error all the time:
E/cr_VideoCapture: getCameraCharacteristics:
java.lang.IllegalArgumentException: supportsCameraApi:2340: Unknown camera ID 0
at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:1001)
at android.hardware.camera2.CameraManager.getCameraCharacteristics(CameraManager.java:449)
at ft0.i(chromium-TrichromeWebViewGoogle6432.aab-stable-489612734:1047)
at org.chromium.media.VideoCaptureFactory.isLegacyOrDeprecatedDevice(chromium-TrichromeWebViewGoogle6432.aab-stable-489612734:1339)
at org.chromium.media.VideoCaptureFactory.getFacingMode(chromium-TrichromeWebViewGoogle6432.aab-stable-489612734:93)
Caused by: android.os.ServiceSpecificException: supportsCameraApi:2340: Unknown camera ID 0 (code 3)
at android.os.Parcel.createExceptionOrNull(Parcel.java:2387)
at android.os.Parcel.createException(Parcel.java:2357)
at android.os.Parcel.readException(Parcel.java:2340)
at android.os.Parcel.readException(Parcel.java:2282)
at android.hardware.ICameraService$Stub$Proxy.supportsCameraApi(ICameraService.java:906)
at android.hardware.camera2.CameraManager.supportsCameraApiLocked(CameraManager.java:1054)
at android.hardware.camera2.CameraManager.supportsCamera2ApiLocked(CameraManager.java:1030)
at android.hardware.camera2.CameraManager.getCameraCharacteristics(CameraManager.java:422)
at ft0.i(chromium-TrichromeWebViewGoogle6432.aab-stable-489612734:1047) 
at org.chromium.media.VideoCaptureFactory.isLegacyOrDeprecatedDevice(chromium-TrichromeWebViewGoogle6432.aab-stable-489612734:1339) 
at org.chromium.media.VideoCaptureFactory.getFacingMode(chromium-TrichromeWebViewGoogle6432.aab-stable-489612734:93) 
Thanks :)
Make sure to add permission in AndroidManifest.xml
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA"/>
<queries>
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
</queries>
Then in your activity, You can check camera permission like below
if(ContextCompat.checkSelfPermission(getApplicationContext(),
Manifest.permission.WRITE_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED &&
ContextCompat.checkSelfPermission(getApplicationContext(),Manifest.permission.CAMERA)==PackageManager.PERMISSION_GRANTED) {
}
Inside this condition you can use android.provider.MediaStore.ACTION_IMAGE_CAPTURE to get the list of camera intent from packagemanager

Is it possible to do screen recording without using foreground service for Android app targeting API 29?

The following code works fine for devices lower than Android 10
startActivityForResult(mProjectionManager.createScreenCaptureIntent(), REQUEST_CODE_SCREEN_RECORDING);
...
MediaProjectionCallback mMediaProjectionCallback = new MediaProjectionCallback();
mMediaProjection = mProjectionManager.getMediaProjection(resultCode, data);
mMediaProjection.registerCallback(mMediaProjectionCallback, null);
startRecording();
Android 10 throws the following exception for ProjectionManager.getMediaProjection(resultCode, data):
Exception: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
at android.os.Parcel.createException(Parcel.java:2071)
at android.os.Parcel.readException(Parcel.java:2039)
at android.os.Parcel.readException(Parcel.java:1987)
at android.media.projection.IMediaProjection$Stub$Proxy.start(IMediaProjection.java:231)
at android.media.projection.MediaProjection.<init>(MediaProjection.java:75)
at android.media.projection.MediaProjectionManager.getMediaProjection(MediaProjectionManager.java:104)
Yes, AndroidManifest.xml has the following:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
The official document says the following:
Apps targeting SDK version Build.VERSION_CODES.Q or later should
specify the foreground service type using the attribute
R.attr.foregroundServiceType in the service element of the app's
manifest file. The
ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION attribute should
be specified.
Could anyone offer a tip on this?

SecurityException: android.permission.INTERACT_ACROSS_USERS missing for bluetooth access

Facing this issue on non system app when attempting to do: "BluetoothAdapter::getProfileProxy". Observed only on android 8.1 but not reproducible.
Caused by: java.lang.SecurityException: query intent receivers: Neither user 15010171 nor current process has android.permission.INTERACT_ACROSS_USERS.
at android.os.Parcel.readException(Parcel.java:2021)
at android.os.Parcel.readException(Parcel.java:1967)
at android.content.pm.IPackageManager$Stub$Proxy.queryIntentServices(IPackageManager.java:4830)
at android.app.ApplicationPackageManager.queryIntentServicesAsUser(ApplicationPackageManager.java:1255)
at android.content.Intent.resolveSystemServiceAsUser(Intent.java:8365)
at android.bluetooth.BluetoothA2dp.doBind(BluetoothA2dp.java:432)
at android.bluetooth.BluetoothA2dp.<init>(BluetoothA2dp.java:405)
at android.bluetooth.BluetoothAdapter.getProfileProxy(BluetoothAdapter.java:3034)
Questions:
Why this permission "INTERACT_ACROSS_USERS" is coming as an issue. (we check for bluetooth permission)
As per https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/bluetooth/BluetoothA2dp.java
boolean doBind() {
Intent intent = new Intent(IBluetoothA2dp.class.getName());
ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
intent.setComponent(comp); ...
It looks like the permission issue is somewhere else - in some system service.
Wondering if someone can explain the issue.

How can I set android permission in framework on runtime..

I made a class for sending special sms.. not in app. but in telephony framework..
there is a error that saying permission SEND_SMS..
How can I set SEND_SMS permission..?
I tried below..
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.SEND_SMS) !=
PackageManager.PERMISSION_GRANTED) {
Log.d(TAG, "young.cha : Can't get PackageManager.PERMISSION_GRANTED~~!! -____-;;; ");
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.SEND_SMS,
"Requires SEND_SMS permission~~!!");
Log.d(TAG, "young.cha : enforceCallingOrSelfPermission~~~~!! SEND_SMS~~~!");
}
else {
Log.d(TAG, "young.cha : OK OK OK get PackageManager.PERMISSION_GRANTED~~!! -____-;;; ");
}
enforceCallingOrSelfPermission and checkCallingOrSelfPermission are not working..
what did I wrong..? or What kind of methods will be effectable..?
help me again~~ plz~~
It's been 5 hours to solve this things... -_-;
If I understand your problem correctly, you should set the SEND_SMS permission in your AndroidManifest.xml file, like so:
<uses-permission android:name="android.permission.SEND_SMS" />
You cannot set permissions in runtime, they have to be accepted by the user before installing the app.

Activity Access Restriction Implementation in a Monodroid Application

I have a requirement where I need to restrict access to an activity of a Monodroid Application. Hence i tried a spike where the application IntentSayHello would have an access restricted Activity called SayHelloActivity. As the first step i defined the permission tag in the AndroidManifest.xml of the application as below:
...
...
</application>
<permission
android:name="intentsayhello.permission.SAYHELLO"
android:protectionLevel="signature" android:label="#string/permlbl_restricted"
android:description="#string/permdesc_restricted">
</permission>
</manifest>
Please note that i'm using protectionLevel = signature which means that any other application signed with the same certificate as IntentSayHello can only access the restricted activity.
Now i coded the SayHelloActivity as below:
[Activity(Label = "SayHelloActivity", MainLauncher = true, Icon = "#drawable/icon", Permission = "intentsayhello.permission.SAYHELLO")]
[IntentFilter(new string[] { "companyXYZ.intent.sayhello.MAIN" },Categories = new string[]{Intent.CategoryDefault},
DataMimeType = "vnd.companyXYZ.say.hello/vnd.companyXYZ.activity")]
public class SayHelloActivity : Activity
{
.....
.....
}
After this i tested with a client application by invoking SayHelloActivity of IntentSayHello through an implicit intent and i got SecurityException as expected.
Permission Denial: starting Intent { act=companyXYZ.intent.sayhello.MAIN typ=vnd.companyXYZ.say.hello/vnd.companyXYZ.activity cmp=IntentSayHello.IntentSayHello/intentsayhello.SayHelloActivity }
from ProcessRecord{4094f850 9126:DiffKeyHello.DiffKeyHello/10097} (pid=9126, uid=10097) requires intentsayhello.permission.SAYHELLO
Now if i want my client Application to be given access to the SayHelloActivity of the restricted application, i'm supposed sign my client application with the same keystore (certificate) and also mention in the AndroidManifest.xml of the client application as below:
...
<uses-sdk android:minSdkVersion="4" />
<uses-permission android:name="intentsayhello.permission.SAYHELLO" />
</manifest>
But when i did both of this, the client application still could not invoke the SayHelloActivity and same SecurityException is thrown.
I would like to know the directions/solution to this issue.
Thanks
After Googling around, hit upon this page: http://lists.ximian.com/pipermail/mono-bugs/2011-January/108218.html
I took the cue from this page that the need to be put into the Client's AssemblyInfo.cs. The syntax would be:
// Add some common permissions, these can be removed if not needed
[assembly: UsesPermission("intentsayhello.permission.SAYHELLO")]
[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
It worked from then on.
Further search in mono android forum, i found that another way of doing this is to explicitly add the androidmanifest.xml in the .csproj file as below:
<PropertyGroup>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
</PropertyGroup>
Either of the above solutions works, only i do not know which/both are correct practice.

Categories

Resources