背景
我正在开发一个控制屏幕旋转的Android应用程序。该应用程序可在Google商店获得。。为了控制屏幕旋转,应用程序禁用系统自动旋转并更改旋转值。源代码可通过Mercurial/hg获得。。
问题
虽然这款应用程序在我的手机上运行良好,但它却在运行Android4.3的朋友三星Galaxy S3上崩溃。崩溃发生在代码之外,因此我无法在Google中获得崩溃报告,堆栈跟踪只显示无法访问的外部代码。
java.lang.SecurityException:权限拒绝:用户的get/set设置请求以用户2的身份运行,但从用户0调用;这需要android.os.Parcel.readException(Parcel.java:1431) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137) at android.content.ContentProviderProxy.call(ContentProviderNative.java:602) at android.provider.Settings$NameValueCache.getStringForUser(Settings.java:934) at android.provider.Settings$System.getStringForUser(Settings.java:1162) at android.provider.Settings$System.getIntForUser(Settings.java:1232) at com.android.internal.policy.impl.WindowOrientationListener$ScreenOrientationEventListenerImpl.onSensorChanged(WindowOrientationListener.java:501) at android.hardware.SystemSensorManager$SensorE
此堆栈跟踪意味着系统自动旋转仍在运行。它还显示,在接收到屏幕方向更改事件后,OS代码试图将int系统设置作为特定用户进行读取。因此,我怀疑这个问题与我禁用旋转或更改旋转有关,两者都是系统设置。
故障排除
WindowOrientationListener,但它不包含发生错误的内部类ScreenOrientationEventListenerImpl。三星手机可能使用自定义版本的代码,很可能部分原因是它有一个非AOSP功能,智能旋转。"intelligent_rotation_mode"设置为用户-0x2,这很有趣,因为我没有触及到三星特有的设置。我还下载了一个官方源代码的副本,但它似乎没有包含相关的文件。发布于 2014-11-26 10:35:07
该应用程序使用了来自AOSP的com.android.internal.policy.impl.WindowOrientationListener的本地副本。但是,本地副本仍然使用原始包com.android.internal.policy.impl。结果发现,当应用程序试图使用这个类的本地副本时,它实际上使用的是相同的完全限定名称的原始系统版本。所以问题是这个应用程序不小心直接使用了手机内置的WindowOrientationListener。
https://stackoverflow.com/questions/27114764
复制相似问题