mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-26 21:57:39 +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">
|
<receiver android:name=".receivers.PackageReceiver">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.PACKAGE_ADDED" />
|
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
||||||
<action android:name="android.intent.action.PACKAGE_REMOVED" />
|
<action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
|
||||||
<data android:scheme="package" />
|
<data android:scheme="package" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package com.topjohnwu.magisk;
|
package com.topjohnwu.magisk;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.PreferenceCategory;
|
import android.preference.PreferenceCategory;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
import android.preference.SwitchPreference;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@ -81,6 +83,7 @@ public class SettingsActivity extends Activity {
|
|||||||
suNotification = (ListPreference) findPreference("su_notification");
|
suNotification = (ListPreference) findPreference("su_notification");
|
||||||
multiuserMode = (ListPreference) findPreference("multiuser_mode");
|
multiuserMode = (ListPreference) findPreference("multiuser_mode");
|
||||||
namespaceMode = (ListPreference) findPreference("mnt_ns");
|
namespaceMode = (ListPreference) findPreference("mnt_ns");
|
||||||
|
SwitchPreference reauth = (SwitchPreference) findPreference("su_reauth");
|
||||||
|
|
||||||
setSummary();
|
setSummary();
|
||||||
|
|
||||||
@ -90,6 +93,11 @@ public class SettingsActivity extends Activity {
|
|||||||
prefScreen.removePreference(suCategory);
|
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) -> {
|
findPreference("clear").setOnPreferenceClickListener((pref) -> {
|
||||||
Utils.clearRepoCache(getActivity());
|
Utils.clearRepoCache(getActivity());
|
||||||
return true;
|
return true;
|
||||||
|
@ -20,20 +20,22 @@ public class PackageReceiver extends BroadcastReceiver {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
switch (intent.getAction()) {
|
switch (intent.getAction()) {
|
||||||
case Intent.ACTION_PACKAGE_ADDED:
|
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);
|
int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
|
||||||
// Update the UID if available
|
// Update the UID if available
|
||||||
if (uid > 0) {
|
if (uid > 0) {
|
||||||
policy.uid = uid % 100000;
|
policy.uid = uid % 100000;
|
||||||
}
|
}
|
||||||
magiskManager.suDB.updatePolicy(policy);
|
magiskManager.suDB.updatePolicy(policy);
|
||||||
return;
|
|
||||||
case Intent.ACTION_PACKAGE_REMOVED:
|
|
||||||
boolean isUpdate = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
|
|
||||||
if (!isUpdate || magiskManager.suReauth) {
|
|
||||||
magiskManager.suDB.deletePolicy(policy);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Intent.ACTION_PACKAGE_FULLY_REMOVED:
|
||||||
|
magiskManager.suDB.deletePolicy(policy);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user