-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Verify package name before initializing ACRA and ErrorActivity #2649
base: hotfix/3.6.2
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,11 +126,13 @@ public static void reportError( | |
|
||
private static void startErrorActivity( | ||
final Context context, final ErrorInfo errorInfo, final List<Throwable> el) { | ||
final Intent intent = new Intent(context, ErrorActivity.class); | ||
intent.putExtra(ERROR_INFO, errorInfo); | ||
intent.putExtra(ERROR_LIST, elToSl(el)); | ||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
context.startActivity(intent); | ||
if (context.getPackageName().equals(BuildConfig.APPLICATION_ID)) { | ||
final Intent intent = new Intent(context, ErrorActivity.class); | ||
intent.putExtra(ERROR_INFO, errorInfo); | ||
intent.putExtra(ERROR_LIST, elToSl(el)); | ||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
context.startActivity(intent); | ||
} | ||
} | ||
|
||
public static void reportError( | ||
|
@@ -149,6 +151,7 @@ public static void reportError( | |
final String[] el = new String[] {report.getString(ReportField.STACK_TRACE)}; | ||
|
||
final Intent intent = new Intent(context, ErrorActivity.class); | ||
intent.setPackage("context.getPackageName()"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you forget to delete the quotes? |
||
intent.putExtra(ERROR_INFO, errorInfo); | ||
intent.putExtra(ERROR_LIST, el); | ||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
|
@@ -174,74 +177,77 @@ private static String[] elToSl(final List<Throwable> stackTraces) { | |
@Override | ||
public void onCreate(final Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_error); | ||
final Toolbar toolbar = findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
|
||
final Intent intent = getIntent(); | ||
|
||
final ActionBar actionBar = getSupportActionBar(); | ||
if (actionBar != null) { | ||
actionBar.setDisplayHomeAsUpEnabled(true); | ||
actionBar.setTitle(R.string.error_report_title); | ||
actionBar.setDisplayShowTitleEnabled(true); | ||
} | ||
|
||
final Button reportEmailButton = findViewById(R.id.errorReportEmailButton); | ||
final Button reportTelegramButton = findViewById(R.id.errorReportTelegramButton); | ||
final Button copyButton = findViewById(R.id.errorReportCopyButton); | ||
final Button reportGithubButton = findViewById(R.id.errorReportGitHubButton); | ||
|
||
userCommentBox = findViewById(R.id.errorCommentBox); | ||
final TextView errorView = findViewById(R.id.errorView); | ||
final TextView errorMessageView = findViewById(R.id.errorMessageView); | ||
|
||
returnActivity = MainActivity.class; | ||
errorInfo = intent.getParcelableExtra(ERROR_INFO); | ||
errorList = intent.getStringArrayExtra(ERROR_LIST); | ||
|
||
// important add guru meditation | ||
addGuruMeditation(); | ||
currentTimeStamp = getCurrentTimeStamp(); | ||
|
||
reportEmailButton.setOnClickListener((View v) -> sendReportEmail()); | ||
|
||
reportTelegramButton.setOnClickListener( | ||
(View v) -> { | ||
FileUtils.copyToClipboard(this, buildMarkdown()); | ||
Toast.makeText(this, R.string.crash_report_copied, Toast.LENGTH_SHORT).show(); | ||
Utils.openTelegramURL(this); | ||
}); | ||
|
||
copyButton.setOnClickListener( | ||
(View v) -> { | ||
FileUtils.copyToClipboard(this, buildMarkdown()); | ||
Toast.makeText(this, R.string.crash_report_copied, Toast.LENGTH_SHORT).show(); | ||
}); | ||
|
||
reportGithubButton.setOnClickListener( | ||
(View v) -> { | ||
FileUtils.copyToClipboard(this, buildMarkdown()); | ||
Toast.makeText(this, R.string.crash_report_copied, Toast.LENGTH_SHORT).show(); | ||
Utils.openURL(ERROR_GITHUB_ISSUE_URL, this); | ||
}); | ||
|
||
// normal bugreport | ||
buildInfo(errorInfo); | ||
if (errorInfo.message != 0) { | ||
errorMessageView.setText(errorInfo.message); | ||
if (ErrorInfo.comparePackageInfo(intent.getPackage()) != 0) { | ||
finish(); | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No else needed AFAIK. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At least a |
||
errorMessageView.setVisibility(View.GONE); | ||
findViewById(R.id.messageWhatHappenedView).setVisibility(View.GONE); | ||
} | ||
setContentView(R.layout.activity_error); | ||
final Toolbar toolbar = findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
|
||
final ActionBar actionBar = getSupportActionBar(); | ||
if (actionBar != null) { | ||
actionBar.setDisplayHomeAsUpEnabled(true); | ||
actionBar.setTitle(R.string.error_report_title); | ||
actionBar.setDisplayShowTitleEnabled(true); | ||
} | ||
|
||
final Button reportEmailButton = findViewById(R.id.errorReportEmailButton); | ||
final Button reportTelegramButton = findViewById(R.id.errorReportTelegramButton); | ||
final Button copyButton = findViewById(R.id.errorReportCopyButton); | ||
final Button reportGithubButton = findViewById(R.id.errorReportGitHubButton); | ||
|
||
userCommentBox = findViewById(R.id.errorCommentBox); | ||
final TextView errorView = findViewById(R.id.errorView); | ||
final TextView errorMessageView = findViewById(R.id.errorMessageView); | ||
|
||
returnActivity = MainActivity.class; | ||
errorInfo = intent.getParcelableExtra(ERROR_INFO); | ||
errorList = intent.getStringArrayExtra(ERROR_LIST); | ||
|
||
// important add guru meditation | ||
addGuruMeditation(); | ||
currentTimeStamp = getCurrentTimeStamp(); | ||
|
||
reportEmailButton.setOnClickListener((View v) -> sendReportEmail()); | ||
|
||
reportTelegramButton.setOnClickListener( | ||
(View v) -> { | ||
FileUtils.copyToClipboard(this, buildMarkdown()); | ||
Toast.makeText(this, R.string.crash_report_copied, Toast.LENGTH_SHORT).show(); | ||
Utils.openTelegramURL(this); | ||
}); | ||
|
||
copyButton.setOnClickListener( | ||
(View v) -> { | ||
FileUtils.copyToClipboard(this, buildMarkdown()); | ||
Toast.makeText(this, R.string.crash_report_copied, Toast.LENGTH_SHORT).show(); | ||
}); | ||
|
||
reportGithubButton.setOnClickListener( | ||
(View v) -> { | ||
FileUtils.copyToClipboard(this, buildMarkdown()); | ||
Toast.makeText(this, R.string.crash_report_copied, Toast.LENGTH_SHORT).show(); | ||
Utils.openURL(ERROR_GITHUB_ISSUE_URL, this); | ||
}); | ||
|
||
// normal bugreport | ||
buildInfo(errorInfo); | ||
if (errorInfo.message != 0) { | ||
errorMessageView.setText(errorInfo.message); | ||
} else { | ||
errorMessageView.setVisibility(View.GONE); | ||
findViewById(R.id.messageWhatHappenedView).setVisibility(View.GONE); | ||
} | ||
|
||
errorView.setText(formErrorText(errorList)); | ||
errorView.setText(formErrorText(errorList)); | ||
|
||
// print stack trace once again for debugging: | ||
for (final String e : errorList) { | ||
Log.e(TAG, e); | ||
// print stack trace once again for debugging: | ||
for (final String e : errorList) { | ||
Log.e(TAG, e); | ||
} | ||
initStatusBarResources(findViewById(R.id.parent_view)); | ||
} | ||
initStatusBarResources(findViewById(R.id.parent_view)); | ||
} | ||
|
||
@Override | ||
|
@@ -496,5 +502,9 @@ public void writeToParcel(final Parcel dest, final int flags) { | |
dest.writeString(this.request); | ||
dest.writeInt(this.message); | ||
} | ||
|
||
public static int comparePackageInfo(String packageName) { | ||
return packageName.indexOf("com.amaze.filemanager"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this going to work on debug package? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "com.amaze.filemanager.debug".indexOf("com.amaze.filemanager") == 0 |
||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't build config generated on compile?