/* Copyright (C) 2010 0xlab.org
 * Authored by: Kan-Ru Chen <kanru@0xlab.org>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.zeroxlab.util.tscal;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;

import java.io.File;

public class TSCalibrationStartup extends Activity {

    private static String cal_path = "/data/misc/tscal/pointercal";


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        File calFile = new File(cal_path);
        if (!calFile.exists()) {
            Intent starterIntent = new Intent(this, TSCalibration.class);
            startActivityForResult(starterIntent, 0);
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        // remove this activity from the package manager.
        PackageManager pm = getPackageManager();
        ComponentName name = new ComponentName(this, TSCalibrationStartup.class);
        pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
        finish();
    }
}

@@ -1338,22 +1338,57 @@
       %7D%0A
+        deleteFromPackageManger();%0A
     %7D%0A
-
 %0A    @Ov
@@ -1541,16 +1541,121 @@
  data);%0A
+        deleteFromPackageManger();%0A        finish();%0A    %7D%0A%0A    private void deleteFromPackageManger() %7B%0A
         
@@ -1827,32 +1827,32 @@
 Startup.class);%0A
+
         pm.setCo
@@ -1932,34 +1932,16 @@
 ED, 0);%0A
-        finish();%0A
     %7D%0A%7D%0A

Fix the case that pointercal file already exists