Problem Adding Permission - Alternative?

fabio borges

Member
Licensed User
Longtime User
Hello.
I want enable/disable a program from App Drawer and i am trying add using addpermission but cannot and dont know why. I am checking in App Config -> App Details.

The error:
java.lang.SecurityException: Permission Denial: attempt to change component state from pid=21672, uid=10105, package uid=10133

AddPermission(android.permission.CHANGE_COMPONENT_ENABLED_STATE)

Thanks
 

fabio borges

Member
Licensed User
Longtime User
Hum...

B4X:
Compiling code.                         0.01
Compiling layouts code.                 0.00
Generating R file.                      0.80
Compiling generated Java code.          0.47
Convert byte code - optimized dex.      0.27
Packaging files.                        0.86
Copying libraries resources             0.01
   Found 2 resource files.
Signing package file (debug key).       0.33
ZipAlign file.                          0.02
Installing file to device.              4.47
   Device serial: XXXXXXX
Completed successfully.

No warning...
If this is a System Only permission have a solution to execute?
B4X:
Obj6.Target = Obj6.RunMethod("getPackageManager")
Obj6.Target = Obj6.RunMethod4("setApplicationEnabledSetting", args2, Types2)
 
Upvote 0

fabio borges

Member
Licensed User
Longtime User
I want make a List with all Installed App, if i choice one i will can select to enable/disable the app from app drawer.

The Manifest:
B4X:
<?xml version="1.0" encoding="utf-8"?>
<manifest
   xmlns:android="http://schemas.android.com/apk/res/android"
   package="b4a.example"
   android:versionCode="1"
   android:versionName=""
   android:installLocation="internalOnly">
   
   <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
   <supports-screens android:largeScreens="true" 
       android:normalScreens="true" 
       android:smallScreens="true" 
       android:anyDensity="true"/>
   <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"/>
   <application
      android:icon="@drawable/icon"
      android:label="B4A Example">
      <activity
         android:windowSoftInputMode="stateHidden"
         android:launchMode="singleTop"
         android:name=".main"
         android:label="B4A Example"
         android:screenOrientation="unspecified">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
         
      </activity>
   </application>
</manifest>

In market have a program similiar, but i forgot the name.... Sh..t
 
Upvote 0

fabio borges

Member
Licensed User
Longtime User
Erel, some solution or idea?
I try add all permissions but SecurityException Persist...

