2

I received the following error report from a couple of different users running Android 2.2. I cannot reproduce it locally.

java.lang.SecurityException: Permission Denial: writing com.android.providers.settings.SettingsProvider uri content://settings/system from pid=15121, uid=10063 requires android.permission.WRITE_SETTINGS
    at android.os.Parcel.readException(Parcel.java:1247)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:160)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
    at android.content.ContentProviderProxy.insert(ContentProviderNative.java:408)
    at android.content.ContentResolver.insert(ContentResolver.java:587)
    at android.provider.Settings$NameValueTable.putString(Settings.java:556)
    at android.provider.Settings$System.putString(Settings.java:753)
    at android.provider.Settings$System.putInt(Settings.java:836)
    at android.widget.MediaController.dolbySwitch(MediaController.java:835)
    at android.widget.MediaController.access$1100(MediaController.java:89)
    at android.widget.MediaController$6.onClick(MediaController.java:763)
    at android.view.View.performClick(View.java:2408)
    at android.view.View$PerformClick.run(View.java:8816)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4669)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
    at dalvik.system.NativeStart.main(Native Method)

My code should not be attempting to change any settings -- I just create a simple VideoView with MediaController and have it load a URI.

The error seems extremely rare, so it's not a huge problem, but I don't understand what would be causing it.

Edit: By request, here's the code for the VideoView & MediaController:

  private void videoViewInit() 
  {
      videoView = (VideoView)findViewById(R.id.videoView);
      MediaController mediaController = new MediaController(this);
      mediaController.setAnchorView(videoView);
      mediaController.setMediaPlayer(videoView);
      videoView.setMediaController(mediaController);
      videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
            @Override
            public boolean onError(MediaPlayer mp, int errorType, int extra) {
                    return false;
            }});
      videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener(){
            @Override
            public void onPrepared(MediaPlayer mp) {
                  videoView.requestFocus();
            }});
      videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
            }});
  }

  protected void videoViewDisable()  {
      videoView.stopPlayback();
  }

  private void videoViewLoad(Uri uri) {
      if( uri == null || uri.toString().equals("") )
          return;

      if( videoView == null )
              videoViewInit();

      videoView.setVideoURI( uri );
      videoView.start();
  }
Sven Viking
  • 2,660
  • 21
  • 34
  • 1
    **My code should not be attempting to change any settings** Show the code then, because that stack trace says different :-) – Blundell Aug 23 '11 at 09:20
  • Edited the question to add the code. I would have thought you'd need to be using some specific Settings class to change system settings. – Sven Viking Aug 23 '11 at 10:19
  • Looks like this only occurs on ZTE V9 devices. They must have added some weird custom code. – Sven Viking Oct 22 '11 at 21:20
  • 1
    I had a similar exception thrown and my app does not try to change the settings as well. However, the device in question was Samsung GT-I5700 running Android 1.5. My question on Google Android Developers Group is here: http://bit.ly/zg0KV7 – Viktor Brešan Mar 01 '12 at 16:41

1 Answers1

3

Add this permission to manifest file

 < uses-permission android:name="android.permission.WRITE_SETTINGS"></uses-permission> 
Rasel
  • 15,499
  • 6
  • 40
  • 50
  • Thanks, though I'd prefer to do without the extra permission if it was possible, since I don't know of any system settings I actually want to change. It would be difficult to explain the reason for the permission if anyone asked. – Sven Viking Aug 23 '11 at 10:20