@ -15,21 +15,22 @@ import java.lang.reflect.Method;
//android.permission.WRITE_EXTERNAL_STORAGE
//android.permission.WRITE_EXTERNAL_STORAGE
public class PermsAskerActivity extends Activity {
public class PermsAskerActivity extends Activity {
private static final int PERMISSION_ WRITE_EXTERNAL_STORAGE = 0 ;
private static final int PERMISSION_ VPN = 0 ;
private Button button_request_write_ext_storage_perms ;
private Button button_request_write_ext_storage_perms ;
private TextView textview_retry ;
private TextView textview_retry ;
@Override
@Override
protected void onCreate ( Bundle savedInstanceState ) {
protected void onCreate ( Bundle savedInstanceState ) {
super . onCreate ( savedInstanceState ) ;
super . onCreate ( savedInstanceState ) ;
startMainActivity ( ) ;
/ *
//if less than Android 6, no runtime perms req system present
//if less than Android 6, no runtime perms req system present
if ( android . os . Build . VERSION . SDK_INT < 23 ) {
if ( android . os . Build . VERSION . SDK_INT < 23 ) {
startMainActivity ( ) ;
return ;
return ;
}
}
setContentView ( R . layout . activity_perms_asker ) ;
setContentView ( R . layout . activity_perms_asker ) ;
button_request_write_ext_storage_perms = ( Button ) findViewById ( R . id . button_request_write_ext_storage_perms ) ;
button_request_write_ext_storage_perms = ( Button ) findViewById ( R . id . button_request_write_ext_storage_perms ) ;
textview_retry = ( TextView ) findViewById ( R . id . textview_retry ) ;
textview_retry = ( TextView ) findViewById ( R . id . textview_retry ) ;
@ -41,6 +42,7 @@ public class PermsAskerActivity extends Activity {
}
}
} ) ;
} ) ;
request_write_ext_storage_perms ( ) ;
request_write_ext_storage_perms ( ) ;
* /
}
}
private void request_write_ext_storage_perms ( ) {
private void request_write_ext_storage_perms ( ) {
@ -63,7 +65,7 @@ public class PermsAskerActivity extends Activity {
Integer resultObj ;
Integer resultObj ;
try {
try {
resultObj = ( Integer ) methodCheckPermission . invoke (
resultObj = ( Integer ) methodCheckPermission . invoke (
this , Manifest . permission . WRITE_EXTERNAL_STORAG E) ;
this , Manifest . permission . BIND_VPN_SERVIC E) ;
} catch ( Throwable e ) {
} catch ( Throwable e ) {
throw new RuntimeException ( e ) ;
throw new RuntimeException ( e ) ;
}
}
@ -74,7 +76,7 @@ public class PermsAskerActivity extends Activity {
Boolean aBoolean ;
Boolean aBoolean ;
try {
try {
aBoolean = ( Boolean ) method_shouldShowRequestPermissionRationale . invoke ( this ,
aBoolean = ( Boolean ) method_shouldShowRequestPermissionRationale . invoke ( this ,
Manifest . permission . WRITE_EXTERNAL_STORAG E) ;
Manifest . permission . BIND_VPN_SERVIC E) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
throw new RuntimeException ( e ) ;
throw new RuntimeException ( e ) ;
}
}
@ -92,8 +94,8 @@ public class PermsAskerActivity extends Activity {
try {
try {
method_requestPermissions . invoke ( this ,
method_requestPermissions . invoke ( this ,
new String [ ] { Manifest . permission . WRITE_EXTERNAL_STORAG E} ,
new String [ ] { Manifest . permission . BIND_VPN_SERVIC E} ,
PERMISSION_ WRITE_EXTERNAL_STORAGE ) ;
PERMISSION_ VPN ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
throw new RuntimeException ( e ) ;
throw new RuntimeException ( e ) ;
}
}
@ -105,7 +107,7 @@ public class PermsAskerActivity extends Activity {
public void onRequestPermissionsResult ( int requestCode ,
public void onRequestPermissionsResult ( int requestCode ,
String permissions [ ] , int [ ] grantResults ) {
String permissions [ ] , int [ ] grantResults ) {
switch ( requestCode ) {
switch ( requestCode ) {
case PERMISSION_ WRITE_EXTERNAL_STORAGE : {
case PERMISSION_ VPN : {
// If request is cancelled, the result arrays are empty.
// If request is cancelled, the result arrays are empty.
if ( grantResults . length > 0
if ( grantResults . length > 0
& & grantResults [ 0 ] = = PackageManager . PERMISSION_GRANTED ) {
& & grantResults [ 0 ] = = PackageManager . PERMISSION_GRANTED ) {
@ -119,7 +121,7 @@ public class PermsAskerActivity extends Activity {
// permission denied, boo! Disable the
// permission denied, boo! Disable the
// functionality that depends on this permission.
// functionality that depends on this permission.
textview_retry . setText ( " SD card write permission denied, you need to allow this to continue") ;
textview_retry . setText ( " you need to allow this to continue") ;
textview_retry . setVisibility ( TextView . VISIBLE ) ;
textview_retry . setVisibility ( TextView . VISIBLE ) ;
button_request_write_ext_storage_perms . setVisibility ( Button . VISIBLE ) ;
button_request_write_ext_storage_perms . setVisibility ( Button . VISIBLE ) ;
}
}
@ -158,8 +160,8 @@ public class PermsAskerActivity extends Activity {
}
}
try {
try {
method_requestPermissions . invoke ( this ,
method_requestPermissions . invoke ( this ,
new String [ ] { Manifest . permission . WRITE_EXTERNAL_STORAG E} ,
new String [ ] { Manifest . permission . BIND_VPN_SERVIC E} ,
PERMISSION_ WRITE_EXTERNAL_STORAGE ) ;
PERMISSION_ VPN ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
throw new RuntimeException ( e ) ;
throw new RuntimeException ( e ) ;
}
}