B4X:
AddPermission(android.permission.ACCESS_CHECKIN_PROPERTIES)
AddPermission(android.permission.ACCESS_COARSE_LOCATION)
AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission(android.permission.ACCESS_LOCATION_EXTRA_COMMANDS)
AddPermission(android.permission.ACCESS_MOCK_LOCATION)
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.ACCESS_SURFACE_FLINGER)
AddPermission(android.permission.ACCESS_WIFI_STATE)
AddPermission(android.permission.ACCOUNT_MANAGER)
AddPermission(android.permission.ADD_VOICEMAIL)
AddPermission(android.permission.AUTHENTICATE_ACCOUNTS)
AddPermission(android.permission.BATTERY_STATS)
AddPermission(android.permission.BIND_ACCESSIBILITY_SERVICE)
AddPermission(android.permission.BIND_APPWIDGET)
AddPermission(android.permission.BIND_DEVICE_ADMIN)
AddPermission(android.permission.BIND_INPUT_METHOD)
AddPermission(android.permission.BIND_REMOTEVIEWS)
AddPermission(android.permission.BIND_TEXT_SERVICE)
AddPermission(android.permission.BIND_VPN_SERVICE)
AddPermission(android.permission.BIND_WALLPAPER)
AddPermission(android.permission.BLUETOOTH)
AddPermission(android.permission.BLUETOOTH_ADMIN)
AddPermission(android.permission.BRICK)
AddPermission(android.permission.BROADCAST_PACKAGE_REMOVED)
AddPermission(android.permission.BROADCAST_SMS)
AddPermission(android.permission.BROADCAST_STICKY)
AddPermission(android.permission.BROADCAST_WAP_PUSH)
AddPermission(android.permission.CALL_PHONE)
AddPermission(android.permission.CALL_PRIVILEGED)
AddPermission(android.permission.CAMERA)
AddPermission(android.permission.CHANGE_COMPONENT_ENABLED_STATE)
AddPermission(android.permission.CHANGE_CONFIGURATION)
AddPermission(android.permission.CHANGE_NETWORK_STATE)
AddPermission(android.permission.CHANGE_WIFI_MULTICAST_STATE)
AddPermission(android.permission.CHANGE_WIFI_STATE)
AddPermission(android.permission.CLEAR_APP_CACHE)
AddPermission(android.permission.CLEAR_APP_USER_DATA)
AddPermission(android.permission.CONTROL_LOCATION_UPDATES)
AddPermission(android.permission.DELETE_CACHE_FILES)
AddPermission(android.permission.DELETE_PACKAGES)
AddPermission(android.permission.DEVICE_POWER)
AddPermission(android.permission.DIAGNOSTIC)
AddPermission(android.permission.DISABLE_KEYGUARD)
AddPermission(android.permission.DUMP)
AddPermission(android.permission.EXPAND_STATUS_BAR)
AddPermission(android.permission.FACTORY_TEST)
AddPermission(android.permission.FLASHLIGHT)
AddPermission(android.permission.FORCE_BACK)
AddPermission(android.permission.GET_ACCOUNTS)
AddPermission(android.permission.GET_PACKAGE_SIZE)
AddPermission(android.permission.GET_TASKS)
AddPermission(android.permission.GLOBAL_SEARCH)
AddPermission(android.permission.HARDWARE_TEST)
AddPermission(android.permission.INJECT_EVENTS)
AddPermission(android.permission.INSTALL_LOCATION_PROVIDER)
AddPermission(android.permission.INSTALL_PACKAGES)
AddPermission(android.permission.INTERNAL_SYSTEM_WINDOW)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.KILL_BACKGROUND_PROCESSES)
AddPermission(android.permission.MANAGE_ACCOUNTS)
AddPermission(android.permission.MANAGE_APP_TOKENS)
AddPermission(android.permission.MASTER_CLEAR)
AddPermission(android.permission.MODIFY_AUDIO_SETTINGS)
AddPermission(android.permission.MODIFY_PHONE_STATE)
AddPermission(android.permission.MOUNT_FORMAT_FILESYSTEMS)
AddPermission(android.permission.MOUNT_UNMOUNT_FILESYSTEMS)
AddPermission(android.permission.NFC)
AddPermission(android.permission.PERSISTENT_ACTIVITY)
AddPermission(android.permission.PROCESS_OUTGOING_CALLS)
AddPermission(android.permission.READ_CALENDAR)
AddPermission(android.permission.READ_CALL_LOG)
AddPermission(android.permission.READ_CONTACTS)
AddPermission(android.permission.READ_EXTERNAL_STORAGE)
AddPermission(android.permission.READ_FRAME_BUFFER)
AddPermission(android.permission.READ_HISTORY_BOOKMARKS)
AddPermission(android.permission.READ_INPUT_STATE)
AddPermission(android.permission.READ_LOGS)
AddPermission(android.permission.READ_PHONE_STATE)
AddPermission(android.permission.READ_PROFILE)
AddPermission(android.permission.READ_SMS)
AddPermission(android.permission.READ_SOCIAL_STREAM)
AddPermission(android.permission.READ_SYNC_SETTINGS)
AddPermission(android.permission.READ_SYNC_STATS)
AddPermission(android.permission.READ_USER_DICTIONARY)
AddPermission(android.permission.REBOOT)
AddPermission(android.permission.RECEIVE_BOOT_COMPLETED)
AddPermission(android.permission.RECEIVE_MMS)
AddPermission(android.permission.RECEIVE_SMS)
AddPermission(android.permission.RECEIVE_WAP_PUSH)
AddPermission(android.permission.RECORD_AUDIO)
AddPermission(android.permission.REORDER_TASKS)
AddPermission(android.permission.RESTART_PACKAGES)
AddPermission(android.permission.SEND_SMS)
AddPermission(android.permission.SET_ACTIVITY_WATCHER)
AddPermission(android.permission.SET_ALARM)
AddPermission(android.permission.SET_ALWAYS_FINISH)
AddPermission(android.permission.SET_ANIMATION_SCALE)
AddPermission(android.permission.SET_DEBUG_APP)
AddPermission(android.permission.SET_ORIENTATION)
AddPermission(android.permission.SET_POINTER_SPEED)
AddPermission(android.permission.SET_PREFERRED_APPLICATIONS)
AddPermission(android.permission.SET_PROCESS_LIMIT)
AddPermission(android.permission.SET_TIME)
AddPermission(android.permission.SET_TIME_ZONE)
AddPermission(android.permission.SET_WALLPAPER)
AddPermission(android.permission.SET_WALLPAPER_HINTS)
AddPermission(android.permission.SIGNAL_PERSISTENT_PROCESSES)
AddPermission(android.permission.STATUS_BAR)
AddPermission(android.permission.SUBSCRIBED_FEEDS_READ)
AddPermission(android.permission.SUBSCRIBED_FEEDS_WRITE)
AddPermission(android.permission.SYSTEM_ALERT_WINDOW)
AddPermission(android.permission.UPDATE_DEVICE_STATS)
AddPermission(android.permission.USE_CREDENTIALS)
AddPermission(android.permission.USE_SIP)
AddPermission(android.permission.VIBRATE)
AddPermission(android.permission.WAKE_LOCK)
AddPermission(android.permission.WRITE_APN_SETTINGS)
AddPermission(android.permission.WRITE_CALENDAR)
AddPermission(android.permission.WRITE_CALL_LOG)
AddPermission(android.permission.WRITE_CONTACTS)
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE   )
AddPermission(android.permission.WRITE_GSERVICES   )
AddPermission(android.permission.WRITE_HISTORY_BOOKMARKS)
AddPermission(android.permission.WRITE_PROFILE)
AddPermission(android.permission.WRITE_SECURE_SETTINGS)
AddPermission(android.permission.WRITE_SETTINGS)
AddPermission(android.permission.WRITE_SMS)
AddPermission(android.permission.WRITE_SOCIAL_STREAM)
AddPermission(android.permission.WRITE_SYNC_SETTINGS)
AddPermission(android.permission.WRITE_USER_DICTIONARY)
 
