1+ /*
2+ ** Copyright 2010, Adam Shanks (@ChainsDD)
3+ ** Copyright 2008, Zinx Verituse (@zinxv)
4+ **
5+ ** Licensed under the Apache License, Version 2.0 (the "License");
6+ ** you may not use this file except in compliance with the License.
7+ ** You may obtain a copy of the License at
8+ **
9+ ** http://www.apache.org/licenses/LICENSE-2.0
10+ **
11+ ** Unless required by applicable law or agreed to in writing, software
12+ ** distributed under the License is distributed on an "AS IS" BASIS,
13+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ ** See the License for the specific language governing permissions and
15+ ** limitations under the License.
16+ */
17+
118#include < unistd.h>
219#include < android_runtime/ActivityManager.h>
320#include < utils/IBinder.h>
@@ -23,7 +40,7 @@ static const int VAL_INTEGER = 1;
2340
2441static const int START_SUCCESS = 0 ;
2542
26- int send_intent (struct su_initiator *from, struct su_request *to, const char *socket_path, int type)
43+ int send_intent (struct su_initiator *from, struct su_request *to, const char *socket_path, int allow, int type)
2744{
2845 char sdk_version_prop[PROPERTY_VALUE_MAX] = " 0" ;
2946 property_get (" ro.build.version.sdk" , sdk_version_prop, " 0" );
@@ -43,7 +60,7 @@ int send_intent(struct su_initiator *from, struct su_request *to, const char *so
4360 if (type == 0 ) {
4461 data.writeString16 (String16 (" com.noshufou.android.su.REQUEST" )); /* action */
4562 } else {
46- data.writeString16 (String16 (" com.noshufou.android.su.NOTIFICATION " )); /* action */
63+ data.writeString16 (String16 (" com.noshufou.android.su.RESULT " )); /* action */
4764 }
4865 data.writeInt32 (NULL_TYPE_ID); /* Uri - data */
4966 data.writeString16 (NULL , 0 ); /* type */
@@ -63,7 +80,7 @@ int send_intent(struct su_initiator *from, struct su_request *to, const char *so
6380 int oldPos = data.dataPosition ();
6481 data.writeInt32 (0x4C444E42 ); // 'B' 'N' 'D' 'L'
6582 { /* writeMapInternal */
66- data.writeInt32 (4 ); /* writeMapInternal - size */
83+ data.writeInt32 (6 ); /* writeMapInternal - size */
6784
6885 data.writeInt32 (VAL_STRING);
6986 data.writeString16 (String16 (" caller_uid" ));
@@ -84,6 +101,16 @@ int send_intent(struct su_initiator *from, struct su_request *to, const char *so
84101 data.writeString16 (String16 (" socket" ));
85102 data.writeInt32 (VAL_STRING);
86103 data.writeString16 (String16 (socket_path));
104+
105+ data.writeInt32 (VAL_STRING);
106+ data.writeString16 (String16 (" allow" ));
107+ data.writeInt32 (VAL_INTEGER);
108+ data.writeInt32 (allow);
109+
110+ data.writeInt32 (VAL_STRING);
111+ data.writeString16 (String16 (" version_code" ));
112+ data.writeInt32 (VAL_INTEGER);
113+ data.writeInt32 (VERSION_CODE);
87114 }
88115 int newPos = data.dataPosition ();
89116 data.setDataPosition (oldPos - 4 );
0 commit comments