Last active
June 14, 2018 07:00
-
-
Save farhanarrafi/45887c41c8d4df5223903344f14c2be9 to your computer and use it in GitHub Desktop.
Changes in: services/core/java/com/android/server/connectivity/NetworkMonitor.java and core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add the floowing code below the other declarations: | |
private static final Set<String> POCKETALK_PERMISSIONS = new ArraySet<>(); | |
static { | |
POCKETALK_PERMISSIONS.add(Manifest.permission.READ_EXTERNAL_STORAGE); | |
POCKETALK_PERMISSIONS.add(Manifest.permission.WRITE_EXTERNAL_STORAGE); | |
POCKETALK_PERMISSIONS.add(Manifest.permission.RECORD_AUDIO); | |
POCKETALK_PERMISSIONS.add(Manifest.permission.ACCESS_FINE_LOCATION); | |
POCKETALK_PERMISSIONS.add(Manifest.permission.READ_PHONE_STATE); | |
} | |
// Add the following code is synchronized (mService.mPackages) {} block of method grantDefaultSystemHandlerPermissions: | |
// Pocketalk | |
PackageParser.Package pocketalkPackage = getDefaultProviderAuthorityPackageLPr( | |
"com.sourcenext.pocketalk", userId); | |
if(pocketalkPackage != null){ | |
grantRuntimePermissionsLPw(pocketalkPackage, POCKETALK_PERMISSIONS, true, userId); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Add this line bleow other import statements | |
import android.content.ComponentName; | |
//2. Find the method processMessage in private class <b>MaybeNotifyState and comment out the follwoing lines. | |
final Intent intent = new Intent( | |
ConnectivityManager.ACTION_CAPTIVE_PORTAL_SIGN_IN); | |
// OneAddressPerFamilyNetwork is not parcelable across processes. | |
intent.putExtra(ConnectivityManager.EXTRA_NETWORK, new Network(mNetwork)); | |
intent.putExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL, | |
new CaptivePortal(new ICaptivePortal.Stub() { | |
@Override | |
public void appResponse(int response) { | |
if (response == APP_RETURN_WANTED_AS_IS) { | |
mContext.enforceCallingPermission( | |
android.Manifest.permission.CONNECTIVITY_INTERNAL, | |
"CaptivePortal"); | |
} | |
sendMessage(CMD_CAPTIVE_PORTAL_APP_FINISHED, response); | |
} | |
})); | |
intent.putExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL_URL, | |
mLastPortalProbeResult.detectUrl); | |
intent.putExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL_USER_AGENT, | |
mCaptivePortalUserAgent); | |
intent.setFlags( | |
Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); | |
mContext.startActivityAsUser(intent, UserHandle.CURRENT); | |
//3. Add the following lines after the commented lines: | |
Intent intent = new Intent(); | |
intent.setComponent(new ComponentName("com.sourcenext.pocketalk", "com.sourcenext.pocketalk.activity.WifiCaptivePortalActivity")); | |
mContext.startActivity(intent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment