1
- package com .kinda . crash ;
1
+ package com .developer . kinda ;
2
2
3
3
import android .annotation .SuppressLint ;
4
4
import android .app .Activity ;
15
15
import androidx .annotation .Nullable ;
16
16
import androidx .annotation .RestrictTo ;
17
17
import android .util .Log ;
18
-
19
18
import java .io .PrintWriter ;
20
19
import java .io .Serializable ;
21
20
import java .io .StringWriter ;
27
26
import java .util .Deque ;
28
27
import java .util .List ;
29
28
import java .util .Locale ;
29
+ import java .util .Objects ;
30
30
import java .util .zip .ZipEntry ;
31
31
import java .util .zip .ZipFile ;
32
-
33
- import com .kinda .crash .activity .DefaultErrorActivity ;
34
- import com .kinda .crash .config .CrashConfig ;
32
+ import com .developer .kinda .activity .DefaultErrorActivity ;
33
+ import com .developer .kinda .config .CrashConfig ;
35
34
36
35
public final class CrashActivity {
37
36
38
37
private final static String TAG = "CrashActivity" ;
39
38
40
39
//Extras passed to the error activity
41
- private static final String EXTRA_CONFIG = "com.kinda.crash .EXTRA_CONFIG" ;
42
- private static final String EXTRA_STACK_TRACE = "com.kinda.crash .EXTRA_STACK_TRACE" ;
43
- private static final String EXTRA_ACTIVITY_LOG = "com.kinda.crash .EXTRA_ACTIVITY_LOG" ;
40
+ private static final String EXTRA_CONFIG = "com.developer.kinda .EXTRA_CONFIG" ;
41
+ private static final String EXTRA_STACK_TRACE = "com.developer.kinda .EXTRA_STACK_TRACE" ;
42
+ private static final String EXTRA_ACTIVITY_LOG = "com.developer.kinda .EXTRA_ACTIVITY_LOG" ;
44
43
45
44
//General constants
46
- private static final String INTENT_ACTION_ERROR_ACTIVITY = "com.kinda.crash .ERROR" ;
47
- private static final String INTENT_ACTION_RESTART_ACTIVITY = "com.kinda.crash .RESTART" ;
48
- private static final String CRASH_HANDLER_PACKAGE_NAME = "com.kinda.crash ." ;
45
+ private static final String INTENT_ACTION_ERROR_ACTIVITY = "com.developer.kinda .ERROR" ;
46
+ private static final String INTENT_ACTION_RESTART_ACTIVITY = "com.developer.kinda .RESTART" ;
47
+ private static final String CRASH_HANDLER_PACKAGE_NAME = "com.developer.kinda ." ;
49
48
private static final String DEFAULT_HANDLER_PACKAGE_NAME = "com.android.internal.os" ;
50
49
private static final int MAX_STACK_TRACE_SIZE = 131071 ; //128 KB - 1
51
50
private static final int MAX_ACTIVITIES_IN_LOG = 50 ;
@@ -259,7 +258,7 @@ public static String getStackTraceFromIntent(@NonNull Intent intent) {
259
258
*/
260
259
public static CrashConfig getConfigFromIntent (@ NonNull Intent intent ) {
261
260
CrashConfig config = (CrashConfig ) intent .getSerializableExtra (CrashActivity .EXTRA_CONFIG );
262
- if (config .isLogErrorOnRestart ()) {
261
+ if (Objects . requireNonNull ( config ) .isLogErrorOnRestart ()) {
263
262
String stackTrace = getStackTraceFromIntent (intent );
264
263
if (stackTrace != null ) {
265
264
Log .e (TAG , "The previous app process crashed. This is the stack trace of the crash:\n " + getStackTraceFromIntent (intent ));
@@ -505,7 +504,7 @@ private static String capitalize(@Nullable String s) {
505
504
506
505
/**
507
506
* INTERNAL method used to guess which activity must be called from the error activity to restart the app.
508
- * It will first get activities from the AndroidManifest with intent filter <action android:name="com.kinda.crash .RESTART" />,
507
+ * It will first get activities from the AndroidManifest with intent filter <action android:name="com.developer.kinda .RESTART" />,
509
508
* if it cannot find them, then it will get the default launcher.
510
509
* If there is no default launcher, this returns null.
511
510
*
@@ -528,13 +527,12 @@ private static Class<? extends Activity> guessRestartActivityClass(@NonNull Cont
528
527
}
529
528
530
529
/**
531
- * INTERNAL method used to get the first activity with an intent-filter <action android:name="com.kinda.crash .RESTART" />,
530
+ * INTERNAL method used to get the first activity with an intent-filter <action android:name="com.developer.kinda .RESTART" />,
532
531
* If there is no activity with that intent filter, this returns null.
533
532
*
534
533
* @param context A valid context. Must not be null.
535
534
* @return A valid activity class, or null if no suitable one is found
536
535
*/
537
- @ SuppressWarnings ("unchecked" )
538
536
@ Nullable
539
537
private static Class <? extends Activity > getRestartActivityClassWithIntentFilter (@ NonNull Context context ) {
540
538
Intent searchedIntent = new Intent ().setAction (INTENT_ACTION_RESTART_ACTIVITY ).setPackage (context .getPackageName ());
@@ -579,7 +577,7 @@ private static Class<? extends Activity> getLauncherActivity(@NonNull Context co
579
577
580
578
/**
581
579
* INTERNAL method used to guess which error activity must be called when the app crashes.
582
- * It will first get activities from the AndroidManifest with intent filter <action android:name="com.kinda.crash .ERROR" />,
580
+ * It will first get activities from the AndroidManifest with intent filter <action android:name="com.developer.kinda .ERROR" />,
583
581
* if it cannot find them, then it will use the default error activity.
584
582
*
585
583
* @param context A valid context. Must not be null.
@@ -601,7 +599,7 @@ private static Class<? extends Activity> guessErrorActivityClass(@NonNull Contex
601
599
}
602
600
603
601
/**
604
- * INTERNAL method used to get the first activity with an intent-filter <action android:name="com.kinda.crash .ERROR" />,
602
+ * INTERNAL method used to get the first activity with an intent-filter <action android:name="com.developer.kinda .ERROR" />,
605
603
* If there is no activity with that intent filter, this returns null.
606
604
*
607
605
* @param context A valid context. Must not be null.
0 commit comments