WIP Sync
It might compile, is probably broken atm...
This commit is contained in:
parent
8176fb7bad
commit
0cbf66996f
@ -32,9 +32,9 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
compile 'com.android.support:recyclerview-v7:24.2.1'
|
compile 'com.android.support:recyclerview-v7:24.2.0'
|
||||||
compile 'com.android.support:cardview-v7:24.2.1'
|
compile 'com.android.support:cardview-v7:24.2.0'
|
||||||
compile 'com.android.support:design:24.2.1'
|
compile 'com.android.support:design:24.2.0'
|
||||||
compile 'com.github.d8ahazard:BroadcastTileSupportUpdate:master'
|
compile 'com.github.d8ahazard:BroadcastTileSupportUpdate:master'
|
||||||
compile 'com.jakewharton:butterknife:8.4.0'
|
compile 'com.jakewharton:butterknife:8.4.0'
|
||||||
compile 'com.github.michalis-vitos:aFileChooser:master'
|
compile 'com.github.michalis-vitos:aFileChooser:master'
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
</service>
|
</service>
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".tile.PrivateBroadcastReceiver"
|
android:name=".receivers.PrivateBroadcastReceiver"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
@ -107,6 +107,11 @@
|
|||||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
<receiver android:name=".RootFragment.mYourBroadcastReceiner">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="com.magisk.UPDATEUI"/>
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
package com.topjohnwu.magisk;
|
package com.topjohnwu.magisk;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -22,6 +25,8 @@ import android.widget.Switch;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.receivers.Receiver;
|
||||||
|
import com.topjohnwu.magisk.receivers.RootFragmentReceiver;
|
||||||
import com.topjohnwu.magisk.services.MonitorService;
|
import com.topjohnwu.magisk.services.MonitorService;
|
||||||
import com.topjohnwu.magisk.utils.Shell;
|
import com.topjohnwu.magisk.utils.Shell;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
@ -33,7 +38,7 @@ import butterknife.BindColor;
|
|||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
public class RootFragment extends Fragment {
|
public class RootFragment extends Fragment implements Receiver{
|
||||||
|
|
||||||
public SharedPreferences prefs;
|
public SharedPreferences prefs;
|
||||||
@BindView(R.id.progressBar)
|
@BindView(R.id.progressBar)
|
||||||
@ -92,7 +97,6 @@ public class RootFragment extends Fragment {
|
|||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.root_fragment, container, false);
|
View view = inflater.inflate(R.layout.root_fragment, container, false);
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
|
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
|
||||||
if (prefs.contains("autoRootEnable")) {
|
if (prefs.contains("autoRootEnable")) {
|
||||||
@ -112,7 +116,7 @@ public class RootFragment extends Fragment {
|
|||||||
|
|
||||||
autoRootToggle.setOnClickListener(toggle -> {
|
autoRootToggle.setOnClickListener(toggle -> {
|
||||||
ToggleAutoRoot(autoRootToggle.isChecked());
|
ToggleAutoRoot(autoRootToggle.isChecked());
|
||||||
new Handler().postDelayed(() -> new updateUI().execute(), 1000);
|
new updateUI().execute();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -121,9 +125,23 @@ public class RootFragment extends Fragment {
|
|||||||
new updateUI().execute();
|
new updateUI().execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mYourBroadcastReceiver,
|
||||||
|
new IntentFilter("com.magisk.UPDATEUI"));
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final BroadcastReceiver mYourBroadcastReceiver = new RootFragmentReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
|
||||||
|
Log.d("Magisk", "RootFragment: UpdateRF called and fired");
|
||||||
|
new updateUI().execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
// Check which request we're responding to
|
// Check which request we're responding to
|
||||||
@ -139,6 +157,9 @@ public class RootFragment extends Fragment {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (requestCode == 420) {
|
||||||
|
Log.d("Magisk", "Got result code OK for UI update.");
|
||||||
|
new updateUI().execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,6 +195,11 @@ public class RootFragment extends Fragment {
|
|||||||
new updateUI().execute();
|
new updateUI().execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResult() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public class updateUI extends AsyncTask<Void, Void, Void> {
|
public class updateUI extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -301,4 +327,5 @@ public class RootFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void navigate(final int itemId) {
|
public void navigate(final int itemId) {
|
||||||
Fragment navFragment = null;
|
Fragment navFragment = null;
|
||||||
String tag = "";
|
String tag = "";
|
||||||
switch (itemId) {
|
switch (itemId) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.topjohnwu.magisk.tile;
|
package com.topjohnwu.magisk.receivers;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -19,15 +19,16 @@ public final class PrivateBroadcastReceiver extends BroadcastReceiver {
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
Log.d("Magisk","Broadcast Receiver, Made it this far!");
|
Log.d("Magisk","Broadcast Receiver, Made it this far! We're trying to " + action);
|
||||||
if (ACTION_AUTOROOT.equals(action)) {
|
if (ACTION_AUTOROOT.equals(action)) {
|
||||||
Utils.toggleAutoRoot(true, context);
|
Utils.toggleAutoRoot(!Utils.autoRootEnabled(context),context);
|
||||||
}
|
}
|
||||||
if (ACTION_ENABLEROOT.equals(action)) {
|
if (ACTION_ENABLEROOT.equals(action)) {
|
||||||
Utils.toggleAutoRoot(false, context);
|
Utils.toggleAutoRoot(false, context);
|
||||||
Utils.toggleRoot(true);
|
Utils.toggleRoot(true);
|
||||||
}
|
}
|
||||||
if (ACTION_DISABLEROOT.equals(action)) {
|
if (ACTION_DISABLEROOT.equals(action)) {
|
||||||
|
Utils.toggleAutoRoot(false, context);
|
||||||
Utils.toggleRoot(false);
|
Utils.toggleRoot(false);
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.topjohnwu.magisk.receivers;
|
||||||
|
|
||||||
|
public interface Receiver {
|
||||||
|
void onResult();
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.topjohnwu.magisk.receivers;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
public class RootFragmentReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
|
private Receiver mFragment;
|
||||||
|
public RootFragmentReceiver(Receiver fragment) {
|
||||||
|
mFragment = fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (intent.getAction().equals(420)) {
|
||||||
|
mFragment.onResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,59 +0,0 @@
|
|||||||
package com.topjohnwu.magisk.tile;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.kcoppock.broadcasttilesupport.BroadcastTileIntentBuilder;
|
|
||||||
import com.topjohnwu.magisk.R;
|
|
||||||
|
|
||||||
final public class CustomTileHelper {
|
|
||||||
/**
|
|
||||||
* This is the identifier of the custom Broadcast Tile. Whatever action you configured the tile
|
|
||||||
* for must be used when configuring the tile. For Broadcast tiles, only alphanumeric characters
|
|
||||||
* (and periods) are allowed. Keep in mind that this excludes underscores.
|
|
||||||
*/
|
|
||||||
private static final String BROADCAST_TILE_IDENTIFIER = "com.kcoppock.CUSTOMTILE";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Keeps track of the last known state of the Quick Settings custom tile. There doesn't seem to
|
|
||||||
* be a way to query the state of the tile.
|
|
||||||
*/
|
|
||||||
private static final String PREF_TILE_SHOWN = "com.kcoppock.CUSTOMTILE_SHOWN";
|
|
||||||
|
|
||||||
private final Context mContext;
|
|
||||||
private final TilePreferenceHelper mTilePreferenceHelper;
|
|
||||||
|
|
||||||
CustomTileHelper(@NonNull Context context) {
|
|
||||||
mContext = context.getApplicationContext();
|
|
||||||
mTilePreferenceHelper = new TilePreferenceHelper(mContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
void showTile() {
|
|
||||||
mTilePreferenceHelper.setBoolean(PREF_TILE_SHOWN, true);
|
|
||||||
|
|
||||||
// Set up an Intent that will be broadcast by the system, and received by the exported
|
|
||||||
// PublicBroadcastReceiver.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Send the update event to the Broadcast Tile. Custom tiles are hidden by default until
|
|
||||||
// enabled with this broadcast Intent.
|
|
||||||
mContext.sendBroadcast(new BroadcastTileIntentBuilder(mContext, BROADCAST_TILE_IDENTIFIER)
|
|
||||||
.setVisible(true)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
void hideTile() {
|
|
||||||
mTilePreferenceHelper.setBoolean(PREF_TILE_SHOWN, false);
|
|
||||||
|
|
||||||
mContext.sendBroadcast(new BroadcastTileIntentBuilder(mContext, BROADCAST_TILE_IDENTIFIER)
|
|
||||||
.setVisible(false)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isLastTileStateShown() {
|
|
||||||
return mTilePreferenceHelper.getBoolean(PREF_TILE_SHOWN);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package com.topjohnwu.magisk.tile;
|
|
||||||
|
|
||||||
import android.content.*;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exported receiver for the custom event on the custom Quick Settings tile
|
|
||||||
*/
|
|
||||||
public final class PublicBroadcastReceiver extends BroadcastReceiver {
|
|
||||||
/**
|
|
||||||
* The action broadcast from the Quick Settings tile when clicked
|
|
||||||
*/
|
|
||||||
public static final String ACTION_TOAST = "com.kcoppock.CUSTOMTILE_ACTION_TOAST";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constant for the String extra to be displayed in the Toast
|
|
||||||
*/
|
|
||||||
public static final String EXTRA_MESSAGE = "com.kcoppock.CUSTOMTILE_EXTRA_MESSAGE";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
final String action = intent.getAction();
|
|
||||||
|
|
||||||
if (ACTION_TOAST.equals(action)) {
|
|
||||||
final String message = intent.getStringExtra(EXTRA_MESSAGE);
|
|
||||||
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package com.topjohnwu.magisk.tile;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper class for tracking preference values to keep track of the state of the custom tile
|
|
||||||
*/
|
|
||||||
final public class TilePreferenceHelper {
|
|
||||||
private static final String PREFS_NAME = "tile_prefs";
|
|
||||||
|
|
||||||
private final SharedPreferences mSharedPreferences;
|
|
||||||
|
|
||||||
TilePreferenceHelper(@NonNull Context context) {
|
|
||||||
mSharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBoolean(@NonNull String key, boolean value) {
|
|
||||||
mSharedPreferences.edit().putBoolean(key, value).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean getBoolean(@NonNull String key) {
|
|
||||||
return mSharedPreferences.getBoolean(key, false);
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,6 +10,7 @@ import android.content.ContentResolver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@ -32,13 +33,15 @@ import com.kcoppock.broadcasttilesupport.BroadcastTileIntentBuilder;
|
|||||||
import com.topjohnwu.magisk.ModulesFragment;
|
import com.topjohnwu.magisk.ModulesFragment;
|
||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.ReposFragment;
|
import com.topjohnwu.magisk.ReposFragment;
|
||||||
|
import com.topjohnwu.magisk.RootFragment;
|
||||||
import com.topjohnwu.magisk.module.Module;
|
import com.topjohnwu.magisk.module.Module;
|
||||||
import com.topjohnwu.magisk.module.Repo;
|
import com.topjohnwu.magisk.module.Repo;
|
||||||
import com.topjohnwu.magisk.module.RepoHelper;
|
import com.topjohnwu.magisk.module.RepoHelper;
|
||||||
import com.topjohnwu.magisk.tile.PrivateBroadcastReceiver;
|
import com.topjohnwu.magisk.receivers.PrivateBroadcastReceiver;
|
||||||
|
import com.topjohnwu.magisk.receivers.Receiver;
|
||||||
|
import com.topjohnwu.magisk.receivers.RootFragmentReceiver;
|
||||||
import com.topjohnwu.magisk.services.MonitorService;
|
import com.topjohnwu.magisk.services.MonitorService;
|
||||||
import com.topjohnwu.magisk.services.QuickSettingTileService;
|
import com.topjohnwu.magisk.services.QuickSettingTileService;
|
||||||
import com.topjohnwu.magisk.tile.CustomTileHelper;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -96,7 +99,9 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean autoRootEnabled(Context context) {
|
public static boolean autoRootEnabled(Context context) {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("autoRootEnable", false);
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
Log.d("Magisk", "AutoRootEnableCheck is " + preferences.getBoolean("autoRootEnable", false));
|
||||||
|
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("autoRootEnable", false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,22 +124,26 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void toggleRoot(Boolean b) {
|
public static void toggleRoot(Boolean b) {
|
||||||
if (b) {
|
if (Utils.magiskVersion != -1) {
|
||||||
Shell.su("ln -s $(getprop magisk.supath) /magisk/.core/bin", "setprop magisk.root 1");
|
if (b) {
|
||||||
} else {
|
Shell.su("ln -s $(getprop magisk.supath) /magisk/.core/bin", "setprop magisk.root 1");
|
||||||
Shell.su("rm -rf /magisk/.core/bin", "setprop magisk.root 0");
|
} else {
|
||||||
|
Shell.su("rm -rf /magisk/.core/bin", "setprop magisk.root 0");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toggleAutoRoot(Boolean b, Context context) {
|
public static void toggleAutoRoot(Boolean b, Context context) {
|
||||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("autoRootEnable", b).apply();
|
if (Utils.magiskVersion != -1) {
|
||||||
Intent myServiceIntent = new Intent(context, MonitorService.class);
|
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("autoRootEnable", b).apply();
|
||||||
if (b) {
|
Intent myServiceIntent = new Intent(context, MonitorService.class);
|
||||||
context.startService(myServiceIntent);
|
if (b) {
|
||||||
} else {
|
context.startService(myServiceIntent);
|
||||||
context.stopService(myServiceIntent);
|
} else {
|
||||||
|
context.stopService(myServiceIntent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
UpdateRootFragmentUI(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getModList(String path) {
|
public static List<String> getModList(String path) {
|
||||||
@ -196,22 +205,24 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void SetupQuickSettingsTile(Context mContext) {
|
public static void SetupQuickSettingsTile(Context mContext) {
|
||||||
Log.d("Magisk","Utils: SetupQuickSettings called");
|
Log.d("Magisk", "Utils: SetupQuickSettings called");
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
Intent serviceIntent = new Intent(mContext, QuickSettingTileService.class);
|
Intent serviceIntent = new Intent(mContext, QuickSettingTileService.class);
|
||||||
mContext.startService(serviceIntent);
|
mContext.startService(serviceIntent);
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
|
||||||
Log.d("Magisk","Utils: Marshmallow build detected");
|
Log.d("Magisk", "Utils: Marshmallow build detected");
|
||||||
String mLabelString;
|
String mLabelString;
|
||||||
int mRootIcon = R.drawable.root;
|
int mRootIcon = R.drawable.root_white;
|
||||||
int mAutoRootIcon = R.drawable.ic_autoroot;
|
int mAutoRootIcon = R.drawable.ic_autoroot_white;
|
||||||
|
int mRootDisabled = R.drawable.root_grey;
|
||||||
int mRootsState = CheckRootsState(mContext);
|
int mRootsState = CheckRootsState(mContext);
|
||||||
Log.d("Magisk","Utils: Root State returned as " + mRootsState);
|
Log.d("Magisk", "Utils: Root State returned as " + mRootsState);
|
||||||
final Intent enableBroadcast = new Intent(PrivateBroadcastReceiver.ACTION_ENABLEROOT);
|
final Intent enableBroadcast = new Intent(PrivateBroadcastReceiver.ACTION_ENABLEROOT);
|
||||||
final Intent disableBroadcast = new Intent(PrivateBroadcastReceiver.ACTION_DISABLEROOT);
|
final Intent disableBroadcast = new Intent(PrivateBroadcastReceiver.ACTION_DISABLEROOT);
|
||||||
final Intent autoBroadcast = new Intent(PrivateBroadcastReceiver.ACTION_AUTOROOT);
|
final Intent autoBroadcast = new Intent(PrivateBroadcastReceiver.ACTION_AUTOROOT);
|
||||||
Intent intent;
|
Intent intent;
|
||||||
|
|
||||||
int mIcon;
|
int mIcon;
|
||||||
switch (mRootsState) {
|
switch (mRootsState) {
|
||||||
case 2:
|
case 2:
|
||||||
@ -222,30 +233,41 @@ public class Utils {
|
|||||||
case 1:
|
case 1:
|
||||||
mLabelString = "Root enabled";
|
mLabelString = "Root enabled";
|
||||||
mIcon = mRootIcon;
|
mIcon = mRootIcon;
|
||||||
intent = enableBroadcast;
|
intent = disableBroadcast;
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
mLabelString = "Root disabled";
|
mLabelString = "Root disabled";
|
||||||
mIcon = mRootIcon;
|
mIcon = mRootDisabled;
|
||||||
intent = disableBroadcast;
|
intent = enableBroadcast;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mLabelString = "Root enabled";
|
mLabelString = "Root disabled";
|
||||||
mIcon = mRootIcon;
|
mIcon = mRootDisabled;
|
||||||
intent = enableBroadcast;
|
intent = disableBroadcast;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent tileConfigurationIntent = new BroadcastTileIntentBuilder(mContext, "ROOT")
|
Intent tileConfigurationIntent = new BroadcastTileIntentBuilder(mContext, "Magisk")
|
||||||
.setLabel(mLabelString)
|
.setLabel(mLabelString)
|
||||||
.setIconResource(mIcon)
|
.setIconResource(mIcon)
|
||||||
.setOnClickBroadcast(intent)
|
.setOnClickBroadcast(intent)
|
||||||
|
.setOnLongClickBroadcast(autoBroadcast)
|
||||||
|
.setVisible(true)
|
||||||
.build();
|
.build();
|
||||||
mContext.sendBroadcast(tileConfigurationIntent);
|
mContext.sendBroadcast(tileConfigurationIntent);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void UpdateRootFragmentUI(Context context) {
|
||||||
|
|
||||||
|
Log.d("Magisk", "Utils: UpdateRF called");
|
||||||
|
Intent intent = new Intent(context, RootFragment.class);
|
||||||
|
intent.setAction("com.magisk.UPDATEUI");
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Gets an overall state for the quick settings tile
|
// Gets an overall state for the quick settings tile
|
||||||
// 0 for root disabled, 1 for root enabled (no auto), 2 for auto-root
|
// 0 for root disabled, 1 for root enabled (no auto), 2 for auto-root
|
||||||
|
|
||||||
@ -562,8 +584,6 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean isMyServiceRunning(Class<?> serviceClass, Context context) {
|
public static boolean isMyServiceRunning(Class<?> serviceClass, Context context) {
|
||||||
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
||||||
|
4
app/src/main/res/drawable/ic_autoroot_white.xml
Normal file
4
app/src/main/res/drawable/ic_autoroot_white.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<vector android:height="24dp" android:viewportHeight="400.0"
|
||||||
|
android:viewportWidth="400.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillAlpha="1.00" android:fillColor="#fff" android:pathData="M200.6,24.2C231.8,24.2 263,33 289.6,49.5C304.7,58.8 318.2,70.7 329.8,84.1C351.5,109.6 365.2,141.7 368.8,175C373.6,217.4 361.5,261.5 335.5,295.5C334.2,297.1 332.8,298.7 331.9,300.7C341.7,310.1 351,320 360.9,329.3C322.7,339.3 284.5,349.6 246.3,359.9C256.4,323.5 266,287 275.7,250.5C262.4,250.5 249.1,250.5 235.8,250.5C228.5,269.8 221.2,289.1 214.1,308.4C205.9,308.6 197.8,308.5 189.6,308.5C188.4,306.7 187.1,304.9 185.9,303C192.4,285.5 199.1,268 205.6,250.5C189.5,250.6 173.4,250.3 157.4,250.6C150.4,270 142.9,289.2 135.8,308.5C129.8,308.5 123.9,308.4 117.9,308.6C130.4,317.8 144,325.6 158.9,330.3C171.9,334.6 185.6,336.6 199.4,336.7C199.4,349.4 199.3,362.1 199.4,374.8C165.8,374.9 132.2,364.5 104.4,345.6C91.7,337 80.3,326.5 70.2,314.9C48.5,289.4 34.8,257.3 31.2,224C26.3,180.4 39.2,134.9 66.8,100.7C67.2,99.9 67.7,99.2 68.1,98.4C58.3,88.9 49,79 39.1,69.7C77.3,59.7 115.6,49.4 153.7,39.1C143.6,75.7 133.8,112.5 124.1,149.3C137.9,149.3 151.7,149.2 165.5,149.3C172.9,130 180.2,110.6 187.3,91.2C195.5,90.8 203.7,91 211.8,91C213,92.8 214.3,94.6 215.5,96.3C209.1,114 202.3,131.6 195.8,149.2C211.8,149.3 227.8,149.2 243.9,149.3C251.2,129.9 258.3,110.3 265.8,90.9C271.5,90.8 277.3,91.6 282.9,90.4C280.2,89.5 278.1,87.7 275.9,86.1C254,70.7 227.4,62.2 200.6,62.3C200.6,49.6 200.7,36.9 200.6,24.2M292.5,100C286.4,116.4 280.2,132.8 274,149.3C280.9,149.2 287.8,149.3 294.7,149.2C296,150.8 297.3,152.4 298.6,153.9C297.1,162.1 295.7,170.3 294.3,178.5C283.9,178.5 273.4,178.5 262.9,178.5C257.5,192.7 252.1,206.9 246.9,221.2C258.7,221.3 270.5,221.1 282.3,221.3C283.5,222.9 284.8,224.4 286.1,225.9C284.9,233.7 283.4,241.4 282.1,249.1C281.6,251 283.6,252.1 284.6,253.3C291.5,259.8 297.7,266.9 304.8,273.1C312.9,262.1 319.6,250.1 324.2,237.3C334.3,208.7 334.2,176.7 323.7,148.3C317,130.1 306.4,113.4 292.5,100M95.2,125.9C86.2,138 79,151.4 74.5,165.8C65.3,194.4 66.4,226.3 77.6,254.2C84.6,271.5 95.1,287.4 108.7,300.1C114.9,283.6 121.3,267.1 127.2,250.5C121.5,250.5 115.8,250.5 110,250.5C108.6,250.4 106.7,251 105.8,249.5C104.5,247.9 102.3,246.3 102.9,244.1C104.2,236.5 105.5,228.9 106.8,221.2C117.4,221.2 128.1,221.4 138.7,221.1C143.9,206.9 149.3,192.7 154.6,178.5C142.9,178.4 131.1,178.6 119.3,178.4C117.6,177.3 116.4,175.3 115,173.8C116.3,165.8 117.9,157.9 119,150C118.3,148.2 116.6,147.1 115.3,145.7C108.6,139.2 102.3,132.1 95.2,125.9M168.8,221.2C184.8,221.2 200.8,221.3 216.8,221.2C222.2,207 227.5,192.8 232.8,178.5C216.8,178.5 200.7,178.5 184.6,178.5C179.4,192.8 174,207 168.8,221.2Z"/>
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/root_grey.xml
Normal file
9
app/src/main/res/drawable/root_grey.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:viewportWidth="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#666"
|
||||||
|
android:pathData="M3,5A2,2 0 0,1 5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5C3.89,21 3,20.1 3,19V5M7,18H9L9.35,16H13.35L13,18H15L15.35,16H17.35L17.71,14H15.71L16.41,10H18.41L18.76,8H16.76L17.12,6H15.12L14.76,8H10.76L11.12,6H9.12L8.76,8H6.76L6.41,10H8.41L7.71,14H5.71L5.35,16H7.35L7,18M10.41,10H14.41L13.71,14H9.71L10.41,10Z"/>
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/root_white.xml
Normal file
9
app/src/main/res/drawable/root_white.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:viewportWidth="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#fff"
|
||||||
|
android:pathData="M3,5A2,2 0 0,1 5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5C3.89,21 3,20.1 3,19V5M7,18H9L9.35,16H13.35L13,18H15L15.35,16H17.35L17.71,14H15.71L16.41,10H18.41L18.76,8H16.76L17.12,6H15.12L14.76,8H10.76L11.12,6H9.12L8.76,8H6.76L6.41,10H8.41L7.71,14H5.71L5.35,16H7.35L7,18M10.41,10H14.41L13.71,14H9.71L10.41,10Z"/>
|
||||||
|
</vector>
|
Loading…
Reference in New Issue
Block a user