拒绝权限:无法访问SurfaceFlinger的

编程入门 行业动态 更新时间:2024-10-28 14:35:02
本文介绍了拒绝权限:无法访问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="schemas.android/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的

本文发布于:2023-10-21 19:58:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1515256.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法访问   权限   SurfaceFlinger

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!