Skip to content

Commit 3db0848

Browse files
committed
fix: safemode
1 parent b1b9758 commit 3db0848

15 files changed

Lines changed: 1044 additions & 34 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<uses-permission
2424
android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS"
2525
tools:ignore="ProtectedPermissions" />
26+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
2627
<uses-permission android:name="android.permission.WAKE_LOCK" />
2728
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
2829
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
@@ -66,6 +67,8 @@
6667
android:name="${applicationId}.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"
6768
tools:node="remove" />
6869

70+
<uses-permission android:name="hyperceiler.permission.APP_CRASH" />
71+
6972
<permission
7073
android:name="${applicationId}.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"
7174
tools:node="remove" />
@@ -76,7 +79,8 @@
7679
android:label="@string/app_name"
7780
android:requestLegacyExternalStorage="true"
7881
android:supportsRtl="true"
79-
android:theme="@style/AppTheme">
82+
android:theme="@style/AppTheme"
83+
android:allowNativeHeapPointerTagging="true">
8084

8185
<activity
8286
android:name=".ui.activity.HyperCeilerTabActivity"
@@ -91,11 +95,11 @@
9195
<activity
9296
android:name=".safe.CrashActivity"
9397
android:configChanges="keyboardHidden|orientation|screenSize"
94-
android:excludeFromRecents="true"
9598
android:exported="true"
9699
android:finishOnTaskLaunch="true"
97100
android:launchMode="singleTask"
98-
android:theme="@style/Theme.HyperCeiler.Translucent.NoActionBar">
101+
android:theme="@style/Theme.HyperCeiler.Translucent.NoActionBar"
102+
android:excludeFromRecents="true">
99103
<intent-filter>
100104
<action android:name="android.intent.action.Crash" />
101105
<category android:name="android.intent.category.CrashDailog" />
@@ -162,12 +166,22 @@
162166
<service
163167
android:name="com.sevtinge.hyperceiler.safe.CrashService"
164168
android:enabled="true"
165-
android:exported="true">
169+
android:exported="false">
166170
<intent-filter>
167171
<action android:name="com.sevtinge.hyperceiler.crash.Service" />
168172
</intent-filter>
169173
</service>
170174

175+
<receiver
176+
android:name=".receiver.CrashReceiver"
177+
android:enabled="true"
178+
android:exported="true"
179+
android:permission="hyperceiler.permission.APP_CRASH">
180+
<intent-filter>
181+
<action android:name="hyperceiler.intent.action.APP_CRASH" />
182+
</intent-filter>
183+
</receiver>
184+
171185
</application>
172186

