Skip to content

Commit

Permalink
Merge pull request #19 from lianglixin/functional
Browse files Browse the repository at this point in the history
修复快捷方式的问题
  • Loading branch information
lianglixin authored Apr 19, 2019
2 parents 6c228f8 + c80fdee commit a212ad5
Show file tree
Hide file tree
Showing 9 changed files with 279 additions and 14 deletions.
Binary file modified app/release/app-release.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":24,"versionName":"1.2.5","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":24,"versionName":"1.2.5","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
9 changes: 8 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@
<activity
android:name=".home.HomeActivity"
android:screenOrientation="portrait"
android:theme="@style/UITheme" />
android:theme="@style/UITheme"
android:launchMode="singleInstance"
android:exported="true">
<intent-filter>
<action android:name="com.sk.vxpmain" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".home.ListAppActivity"
android:screenOrientation="portrait"
Expand Down
48 changes: 48 additions & 0 deletions app/src/main/java/io/virtualapp/home/HomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import android.widget.Toast;

import com.lody.virtual.GmsSupport;
import com.lody.virtual.client.core.RomChecker;
import com.lody.virtual.client.core.VirtualCore;
import com.lody.virtual.client.ipc.VActivityManager;
import com.lody.virtual.client.stub.ChooseTypeAndAccountActivity;
import com.lody.virtual.os.VUserInfo;
Expand Down Expand Up @@ -89,6 +91,35 @@ public static void goHome(Context context) {
context.startActivity(intent);
}

@Override
protected void onResume()
{
super.onResume();
Bundle lpBundle = getIntent().getExtras();
while(lpBundle!=null)
{
try
{
// Fix android O shortcut by Saurik QQ 384550791
String pIntentInvoke = lpBundle.getString("pArgsToLaunch");
getIntent().removeExtra("pArgsToLaunch");
if (pIntentInvoke == null)
{
break;
}
int dwUserID = lpBundle.getInt("dwUserID");
XAppDataInstalled lpAppInfo = new XAppDataInstalled();
lpAppInfo.pkgName = pIntentInvoke;
LoadingActivity.launch(getContext(),pIntentInvoke,dwUserID);
}
catch(Throwable e)
{
e.printStackTrace();
}
break;
}
}

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
overridePendingTransition(0, 0);
Expand Down Expand Up @@ -239,6 +270,23 @@ private void deleteApp(int position) {
}

