Article 2: Android Supersu blocking permission request notification SuReceiver broadcast, supersusureceiver

Source: Internet
Author: User

Article 2: Android Supersu blocking permission request notification SuReceiver broadcast, supersusureceiver

We want to customize Supersu to filter out our own applications without displaying permission reminders. Let's take a look at this su call system to send broadcasts. Then our supersu.apk will receive a pop-up broadcast. We can intercept and filter them here.



Public class SuReceiver extends BroadcastReceiver {@ Override public void onReceive (final Context context, Intent intent) {if (intent = null) return; String command = intent. getStringExtra ("command"); if (command = null) return; int uid = intent. getIntExtra ("uid",-1); if (uid =-1) return; int desistmid = intent. getIntExtra ("desired_uid",-1); if (desiredid =-1) return; String action = int Ent. getStringExtra ("action"); if (action = null) return; String fromName = intent. getStringExtra ("from_name"); String desiredName = intent. getStringExtra ("desired_name"); final LogEntry le = new LogEntry (); le. uid = uid; le. command = command; le. action = action; le. desistmid = desistmid; le. desiredName = desiredName; le. username = fromName; le. date = (int) (System. currentTimeMillis ()/1000); le. GetPackageInfo (context); // You can intercept the output of super logs and filter out UidPolicy u = SuperuserDatabaseHelper, an application that does not want to print logs. addLog (context, le); String toast; if (UidPolicy. ALLOW. equals (action) {// The Super application authorization will pop up here. We can judge it here so that it does not display the Toast prompt toast = context. getString (R. string. superuser_granted, le. getName ();} else {toast = context. getString (R. string. superuser_denied, le. getName (); // reject user requests} if (u! = Null &&! U. notification) return; switch (Settings. getNotificationType (context) {// whether a pop-up window is displayed. Case Settings. icationication_type_notification: NotificationCompat. builder builder = new NotificationCompat. builder (context); builder. setTicker (toast ). setAutoCancel (true ). setContentIntent (PendingIntent. getActivity (context, 0, new Intent (), 0 )). setContentTitle (context. getString (R. string. superuser )). setContentText (toast ). setSmallIcon (R. drawable. ic_stat_notification); icationicationmanager nm = (icationicationmanager) context. getSystemService (Context. NOTIFICATION_SERVICE); nm. Y (ication_id _id, builder. getNotification (); break; case Settings. icationication_type_toast: Toast. makeText (context, toast, Toast. LENGTH_SHORT ). show (); break ;}} private static final int icationication_id = 4545 ;}
Next article,


The next article will introduce how to block the confirmation notification of authorization Acitivty

Through su. c

# Include "su. h"


/* Intent actions */
# Define ACTION_REQUEST "start", "-n", REQUESTOR "/" REQUESTOR_PREFIX ". RequestActivity"
# Define ACTION_NOTIFY "start", "-n", REQUESTOR "/" REQUESTOR_PREFIX ". policyactivity"
# Define ACTION_RESULT "broadcast", "-n", REQUESTOR "/" REQUESTOR_PREFIX ". SuReceiver"


# Define AM_PATH "/system/bin/app_process", "/system/bin", "com. android. commands. am. Am"

I found that su started the Acitivty of a permission request through the shell command. This is the permission reminder interface we see.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.