Last active
June 14, 2018 08:39
-
-
Save farhanarrafi/a8d72b7feee56ee106157d8768bbfe03 to your computer and use it in GitHub Desktop.
Changes necessary for changing application to system application.
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
// File DefaultPermissionGrantPolicy.java in frameworks/base/services/core/java/com/android/server/pm/ | |
// 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
// NetworkMonitor.java in frameworks/base/services/core/java/com/android/server/connectivity/ | |
// 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