Upvote 0

fabio borges

Member
Licensed User
Longtime User
Hello...
Hummm.. Right...
A program similar is "App Quarantine", but need SuperUser to get permission... Can i use a "addPermission" android function by "reflector" to give more permission?

B4X:
addPermission(PermissionInfo info)
Add a new dynamic permission to the system.

Or maybe can i use "command line" ?

Have a possibility to get this permission by "standard" mode?
Thanks
 
Upvote 0

fabio borges

Member
Licensed User
Longtime User
Hum... Look, i installed the SuperUser App to get permission in "App Quarantine" but if i execute my program the problem persist, SecurityException and no request access permission...

Look:
B4X:
Sub Process_Globals
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Dim btnSetar As Button
   btnSetar.Initialize("btnSetar")
   btnSetar.Text = "Setar"
   
   Activity.AddView(btnSetar,35%x,45%y,120dip,50dip)
   
End Sub

Sub btnSetar_Click

Dim args(1),args2(3), pack() As Object
Dim Obj1, Obj2, Obj3, Obj4, Obj5, Obj6 As Reflector
Dim size, i, flags, count As Int
Dim Types(1),Types2(3), msg, name As String
Obj1.Target = Obj1.GetContext
Obj1.Target = Obj1.RunMethod("getPackageManager") ' PackageManager
Obj2.Target = Obj1.RunMethod2("getInstalledPackages", 0, "java.lang.int") ' List<PackageInfo>
size = Obj2.RunMethod("size")
For i = 0 To size -1
    Obj3.Target = Obj2.RunMethod2("get", i, "java.lang.int") ' PackageInfo
    name = "PackName: "&Obj3.GetField("packageName")
    Obj4.Target = Obj3.GetField("applicationInfo") ' ApplicationInfo        
    flags = Obj4.GetField("flags")    
    args(0) = Obj4.Target
    Types(0) = "android.content.pm.ApplicationInfo" 
    name = name & " - Label: " &Obj1.RunMethod4("getApplicationLabel", args, Types)
   msg = msg & name & " : " & flags & CRLF
    count = count + 1   
   If Obj1.RunMethod4("getApplicationLabel", args, Types) == "Reflector Demo" Then
      args2(0) = Obj3.GetField("packageName")
      args2(1) = 2
      args2(2) = 0
      Types2(0) = "java.lang.String"
      Types2(1) = "java.lang.int"
      Types2(2) = "java.lang.int"
      Obj6.Target = Obj6.GetContext
      Obj6.Target = Obj6.RunMethod("getPackageManager")
      Obj6.Target = Obj6.RunMethod4("setApplicationEnabledSetting", args2, Types2)
      ToastMessageShow("ENNNTROU IF",True)
   End If
    
Next    
Msgbox(msg,count) 

End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…