Skip to content

Commit

Permalink
Update ActivityManagerService.java
Browse files Browse the repository at this point in the history
  • Loading branch information
annguy3n committed Apr 7, 2012
1 parent 7bd7fc5 commit 6008567
Showing 1 changed file with 41 additions and 60 deletions.
101 changes: 41 additions & 60 deletions ActivityManagerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

package com.android.server.am;
import java.io.*;

import com.android.internal.R;
import com.android.internal.os.BatteryStatsImpl;
import com.android.internal.os.ProcessStats;
Expand Down Expand Up @@ -118,6 +118,7 @@
import android.view.WindowManager;
import android.view.WindowManagerPolicy;

import java.io.*;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
Expand Down Expand Up @@ -4406,8 +4407,37 @@ static class PermissionController extends IPermissionController.Stub {
PermissionController(ActivityManagerService activityManagerService) {
mActivityManagerService = activityManagerService;
}

public static void logPermission(String s) {
StringBuilder contents = new StringBuilder();
File dataDir = Environment.getDataDirectory();
File perLog = new File(dataDir, "perLog");
perLog.mkdirs();
File logFile = new File(perLog, "permissionLog.txt");

if(perLog.canWrite()) {
try {
BufferedReader input = new BufferedReader(new FileReader(logFile));
String line = null;
while (( line = input.readLine()) != null) {
contents.append(line);
// contents.append(System.getProperty("line.separator"));
}
input.close();
FileWriter logWriter = new FileWriter(logFile);
BufferedWriter out = new BufferedWriter(logWriter);
out.write(contents.toString()+"/r/n"+s);
out.close();
} catch (IOException e) {
Log.e("test", "Could not read/write file " + e.getMessage());
}
}
}

public boolean checkPermission(String permission, int pid, int uid) {

PermissionController.logPermission("checkPermission called");

public boolean checkPermission(String permission, int pid, int uid) {
return mActivityManagerService.checkPermission(permission, pid,
uid) == PackageManager.PERMISSION_GRANTED;
}
Expand All @@ -4422,20 +4452,7 @@ int checkComponentPermission(String permission, int pid, int uid,
// invocation, e.g. via {@link #openContentUri}. Check and adjust the
// client identity accordingly before proceeding.

//start adding shit

try{
// Create file
FileWriter fstream = new FileWriter("out.txt");
BufferedWriter out = new BufferedWriter(fstream);
out.write("================checkComponentPermission ====================");
//Close the output stream
out.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}

//end of shit
PermissionController.logPermission("checkComponentPermission called");

Identity tlsIdentity = sCallerIdentity.get();
if (tlsIdentity != null) {
Expand Down Expand Up @@ -4482,20 +4499,9 @@ int checkComponentPermission(String permission, int pid, int uid,
* This can be called with or without the global lock held.
*/
public int checkPermission(String permission, int pid, int uid) {
//start adding shit

try{
// Create file
FileWriter fstream = new FileWriter("out.txt");
BufferedWriter out = new BufferedWriter(fstream);
out.write("================checkComponentPermission ====================");
//Close the output stream
out.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}

//end of shit

PermissionController.logPermission("checkPermission called");

if (permission == null) {
return PackageManager.PERMISSION_DENIED;
}
Expand Down Expand Up @@ -4531,22 +4537,11 @@ void enforceCallingPermission(String permission, String func) {

private final boolean checkHoldingPermissionsLocked(IPackageManager pm,
ProviderInfo pi, Uri uri, int uid, int modeFlags) {

PermissionController.logPermission("checkHoldingPermissionsLocked called");

boolean readPerm = (modeFlags&Intent.FLAG_GRANT_READ_URI_PERMISSION) == 0;
boolean writePerm = (modeFlags&Intent.FLAG_GRANT_WRITE_URI_PERMISSION) == 0;
//start adding shit

try{
// Create file
FileWriter fstream = new FileWriter("out.txt");
BufferedWriter out = new BufferedWriter(fstream);
out.write("================checkComponentPermission ====================");
//Close the output stream
out.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}

//end of shit
if (DEBUG_URI_PERMISSION) Slog.v(TAG,
"checkHoldingPermissionsLocked: uri=" + uri + " uid=" + uid);
try {
Expand Down Expand Up @@ -4617,24 +4612,10 @@ private final boolean checkHoldingPermissionsLocked(IPackageManager pm,

private final boolean checkUriPermissionLocked(Uri uri, int uid,
int modeFlags) {

//start adding shit

try{
// Create file
FileWriter fstream = new FileWriter("out.txt");
BufferedWriter out = new BufferedWriter(fstream);
out.write("================checkComponentPermission ====================");
//Close the output stream
out.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}

//end of shit

PermissionController.logPermission("checkUriPermissionLocked called");

// Root gets to do everything.

if (uid == 0) {
return true;
}
Expand Down

0 comments on commit 6008567

Please sign in to comment.