Android Things doesn't grant permissions on boot, what gives? - android

Got this shiny manifest ready to be granted all ze permissions
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="exm.rand.lol">
<uses-permission android:name="com.google.android.things.permission.MODIFY_SCREEN_SETTINGS" />
<uses-permission android:name="com.google.android.things.permission.REBOOT"/>
<application>
<uses-library android:name="com.google.android.things" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.IOT_LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
and yet when I boot up the raspberry pi it fails with this in the logcat
12-01 15:23:19.349 2960 2960 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{exm.rand.lol/exm.rand.lol.MainActivity}: java.lang.SecurityException: Calling process requires permission com.google.android.things.permission.MODIFY_SCREEN_SETTINGS
I searched high and low, stumbled upon multiple threads on StackOverflow
Android Things permission com.google.android.things.permission.MANAGE_INPUT_DRIVERS not found
How to request permission on Android Things?
but to no avail. Rebooting doesn't do anything, reinstalling doesn't do anything, the only way I found atm to give permissions is to manually grant them through adb like dis
adb shell pm grant exm.rand.lol com.google.android.things.permission.REBOOT
Running latest Preiew 6 of Android Things.

With Developer Preview 6, you should use the DeviceManager API. Reboot permission can only be granted to system apps if I'm not wrong, and the Android Things console will never package your APK as a system app.
new DeviceManager().reboot()

To summerize things... Altough it's stated in Android Things readme that:
All normal and dangerous permissions declared in your app's manifest are granted at install time.
It's not enough to declare permissions in manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx.yyy">
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="com.google.android.things.permission.MODIFY_SCREEN_SETTINGS"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application>
</application>
</manifest>
You need to restart the device with the installed application.
APPLICATION RIGHTS ARE GRANTED UPON DEVICE RESTART not application restart.

Related

Android Permission is not include in final apk using Unity + Oculus Quest

I want to use bluetooth in my Oculus Quest device so I need to include android.permission.BLUETOOTH permission in the .apk generated by Unity.
I included the AndroidManifest.xml file below in the ../MyProject/Assets/Plugins/Android/ folder
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.unity3d.player"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false"/>
<application>
<activity android:name="com.unity3d.player.UnityPlayerActivity"
android:theme="#StyLe/UnityThemeSelector">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
</application>
</manifest>
The permissions ACCESS_COARSE_LOCATION and BLUETOOTH_ADMIN was included but not the BLUETOOTH permission.
Im using Oculus Plugin + Unity 2019.4.16f1
I tried with Unity versions 2019.3.2.f1, 2020.1.0f1, 2020.1.9f1. Same result. Not work.
I cant believe it. Any idea?
Thanks in advance!!
The solution is to downgrade to the Unity oculus XR package version 1.4.3. I speculate that their 1.5.0 is forcefully removing the permissions from the manifest after building it (see the changelog reference to bluetooth permissions)

Neither user 10063 nor current process has android.permission.ACCESS_NETWORK_STATE [duplicate]

I know it may be silly question and I have referred all the similar question before but unfortunately I could resolve this issue. Most probably it is problem in my Manifest.xml file.
When I am trying to access location, app is crashing
here is my manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.tt.test" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".sTest"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.test.tt.test.sService">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </service>
<service android:name="com.test.tt.test.sServiceRequest" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
</application>
when I run it throw this error
java.lang.SecurityException: Neither user 11029 nor current process has android.permission.ACCESS_COARSE_LOCATION.
Similar with other permissions. I can not see any mistake in my manifest file. Help appreciated
If you are running on a device on Android Marshmallow and above:
If the device is running Android 6.0 or higher and if the app's target SDK is 23 or higher, the app not just have to list the permissions in the manifest but also must request each dangerous permission it needs while the app is running.
More info:
http://developer.android.com/training/permissions/requesting.html
and
http://developer.android.com/guide/topics/security/permissions.html#normal-dangerous
This means you have some wrong information or malformed info in your menifest file and that is the reason none of your Permission is not identified by your app. Just make sure you have cleaned ANDROIDMANIFEST file with any malformed data.
It will work and all permission should be outside Application tag
move the uses-permission outside application just below the manifest tag
Moving permission section solved my problem with "Neither user or current process has android.permission.READ_PHONE_STATE". Thank you so much to everyone in this forum.
In reference to others, my changes are bellow:
Original:
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-feature
android:name="android.hardware.nfc"
android:required="true" />
<activity android:name=".NfcRead"></activity>
</application>
Change:
<uses-permission android:name="android.permission.NFC" />
<uses-feature
android:name="android.hardware.nfc"
android:required="true" />
<activity android:name=".NfcRead"></activity>
</application>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
This exception is related to the runtime permission system in Android 6 and above. The Location permission comes under dangerous permission [check here], so you must have to fulfill below 2 minimum requirements to handle these permissions:
Declared below 2 permission in manifest (These permissions must be outside application tag)
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION " />
Check for the granted permission at runtime using checkSelfPermission() and request permissions using requestPermissions() if not already granted.
If you have already done both of the above then and still getting error then check below:
You App's targetSdkVersion (should be >=23) [If the application's targetSdkVersion is set to less than 23. It will be assumed that application is not tested with new permission system yet and will switch to the same old behavior: user has to accept every single permission at install time and they will be all granted once installed].
Check if you have any thing wrong with you manifest file. You might have malformed manifest file.
Check if you are calling any function, that works on location data, before the user Accept/revoked runtime location permission dialog?
Clean you app (Clean build) and re-run.
Hope this may help :-)

Neither user nor current process has android.permission.ACCESS_COARSE_LOCATION

