Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
cc4da97f
Commit
cc4da97f
authored
Sep 10, 2021
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove game receiver
parent
e35f4fa0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
82 deletions
+35
-82
libcore/src/main/AndroidManifest.xml
libcore/src/main/AndroidManifest.xml
+1
-7
libcore/src/main/java/cn/garymb/ygomobile/GameReceiver.java
libcore/src/main/java/cn/garymb/ygomobile/GameReceiver.java
+0
-38
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
.../src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
+19
-23
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
...rc/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
+13
-7
libygo/src/main/AndroidManifest.xml
libygo/src/main/AndroidManifest.xml
+2
-7
No files found.
libcore/src/main/AndroidManifest.xml
View file @
cc4da97f
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<application>
<application>
<activity
<activity
...
@@ -23,13 +24,6 @@
...
@@ -23,13 +24,6 @@
android:name=
"android.app.lib_name"
android:name=
"android.app.lib_name"
android:value=
"YGOMobile"
/>
android:value=
"YGOMobile"
/>
</activity>
</activity>
<receiver
android:name=
"cn.garymb.ygomobile.GameReceiver"
android:process=
":gamehelper"
>
<intent-filter>
<action
android:name=
"cn.garymb.ygomobile.game.start"
/>
<action
android:name=
"cn.garymb.ygomobile.game.stop"
/>
</intent-filter>
</receiver>
</application>
</application>
</manifest>
</manifest>
libcore/src/main/java/cn/garymb/ygomobile/GameReceiver.java
deleted
100644 → 0
View file @
e35f4fa0
package
cn.garymb.ygomobile
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
static
cn
.
garymb
.
ygomobile
.
core
.
IrrlichtBridge
.
ACTION_START
;
import
static
cn
.
garymb
.
ygomobile
.
core
.
IrrlichtBridge
.
ACTION_STOP
;
public
class
GameReceiver
extends
BroadcastReceiver
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
String
action
=
intent
.
getAction
();
if
(
ACTION_START
.
equals
(
action
))
{
//
IrrlichtBridge
.
gPid
=
intent
.
getIntExtra
(
IrrlichtBridge
.
EXTRA_PID
,
0
);
// Log.w("ygo", "pid=" + IrrlichtBridge.gPid);
}
else
if
(
ACTION_STOP
.
equals
(
action
))
{
int
pid
=
intent
.
getIntExtra
(
IrrlichtBridge
.
EXTRA_PID
,
0
);
if
(
pid
==
0
&&
IrrlichtBridge
.
gPid
!=
0
)
{
pid
=
IrrlichtBridge
.
gPid
;
// Log.w("ygo", "will kill last pid=" + pid);
}
if
(
pid
==
0
)
{
pid
=
android
.
os
.
Process
.
myPid
();
// Log.w("ygo", "will kill now pid=" + pid);
}
try
{
// Log.w("ygo", "kill pid=" + pid);
android
.
os
.
Process
.
killProcess
(
pid
);
}
catch
(
Exception
e
)
{
//ignore
}
}
}
}
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
View file @
cc4da97f
...
@@ -43,8 +43,6 @@ import cn.garymb.ygomobile.widget.overlay.OverlayOvalView;
...
@@ -43,8 +43,6 @@ import cn.garymb.ygomobile.widget.overlay.OverlayOvalView;
import
cn.garymb.ygomobile.widget.overlay.OverlayView
;
import
cn.garymb.ygomobile.widget.overlay.OverlayView
;
import
static
cn
.
garymb
.
ygomobile
.
core
.
IrrlichtBridge
.
ACTION_SHARE_FILE
;
import
static
cn
.
garymb
.
ygomobile
.
core
.
IrrlichtBridge
.
ACTION_SHARE_FILE
;
import
static
cn
.
garymb
.
ygomobile
.
core
.
IrrlichtBridge
.
ACTION_START
;
import
static
cn
.
garymb
.
ygomobile
.
core
.
IrrlichtBridge
.
ACTION_STOP
;
/**
/**
* @author mabin
* @author mabin
...
@@ -131,9 +129,6 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -131,9 +129,6 @@ public class YGOMobileActivity extends NativeActivity implements
mPM
=
(
PowerManager
)
getSystemService
(
Context
.
POWER_SERVICE
);
mPM
=
(
PowerManager
)
getSystemService
(
Context
.
POWER_SERVICE
);
mNetController
=
new
NetworkController
(
getApplicationContext
());
mNetController
=
new
NetworkController
(
getApplicationContext
());
handleExternalCommand
(
getIntent
());
handleExternalCommand
(
getIntent
());
sendBroadcast
(
new
Intent
(
ACTION_START
)
.
putExtra
(
IrrlichtBridge
.
EXTRA_PID
,
android
.
os
.
Process
.
myPid
())
.
setPackage
(
getPackageName
()));
}
}
//电池管理
//电池管理
...
@@ -194,14 +189,6 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -194,14 +189,6 @@ public class YGOMobileActivity extends NativeActivity implements
super
.
onDestroy
();
super
.
onDestroy
();
}
}
@Override
public
void
finish
()
{
super
.
finish
();
sendBroadcast
(
new
Intent
(
ACTION_STOP
)
.
putExtra
(
IrrlichtBridge
.
EXTRA_PID
,
android
.
os
.
Process
.
myPid
())
.
setPackage
(
getPackageName
()));
}
private
void
handleExternalCommand
(
Intent
intent
)
{
private
void
handleExternalCommand
(
Intent
intent
)
{
YGOGameOptions
options
=
intent
YGOGameOptions
options
=
intent
.
getParcelableExtra
(
YGOGameOptions
.
YGO_GAME_OPTIONS_BUNDLE_KEY
);
.
getParcelableExtra
(
YGOGameOptions
.
YGO_GAME_OPTIONS_BUNDLE_KEY
);
...
@@ -291,7 +278,6 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -291,7 +278,6 @@ public class YGOMobileActivity extends NativeActivity implements
int
h
=
(
int
)
app
().
getScreenWidth
();
int
h
=
(
int
)
app
().
getScreenWidth
();
int
spX
=
(
int
)
((
w
-
size
[
0
])
/
2.0f
);
int
spX
=
(
int
)
((
w
-
size
[
0
])
/
2.0f
);
int
spY
=
(
int
)
((
h
-
size
[
1
])
/
2.0f
);
int
spY
=
(
int
)
((
h
-
size
[
1
])
/
2.0f
);
// Log.i("ygo", "Android command 1:posX=" + spX + ",posY=" + spY);
boolean
update
=
false
;
boolean
update
=
false
;
synchronized
(
this
)
{
synchronized
(
this
)
{
if
(
spX
!=
mPositionX
||
spY
!=
mPositionY
)
{
if
(
spX
!=
mPositionX
||
spY
!=
mPositionY
)
{
...
@@ -301,7 +287,6 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -301,7 +287,6 @@ public class YGOMobileActivity extends NativeActivity implements
}
}
}
}
if
(
update
)
{
if
(
update
)
{
// Log.i("ygo", "Android command setInputFix2:posX=" + spX + ",posY=" + spY);
IrrlichtBridge
.
setInputFix
(
mPositionX
,
mPositionY
);
IrrlichtBridge
.
setInputFix
(
mPositionX
,
mPositionY
);
}
}
}
}
...
@@ -527,15 +512,15 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -527,15 +512,15 @@ public class YGOMobileActivity extends NativeActivity implements
}
}
@Override
@Override
public
void
shareFile
(
final
String
t
itle
,
final
String
ext
)
{
public
void
shareFile
(
final
String
t
ype
,
final
String
name
)
{
//TODO 分享文件
//TODO 分享文件
runOnUiThread
(
new
Runnable
()
{
runOnUiThread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
Intent
intent
=
new
Intent
(
ACTION_SHARE_FILE
);
Intent
intent
=
new
Intent
(
ACTION_SHARE_FILE
);
intent
.
addCategory
(
Intent
.
CATEGORY_DEFAULT
);
intent
.
addCategory
(
Intent
.
CATEGORY_DEFAULT
);
intent
.
putExtra
(
IrrlichtBridge
.
EXTRA_SHARE_TYPE
,
t
itl
e
);
intent
.
putExtra
(
IrrlichtBridge
.
EXTRA_SHARE_TYPE
,
t
yp
e
);
intent
.
putExtra
(
IrrlichtBridge
.
EXTRA_SHARE_FILE
,
ext
);
intent
.
putExtra
(
IrrlichtBridge
.
EXTRA_SHARE_FILE
,
name
);
intent
.
setPackage
(
getPackageName
());
intent
.
setPackage
(
getPackageName
());
try
{
try
{
startActivity
(
intent
);
startActivity
(
intent
);
...
@@ -553,20 +538,31 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -553,20 +538,31 @@ public class YGOMobileActivity extends NativeActivity implements
return
;
return
;
}
}
onGameExiting
=
true
;
onGameExiting
=
true
;
Log
.
e
(
"ygomobile"
,
"game exit"
);
Log
.
e
(
IrrlichtBridge
.
TAG
,
"game exit"
);
final
Intent
intent
=
new
Intent
(
"ygomobile.intent.action.GAME"
);
final
Intent
intent
=
new
Intent
(
IrrlichtBridge
.
ACTION_OPEN_GAME_HOME
);
intent
.
addCategory
(
Intent
.
CATEGORY_DEFAULT
);
intent
.
addCategory
(
Intent
.
CATEGORY_DEFAULT
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
);
intent
.
putExtra
(
"game_exit_time"
,
System
.
currentTimeMillis
());
// intent.putExtra(IrrlichtBridge.EXTRA_PID, Process.myPid());
// intent.putExtra(IrrlichtBridge.EXTRA_TASK_ID, getTaskId());
// intent.putExtra(IrrlichtBridge.EXTRA_GAME_EXIT_TIME, System.currentTimeMillis());
intent
.
setPackage
(
getPackageName
());
intent
.
setPackage
(
getPackageName
());
runOnUiThread
(
new
Runnable
()
{
runOnUiThread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
try
{
try
{
startActivity
(
intent
);
startActivity
(
intent
);
}
catch
(
Throwable
ignore
)
{}
Log
.
d
(
IrrlichtBridge
.
TAG
,
"open home ok"
);
finishAndRemoveTask
();
}
catch
(
Throwable
e
)
{
Log
.
w
(
IrrlichtBridge
.
TAG
,
"open home"
,
e
);
}
boolean
isRoot
=
isTaskRoot
();
Log
.
d
(
IrrlichtBridge
.
TAG
,
"isRoot="
+
isRoot
+
",kill:"
+
Process
.
myPid
());
if
(
isRoot
)
{
finishAndRemoveTask
();
}
else
{
finish
();
}
Process
.
killProcess
(
Process
.
myPid
());
Process
.
killProcess
(
Process
.
myPid
());
}
}
});
});
...
...
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
View file @
cc4da97f
...
@@ -17,6 +17,8 @@ import java.io.InputStream;
...
@@ -17,6 +17,8 @@ import java.io.InputStream;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
cn.garymb.ygodata.YGOGameOptions
;
import
static
cn
.
garymb
.
ygomobile
.
utils
.
ByteUtils
.
byte2int
;
import
static
cn
.
garymb
.
ygomobile
.
utils
.
ByteUtils
.
byte2int
;
import
static
cn
.
garymb
.
ygomobile
.
utils
.
ByteUtils
.
byte2uint
;
import
static
cn
.
garymb
.
ygomobile
.
utils
.
ByteUtils
.
byte2uint
;
...
@@ -24,8 +26,7 @@ import static cn.garymb.ygomobile.utils.ByteUtils.byte2uint;
...
@@ -24,8 +26,7 @@ import static cn.garymb.ygomobile.utils.ByteUtils.byte2uint;
* @author mabin
* @author mabin
*/
*/
public
final
class
IrrlichtBridge
{
public
final
class
IrrlichtBridge
{
public
static
final
String
ACTION_START
=
"cn.garymb.ygomobile.game.start"
;
public
static
final
String
ACTION_OPEN_GAME_HOME
=
"ygomobile.intent.action.GAME"
;
public
static
final
String
ACTION_STOP
=
"cn.garymb.ygomobile.game.stop"
;
/**
/**
* @see #EXTRA_SHARE_FILE
* @see #EXTRA_SHARE_FILE
* @see #EXTRA_SHARE_TYPE
* @see #EXTRA_SHARE_TYPE
...
@@ -37,8 +38,11 @@ public final class IrrlichtBridge {
...
@@ -37,8 +38,11 @@ public final class IrrlichtBridge {
public
static
final
String
EXTRA_PID
=
"extras.mypid"
;
public
static
final
String
EXTRA_PID
=
"extras.mypid"
;
public
static
final
String
EXTRA_ARGV
=
"extras.argv"
;
public
static
final
String
EXTRA_ARGV
=
"extras.argv"
;
public
static
final
String
EXTRA_ARGV_TIME_OUT
=
"extras.argv_timeout"
;
public
static
final
String
EXTRA_ARGV_TIME_OUT
=
"extras.argv_timeout"
;
private
static
final
boolean
DEBUG
=
false
;
public
static
final
String
EXTRA_GAME_EXIT_TIME
=
"game_exit_time"
;
private
static
final
String
TAG
=
IrrlichtBridge
.
class
.
getSimpleName
();
public
static
final
String
EXTRA_TASK_ID
=
"extras.taskid"
;
public
static
final
String
TAG
=
"ygo-java"
;
public
static
int
gPid
;
public
static
int
gPid
;
public
static
long
sNativeHandle
;
public
static
long
sNativeHandle
;
...
@@ -80,14 +84,16 @@ public final class IrrlichtBridge {
...
@@ -80,14 +84,16 @@ public final class IrrlichtBridge {
private
static
native
void
nativeSetInputFix
(
long
handle
,
int
x
,
int
y
);
private
static
native
void
nativeSetInputFix
(
long
handle
,
int
x
,
int
y
);
private
static
final
boolean
DEBUG
=
false
;
public
static
void
setArgs
(
Intent
intent
,
String
[]
args
)
{
public
static
void
setArgs
(
Intent
intent
,
String
[]
args
)
{
intent
.
putExtra
(
EXTRA_ARGV
,
args
);
intent
.
putExtra
(
EXTRA_ARGV
,
args
);
intent
.
putExtra
(
EXTRA_ARGV_TIME_OUT
,
(
System
.
currentTimeMillis
()
+
15
*
1000
));
intent
.
putExtra
(
EXTRA_ARGV_TIME_OUT
,
(
System
.
currentTimeMillis
()
+
15
*
1000
));
}
}
public
static
String
[]
getArgs
(
Intent
intent
)
{
public
static
String
[]
getArgs
(
Intent
intent
){
long
time
=
intent
.
getLongExtra
(
EXTRA_ARGV_TIME_OUT
,
0
);
long
time
=
intent
.
getLongExtra
(
EXTRA_ARGV_TIME_OUT
,
0
);
if
(
time
>
System
.
currentTimeMillis
())
{
if
(
time
>
System
.
currentTimeMillis
())
{
return
intent
.
getStringArrayExtra
(
EXTRA_ARGV
);
return
intent
.
getStringArrayExtra
(
EXTRA_ARGV
);
}
}
return
null
;
return
null
;
...
@@ -202,7 +208,7 @@ public final class IrrlichtBridge {
...
@@ -202,7 +208,7 @@ public final class IrrlichtBridge {
float
getScreenHeight
();
float
getScreenHeight
();
void
runWindbot
(
String
args
);
void
runWindbot
(
String
args
);
float
getXScale
();
float
getXScale
();
...
...
libygo/src/main/AndroidManifest.xml
View file @
cc4da97f
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<application>
<application>
<activity
<activity
android:name=
"cn.garymb.ygomobile.YGOMobileActivity"
android:name=
"cn.garymb.ygomobile.YGOMobileActivity"
...
@@ -25,13 +27,6 @@
...
@@ -25,13 +27,6 @@
android:name=
"android.notch_support"
android:name=
"android.notch_support"
android:value=
"true"
/>
android:value=
"true"
/>
</activity>
</activity>
<receiver
android:name=
"cn.garymb.ygomobile.GameReceiver"
android:process=
":game"
>
<intent-filter>
<action
android:name=
"cn.garymb.ygomobile.game.start"
/>
<action
android:name=
"cn.garymb.ygomobile.game.stop"
/>
</intent-filter>
</receiver>
</application>
</application>
</manifest>
</manifest>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment