Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ADB throws SecurityException while starting service after system update to Nexus 7: "Caller uid=2000 is not privileged to communicate with user=-2"

Tags:

android

adb

I am issuing following command to Nexus 7 tablet:

adb.exe -s 015d2109567231a0f shell am startservice -n com.packagename/.ExServiceName --ei port 59777

and getting:

Starting service: Intent { cmp=com.packagename/.ExServiceName (has extras) }
java.lang.SecurityException: Caller uid=2000 is not privileged to communicate with user=-2
    at android.os.Parcel.readException(Parcel.java:1425)
    at android.os.Parcel.readException(Parcel.java:1379)
    at android.app.ActivityManagerProxy.startService(ActivityManagerNative.java:2648)
    at com.android.commands.am.Am.runStartService(Am.java:415)
    at com.android.commands.am.Am.run(Am.java:111)
    at com.android.commands.am.Am.main(Am.java:82)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
    at dalvik.system.NativeStart.main(Native Method)

It all worked without problems until I applied a system update to my tablet!

Current tablet information:

Model number: Nexus 7
Android version: 4.2
Kernel version: 3.1.10-g22b4fcd

Service manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.packagename"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />
    <uses-permission android:name="android.permission.INTERNET"/>

    <application android:label="@string/app_name"
        android:icon="@drawable/ic_launcher"
        android:theme="@style/AppTheme">

        <service android:name=".ExServiceName" android:exported="true"></service>

    </application>

</manifest>

I am developing under Windows 7 x64

Can you please tell me how to make the service successfully accept the intent without throwing exceptions of any kind?

Thanks,
Konrad

like image 693
Konrad Jamrozik Avatar asked Nov 27 '12 16:11

Konrad Jamrozik


3 Answers

I got the same exception on a Galaxy Nexus which version is Android 4.2.

I succeeded to start a service by the following command.

am startservice --user 0 -a <action>
like image 85
Koji Hisano Avatar answered Nov 09 '22 09:11

Koji Hisano


After a lot of searching on the internet and Koji Hisano's very helpful post, I managed to get the System Bar to appear using:

am startservice --user 0 -n com.android.systemui/.SystemUIService

If the -a option was used I was getting a message:

Error: Not found; no service started.

like image 3
TheIT Avatar answered Nov 09 '22 10:11

TheIT


You might start the service on a rooted phone also with:

adb.exe -s 015d2109567231a0f shell su -c "am startservice -n com.packagename/.ExServiceName --ei port 59777"
like image 1
Similitran Avatar answered Nov 09 '22 10:11

Similitran