173187
</manifest>
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
/*
2+
* This file is part of HyperCeiler.
3+
*
4+
* HyperCeiler is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Affero General Public License as
6+
* published by the Free Software Foundation, either version 3 of the
7+
* License.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Affero General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Affero General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*
17+
* Copyright (C) 2023-2024 HyperCeiler Contributions
18+
*/
19+
20+
package com.sevtinge.hyperceiler.data;
21+
22+
import android.app.ApplicationErrorReport.CrashInfo;
23+
import android.os.Parcel;
24+
import android.os.Parcelable;
25+
26+
import androidx.annotation.NonNull;
27+
28+
public class AppCrashInfo implements Parcelable {
29+
30+
/**
31+
* The name of the exception handler that is installed.
32+
* @hide
33+
*/
34+
public String exceptionHandlerClassName;
35+
36+
/**
37+
* Class name of the exception that caused the crash.
38+
*/
39+
public String exceptionClassName;
40+
41+
/**
42+
* Message stored in the exception.
43+
*/
44+
public String exceptionMessage;
45+
46+
/**
47+
* File which the exception was thrown from.
48+
*/
49+
public String throwFileName;
50+
51+
/**
52+
* Class which the exception was thrown from.
53+
*/
54+
public String throwClassName;
55+
56+
/**
57+
* Method which the exception was thrown from.
58+
*/
59+
public String throwMethodName;
60+
61+
/**
62+
* Line number the exception was thrown from.
63+
*/
64+
public int throwLineNumber;
65+
66+
/**
67+
* Stack trace.
68+
*/
69+
public String stackTrace;
70+
71+
/**
72+
* Crash tag for some context.
73+
* @hide
74+
*/
75+
public String crashTag;
76+
77+
public static final Creator<AppCrashInfo> CREATOR = new Creator<>() {
78+
@Override
79+
public AppCrashInfo createFromParcel(Parcel in) {
80+
return new AppCrashInfo(in);
81+
}
82+
83+
@Override
84+
public AppCrashInfo[] newArray(int size) {
85+
return new AppCrashInfo[size];
86+
}
87+
};
88+
89+
public AppCrashInfo() {}
90+
91+
public AppCrashInfo(CrashInfo info) {
92+
exceptionMessage = info.exceptionMessage;
93+
throwMethodName = info.throwMethodName;
94+
throwFileName = info.throwFileName;
95+
exceptionClassName = info.exceptionClassName;
96+
throwClassName = info.throwClassName;
97+
throwLineNumber = info.throwLineNumber;
98+
stackTrace = info.stackTrace;
99+
}
100+
101+
protected AppCrashInfo(Parcel in) {
102+
exceptionHandlerClassName = in.readString();
103+
exceptionClassName = in.readString();
104+
exceptionMessage = in.readString();
105+
throwFileName = in.readString();
106+
throwClassName = in.readString();
107+
throwMethodName = in.readString();
108+
throwLineNumber = in.readInt();
109+
stackTrace = in.readString();
110+
crashTag = in.readString();
111+
}
112+
113+
@Override
114+
public void writeToParcel(@NonNull Parcel dest, int flags) {
115+
dest.writeString(exceptionHandlerClassName);
116+
dest.writeString(exceptionClassName);
117+
dest.writeString(exceptionMessage);
118+
dest.writeString(throwFileName);
119+
dest.writeString(throwClassName);
120+
dest.writeString(throwMethodName);
121+
dest.writeInt(throwLineNumber);
122+
dest.writeString(stackTrace);
123+
dest.writeString(crashTag);
124+
}
125+
126+
@Override
127+
public int describeContents() {
128+
return 0;
129+
}
130+
131+
public String getExceptionHandlerClassName() {
132+
return exceptionHandlerClassName;
133+
}
134+
135+
public void setExceptionHandlerClassName(String exceptionHandlerClassName) {
136+
this.exceptionHandlerClassName = exceptionHandlerClassName;
137+
}
138+
139+
public String getExceptionClassName() {
140+
return exceptionClassName;
141+
}
142+
143+
public void setExceptionClassName(String exceptionClassName) {
144+
this.exceptionClassName = exceptionClassName;
145+
}
146+
147+
public String getExceptionMessage() {
148+
return exceptionMessage;
149+
}
150+
151+
public void setExceptionMessage(String exceptionMessage) {
152+
this.exceptionMessage = exceptionMessage;
153+
}
154+
155+
public String getThrowFileName() {
156+
return throwFileName;
157+
}
158+
159+
public void setThrowFileName(String throwFileName) {
160+
this.throwFileName = throwFileName;
161+
}
162+
163+
public String getThrowClassName() {
164+
return throwClassName;
165+
}
166+
167+
public void setThrowClassName(String throwClassName) {
168+
this.throwClassName = throwClassName;
169+
}
170+
171+
public String getThrowMethodName() {
172+
return throwMethodName;
173+
}
174+
175+
public void setThrowMethodName(String throwMethodName) {
176+
this.throwMethodName = throwMethodName;
177+
}
178+
179+
public int getThrowLineNumber() {
180+
return throwLineNumber;
181+
}
182+
183+
public void setThrowLineNumber(int throwLineNumber) {
184+
this.throwLineNumber = throwLineNumber;
185+
}
186+
187+
public String getStackTrace() {
188+
return stackTrace;
189+
}
190+
191+
public void setStackTrace(String stackTrace) {
192+
this.stackTrace = stackTrace;
193+
}
194+
195+
public String getCrashTag() {
196+
return crashTag;
197+
}
198+
199+
public void setCrashTag(String crashTag) {
200+
this.crashTag = crashTag;
201+
}
202+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* This file is part of HyperCeiler.
3+
*
4+
* HyperCeiler is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Affero General Public License as
6+
* published by the Free Software Foundation, either version 3 of the
7+
* License.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Affero General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Affero General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*
17+
* Copyright (C) 2023-2024 HyperCeiler Contributions
18+
*/
19+
20+
package com.sevtinge.hyperceiler.data;
21+
22+
import android.os.Parcel;
23+
import android.os.Parcelable;
24+
25+
import androidx.annotation.NonNull;
26+
27+
public class AppErrorsData implements Parcelable {
28+
29+
AppCrashInfo crashInfo;
30+
ProcessInfo processInfo;
31+
boolean handleAppCrashInActivity;
32+
33+
public static final Creator<AppErrorsData> CREATOR = new Creator<>() {
34+
@Override
35+
public AppErrorsData createFromParcel(Parcel in) {
36+
return new AppErrorsData(in);
37+
}
38+
39+
@Override
40+
public AppErrorsData[] newArray(int size) {
41+
return new AppErrorsData[size];
42+
}
43+
};
44+
45+
public AppErrorsData() {}
46+
47+
public AppErrorsData(AppCrashInfo crashInfo, ProcessInfo processInfo, boolean handleAppCrashInActivity) {
48+
this.crashInfo = crashInfo;
49+
this.processInfo = processInfo;
50+
this.handleAppCrashInActivity = handleAppCrashInActivity;
51+
}
52+
53+
protected AppErrorsData(Parcel in) {
54+
crashInfo = in.readParcelable(AppCrashInfo.class.getClassLoader());
55+
processInfo = in.readParcelable(ProcessInfo.class.getClassLoader());
56+
handleAppCrashInActivity = in.readByte() != 0;
57+
}
58+
59+
@Override
60+
public int describeContents() {
61+
return 0;
62+
}
63+
64+
@Override
65+
public void writeToParcel(@NonNull Parcel dest, int flags) {
66+
dest.writeParcelable(crashInfo, flags);
67+
dest.writeParcelable(processInfo, flags);
68+
dest.writeByte((byte) (handleAppCrashInActivity ? 1 : 0));
69+
}
70+
71+
public AppCrashInfo getCrashInfo() {
72+
return crashInfo;
73+
}
74+
75+
public void setCrashInfo(AppCrashInfo crashInfo) {
76+
this.crashInfo = crashInfo;
77+
}
78+
79+
public ProcessInfo getProcessInfo() {
80+
return processInfo;
81+
}
82+
83+
public void setProcessInfo(ProcessInfo appInfo) {
84+
this.processInfo = appInfo;
85+
}
86+
87+
public boolean isHandleAppCrashInActivity() {
88+
return handleAppCrashInActivity;
89+
}
90+
91+
public void setHandleAppCrashInActivity(boolean handleAppCrashInActivity) {
92+
this.handleAppCrashInActivity = handleAppCrashInActivity;
93+
}
94+
95+
public void clean() {
96+
setCrashInfo(null);
97+
setProcessInfo(null);
98+
}
99+
}

0 commit comments

Comments
 (0)