Skip to content

Commit

Permalink
Add DirectBoot support to receivers and SuRequestActivity
Browse files Browse the repository at this point in the history
Close topjohnwu#1032, courtesy of @vvb2060
  • Loading branch information
topjohnwu committed Feb 4, 2019
1 parent f620ac7 commit 81a0cdd
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
9 changes: 7 additions & 2 deletions app-core/src/main/java/com/topjohnwu/magisk/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.AsyncTask;
import android.os.Build;
import android.preference.PreferenceManager;

import com.topjohnwu.magisk.core.BuildConfig;
Expand Down Expand Up @@ -40,9 +41,13 @@ protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
self = this;

prefs = PreferenceManager.getDefaultSharedPreferences(this);
Context de = this;
if (Build.VERSION.SDK_INT >= 24) {
de = createDeviceProtectedStorageContext();
de.moveSharedPreferencesFrom(this, PreferenceManager.getDefaultSharedPreferencesName(base));
}
prefs = PreferenceManager.getDefaultSharedPreferences(de);
mDB = new MagiskDB(this);
repoDB = new RepoDatabaseHelper(this);

Networking.init(this);
LocaleManager.setLocale(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.topjohnwu.magisk.Config;
import com.topjohnwu.magisk.Const;
import com.topjohnwu.magisk.container.TarEntry;
import com.topjohnwu.magisk.core.R;
import com.topjohnwu.magisk.utils.Utils;
import com.topjohnwu.net.DownloadProgressListener;
import com.topjohnwu.net.Networking;
Expand Down
13 changes: 8 additions & 5 deletions app/src/full/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<application
android:name="a.e"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning">
tools:ignore="UnusedAttribute,GoogleAppIndexingWarning">

<!-- Activities -->

Expand Down Expand Up @@ -39,28 +38,32 @@

<activity
android:name="a.m"
android:directBootAware="true"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:taskAffinity="internal.superuser"
android:taskAffinity="a.m"
android:theme="@style/SuRequest" />

<!-- Receiver -->

<receiver android:name="a.h">
<receiver
android:name="a.h"
android:directBootAware="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.LOCALE_CHANGED" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />

<data android:scheme="package" />
</intent-filter>
</receiver>

<!-- Service -->

<service android:name="a.j"/>
<service android:name="a.j" />

<!-- Hardcode GMS version -->
<meta-data
Expand Down
4 changes: 4 additions & 0 deletions app/src/full/java/com/topjohnwu/magisk/SplashActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.text.TextUtils;

import com.topjohnwu.magisk.components.BaseActivity;
import com.topjohnwu.magisk.database.RepoDatabaseHelper;
import com.topjohnwu.magisk.tasks.UpdateRepos;
import com.topjohnwu.magisk.uicomponents.Notifications;
import com.topjohnwu.magisk.uicomponents.Shortcuts;
Expand Down Expand Up @@ -67,6 +68,9 @@ private void initAndStart() {
// Setup shortcuts
Shortcuts.setup(this);

// Create repo database
app.repoDB = new RepoDatabaseHelper(this);

// Magisk working as expected
if (Shell.rootAccess() && Config.magiskVersionCode > 0) {
// Load modules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.topjohnwu.magisk.container.Policy;
import com.topjohnwu.magisk.utils.FingerprintHelper;
import com.topjohnwu.magisk.utils.SuConnector;
import com.topjohnwu.magisk.utils.Utils;

import java.io.IOException;

Expand Down Expand Up @@ -75,7 +76,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

PackageManager pm = getPackageManager();
app.mDB.clearOutdated();
timeoutPrefs = getSharedPreferences("su_timeout", 0);
timeoutPrefs = Utils.getDEContext().getSharedPreferences("su_timeout", 0);

// Get policy
Intent intent = getIntent();
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

<application
android:installLocation="internalOnly"
android:allowBackup="true"
android:directBootAware="true"
android:icon="@drawable/ic_launcher"
android:installLocation="internalOnly"
android:label="@string/app_name"
android:supportsRtl="true"
tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">
Expand All @@ -28,4 +27,4 @@

</application>

</manifest>
</manifest>

0 comments on commit 81a0cdd

Please sign in to comment.