Skip to content

Commit

Permalink
Remove unnecessary logic to transform broadcast receiver class names
Browse files Browse the repository at this point in the history
It does not appear to be necessary any more. The receiver name can be used
diretly.

Related to #7581

PiperOrigin-RevId: 522204982
  • Loading branch information
hoisie authored and copybara-github committed Apr 6, 2023
1 parent adb2d07 commit 40c16ea
Showing 1 changed file with 1 addition and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -700,22 +700,7 @@ static void registerBroadcastReceivers(Application application, AndroidManifest
for (String action : receiver.getActions()) {
filter.addAction(action);
}
String receiverClassName = replaceLastDotWith$IfInnerStaticClass(receiver.getName());
application.registerReceiver((BroadcastReceiver) newInstanceOf(receiverClassName), filter);
application.registerReceiver((BroadcastReceiver) newInstanceOf(receiver.getName()), filter);
}
}

private static String replaceLastDotWith$IfInnerStaticClass(String receiverClassName) {
String[] splits = receiverClassName.split("\\.", 0);
String staticInnerClassRegex = "[A-Z][a-zA-Z]*";
if (splits.length > 1
&& splits[splits.length - 1].matches(staticInnerClassRegex)
&& splits[splits.length - 2].matches(staticInnerClassRegex)) {
int lastDotIndex = receiverClassName.lastIndexOf(".");
StringBuilder buffer = new StringBuilder(receiverClassName);
buffer.setCharAt(lastDotIndex, '$');
return buffer.toString();
}
return receiverClassName;
}
}

0 comments on commit 40c16ea

Please sign in to comment.