I know it may be silly question and I have referred all the similar question before but unfortunately I could resolve this issue. Most probably it is problem in my Manifest.xml file.
When I am trying to access location, app is crashing
here is my manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.tt.test" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".sTest"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.test.tt.test.sService">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </service>
<service android:name="com.test.tt.test.sServiceRequest" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
</application>
when I run it throw this error
java.lang.SecurityException: Neither user 11029 nor current process has android.permission.ACCESS_COARSE_LOCATION.
Similar with other permissions. I can not see any mistake in my manifest file. Help appreciated
If you are running on a device on Android Marshmallow and above:
If the device is running Android 6.0 or higher and if the app's target SDK is 23 or higher, the app not just have to list the permissions in the manifest but also must request each dangerous permission it needs while the app is running.
More info:
http://developer.android.com/training/permissions/requesting.html
and
http://developer.android.com/guide/topics/security/permissions.html#normal-dangerous
This means you have some wrong information or malformed info in your menifest file and that is the reason none of your Permission is not identified by your app. Just make sure you have cleaned ANDROIDMANIFEST file with any malformed data.
It will work and all permission should be outside Application tag
move the uses-permission outside application just below the manifest tag
Moving permission section solved my problem with "Neither user or current process has android.permission.READ_PHONE_STATE". Thank you so much to everyone in this forum.
In reference to others, my changes are bellow:
Original:
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-feature
android:name="android.hardware.nfc"
android:required="true" />
<activity android:name=".NfcRead"></activity>
</application>
Change:
<uses-permission android:name="android.permission.NFC" />
<uses-feature
android:name="android.hardware.nfc"
android:required="true" />
<activity android:name=".NfcRead"></activity>
</application>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
This exception is related to the runtime permission system in Android 6 and above. The Location permission comes under dangerous permission [check here], so you must have to fulfill below 2 minimum requirements to handle these permissions:
Declared below 2 permission in manifest (These permissions must be outside application tag)
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION " />
Check for the granted permission at runtime using checkSelfPermission() and request permissions using requestPermissions() if not already granted.
If you have already done both of the above then and still getting error then check below:
You App's targetSdkVersion (should be >=23) [If the application's targetSdkVersion is set to less than 23. It will be assumed that application is not tested with new permission system yet and will switch to the same old behavior: user has to accept every single permission at install time and they will be all granted once installed].
Check if you have any thing wrong with you manifest file. You might have malformed manifest file.
Check if you are calling any function, that works on location data, before the user Accept/revoked runtime location permission dialog?
Clean you app (Clean build) and re-run.
Hope this may help :-)

app not starting, despite loading successfully

I am getting a strange issue, please see if anyone can help here. Whenever I run my app (either in emulator or in phone), I can see the installation goes successful but the activity does not show up. Following is the message I get in the Console.
------------------------------
Android Launch!
adb is running normally.
Performing sync
Uploading MyApp.apk onto device 'emulator-5554'
Installing MyApp.apk...
Success!
\MyApp\bin\MyApp.apk installed on device
Done!
It was running normally before but since yesterday, it has started to behave like this. Ideally after "Success!" statement, the intent gets loaded and MainActivity shows up. But not anymore. I tried restarting/recreating emulator but no help. The only change I had done in my app was to create some xml files for titlebar. I even undid that change but still the same issue. Any help is appreciated.
UPDATED TO ADD MANIFEST FILE
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bfp.MyApp"
android:versionCode="12"
android:versionName="2.5" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="10" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<permission
android:name="com.bfp.MyApp.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.bfp.MyApp.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme" >
<activity
android:name="com.bfp.MyApp.MainActivity"
android:label="#string/app_name"
android:configChanges="orientation|keyboardHidden|screenSize"
android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.bfp.MyApp.TestQuizActivity"
android:parentActivityName="com.bfp.MyApp.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.bfp.MyApp.MainActivity" />
</activity>
<service android:name="com.bfp.MyApp.GCMIntentService" />
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.bfp.MyApp" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.bfp.MyApp" />
</intent-filter>
</receiver>
<activity
android:name="com.bfp.MyApp.RegisterActivity"
android:launchMode="singleTop" />
<activity
android:name="com.bfp.MyApp.BaseActivity"
android:label="#string/title_activity_main" >
</activity>
</application>
Does your app run correctly when you run it from the phone directly? If so, perhaps you accidently changed the run configuration from eclipse to launch other activity than you MainActivity. This affect running from eclipse via the debug interface.
Looks like the problem was more while running the app from eclipse. Installing the apk file in phone was working fine. I deleted the AVDs and recreated them. Also I noticed that my app had reference to android ver 4.3 whereas the intel atom image was not available for that version. hence I downgraded it to 4.2.2. With these changes done, the app started loading normally. Not really what was the root cause, but something to do with the AVD was the issue.

Service failing to run because of "Permission Denial", permission required is null

My program has been running fine, but I think I must have accidentally changed something I shouldn't have done. I had my program running "UpdateService" on the press of a button, but now it doesn't run, and debug brings up the following two lines:
01-05 21:43:39.945: WARN/ActivityManager(98): Permission denied: checkComponentPermission() reqUid=10084
01-05 21:43:39.955: WARN/ActivityManager(98): Permission Denial: Accessing service ComponentInfo{com.android.datausagemonitor/com.android.datausagemonitor.UpdateService} from pid=98, uid=1000 requires null
Here is my manifest, judging by similar posts it could well be a problem with this, but I can't see it and am pretty sure I haven't changed anything since it was last working:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.datausagemonitor"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".DataUsageMonitorActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.android.datausagemonitor.UpdateService"></service>
<service android:name="com.android.datausagemonitor.ResetService"></service>
</application>
[Solved] There was some problem with the Uid between Eclipse and the device I was testing on. Rebooting the device solved the problem.

Categories

Resources