mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-26 08:57:43 +00:00
Adapt to Android O new broadcast limitations
This commit is contained in:
parent
789fef34ba
commit
bf1f941e50
@ -62,8 +62,8 @@
|
||||
|
||||
<receiver android:name=".receivers.PackageReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.PACKAGE_ADDED" />
|
||||
<action android:name="android.intent.action.PACKAGE_REMOVED" />
|
||||
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
||||
<action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
|
||||
<data android:scheme="package" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
@ -1,12 +1,14 @@
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.preference.SwitchPreference;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.widget.Toast;
|
||||
@ -81,6 +83,7 @@ public class SettingsActivity extends Activity {
|
||||
suNotification = (ListPreference) findPreference("su_notification");
|
||||
multiuserMode = (ListPreference) findPreference("multiuser_mode");
|
||||
namespaceMode = (ListPreference) findPreference("mnt_ns");
|
||||
SwitchPreference reauth = (SwitchPreference) findPreference("su_reauth");
|
||||
|
||||
setSummary();
|
||||
|
||||
@ -90,6 +93,11 @@ public class SettingsActivity extends Activity {
|
||||
prefScreen.removePreference(suCategory);
|
||||
}
|
||||
|
||||
// Remove re-authentication option on Android O, it will not work
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
suCategory.removePreference(reauth);
|
||||
}
|
||||
|
||||
findPreference("clear").setOnPreferenceClickListener((pref) -> {
|
||||
Utils.clearRepoCache(getActivity());
|
||||
return true;
|
||||
|
@ -20,20 +20,22 @@ public class PackageReceiver extends BroadcastReceiver {
|
||||
return;
|
||||
|
||||
switch (intent.getAction()) {
|
||||
case Intent.ACTION_PACKAGE_ADDED:
|
||||
int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
|
||||
// Update the UID if available
|
||||
if (uid > 0) {
|
||||
policy.uid = uid % 100000;
|
||||
}
|
||||
magiskManager.suDB.updatePolicy(policy);
|
||||
return;
|
||||
case Intent.ACTION_PACKAGE_REMOVED:
|
||||
boolean isUpdate = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
|
||||
if (!isUpdate || magiskManager.suReauth) {
|
||||
case Intent.ACTION_PACKAGE_REPLACED:
|
||||
// This will only work pre-O
|
||||
if (magiskManager.suReauth) {
|
||||
magiskManager.suDB.deletePolicy(policy);
|
||||
} else {
|
||||
int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
|
||||
// Update the UID if available
|
||||
if (uid > 0) {
|
||||
policy.uid = uid % 100000;
|
||||
}
|
||||
magiskManager.suDB.updatePolicy(policy);
|
||||
}
|
||||
break;
|
||||
case Intent.ACTION_PACKAGE_FULLY_REMOVED:
|
||||
magiskManager.suDB.deletePolicy(policy);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user