我正在寻找一些帮助,通过应用程序修改Android系统设置。
我在Kitkat 4.4.2下运行自定义Android应用程序时遇到了一些问题。我不确定我的挫败感的来源,但我认为我在清单中缺少某种安全设置或技巧。
背景:我不是开发人员,但这个项目已经落到了我的手上。在部署我们的平板电脑之前,我们会将我们的MDM和公司apk安装到平板电脑上,并运行一个简单的程序来配置一些系统设置。我们在此过程中对平板电脑进行了root并安装了SU二进制文件。
我已经在我的清单中添加了ACCESS_SUPERUSER,但我没有被SuperSU提示要求为此应用程序请求SU访问权限。此外,如果我尝试运行该应用程序,我会收到“应用程序未安装”的toast消息。(我用APPLICATION替换了应用程序名称)
Java代码
Settings.Global.putInt(MainActivity.this.getContentResolver(), Settings.Global.INSTALL_NON_MARKET_APPS, 1);
Settings.Global.putInt(MainActivity.this.getContentResolver(), Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 1);
Settings.Secure.putInt(MainActivity.this.getContentResolver(), Settings.Secure.LOCK_PATERN_ENABLED, 0);
Settings.Secure.putInt(MainActivity.this.getContentResolver(), Settings.Secure.LOCK_PATTERN_VISIBLE, 0);
Settings.System.putInt(MainActivity.this.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 300000);
Settings.Secure.putInt(MainActivity.this.getContentResolver(), Settings.Global.ADB_ENABLED, 0);
清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.APPLICATION"
android:versionCode="1"
android:versionName="1.2" >
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:persistent="false"
android:permission="android.permission.WRITE_SECURE_SETTINGS"
android:exported="true" >
<activity
android:name="com.example.APPLICATION.MainActivity"
android:label="@string/app_name"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Logcat错误
11-20 17:17:51.749: E/Launcher(686): 启动器没有权限启动意图{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.APPLICATION/.MainActivity}。请确保为相应的活动创建一个MAIN意图过滤器,或者使用此活动的导出属性。标记=ApplicationInfo(title=SetSet id=-1 type=0 container=-1 screen=-1 cellX=-1 cellY=-1 spanX=1 spanY=1 dropPos=null) intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.setset/.MainActivity }
11-20 17:32:16.169: E/AndroidRuntime(4744): java.lang.RuntimeException:无法启动活动ComponentInfo{com.example.setset/com.example.APPLICATION.MainActivity}:java.lang.SecurityException:权限拒绝:写入安全设置需要android.permission.WRITE_SECURE_SETTINGS
/system/app
和/system/priv-app
文件夹中,但是我收到了类似的结果。我还尝试在清单中添加标签android:sharedUserId="android.uid.system"
,但似乎没有什么区别。 - DontCopyThatFloppy/system/app
并重新启动后,我在设备上没有看到该应用程序。它也未列在“设置>>应用程序>>预装”下。可能有一些残留的东西来自以前的安装,阻止了这个吗?此外,尝试进行adb install
时出现以下错误:Failure [INSTALL_FAILED_SHARED_USER_INCOMPATIBLE]
。 - DontCopyThatFloppy