拒绝权限:无法访问SurfaceFlinger的 [英] Permission denial: Can't access the SurfaceFlinger

查看:490
本文介绍了拒绝权限:无法访问SurfaceFlinger的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跑我的应用程序时出现此错误。我还包括为manifest.xml中的SurfaceFlinger的许可

I get this error when running my app. I also included the permission for surfaceFlinger in manifest.xml

"uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER"

但仍给予同样的错误不能访问SurfaceFlinger的在LogCat中。

基本上我想运行开发工具开发设置code。

Basically i want to run the Development setting code in Dev tools.

public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    try {
        Class partypes[] = new Class[1];
        partypes[0] = String.class;
        Method getService= ServiceManager.getMethod("getService", partypes );
        Object arglist[] = new Object[1];
        arglist[0] = "SurfaceFlinger";
        IBinder flinger= (IBinder)getService.invoke(smObject, arglist );

  //    IBinder flinger = ServiceManager.getService("SurfaceFlinger");
        if (flinger != null) {
            Parcel data = Parcel.obtain();
            data.writeInterfaceToken("android.ui.ISurfaceComposer");
            data.writeInt(isChecked ? 1 : 0);
            flinger.transact(mCode, data, null, 0);
            data.recycle();

            updateFlingerOptions();
        }
    } catch (RemoteException ex) {
    } 
**catch (SecurityException e) {
        // TODO Auto-generated catch block
        String err=e.toString();
        Toast.makeText(DevelopmentSetting.this, err, Toast.LENGTH_SHORT).show();
    }**

    catch (NoSuchMethodException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
}

在抓SecurityException异常它提供了错误java.lang.SecurityException异常,但logcat的它说权限被拒绝:无法访问SurfaceFlinger

In catch SecurityException it gives the error java.lang.securityException but logcat it says permission denied : can't access surfaceFlinger.

和manifest.xml的是这里

and the manifest.xml is here

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.nustian.android"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="10" />
    <uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER"/>

    <uses-permission android:name="android.permission.SET_WALLPAPER"   />
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/> 

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

        <activity
            android:name=".DevelopmentSetting"
            android:label="@string/app_name" >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>

有人帮助我。

推荐答案

作为解决办法,将它添加到您的清单文件。 UID媒体能够使用面护圈的API,所以用它分享UID将让您的应用程序使用它。

As a workaround, add this to your manifest file. UID media is able to use the surface flinger APIs, so sharing UID with it will allow your app to use it as well.

  coreApp="true"
  android:sharedUserId="android.uid.media"

这篇关于拒绝权限:无法访问SurfaceFlinger的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