private void createShortcut(int position) {
try
{
boolean bIsEMUI = RomChecker.isEmui();
if (bIsEMUI)
{
AlertDialog.Builder hDialog = new AlertDialog.Builder(HomeActivity.hHomeAct);
// 消极
hDialog.setNegativeButton("知道了", (dialog, which) ->
Toast.makeText(HomeActivity.hHomeAct, "记得允许权限哦~", Toast.LENGTH_SHORT).show());
hDialog.setMessage(R.string.rom_shortcut_tips);
hDialog.setTitle(R.string.create_shortcut);
hDialog.create().show();
}
}catch (Throwable e)
{
e.printStackTrace();
}
AppData model = mLaunchpadAdapter.getList().get(position);
if (model instanceof PackageAppData || model instanceof MultiplePackageAppData) {
mPresenter.createShortcut(model);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@
<string name="about_info">"特别感谢甘!##SandVXP是一个应用程序,可以让用户在非Root和非引导加载程序解锁设备上使用Xposed模块。##将应用程序和模块添加或克隆到这个应用程序中,然后在菜单的“Xposed管理器”中启用它,应用和模块就可以工作了。##QQ 384550791##邮箱: [email protected]##网址https://www.fou.ink/ "</string>
<string name="launch_failed">抱歉,启动失败。</string>
<string name="sys_crash">应用程序发生异常,已被捕捉,请留意。</string>
<string name="rom_shortcut_tips">检测到您的机型必须手动允许快捷方式的创建,请到系统设置->应用->权限管理,找到本应用,开启快捷方式权限。</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@
<string name="about_info">"特别感谢甘!##SandVXP是一个应用程序,可以让用户在非Root和非引导加载程序解锁设备上使用Xposed模块。##将应用程序和模块添加或克隆到这个应用程序中,然后在菜单的“Xposed管理器”中启用它,应用和模块就可以工作了。##QQ 384550791##邮箱: [email protected]##网址https://www.fou.ink/ "</string>
<string name="launch_failed">Sorry,App无法启动。</string>
<string name="sys_crash">应用程序异常,已经捕捉。</string>
<string name="rom_shortcut_tips">检测到您的机型必须手动允许快捷方式的创建,请到系统设置->应用->权限管理,找到本应用,开启快捷方式权限。</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,5 @@
<string name="about_info">Special thanks for Gan!##SandVXP is a application that can let user use Xposed module on non-root and non-bootloader-unlock devices. Clone application into this app and xposed modules, then validate it in menu\'s xposed manager, and they will work.##QQ 384550791##E-Mail [email protected]##Website https://www.fou.ink/</string>
<string name="launch_failed">Launch app failed...</string>
<string name="sys_crash">Application may crash but catch by SKActivity.</string>
<string name="rom_shortcut_tips">We detected your device must accept permission manual. Please allow shortcut ceration permission in system settings. Allow this in Settings -> App Management -> Permission Management -> this application -> allow shortcut permission.</string>
</resources>
197 changes: 197 additions & 0 deletions lib/src/main/java/com/lody/virtual/client/core/RomChecker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
package com.lody.virtual.client.core;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class RomChecker
{
private static final String KEY_VERSION_EMUI = "ro.build.version.emui";
private static final String KEY_VERSION_MIUI = "ro.miui.ui.version.name";
private static final String KEY_VERSION_OPPO = "ro.build.version.opporom";
private static final String KEY_VERSION_SMARTISAN = "ro.smartisan.version";
private static final String KEY_VERSION_VIVO = "ro.vivo.os.version";
public static final String ROM_EMUI = "EMUI";
public static final String ROM_FLYME = "FLYME";
public static final String ROM_MIUI = "MIUI";
public static final String ROM_OPPO = "OPPO";
public static final String ROM_QIKU = "QIKU";
public static final String ROM_SMARTISAN = "SMARTISAN";
public static final String ROM_VIVO = "VIVO";
private static final String TAG = "Rom";
private static String sName;
private static String sVersion;

public static boolean check(String str) {
if (sName != null) {
return sName.equals(str);
}
CharSequence prop = getProp(KEY_VERSION_MIUI);
sVersion = (String) prop;
if (TextUtils.isEmpty(prop)) {
prop = getProp(KEY_VERSION_EMUI);
sVersion = (String) prop;
if (TextUtils.isEmpty(prop)) {
prop = getProp(KEY_VERSION_OPPO);
sVersion = (String) prop;
if (TextUtils.isEmpty(prop)) {
prop = getProp(KEY_VERSION_VIVO);
sVersion = (String) prop;
if (TextUtils.isEmpty(prop)) {
prop = getProp(KEY_VERSION_SMARTISAN);
sVersion = (String) prop;
if (TextUtils.isEmpty(prop)) {
sVersion = Build.DISPLAY;
if (sVersion.toUpperCase().contains(ROM_FLYME)) {
sName = ROM_FLYME;
} else {
sName = Build.MANUFACTURER.toUpperCase();
}
} else {
sName = ROM_SMARTISAN;
}
} else {
sName = ROM_VIVO;
}
} else {
sName = ROM_OPPO;
}
} else {
sName = ROM_EMUI;
}
} else {
sName = ROM_MIUI;
}
return sName.equals(str);
}

public static String getName() {
if (sName == null) {
check("");
}
return sName;
}

public static String getProp(String str) {
BufferedReader bufferedReader;
Throwable e;
String str2;
StringBuilder stringBuilder;
Throwable th;
BufferedReader bufferedReader2 = null;
try {
Runtime runtime = Runtime.getRuntime();
StringBuilder stringBuilder2 = new StringBuilder();
stringBuilder2.append("getprop ");
stringBuilder2.append(str);
bufferedReader = new BufferedReader(new InputStreamReader(runtime.exec(stringBuilder2.toString()).getInputStream()), 1024);
try {
String readLine = bufferedReader.readLine();
bufferedReader.close();
try {
bufferedReader.close();
} catch (IOException e2) {
e2.printStackTrace();
}
return readLine;
} catch (IOException e3) {
e = e3;
try {
str2 = TAG;
stringBuilder = new StringBuilder();
stringBuilder.append("Unable to read prop ");
stringBuilder.append(str);
Log.e(str2, stringBuilder.toString(), e);
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException e22) {
e22.printStackTrace();
}
}
return null;
} catch (Throwable th2) {
th = th2;
bufferedReader2 = bufferedReader;
if (bufferedReader2 != null) {
try {
bufferedReader2.close();
} catch (IOException e4) {
e4.printStackTrace();
}
}
throw th;
}
}
} catch (IOException e5) {
e = e5;
bufferedReader = null;
str2 = TAG;
stringBuilder = new StringBuilder();
stringBuilder.append("Unable to read prop ");
stringBuilder.append(str);
Log.e(str2, stringBuilder.toString(), e);
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
return null;
} catch (Throwable th3) {
th = th3;
if (bufferedReader2 != null) {
try {
bufferedReader2.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
return null;
}
}

public static String getVersion() {
if (sVersion == null) {
check("");
}
return sVersion;
}

public static boolean is360() {
if (!check(ROM_QIKU)) {
if (!check("360")) {
return false;
}
}
return true;
}

public static boolean isEmui() {
return check(ROM_EMUI);
}

public static boolean isFlyme() {
return check(ROM_FLYME);
}

public static boolean isMiui() {
return check(ROM_MIUI);
}

public static boolean isOppo() {
return check(ROM_OPPO);
}

public static boolean isSmartisan() {
return check(ROM_SMARTISAN);
}

public static boolean isVivo() {
return check(ROM_VIVO);
}
}
34 changes: 22 additions & 12 deletions lib/src/main/java/com/lody/virtual/client/core/VirtualCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -475,18 +475,28 @@ public boolean createShortcut(int userId, String packageName, Intent splash, OnE
{
ShortcutManager shortcutManager = (ShortcutManager) context.getSystemService(Context.SHORTCUT_SERVICE);
if(shortcutManager.isRequestPinShortcutSupported()) {
Intent shortcutInfoIntent = new Intent(context, android.app.Activity.class);
shortcutInfoIntent.setAction(Intent.ACTION_VIEW);
shortcutInfoIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
ShortcutInfo info = new ShortcutInfo.Builder(context, targetIntent.toUri(0)+userId)
.setIcon(Icon.createWithBitmap(icon))
.setShortLabel(name)
.setIntent(shortcutInfoIntent)
.build();
//当添加快捷方式的确认弹框弹出来时,将被回调
PendingIntent shortcutCallbackIntent = PendingIntent.getBroadcast(context, 0, new Intent(context, android.app.Activity.class),
PendingIntent.FLAG_UPDATE_CURRENT);
shortcutManager.requestPinShortcut(info, shortcutCallbackIntent.getIntentSender());
ShortcutInfo info = null;
try
{
Intent shortcutInfoIntent = new Intent();
shortcutInfoIntent.setAction("com.sk.vxpmain");
shortcutInfoIntent.putExtra("pArgsToLaunch", packageName);
shortcutInfoIntent.putExtra("dwUserID", userId);

info = new ShortcutInfo.Builder(context, targetIntent.toUri(0) + userId)
.setIcon(Icon.createWithBitmap(icon))
.setShortLabel(name)
.setIntent(shortcutInfoIntent)
.build();
//当添加快捷方式的确认弹框弹出来时,将被回调
PendingIntent shortcutCallbackIntent = PendingIntent.getBroadcast(context, 0, new Intent(context, android.app.Activity.class),
PendingIntent.FLAG_UPDATE_CURRENT);
shortcutManager.requestPinShortcut(info, shortcutCallbackIntent.getIntentSender());
}
catch (Throwable e)
{
e.printStackTrace();
}
}
}
else
Expand Down

0 comments on commit a212ad5

Please sign in to comment.