Created
August 16, 2013 18:39
-
-
Save hnakagawa/6252397 to your computer and use it in GitHub Desktop.
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
package com.example.hackpolicy; | |
import android.app.Service; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.os.IBinder; | |
import android.util.Log; | |
import android.view.Window; | |
import android.view.WindowManager; | |
import java.lang.reflect.Method; | |
/** | |
* Created by Hirofumi Nakagawa on 13/08/17. | |
*/ | |
public class HackService extends Service{ | |
private static final String TAG = HackService.class.getSimpleName(); | |
private static final String POLICY_IMPL_CLASS_NAME = | |
"com.android.internal.policy.impl.Policy"; | |
private static final Object sPolicy; | |
static { | |
// Pull in the actual implementation of the policy at run-time | |
try { | |
Class policyClass = Class.forName(POLICY_IMPL_CLASS_NAME); | |
sPolicy = policyClass.newInstance(); | |
} catch (ClassNotFoundException ex) { | |
throw new RuntimeException( | |
POLICY_IMPL_CLASS_NAME + " could not be loaded", ex); | |
} catch (InstantiationException ex) { | |
throw new RuntimeException( | |
POLICY_IMPL_CLASS_NAME + " could not be instantiated", ex); | |
} catch (IllegalAccessException ex) { | |
throw new RuntimeException( | |
POLICY_IMPL_CLASS_NAME + " could not be instantiated", ex); | |
} | |
} | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
try { | |
Method method = sPolicy.getClass().getMethod("makeNewWindow", Context.class); | |
Window window = (Window)method.invoke(sPolicy, this); | |
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, | |
WindowManager.LayoutParams.FLAG_FULLSCREEN); | |
//need additional hack... | |
} catch (Exception exp) { | |
Log.e(TAG, exp.getMessage() + "", exp); | |
} | |
} | |
public int onStartCommand(Intent intent, int flags, int startId) { | |
return START_STICKY; | |
} | |
@Override | |
public IBinder onBind(Intent intent) { | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment