Skip to content

Commit 1b37c1a

Browse files
author
weishu.tws
committed
Merge branch 'exposed' of github.com:android-hacker/VirtualXposed into exposed
2 parents 3847476 + 6b73a34 commit 1b37c1a

File tree

8 files changed

+104
-35
lines changed

8 files changed

+104
-35
lines changed

VirtualApp/app/src/main/AndroidManifest.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
android:name=".settings.SettingsActivity"
6060
android:label="@string/settings_title"
6161
android:screenOrientation="portrait"
62-
android:theme="@style/Theme.AppCompat.Light" />
62+
android:theme="@android:style/Theme.Material.Settings" />
6363

6464
<activity
6565
android:name=".settings.AppManageActivity"
@@ -93,13 +93,18 @@
9393
android:allowTaskReparenting="true"
9494
android:configChanges="keyboard|keyboardHidden|orientation"
9595
android:excludeFromRecents="true"
96-
android:exported="true"
96+
android:exported="false"
9797
android:icon="@mipmap/ic_launcher"
9898
android:label="@string/app_installer_label"
9999
android:noHistory="true"
100100
android:taskAffinity="io.va.exposed.installer"
101-
android:theme="@style/Theme.AppCompat.Light">
101+
android:theme="@style/Theme.AppCompat.Light" />
102102

103+
<activity-alias
104+
android:name="vxp.installer"
105+
android:enabled="true"
106+
android:exported="true"
107+
android:targetActivity=".sys.InstallerActivity">
103108
<intent-filter>
104109
<action android:name="android.intent.action.VIEW" />
105110
<category android:name="android.intent.category.DEFAULT" />
@@ -115,7 +120,7 @@
115120
<data android:scheme="content" />
116121
<data android:mimeType="application/vnd.android.package-archive" />
117122
</intent-filter>
118-
</activity>
123+
</activity-alias>
119124

120125
<service
121126
android:name=".update.VAVersionService"

VirtualApp/app/src/main/java/io/virtualapp/settings/SettingsActivity.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
package io.virtualapp.settings;
22

3+
import android.app.Activity;
4+
import android.content.ComponentName;
35
import android.content.Intent;
6+
import android.content.pm.PackageManager;
47
import android.net.Uri;
58
import android.os.Bundle;
69
import android.preference.Preference;
710
import android.preference.PreferenceFragment;
11+
import android.preference.SwitchPreference;
812
import android.support.v7.app.AlertDialog;
913
import android.widget.Toast;
1014

1115
import com.android.launcher3.LauncherFiles;
1216
import com.lody.virtual.client.core.VirtualCore;
1317

1418
import io.virtualapp.R;
15-
import io.virtualapp.abs.ui.VActivity;
1619
import io.virtualapp.home.ListAppActivity;
1720
import moe.feng.alipay.zerosdk.AlipayZeroSdk;
1821

1922
/**
2023
* Settings activity for Launcher. Currently implements the following setting: Allow rotation
2124
*/
22-
public class SettingsActivity extends VActivity {
25+
public class SettingsActivity extends Activity {
2326

2427
private static final String ADD_APP_KEY = "settings_add_app";
2528
private static final String APP_MANAGE_KEY = "settings_app_manage";
@@ -29,6 +32,8 @@ public class SettingsActivity extends VActivity {
2932
private static final String DONATE_KEY = "settings_donate";
3033
private static final String ABOUT_KEY = "settings_about";
3134
private static final String REBOOT_KEY = "settings_reboot";
35+
private static final String HIDE_SETTINGS_KEY = "advance_settings_hide_settings";
36+
private static final String DISABLE_INSTALLER_KEY = "advance_settings_disable_installer";
3237

3338
@Override
3439
protected void onCreate(Bundle savedInstanceState) {
@@ -65,6 +70,8 @@ public void onCreate(Bundle savedInstanceState) {
6570
Preference about = findPreference(ABOUT_KEY);
6671
Preference reboot = findPreference(REBOOT_KEY);
6772

73+
SwitchPreference disableInstaller = (SwitchPreference) findPreference(DISABLE_INSTALLER_KEY);
74+
6875
addApp.setOnPreferenceClickListener(preference -> {
6976
ListAppActivity.gotoListApp(getActivity());
7077
return false;
@@ -138,6 +145,22 @@ public void onCreate(Bundle savedInstanceState) {
138145
}
139146
return false;
140147
});
148+
149+
disableInstaller.setOnPreferenceChangeListener((preference, newValue) -> {
150+
if (!(newValue instanceof Boolean)) {
151+
return false;
152+
}
153+
try {
154+
boolean disable = (boolean) newValue;
155+
PackageManager packageManager = getActivity().getPackageManager();
156+
packageManager.setComponentEnabledSetting(new ComponentName(getActivity().getPackageName(), "vxp.installer"),
157+
!disable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
158+
PackageManager.DONT_KILL_APP);
159+
return true;
160+
} catch (Throwable ignored) {
161+
return false;
162+
}
163+
});
141164
}
142165
}
143166
}

VirtualApp/app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,9 @@
113113
<string name="install_package">添加新应用 : %s</string>
114114
<string name="install_package_version_tips">你选择了一个已经安装了的应用,\n\n已经安装的版本:%1$s\n即将安装的版本:%2$s,确认安装?</string>
115115
<string name="settings_add_app_summary">必须先把应用以及Xposed模块都添加到 VirtualXposed ,否则Xposed模块不会生效。</string>
116+
<string name="settings_advance">高级设置</string>
117+
<string name="advance_settings_hide_settings">隐藏桌面的设置按钮</string>
118+
<string name="advance_settings_disable_installer">禁用 VirtualXposed 的APK安装器</string>
119+
<string name="advance_settings_hide_settings_summary">如果你可以在主界面通过菜单键(长按多任务或者虚拟菜单键)进入设置,那么可以隐藏这个按钮;否则你将无法进入设置!!\n(强制停止VirtualXposed后生效)</string>
120+
<string name="advance_settings_disable_installer_summary">在系统中安装APK文件的时候,不显示VirtualXposed的安装器</string>
116121
</resources>

VirtualApp/app/src/main/res/values/strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,9 @@
117117
<string name="install_package">Install new app: %s</string>
118118
<string name="install_package_version_tips">You have chosen an existing app, \n(Installed version %1$s, selected version: %2$s, install it?</string>
119119
<string name="settings_add_app_summary">Please add both app and Xposed module to VirtualXposed first, otherwise the Xposed module won\'t take effect.</string>
120+
<string name="settings_advance">Advance Settings</string>
121+
<string name="advance_settings_hide_settings">Hide settings button on desktop</string>
122+
<string name="advance_settings_disable_installer">Disable apk installer for system</string>
123+
<string name="advance_settings_hide_settings_summary">If you can enter settings by menu key on main activity, you can hide this, otherwise you may not be able to enter settings!! \n(Force stop VirtualXposed to take effect.)</string>
124+
<string name="advance_settings_disable_installer_summary">Do not show VirtualXposed\'s installer when you choose apk file in system</string>
120125
</resources>

VirtualApp/app/src/main/res/xml/settings_preferences.xml

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,61 @@
33

44
<Preference
55
android:key="settings_add_app"
6-
android:title="@string/add_app"
6+
android:persistent="false"
77
android:summary="@string/settings_add_app_summary"
8-
android:persistent="false">
9-
</Preference>
8+
android:title="@string/add_app" />
109

1110
<Preference
1211
android:key="settings_app_manage"
13-
android:title="@string/settings_app_manage_text"
14-
android:persistent="false">
15-
</Preference>
12+
android:persistent="false"
13+
android:title="@string/settings_app_manage_text" />
1614

1715
<Preference
1816
android:key="settings_task_manage"
19-
android:title="@string/settings_task_manage_text"
20-
android:persistent="false">
21-
</Preference>
17+
android:persistent="false"
18+
android:title="@string/settings_task_manage_text" />
19+
20+
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
21+
android:title="@string/settings_advance">
22+
23+
<SwitchPreference
24+
android:defaultValue="false"
25+
android:key="advance_settings_hide_settings"
26+
android:persistent="true"
27+
android:summary="@string/advance_settings_hide_settings_summary"
28+
android:title="@string/advance_settings_hide_settings" />
29+
30+
<SwitchPreference
31+
android:defaultValue="false"
32+
android:key="advance_settings_disable_installer"
33+
android:persistent="true"
34+
android:summary="@string/advance_settings_disable_installer_summary"
35+
android:title="@string/advance_settings_disable_installer" />
36+
37+
</PreferenceScreen>
2238

2339
<Preference
2440
android:key="settings_desktop"
25-
android:title="@string/settings_desktop_text"
26-
android:persistent="false">
27-
</Preference>
41+
android:persistent="false"
42+
android:title="@string/settings_desktop_text" />
2843

2944
<Preference
3045
android:key="settings_faq"
31-
android:title="@string/about_faq_title"
32-
android:persistent="false">
33-
</Preference>
46+
android:persistent="false"
47+
android:title="@string/about_faq_title" />
3448

3549
<Preference
3650
android:key="settings_donate"
37-
android:title="@string/about_donate_title"
38-
android:persistent="false">
39-
</Preference>
51+
android:persistent="false"
52+
android:title="@string/about_donate_title" />
4053

4154
<Preference
4255
android:key="settings_about"
43-
android:title="@string/settings_about_text"
44-
android:persistent="false">
45-
</Preference>
56+
android:persistent="false"
57+
android:title="@string/settings_about_text" />
4658

4759
<Preference
4860
android:key="settings_reboot"
49-
android:title="@string/menu_reboot"
50-
android:persistent="false">
51-
</Preference>
61+
android:persistent="false"
62+
android:title="@string/menu_reboot" />
5263
</PreferenceScreen>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.lody.virtual.helper.utils;
2+
3+
import android.util.Base64;
4+
5+
/**
6+
* @author weishu
7+
* @date 18/3/20.
8+
*/
9+
public class EncodeUtils {
10+
11+
public static String decode(String base64) {
12+
return new String(Base64.decode(base64, 0));
13+
}
14+
}

VirtualApp/lib/src/main/java/com/lody/virtual/os/VEnvironment.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.os.Environment;
66

77
import com.lody.virtual.client.core.VirtualCore;
8+
import com.lody.virtual.helper.utils.EncodeUtils;
89
import com.lody.virtual.helper.utils.FileUtils;
910
import com.lody.virtual.helper.utils.VLog;
1011

@@ -67,7 +68,8 @@ public static File getDataUserPackageDirectory(int userId,
6768
}
6869

6970
public static File getPackageResourcePath(String packgeName) {
70-
return new File(getDataAppPackageDirectory(packgeName), "base.apk");
71+
return new File(getDataAppPackageDirectory(packgeName),
72+
EncodeUtils.decode("YmFzZS5hcGs=")); // base.apk
7173
}
7274

7375
public static File getDataAppDirectory() {
@@ -123,9 +125,12 @@ public static File getOdexFile(String packageName) {
123125
// in Android O, the oatfile is relate with classloader, we must ensure the correct location to avoid repeated load dex.
124126
String instructionSet = VMRuntime.getCurrentInstructionSet.call();
125127
File oatDir = ensureCreated(new File(getDataAppPackageDirectory(packageName), "oat" + File.separator + instructionSet));
126-
return new File(oatDir, "base.odex");
128+
return new File(oatDir, EncodeUtils.decode("YmFzZS5vZGV4")); // base.odex
127129
} else {
128-
return new File(DALVIK_CACHE_DIRECTORY, "data@app@" + packageName + "[email protected]@classes.dex");
130+
// return new File(DALVIK_CACHE_DIRECTORY, "data@app@" + packageName + "[email protected]@classes.dex");
131+
return new File(DALVIK_CACHE_DIRECTORY, EncodeUtils.decode("ZGF0YUBhcHBA") +
132+
packageName +
133+
EncodeUtils.decode("LTFAYmFzZS5hcGtAY2xhc3Nlcy5kZXg="));
129134
}
130135
}
131136

@@ -174,7 +179,8 @@ public static File getVirtualStorageDir(String packageName, int userId) {
174179
}
175180

176181
public static File getWifiMacFile(int userId) {
177-
return new File(getUserSystemDirectory(userId), "wifiMacAddress");
182+
// return new File(getUserSystemDirectory(userId), "wifiMacAddress");
183+
return new File(getUserSystemDirectory(userId), EncodeUtils.decode("d2lmaU1hY0FkZHJlc3M="));
178184
}
179185

180186
public static File getDataDirectory() {

0 commit comments

Comments
 (0)