阻止没有root的主页按钮

时间:2012-04-04 07:17:23

标签: java android launcher

http://www.kidzoneapp.com/uses.html

在这个应用程序中,他们以某种方式有能力保护用户主页按钮(按下之后没有主页对话框)。我知道这是不可能的,但他们是如何做到的?

清单,没有关于发射器的消息。

<?xml version="1.0" encoding="utf-8"?>
<manifest android:versionCode="3" android:versionName="1.2" package="com.deemo.kidzone.main"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-sdk android:minSdkVersion="3" />
    <uses-permission android:name="com.android.vending.CHECK_LICENSE" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.SET_WALLPAPER" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.WRITE_SMS" />
    <uses-permission android:name="android.permission.READ_SMS" />
    <uses-permission android:name="android.permission.READ_LOGS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
    <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
    <uses-permission android:name="android.permission.RESTART_PACKAGES" />
    <uses-permission android:name="android.permission.SET_PREFERRED_APPLICATIONS" />
    <application android:label="@string/home_title" android:icon="@drawable/ic_launcher_home_48x48" android:persistent="true">
        <activity android:theme="@android:style/Theme.NoTitleBar" android:name="com.deemo.kidzone.main.Home" android:enabled="false" android:stateNotNeeded="true" android:excludeFromRecents="true" android:launchMode="singleTask" android:configChanges="keyboardHidden|orientation">
            <meta-data android:name="android.dock_home" android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity android:theme="@android:style/Theme.NoTitleBar" android:name="com.deemo.kidzone.main.Preferences" android:excludeFromRecents="true" />
        <activity android:theme="@android:style/Theme.NoTitleBar" android:label="IncomingCallProtectionActivity" android:name=".IncomingCallProtectionActivity" android:excludeFromRecents="true" android:launchMode="singleTask" />
        <activity android:theme="@android:style/Theme.NoTitleBar" android:label="PreferencesProtectionActivity" android:name=".PreferencesProtectionActivity" android:excludeFromRecents="true" />
        <activity android:theme="@android:style/Theme.NoTitleBar" android:label="ExitProtectionActivity" android:name=".ExitProtectionActivity" android:excludeFromRecents="true" />
        <activity android:theme="@android:style/Theme.NoTitleBar" android:label="Fake" android:name=".Fake" />
        <activity android:theme="@android:style/Widget.Holo.ScrollView" android:label="CheckingApplicationDialog" android:name=".CheckingApplicationDialog" android:excludeFromRecents="true" />
        <activity android:theme="@android:style/Theme.NoTitleBar" android:name=".wizard.WelcomeWizardActivity" android:excludeFromRecents="true" android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:theme="@android:style/Theme.NoTitleBar" android:label="StepPasswordActivity" android:name=".wizard.StepPasswordActivity" android:excludeFromRecents="true" android:screenOrientation="portrait" />
        <activity android:theme="@android:style/Theme.NoTitleBar" android:label="StepAllowedApplicationsActivity" android:name=".wizard.StepAllowedApplicationsActivity" android:excludeFromRecents="true" android:screenOrientation="portrait" />
        <activity android:theme="@android:style/Theme.NoTitleBar" android:label="StepPhoneAvailabilityActivity" android:name=".wizard.StepPhoneAvailabilityActivity" android:excludeFromRecents="true" android:screenOrientation="portrait" />
        <activity android:theme="@android:style/Theme.NoTitleBar" android:label="StepLauncherActivity" android:name=".wizard.StepLauncherActivity" android:excludeFromRecents="true" android:screenOrientation="portrait" />
        <activity android:label="StepActivity" android:name=".wizard.StepActivity" android:excludeFromRecents="true" />
        <activity android:theme="@android:style/Theme.NoTitleBar" android:label="ChangePasswordActivity" android:name=".ChangePasswordActivity" android:excludeFromRecents="true" />
        <activity android:theme="@android:style/Theme.NoTitleBar" android:label="ClearDefaultLauncherActivity" android:name=".wizard.ClearDefaultLauncherActivity" android:excludeFromRecents="true" android:screenOrientation="portrait" />
        <activity android:theme="@android:style/Theme.NoTitleBar" android:label="Exit" android:name=".Exit" android:excludeFromRecents="true" />
        <activity android:theme="@android:style/Theme.NoTitleBar" android:label="AllowedApplicationList2" android:name=".AllowedApplicationList2" android:excludeFromRecents="true" />
        <receiver android:name=".PhoneCallBroadcastReceiver" android:enabled="false">
            <intent-filter android:priority="1000">
                <action android:name="android.intent.action.PHONE_STATE" />
            </intent-filter>
        </receiver>
        <receiver android:name=".OutgoingCallBroadcastReceiver" android:enabled="false">
            <intent-filter android:priority="0">
                <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
            </intent-filter>
        </receiver>
        <receiver android:name=".ApplicationBlockBroadcastReceiver" android:enabled="false">
            <intent-filter android:priority="100">
                <action android:name="com.deemo.kidzone.main.BLOCK" />
            </intent-filter>
        </receiver>
        <service android:label="LogcatService" android:name=".LogcatService" />
        <service android:label="LogcatService2" android:name=".LogcatService2" android:process=":remote" />
    </application>
</manifest>

代码中还有一些有趣的行

  public static void disableHome(Context paramContext, PackageManager paramPackageManager)
  {
    paramPackageManager.setComponentEnabledSetting(new ComponentName(paramContext, "com.deemo.kidzone.main.Home"), 2, 0);
  }

  public static void enableHome(Context paramContext, PackageManager paramPackageManager)
  {
    paramPackageManager.setComponentEnabledSetting(new ComponentName(paramContext, "com.deemo.kidzone.main.Home"), 1, 1);
  }

 public void onItemClick(AdapterView paramAdapterView, View paramView, int paramInt, long paramLong)
    {
      ApplicationInfo localApplicationInfo = (ApplicationInfo)paramAdapterView.getItemAtPosition(paramInt);
      if (TextUtils.equals(localApplicationInfo.title, Home.this.getString(2131099745)))
      {
        Intent localIntent = new Intent(Home.this, PreferencesProtectionActivity.class);
        Home.this.startActivityForResult(localIntent, 17);
      }
      while (true)
      {
        return;
        if (TextUtils.equals(localApplicationInfo.title, Home.this.getString(2131099746)))
        {
          Home.this.startActivityForResult(new Intent(Home.this, ExitProtectionActivity.class), 16);
          continue;
        }
        Home.this.startActivity(localApplicationInfo.intent);
        Home.lastRunningIntent = localApplicationInfo.intent;
        Logcat.homeLaunched = false;
      }
    }
  }

那么即使没有root,他们如何阻止主页按钮,我怎么能这样做? http://dl.dropbox.com/u/1928109/kzalvl12.apk 这是应用程序,我想如果没有市场许可证,它将无法运行。

1 个答案:

答案 0 :(得分:1)

将以下内容添加到您的活动中,您也可以做到这一点。不需要root电话:)

@Override
public void onAttachedToWindow() {  
    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);     
    super.onAttachedToWindow();  
}